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

@@ -86,6 +86,45 @@ namespace CapMachine.Wpf.Services
#region CAN
private bool _CanAutoHand;
/// <summary>
/// CAN 手自动 模式,自动代表接受程序步骤的数据,手动代表接受手动输入的数据
/// True代表自动False代表手动
/// </summary>
public bool CanAutoHand
{
get { return _CanAutoHand; }
set
{
if (_CanAutoHand != value)
{
RaisePropertyChanged();
_CanAutoHand = value;
}
}
}
private bool _CanHandEnable;
/// <summary>
/// CAN 手动 模式,是否使能,用于报文的使能和非使能的数据
/// True代表使能False代表禁用
/// </summary>
public bool CanHandEnable
{
get { return _CanHandEnable; }
set
{
if (_CanHandEnable != value)
{
RaisePropertyChanged();
_CanHandEnable = value;
}
}
}
private int _AutoSpeedSv;
/// <summary>
/// 转速SV
@@ -93,7 +132,15 @@ namespace CapMachine.Wpf.Services
public int AutoSpeedSv
{
get { return _AutoSpeedSv; }
set { _AutoSpeedSv = value; RaisePropertyChanged(); }
set
{
if (value!= _AutoSpeedSv)
{
_AutoSpeedSv = value;
RaisePropertyChanged();
}
}
}
@@ -167,7 +214,7 @@ namespace CapMachine.Wpf.Services
{
//LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
SpeedCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}");
//Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}");
}
}
@@ -184,7 +231,7 @@ namespace CapMachine.Wpf.Services
public void UpdateCapEnableCmdData(bool IsEnable)
{
if (!ToomossCanDrive.IsCycleSend) return;
if (!CanAutoHand) return;
if (EnableCanCmdData != null)
{
EnableCanCmdData.SignalCmdValue = IsEnable ? 1 : 0;
@@ -194,6 +241,7 @@ namespace CapMachine.Wpf.Services
/// <summary>
/// 发送消息给CAN 驱动
/// 手动发送时使用
/// </summary>
public void SendMsgToCanDrive(double SpeedData)
{

View File

@@ -2747,7 +2747,7 @@ namespace CapMachine.Wpf.Services
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
case CanLinEnum.Can:
//获取PLC的使能状态更新到CAN的使能状态
//获取PLC的使能状态更新到CAN的使能状态
CanDriveService.UpdateCapEnableCmdData(item.State);
//itemTag.Value.EngPvValue = 0;
break;
@@ -3068,10 +3068,12 @@ namespace CapMachine.Wpf.Services
switch (itemStepExd.ValueType)
{
case ExdValueType.Bool:
SiemensDrive.Write(DataAdrees.Address, (bool)itemStepExd.Value == true ? 1 : 0);
var ResultBool = SiemensDrive.Write(DataAdrees.Address, (bool)itemStepExd.Value == true ? 1 : 0);
if (!ResultBool.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:{itemStepExd.Name}写入失败");
break;
case ExdValueType.Short:
SiemensDrive.Write(DataAdrees.Address, (short)itemStepExd.Value);
var ResultShort = SiemensDrive.Write(DataAdrees.Address, (short)itemStepExd.Value);
if (!ResultShort.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:{itemStepExd.Name}写入失败");
break;
case ExdValueType.Double:
break;
@@ -3117,6 +3119,7 @@ namespace CapMachine.Wpf.Services
/// <summary>
/// 发送速度SV到压缩机
/// 自动步骤数据发送
/// </summary>
private void SendSpeedSvToCap(int SpeedSv)
{
@@ -3124,7 +3127,11 @@ namespace CapMachine.Wpf.Services
{
case CanLinEnum.Can:
//获取PLC的SV数据 更新SV的速度值到压缩机
CanDriveService.UpdateSpeedCmdData(SpeedSv);
if (CanDriveService.CanAutoHand)//自动时步骤的数据可以赋值数据
{
CanDriveService.UpdateSpeedCmdData(SpeedSv);
}
//itemTag.Value.EngPvValue = 0;
break;
case CanLinEnum.Lin: