CAN和SV发送数据问题的修复,只发送速度到CAN
This commit is contained in:
@@ -522,16 +522,16 @@ namespace CapMachine.Wpf.CanDrive
|
||||
|
||||
//释放申请的临时缓冲区
|
||||
Marshal.FreeHGlobal(msgPtSend);
|
||||
Console.WriteLine("");
|
||||
//Console.WriteLine("");
|
||||
//发送CAN数据
|
||||
int SendedNum = USB2CAN.CAN_SendMsg(DevHandle, WriteCANIndex, CanMsg, (uint)CanMsg.Length);
|
||||
if (SendedNum >= 0)
|
||||
{
|
||||
Console.WriteLine("Success send frames:{0}", SendedNum);
|
||||
//Console.WriteLine("Success send frames:{0}", SendedNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Send CAN data failed! {0}", SendedNum);
|
||||
//Console.WriteLine("Send CAN data failed! {0}", SendedNum);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -562,20 +562,20 @@ namespace CapMachine.Wpf.CanDrive
|
||||
int CanNum = USB2CAN.CAN_GetMsgWithSize(DevHandle, ReadCANIndex, msgPtRead, CanMsgBuffer.Length);
|
||||
if (CanNum > 0)
|
||||
{
|
||||
Console.WriteLine("Read CanMsgNum = {0}", CanNum);
|
||||
//Console.WriteLine("Read CanMsgNum = {0}", CanNum);
|
||||
for (int i = 0; i < CanNum; i++)
|
||||
{
|
||||
//CanMsgBuffer[i] = (USB2CAN.CAN_MSG)Marshal.PtrToStructure((IntPtr)((UInt32)msgPtRead + i * Marshal.SizeOf(typeof(USB2CAN.CAN_MSG))), typeof(USB2CAN.CAN_MSG)); //有溢出报错
|
||||
CanMsgBuffer[i] = (USB2CAN.CAN_MSG)Marshal.PtrToStructure((IntPtr)(msgPtRead + i * Marshal.SizeOf(typeof(USB2CAN.CAN_MSG))), typeof(USB2CAN.CAN_MSG));
|
||||
|
||||
Console.WriteLine("CanMsg[{0}].ID = 0x{1}", i, CanMsgBuffer[i].ID.ToString("X8"));
|
||||
Console.WriteLine("CanMsg[{0}].TimeStamp = {1}", i, CanMsgBuffer[i].TimeStamp);
|
||||
Console.Write("CanMsg[{0}].Data = ", i);
|
||||
//Console.WriteLine("CanMsg[{0}].ID = 0x{1}", i, CanMsgBuffer[i].ID.ToString("X8"));
|
||||
//Console.WriteLine("CanMsg[{0}].TimeStamp = {1}", i, CanMsgBuffer[i].TimeStamp);
|
||||
//Console.Write("CanMsg[{0}].Data = ", i);
|
||||
for (int j = 0; j < CanMsgBuffer[i].DataLen; j++)
|
||||
{
|
||||
Console.Write("{0} ", CanMsgBuffer[i].Data[j].ToString("X2"));
|
||||
//Console.Write("{0} ", CanMsgBuffer[i].Data[j].ToString("X2"));
|
||||
}
|
||||
Console.WriteLine("");
|
||||
//Console.WriteLine("");
|
||||
|
||||
//报文给高速记录的服务
|
||||
HighSpeedDataService.AppendOrUpdateMsg(new Models.HighSpeed.CommMsg()
|
||||
@@ -589,13 +589,13 @@ namespace CapMachine.Wpf.CanDrive
|
||||
}
|
||||
else if (CanNum == 0)
|
||||
{
|
||||
Console.WriteLine("No CAN data!");
|
||||
//Console.WriteLine("No CAN data!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Get CAN data error!");
|
||||
//Console.WriteLine("Get CAN data error!");
|
||||
}
|
||||
Console.WriteLine("");
|
||||
//Console.WriteLine("");
|
||||
|
||||
//将CAN消息数据填充到信号里面,用DBC解析数据
|
||||
CAN_DBCParser.DBC_SyncCANMsgToValue(DBCHandle, msgPtRead, CanNum);
|
||||
@@ -608,7 +608,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
//{
|
||||
CAN_DBCParser.DBC_GetSignalValueStr(DBCHandle, new StringBuilder(item.MsgName), new StringBuilder(item.SignalName), ValueSb);
|
||||
item.SignalRtValueSb = ValueSb;
|
||||
Console.Write(ValueSb.ToString());
|
||||
//Console.Write(ValueSb.ToString());
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,12 @@ namespace CapMachine.Wpf.ChannelModel
|
||||
/// </summary>
|
||||
public Limit? CurLoadLimit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是速度仪表参数
|
||||
/// 这个模型是通用的,但是发送后的速度参数需要特殊处理(给压缩机),所以要标记
|
||||
/// </summary>
|
||||
public bool IsSpeed { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 拓展参数集合
|
||||
/// 比如:速度参数拓展的输出锁定、吸排气阀,压缩机使能等这些拓展参数
|
||||
|
||||
@@ -208,6 +208,7 @@ namespace CapMachine.Wpf.Models.ProModelPars
|
||||
CurLoadLimit = LimitResult == true ? new Limit() { Up = (short)NextProStepExe.CurConfigLimitDto.Up, Down = (short)NextProStepExe.CurConfigLimitDto.Down } : new Limit(),
|
||||
CurLoadPID = PidResult == true ? new PID() { P = (short)NextProStepExe.CurConfigPIDDto.P, I = (short)NextProStepExe.CurConfigPIDDto.I, D = (short)NextProStepExe.CurConfigPIDDto.D } : new PID(),
|
||||
RunStepType = GetRunStepType(PidResult, LimitResult, false),
|
||||
IsSpeed=IsSpeed,
|
||||
|
||||
ListStepExd = GetStepExds(NextProStepExe),//拓展参数
|
||||
|
||||
@@ -264,6 +265,7 @@ namespace CapMachine.Wpf.Models.ProModelPars
|
||||
CurLoadLimit = LimitResult == true ? new Limit() { Up = (short)NextProStepExe.CurConfigLimitDto.Up, Down = (short)NextProStepExe.CurConfigLimitDto.Down } : new Limit(),
|
||||
CurLoadPID = PidResult == true ? new PID() { P = (short)NextProStepExe.CurConfigPIDDto.P, I = (short)NextProStepExe.CurConfigPIDDto.I, D = (short)NextProStepExe.CurConfigPIDDto.D } : new PID(),
|
||||
RunStepType = GetRunStepType(PidResult, LimitResult, true),
|
||||
IsSpeed = IsSpeed,
|
||||
|
||||
ListStepExd = GetStepExds(NextProStepExe),//拓展参数
|
||||
});
|
||||
@@ -444,6 +446,7 @@ namespace CapMachine.Wpf.Models.ProModelPars
|
||||
{
|
||||
MeterName = MeterName,
|
||||
SV = NoExData.First().SV,
|
||||
IsSpeed = IsSpeed,
|
||||
|
||||
ProSegName = CurProStepExe.ProSegName,
|
||||
MeterStep = CurProStepExe.MeterStep,
|
||||
|
||||
@@ -63,10 +63,20 @@ namespace CapMachine.Wpf.Models.ProModelPars
|
||||
/// </summary>
|
||||
public int MeterStep { get; set; }
|
||||
|
||||
private string? _ProStepInfo;
|
||||
/// <summary>
|
||||
/// 这个步骤是打开具体设置步骤界面的那个层面的信息,例如:2-3,代表是程序2里面的仪表步骤3,方便调试和给液击使用
|
||||
/// </summary>
|
||||
public string? ProStepInfo { get; set; }
|
||||
public string? ProStepInfo
|
||||
{
|
||||
get { return _ProStepInfo; }
|
||||
set { _ProStepInfo = value;RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/////// <summary>
|
||||
/////// 这个步骤是打开具体设置步骤界面的那个层面的信息,例如:2-3,代表是程序2里面的仪表步骤3,方便调试和给液击使用
|
||||
/////// </summary>
|
||||
////public string? ProStepInfo { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 启用状态-没有启用就是什么数据都没有
|
||||
|
||||
@@ -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}" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// </summary>
|
||||
private void LoadChartSourceData()
|
||||
{
|
||||
foreach (var item in MachineRtDataService.TagManger.DicTags)
|
||||
foreach (var item in MachineRtDataService.TagManger.DicTags.OrderBy(a=>a.Value.Id))
|
||||
{
|
||||
ChartSrcDataListViewItems.Add(new ChartSrcData()
|
||||
{
|
||||
|
||||
@@ -259,7 +259,7 @@
|
||||
|
||||
<materialDesign:Card
|
||||
Grid.Row="1"
|
||||
Grid.ColumnSpan="6"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="3"
|
||||
Background="{DynamicResource MaterialDesignLightBackground}"
|
||||
Foreground="{DynamicResource PrimaryHueLightForegroundBrush}"
|
||||
@@ -281,7 +281,7 @@
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
|
||||
<!--<materialDesign:Card
|
||||
<materialDesign:Card
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Grid.ColumnSpan="2"
|
||||
@@ -295,8 +295,8 @@
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="26"
|
||||
Text="" />
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="剩余时间:" />
|
||||
Text="" />
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="当前步骤:" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="30"
|
||||
@@ -319,15 +319,15 @@
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="26"
|
||||
Text="" />
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="当前步骤:" />
|
||||
Text="" />
|
||||
<TextBlock Style="{StaticResource TitelStyle}" Text="步进运行时间:" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontSize="26"
|
||||
FontWeight="Bold"
|
||||
Text="0" />
|
||||
</StackPanel>
|
||||
</materialDesign:Card>-->
|
||||
</materialDesign:Card>
|
||||
|
||||
<materialDesign:Card
|
||||
Grid.Row="2"
|
||||
|
||||
Reference in New Issue
Block a user