| | |
| | | /// <returns></returns> |
| | | public bool SendTask(int deviceId, int taskId, string sourcePlce, string toPlace, out string msg) |
| | | { |
| | | try |
| | | { |
| | | msg = ""; |
| | | if (!CanSendTask(deviceId, out msg)) |
| | | { |
| | | return false; |
| | | } |
| | | msg = ""; |
| | | return false; |
| | | //try |
| | | //{ |
| | | // msg = ""; |
| | | // if (!CanSendTask(deviceId, out msg)) |
| | | // { |
| | | // return false; |
| | | // } |
| | | |
| | | //这里特殊转换一下 |
| | | if (toPlace == ((int)EDevice.出库口1012).ToString()) |
| | | { |
| | | toPlace = ((int)EDevice.提升机1030).ToString(); |
| | | } |
| | | // //这里特殊转换一下 |
| | | // if (toPlace == ((int)EDevice.出库口1012).ToString()) |
| | | // { |
| | | // toPlace = ((int)EDevice.提升机1030).ToString(); |
| | | // } |
| | | |
| | | |
| | | StationDBForWriteComm w_db_source = this.DBBlockForWrite.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == sourcePlce); |
| | | StationDB2ObjForWriteComm w_dbObj_source = this.View.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == sourcePlce); |
| | | // StationDBForWriteComm w_db_source = this.DBBlockForWrite.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == sourcePlce); |
| | | // StationDB2ObjForWriteComm w_dbObj_source = this.View.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == sourcePlce); |
| | | |
| | | //StationDBForWriteComm w_db_to = this.DBBlockForWrite.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == toPlace); |
| | | //StationDB2ObjForWriteComm w_dbObj_to = this.View.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == toPlace); |
| | | //如果ACK为true,表示不能发任务 |
| | | var readObj = this.View.R_StationForReadCommList.FirstOrDefault(x => x.StationCode == sourcePlce); |
| | | if (readObj.R_ACK == true) |
| | | { |
| | | msg = "ACK为TRUE,不允许发任务"; |
| | | return false; |
| | | } |
| | | // //StationDBForWriteComm w_db_to = this.DBBlockForWrite.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == toPlace); |
| | | // //StationDB2ObjForWriteComm w_dbObj_to = this.View.W_StationForWriteCommList.FirstOrDefault(x => x.StationCode == toPlace); |
| | | // //如果ACK为true,表示不能发任务 |
| | | // var readObj = this.View.R_StationForReadCommList.FirstOrDefault(x => x.StationCode == sourcePlce); |
| | | // if (readObj.R_ACK == true) |
| | | // { |
| | | // msg = "ACK为TRUE,不允许发任务"; |
| | | // return false; |
| | | // } |
| | | |
| | | MessageModel b2 = null; |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station{0},起点{1}发送任务{2},写入目标站点{3}失败,返回结果:" + b2.resMsg, this.View.DeviceName, sourcePlce, taskId, toPlace); |
| | | return false; |
| | | } |
| | | b2 = this.plcService.WriteValuePoint(w_db_source.W_TaskID, Convert.ToInt32(taskId), w_dbObj_source.W_TaskID); |
| | | if (!b2.result) |
| | | { |
| | | msg = string.Format("向Station{0},起点{1},目标点{2},写入任务号{3}失败,返回结果:" + b2.resMsg, this.View.DeviceName, sourcePlce, toPlace, taskId); |
| | | return false; |
| | | } |
| | | // MessageModel b2 = null; |
| | | // if (!b2.result) |
| | | // { |
| | | // msg = string.Format("向Station{0},起点{1}发送任务{2},写入目标站点{3}失败,返回结果:" + b2.resMsg, this.View.DeviceName, sourcePlce, taskId, toPlace); |
| | | // return false; |
| | | // } |
| | | // b2 = this.plcService.WriteValuePoint(w_db_source.W_TaskID, Convert.ToInt32(taskId), w_dbObj_source.W_TaskID); |
| | | // if (!b2.result) |
| | | // { |
| | | // msg = string.Format("向Station{0},起点{1},目标点{2},写入任务号{3}失败,返回结果:" + b2.resMsg, this.View.DeviceName, sourcePlce, toPlace, taskId); |
| | | // return false; |
| | | // } |
| | | |
| | | |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | msg = ex.Message; |
| | | Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, "发送任务出现异常:" + ex.Message, ex); |
| | | return false; |
| | | } |
| | | // return true; |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // msg = ex.Message; |
| | | // Log4NetHelper.WriteErrorLog(Station_CacheEntity.curLogType, "发送任务出现异常:" + ex.Message, ex); |
| | | // return false; |
| | | //} |
| | | } |
| | | |
| | | |