现场更改2
This commit is contained in:
@@ -9,7 +9,6 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Services
|
||||
@@ -22,12 +21,6 @@ namespace CapMachine.Wpf.Services
|
||||
|
||||
public HighSpeedDataService HighSpeedDataService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 读写锁,用于保护 ListCanDbcModel 的并发访问
|
||||
/// 支持多个读取操作同时进行,写入操作独占
|
||||
/// </summary>
|
||||
private readonly ReaderWriterLockSlim _dbcModelLock = new ReaderWriterLockSlim();
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
@@ -63,25 +56,17 @@ namespace CapMachine.Wpf.Services
|
||||
/// </summary>
|
||||
public void InitCanConfig(CanLinConfigPro selectedCanLinConfigPro)
|
||||
{
|
||||
_dbcModelLock.EnterWriteLock();
|
||||
try
|
||||
//赋值配置数据
|
||||
SelectedCanLinConfigPro = selectedCanLinConfigPro;
|
||||
//为DBC实时数据关联配置的名称
|
||||
foreach (var item in SelectedCanLinConfigPro.CanLinConfigContents)
|
||||
{
|
||||
//赋值配置数据
|
||||
SelectedCanLinConfigPro = selectedCanLinConfigPro;
|
||||
//为DBC实时数据关联配置的名称
|
||||
foreach (var item in SelectedCanLinConfigPro.CanLinConfigContents)
|
||||
var FindData = ListCanDbcModel.FindFirst(a => a.SignalName == item.SignalName);
|
||||
if (FindData != null)
|
||||
{
|
||||
var FindData = ListCanDbcModel.FindFirst(a => a.SignalName == item.SignalName);
|
||||
if (FindData != null)
|
||||
{
|
||||
FindData.Name = item.Name;
|
||||
}
|
||||
FindData.Name = item.Name;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dbcModelLock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -242,22 +227,14 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
if (ToomossCanDrive.IsCycleRevice == false)
|
||||
{
|
||||
_dbcModelLock.EnterReadLock();
|
||||
try
|
||||
if (ListCanDbcModel.Count > 0)
|
||||
{
|
||||
if (ListCanDbcModel.Count > 0)
|
||||
{
|
||||
ToomossCanDrive.IsCycleRevice = true;
|
||||
ToomossCanDrive.StartPrecisionCycleSendMsg();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
ToomossCanDrive.IsCycleRevice = true;
|
||||
ToomossCanDrive.StartPrecisionCycleSendMsg();
|
||||
}
|
||||
finally
|
||||
else
|
||||
{
|
||||
_dbcModelLock.ExitReadLock();
|
||||
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -278,18 +255,10 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
if (!ToomossCanDrive.IsCycleRevice) return 0;
|
||||
|
||||
_dbcModelLock.EnterReadLock();
|
||||
try
|
||||
if (ListCanDbcModel.Any(a => a.Name == Name))
|
||||
{
|
||||
if (ListCanDbcModel.Any(a => a.Name == Name))
|
||||
{
|
||||
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
|
||||
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dbcModelLock.ExitReadLock();
|
||||
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
|
||||
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -305,18 +274,10 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
if (!ToomossCanDrive.IsCycleRevice) return 0;
|
||||
|
||||
_dbcModelLock.EnterReadLock();
|
||||
try
|
||||
if (ListCanDbcModel.Any(a => a.Name == Name))
|
||||
{
|
||||
if (ListCanDbcModel.Any(a => a.Name == Name))
|
||||
{
|
||||
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
|
||||
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dbcModelLock.ExitReadLock();
|
||||
//double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue, out double Result1);
|
||||
return double.TryParse(ListCanDbcModel.FindFirst(a => a.Name == Name).SignalRtValue.Split(" ")[0], out double Result) == true ? Result : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user