工具类

dep_yangw
我叫锄头 11 months ago
parent c8c4b4092e
commit 9e2b560894

@ -47,7 +47,7 @@ namespace ProductionSystem.Untils.Tool
var by = me.GetByteDat();
var sendMes = by.ToHex(" ");
XTrace.WriteLine("发送报文:{0}", sendMes);
XTrace.WriteLine($"膨胀阀[{com}]发送报文:{0}", sendMes);
mfSerialInfo = new MfSerialInfo(0x13, 0x23, com, "19200");
@ -56,7 +56,7 @@ namespace ProductionSystem.Untils.Tool
mfSerialInfo.MsgFunc += (x) =>
{
XTrace.WriteLine(x.ToJson());
XTrace.WriteLine($"膨胀阀[{com}]收到返回报文{x.ToJson()}");
if (x.Id.Contains("23") && x.Err == "0")
{
var bytes = x.Dat.ToHex();
@ -82,11 +82,13 @@ namespace ProductionSystem.Untils.Tool
intelLsb = me.GetIntelLsb(16, 16);
XTrace.WriteLine(intelLsb.ToString());
Val = intelLsb.ToString();
XTrace.WriteLine($"膨胀阀[{com}]收到返回报文 解析开度{Val}");
double errorMargin = Math.Abs(intelLsb.ToInt() - mo);
if (errorMargin<=10 && !b)
{
XTrace.WriteLine($"膨胀阀[{com}] 逻辑结束");
Val = intelLsb.ToString();
mfSerialInfo.MsgFunc = null;
mfSerialInfo.Exit = true;
@ -101,7 +103,7 @@ namespace ProductionSystem.Untils.Tool
};
mfSerialInfo.SendMsg(sendMes, 60, 200);
mfSerialInfo.SendMsg(sendMes, 60, 500);
return b;
}

@ -68,13 +68,13 @@ namespace ProductionSystem.Untils.Tool
}
int cou = 0;
XTrace.WriteLine("发送报文:{0}", sendMes);
XTrace.WriteLine($"四通阀[{com}]发送报文:{0}", sendMes);
bool b = false;
mfSerialInfo.MsgFunc += (x) =>
{
cou++;
XTrace.WriteLine("回调函数返回:" + x.ToJson());
XTrace.WriteLine($"四通阀[{com}]收到返回报文{x.ToJson()}");
if (x.Id.Contains("2e") && x.Err=="0")
{
var bytes = x.Dat.ToHex();
@ -87,13 +87,15 @@ namespace ProductionSystem.Untils.Tool
//获取最后返回的模式
Val = intelLsb.ToInt().ToString();
XTrace.WriteLine($"四通阀[{com}]收到返回报文 解析模式[{Val}]");
if (intelLsb.ToInt() == mo && !b)
{
b = true;
mfSerialInfo.Exit = true;
mfSerialInfo.MsgFunc = null;
Val = intelLsb.ToInt().ToString();
XTrace.WriteLine($"四通阀[{com}] 逻辑结束");
return;
}

@ -1,55 +1 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProductionSystem.Untils.Tool
{
public class StateTool
{
}
public class StateModel
{
public string Name { get; set; }
/// <summary>
/// 是不是验证通过
/// </summary>
public bool boo { get; set; }
/// <summary>
/// 设备反馈的值
/// </summary>
public string value { get; set; }
}
public enum State
{
Exv1,
Exv2,
Ux1,
Ux2,
Uy1,
Uy2,
St1,
St2
}
public enum MoShi
{
M1,
M2,
M3,
M4,
M5,
M6,
M7,
M8
}
}


@ -40,7 +40,7 @@ namespace ProductionSystem.Untils.Tool
uint seep = uint.Parse((mo * 0.4).ToString());
Write = seep.ToString();
XTrace.WriteLine("真实速度:{0}", seep);
XTrace.WriteLine($"水泵Ux 第[{com}]个 写入真实速度:{seep}");
MFMsgVariable me = new MFMsgVariable(8);
me.AddMotoralaLsb(0, 8, seep);
@ -48,7 +48,7 @@ namespace ProductionSystem.Untils.Tool
var by = me.GetByteDat();
var sendMes = by.ToHex(" ");
XTrace.WriteLine("发送报文:{0}", sendMes);
XTrace.WriteLine($"水泵Ux 第[{com}]个 写入设备报文:{sendMes}");
bool b = false;
@ -59,7 +59,7 @@ namespace ProductionSystem.Untils.Tool
mfSerialInfo.MsgFunc += (x) =>
{
XTrace.WriteLine(x.ToJson());
XTrace.WriteLine($"水泵Ux 第[{com}]个 收到反馈报文:{x.ToJson()}");
if (x.Id.Contains("29") && x.Err == "0")
{
var bytes = x.Dat.ToHex();
@ -73,14 +73,13 @@ namespace ProductionSystem.Untils.Tool
XTrace.WriteLine("PumpPCState: {0}", intelLsb);
intelLsb = me.GetMotoralaLsb(24, 8);
XTrace.WriteLine("RealRPM: {0}", intelLsb);
Val = intelLsb.ToString();
XTrace.WriteLine($"水泵Ux 第[{com}]个 收到反馈速度:{Val}");
double errorMargin = Math.Abs(intelLsb.ToInt() - Write.ToInt());
if(!b && errorMargin<=5)
{
XTrace.WriteLine($"水泵Ux[{com}] 逻辑结束");
mfSerialInfo.MsgFunc = null;
mfSerialInfo.Exit = true;
b = true;

@ -5,6 +5,10 @@ using NewLife.Serialization;
namespace ProductionSystem.Untils.Tool
{
/// <summary>
/// 第一个水泵
/// </summary>
public class UyTool: IDisposable
{
string com;
@ -34,7 +38,7 @@ namespace ProductionSystem.Untils.Tool
uint seep = uint.Parse((mo * 0.4).ToString());
Write = seep.ToString();
XTrace.WriteLine("真实速度:{0}", seep);
XTrace.WriteLine($"水泵Uy 第[{com}]个 写入真实速度:{seep}");
MFMsgVariable me = new MFMsgVariable(8);
me.AddMotoralaLsb(8, 8, seep);
@ -42,7 +46,7 @@ namespace ProductionSystem.Untils.Tool
var by = me.GetByteDat();
var sendMes = by.ToHex(" ");
XTrace.WriteLine("发送报文:{0}", sendMes);
XTrace.WriteLine($"水泵Uy 第[{com}]个 写入设备报文:{sendMes}");
bool b = false;
@ -53,7 +57,7 @@ namespace ProductionSystem.Untils.Tool
mfSerialInfo.MsgFunc += (x) =>
{
XTrace.WriteLine(x.ToJson());
XTrace.WriteLine($"水泵Uy 第[{com}]个 收到反馈报文:{sendMes}");
if (x.Id.Contains("26") && x.Err == "0")
{
var bytes = x.Dat.ToHex();
@ -70,11 +74,12 @@ namespace ProductionSystem.Untils.Tool
Val = intelLsb.ToString();
XTrace.WriteLine($"水泵Uy 第[{com}]个 收到反馈速度:{Val}");
double errorMargin = Math.Abs(intelLsb.ToInt() - Write.ToInt());
if(!b && errorMargin<=5)
{
XTrace.WriteLine($"水泵Uy[{com}] 逻辑结束");
mfSerialInfo.MsgFunc = null;
mfSerialInfo.Exit = true;
b = true;

Loading…
Cancel
Save