CAN和SV发送数据问题的修复,只发送速度到CAN

This commit is contained in:
2025-04-25 22:28:16 +08:00
parent 0aee140e3f
commit 2f80b50e0b
9 changed files with 60 additions and 129 deletions

View File

@@ -7,6 +7,7 @@ using SharpDX;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -152,6 +153,7 @@ namespace CapMachine.Wpf.Services
{
//LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
SpeedCanCmdData.SignalCmdValue = LogicRuleService.ApplyExpressionFast(SpeedData, SpeedCanCmdData.LogicRuleDto);
Console.WriteLine($"实时转换后转速值:{SpeedCanCmdData.SignalCmdValue}-SV值:{SpeedData}" );
}
}

View File

@@ -2706,8 +2706,8 @@ namespace CapMachine.Wpf.Services
//程序步骤的写入
ProRunStepWrite();
TestValue = TestValue + 0.001;
Console.WriteLine($"结果:{LogicRuleService.ApplyExpressionFast(TestValue, LogicRuleService.LogicRuleDtos[1])}");
//TestValue = TestValue + 0.001;
//Console.WriteLine($"结果:{LogicRuleService.ApplyExpressionFast(TestValue, LogicRuleService.LogicRuleDtos[1])}");
//stopwatch.Stop(); //停止Stopwatch
//Console.WriteLine("Add Elapsed output runTime:{0}", stopwatch.Elapsed.TotalSeconds.ToString());
@@ -2893,7 +2893,8 @@ namespace CapMachine.Wpf.Services
var SvResult = SiemensDrive.Write(CurMeterInfo!.SvAddress, (short)ProRunChannelData.SV!);
if (!SvResult.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:SV写入失败");
//速度SV到压缩机
SendSpeedSvToCap(ProRunChannelData.SV);
if (ProRunChannelData.IsSpeed) SendSpeedSvToCap(ProRunChannelData.SV);
//Pid
if (!string.IsNullOrEmpty(CurMeterInfo.Pid_PAddress))
@@ -2923,7 +2924,7 @@ namespace CapMachine.Wpf.Services
var SvResult = SiemensDrive.Write(CurMeterInfo!.SvAddress, (short)ProRunChannelData.SV!);
if (!SvResult.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:SV写入失败");
//速度SV到压缩机
SendSpeedSvToCap(ProRunChannelData.SV);
if (ProRunChannelData.IsSpeed) SendSpeedSvToCap(ProRunChannelData.SV);
//Pid
if (!string.IsNullOrEmpty(CurMeterInfo.Pid_PAddress))
@@ -2944,7 +2945,7 @@ namespace CapMachine.Wpf.Services
var SvResult = SiemensDrive.Write(CurMeterInfo!.SvAddress, (short)ProRunChannelData.SV!);
if (!SvResult.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:SV写入失败");
//速度SV到压缩机
SendSpeedSvToCap(ProRunChannelData.SV);
if (ProRunChannelData.IsSpeed) SendSpeedSvToCap(ProRunChannelData.SV);
//Limit
if (!string.IsNullOrEmpty(CurMeterInfo.Limit_UpAddress))
@@ -2964,7 +2965,7 @@ namespace CapMachine.Wpf.Services
var SvResult = SiemensDrive.Write(CurMeterInfo!.SvAddress, (short)ProRunChannelData.SV!);
if (!SvResult.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:SV写入失败");
//速度SV到压缩机
SendSpeedSvToCap(ProRunChannelData.SV);
if (ProRunChannelData.IsSpeed) SendSpeedSvToCap(ProRunChannelData.SV);
}
break;
@@ -3031,7 +3032,7 @@ namespace CapMachine.Wpf.Services
var SvResult = SiemensDrive.Write(CurMeterInfo!.SvAddress, (short)ProRunChannelData.SV!);
if (!SvResult.IsSuccess) Console.WriteLine($"{ProRunChannelData.MeterName}:SV写入失败");
//速度SV到压缩机
SendSpeedSvToCap(ProRunChannelData.SV);
if (ProRunChannelData.IsSpeed) SendSpeedSvToCap(ProRunChannelData.SV);
}
break;
@@ -3121,6 +3122,7 @@ namespace CapMachine.Wpf.Services
//itemTag.Value.EngPvValue = 0;
break;
default:
//CanDriveService.UpdateSpeedCmdData(SpeedSv);
break;
}
}

View File

@@ -54,106 +54,6 @@ namespace CapMachine.Wpf.Services
//实例化函数
ListProExModel = new List<ProExModel>();
#region
//{
// new ProExModel(ProRunChannel){
// MeterName="转速",
// ListProStepExe=new List<ProStepExe>(),
// IsSpeed=true,
// },
// new ProExModel(ProRunChannel){
// MeterName="COND1温度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="COND2温度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="COND2压力",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="EVAP出口温度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="排气压力",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="HV[V]",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="吸气压力",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="吸气温度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="润滑油压力",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="LV[V]",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="OCR",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="OS1温度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="OS2温度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="PTC入口温度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="PTC流量",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="PTC功率",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="环境湿度",
// ListProStepExe=new List<ProStepExe>(),
// },
// new ProExModel(ProRunChannel){
// MeterName="环境温度",
// ListProStepExe=new List<ProStepExe>(),
// }
//};
#endregion
//从变量集合中加载PLC转制的配置数据
ListPlcLoadConfigCell = new List<PlcLoadConfigCell>();
@@ -184,6 +84,8 @@ namespace CapMachine.Wpf.Services
}
}
SpeedProExModel= ListProExModel.FindFirst(a => a.MeterName.Contains("转速"));//转速执行模型
//SpeedRunEndEvent
ListProExModel.FindFirst(a => a.MeterName.Contains("转速")).SpeedRunEndEvent += ProRuntimeService_SpeedRunEndEvent;
@@ -229,6 +131,12 @@ namespace CapMachine.Wpf.Services
/// </summary>
public List<ProExModel> ListProExModel { get; set; }
/// <summary>
/// 转速执行模型
/// 摘出来给界面展示用,因为速度的时间和步骤代表整个程序的时间和步骤
/// </summary>
public ProExModel SpeedProExModel { get; set; }
/// <summary>
/// PLC加载配置数据集合
/// </summary>