|
|
using CompressorXN.Untils;
|
|
|
using CompressorXN_Common;
|
|
|
using CompressorXN_Communication;
|
|
|
using CompressorXN_Communication.MyPlc;
|
|
|
using CompressorXN_Communication.TuMos;
|
|
|
using CompressorXN_ControlLib;
|
|
|
using CompressorXN_Log;
|
|
|
using CompressorXN_Model;
|
|
|
using CompressorXN_Model.Enums;
|
|
|
using CompressorXN_Model.ViewModel.Plc;
|
|
|
using CompressorXN_Service;
|
|
|
using HslControls;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.InteropServices;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using thinger.DataConvertLib;
|
|
|
using USB2XXX;
|
|
|
|
|
|
namespace CompressorXN
|
|
|
{
|
|
|
public partial class FrmHome : Form
|
|
|
{
|
|
|
private static readonly AgreementMsgService _agreementMsgService = new AgreementMsgService();
|
|
|
private static readonly ProductTypeService _productTypeService = new ProductTypeService();
|
|
|
private CancellationTokenSource cts;//用于控制线程
|
|
|
|
|
|
private static ManualResetEvent speed1_ManualResetEvent = new ManualResetEvent(false);
|
|
|
private static ManualResetEvent speed2_ManualResetEvent = new ManualResetEvent(false);
|
|
|
private static ManualResetEvent speed3_ManualResetEvent = new ManualResetEvent(false);
|
|
|
private static ManualResetEvent additional_ManualResetEvent = new ManualResetEvent(false);
|
|
|
|
|
|
public FrmHome()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
cts = new CancellationTokenSource();
|
|
|
|
|
|
GlobalVar.StartTypeValueChanged += GlobalVar_StartTypeValueChanged;
|
|
|
|
|
|
T_ProductType usedProductType = _productTypeService.QueryUsedProductType();
|
|
|
if (usedProductType == null)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
GlobalVar.ProductTypeName = usedProductType.ProductTypeName;
|
|
|
//参数写入PLC
|
|
|
var (isOk, msg) = WriteToPlcHelper.WriteParaToPlc(GlobalVar.ProductTypeName);
|
|
|
if (!isOk)
|
|
|
{
|
|
|
new FrmDialog(msg).ShowDialog();
|
|
|
}
|
|
|
|
|
|
GlobalVar.agreementMsgVM = _agreementMsgService.GetAgreementMsgByProductTypeName(GlobalVar.ProductTypeName);
|
|
|
|
|
|
GlobalVar.StartType = GlobalVar.agreementMsgVM.StartType;
|
|
|
|
|
|
(isOk, msg) = BaseTMS.OpenDevice();
|
|
|
if (!isOk)
|
|
|
{
|
|
|
new FrmDialog(msg).ShowDialog();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CAN")
|
|
|
{
|
|
|
BaseTMS.CanInit((uint)GlobalVar.agreementMsgVM.Bps);
|
|
|
}
|
|
|
else if (GlobalVar.agreementMsgVM.StartType == "CANFD")
|
|
|
{
|
|
|
//新建CANFD进程
|
|
|
BaseTMS.CANFDInit(5000000, (uint)GlobalVar.agreementMsgVM.Bps);
|
|
|
}
|
|
|
else if (GlobalVar.agreementMsgVM.StartType == "LIN")
|
|
|
{
|
|
|
TMSLINHelper.LinInit(GlobalVar.agreementMsgVM.Bps);
|
|
|
}
|
|
|
|
|
|
//初始化曲线
|
|
|
InitCurve();
|
|
|
|
|
|
//根据PLC信号进行动作
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
Dosomething();
|
|
|
|
|
|
Thread.Sleep(5);
|
|
|
}
|
|
|
}, cts.Token);
|
|
|
|
|
|
//显示采集值及结果状态
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
LoadParaData();
|
|
|
Thread.Sleep(10);
|
|
|
}
|
|
|
}, cts.Token);
|
|
|
|
|
|
//设置曲线数据
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
LoadCurveData();
|
|
|
Thread.Sleep(100);
|
|
|
}
|
|
|
}, cts.Token);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private void GlobalVar_StartTypeValueChanged(string arg1, string arg2)
|
|
|
{
|
|
|
#region 图莫斯通讯线程
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
if (arg2 == "CAN")
|
|
|
{
|
|
|
CAN_SendSpeed1();
|
|
|
}
|
|
|
else if (arg2 == "CANFD")
|
|
|
{
|
|
|
CANFD_SendSpeed1();
|
|
|
}
|
|
|
else if (arg2 == "LIN")
|
|
|
{
|
|
|
LIN_SendSpeed1();
|
|
|
}
|
|
|
}, cts.Token);
|
|
|
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
if (arg2 == "CAN")
|
|
|
{
|
|
|
CAN_SendSpeed2();
|
|
|
}
|
|
|
else if (arg2 == "CANFD")
|
|
|
{
|
|
|
CANFD_SendSpeed2();
|
|
|
}
|
|
|
else if (arg2 == "LIN")
|
|
|
{
|
|
|
LIN_SendSpeed2();
|
|
|
}
|
|
|
}, cts.Token);
|
|
|
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
if (arg2 == "CAN")
|
|
|
{
|
|
|
CAN_SendSpeed3();
|
|
|
}
|
|
|
else if (arg2 == "CANFD")
|
|
|
{
|
|
|
CANFD_SendSpeed3();
|
|
|
}
|
|
|
else if (arg2 == "LIN")
|
|
|
{
|
|
|
LIN_SendSpeed3();
|
|
|
}
|
|
|
}, cts.Token);
|
|
|
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
if (arg2 == "CAN")
|
|
|
{
|
|
|
CAN_SendAdditional();
|
|
|
}
|
|
|
else if (arg2 == "CANFD")
|
|
|
{
|
|
|
CANFD_SendAdditional();
|
|
|
}
|
|
|
else if (arg2 == "LIN")
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}, cts.Token);
|
|
|
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
if (arg2 == "CAN")
|
|
|
{
|
|
|
CAN_ReciveMsg();
|
|
|
}
|
|
|
else if (arg2 == "CANFD")
|
|
|
{
|
|
|
CANFD_ReciveMsg();
|
|
|
}
|
|
|
else if (arg2 == "LIN")
|
|
|
{
|
|
|
LIN_ReciveMsg();
|
|
|
}
|
|
|
}, cts.Token);
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// PLC变量集合
|
|
|
/// </summary>
|
|
|
private static List<Variable> variableList = GlobalVar.deviceInfo.CommGroupList.FirstOrDefault().VariableList;
|
|
|
|
|
|
private void FrmHome_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
Task.Run(() =>
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
UpdateMyResultControl(result_Speed, GlobalVar.RealSpeed.ToString(), Color.Gainsboro);
|
|
|
|
|
|
Thread.Sleep(10);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 动作逻辑
|
|
|
/// </summary>
|
|
|
private void Dosomething()
|
|
|
{
|
|
|
//步序
|
|
|
string D1190 = OmronCIPHelper.SingleReadPlcVal("D1190", "float").val;
|
|
|
|
|
|
//压缩机停止转动
|
|
|
if (D1190 == "10.000" || D1190 == "0.000")
|
|
|
{
|
|
|
speed1_ManualResetEvent.Reset();
|
|
|
speed2_ManualResetEvent.Reset();
|
|
|
speed3_ManualResetEvent.Reset();
|
|
|
additional_ManualResetEvent.Reset();
|
|
|
|
|
|
OmronCIPHelper.SingleWriteValToPlc("D1244", "float", 1);//停机反馈PLC
|
|
|
|
|
|
currentResetEvent.Reset();//停止曲线数据采集
|
|
|
}
|
|
|
else if (D1190 == "1.000" || D1190 == "2.000")//电检或者空载阶段清空曲线数据
|
|
|
{
|
|
|
ClearCurveData();//清空曲线数据
|
|
|
|
|
|
//清空接收缓冲区数据
|
|
|
ret = USB2CAN.CAN_ClearMsg(GlobalVar.DevHandle, GlobalVar.ReadCANIndex);
|
|
|
if (ret != USB2CAN.CAN_SUCCESS)
|
|
|
{
|
|
|
Console.WriteLine("Clear Message Failed!");
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Clear Message Success!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//PLC请求一段速打开电机
|
|
|
var D1224 = OmronCIPHelper.SingleReadPlcVal("D1224", "float").val;
|
|
|
if (D1224 == "1.000")
|
|
|
{
|
|
|
GlobalVar.stepEnum = StepEnum.speed1;
|
|
|
speed1_ManualResetEvent.Set();
|
|
|
additional_ManualResetEvent.Set();
|
|
|
currentResetEvent.Set();//启动曲线数据采集
|
|
|
|
|
|
}
|
|
|
//PLC请求二段速打开电机
|
|
|
var D1228 = OmronCIPHelper.SingleReadPlcVal("D1228", "float").val;
|
|
|
if (D1228 == "1.000")
|
|
|
{
|
|
|
GlobalVar.stepEnum = StepEnum.speed2;
|
|
|
speed1_ManualResetEvent.Reset();
|
|
|
speed2_ManualResetEvent.Set();
|
|
|
additional_ManualResetEvent.Set();
|
|
|
}
|
|
|
//PLC请求三段速打开电机
|
|
|
var D1232 = OmronCIPHelper.SingleReadPlcVal("D1232", "float").val;
|
|
|
if (D1232 == "1.000")
|
|
|
{
|
|
|
GlobalVar.stepEnum = StepEnum.speed3;
|
|
|
speed1_ManualResetEvent.Reset();
|
|
|
speed2_ManualResetEvent.Reset();
|
|
|
speed3_ManualResetEvent.Set();
|
|
|
additional_ManualResetEvent.Set();
|
|
|
}
|
|
|
//内漏阶段,关机
|
|
|
var D1236 = OmronCIPHelper.SingleReadPlcVal("D1236", "float").val;
|
|
|
if (D1236 == "1.000")
|
|
|
{
|
|
|
GlobalVar.stepEnum = StepEnum.endolead;
|
|
|
|
|
|
speed1_ManualResetEvent.Reset();
|
|
|
speed2_ManualResetEvent.Reset();
|
|
|
speed3_ManualResetEvent.Reset();
|
|
|
additional_ManualResetEvent.Reset();
|
|
|
currentResetEvent.Reset();//停止曲线数据采集
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 控制压缩机
|
|
|
/// </summary>
|
|
|
/// <param name="stepEnum"></param>
|
|
|
/// <param name="start">是否启动压缩机</param>
|
|
|
private void ControlTask(StepEnum stepEnum, bool start)
|
|
|
{
|
|
|
switch (GlobalVar.agreementMsgVM.StartType)
|
|
|
{
|
|
|
case "CAN":
|
|
|
if (start)
|
|
|
{
|
|
|
GlobalVar.stepEnum = stepEnum;
|
|
|
if (!GlobalVar.CAN_SendMsgFlag)
|
|
|
{
|
|
|
TMSCANHelper.CAN_StartTask();
|
|
|
currentResetEvent.Set();//启动曲线数据采集
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "LIN":
|
|
|
if (start)
|
|
|
{
|
|
|
GlobalVar.stepEnum = stepEnum;
|
|
|
if (!GlobalVar.LIN_SendMsgFlag)
|
|
|
{
|
|
|
TMSLINHelper.LIN_StartTask();
|
|
|
currentResetEvent.Set();//启动曲线数据采集
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "PWM":
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 显示采集值
|
|
|
/// </summary>
|
|
|
private void LoadParaData()
|
|
|
{
|
|
|
//当前生产中机型
|
|
|
UpdateTextBoxControl(txt_ProductType, GlobalVar.ProductTypeName);
|
|
|
//产品编码
|
|
|
Variable D1160 = variableList.FirstOrDefault(m => m.VariableName == "D1160");
|
|
|
UpdateTextBoxControl(txtProductCode, D1160?.ReadVal?.ToString());
|
|
|
|
|
|
List<GroupBoxEx> groupBoxExList = this.Controls.OfType<GroupBoxEx>().ToList();
|
|
|
foreach (GroupBoxEx groupBoxEx in groupBoxExList)
|
|
|
{
|
|
|
//设置groupBoxEx边框颜色(根据各阶段总状态)
|
|
|
if (groupBoxEx.Tag != null)
|
|
|
{
|
|
|
Variable variable = variableList.FirstOrDefault(m => m.VariableName == groupBoxEx.Tag.ToString());
|
|
|
if (variable != null)
|
|
|
{
|
|
|
string readVal = variable.ReadVal?.ToString();
|
|
|
UpdateGroupBoxExBorderColor(groupBoxEx, GetColorByReadVal(readVal));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
List<MyResultControl> resultCtlList = groupBoxEx.Controls.OfType<MyResultControl>().ToList();
|
|
|
foreach (MyResultControl myResultControl in resultCtlList)
|
|
|
{
|
|
|
if (myResultControl.Name != "result_Speed")
|
|
|
{
|
|
|
Variable Result_variable = variableList.FirstOrDefault(m => m.VariableName == myResultControl.TestResultPLCPointCode);
|
|
|
Variable Val_variable = variableList.FirstOrDefault(m => m.VariableName == myResultControl.TestValPLCPointCode);
|
|
|
|
|
|
if (Val_variable != null)
|
|
|
{
|
|
|
string readVal = Val_variable.ReadVal?.ToString();
|
|
|
Color color = GetColorByReadVal(Result_variable?.ReadVal?.ToString());
|
|
|
UpdateMyResultControl(myResultControl, readVal, color);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 曲线相关
|
|
|
|
|
|
private ManualResetEvent currentResetEvent = new ManualResetEvent(false);//控制曲线
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化曲线
|
|
|
/// </summary>
|
|
|
private void InitCurve()
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = 1500;
|
|
|
// 自定义倍率
|
|
|
hslCurveHistory.SetScaleByXAxis(12);
|
|
|
chk_OutPress.Checked = true;
|
|
|
hslCurveHistory.RenderCurveUI();
|
|
|
Console.WriteLine("初始化曲线完成");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置曲线数据
|
|
|
/// </summary>
|
|
|
private void LoadCurveData()
|
|
|
{
|
|
|
currentResetEvent.WaitOne();//等待信号
|
|
|
|
|
|
//时间
|
|
|
GlobalVar.times.Add(DateTime.Now);
|
|
|
//出口压力
|
|
|
string D1402 = OmronCIPHelper.SingleReadPlcVal("D1402", "float").val;
|
|
|
if (!string.IsNullOrEmpty(D1402))
|
|
|
{
|
|
|
float.TryParse(D1402, out float D1402Val);
|
|
|
GlobalVar.OutPress.Add(D1402Val);
|
|
|
}
|
|
|
|
|
|
//进口压力
|
|
|
string D1400 = OmronCIPHelper.SingleReadPlcVal("D1400", "float").val;
|
|
|
if (!string.IsNullOrEmpty(D1400))
|
|
|
{
|
|
|
float.TryParse(D1400, out float D1400Val);
|
|
|
GlobalVar.InPress.Add(D1400Val);
|
|
|
}
|
|
|
|
|
|
//罐压力
|
|
|
string D1404 = OmronCIPHelper.SingleReadPlcVal("D1404", "float").val;
|
|
|
if (!string.IsNullOrEmpty(D1404))
|
|
|
{
|
|
|
float.TryParse(D1404, out float D1404Val);
|
|
|
GlobalVar.JarPress.Add(D1404Val);
|
|
|
}
|
|
|
|
|
|
//电压
|
|
|
string D1406 = OmronCIPHelper.SingleReadPlcVal("D1406", "float").val;
|
|
|
if (!string.IsNullOrEmpty(D1406))
|
|
|
{
|
|
|
float.TryParse(D1406, out float D1406Val);
|
|
|
GlobalVar.Voltage.Add(D1406Val);
|
|
|
}
|
|
|
|
|
|
//电流
|
|
|
string D1408 = OmronCIPHelper.SingleReadPlcVal("D1408", "float").val;
|
|
|
if (!string.IsNullOrEmpty(D1408))
|
|
|
{
|
|
|
float.TryParse(D1408, out float D1408Val);
|
|
|
GlobalVar.Current.Add(D1408Val);
|
|
|
}
|
|
|
|
|
|
//噪音
|
|
|
string D1418 = OmronCIPHelper.SingleReadPlcVal("D1418", "float").val;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(D1418))
|
|
|
{
|
|
|
float.TryParse(D1418, out float D1418Val);
|
|
|
GlobalVar.Noise.Add(D1418Val);
|
|
|
}
|
|
|
//X轴振动
|
|
|
string D1416 = OmronCIPHelper.SingleReadPlcVal("D1416", "float").val;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(D1416))
|
|
|
{
|
|
|
float.TryParse(D1416, out float D1416Val);
|
|
|
GlobalVar.X_Vibrate.Add(D1416Val);
|
|
|
}
|
|
|
//Y轴振动
|
|
|
string D1422 = OmronCIPHelper.SingleReadPlcVal("D1422", "float").val;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(D1422))
|
|
|
{
|
|
|
float.TryParse(D1422, out float D1422Val);
|
|
|
GlobalVar.Y_Vibrate.Add(D1422Val);
|
|
|
}
|
|
|
//Z轴振动
|
|
|
string D1424 = OmronCIPHelper.SingleReadPlcVal("D1424", "float").val;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(D1424))
|
|
|
{
|
|
|
float.TryParse(D1424, out float D1424Val);
|
|
|
GlobalVar.Z_Vibrate.Add(D1424Val);
|
|
|
}
|
|
|
int offset = 10;
|
|
|
#region 显示曲线数据
|
|
|
this.BeginInvoke(new Action(() =>
|
|
|
{
|
|
|
if (GlobalVar.OutPress.Count > 0 && chk_OutPress.Checked)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.OutPress.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("出口压力", GlobalVar.OutPress.ToArray(), Color.Tomato, CurveStyle.Curve, "{0:F2} kPa");
|
|
|
}
|
|
|
//if (GlobalVar.InPress.Count > 0 && chk_InPress.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.InPress.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("进口压力", GlobalVar.InPress.ToArray(), Color.DodgerBlue, CurveStyle.Curve, "{0:F2} kPa");
|
|
|
//}
|
|
|
//if (GlobalVar.JarPress.Count > 0 && chk_JarPress.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.JarPress.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("罐压力", GlobalVar.JarPress.ToArray(), Color.Yellow, CurveStyle.Curve, "{0:F2} kPa");
|
|
|
//}
|
|
|
//if (GlobalVar.Voltage.Count > 0 && chk_Voltage.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Voltage.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("电压", GlobalVar.Voltage.ToArray(), Color.DarkOliveGreen, CurveStyle.Curve, "{0:F2} V");
|
|
|
//}
|
|
|
//if (GlobalVar.Current.Count > 0 && chk_Current.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Current.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("电流", GlobalVar.Current.ToArray(), Color.Gold, CurveStyle.Curve, "{0:F2} A");
|
|
|
//}
|
|
|
//if (GlobalVar.Noise.Count > 0 && chk_Noise.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Noise.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("噪音", GlobalVar.Noise.ToArray(), Color.BlueViolet, CurveStyle.Curve, "{0:F2} dB");
|
|
|
//}
|
|
|
//if (GlobalVar.X_Vibrate.Count > 0 && chk_X_Vibrate.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.X_Vibrate.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("X轴振动", GlobalVar.X_Vibrate.ToArray(), Color.White, CurveStyle.Curve, "{0:F2} mm");
|
|
|
//}
|
|
|
//if (GlobalVar.Y_Vibrate.Count > 0 && chk_Y_Vibrate.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Y_Vibrate.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("Y轴振动", GlobalVar.Y_Vibrate.ToArray(), Color.Green, CurveStyle.Curve, "{0:F2} mm");
|
|
|
//}
|
|
|
//if (GlobalVar.Z_Vibrate.Count > 0 && chk_Z_Vibrate.Checked)
|
|
|
//{
|
|
|
// hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Z_Vibrate.Max() + offset;
|
|
|
// hslCurveHistory.SetLeftCurve("Z轴振动", GlobalVar.Z_Vibrate.ToArray(), Color.Orange, CurveStyle.Curve, "{0:F2} mm");
|
|
|
//}
|
|
|
hslCurveHistory.SetDateTimes(GlobalVar.times.ToArray());
|
|
|
|
|
|
hslCurveHistory.ScrollToRight();
|
|
|
hslCurveHistory.RenderCurveUI();
|
|
|
}));
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 复选框Change
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void CheckedChanged(object sender, EventArgs e)
|
|
|
{
|
|
|
int offset = 0;
|
|
|
var checkBox = sender as CheckBox;
|
|
|
var checkBoxList = this.Controls.OfType<CheckBox>().ToList();
|
|
|
var checkedList = checkBoxList.Where(m => m.Checked).ToList();
|
|
|
if (checkedList.Count <= 0)
|
|
|
{
|
|
|
chk_OutPress.Checked = true;
|
|
|
}
|
|
|
if (checkBox.Checked)
|
|
|
{
|
|
|
foreach (var item in checkBoxList)
|
|
|
{
|
|
|
if (item != checkBox)
|
|
|
{
|
|
|
item.Checked = false;
|
|
|
hslCurveHistory.SetCurveVisible(item.Text, false);
|
|
|
}
|
|
|
}
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = 1500;
|
|
|
switch (checkBox.Text)
|
|
|
{
|
|
|
case "出口压力":
|
|
|
if (GlobalVar.OutPress.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.OutPress.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("出口压力", GlobalVar.OutPress.ToArray(), Color.Tomato, CurveStyle.Curve, "{0:F2} kPa");
|
|
|
}
|
|
|
break;
|
|
|
case "进口压力":
|
|
|
if (GlobalVar.InPress.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.InPress.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("进口压力", GlobalVar.InPress.ToArray(), Color.DodgerBlue, CurveStyle.Curve, "{0:F2} kPa");
|
|
|
}
|
|
|
break;
|
|
|
case "罐压力":
|
|
|
if (GlobalVar.JarPress.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.JarPress.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("罐压力", GlobalVar.JarPress.ToArray(), Color.Yellow, CurveStyle.Curve, "{0:F2} kPa");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "电压":
|
|
|
if (GlobalVar.Voltage.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Voltage.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("电压", GlobalVar.Voltage.ToArray(), Color.DarkOliveGreen, CurveStyle.Curve, "{0:F2} V");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "电流":
|
|
|
if (GlobalVar.Current.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Current.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("电流", GlobalVar.Current.ToArray(), Color.Gold, CurveStyle.Curve, "{0:F2} A");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "噪音":
|
|
|
if (GlobalVar.Noise.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Noise.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("噪音", GlobalVar.Noise.ToArray(), Color.BlueViolet, CurveStyle.Curve, "{0:F2} dB");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "X轴振动":
|
|
|
if (GlobalVar.X_Vibrate.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.X_Vibrate.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("X轴振动", GlobalVar.X_Vibrate.ToArray(), Color.White, CurveStyle.Curve, "{0:F2} mm");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "Y轴振动":
|
|
|
if (GlobalVar.Y_Vibrate.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Y_Vibrate.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("Y轴振动", GlobalVar.Y_Vibrate.ToArray(), Color.Green, CurveStyle.Curve, "{0:F2} mm");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "Z轴振动":
|
|
|
if (GlobalVar.Z_Vibrate.Count > 0)
|
|
|
{
|
|
|
hslCurveHistory.ReferenceAxisLeft.Max = GlobalVar.Z_Vibrate.Max() + offset;
|
|
|
hslCurveHistory.SetLeftCurve("Z轴振动", GlobalVar.Z_Vibrate.ToArray(), Color.Orange, CurveStyle.Curve, "{0:F2} mm");
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
|
|
|
hslCurveHistory.SetCurveVisible(checkBox.Text, true);
|
|
|
|
|
|
hslCurveHistory.RenderCurveUI();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据采集值获取颜色
|
|
|
/// </summary>
|
|
|
/// <param name="readVal"></param>
|
|
|
/// <returns></returns>
|
|
|
private System.Drawing.Color GetColorByReadVal(string readVal)
|
|
|
{
|
|
|
return readVal == "1.000" ? Color.Green : (readVal == "2.000" ? Color.Red : Color.Silver);
|
|
|
}
|
|
|
|
|
|
private void UpdateMyResultControl(MyResultControl myResultControl, string val, System.Drawing.Color color)
|
|
|
{
|
|
|
if (myResultControl.InvokeRequired)
|
|
|
{
|
|
|
this.Invoke(new Action(() =>
|
|
|
{
|
|
|
if (!myResultControl.IsHandleCreated || myResultControl.IsDisposed || myResultControl.Disposing)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
myResultControl.TestValText = val;
|
|
|
myResultControl.TestResultBackColor = color;
|
|
|
}));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
myResultControl.TestValText = val;
|
|
|
myResultControl.TestResultBackColor = color;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void UpdateTextBoxControl(TextBox textBox, string val)
|
|
|
{
|
|
|
if (textBox.InvokeRequired)
|
|
|
{
|
|
|
this.Invoke(new Action(() =>
|
|
|
{
|
|
|
if (!textBox.IsHandleCreated || textBox.IsDisposed || textBox.Disposing)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
textBox.Text = val;
|
|
|
}));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
textBox.Text = val;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 异步更新GroupBoxEx控件背景色
|
|
|
/// </summary>
|
|
|
/// <param name="groupBoxEx"></param>
|
|
|
/// <param name="borderColor"></param>
|
|
|
private void UpdateGroupBoxExBorderColor(GroupBoxEx groupBoxEx, Color borderColor)
|
|
|
{
|
|
|
if (groupBoxEx.InvokeRequired)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
this.BeginInvoke(new Action(() =>
|
|
|
{
|
|
|
if (!groupBoxEx.IsHandleCreated || groupBoxEx.IsDisposed || groupBoxEx.Disposing)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
groupBoxEx.BorderColor = borderColor;
|
|
|
}));
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
LogHelper.Error(ex, $"异步更新控件内容失败");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
groupBoxEx.BackColor = borderColor;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void FrmHome_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
{
|
|
|
cts.Cancel();
|
|
|
TMSCANHelper.CAN_StopTask();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 清空曲线数据
|
|
|
/// </summary>
|
|
|
private void ClearCurveData()
|
|
|
{
|
|
|
GlobalVar.times.Clear();
|
|
|
GlobalVar.OutPress.Clear();
|
|
|
GlobalVar.InPress.Clear();
|
|
|
GlobalVar.JarPress.Clear();
|
|
|
GlobalVar.Voltage.Clear();
|
|
|
GlobalVar.Current.Clear();
|
|
|
GlobalVar.Noise.Clear();
|
|
|
GlobalVar.X_Vibrate.Clear();
|
|
|
GlobalVar.Y_Vibrate.Clear();
|
|
|
GlobalVar.Z_Vibrate.Clear();
|
|
|
}
|
|
|
|
|
|
#region 图莫斯模块通讯
|
|
|
|
|
|
#region CAN
|
|
|
|
|
|
private static Int32 ret = 0;
|
|
|
private static USB2CAN.CAN_MSG[] CanMsg = null;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 一段速度
|
|
|
/// </summary>
|
|
|
private void CAN_SendSpeed1()
|
|
|
{
|
|
|
if (CanMsg == null)
|
|
|
{
|
|
|
CanMsg = new USB2CAN.CAN_MSG[1];
|
|
|
CanMsg[0] = new USB2CAN.CAN_MSG
|
|
|
{
|
|
|
ExternFlag = GlobalVar.agreementMsgVM.FrameType == "EXTEND" ? (byte)1 : (byte)0, //bit[0] - 是否是扩展帧,bit[7] - 当前帧为错误帧
|
|
|
RemoteFlag = 0,//bit[0]-是否是远程帧,bit[6..5]-当前帧通道号,bit[7]-发送帧标志
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID
|
|
|
DataLen = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF)//数据长度(<=8),即Data中有效数据长度
|
|
|
};
|
|
|
}
|
|
|
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected || GlobalVar.agreementMsgVM == null || GlobalVar.agreementMsgVM.StartType != "CAN")
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
speed1_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动了CAN_SendSpeed1");
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CAN")
|
|
|
{
|
|
|
string speed1Hex = GlobalVar.agreementMsgVM.Speed1Hex;
|
|
|
if (!string.IsNullOrEmpty(speed1Hex))
|
|
|
{
|
|
|
CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed1Hex);
|
|
|
}
|
|
|
int SendedNum = USB2CAN.CAN_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, CanMsg, (UInt32)CanMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
// Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{0}", SendMsgNum);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Send CAN data failed!");
|
|
|
//break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 二段速度
|
|
|
/// </summary>
|
|
|
private void CAN_SendSpeed2()
|
|
|
{
|
|
|
|
|
|
if (CanMsg == null)
|
|
|
{
|
|
|
CanMsg = new USB2CAN.CAN_MSG[1];
|
|
|
CanMsg[0] = new USB2CAN.CAN_MSG
|
|
|
{
|
|
|
ExternFlag = GlobalVar.agreementMsgVM.FrameType == "EXTEND" ? (byte)1 : (byte)0, //bit[0] - 是否是扩展帧,bit[7] - 当前帧为错误帧
|
|
|
RemoteFlag = 0,//bit[0]-是否是远程帧,bit[6..5]-当前帧通道号,bit[7]-发送帧标志
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID
|
|
|
DataLen = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF)//数据长度(<=8),即Data中有效数据长度
|
|
|
};
|
|
|
}
|
|
|
|
|
|
while (true)
|
|
|
{
|
|
|
speed2_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动了CAN_SendSpeed2");
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CAN")
|
|
|
{
|
|
|
string speed2Hex = GlobalVar.agreementMsgVM.Speed2Hex;
|
|
|
if (!string.IsNullOrEmpty(speed2Hex))
|
|
|
{
|
|
|
CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed2Hex);
|
|
|
}
|
|
|
|
|
|
int SendedNum = USB2CAN.CAN_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, CanMsg, (UInt32)CanMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
// Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{SendMsgNum}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Send CAN data failed!");
|
|
|
//break;
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 三段速度
|
|
|
/// </summary>
|
|
|
private void CAN_SendSpeed3()
|
|
|
{
|
|
|
|
|
|
if (CanMsg == null)
|
|
|
{
|
|
|
CanMsg = new USB2CAN.CAN_MSG[1];
|
|
|
CanMsg[0] = new USB2CAN.CAN_MSG
|
|
|
{
|
|
|
ExternFlag = GlobalVar.agreementMsgVM.FrameType == "EXTEND" ? (byte)1 : (byte)0, //bit[0] - 是否是扩展帧,bit[7] - 当前帧为错误帧
|
|
|
RemoteFlag = 0,//bit[0]-是否是远程帧,bit[6..5]-当前帧通道号,bit[7]-发送帧标志
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID
|
|
|
DataLen = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF)//数据长度(<=8),即Data中有效数据长度
|
|
|
};
|
|
|
}
|
|
|
|
|
|
while (true)
|
|
|
{
|
|
|
speed3_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动了CAN_SendSpeed3");
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CAN")
|
|
|
{
|
|
|
string speed3Hex = GlobalVar.agreementMsgVM.Speed3Hex;
|
|
|
if (!string.IsNullOrEmpty(speed3Hex))
|
|
|
{
|
|
|
CanMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed3Hex);
|
|
|
}
|
|
|
|
|
|
int SendedNum = USB2CAN.CAN_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, CanMsg, (UInt32)CanMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
// Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{SendMsgNum}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Send CAN data failed!");
|
|
|
//break;
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 附加报文
|
|
|
/// </summary>
|
|
|
private async void CAN_SendAdditional()
|
|
|
{
|
|
|
USB2CAN.CAN_MSG[] additionalCanMsg = null;
|
|
|
if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId) && !string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent) && additionalCanMsg == null)
|
|
|
{
|
|
|
additionalCanMsg = new USB2CAN.CAN_MSG[1];
|
|
|
additionalCanMsg[0] = new USB2CAN.CAN_MSG
|
|
|
{
|
|
|
ExternFlag = GlobalVar.agreementMsgVM.FrameType == "EXTEND" ? (byte)1 : (byte)0, //bit[0] - 是否是扩展帧,bit[7] - 当前帧为错误帧
|
|
|
RemoteFlag = 0,//bit[0]-是否是远程帧,bit[6..5]-当前帧通道号,bit[7]-发送帧标志
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId, 16),//报文ID
|
|
|
DataLen = 8,//数据长度(<=8),即Data中有效数据长度
|
|
|
Data = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent)
|
|
|
};
|
|
|
}
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || GlobalVar.agreementMsgVM == null || GlobalVar.agreementMsgVM.SendAdditionalRules == null || string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId) || string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent))
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
additional_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动发送附加报文==" + StringLib.GetHexStringFromByteArray(additionalCanMsg[0].Data));
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CAN")
|
|
|
{
|
|
|
int SendedNum = USB2CAN.CAN_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, additionalCanMsg, (UInt32)additionalCanMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
Console.WriteLine("附加报文Success send frames:{0}", SendedNum);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("附加报文Send CAN data failed!");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
await Task.Delay(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalPeriod);
|
|
|
//Thread.Sleep(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接收报文
|
|
|
/// </summary>
|
|
|
private void CAN_ReciveMsg()
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
if (GlobalVar.DevHandle <= 0)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CAN")
|
|
|
{
|
|
|
USB2CAN.CAN_MSG[] CanMsgBuffer = new USB2CAN.CAN_MSG[1024];
|
|
|
//申请数据缓冲区
|
|
|
IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CAN.CAN_MSG)) * CanMsgBuffer.Length);
|
|
|
|
|
|
int CanNum = USB2CAN.CAN_GetMsgWithSize(GlobalVar.DevHandle, GlobalVar.ReadCANIndex, pt, CanMsgBuffer.Length);
|
|
|
if (CanNum > 0)
|
|
|
{
|
|
|
for (int i = 0; i < CanNum; i++)
|
|
|
{
|
|
|
//从缓冲区中获取数据
|
|
|
CanMsgBuffer[i] = (USB2CAN.CAN_MSG)Marshal.PtrToStructure(pt + i * Marshal.SizeOf(typeof(USB2CAN.CAN_MSG)), typeof(USB2CAN.CAN_MSG));
|
|
|
//判断获取的是不是目标报文
|
|
|
if (CanMsgBuffer[i].ID == Convert.ToUInt64(GlobalVar.agreementMsgVM.ReciveId, 16) && CanMsgBuffer[i].DataLen == 8)
|
|
|
{
|
|
|
//如果信号值不为空,要过滤信号值
|
|
|
if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.ReciveSignalVal))
|
|
|
{
|
|
|
if (Convert.ToUInt64(GlobalVar.agreementMsgVM.ReciveSignalVal, 16) == CanMsgBuffer[i].Data[0])
|
|
|
{
|
|
|
|
|
|
GetCANReciveValHelper.GetReciveVal(CanMsgBuffer[i].Data);//从接收报文中解析实际值
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GetCANReciveValHelper.GetReciveVal(CanMsgBuffer[i].Data);//从接收报文中解析实际值
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (CanNum == 0)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Get CAN data error!");
|
|
|
LogHelper.Error(null, "Get CAN data error!");
|
|
|
break;
|
|
|
}
|
|
|
//释放数据缓冲区,必须释放,否则程序运行一段时间后会报内存不足
|
|
|
Marshal.FreeHGlobal(pt);
|
|
|
//Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}执行接收");
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.RecivePeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region CANFD
|
|
|
|
|
|
private static Int32 retFD = 0;
|
|
|
private static USB2CANFD.CANFD_MSG[] CanFDMsg = null;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 一段速度
|
|
|
/// </summary>
|
|
|
private void CANFD_SendSpeed1()
|
|
|
{
|
|
|
if (CanFDMsg == null)
|
|
|
{
|
|
|
CanFDMsg = new USB2CANFD.CANFD_MSG[1];
|
|
|
CanFDMsg[0] = new USB2CANFD.CANFD_MSG
|
|
|
{
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID
|
|
|
DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度
|
|
|
};
|
|
|
CanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF;
|
|
|
}
|
|
|
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected || GlobalVar.agreementMsgVM == null || GlobalVar.agreementMsgVM.StartType != "CAN")
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
speed1_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动了CANFD_SendSpeed1");
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CANFD")
|
|
|
{
|
|
|
string speed1Hex = GlobalVar.agreementMsgVM.Speed1Hex;
|
|
|
if (!string.IsNullOrEmpty(speed1Hex))
|
|
|
{
|
|
|
CanFDMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed1Hex);
|
|
|
}
|
|
|
CanMsgDataCatch(CanFDMsg, out IntPtr pCanSendMsg);
|
|
|
int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, CanFDMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
// Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{0}", SendMsgNum);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Send CANFD data failed!");
|
|
|
//break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 二段速度
|
|
|
/// </summary>
|
|
|
private void CANFD_SendSpeed2()
|
|
|
{
|
|
|
|
|
|
if (CanFDMsg == null)
|
|
|
{
|
|
|
CanFDMsg = new USB2CANFD.CANFD_MSG[1];
|
|
|
CanFDMsg[0] = new USB2CANFD.CANFD_MSG
|
|
|
{
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID
|
|
|
DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度
|
|
|
};
|
|
|
CanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF;
|
|
|
}
|
|
|
|
|
|
while (true)
|
|
|
{
|
|
|
speed2_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动了CANFD_SendSpeed2");
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CANFD")
|
|
|
{
|
|
|
string speed2Hex = GlobalVar.agreementMsgVM.Speed2Hex;
|
|
|
if (!string.IsNullOrEmpty(speed2Hex))
|
|
|
{
|
|
|
CanFDMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed2Hex);
|
|
|
}
|
|
|
CanMsgDataCatch(CanFDMsg, out IntPtr pCanSendMsg);
|
|
|
int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, CanFDMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
// Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{SendMsgNum}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Send CANFD data failed!");
|
|
|
//break;
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 三段速度
|
|
|
/// </summary>
|
|
|
private void CANFD_SendSpeed3()
|
|
|
{
|
|
|
|
|
|
if (CanFDMsg == null)
|
|
|
{
|
|
|
CanFDMsg = new USB2CANFD.CANFD_MSG[1];
|
|
|
CanFDMsg[0] = new USB2CANFD.CANFD_MSG
|
|
|
{
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID
|
|
|
DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度
|
|
|
};
|
|
|
CanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF;
|
|
|
}
|
|
|
|
|
|
while (true)
|
|
|
{
|
|
|
speed3_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动了CANFD_SendSpeed3");
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CANFD")
|
|
|
{
|
|
|
string speed3Hex = GlobalVar.agreementMsgVM.Speed3Hex;
|
|
|
if (!string.IsNullOrEmpty(speed3Hex))
|
|
|
{
|
|
|
CanFDMsg[0].Data = ByteArrayLib.GetByteArrayFromHexString(speed3Hex);
|
|
|
}
|
|
|
CanMsgDataCatch(CanFDMsg, out IntPtr pCanSendMsg);
|
|
|
int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, CanFDMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
// Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}:Success send frames:{SendMsgNum}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Send CANFD data failed!");
|
|
|
//break;
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 附加报文
|
|
|
/// </summary>
|
|
|
private async void CANFD_SendAdditional()
|
|
|
{
|
|
|
USB2CANFD.CANFD_MSG[] additionalCanFDMsg = null;
|
|
|
if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId) && !string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent) && additionalCanFDMsg == null)
|
|
|
{
|
|
|
additionalCanFDMsg = new USB2CANFD.CANFD_MSG[1];
|
|
|
additionalCanFDMsg[0] = new USB2CANFD.CANFD_MSG
|
|
|
{
|
|
|
ID = Convert.ToUInt32(GlobalVar.agreementMsgVM.SendId, 16),//报文ID
|
|
|
DLC = (byte)(GlobalVar.agreementMsgVM.FrameLen & 0xFF),//数据长度(<=8),即Data中有效数据长度
|
|
|
Data = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent)
|
|
|
};
|
|
|
additionalCanFDMsg[0].Flags |= USB2CANFD.CANFD_MSG_FLAG_FDF;
|
|
|
}
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || GlobalVar.agreementMsgVM == null || GlobalVar.agreementMsgVM.SendAdditionalRules == null || string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalSendId) || string.IsNullOrEmpty(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalContent))
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
additional_ManualResetEvent.WaitOne();
|
|
|
Console.WriteLine("启动CANFD发送附加报文==" + StringLib.GetHexStringFromByteArray(additionalCanFDMsg[0].Data));
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CANFD")
|
|
|
{
|
|
|
CanMsgDataCatch(additionalCanFDMsg, out IntPtr pCanSendMsg);
|
|
|
int SendedNum = USB2CANFD.CANFD_SendMsg(GlobalVar.DevHandle, GlobalVar.WriteCANIndex, pCanSendMsg, additionalCanFDMsg.Length);
|
|
|
if (SendedNum >= 0)
|
|
|
{
|
|
|
Console.WriteLine("附加报文Success send frames:{0}", SendedNum);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("附加报文Send CANFD data failed!");
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
await Task.Delay(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalPeriod);
|
|
|
//Thread.Sleep(GlobalVar.agreementMsgVM.SendAdditionalRules.AdditionalPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接收报文
|
|
|
/// </summary>
|
|
|
private void CANFD_ReciveMsg()
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
if (GlobalVar.DevHandle <= 0)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "CANFD")
|
|
|
{
|
|
|
USB2CANFD.CANFD_MSG[] CanFDMsgBuffer = new USB2CANFD.CANFD_MSG[1024];
|
|
|
//申请数据缓冲区
|
|
|
IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)) * CanFDMsgBuffer.Length);
|
|
|
|
|
|
int CanNum = USB2CANFD.CANFD_GetMsg(GlobalVar.DevHandle, GlobalVar.ReadCANIndex, pt, CanFDMsgBuffer.Length);
|
|
|
if (CanNum > 0)
|
|
|
{
|
|
|
for (int i = 0; i < CanNum; i++)
|
|
|
{
|
|
|
//从缓冲区中获取数据
|
|
|
CanFDMsgBuffer[i] = (USB2CANFD.CANFD_MSG)Marshal.PtrToStructure(pt + i * Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)), typeof(USB2CANFD.CANFD_MSG));
|
|
|
//判断获取的是不是目标报文
|
|
|
if (CanFDMsgBuffer[i].ID == Convert.ToUInt64(GlobalVar.agreementMsgVM.ReciveId, 16))
|
|
|
{
|
|
|
//如果信号值不为空,要过滤信号值
|
|
|
if (!string.IsNullOrEmpty(GlobalVar.agreementMsgVM.ReciveSignalVal))
|
|
|
{
|
|
|
if (Convert.ToUInt64(GlobalVar.agreementMsgVM.ReciveSignalVal, 16) == CanFDMsgBuffer[i].Data[0])
|
|
|
{
|
|
|
|
|
|
GetCANReciveValHelper.GetFDReciveVal(CanFDMsgBuffer[i].Data);//从接收报文中解析实际值
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GetCANReciveValHelper.GetFDReciveVal(CanFDMsgBuffer[i].Data);//从接收报文中解析实际值
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (CanNum == 0)
|
|
|
{
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Console.WriteLine("Get CANFD data error!");
|
|
|
LogHelper.Error(null, "Get CANFD data error!");
|
|
|
break;
|
|
|
}
|
|
|
//释放数据缓冲区,必须释放,否则程序运行一段时间后会报内存不足
|
|
|
Marshal.FreeHGlobal(pt);
|
|
|
//Console.WriteLine($"{DateTime.Now.ToString("mm:ss fff")}执行接收");
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.RecivePeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 数据复制到数据缓冲区中
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
private static void CanMsgDataCatch(USB2CANFD.CANFD_MSG[] CanMsg, out IntPtr pCanSendMsg)
|
|
|
{
|
|
|
pCanSendMsg = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)) * CanMsg.Length);//申请缓冲区
|
|
|
IntPtr pPonitor = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)));
|
|
|
Marshal.StructureToPtr(CanMsg[0], pPonitor, true);
|
|
|
byte[] buffer = new byte[Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG))];
|
|
|
Marshal.Copy(pPonitor, buffer, 0, Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)));
|
|
|
Marshal.Copy(buffer, 0, (IntPtr)(UInt32)pCanSendMsg, Marshal.SizeOf(typeof(USB2CANFD.CANFD_MSG)));
|
|
|
Marshal.FreeHGlobal(pPonitor);//释放缓冲区
|
|
|
}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 一段速度
|
|
|
///// </summary>
|
|
|
//private void CANFD_SendSpeed1()
|
|
|
//{
|
|
|
|
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 二段速度
|
|
|
///// </summary>
|
|
|
//private void CANFD_SendSpeed2()
|
|
|
//{
|
|
|
|
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 三段速度
|
|
|
///// </summary>
|
|
|
//private void CANFD_SendSpeed3()
|
|
|
//{
|
|
|
|
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 附加报文
|
|
|
///// </summary>
|
|
|
//private async void CANFD_SendAdditional()
|
|
|
//{
|
|
|
|
|
|
//}
|
|
|
|
|
|
///// <summary>
|
|
|
///// 接收报文
|
|
|
///// </summary>
|
|
|
//private void CANFD_ReciveMsg()
|
|
|
//{
|
|
|
|
|
|
//}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region LIN
|
|
|
/// <summary>
|
|
|
/// 一段速
|
|
|
/// </summary>
|
|
|
private void LIN_SendSpeed1()
|
|
|
{
|
|
|
Console.WriteLine("启动了LIN_SendSpeed1");
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected || GlobalVar.agreementMsgVM == null)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
if (GlobalVar.DevHandle <= 0)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
speed1_ManualResetEvent.WaitOne();
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "LIN")
|
|
|
{
|
|
|
byte[] DataBuffer = new byte[8];
|
|
|
string speed1Hex = GlobalVar.agreementMsgVM.Speed1Hex;
|
|
|
DataBuffer = ByteArrayLib.GetByteArrayFromHexString(speed1Hex);
|
|
|
byte ID = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.SendId)[0];
|
|
|
ret = USB2LIN_EX.LIN_EX_MasterWrite(GlobalVar.DevHandle, 0, ID, DataBuffer, (byte)DataBuffer.Length, 1);
|
|
|
if (ret != USB2LIN_EX.LIN_EX_SUCCESS)
|
|
|
{
|
|
|
Console.WriteLine("Write LIN failed!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//Console.WriteLine("Write LIN Success!");
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 二段速
|
|
|
/// </summary>
|
|
|
private void LIN_SendSpeed2()
|
|
|
{
|
|
|
Console.WriteLine("启动了LIN_SendSpeed2");
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected || GlobalVar.agreementMsgVM == null)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
if (GlobalVar.DevHandle <= 0)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
speed2_ManualResetEvent.WaitOne();
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "LIN")
|
|
|
{
|
|
|
byte[] DataBuffer = new byte[8];
|
|
|
string speed2Hex = GlobalVar.agreementMsgVM.Speed2Hex;
|
|
|
DataBuffer = ByteArrayLib.GetByteArrayFromHexString(speed2Hex);
|
|
|
byte ID = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.SendId)[0];
|
|
|
ret = USB2LIN_EX.LIN_EX_MasterWrite(GlobalVar.DevHandle, 0, ID, DataBuffer, (byte)DataBuffer.Length, 1);
|
|
|
if (ret != USB2LIN_EX.LIN_EX_SUCCESS)
|
|
|
{
|
|
|
Console.WriteLine("Write LIN failed!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//Console.WriteLine("Write LIN Success!");
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 三段速
|
|
|
/// </summary>
|
|
|
private void LIN_SendSpeed3()
|
|
|
{
|
|
|
Console.WriteLine("启动了LIN_SendSpeed3");
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected || GlobalVar.agreementMsgVM == null)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
if (GlobalVar.DevHandle <= 0)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
speed3_ManualResetEvent.WaitOne();
|
|
|
if (GlobalVar.agreementMsgVM.StartType == "LIN")
|
|
|
{
|
|
|
byte[] DataBuffer = new byte[8];
|
|
|
string speed3Hex = GlobalVar.agreementMsgVM.Speed3Hex;
|
|
|
DataBuffer = ByteArrayLib.GetByteArrayFromHexString(speed3Hex);
|
|
|
byte ID = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.SendId)[0];
|
|
|
ret = USB2LIN_EX.LIN_EX_MasterWrite(GlobalVar.DevHandle, 0, ID, DataBuffer, (byte)DataBuffer.Length, 1);
|
|
|
if (ret != USB2LIN_EX.LIN_EX_SUCCESS)
|
|
|
{
|
|
|
Console.WriteLine("Write LIN failed!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//Console.WriteLine("Write LIN Success!");
|
|
|
}
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.SendPeriod);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 接收报文
|
|
|
/// </summary>
|
|
|
private void LIN_ReciveMsg()
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
if (cts.IsCancellationRequested || !OmronCIPHelper.IsConnected || GlobalVar.agreementMsgVM == null || GlobalVar.agreementMsgVM.StartType != "LIN")
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
if (GlobalVar.DevHandle <= 0)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
byte[] DataBuffer = new byte[8];
|
|
|
byte[] reciveIdArr = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.ReciveId);
|
|
|
if (reciveIdArr.Length <= 0)
|
|
|
{
|
|
|
Thread.Sleep(1000);
|
|
|
continue;
|
|
|
}
|
|
|
byte pid = ByteArrayLib.GetByteArrayFromHexString(GlobalVar.agreementMsgVM.ReciveId)[0];
|
|
|
ret = USB2LIN_EX.LIN_EX_MasterRead(GlobalVar.DevHandle, 0, pid, DataBuffer);
|
|
|
if (ret < 0)
|
|
|
{
|
|
|
Console.WriteLine("Read LIN failed! ret={0}", ret);
|
|
|
}
|
|
|
else if (ret == 0)
|
|
|
{
|
|
|
|
|
|
//Console.WriteLine("The slave machine is not responding!");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
GetCANReciveValHelper.GetReciveVal(DataBuffer);//从接收报文中解析实际值
|
|
|
}
|
|
|
Thread.Sleep(GlobalVar.agreementMsgVM.RecivePeriod);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
}
|