private async Task <Tuple <bool, RightMaterialServiceErrorCodeEnum> > RightMaterialFlow() { bool ret = false; bool S_HouseRequestFCS = false; ret = ControlDevice.GetHouseRequestFCS(ref S_HouseRequestFCS); if (ret != true) { return(new Tuple <bool, RightMaterialServiceErrorCodeEnum>(false, RightMaterialServiceErrorCodeEnum.GETREQ)); } if (S_HouseRequestFCS == true) { Temp_S_House_RequestFCS_Last = S_HouseRequestFCS; //防错处理 ret = CheckOnBegin(); if (ret != true) { return(new Tuple <bool, RightMaterialServiceErrorCodeEnum>(false, RightMaterialServiceErrorCodeEnum.CHECKONBEGIN)); } //料库通讯 bool S_House_InOut = false; var ret_inout = ControlDevice.GetHouseInOut(ref S_House_InOut); if (ret_inout == false) { return(new Tuple <bool, RightMaterialServiceErrorCodeEnum>(ret_inout, RightMaterialServiceErrorCodeEnum.INOUT)); } if (S_House_InOut == true) { var ret_out = await RightMaterialOutFlow(); if (ret_out.Item1 == false) { return(ret_out); } } else { var ret_in = await RightMaterialInFlow(); if (ret_in.Item1 == false) { return(ret_in); } } } else { Temp_S_House_RequestFCS_Last = S_HouseRequestFCS; } return(new Tuple <bool, RightMaterialServiceErrorCodeEnum>(true, RightMaterialServiceErrorCodeEnum.NORMAL)); }
public void Start() { SendLeftMaterialServiceStateMessage( new LeftMaterialServiceState { State = LeftMaterialServiceStateEnum.INFO, Message = "左侧料库服务启动!", ErrorCode = LeftMaterialServiceErrorCodeEnum.NORMAL }); Temp_S_House_RequestFCS_Last = false; bool ret = false; #region 初始化 bool temp_S_House_RequestFCS_Last = false; ret = ControlDevice.GetHouseRequestFCS(ref temp_S_House_RequestFCS_Last); if (ret == false) { while (ret == false) { ret = ControlDevice.SetHouseFCSAlarm(true); SendLeftMaterialServiceStateMessage( new LeftMaterialServiceState { State = LeftMaterialServiceStateEnum.ERROR, Message = "初始化连接,请检查网络连接与配置后复位!", ErrorCode = LeftMaterialServiceErrorCodeEnum.INI_GETREQ }); Thread.Sleep(1000); } bool dev_reset = false; while (dev_reset == false) { ControlDevice.GetHouseFCSReset(ref dev_reset); SendLeftMaterialServiceStateMessage( new LeftMaterialServiceState { State = LeftMaterialServiceStateEnum.WARN, Message = "初始化失败,等待设备的复位信号", ErrorCode = LeftMaterialServiceErrorCodeEnum.NORMAL }); Thread.Sleep(1000); } } Temp_S_House_RequestFCS_Last = temp_S_House_RequestFCS_Last; #endregion while (!token.IsCancellationRequested) { //料库请求 var ret_tuple = LeftMaterialFlow().Result; if (ret_tuple.Item1 == false) { ret = false; while (ret == false) { ret = ControlDevice.SetHouseFCSAlarm(true); SendLeftMaterialServiceStateMessage( new LeftMaterialServiceState { State = LeftMaterialServiceStateEnum.ERROR, Message = "左侧料库请求调用失败,请检查后复位!", ErrorCode = ret_tuple.Item2 }); Thread.Sleep(1000); } bool dev_reset = false; while (dev_reset == false) { ControlDevice.GetHouseFCSReset(ref dev_reset); SendLeftMaterialServiceStateMessage( new LeftMaterialServiceState { State = LeftMaterialServiceStateEnum.WARN, Message = "左侧料库请求调用失败,等待设备的复位信号", ErrorCode = LeftMaterialServiceErrorCodeEnum.NORMAL }); Thread.Sleep(1000); } SendLeftMaterialServiceStateMessage( new LeftMaterialServiceState { State = LeftMaterialServiceStateEnum.WARN, Message = "左侧料库请求调用失败,设备复位", ErrorCode = LeftMaterialServiceErrorCodeEnum.NORMAL }); } else { } Thread.Sleep(1000); } }