CAN的更改
This commit is contained in:
@@ -618,7 +618,7 @@ namespace CapMachine.Wpf.CanDrive
|
|||||||
// 预先计算固定值
|
// 预先计算固定值
|
||||||
long CycleInTicks = (long)(SendCycle * TicksPerMs);
|
long CycleInTicks = (long)(SendCycle * TicksPerMs);
|
||||||
//临时测试用
|
//临时测试用
|
||||||
long lastTicks = Stopwatcher.ElapsedTicks;
|
//long lastTicks = Stopwatcher.ElapsedTicks;
|
||||||
//IsCycleSend
|
//IsCycleSend
|
||||||
while (IsCycleSend && !token.IsCancellationRequested)
|
while (IsCycleSend && !token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
@@ -664,8 +664,9 @@ namespace CapMachine.Wpf.CanDrive
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用Stopwatch记录实际的执行间隔,而不是DateTime
|
// 使用Stopwatch记录实际的执行间隔,而不是DateTime
|
||||||
Console.WriteLine($"--实际间隔(ms): {(Stopwatcher.ElapsedTicks - lastTicks) / TicksPerMs:F3}, 目标: {SendCycle}");
|
//Console.WriteLine($"--实际间隔(ms): {(Stopwatcher.ElapsedTicks - lastTicks) / TicksPerMs:F3}, 目标: {SendCycle}");
|
||||||
lastTicks = Stopwatcher.ElapsedTicks;
|
//lastTicks = Stopwatcher.ElapsedTicks;
|
||||||
|
|
||||||
//Console.WriteLine($"--当前时间(毫秒): {DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}");
|
//Console.WriteLine($"--当前时间(毫秒): {DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ namespace CapMachine.Wpf.Services
|
|||||||
get { return _AutoSpeedSv; }
|
get { return _AutoSpeedSv; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value!= _AutoSpeedSv)
|
if (value != _AutoSpeedSv)
|
||||||
{
|
{
|
||||||
_AutoSpeedSv = value;
|
_AutoSpeedSv = value;
|
||||||
RaisePropertyChanged();
|
RaisePropertyChanged();
|
||||||
@@ -225,19 +225,33 @@ namespace CapMachine.Wpf.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新压缩机使能数据
|
/// 更新压缩机使能数据 自动时的赋值数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="IsEnable"></param>
|
/// <param name="IsEnable"></param>
|
||||||
public void UpdateCapEnableCmdData(bool IsEnable)
|
public void UpdateCapEnableCmdData(bool IsEnable)
|
||||||
{
|
{
|
||||||
if (!ToomossCanDrive.IsCycleSend) return;
|
if (!ToomossCanDrive.IsCycleSend) return;
|
||||||
if (!CanAutoHand) return;
|
if (CanAutoHand)
|
||||||
|
{
|
||||||
if (EnableCanCmdData != null)
|
if (EnableCanCmdData != null)
|
||||||
{
|
{
|
||||||
EnableCanCmdData.SignalCmdValue = IsEnable ? 1 : 0;
|
EnableCanCmdData.SignalCmdValue = IsEnable ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新压缩机使能数据 手动时的赋值数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="IsEnable"></param>
|
||||||
|
public void UpdateCapEnableCmdDataByHand(bool IsEnable)
|
||||||
|
{
|
||||||
|
if (EnableCanCmdData != null)
|
||||||
|
{
|
||||||
|
EnableCanCmdData.SignalCmdValue = IsEnable ? 1 : 0;
|
||||||
|
Console.WriteLine("压缩机使能:" + IsEnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 发送消息给CAN 驱动
|
/// 发送消息给CAN 驱动
|
||||||
|
|||||||
@@ -296,7 +296,10 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
private async void ListenRecoredChannelAction()
|
private async void ListenRecoredChannelAction()
|
||||||
{
|
{
|
||||||
|
|
||||||
while (await RecoredChannelInfo.Reader.WaitToReadAsync())
|
while (await RecoredChannelInfo.Reader.WaitToReadAsync())
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (RecoredChannelInfo.Reader.TryRead(out var recordChannelData))
|
if (RecoredChannelInfo.Reader.TryRead(out var recordChannelData))
|
||||||
{
|
{
|
||||||
@@ -359,12 +362,19 @@ namespace CapMachine.Wpf.Services
|
|||||||
//Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss:fff")}-{LineName}-保存成功!");
|
//Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss:fff")}-{LineName}-保存成功!");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//stopwatch.Stop(); //停止Stopwatch
|
//stopwatch.Stop(); //停止Stopwatch
|
||||||
//Console.WriteLine("保存数据耗时::{0}", stopwatch.Elapsed.TotalSeconds.ToString());
|
//Console.WriteLine("保存数据耗时::{0}", stopwatch.Elapsed.TotalSeconds.ToString());
|
||||||
//stopwatch.Reset();
|
//stopwatch.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogService.Error($"时间:{DateTime.Now.ToString()}-【ListenRecoredChannelAction】-{ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -459,7 +469,7 @@ namespace CapMachine.Wpf.Services
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
//CycleTimer.Start(); //执行完毕后再开启器
|
//CycleTimer.Start(); //执行完毕后再开启器
|
||||||
LogService.Info($"时间:{DateTime.Now.ToString()}-【PwAnalyze-CycleAction】-{ex.Message}");
|
LogService.Error($"时间:{DateTime.Now.ToString()}-【PwAnalyze-CycleAction】-{ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,8 @@ namespace CapMachine.Wpf.Services
|
|||||||
private async void ListenCycleChannelAction()
|
private async void ListenCycleChannelAction()
|
||||||
{
|
{
|
||||||
while (await CycleChannelInfo.Reader.WaitToReadAsync())
|
while (await CycleChannelInfo.Reader.WaitToReadAsync())
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (CycleChannelInfo.Reader.TryRead(out var CycleChannelData))
|
if (CycleChannelInfo.Reader.TryRead(out var CycleChannelData))
|
||||||
{
|
{
|
||||||
@@ -205,6 +207,12 @@ namespace CapMachine.Wpf.Services
|
|||||||
//stopwatch.Reset();
|
//stopwatch.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogService.Error($"时间:{DateTime.Now.ToString()}-【ListenCycleChannelAction】-{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否启用CAN报文显示
|
/// 是否启用CAN报文显示
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool _IsDisplayEnabled=true;
|
private bool _IsDisplayEnabled = true;
|
||||||
public bool IsDisplayEnabled
|
public bool IsDisplayEnabled
|
||||||
{
|
{
|
||||||
get { return _IsDisplayEnabled; }
|
get { return _IsDisplayEnabled; }
|
||||||
@@ -241,9 +241,11 @@ namespace CapMachine.Wpf.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task ProcessMessagesAsync()
|
private async Task ProcessMessagesAsync()
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
while (await ReceiveChannel.Reader.WaitToReadAsync(TaskCancellationTokenSource.Token))
|
while (await ReceiveChannel.Reader.WaitToReadAsync(TaskCancellationTokenSource.Token))
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// 清空列表但保留容量
|
// 清空列表但保留容量
|
||||||
MessageBatch.Clear();
|
MessageBatch.Clear();
|
||||||
@@ -280,7 +282,6 @@ namespace CapMachine.Wpf.Services
|
|||||||
await Task.Delay(20);
|
await Task.Delay(20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (OperationCanceledException ex)
|
catch (OperationCanceledException ex)
|
||||||
{
|
{
|
||||||
// 服务被取消,正常退出
|
// 服务被取消,正常退出
|
||||||
@@ -290,6 +291,9 @@ namespace CapMachine.Wpf.Services
|
|||||||
{
|
{
|
||||||
LogService.Error($"消息处理任务异常: {ex.Message}");
|
LogService.Error($"消息处理任务异常: {ex.Message}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2741,25 +2741,25 @@ namespace CapMachine.Wpf.Services
|
|||||||
if (item.StateOperateResult.IsSuccess)
|
if (item.StateOperateResult.IsSuccess)
|
||||||
{
|
{
|
||||||
item.State = item.StateOperateResult.Content;
|
item.State = item.StateOperateResult.Content;
|
||||||
//根据PLC得到执行的步骤数据,更新到CAN和LIN的数据
|
//根据PLC得到执行的步骤数据,更新到CAN和LIN的数据,压缩的使能时来自于程序的步骤配置,不再接受PLC的指令数据
|
||||||
if (item.Name!.Equals("使能"))
|
//if (item.Name!.Equals("使能"))
|
||||||
{
|
//{
|
||||||
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
|
// switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
|
||||||
{
|
// {
|
||||||
case CanLinEnum.Can:
|
// case CanLinEnum.Can:
|
||||||
//获取PLC的使能状态,更新到CAN的使能状态
|
// //获取PLC的使能状态,更新到CAN的使能状态
|
||||||
CanDriveService.UpdateCapEnableCmdData(item.State);
|
// CanDriveService.UpdateCapEnableCmdData(item.State);
|
||||||
//itemTag.Value.EngPvValue = 0;
|
// //itemTag.Value.EngPvValue = 0;
|
||||||
break;
|
// break;
|
||||||
case CanLinEnum.Lin:
|
// case CanLinEnum.Lin:
|
||||||
//获取PLC的使能状态,更新到LIN的使能状态
|
// //获取PLC的使能状态,更新到LIN的使能状态
|
||||||
LinDriveService.UpdateCapEnableCmdData(item.State);
|
// LinDriveService.UpdateCapEnableCmdData(item.State);
|
||||||
//itemTag.Value.EngPvValue = 0;
|
// //itemTag.Value.EngPvValue = 0;
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3062,6 +3062,13 @@ namespace CapMachine.Wpf.Services
|
|||||||
{
|
{
|
||||||
foreach (var itemStepExd in ProRunChannelData.ListStepExd)
|
foreach (var itemStepExd in ProRunChannelData.ListStepExd)
|
||||||
{
|
{
|
||||||
|
//压缩机使能的参数直接给压缩机触发
|
||||||
|
if (itemStepExd.Name.Contains("压缩机使能"))
|
||||||
|
{
|
||||||
|
CanDriveService.UpdateCapEnableCmdData((bool)itemStepExd.Value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var DataAdrees = ListPlcExdConfigCell.FirstOrDefault(a => a.Name == itemStepExd.Name);
|
var DataAdrees = ListPlcExdConfigCell.FirstOrDefault(a => a.Name == itemStepExd.Name);
|
||||||
if (DataAdrees != null)
|
if (DataAdrees != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -534,6 +534,7 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
MsgName = item.MsgFrameName,
|
MsgName = item.MsgFrameName,
|
||||||
SignalName = item.SignalName,
|
SignalName = item.SignalName,
|
||||||
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
|
||||||
|
LogicRuleDto = Mapper.Map<LogicRuleDto>(item.LogicRule),
|
||||||
});
|
});
|
||||||
|
|
||||||
//CanDriveService.CmdData.Add(new CanCmdData()
|
//CanDriveService.CmdData.Add(new CanCmdData()
|
||||||
@@ -1075,7 +1076,7 @@ namespace CapMachine.Wpf.ViewModels
|
|||||||
//ToDo cmd
|
//ToDo cmd
|
||||||
CanDriveService.CanHandEnable = (bool)Data!;
|
CanDriveService.CanHandEnable = (bool)Data!;
|
||||||
//给使能数据
|
//给使能数据
|
||||||
CanDriveService.UpdateCapEnableCmdData(CanDriveService.CanHandEnable);
|
CanDriveService.UpdateCapEnableCmdDataByHand((bool)Data!);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -609,7 +609,7 @@
|
|||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
Command="{Binding CanAutoHandCmd}"
|
Command="{Binding CanAutoHandCmd}"
|
||||||
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
|
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
|
||||||
FontSize="11"
|
FontSize="8"
|
||||||
ToolTip="自动时:接受程序步骤的转速控制;手动时:手动发送转速数据">
|
ToolTip="自动时:接受程序步骤的转速控制;手动时:手动发送转速数据">
|
||||||
<ToggleButton.Style>
|
<ToggleButton.Style>
|
||||||
<Style BasedOn="{StaticResource MaterialDesignSwitchToggleButton}" TargetType="ToggleButton">
|
<Style BasedOn="{StaticResource MaterialDesignSwitchToggleButton}" TargetType="ToggleButton">
|
||||||
@@ -647,7 +647,7 @@
|
|||||||
Margin="10,0,0,0"
|
Margin="10,0,0,0"
|
||||||
Command="{Binding CanHandEnableCmd}"
|
Command="{Binding CanHandEnableCmd}"
|
||||||
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
|
CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
|
||||||
FontSize="11"
|
FontSize="8"
|
||||||
ToolTip="使能时:触发报文中使能;禁用时:触发报文中使能=False">
|
ToolTip="使能时:触发报文中使能;禁用时:触发报文中使能=False">
|
||||||
<ToggleButton.Style>
|
<ToggleButton.Style>
|
||||||
<Style BasedOn="{StaticResource MaterialDesignSwitchToggleButton}" TargetType="ToggleButton">
|
<Style BasedOn="{StaticResource MaterialDesignSwitchToggleButton}" TargetType="ToggleButton">
|
||||||
|
|||||||
Reference in New Issue
Block a user