Commit 39ba4115 authored by 潘栩锋's avatar 潘栩锋 🚴

1.修复 旋转使用了PLC,但计算膜距离时,没有使用PLC的全局脉冲信息

2.修复 计算角度时,使用了旋转速度。 非常不对。 改用了 全局脉冲 与 时间推算角度
parent 9e43ed2d
......@@ -648,9 +648,18 @@ namespace FLY.Thick.Blowing.UI
return false;
}
var posData = mRPosList[p_index + 1];
TimeSpan ts = posData.Time - dt;
int globalRPos = (int)(posData.GlobalRPos - ts.TotalSeconds * posData.Speed);
var posData0 = mRPosList[p_index];
var posData1 = mRPosList[p_index + 1];
int globalRPos;
if ((posData1.Time - posData0.Time) < TimeSpan.FromSeconds(0.2))
{
//数据异常
globalRPos = posData1.GlobalRPos;
}
else
{
globalRPos = (int)(posData0.GlobalRPos + (posData1.GlobalRPos - posData0.GlobalRPos) * (dt - posData0.Time).TotalSeconds / (posData1.Time - posData0.Time).TotalSeconds);
}
int no;
......
......@@ -145,11 +145,10 @@ namespace FLY.Thick.Blowing.UI
});
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.Is3D), this, nameof(Is3D));
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.IsRPosMode), this, nameof(IsRPosMode));
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.IsRPosMode2), this, nameof(IsRPosMode));
}
ActionQueue actionQueue = new ActionQueue();
public bool DownloadData()
{
......@@ -172,7 +171,7 @@ namespace FLY.Thick.Blowing.UI
actionQueue.Add(DownloadData_roll);
actionQueue.Add(DownloadData_ad);
if (mCurrRDetect.IsRPosMode)
if (mCurrRDetect.IsRPosMode2)
actionQueue.Add(DownloadData_rPos);
if (mCurrRDetect.Is3D)
......@@ -359,7 +358,7 @@ namespace FLY.Thick.Blowing.UI
mLimitList,
CurrFilmLength3D,
mCurrRDetect.DefaultTime,
mCurrRDetect.IsRPosMode,
mCurrRDetect.IsRPosMode2,
mCurrRDetect.OrgRPos,
mCurrRDetect.RPosOfR,
mRPosList);
......@@ -367,7 +366,7 @@ namespace FLY.Thick.Blowing.UI
UpdateLimitValues();
UpdateThicknessValues();
UpdateVelocityValues(VelocityFilter);
if (mCurrRDetect.IsRPosMode) {
if (mCurrRDetect.IsRPosMode2) {
UpdateAngleValues();
}
UpdateThkList();
......
......@@ -267,9 +267,13 @@ namespace FLY.Thick.Blowing.UI
else if (e.PropertyName == nameof(Cfl.Frames))
{
FrameSeries.Clear();
for (int i = 0; i < Cfl.Frames.Count(); i++)
//限制数量在4条内
int cnt = 4;
if (cnt > Cfl.Frames.Count())
cnt = Cfl.Frames.Count();
int beginIndex = Cfl.Frames.Count() - cnt;
for (int i = beginIndex; i < Cfl.Frames.Count(); i++)
{
var frame = Cfl.Frames[i];
string title = $"{((frame.Direction == Misc.DIRECTION.FORWARD) ? "正" : "反")}" +
$" [{frame.RotationCnt}]";
......
......@@ -183,6 +183,7 @@ namespace FLY.Thick.Blowing.UI
public DateTime DefaultTime { get; set; }
public bool IsRPosMode2 => throw new NotImplementedException();
public event PropertyChangedEventHandler PropertyChanged;
......
......@@ -107,6 +107,11 @@ namespace FLY.Thick.Blowing.Client
/// </summary>
public bool IsRPosMode { get; set; }
/// <summary>
/// 使用旋转位置, 它是 IsPlcMode || IsRPosMode
/// </summary>
public bool IsRPosMode2 { get; set; }
/// <summary>
/// 离开限位 到 撞下一个限位 的 旋转架转动总脉冲 单位 脉冲;
/// 通过看 转向信号列表,可以看到
......
......@@ -80,6 +80,7 @@ namespace FLY.Thick.Blowing.IService
/// 使用收卷PLC的数据,得到旋转位置,速度数据
/// </summary>
bool IsPlcMode { get; set; }
/// <summary>
/// 旋转服务地址
/// </summary>
......@@ -90,6 +91,11 @@ namespace FLY.Thick.Blowing.IService
/// </summary>
bool IsRPosMode { get; set; }
/// <summary>
/// 使用旋转位置, 它是 IsPlcMode || IsRPosMode
/// </summary>
bool IsRPosMode2 { get; }
/// <summary>
/// 离开限位 到 撞下一个限位 的 旋转架转动总脉冲 单位 脉冲;
/// 通过看 转向信号列表,可以看到
......
......@@ -112,6 +112,11 @@ namespace FLY.Thick.Blowing.Server
/// </summary>
public bool IsRPosMode { get; set; }
/// <summary>
/// 使用旋转位置, 它是 IsPlcMode || IsRPosMode
/// </summary>
public bool IsRPosMode2 => IsPlcMode || IsRPosMode;
/// <summary>
/// 人字架 离开限位 到 撞下一个限位 的 旋转架转动总脉冲 单位 脉冲
/// </summary>
......@@ -944,7 +949,7 @@ namespace FLY.Thick.Blowing.Server
/// </summary>
void OnPoll_updateAngle()
{
GetAngle(DateTime.Now, false, out double angle, out DIRECTION direction, out int rotationCnt, out bool inCV);
GetAngleByTime(DateTime.Now, false, out double angle, out DIRECTION direction, out int rotationCnt, out bool inCV);
Angle = angle;
}
/// <summary>
......@@ -1413,7 +1418,7 @@ namespace FLY.Thick.Blowing.Server
/// <param name="inCV">在恒速区</param>
bool GetAngle(DateTime dt, bool modifyparam, out double angle, out Misc.DIRECTION direction, out int rotationCnt, out bool inCV)
{
if (IsRPosMode)
if (IsRPosMode2)
{
return GetAngleByRPos(dt, out angle, out direction, out rotationCnt, out inCV);
}
......@@ -1575,9 +1580,18 @@ namespace FLY.Thick.Blowing.Server
return false;
}
var posData = mRPosList[p_index + 1];
TimeSpan ts = posData.Time - dt;
int globalRPos = (int)(posData.GlobalRPos - ts.TotalSeconds * posData.Speed);
var posData0 = mRPosList[p_index];
var posData1 = mRPosList[p_index + 1];
int globalRPos;
if ((posData1.Time - posData0.Time) < TimeSpan.FromSeconds(0.2))
{
//数据异常
globalRPos = posData1.GlobalRPos;
}
else
{
globalRPos = (int)(posData0.GlobalRPos + (posData1.GlobalRPos - posData0.GlobalRPos) * (dt - posData0.Time).TotalSeconds / (posData1.Time - posData0.Time).TotalSeconds);
}
int no;
......
......@@ -130,7 +130,7 @@ namespace FLY.Thick.BlowingScan.UI.Client
});
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.Is3D), this, nameof(Is3D));
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.IsRPosMode), this, nameof(IsRPosMode));
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.IsRPosMode2), this, nameof(IsRPosMode));
}
......@@ -152,10 +152,10 @@ namespace FLY.Thick.BlowingScan.UI.Client
actionQueue.Add(DownloadData_limit);
actionQueue.Add(DownloadData_roll);
if (IsRPosMode)
if (mCurrRDetect.IsRPosMode2)
actionQueue.Add(DownloadData_rPos);
if (Is3D)
if (mCurrRDetect.Is3D)
actionQueue.Add(DownloadData_CurrFilmLength3D);
actionQueue.Add(DownloadData_BufList);
......@@ -389,19 +389,19 @@ namespace FLY.Thick.BlowingScan.UI.Client
mCurrRDetect.RollPerimeter,
mCurrRDetect.RenZiJiaPeriod,
mCurrRDetect.FilmLength,
Is3D,
mCurrRDetect.Is3D,
mRollList,
mLimitList,
CurrFilmLength3D,
mCurrRDetect.DefaultTime,
IsRPosMode,
mCurrRDetect.IsRPosMode2,
mCurrRDetect.OrgRPos,
mCurrRDetect.RPosOfR,
mRPosList);
UpdateLimitValues();
UpdateVelocityValues(VelocityFilter);
if (mCurrRDetect.IsRPosMode)
if (mCurrRDetect.IsRPosMode2)
{
UpdateAngleValues();
}
......
......@@ -183,6 +183,7 @@ namespace FLY.Thick.BlowingScan.UI.Client
public DateTime DefaultTime { get; set; }
public bool IsRPosMode2 => throw new NotImplementedException();
public event PropertyChangedEventHandler PropertyChanged;
......
......@@ -60,7 +60,7 @@
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="地址:端口"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}">
<Run Text="{Binding PlcAddr,Mode=OneWay}"/>:<Run Text="{Binding Port,Mode=OneWay}"/>
<Run Text="{Binding PlcAddr,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
</StackPanel>
......@@ -84,7 +84,7 @@
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="速度" />
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent}">
<Run Text="{Binding RSpeed,StringFormat={}{0:F1}}"/>°/s
<Run Text="{Binding RSpeed,StringFormat={}{0:F1}}"/>p/s
</TextBlock>
</StackPanel>
</StackPanel>
......@@ -109,9 +109,6 @@
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="复位信号" />
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Led}" Tag="{Binding IsOrgSign}" />
<TextBlock Style="{StaticResource Styles.Text.FieldContent}">
<Run Text="{Binding RPosAtOrgSign,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
......@@ -146,9 +143,8 @@
<DataGrid.Columns>
<DataGridTextColumn Header="时间" Binding="{Binding Time,StringFormat={}{0:HH:mm:ss.f}}" />
<DataGridTextColumn Header="信号" Binding="{Binding No}" />
<DataGridTextColumn Header="全局脉冲" Binding="{Binding RPosGlobal,StringFormat={}{0:F0}}"/>
<DataGridTextColumn Header="相对脉冲" Binding="{Binding RPos,StringFormat={}{0:F0}}"/>
<DataGridTextColumn Header="速度%" Binding="{Binding RotaryVelocity,StringFormat={}{0:F1}}"/>
<DataGridTextColumn Header="脉冲" Binding="{Binding RPosGlobal,StringFormat={}{0:F0}}"/>
<DataGridTextColumn Header="速度" Binding="{Binding RotaryVelocity,StringFormat={}{0:F1}}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
......
......@@ -63,7 +63,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
/// 旋转塔电机当前速度 °/秒, +为正方向, -为反反向
/// </summary>
public double RSpeed { get; protected set; }
#endregion
public bool IsError => string.IsNullOrEmpty(ErrMsg);
......@@ -90,6 +90,12 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
/// </summary>
HslCommunication.Core.Net.NetworkDeviceBase device;
class AngleAndTime
{
public double angle;
public TimeSpan time;
}
List<AngleAndTime> angles = new List<AngleAndTime>();
double lastAngle=double.NaN;
Stopwatch stopwatch_lastAngle = new Stopwatch();
public RotaryPlc()
......@@ -256,17 +262,31 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
//第1次 获取到 angle
lastAngle = Angle;
stopwatch_lastAngle.Restart();
angles.Clear();
angles.Add(new AngleAndTime() { angle = Angle, time = TimeSpan.Zero });
}
else {
if (stopwatch_lastAngle.Elapsed >= TimeSpan.FromSeconds(0.5))
if (stopwatch_lastAngle.Elapsed >= TimeSpan.FromSeconds(1))
{
double sec = stopwatch_lastAngle.Elapsed.TotalSeconds;
var ts = stopwatch_lastAngle.Elapsed;
stopwatch_lastAngle.Restart();
RSpeed = (Angle - lastAngle) / sec;
var time2 = angles.Last().time + ts;
angles.Add(new AngleAndTime() { angle = Angle, time = time2 });
IsForw = (Angle > lastAngle);
IsBackw = (Angle < lastAngle);
lastAngle = Angle;
IsForw = RSpeed > 0;
IsBackw = RSpeed < 0;
int cnt = 5;
if (cnt > angles.Count())
cnt = angles.Count();
ts = time2 - angles[angles.Count() - cnt].time;
if (ts.TotalSeconds > 0)
{
RSpeed = (Angle - angles[angles.Count() - cnt].angle) / ts.TotalSeconds;
}
if (angles.Count() > 6)
angles.RemoveAt(0);
}
}
}
......
......@@ -118,7 +118,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
{
this.plc = plc;
RPosOfR = 360;//永远是360
RPosOfR = 3600;//永远是3600
RPosAtOrgSign = 0;
RPosAtOrgSign1 = 0;
......@@ -128,11 +128,13 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsPlcConnected), this, nameof(IsPlcConnected));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.Angle), () => {
Angle = plc.Angle;
RPosGlobal = plc.Angle;
RPosGlobal = plc.Angle*10;
});
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsForw), this, nameof(IsForw));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.IsBackw), this, nameof(IsBackw));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.RSpeed),this, nameof(RSpeed));
Misc.BindingOperations.SetBinding(this.plc, nameof(plc.RSpeed),()=> {
RSpeed = plc.RSpeed * 10;
});
updateMinuteOfR();
this.PropertyChanged += RotarySystem_PropertyChanged;
......@@ -171,6 +173,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
}
}
bool is1stUpdateIsRotaryOn = true;
bool lastIsForw;
bool lastIsBackw;
void updateIsRotaryOn()
......@@ -191,32 +194,30 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
IsRotaryOn = true;
stopwatch_IsRotaryOn.Restart();
}
if (lastIsForw != IsForw) {
if (is1stUpdateIsRotaryOn)
{
is1stUpdateIsRotaryOn = false;
lastIsForw = IsForw;
lastIsBackw = IsBackw;
}
else
{
if (lastIsForw && !IsForw && Angle > 100)
{
//正方向运行停下来
IsTurnSign1 = true;
AddSign(1);
}
else if (IsForw && !lastIsForw)
else if (IsForw && !lastIsForw)
{
//开始正方向运行, 等于松开 转向信号0
IsTurnSign0 = false;
}
lastIsForw = IsForw;
}
if (lastIsBackw != IsBackw)
{
lastIsBackw = IsBackw;
}
else
{
if (lastIsBackw && !IsBackw && Angle < -100)
{
//反方向运行停下来
......@@ -229,8 +230,8 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
IsTurnSign1 = false;
}
lastIsBackw = IsBackw;
}
}
IsOrgSign = Math.Abs(Angle) < 2;
}
......@@ -253,7 +254,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
void AddSign(SignCell sign)
{
Signs.Insert(0, sign);
while (Signs.Count > 100)
while (Signs.Count > 25)
Signs.RemoveAt(Signs.Count() - 1);
}
void AddSign(int no)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment