Commit 0073273f authored by 潘栩锋's avatar 潘栩锋 🚴

修复 单组数据不会更新

parent 26a3e5aa
......@@ -31,9 +31,9 @@
<StackPanel Margin="3" Grid.Column="1" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="当前产量" Style="{StaticResource TextBlockStyle_title}" Margin="3,0" />
<TextBlock >
<Run Text="{Binding CurrentFlowAuto,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text}" FontSize="30" />
<Run Text="kg" Style="{StaticResource RunStyle_unit}" />
<TextBlock Visibility="{Binding ScrewIsAutoMode,Converter={StaticResource visbilityconv}}">
<Run Text="{Binding CurrentFlowAuto,StringFormat={}{0:F0}}" Style="{StaticResource RunStyle_text}" FontSize="30" />
<Run Text="kg" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
......@@ -71,7 +71,7 @@
<Run Text="%" Style="{StaticResource RunStyle_unit}" />
</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Margin="3">
<StackPanel Grid.Column="1" Margin="3" Visibility="{Binding ScrewIsAutoMode,Converter={StaticResource visbilityconv}}">
<TextBlock Text="设置比例" Style="{StaticResource TextBlockStyle_title_activity}"/>
<TextBlock >
<Run Text="{Binding ScrewPDispAuto,StringFormat={}{0:F1}}" Style="{StaticResource RunStyle_text_activity}"/>
......
......@@ -78,46 +78,16 @@ namespace FLY.Weight2.UI.Client.UiModule
this.DataContext = this.WeightSystemService.Items[idx];
for (int i = 0; i < this.WeightSystemService.Items.Count(); i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.WeightSystemService.PLCos,
this.WeightSystemService.Items[i],
item_update_propertynames);
setPlan_items.Add(plan);
}
if (weightSystemService is WeightSystemServiceClient)
(weightSystemService as WeightSystemServiceClient).ResetItemsEvent += MWeighterCsService_ResetItemsEvent;
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
this.WeightSystemService.PLCos,
this.WeightSystemService.Items[idx],
item_update_propertynames);
setPlan_items.Add(plan);
}
private void MWeighterCsService_ResetItemsEvent()
{
//把多出来的删除
int remove_cnt = setPlan_items.Count() - WeightSystemService.Items.Count();
if (remove_cnt > 0)
{
for (int i = 0; i < remove_cnt; i++)
{
SetPLCUpdatePlan plan = setPlan_items[setPlan_items.Count() - 1 - i];
plan.Dispose();
}
setPlan_items.RemoveRange(setPlan_items.Count() - remove_cnt, remove_cnt);
}
else
{
int start_idx = setPlan_items.Count();
int add_cnt = -remove_cnt;
for (int i = 0; i < add_cnt; i++)
{
SetPLCUpdatePlan plan = new SetPLCUpdatePlan(
WeightSystemService.PLCos,
WeightSystemService.Items[start_idx + i],
item_update_propertynames);
setPlan_items.Add(plan);
}
}
}
public static string[] item_update_propertynames = new string[] {
"CurrentFlow",
"ScrewPDisp",
......
......@@ -90,6 +90,9 @@
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
......@@ -23,7 +23,10 @@ namespace FLY.Weight2.Server.OBJProxy
public OBJProxy(int objsys_idx, TDGage gage)
{
TDGage mGage = gage;
weightSystemOBJProxy = new WeightSystem_OBJProxy(objsys_idx, gage.mData);
weightSystemOBJProxy = new WeightSystem_OBJProxy(
objsys_idx,
OBJ_INTERFACE.OBJ_INTERFACE.WEIGHTS_OBJ_ID,
gage.mData);
mFlowListOBJProxy = new Buffer_OBJProxy<Lc_Flow>(
objsys_idx,
......
......@@ -20,9 +20,9 @@ namespace FLY.Weight2.Server.OBJProxy
public WeightSystem_OBJProxy(int objsys_idx, WeightSystem data):base(objsys_idx)
public WeightSystem_OBJProxy(int objsys_idx, UInt32 id, WeightSystem data):base(objsys_idx)
{
ID = OBJ_INTERFACE.OBJ_INTERFACE.WEIGHTS_OBJ_ID;
ID = id;
this.data = data;
//--------------------------------------------------------------
......
......@@ -73,7 +73,10 @@ namespace FLY.Weight2.Server
/// 报警配置
/// </summary>
ErrorConf errorConf;
/// <summary>
/// 周期保存Ibc数据
/// </summary>
PeriodicallySaveData<Lc_Flow> psdFlow;
public WeightSystem()
{
Load();
......@@ -133,9 +136,6 @@ namespace FLY.Weight2.Server
//});
//--------------------------------------------------------------------------------
//step 3 历史数据记录
this.PropertyChanged += (s, e) =>
{
if (e.PropertyName == "FlowInterval")
......@@ -144,9 +144,10 @@ namespace FLY.Weight2.Server
}
};
FObjBase.PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, OnPoll, TimeSpan.FromSeconds(1));
//--------------------------------------------------------------------------------
//step 3 历史数据记录
//添加任务
for (int i = 0; i < Items.Count(); i++)
{
......@@ -160,82 +161,44 @@ namespace FLY.Weight2.Server
}
PLCos.SetPlan("Accessory", new string[] { "TotalFlow" }, 0);
psdFlow = new PeriodicallySaveData<Lc_Flow>();
psdFlow.Init(
FlowInterval,
this.historyDb.AddFlowRange,
() => {
if (!PLCos.IsConnectedWithPLC)
return null;
var v = Items[0].BinWeight;
var v1 = Items[1].BinWeight;
var v2 = Items[2].BinWeight;
if (Accessory.TotalFlow < 5)//没有生产
return null;
//记录数据
Lc_Flow lc_Flow = new Lc_Flow
{
Time = DateTime.Now,
Total = Math.Round(Accessory.TotalFlow, 4),
Items = new Lc_FlowItem[Items.Count]
};
for (int i = 0; i < Items.Count; i++)
{
lc_Flow.Items[i] = new Lc_FlowItem
{
Flow = Math.Round(Items[i].CurrentFlow, 4),
ScrewPDisp = Math.Round(Items[i].ScrewPDisp, 2),
ScrewMotorFreq = Math.Round(Items[i].ScrewMotorFreq, 1)
};
}
return lc_Flow;
});
//--------------------------------------------------------------------------------
//last step PLC 更新计划服务初始化
plcos.Init();
}
Stopwatch stopwatch_flowInterval = new Stopwatch();
Stopwatch stopwatch_1min = new Stopwatch();
List<Lc_Flow> lcFlows_1min = new List<Lc_Flow>();
void OnPoll()
{
if (stopwatch_1min.IsRunning && stopwatch_1min.Elapsed >= TimeSpan.FromSeconds(20))//限制,最快每20秒写入一次数据库
{
//启动了1min 且到点了
if (lcFlows_1min.Count > 0)
{
historyDb.AddFlowRange(lcFlows_1min);
lcFlows_1min.Clear();
stopwatch_1min.Restart();
}
else
{
stopwatch_1min.Reset();
}
}
if (!stopwatch_flowInterval.IsRunning)
{
stopwatch_flowInterval.Start();
return;
}
else
{
if (stopwatch_flowInterval.Elapsed < TimeSpan.FromSeconds(FlowInterval))
return;
else
stopwatch_flowInterval.Restart();
}
if (!PLCos.IsConnectedWithPLC)//连接断开
return;
if (Accessory.TotalFlow < 5)//没有生产
return;
//记录数据
Lc_Flow lc_Flow = new Lc_Flow
{
Time = DateTime.Now,
Total = Math.Round(Accessory.TotalFlow, 4),
Items = new Lc_FlowItem[Items.Count]
};
for (int i = 0; i < Items.Count; i++)
{
lc_Flow.Items[i] = new Lc_FlowItem
{
Flow = Math.Round(Items[i].CurrentFlow, 4),
ScrewPDisp = Math.Round(Items[i].ScrewPDisp, 2),
ScrewMotorFreq = Math.Round(Items[i].ScrewMotorFreq, 1)
};
}
//写入数据库
if (!stopwatch_1min.IsRunning)
{
//第1次立刻写入
historyDb.AddFlow(lc_Flow);
stopwatch_1min.Start();
}
else
{
//第2次,1分钟后才能保存
lcFlows_1min.Add(lc_Flow);
}
}
void AddConfigFile()
{
......
......@@ -598,7 +598,7 @@ Global
{CC941BE1-1A92-4830-B8DD-E743939BA8BA} = {B3B684FF-D5C5-441F-B69C-E75841AE17F6}
{973F0EED-3181-4FB9-ABD6-196A9E816B77} = {95225870-0DAF-491E-B79C-FAB26A134DF8}
{276EE86A-0961-4C69-A38A-696F4D76E931} = {95225870-0DAF-491E-B79C-FAB26A134DF8}
{3340B6F4-74B5-4A0E-8912-951222642E77} = {95225870-0DAF-491E-B79C-FAB26A134DF8}
{3340B6F4-74B5-4A0E-8912-951222642E77} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{A539505D-9AC0-426B-A9A0-197DF50598B0} = {2488C4FB-3677-405B-BE1B-C9F532708DE3}
{EC11911F-D868-49EA-BDA4-9F91CA7186AF} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
{DE0879A1-2723-4FA1-8E59-A22B1154503D} = {1262AB40-4503-469A-A00B-50C1AE6A3BA6}
......
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