using IStation.DataDockingSocket.MsgHandle; using IStation.Untity; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.DataDockingSocket { internal class StartUpMsgHelper { public static eStartUpInstructionStatus ShutUpInstructionStatus = eStartUpInstructionStatus.未发送; /// /// 开机 /// /// /// public static bool StartJob(Model.IMonitorDataDockingSession session) { if (session != null) { NtLogHelper.Error($"开机 session:Close"); return false; } if (session.IsConnected) { byte[] bts = GetControlMsg开机(); session.Send(bts, 0, bts.Length); ShutUpInstructionStatus = eStartUpInstructionStatus.调频指令发送; NtLogHelper.Info("开机" + session.SessionName + ":" + BitTransfer.ToString(bts) + ", 发送一条请求控制指令"); return true; } else { NtLogHelper.Error($"开机时 session:Not connected"); return false; } } /// /// /// /// /// public static bool IsCurrentMsg(byte[] byteMessage) { if(byteMessage.Length == 8) { if (byteMessage[0] == 0x01 && byteMessage[1] == 0x06 && byteMessage[2] == 0x00 && byteMessage[3] == 0x0F && byteMessage[4] == 0x00 && byteMessage[5] == 0x01 && byteMessage[6] == 0x78 && byteMessage[7] == 0x09) {//01-06-00-0F-00-01-78-09 return true; } } return false; } /// /// 获取控制指令(开机) /// /// public static byte[] GetControlMsg开机() { //var appParas = AppParasHelper.GetInstance(); //if (appParas == null || appParas.InstructionStartUp == null || appParas.InstructionStartUp.Content == null) { return BitTransfer.FromString("01-06-00-0F-00-01-78-09"); } //return BitTransfer.FromString(appParas.InstructionStartUp.Content); } /// /// 获取控制指令(调频) /// /// public static byte[] GetControlMsg调频(double frequece) { var iFrequece = (int)(frequece * 10); byte[] commandSend = null; ModBusRtuHelper.BuildSendMessage06(0x01, 20, 2, iFrequece, ref commandSend); return commandSend; } } }