增加CAN 调度表的配置
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using CapMachine.Model.CANLIN;
|
||||
using CapMachine.Wpf.CanDrive;
|
||||
using CapMachine.Wpf.Dtos;
|
||||
using ImTools;
|
||||
using Prism.Ioc;
|
||||
using Prism.Mvvm;
|
||||
@@ -20,15 +21,17 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
|
||||
public HighSpeedDataService HighSpeedDataService { get; }
|
||||
public LogicRuleService LogicRuleService { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public CanDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider)
|
||||
public CanDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider, LogicRuleService logicRuleService)
|
||||
{
|
||||
ToomossCanDrive = new ToomossCan(containerProvider);
|
||||
//高速数据服务
|
||||
HighSpeedDataService = highSpeedDataService;
|
||||
LogicRuleService = logicRuleService;
|
||||
|
||||
//ToomossCanDrive.StartCanDrive();
|
||||
}
|
||||
@@ -124,6 +127,11 @@ namespace CapMachine.Wpf.Services
|
||||
/// </summary>
|
||||
public List<CanCmdData> CmdData { get; set; } = new List<CanCmdData>();
|
||||
|
||||
/// <summary>
|
||||
/// CNA 调度表的配置信息
|
||||
/// </summary>
|
||||
public List<CANScheduleConfigDto> ListCANScheduleConfig { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 增加发送的指令数据
|
||||
/// </summary>
|
||||
@@ -172,14 +180,26 @@ namespace CapMachine.Wpf.Services
|
||||
/// <param name="canCmdData"></param>
|
||||
public void UpdateSpeedCmdData(double SpeedData)
|
||||
{
|
||||
//if (SpeedCanCmdData != null)
|
||||
//{
|
||||
// SpeedCanCmdData.SignalCmdValue = SpeedData;
|
||||
//}
|
||||
if (SpeedCanCmdData != null)
|
||||
{
|
||||
SpeedCanCmdData.SignalCmdValue = SpeedData;
|
||||
//首先是否判断是有斜率
|
||||
if (SpeedCanCmdData.LogicRuleDto == null)
|
||||
{
|
||||
//没有启动逻辑规则处理
|
||||
SpeedCanCmdData.SignalCmdValue = SpeedData;
|
||||
}
|
||||
else
|
||||
{
|
||||
//LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
|
||||
SpeedCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
|
||||
//Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}");
|
||||
}
|
||||
|
||||
}
|
||||
//if (EnableCanCmdData != null)
|
||||
//{
|
||||
// EnableCanCmdData.SignalCmdValue = 1;
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -293,10 +313,39 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
if (CmdData.Count > 0)
|
||||
{
|
||||
ToomossCanDrive.IsCycleSend = true;
|
||||
|
||||
ToomossCanDrive.CmdData = CmdData;
|
||||
//ToomossCanDrive.StartCycleSendMsg();
|
||||
ToomossCanDrive.StartPrecisionCycleSendMsg();
|
||||
|
||||
if (ToomossCanDrive.SchEnable)
|
||||
{
|
||||
|
||||
//使用调度表的话,需要在调度表中配置信息后才可以进行操作
|
||||
var GroupMsg = ToomossCanDrive.CmdData.GroupBy(a => a.MsgName).ToList();
|
||||
foreach (var itemMsg in GroupMsg)
|
||||
{
|
||||
if (!ListCANScheduleConfig.ToList().Any(a => a.MsgName == itemMsg.Key))
|
||||
{
|
||||
System.Windows.MessageBox.Show($"你使能了调度表,但是调度表中没有设置【{itemMsg.Key}】信息,请设置后再操作", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ListCANScheduleConfig == null && ListCANScheduleConfig!.Count() == 0)
|
||||
{
|
||||
System.Windows.MessageBox.Show("调度表配置为空数据,请检查!将无法发送数据", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
return;
|
||||
}
|
||||
ToomossCanDrive.ListCANScheduleConfig = ListCANScheduleConfig!;
|
||||
ToomossCanDrive.StartSchedule();
|
||||
ToomossCanDrive.StartCycleUpdateCmd();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToomossCanDrive.StartPrecisionCycleSendMsg();
|
||||
//ToomossCanDrive.StartCycleSendMsg();
|
||||
}
|
||||
|
||||
ToomossCanDrive.IsCycleSend = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -305,7 +354,15 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
ToomossCanDrive.IsCycleSend = false;
|
||||
if (ToomossCanDrive.SchEnable)
|
||||
{
|
||||
ToomossCanDrive.IsCycleSend = false;
|
||||
ToomossCanDrive.StopSchedule();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToomossCanDrive.IsCycleSend = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -374,6 +431,7 @@ namespace CapMachine.Wpf.Services
|
||||
//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 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