Commit 4032422a authored by 潘栩锋's avatar 潘栩锋 🚴

在 PLCProxySystem.plc_NameDataChanged 加入线程同步!!!

parent b0445e04
......@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
namespace FObjBase
{
......@@ -220,6 +221,7 @@ namespace FObjBase
}
static DateTime dt_last = DateTime.Now;
System.Windows.Threading.DispatcherTimer timer;
public Dispatcher Dispatcher;
/// <summary>
/// 不需要自己创建实例,因为已经创建了静态的对象
/// </summary>
......@@ -236,6 +238,7 @@ namespace FObjBase
mylock = false;
}
};
Dispatcher = timer.Dispatcher;
}
bool mylock=false;
/// <summary>
......
......@@ -44,10 +44,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="LiveCharts, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
<HintPath>..\packages\LiveCharts.0.9.7\lib\net40\LiveCharts.dll</HintPath>
<HintPath>..\..\packages\LiveCharts.0.9.7\lib\net40\LiveCharts.dll</HintPath>
</Reference>
<Reference Include="LiveCharts.Wpf, Version=0.9.7.0, Culture=neutral, PublicKeyToken=0bc1f845d1ebb8df, processorArchitecture=MSIL">
<HintPath>..\packages\LiveCharts.Wpf.0.9.7\lib\net40\LiveCharts.Wpf.dll</HintPath>
<HintPath>..\..\packages\LiveCharts.Wpf.0.9.7\lib\net40\LiveCharts.Wpf.dll</HintPath>
</Reference>
<Reference Include="PropertyChanged2, Version=2.5.13.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\..\packages\PropertyChanged2.Fody.2.5.13\lib\net40\PropertyChanged2.dll</HintPath>
......
......@@ -155,7 +155,7 @@ namespace FLY.Modbus.WithThread
TimeSpan elapsed = stopwatch.Elapsed;
ActUpdateInterval = elapsed;
stopwatch.Restart();
if (!UpdateReadData())
{
if (cts.IsCancellationRequested)//可能是外部强制关闭
......
......@@ -5,6 +5,7 @@ using System.ComponentModel;
using System.Linq;
using System.Text;
using FLY.Modbus;
using System.Windows.Threading;
namespace FLY.OBJComponents.Server
{
......@@ -98,12 +99,18 @@ namespace FLY.OBJComponents.Server
//var plc = sender as Modbus.WithThread.ModbusMapper_Client;
//object value = plc.GetNameData(e.Owener, e.PropertyName);
//这是从PLC 更新过来的,不需要向PLC写入
isShield = true;
//Misc.PropertiesManager.SetValue(e.Owener, e.PropertyName, value);
Misc.PropertiesManager.SetValue(dr.owner, dr.propertyName, dr.value);// ce.PropertyName, value);
isShield = false;
}
FObjBase.PollModule.Current.Dispatcher.Invoke(new SetValueHandler((owner, propertyname, value) =>
{
isShield = true;
Misc.PropertiesManager.SetValue(dr.owner, dr.propertyName, dr.value);
isShield = false;
}), dr.owner, dr.propertyName, dr.value);
}
delegate void SetValueHandler(object owner, string propertyname, object value);
/// <summary>
/// 设置更新计划
/// </summary>
......
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