CAN的定时发送的更改和一些其他的改动

This commit is contained in:
2025-05-06 11:03:51 +08:00
parent 16eaa230d8
commit df4b481bbb
7 changed files with 238 additions and 24 deletions

View File

@@ -25,6 +25,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using static CapMachine.Wpf.Models.ComEnum;
@@ -38,7 +39,7 @@ namespace CapMachine.Wpf.ViewModels
public CANConfigViewModel(IDialogService dialogService, IFreeSql freeSql,
IEventAggregator eventAggregator, IRegionManager regionManager, SysRunService sysRunService,
ComActionService actionService, LogicRuleService logicRuleService,
ConfigService configService, CanDriveService canDriveService,HightDriveMsgService hightDriveMsgService,
ConfigService configService, CanDriveService canDriveService, HightDriveMsgService hightDriveMsgService,
IMapper mapper, MachineRtDataService machineRtDataService)
{
//LogService = logService;
@@ -96,7 +97,7 @@ namespace CapMachine.Wpf.ViewModels
public ComActionService ComActionService { get; }
public LogicRuleService LogicRuleService { get; }
public ConfigService ConfigService { get; }
public CanDriveService CanDriveService { get; }
public CanDriveService CanDriveService { get; set; }
public HightDriveMsgService HightDriveMsgService { get; }
public IMapper Mapper { get; }
private MachineRtDataService MachineRtDataService { get; }
@@ -991,7 +992,7 @@ namespace CapMachine.Wpf.ViewModels
case "CycleRecive":
CanDriveService.CycleReciveMsg();
//Listen
//Listen
break;
default:
break;
@@ -999,6 +1000,87 @@ namespace CapMachine.Wpf.ViewModels
}
private DelegateCommand<object> _CanAutoHandCmd;
/// <summary>
/// CAN的手自动切换
/// </summary>
public DelegateCommand<object> CanAutoHandCmd
{
set
{
_CanAutoHandCmd = value;
}
get
{
if (_CanAutoHandCmd == null)
{
_CanAutoHandCmd = new DelegateCommand<object>((p) => CanAutoHandCmdCall(p));
}
return _CanAutoHandCmd;
}
}
/// <summary>
/// CAN的手自动切换操作指令执行方法
/// CAN的手自动切换在调试时手动操作在正常运行时自动操作
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void CanAutoHandCmdCall(object Par)
{
if (Par != null && Par is ToggleButton)
{
var ControlData = Par as ToggleButton;
var Name = ControlData.ToolTip;
var Data = ControlData.IsChecked;
//ToDo cmd
CanDriveService.CanAutoHand = (bool)Data!;
//CAN手自动切换时报文的展示需要配置一下自动时报文不再展示节省资源手动时报文才展示
HightDriveMsgService.IsDisplayEnabled= !(bool)Data!;
}
}
private DelegateCommand<object> _CanHandEnableCmd;
/// <summary>
/// CAN 手动 模式,是否使能,用于报文的使能和非使能的数据
/// True代表使能False代表禁用
/// </summary>
public DelegateCommand<object> CanHandEnableCmd
{
set
{
_CanHandEnableCmd = value;
}
get
{
if (_CanHandEnableCmd == null)
{
_CanHandEnableCmd = new DelegateCommand<object>((p) => CanHandEnableCmdCall(p));
}
return _CanHandEnableCmd;
}
}
/// <summary>
/// CAN 手动 模式,是否使能,用于报文的使能和非使能的数据
/// True代表使能False代表禁用
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void CanHandEnableCmdCall(object Par)
{
if (Par != null && Par is ToggleButton)
{
var ControlData = Par as ToggleButton;
var Name = ControlData.ToolTip;
var Data = ControlData.IsChecked;
//ToDo cmd
CanDriveService.CanHandEnable = (bool)Data!;
//给使能数据
CanDriveService.UpdateCapEnableCmdData(CanDriveService.CanHandEnable);
}
}
private double _HandSpeed;
/// <summary>
/// 手动转速数据