|
|
|
@ -6,6 +6,9 @@ using NewLife;
|
|
|
|
|
using NewLife.Log;
|
|
|
|
|
using NewLife.Serialization;
|
|
|
|
|
using NewLife.Threading;
|
|
|
|
|
using ProductionSystem_Model.DbModel;
|
|
|
|
|
using ProductionSystem_Model.Enum;
|
|
|
|
|
using ProductionSystem_Service;
|
|
|
|
|
|
|
|
|
|
namespace ProductionSystem.Untils.Tool
|
|
|
|
|
{
|
|
|
|
@ -37,7 +40,7 @@ namespace ProductionSystem.Untils.Tool
|
|
|
|
|
public string Val { get; set; } = "0";
|
|
|
|
|
|
|
|
|
|
public string Write { get; set; } = "0";
|
|
|
|
|
|
|
|
|
|
bool b = false;
|
|
|
|
|
public bool ToAction()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -53,50 +56,8 @@ namespace ProductionSystem.Untils.Tool
|
|
|
|
|
|
|
|
|
|
XTrace.WriteLine($"水泵Uy 第[{mo}-{com}]个 写入设备报文:{sendMes}");
|
|
|
|
|
|
|
|
|
|
bool b = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mfSerialInfo.MsgFunc += (x) =>
|
|
|
|
|
{
|
|
|
|
|
XTrace.WriteLine($"水泵Uy 第[{mo}-{com}]个 收到反馈报文:{sendMes}");
|
|
|
|
|
if (x.Id.Contains("26") && x.Err == "0")
|
|
|
|
|
{
|
|
|
|
|
var bytes = x.Dat.ToHex();
|
|
|
|
|
|
|
|
|
|
me = new MFMsgVariable(bytes, 0, 8);
|
|
|
|
|
|
|
|
|
|
XTrace.WriteLine("=============================");
|
|
|
|
|
var intelLsb = me.GetMotoralaLsb(0, 1);
|
|
|
|
|
XTrace.WriteLine("on: {0}", intelLsb);
|
|
|
|
|
intelLsb = me.GetMotoralaLsb(4, 2);
|
|
|
|
|
XTrace.WriteLine("PumpPCState: {0}", intelLsb);
|
|
|
|
|
intelLsb = me.GetMotoralaLsb(24, 8);
|
|
|
|
|
XTrace.WriteLine("RealRPM: {0}", intelLsb);
|
|
|
|
|
|
|
|
|
|
Val = intelLsb.ToString();
|
|
|
|
|
|
|
|
|
|
XTrace.WriteLine($"水泵Uy 第[{mo}-{com}]个 收到反馈速度:{Val}");
|
|
|
|
|
double errorMargin = Math.Abs(intelLsb.ToInt() - Write.ToInt());
|
|
|
|
|
|
|
|
|
|
if(!b && errorMargin<=5)
|
|
|
|
|
{
|
|
|
|
|
XTrace.WriteLine($"水泵Uy[{mo}-{com}] 逻辑结束");
|
|
|
|
|
mfSerialInfo.MsgFunc = null;
|
|
|
|
|
mfSerialInfo.Exit = true;
|
|
|
|
|
b = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mfSerialInfo.MsgFunc = Fun;
|
|
|
|
|
mfSerialInfo.SendMsg(sendMes,50);
|
|
|
|
|
return b;
|
|
|
|
|
|
|
|
|
@ -107,25 +68,28 @@ namespace ProductionSystem.Untils.Tool
|
|
|
|
|
|
|
|
|
|
private TimerX _timer;
|
|
|
|
|
|
|
|
|
|
public void Send()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public T_Product_Step TProductStep { set; get; }
|
|
|
|
|
|
|
|
|
|
public void Send(T_Product_Step step)
|
|
|
|
|
{
|
|
|
|
|
TProductStep = step;
|
|
|
|
|
mfSerialInfo.MsgFunc = Fun;
|
|
|
|
|
var sendMes = GetMsg(mo);
|
|
|
|
|
_timer= new TimerX(DoBackup, sendMes, 100, 800) { Async = true };
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string sendMes = "";
|
|
|
|
|
private void DoBackup(Object state)
|
|
|
|
|
{
|
|
|
|
|
XTrace.WriteLine("Uy定时器");
|
|
|
|
|
var sendMes = "";
|
|
|
|
|
|
|
|
|
|
sendMes = state == null ? GetMsg(mo) : state.ToString();
|
|
|
|
|
mfSerialInfo.SendMessage(sendMes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ProductStepService _productStepService = new ProductStepService();
|
|
|
|
|
|
|
|
|
|
public string GetMsg(int num)
|
|
|
|
|
private string GetMsg(int num)
|
|
|
|
|
{
|
|
|
|
|
uint seep = uint.Parse((num * 0.4).ToString());
|
|
|
|
|
Write = seep.ToString();
|
|
|
|
@ -154,5 +118,42 @@ namespace ProductionSystem.Untils.Tool
|
|
|
|
|
Exit = true;
|
|
|
|
|
Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Fun(MfSerialEntity x)
|
|
|
|
|
{
|
|
|
|
|
XTrace.WriteLine($"水泵Uy 第[{mo}-{com}]个 收到反馈报文:{sendMes}");
|
|
|
|
|
if (x.Id.Contains("26") && x.Err == "0")
|
|
|
|
|
{
|
|
|
|
|
var bytes = x.Dat.ToHex();
|
|
|
|
|
|
|
|
|
|
var me = new MFMsgVariable(bytes, 0, 8);
|
|
|
|
|
|
|
|
|
|
XTrace.WriteLine("=============================");
|
|
|
|
|
var intelLsb = me.GetMotoralaLsb(0, 1);
|
|
|
|
|
XTrace.WriteLine("on: {0}", intelLsb);
|
|
|
|
|
intelLsb = me.GetMotoralaLsb(4, 2);
|
|
|
|
|
XTrace.WriteLine("PumpPCState: {0}", intelLsb);
|
|
|
|
|
intelLsb = me.GetMotoralaLsb(24, 8);
|
|
|
|
|
XTrace.WriteLine("RealRPM: {0}", intelLsb);
|
|
|
|
|
|
|
|
|
|
Val = intelLsb.ToString();
|
|
|
|
|
|
|
|
|
|
_productStepService.UpdateSBSpeed(TProductStep.ProductType,TProductStep.ProductBarcode,TProductStep.StepName,EquipmentEnum.SB1ZS_DB.ToString(),Write,Val);
|
|
|
|
|
|
|
|
|
|
XTrace.WriteLine($"水泵Uy 第[{mo}-{com}]个 收到反馈速度:{Val}");
|
|
|
|
|
double errorMargin = Math.Abs(intelLsb.ToInt() - Write.ToInt());
|
|
|
|
|
|
|
|
|
|
if(!b && errorMargin<=5)
|
|
|
|
|
{
|
|
|
|
|
XTrace.WriteLine($"水泵Uy[{mo}-{com}] 逻辑结束");
|
|
|
|
|
mfSerialInfo.MsgFunc = null;
|
|
|
|
|
mfSerialInfo.Exit = true;
|
|
|
|
|
b = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|