Commit 0769412b authored by 潘栩锋's avatar 潘栩锋 🚴

1. 有bug FlyData_Mix TryParse 有问题

parent 00caf7e5
......@@ -96,7 +96,7 @@ namespace FLY.Weight.UI.Client
// %
DataGridTextColumn dgtc2 = new DataGridTextColumn()
{
Binding = new Binding() { Path = new PropertyPath($"Items[{i}].PDisp"), StringFormat = "{0:F1}" }
Binding = new Binding() { Path = new PropertyPath($"Items[{i}].PDisp"), StringFormat = "{0:F3}" }
};
StackPanel sp2 = new StackPanel() { Orientation = Orientation.Horizontal };
sp2.Children.Add(
......
......@@ -62,6 +62,9 @@ namespace FLY.Weight.Common
if (items.Length < (2 + 2 * 4))
return false;
int idx = 0;
DateTime t;
float f;
......@@ -78,6 +81,10 @@ namespace FLY.Weight.Common
Total = f;
idx++;
//翻译
//header += "," + n + "#";
//header += "," + n + "#%";
for (int i = 0; i < 4; i++)
{
if (!float.TryParse(items[idx], out f))//?#重量
......
......@@ -31,6 +31,12 @@ namespace FLY.Weight.Server
public ObservableCollection<WeighterC> Items { get; } = new ObservableCollection<WeighterC>();
/// <summary>
/// 每1秒保存一次配料数据, 一共10秒。
/// 当卸料时,提起3秒前的数据保存
/// </summary>
List<Dictionary<WeighterC, FlyData_Mix>> mix10 = new List<Dictionary<WeighterC, FlyData_Mix>>();
public WeighterAccessory Accessory { get; } = new WeighterAccessory();
private PLCProxySystem plcos = new PLCProxySystem();
......@@ -111,7 +117,7 @@ namespace FLY.Weight.Server
{
"BucketValveIsOpen",
"MixDisp",
"IsMixSave",
//"IsMixSave",
"ClearProduction",
"CumulativeProduction",
"CurrentFlow",
......@@ -166,8 +172,8 @@ namespace FLY.Weight.Server
{
//LastCumulativeProductions.Add(w, w.CumulativeProduction);
w.PropertyChanged += WeightSystem_MBServer_PropertyChanged;
MixBuffer.Add(w, new BufferStorage<FlyData_Mix>(w.Number + "_mixbuffer.csv", 5, 2000));
RollMixBuffer.Add(w, new BufferStorage<FlyData_Mix>(w.Number + "_rollmixbuffer.csv", 1, 400));
MixBuffer.Add(w, new BufferStorage<FlyData_Mix>($"{w.Number}_mixbuffer.csv", 5, 2000));
RollMixBuffer.Add(w, new BufferStorage<FlyData_Mix>($"{w.Number}_rollmixbuffer.csv", 1, 400));
}
//--------------------------------------------------------------------------------
//Test();
......@@ -175,8 +181,35 @@ namespace FLY.Weight.Server
plcos.Init();
this.PropertyChanged += WeightSystem_PropertyChanged;
}
FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, OnPoll_SaveMix, TimeSpan.FromSeconds(1));
}
void OnPoll_SaveMix()
{
Dictionary<WeighterC, FlyData_Mix> mix = new Dictionary<WeighterC, FlyData_Mix>();
foreach (WeighterC w in Items)
{
//记录
FlyData_Mix f = new FlyData_Mix
{
Time = DateTime.Now,
Total = w.MixDisp
};
for (int i = 0; i < w.Ingredients.Count; i++)
{
FlyData_MixItem item = new FlyData_MixItem()
{
Disp = w.Ingredients[i].MixDisp,
PDisp = w.Ingredients[i].MixPDisp
};
f.Items.Add(item);
}
mix.Add(w, f);
}
mix10.Add(mix);
if (mix10.Count > 10)
mix10.RemoveAt(0);
}
private void WeightSystem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (GetSavePropertyNames().Contains(e.PropertyName))
......@@ -184,14 +217,25 @@ namespace FLY.Weight.Server
Save();
}
}
//每隔1秒记录,w.MixDisp, Ingredients[i].(MixDisp,MixPDisp) 这些的最大值
//每隔1秒记录,w.MixDisp, Ingredients[i].(MixDisp,MixPDisp),保存10s
//当卸料时,提取2s前的数据保存!!!!
private void WeightSystem_MBServer_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
WeighterC w = sender as WeighterC;
if (e.PropertyName == "IsMixSave")
if (e.PropertyName == "BucketValveIsOpen")
{
if (w.BucketValveIsOpen)
{
if (w.IsMixSave)
FlyData_Mix f_last=null;
//提取之前的记录
if (mix10.Count > 3)
{
f_last = mix10[mix10.Count - 3][w];
}
//记录
FlyData_Mix f = new FlyData_Mix
{
......@@ -209,6 +253,17 @@ namespace FLY.Weight.Server
f.Items.Add(item);
}
if (f_last!=null && f_last.Total > f.Total)
{
//没错,用以前的是对的!!!!
f.Total = f_last.Total;
for (int i = 0; i < w.Ingredients.Count; i++)
{
f.Items[i].Disp = f_last.Items[i].Disp;
f.Items[i].PDisp = f_last.Items[i].PDisp;
}
}
MixBuffer[w].Add(f);
}
}
......
......@@ -26,24 +26,24 @@ namespace WpfApplication1
//FLY.FeedbackRenZiJia.UI.Client.UIModule.Page_DynArea dynArea = new FLY.FeedbackRenZiJia.UI.Client.UIModule.Page_DynArea();
//FLY.IBC.UI.Client.UIModule.Page_DynArea dynArea = new FLY.IBC.UI.Client.UIModule.Page_DynArea();
FLY.Winder.UI.Client.UIModule.Page_DynArea dynArea = new FLY.Winder.UI.Client.UIModule.Page_DynArea();
//FLY.Weight.UI.Client.UIModule.Page_DynArea dynArea = new FLY.Weight.UI.Client.UIModule.Page_DynArea();
//FLY.Winder.UI.Client.UIModule.Page_DynArea dynArea = new FLY.Winder.UI.Client.UIModule.Page_DynArea();
FLY.Weight.UI.Client.UIModule.Page_DynArea dynArea = new FLY.Weight.UI.Client.UIModule.Page_DynArea();
dynArea.Init(0);
Frame f = new Frame();
f.Content = dynArea;
stackpanel_dynarea.Children.Add(f);
FLY.Winder.UI.Client.UIModule.MenuSelect menu = new FLY.Winder.UI.Client.UIModule.MenuSelect();
//FLY.Weight.UI.Client.UIModule.MenuSelect menu = new FLY.Weight.UI.Client.UIModule.MenuSelect();
//FLY.Winder.UI.Client.UIModule.MenuSelect menu = new FLY.Winder.UI.Client.UIModule.MenuSelect();
FLY.Weight.UI.Client.UIModule.MenuSelect menu = new FLY.Weight.UI.Client.UIModule.MenuSelect();
menu.Init(0);
stackpanel_toolbox.Children.Add(menu);
//FLY.IBC.UI.Client.UIModule.Page_Main p = new FLY.IBC.UI.Client.UIModule.Page_Main();
FLY.Winder.UI.Client.UIModule.Page_Main p = new FLY.Winder.UI.Client.UIModule.Page_Main();
//FLY.Weight.UI.Client.UIModule.Page_Main p = new FLY.Weight.UI.Client.UIModule.Page_Main();
//FLY.Winder.UI.Client.UIModule.Page_Main p = new FLY.Winder.UI.Client.UIModule.Page_Main();
FLY.Weight.UI.Client.UIModule.Page_Main p = new FLY.Weight.UI.Client.UIModule.Page_Main();
//FLY.Weight.UI.Client.UIModule.FlowGraph p = new FLY.Weight.UI.Client.UIModule.FlowGraph();
p.Init(0);
......
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