public static Result 机故上报2(int e1, int e2, int e3) { string datetime = DateTime.Now.ToString("yyyyMMddHHmmss"); bool[] ErrorArray = new bool[96]; for (int i = 0; i < 32; i++) { ErrorArray[i] = BitHandle.GetBit(e1, i); ErrorArray[i + 32] = BitHandle.GetBit(e2, i); ErrorArray[i + 64] = BitHandle.GetBit(e3, i); } for (int i = 0; i < 96; i++) { if (ErrorArray[i] && !LastErrorArray[i]) { int code = i + 1; string errorStr = ErrorCodeCollection.GetError(code); bool IsSuccess = Post2(errorStr, datetime, out string responseContent); LastErrorArray[i] = ErrorArray[i]; if (IsSuccess) { Log.Run(LogLevel.Info, "机故上报=>编码:" + code.ToString() + ";描述:" + errorStr); Log.Debug("机故上报成功,IOT回复:" + responseContent); } else { return(new Result(false, "机故上报出错:" + responseContent /*, (int)ErrorCode.fatalError*/)); } } } LastErrorArray = ErrorArray; Thread.Sleep(50); return(new Result(true)); }
public static Result Init() { ErrorCodeCollection.LoadCfg(); //MyPing(); return(new Result()); string paramStrNew = Settings.GetSetting("mes IP"); int paramIntNew = Convert.ToInt32(Settings.GetSetting("mes 端口")); int timeoutNew = Convert.ToInt32(Settings.GetSetting("mes超时时间")); if (Mes != null) { bool isChanged = paramStr != paramStrNew || paramInt != paramIntNew || timeout != timeoutNew; if (!isChanged) { string resultMsg = ""; if (!Mes.IsConnected()) { resultMsg = "Mes连接失败,请检查参数是否设置正确"; } return(new Result(Mes.IsConnected(), resultMsg)); } Mes.Close(); } paramStr = paramStrNew; paramInt = paramIntNew; timeout = timeoutNew; Mes = new MesConnectorBySocketClient <SocketClient>(paramStr, paramInt, timeout); Thread.Sleep(20); if (Mes.IsConnected()) { //Mes.PassStation("1", 1, Settings.GetSetting("上传格式")); //Thread.Sleep(500); return(new Result(true, "Mes连接成功")); } return(new Result(false, "Mes连接失败,请检查参数是否设置正确")); }