一些优化:CAN和PLC地址的优化

This commit is contained in:
2025-01-01 13:11:13 +08:00
parent 8b21846424
commit 26569135d3
182 changed files with 87934 additions and 261 deletions

View File

@@ -17,10 +17,16 @@ namespace CapMachine.Wpf.Services
/// </summary>
public class CanDriveService : BindableBase
{
/// <summary>
/// 当前选中的CanLinConfigPro 程序
/// </summary>
public CanLinConfigPro SelectedCanLinConfigPro { get; set; }
public HighSpeedDataService HighSpeedDataService { get; }
/// <summary>
/// 实例化函数
/// </summary>
public CanDriveService(HighSpeedDataService highSpeedDataService,IContainerProvider containerProvider)
public CanDriveService(HighSpeedDataService highSpeedDataService, IContainerProvider containerProvider)
{
ToomossCanDrive = new ToomossCan(containerProvider);
//高速数据服务
@@ -51,7 +57,7 @@ namespace CapMachine.Wpf.Services
//为DBC实时数据关联配置的名称
foreach (var item in SelectedCanLinConfigPro.CanLinConfigContents)
{
var FindData = ListCanDbcModel.FindFirst(a => a.SignalName == item.Content);
var FindData = ListCanDbcModel.FindFirst(a => a.SignalName == item.SignalName);
if (FindData != null)
{
FindData.Name = item.Name;
@@ -69,10 +75,93 @@ namespace CapMachine.Wpf.Services
return ListCanDbcModel;
}
#region CAN
/// <summary>
/// 当前选中的CanLinConfigPro 程序
/// 要发送的CAN指令数据
/// 在程序配置好后就确定要发送哪些数据
/// </summary>
public CanLinConfigPro SelectedCanLinConfigPro { get; set; }
public HighSpeedDataService HighSpeedDataService { get; }
public List<CanCmdData> CmdData { get; set; } = new List<CanCmdData>();
/// <summary>
/// 发送消息给CAN 驱动
/// </summary>
public void SendMsgToCanDrive()
{
if (ToomossCanDrive.OpenState)
{
if (CmdData.Count > 0)
{
ToomossCanDrive.SendCanMsg(CmdData);
}
else
{
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
}
}
}
/// <summary>
/// 循环发送数据到CAN
/// </summary>
public void CycleSendMsg()
{
if (ToomossCanDrive.OpenState)
{
if (ToomossCanDrive.IsCycleSend == false)
{
if (CmdData.Count > 0)
{
ToomossCanDrive.IsCycleSend = true;
ToomossCanDrive.CmdData = CmdData;
ToomossCanDrive.StartCycleSendMsg();
}
else
{
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
}
}
else
{
ToomossCanDrive.IsCycleSend = false;
}
}
}
/// <summary>
///循环接收数据
/// </summary>
public void CycleReciveMsg()
{
if (ToomossCanDrive.OpenState)
{
if (ToomossCanDrive.IsCycleRevice == false)
{
if (CmdData.Count > 0)
{
ToomossCanDrive.IsCycleRevice = true;
ToomossCanDrive.StartCycleReviceCanMsg();
}
else
{
System.Windows.MessageBox.Show("未发现配置的数据内容", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
}
}
else
{
ToomossCanDrive.IsCycleRevice = false;
}
}
}
#endregion
}
}