Commit 561c75a3 authored by 潘栩锋's avatar 潘栩锋 🚴

小修补

parent e65227a2
......@@ -141,12 +141,12 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
this.FilmLength = mRDetect.FilmLength;
Misc.BindingOperations.SetBinding(mCurrRDetect, "BufTotalTime", () =>
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.BufTotalTime), () =>
{
DataMaxMinute = (int)(mCurrRDetect.BufTotalTime.TotalMinutes);
});
Misc.BindingOperations.SetBinding(mCurrRDetect, "RotationCnt", () =>
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.RotationCnt), () =>
{
if (mRDetect.RotationCnt < minRotationCnt)
{
......@@ -158,7 +158,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
}
});
Misc.BindingOperations.SetBinding(mCurrRDetect, "RenZiJiaPeriod", () =>
Misc.BindingOperations.SetBinding(mCurrRDetect, nameof(mCurrRDetect.RenZiJiaPeriod), () =>
{
DataMinMinute = (int)(mRDetect.RenZiJiaPeriod.TotalMinutes * (minRotationCnt - 1));
DataBestMinute = (int)Math.Round((mRDetect.RenZiJiaPeriod.TotalMinutes * 3));
......@@ -178,10 +178,17 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
if (IsCaling)
return false;
TimeSpan getBufTime = TimeSpan.FromMinutes(getDataMinute);
if ( getBufTime > mCurrRDetect.BufTotalTime)
if (getBufTime > mCurrRDetect.BufTotalTime)
//return false;
{
getBufTime = mCurrRDetect.BufTotalTime;
}
if (getBufTime < TimeSpan.FromMinutes(DataMinMinute)) {
return false;
}
dataBegin = DateTime.Now - getBufTime;
IsDownloading = true;
IsDataReady = false;
......@@ -193,9 +200,9 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
void DownloadData_limit()
{
Msg = $"下载 转向信号数据 [{dataBegin} - Now]....";
mCurrRDetect.GetLimitList(dataBegin, (object AsyncState, object retData) =>
mCurrRDetect.GetLimitList(dataBegin, (object asyncContext, object retData) =>
{
Action act = AsyncState as Action;
Action act = asyncContext as Action;
var p = retData as GetLimitListReponse;
if ((p.datas == null) || p.datas.Count() < 2)
{
......@@ -350,7 +357,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
Value = v
});
}
OnPropertyChanged("VelocityValues");
OnPropertyChanged(nameof(VelocityValues));
Velocity1 = VelocityValues.Average(tv => tv.Value);
if (mCurrRDetect.Is3D)
......@@ -386,7 +393,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
foreach (var tv in FilmLength3DValues)
tv.Value -= min_f;
OnPropertyChanged("FilmLength3DValues");
OnPropertyChanged(nameof(FilmLength3DValues));
UpdateNewFilmLength3D();
}
......
......@@ -84,7 +84,7 @@
</StackPanel>
</StackPanel>
<TextBlock Text="旋转次数不足2次不能下载数据" Style="{StaticResource TextBlockStyle_FieldContent}" Foreground="Red" VerticalAlignment="Center"
<TextBlock Text="旋转次数不足2次,不能下载数据" Style="{StaticResource TextBlockStyle_FieldContent}" Foreground="Red" VerticalAlignment="Center"
Visibility="{Binding Cfl.IsCanDownload,Converter={StaticResource visbilityconv},ConverterParameter=HiddenWhenTrue}"
/>
</Grid>
......@@ -101,13 +101,15 @@
<TextBlock Style="{StaticResource CardTitleStyle}" Text="厚度趋势"/>
<lvc:CartesianChart Height="150" DisableAnimations="True" Margin="5" Hoverable="False" DataTooltip="{x:Null}" >
<lvc:CartesianChart.Series>
<lvc:LineSeries Values="{Binding ThicknessValues}" Configuration="{Binding MapperTv}" />
<lvc:LineSeries Values="{Binding ThicknessValues}"
PointGeometry="{x:Null}"
Configuration="{Binding MapperTv}" />
</lvc:CartesianChart.Series>
<lvc:CartesianChart.AxisX>
<lvc:Axis LabelFormatter="{Binding DateTimeFormatter}"
x:Name="axisXAD"
Foreground="DarkSlateBlue"
Sections="{Binding LimitValues,Converter={StaticResource limit2SectionsConv}}"
Sections="{Binding LimitSections}"
/>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
......
......@@ -10,7 +10,7 @@ using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FLY.Thick.Blowing.UI.Fix.Client
{
......@@ -22,8 +22,8 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
/// <summary>
/// 画在图上的 限位信号
/// </summary>
[PropertyChanged.DoNotCheckEquality]
public List<TimeValue> LimitValues { get; private set; }
public ChartValues<TimeValue> LimitValues { get; } = new ChartValues<TimeValue>();
/// <summary>
/// 画在图上的 速度曲线,限制最多100个数据
/// </summary>
......@@ -51,6 +51,8 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
/// 转换为分区号单位的 每幅图
/// </summary>
public SeriesCollection FrameSeries { get; } = new SeriesCollection();
public SectionsCollection LimitSections { get; } = new SectionsCollection();
#endregion
#region 参数
......@@ -153,13 +155,13 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
Misc.BindingOperations.SetBinding(rdetect, "Is3D", this, "Is3D");
Misc.BindingOperations.SetBinding(rdetect, nameof(rdetect.Is3D), this, nameof(Is3D));
Misc.BindingOperations.SetBinding(Cfl, "FilmLength", this, "FilmLength");
Misc.BindingOperations.SetBinding(Cfl, "VelocityFilter", this, "VelocityFilter");
Misc.BindingOperations.SetBinding(Cfl, "Velocity1", this, "Velocity1");
Misc.BindingOperations.SetBinding(Cfl, nameof(Cfl.FilmLength), this, nameof(FilmLength));
Misc.BindingOperations.SetBinding(Cfl, nameof(Cfl.VelocityFilter), this, nameof(VelocityFilter));
Misc.BindingOperations.SetBinding(Cfl, nameof(Cfl.Velocity1), this, nameof(Velocity1));
Misc.BindingOperations.SetBinding(Cfl,
new string[] { "DataMaxMinute", "DataMinMinute", "DataBestMinute" },
new string[] { nameof(Cfl.DataMaxMinute), nameof(Cfl.DataMinMinute),nameof(Cfl.DataBestMinute) },
() => {
if (GetDataMinute < Cfl.DataMinMinute)
GetDataMinute = Cfl.DataBestMinute;
......@@ -188,65 +190,77 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
private void CalFilmLen_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "LimitValues")
{
LimitValues = Cfl.LimitValues;
}
else if (e.PropertyName == "VelocityValues")
if (e.PropertyName == nameof(Cfl.LimitValues))
{
var vList = Cfl.LimitValues;
VelocityValues.Clear();
var vList = Cfl.VelocityValues;
for (int i = 0; i < 100; i++)
//var newList = GetLimitedList(vList, 100);
LimitSections.Clear();
for (int i = 0; i < vList.Count(); i++) {
var value = vList[i];
var axisSection = new AxisSection()
{
int idx = vList.Count() * i / 100;
if (idx >= vList.Count()) idx = vList.Count() - 1;
VelocityValues.Add(vList[idx]);
StrokeThickness = 1,
DataLabel = true,
DisableAnimations = true,
DataLabelForeground = new SolidColorBrush(Colors.White),
Opacity = 1,
Stroke = new SolidColorBrush(Colors.Orange),
};
if (value.Value == 1)
axisSection.Stroke = new SolidColorBrush(Colors.DarkBlue);
axisSection.Value = value.Time.Ticks;
LimitSections.Add(axisSection);
}
//LimitValues.Clear();
//LimitValues.AddRange(newList);
}
else if (e.PropertyName == nameof(Cfl.VelocityValues))
{
var vList = Cfl.VelocityValues;
VAvg = vList.Average(tv => tv.Value);
VMax = vList.Max(tv => tv.Value);
VMin = vList.Min(tv => tv.Value);
var newList = GetLimitedList(vList,100);
VelocityValues.Clear();
VelocityValues.AddRange(newList);
}
else if (e.PropertyName == "ThicknessValues")
else if (e.PropertyName == nameof(Cfl.ThicknessValues))
{
var vList = Cfl.ThicknessValues;
var newList = GetLimitedList(vList, 100);
ThicknessValues.Clear();
var tList = Cfl.ThicknessValues;
for (int i = 0; i < 100; i++)
{
int idx = tList.Count() * i / 100;
if (idx >= tList.Count()) idx = tList.Count() - 1;
ThicknessValues.Add(tList[idx]);
ThicknessValues.AddRange(newList);
}
}
else if (e.PropertyName == "FilmLength3DValues")
{
FilmLength3DValues.Clear();
var tList = Cfl.FilmLength3DValues;
for (int i = 0; i < 100; i++)
else if (e.PropertyName == nameof(Cfl.FilmLength3DValues))
{
int idx = tList.Count() * i / 100;
if (idx >= tList.Count()) idx = tList.Count() - 1;
FilmLength3DValues.Add(tList[idx]);
}
var vList = Cfl.FilmLength3DValues;
var newList = GetLimitedList(vList, 100);
FAvg = tList.Average(tv => tv.Value);
FMax = tList.Max(tv => tv.Value);
FMin = tList.Min(tv => tv.Value);
FAvg = vList.Average(tv => tv.Value);
FMax = vList.Max(tv => tv.Value);
FMin = vList.Min(tv => tv.Value);
FilmLength3DValues.Clear();
FilmLength3DValues.AddRange(newList);
}
else if (e.PropertyName == "CurrFilmLength3D")
else if (e.PropertyName == nameof(Cfl.CurrFilmLength3D))
{
CurrFilmLength3D.Clear();
foreach (var d in Cfl.CurrFilmLength3D)
CurrFilmLength3D.Add(d);
CurrFilmLength3D.AddRange(Cfl.CurrFilmLength3D);
}
else if (e.PropertyName == "NewFilmLength3D")
else if (e.PropertyName == nameof(Cfl.NewFilmLength3D))
{
NewFilmLength3D.Clear();
foreach (var d in Cfl.NewFilmLength3D)
NewFilmLength3D.Add(d);
NewFilmLength3D.AddRange(Cfl.NewFilmLength3D);
}
else if (e.PropertyName == "Frames")
else if (e.PropertyName == nameof(Cfl.Frames))
{
FrameSeries.Clear();
for (int i = 0; i < Cfl.Frames.Count(); i++)
......@@ -270,6 +284,28 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
}
}
/// <summary>
/// 从原始数据队列平均获取100个数据
/// </summary>
/// <param name="orgList"></param>
/// <returns></returns>
List<T> GetLimitedList<T>(List<T> orgList, int limitCnt) {
var tList = orgList;
var newList = new List<T>();
if (tList.Count < limitCnt)
{
limitCnt = tList.Count;
}
for (int i = 0; i < limitCnt; i++)
{
int idx = tList.Count() * i / limitCnt;
if (idx >= tList.Count()) idx = tList.Count() - 1;
newList.Add(tList[idx]);
}
return newList;
}
void Init1()
{
#region 界面配置
......
......@@ -8,6 +8,7 @@ using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FLY.Thick.Blowing.UI.Fix.Client
{
......@@ -18,7 +19,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
/// <summary>
/// 画在图上的 限位信号
/// </summary>
public List<TimeValue> LimitValues { get; } = new List<TimeValue>();
public ChartValues<TimeValue> LimitValues { get; } = new ChartValues<TimeValue>();
/// <summary>
/// 画在图上的 速度曲线,限制最多100个数据
/// </summary>
......@@ -46,6 +47,7 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
/// 转换为分区号单位的 每幅图
/// </summary>
public SeriesCollection FrameSeries { get; } = new SeriesCollection();
public SectionsCollection LimitSections { get; } = new SectionsCollection();
#endregion
#region 参数
......@@ -150,6 +152,30 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
#endregion
}
/// <summary>
/// 从原始数据队列平均获取100个数据
/// </summary>
/// <param name="orgList"></param>
/// <returns></returns>
List<T> GetLimitedList<T>(List<T> orgList, int limitCnt)
{
var tList = orgList;
var newList = new List<T>();
if (tList.Count < limitCnt)
{
limitCnt = tList.Count;
}
for (int i = 0; i < limitCnt; i++)
{
int idx = tList.Count() * i / limitCnt;
if (idx >= tList.Count()) idx = tList.Count() - 1;
newList.Add(tList[idx]);
}
return newList;
}
/// <summary>
/// 产生虚拟数据
/// </summary>
......@@ -291,24 +317,24 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
double thick;
if (n == 0)
thick = thicks[idx];
thick = thicks[idx] / 100.0;
else
thick = thicks[thicks.Count() - 1 - idx];
thick = thicks[thicks.Count() - 1 - idx] / 100.0;
tList.Add(new TimeValue()
{
Time = dt,
Value = thick / 100.0
});
Value = thick
}) ;
if (lList.Count() == 0)
{
lList.Add(new TimeValue() { Time = dt_begin + RInterval, Value = n });
lList.Add(new TimeValue() { Time = dt_begin + RInterval, Value = thick });
}
else if (dt >= lList.Last().Time)
{
lList.Add(new TimeValue() { Time = lList.Last().Time + RInterval, Value = n });
lList.Add(new TimeValue() { Time = lList.Last().Time + RInterval, Value = thick });
}
}
......@@ -360,46 +386,34 @@ namespace FLY.Thick.Blowing.UI.Fix.Client
#endregion
foreach (var tv in lList)
{
LimitValues.Add(tv);
}
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("LimitValues"));
for (int i = 0; i < 100; i++)
{
int idx = vList.Count() * i / 100;
if (idx >= vList.Count()) idx = vList.Count() - 1;
VelocityValues.Add(vList[idx]);
}
// LimitValues.AddRange(lList);
for (int i = 0; i < 100; i++)
for (int i = 0; i < lList.Count(); i++)
{
int idx = tList.Count() * i / 100;
if (idx >= tList.Count()) idx = tList.Count() - 1;
ThicknessValues.Add(tList[idx]);
}
for (int i = 0; i < 100; i++)
var value = lList[i];
var axisSection = new AxisSection()
{
int idx = fList.Count() * i / 100;
if (idx >= fList.Count()) idx = fList.Count() - 1;
FilmLength3DValues.Add(fList[idx]);
StrokeThickness = 1,
DataLabel = true,
DisableAnimations = true,
DataLabelForeground = new SolidColorBrush(Colors.White),
Opacity = 1,
Stroke = new SolidColorBrush(Colors.Orange),
};
if (value.Value == 1)
axisSection.Stroke = new SolidColorBrush(Colors.DarkBlue);
axisSection.Value = value.Time.Ticks;
LimitSections.Add(axisSection);
}
for (int i = 0; i < 100; i++)
{
int idx = currFilmLength.Count() * i / 100;
if (idx >= currFilmLength.Count()) idx = currFilmLength.Count() - 1;
CurrFilmLength3D.Add(currFilmLength[idx]);
}
for (int i = 0; i < 100; i++)
{
int idx = setFilmLength.Count() * i / 100;
if (idx >= setFilmLength.Count()) idx = setFilmLength.Count() - 1;
NewFilmLength3D.Add(setFilmLength[idx]);
}
VelocityValues.AddRange(GetLimitedList(vList, 100));
ThicknessValues.AddRange(GetLimitedList(tList, 100));
FilmLength3DValues.AddRange(GetLimitedList(fList, 100));
CurrFilmLength3D.AddRange(GetLimitedList(currFilmLength, 100));
NewFilmLength3D.AddRange(GetLimitedList(setFilmLength, 100));
for (int i = 0; i < frames.Count(); i++)
{
......
......@@ -225,20 +225,11 @@ namespace FLY.Thick.Blowing.IService
/// </summary>
public class RollCell
{
/// <summary>
/// 创建副本
/// </summary>
/// <returns></returns>
public RollCell Clone()
{
RollCell r = new RollCell();
r.dt = dt;
return r;
}
public DateTime dt;
public DateTime sysTime;
public override string ToString()
{
return dt.ToString();
return $"{sysTime}";
}
}
......
......@@ -225,6 +225,7 @@ namespace FLY.Thick.Blowing.Server
List<double> mFilmLength3D = new List<double>();
#endregion
FlyADBase.IFlyAD flyad;
/// <summary>
///
/// </summary>
......@@ -410,7 +411,8 @@ namespace FLY.Thick.Blowing.Server
/// <param name="flyad"></param>
public void Init(FlyADBase.IFlyAD flyad)
{
flyad.IStatusChangedEvent += new FlyADBase.IStatusChangedEventHandler(flyad_IStatusChangedEvent);
this.flyad = flyad;
this.flyad.IStatusChangedEvent += new FlyADBase.IStatusChangedEventHandler(flyad_IStatusChangedEvent);
FObjBase.PollModule.Current.Poll_Config(FObjBase.PollModule.POLL_CONFIG.ADD, new FObjBase.PollModule.PollHandler(OnPoll));
}
......@@ -914,17 +916,13 @@ namespace FLY.Thick.Blowing.Server
//信号的状态
bool status = !Misc.MyBase.CHECKBIT(e.IStatus, Roll_bit - 1);
//TODO,不使用AD盒的时间
//DateTime dt = e.Time;//信号更新发生的时间
DateTime dt = DateTime.Now;
if (status)//1->0 触发!!!
{
mRollList.RAdd(
new RollCell()
{
dt = dt
dt = DateTime.Now,//用于时间定位
sysTime = e.Time,//用于算速度
});
......@@ -932,6 +930,7 @@ namespace FLY.Thick.Blowing.Server
TouchFilmInfoChanged();
}
}
void flyad_IStatusChangedEvent(object sender, FlyADBase.IStatusChangedEventArgs e)
{
update_limit(e);
......@@ -1075,22 +1074,21 @@ namespace FLY.Thick.Blowing.Server
{
if (mRollList.Count > 1)
{
DateTime dt1 = mRollList[mRollList.Count - 1].dt;
DateTime sysTime0 = flyad.Now;
DateTime sysTime1 = mRollList[mRollList.Count - 1].sysTime;
int cnt = 5;
if (cnt > mRollList.Count)
cnt = mRollList.Count;
DateTime sysTime4 = mRollList[mRollList.Count - (cnt - 1)].dt;
DateTime sysTime5 = mRollList[mRollList.Count - cnt].sysTime;
DateTime dt2 = mRollList[mRollList.Count - cnt].dt;
TimeSpan ts_last = TimeSpan.FromTicks((sysTime1 - sysTime5).Ticks / (cnt - 1));//5次的平均滤波
DateTime dt11 = mRollList[mRollList.Count - (cnt - 1)].dt;
TimeSpan ts_last = TimeSpan.FromTicks((dt1 - dt2).Ticks / (cnt - 1));//5次的平均滤波
//因为没有使用AD盒的时间,所以可以用DateTime.Now 比较
TimeSpan ts_now = TimeSpan.FromTicks((DateTime.Now - dt11).Ticks / (cnt - 1));
//未来的 5次的平均滤波 时间差
TimeSpan ts_now = TimeSpan.FromTicks((sysTime0 - sysTime4).Ticks / (cnt - 1));
TimeSpan ts_max;
if (ts_now > (ts_last + ts_last))
if (ts_now > (ts_last + ts_last))//超过了2倍的时间,肯定是慢下来了
{
ts_max = ts_now;
}
......@@ -1101,7 +1099,7 @@ namespace FLY.Thick.Blowing.Server
FilmVelocity = RollPerimeter / 1000.0 / ts_max.TotalMinutes;
BufTotalTime = DateTime.Now - mRollList[0].dt;
BufTotalTime = DateTime.Now - mRollList[0].dt;//这里用回电脑的时间
}
}
/// <summary>
......@@ -1111,12 +1109,13 @@ namespace FLY.Thick.Blowing.Server
{
if (mRollList.Count > 0)
{
DateTime dt = mRollList[mRollList.Count - 1].dt;
DateTime dt = mRollList.Last().dt;
//因为没有使用AD盒的时间,所以可以用DateTime.Now 比较
TimeSpan ts = DateTime.Now - dt;
if (ts.TotalMinutes > 1)//1min
if (ts.TotalMinutes > 0.5)
{
//大于1分钟,也没有一个信号,复位
//大于0.5分钟,也没有一个信号,复位
//辊周长314mm, 0.5min = 0.6m/min, 太慢了
Clear();
}
}
......@@ -1536,6 +1535,9 @@ namespace FLY.Thick.Blowing.Server
/// <returns></returns>
double RollList_GetPosition(int idx, DateTime dt)
{
DateTime dt1 = mRollList[idx + 1].dt;
double position1 = (idx + 1) * RollPerimeter;
DateTime dt2 = mRollList[idx].dt;
......@@ -1550,6 +1552,40 @@ namespace FLY.Thick.Blowing.Server
/// <returns></returns>
double RollList_GetVelocity(int idx)
{
//TODO
//速度是准的
//if (idx>5)
//{
// DateTime sysTime0 = flyad.Now;
// DateTime sysTime1 = mRollList[mRollList.Count - 1].sysTime;
// int cnt = 5;
// if (cnt > mRollList.Count)
// cnt = mRollList.Count;
// DateTime sysTime4 = mRollList[mRollList.Count - (cnt - 1)].dt;
// DateTime sysTime5 = mRollList[mRollList.Count - cnt].sysTime;
// TimeSpan ts_last = TimeSpan.FromTicks((sysTime1 - sysTime5).Ticks / (cnt - 1));//5次的平均滤波
// //未来的 5次的平均滤波 时间差
// TimeSpan ts_now = TimeSpan.FromTicks((sysTime0 - sysTime4).Ticks / (cnt - 1));
// TimeSpan ts_max;
// if (ts_now > (ts_last + ts_last))//超过了2倍的时间,肯定是慢下来了
// {
// ts_max = ts_now;
// }
// else
// {
// ts_max = ts_last;
// }
// FilmVelocity = RollPerimeter / 1000.0 / ts_max.TotalMinutes;
// BufTotalTime = DateTime.Now - mRollList[0].dt;//这里用回电脑的时间
//}
DateTime dt1 = mRollList[idx + 1].dt;
DateTime dt2 = mRollList[idx].dt;
......
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