CAN 变化更改和物性的更改

This commit is contained in:
2025-10-13 21:30:42 +08:00
parent 3cb4747002
commit 7a2eca6f2f
8 changed files with 35 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
using CapMachine.Wpf.Dtos; using CapMachine.Wpf.Dtos;
namespace CapMachine.Wpf.CanDrive namespace CapMachine.Wpf.CanDrive
{ {
@@ -41,7 +41,10 @@ namespace CapMachine.Wpf.CanDrive
if (_SignalCmdValue != value) if (_SignalCmdValue != value)
{ {
_SignalCmdValue = value; _SignalCmdValue = value;
CanCmdDataChangedHandler!.BeginInvoke(this, MsgName!, null, null); if (CanCmdDataChangedHandler != null)
{
CanCmdDataChangedHandler!.Invoke(this, MsgName!);
}
} }
} }

View File

@@ -542,6 +542,7 @@ namespace CapMachine.Wpf.CanDrive
/// <summary> /// <summary>
/// 加载要发送的数据 /// 加载要发送的数据
/// 一般是激活后才注册事件
/// </summary> /// </summary>
/// <param name="cmdData"></param> /// <param name="cmdData"></param>
public void LoadCmdDataToDrive(List<CanCmdData> cmdData) public void LoadCmdDataToDrive(List<CanCmdData> cmdData)
@@ -557,7 +558,7 @@ namespace CapMachine.Wpf.CanDrive
// Set the new data and subscribe to events // Set the new data and subscribe to events
CmdData = cmdData; CmdData = cmdData;
foreach (var cmd in CmdData) foreach (var cmd in cmdData)
{ {
cmd.CanCmdDataChangedHandler += CmdData_CanCmdDataChangedHandler; cmd.CanCmdDataChangedHandler += CmdData_CanCmdDataChangedHandler;
} }
@@ -589,6 +590,7 @@ namespace CapMachine.Wpf.CanDrive
try try
{ {
if (!IsCycleSend) return; if (!IsCycleSend) return;
if (!SchEnable) return;
// 基础防御:确保 DBC/ 调度表 / 分组已经初始化 // 基础防御:确保 DBC/ 调度表 / 分组已经初始化
if (DBCHandle == 0 || SchCanMsg == null || GroupMsg == null) if (DBCHandle == 0 || SchCanMsg == null || GroupMsg == null)
@@ -651,6 +653,7 @@ namespace CapMachine.Wpf.CanDrive
} }
} }
/// <summary> /// <summary>
/// 循环发送数据 /// 循环发送数据
/// </summary> /// </summary>

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework> <TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>

View File

@@ -776,6 +776,18 @@ namespace CapMachine.Wpf.LinDrive
{ {
if (CmdData.Count() == 0) return; if (CmdData.Count() == 0) return;
//设置调度表发送次数
var SetSchRunTimeRet = USB2LIN_EX.LIN_EX_MasterSetSchRunTimes(DevHandle, LINIndex, 0xFFFFFFFF);//次数为0xFFFFFFFF表示一直发送数据
if (SetSchRunTimeRet < USB2LIN_EX.LIN_EX_SUCCESS)
{
Console.WriteLine("Set Master Run Times failed!");
return;
}
else
{
Console.WriteLine("Set Master Run Times success!");
}
//防止有多个不同的消息名称/帧,每个帧单独处理发送 //防止有多个不同的消息名称/帧,每个帧单独处理发送
var GroupMsg = CmdData.GroupBy(x => x.MsgName); var GroupMsg = CmdData.GroupBy(x => x.MsgName);
foreach (var itemMsg in GroupMsg) foreach (var itemMsg in GroupMsg)
@@ -803,7 +815,6 @@ namespace CapMachine.Wpf.LinDrive
} }
} }
LDFParser.LDF_ExeSchToBus(LDFHandle, new StringBuilder(itemMsg.Key), 1);
LDFParser.LDF_SetSchToTable(LDFHandle, new StringBuilder(itemMsg.Key), 1); LDFParser.LDF_SetSchToTable(LDFHandle, new StringBuilder(itemMsg.Key), 1);
} }
@@ -859,7 +870,7 @@ namespace CapMachine.Wpf.LinDrive
LDFParser.LDF_SetSchToTable(LDFHandle, new StringBuilder(itemMsg.Key), 1); LDFParser.LDF_SetSchToTable(LDFHandle, new StringBuilder(itemMsg.Key), 1);
} }
IsSendOk = true;
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@@ -1,9 +1,4 @@
using System; using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace CapMachine.Wpf.LinDrive namespace CapMachine.Wpf.LinDrive
{ {
@@ -95,7 +90,12 @@ namespace CapMachine.Wpf.LinDrive
public static extern Int32 LIN_EX_MasterStopSch(Int32 DevHandle, Byte LINIndex); public static extern Int32 LIN_EX_MasterStopSch(Int32 DevHandle, Byte LINIndex);
[DllImport("USB2XXX.dll")] [DllImport("USB2XXX.dll")]
public static extern Int32 LIN_EX_MasterGetSch(Int32 DevHandle, Byte LINIndex, IntPtr pLINMsg); public static extern Int32 LIN_EX_MasterGetSch(Int32 DevHandle, Byte LINIndex, IntPtr pLINMsg);
[DllImport("USB2XXX.dll")]
public static extern Int32 LIN_EX_MasterSetSchRunTimes(Int32 DevHandle, Byte LINIndex, UInt32 RunTimes);
[DllImport("USB2XXX.dll")]
public static extern Int64 LIN_EX_GetStartTime(Int32 DevHandle, Byte LINIndex);
[DllImport("USB2XXX.dll")]
public static extern Int32 LIN_EX_ResetStartTime(Int32 DevHandle, Byte LINIndex);
[DllImport("USB2XXX.dll")] [DllImport("USB2XXX.dll")]
public static extern Int32 LIN_EX_MasterOfflineSch(Int32 DevHandle, Byte LINIndex, Int32 BaudRate, LIN_EX_MSG[] pLINMsg, Int32 MsgLen); public static extern Int32 LIN_EX_MasterOfflineSch(Int32 DevHandle, Byte LINIndex, Int32 BaudRate, LIN_EX_MSG[] pLINMsg, Int32 MsgLen);
[DllImport("USB2XXX.dll")] [DllImport("USB2XXX.dll")]

View File

@@ -314,7 +314,7 @@ namespace CapMachine.Wpf.Services
if (CmdData.Count > 0) if (CmdData.Count > 0)
{ {
//把指令数据赋值给CAN 驱动 //把指令数据赋值给CAN 驱动
ToomossCanDrive.LoadCmdDataToDrive(CmdData); ToomossCanDrive.CmdData = CmdData;
if (ToomossCanDrive.SchEnable) if (ToomossCanDrive.SchEnable)
{ {
@@ -337,7 +337,7 @@ namespace CapMachine.Wpf.Services
} }
ToomossCanDrive.ListCANScheduleConfig = ListCANScheduleConfig!; ToomossCanDrive.ListCANScheduleConfig = ListCANScheduleConfig!;
ToomossCanDrive.StartSchedule(); ToomossCanDrive.StartSchedule();
ToomossCanDrive.StartCycleUpdateCmd(); //ToomossCanDrive.StartCycleUpdateCmd();
} }
else else
{ {

View File

@@ -1,19 +1,11 @@
using CapMachine.Core; using CapMachine.Core;
using CapMachine.Shared.Controls;
using CapMachine.Wpf.Models.PPCalc; using CapMachine.Wpf.Models.PPCalc;
using CapMachine.Wpf.Models.Tag; using CapMachine.Wpf.Models.Tag;
using CapMachine.Wpf.PPCalculation; using CapMachine.Wpf.PPCalculation;
using NLog;
using Prism.Events; using Prism.Events;
using Prism.Mvvm; using Prism.Mvvm;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NLog;
namespace CapMachine.Wpf.Services namespace CapMachine.Wpf.Services
{ {

View File

@@ -1,4 +1,4 @@
using AutoMapper; using AutoMapper;
using CapMachine.Core; using CapMachine.Core;
using CapMachine.Model; using CapMachine.Model;
using CapMachine.Model.CANLIN; using CapMachine.Model.CANLIN;
@@ -489,6 +489,7 @@ namespace CapMachine.Wpf.ViewModels
CanDriveService.InitCanConfig(SelectCanLinConfigPro); CanDriveService.InitCanConfig(SelectCanLinConfigPro);
InitLoadCanConfigPro(); InitLoadCanConfigPro();
CanDriveService.ToomossCanDrive.LoadCmdDataToDrive(CanDriveService.CmdData);
} }
else else
{ {