public void add(ATRANSFER transfer) { using (DBConnection_EF con = DBConnection_EF.GetUContext()) { tranDao.add(con, transfer); } }
public CarrierLocationChooseForm(SCApplication _scApp, ATRANSFER transfer) { InitializeComponent(); scApp = _scApp; initialVhLocationCmd(); initialForceFinishStatus(); initialCarrierInfo(transfer); }
private void initialCarrierInfo(ATRANSFER transfer) { string source = SCUtility.Trim(transfer.HOSTSOURCE, true); string dest = SCUtility.Trim(transfer.HOSTDESTINATION, true); string carrier_id = SCUtility.Trim(transfer.CARRIER_ID, true); string cmd_id = SCUtility.Trim(transfer.ID, true); m_CMDIDTxb.Text = cmd_id; m_CSTIDTxb.Text = carrier_id; m_sourceTxb.Text = source; m_destTxb.Text = dest; }
public bool updateTranStatus2LoadArrivals(string cmdID) { bool isSuccess = true; using (DBConnection_EF con = DBConnection_EF.GetUContext()) { ATRANSFER cmd = tranDao.getByID(con, cmdID); cmd.COMMANDSTATE = cmd.COMMANDSTATE | ATRANSFER.COMMAND_STATUS_BIT_INDEX_LOAD_ARRIVE; tranDao.update(con, cmd); } return(isSuccess); }
public bool updateTranStatus2UnloadComplete(string cmdID) { bool isSuccess = true; using (DBConnection_EF con = DBConnection_EF.GetUContext()) { ATRANSFER cmd = tranDao.getByID(con, cmdID); cmd.COMMANDSTATE = cmd.COMMANDSTATE | ATRANSFER.COMMAND_STATUS_BIT_INDEX_UNLOAD_COMPLETE; tranDao.update(con, cmd); } return(isSuccess); }
private async void btnPriorityUpdate_Click(object sender, EventArgs e) { try { if (selection_index == -1) { return; } btn_force_finish.Enabled = false; var mcs_cmd = cmdMCSshowList[selection_index]; ATRANSFER transfer = await Task.Run(() => GetRealTranCommandInfo(mcs_cmd)); if (transfer == null) { MessageBox.Show($"Transfer cmd ID:{SCUtility.Trim(mcs_cmd.CMD_ID, true)} not exist.", "Check command fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (transfer.TRANSFERSTATE != E_TRAN_STATUS.Queue) { MessageBox.Show($"Transfer cmd ID:{SCUtility.Trim(mcs_cmd.CMD_ID, true)} is not in queue.", "Priority update fail.", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } bool is_success = false; int manual_time_priority = (int)num_PriorityValue.Value; await Task.Run(() => { try { is_success = mainform.BCApp.SCApplication.TransferService.updateTranTimePriority(mcs_cmd.vtrnasfer, manual_time_priority); } catch { } }); if (is_success) { MessageBox.Show($"Transfer cmd ID:{SCUtility.Trim(mcs_cmd.CMD_ID, true)} update priority to {manual_time_priority} is success.", "Priority update success.", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show($"Transfer cmd ID:{SCUtility.Trim(mcs_cmd.CMD_ID, true)} update priority to {manual_time_priority} is fail.", "Priority update success.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } updateTransferCommand(); } catch (Exception ex) { } finally { btn_force_finish.Enabled = true; } }
private async void btn_force_assign_Click(object sender, EventArgs e) { string selected_vh_id = cmb_force_assign.Text; try { if (selection_index == -1) { MessageBox.Show("Please select transfer command. ", "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } btn_force_finish.Enabled = false; var mcs_cmd = cmdMCSshowList[selection_index]; AVEHICLE excute_cmd_of_vh = mainform.BCApp.SCApplication.VehicleBLL.cache.getVehicle(selected_vh_id); ATRANSFER transfer = mainform.BCApp.SCApplication.CMDBLL.GetTransferByID(mcs_cmd.CMD_ID); sc.BLL.CMDBLL.CommandCheckResult check_result_info = null; string force_assign_st_port = ""; bool is_selected_agv_station_port = cmb_st_port_ids.Visible; if (is_selected_agv_station_port) { force_assign_st_port = cmb_st_port_ids.Text; } await Task.Run(() => { try { mainform.BCApp.SCApplication.TransferService.AssignTransferToVehicle(transfer, excute_cmd_of_vh, force_assign_st_port); check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.CommandCheckResult> (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT); } catch { } } ); updateTransferCommand(); if (check_result_info != null && !check_result_info.IsSuccess) { MessageBox.Show(check_result_info.ToString(), "Command create fail. ", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("Command create success.", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { } finally { btn_force_finish.Enabled = true; } }
public bool updateTranStatus2Transferring(string cmdID, bool isWating) { bool isSuccess = true; using (DBConnection_EF con = DBConnection_EF.GetUContext()) { ATRANSFER cmd = tranDao.getByID(con, cmdID); cmd.PAUSEFLAG = isWating ? TRANSFER_PAUSE_FLAG : ""; cmd.TRANSFERSTATE = E_TRAN_STATUS.Transferring; cmd.COMMANDSTATE = cmd.COMMANDSTATE | ATRANSFER.COMMAND_STATUS_BIT_INDEX_LOAD_COMPLETE; tranDao.update(con, cmd); } return(isSuccess); }
public bool updateTranStatus2InitialAndExcuteCmdID(string cmdID, string excuteCmdID) { bool isSuccess = true; using (DBConnection_EF con = DBConnection_EF.GetUContext()) { ATRANSFER cmd = tranDao.getByID(con, cmdID); cmd.TRANSFERSTATE = E_TRAN_STATUS.Initial; cmd.CMD_START_TIME = DateTime.Now; cmd.COMMANDSTATE = cmd.COMMANDSTATE | ATRANSFER.COMMAND_STATUS_BIT_INDEX_ENROUTE; cmd.EXCUTE_CMD_ID = excuteCmdID; tranDao.update(con, cmd); } return(isSuccess); }
public void update(DBConnection_EF con, ATRANSFER cmd) { con.SaveChanges(); }
public void add(DBConnection_EF con, ATRANSFER rail) { con.ATRANSFER.Add(rail); con.SaveChanges(); }
private void RegisterTransferManagementEvent() { Post["TransferManagement/MCSQueueSwitch"] = (p) => { var scApp = SCApplication.getInstance(); string result = string.Empty; try { string AutoAssign = Request.Query.AutoAssign.Value ?? Request.Form.AutoAssign.Value ?? string.Empty; bool isAutoAssign = Convert.ToBoolean(AutoAssign); scApp.getEQObjCacheManager().getLine().MCSCommandAutoAssign = isAutoAssign; result = "OK"; } catch (Exception ex) { result = "MCS Queue Switch update failed with exception happened"; } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["TransferManagement/CancelAbort"] = (p) => { var scApp = SCApplication.getInstance(); bool isSuccess = true; string result = string.Empty; CancelActionType cnacel_type = default(CancelActionType); string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty; try { ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id); if (mcs_cmd == null) { result = $"Can not find transfer command:[{mcs_cmd_id}]."; } else { if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring) { cnacel_type = CancelActionType.CmdCancel; bool btemp = scApp.TransferService.AbortOrCancel(mcs_cmd_id, cnacel_type); if (btemp) { result = "OK"; } else { result = $"Transfer command:[{mcs_cmd_id}] cancel failed."; } } else if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling) { cnacel_type = CancelActionType.CmdAbort; bool btemp = scApp.TransferService.AbortOrCancel(mcs_cmd_id, cnacel_type); if (btemp) { result = "OK"; } else { result = $"Transfer command:[{mcs_cmd_id}] adort failed."; } } else { result = $"Command ID:{mcs_cmd.ID.Trim()} can't excute cancel / abort,\r\ncurrent state:{mcs_cmd.TRANSFERSTATE}"; } } } catch (Exception ex) { isSuccess = false; result = "Execption happend!"; logger.Error(ex, "Execption:"); } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["TransferManagement/ForceFinish"] = (p) => { var scApp = SCApplication.getInstance(); bool isSuccess = true; string result = string.Empty; string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty; ACMD cmd = scApp.CMDBLL.GetCommandByTransferCmdID(mcs_cmd_id); AVEHICLE excute_cmd_of_vh = scApp.VehicleBLL.cache.getVehicle(cmd.VH_ID); ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id); try { //todo kevin 需要再Reviwer下 //if (cmd != null) //{ // scApp.VehicleBLL.doTransferCommandFinish(excute_cmd_of_vh.VEHICLE_ID, cmd.ID, CompleteStatus.ForceFinishByOp, 0); // scApp.VIDBLL.initialVIDCommandInfo(excute_cmd_of_vh.VEHICLE_ID); //} //scApp.CMDBLL.updateCMD_MCS_TranStatus2Complete(mcs_cmd_id, E_TRAN_STATUS.Aborted); //scApp.ReportBLL.newReportTransferCommandFinish(mcs_cmd, excute_cmd_of_vh, sc.Data.SECS.AGVC.SECSConst.CMD_Result_Unsuccessful, null); result = "OK"; } catch { result = "ForceFinish failed."; } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["TransferManagement/AssignVehicle"] = (p) => { var scApp = SCApplication.getInstance(); string result = string.Empty; string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty; string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; try { ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id); scApp.CMDBLL.assignCommnadToVehicle(mcs_cmd_id, vh_id, out result); } catch (Exception ex) { result = "Assign command to vehicle failed with exception happened."; } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["TransferManagement/ShiftCommand"] = (p) => { var scApp = SCApplication.getInstance(); string result = string.Empty; string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty; string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; try { ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id); var excute_result = scApp.TransferService.CommandShift(mcs_cmd_id, vh_id); result = excute_result.result; } catch (Exception ex) { result = "Shift command failed with exception happened."; } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["TransferManagement/ChangeStatus"] = (p) => { var scApp = SCApplication.getInstance(); string result = string.Empty; bool isSuccess = true; string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty; string sstatus = Request.Query.status.Value ?? Request.Form.status.Value ?? string.Empty; try { ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id); E_TRAN_STATUS status = (E_TRAN_STATUS)Enum.Parse(typeof(E_TRAN_STATUS), sstatus, false); if (mcs_cmd != null) { isSuccess = scApp.CMDBLL.updateTransferCmd_TranStatus(mcs_cmd_id, status); if (isSuccess) { result = "OK"; } else { result = "Update status failed."; } } else { result = $"Can not find MCS Command[{mcs_cmd_id}]."; } } catch (Exception ex) { result = "Update status failed with exception happened."; } //Todo by Mark var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["TransferManagement/Priority"] = (p) => { var scApp = SCApplication.getInstance(); string result = string.Empty; bool isSuccess = true; string mcs_cmd_id = Request.Query.mcs_cmd.Value ?? Request.Form.mcs_cmd.Value ?? string.Empty; string priority = Request.Query.priority.Value ?? Request.Form.priority.Value ?? string.Empty; try { ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id); int iPriority = Convert.ToInt32(priority); if (mcs_cmd != null) { isSuccess = scApp.CMDBLL.updateCMD_MCS_PrioritySUM(mcs_cmd, iPriority); if (isSuccess) { result = "OK"; } else { result = "Update priority failed."; } } else { result = $"Can not find MCS Command[{mcs_cmd_id}]."; } } catch (Exception ex) { result = "Update priority failed with exception happened."; } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; }
private void RegisterVehilceEvent() { Get["AVEHICLES/{ID}"] = (p) => { string vh_id = p.ID; AVEHICLE vh = SCApplication.getInstance().VehicleBLL.cache.getVehicle(vh_id); var response = (Response)vh.ToString(); response.ContentType = restfulContentType; return(response); }; Get["AVEHICLES"] = (p) => { string vh_id = p.ID; List <AVEHICLE> vhs = SCApplication.getInstance().getEQObjCacheManager().getAllVehicle(); var response = (Response)JsonConvert.SerializeObject(vhs); response.ContentType = restfulContentType; return(response); }; //Get["AVEHICLES/(?<all>)"] = (p) => Get["AVEHICLES/_search"] = (p) => { List <AVEHICLE> vhs = null; foreach (string name in Request.Query) { switch (name) { case "SectionID": string sec_id = Request.Query[name] ?? string.Empty; vhs = SCApplication.getInstance().VehicleBLL.cache.loadVehicleBySEC_ID(sec_id); break; } } var response = (Response)JsonConvert.SerializeObject(vhs); response.ContentType = restfulContentType; return(response); }; Get["metrics"] = (p) => { int total_idle_vh_clean = SCApplication.getInstance().VehicleBLL.cache.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Clean); int total_idle_vh_Dirty = SCApplication.getInstance().VehicleBLL.cache.getNoExcuteMcsCmdVhCount(E_VH_TYPE.Dirty); int total_cmd_is_queue_count = SCApplication.getInstance().CMDBLL.getCMD_MCSIsQueueCount(); int total_cmd_is_running_count = SCApplication.getInstance().CMDBLL.getCMD_MCSIsRunningCount(); string ohxc_excute_info = string.Empty; StringBuilder sb = new StringBuilder(); setOhxCContent(sb, nameof(total_idle_vh_clean), total_idle_vh_clean, "current idle clean car"); setOhxCContent(sb, nameof(total_idle_vh_Dirty), total_idle_vh_Dirty, "current idle dirty car"); setOhxCContent(sb, nameof(total_cmd_is_queue_count), total_cmd_is_queue_count, "cmd number being queued"); setOhxCContent(sb, nameof(total_cmd_is_running_count), total_cmd_is_running_count, "cmd number being executed"); var response = (Response)sb.ToString(); response.ContentType = restfulContentType; return(response); }; Post["AVEHICLES/ViewerUpdate"] = (p) => { SCApplication scApp = SCApplication.getInstance(); List <AVEHICLE> vhs = scApp.getEQObjCacheManager().getAllVehicle(); //foreach (AVEHICLE vh in vhs) //{ // scApp.VehicleService.PublishVhInfo(vh, null); // SpinWait.SpinUntil(() => false, 10); //} var response = (Response)"OK"; response.ContentType = restfulContentType; return(response); }; //Post["api/io/T2STK100T01/waitin/CST01"] = (p) => //{ // var response = (Response)"OK"; // response.ContentType = restfulContentType; // return response; //}; Post["AVEHICLES/SendCommand"] = (p) => { var scApp = SCApplication.getInstance(); bool isSuccess = true; string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; string carrier_id = Request.Query.carrier_id.Value ?? Request.Form.carrier_id.Value ?? string.Empty; string from_port_id = Request.Query.from_port_id.Value ?? Request.Form.from_port_id.Value ?? string.Empty; string to_port_id = Request.Query.to_port_id.Value ?? Request.Form.to_port_id.Value ?? string.Empty; E_CMD_TYPE e_cmd_type = default(E_CMD_TYPE); string cmd_type = Request.Query.cmd_type.Value ?? Request.Form.cmd_type.Value ?? string.Empty; string result = string.Empty; try { ACMD cmd_obj = null; AVEHICLE assignVH = null; assignVH = scApp.VehicleBLL.cache.getVehicle(vh_id); isSuccess = assignVH != null; if (isSuccess) { isSuccess = Enum.TryParse(cmd_type, out e_cmd_type); if (isSuccess) { switch (e_cmd_type) { case E_CMD_TYPE.Move: case E_CMD_TYPE.Load: case E_CMD_TYPE.Unload: case E_CMD_TYPE.LoadUnload: string from_adr = from_port_id; string to_adr = to_port_id; //scApp.MapBLL.getAddressID(from_port_id, out from_adr); //scApp.MapBLL.getAddressID(to_port_id, out to_adr); scApp.CMDBLL.doCreatCommand(vh_id, out cmd_obj, cmd_type: e_cmd_type, source: from_adr, destination: to_adr, carrier_id: carrier_id, gen_cmd_type: SCAppConstants.GenOHxCCommandType.Manual); sc.BLL.CMDBLL.CommandCheckResult check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.CommandCheckResult> (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT); isSuccess = check_result_info.IsSuccess; result = check_result_info.ToString(); if (isSuccess) { //isSuccess = scApp.VehicleService.doSendCommandToVh(assignVH, cmd_obj); isSuccess = scApp.VehicleService.Send.Command(assignVH, cmd_obj); if (isSuccess) { result = "OK"; } else { result = "Send command to vehicle failed!"; } } else { result = "Command create failed!"; //bcf.App.BCFApplication.onWarningMsg(this, new bcf.Common.LogEventArgs("Command create fail.", check_result_info.Num)); } break; case E_CMD_TYPE.Teaching: isSuccess = scApp.VehicleService.Send.Teaching(vh_id, from_port_id, to_port_id); break; } } else { result = $"Try parse Command Type:[{cmd_type}] failed!"; } } else { result = $"Vehicle :[{vh_id}] not found!"; } } catch (Exception ex) { isSuccess = false; result = "Execption happend!"; logger.Error(ex, "Execption:"); } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["AVEHICLES/SendReset"] = (p) => { var scApp = SCApplication.getInstance(); bool isSuccess = true; string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; string result = string.Empty; try { AVEHICLE assignVH = null; assignVH = scApp.VehicleBLL.cache.getVehicle(vh_id); isSuccess = assignVH != null; if (isSuccess) { isSuccess = scApp.VehicleService.Send.StatusRequest(vh_id, true); if (isSuccess) { result = "OK"; } else { result = "Send vehicle status request failed."; } } else { result = $"Vehicle :[{vh_id}] not found!"; } } catch (Exception ex) { isSuccess = false; result = "Execption happend!"; logger.Error(ex, "Execption:"); } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["AVEHICLES/SendCancelAbort"] = (p) => { var scApp = SCApplication.getInstance(); bool isSuccess = true; string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; string cmd_id = "";//todo kevin 需要指定cmd id string result = string.Empty; try { ACMD cmd = scApp.CMDBLL.GetCMD_OHTCByID(cmd_id); if (cmd == null) { result = $"Can't find command:[{cmd_id}] in database."; isSuccess = false; } AVEHICLE assignVH = null; if (isSuccess) { assignVH = scApp.VehicleBLL.cache.getVehicle(vh_id); isSuccess = assignVH != null; } if (isSuccess) { string mcs_cmd_id = cmd_id; if (!string.IsNullOrWhiteSpace(mcs_cmd_id)) { ATRANSFER mcs_cmd = scApp.CMDBLL.GetTransferByID(mcs_cmd_id); if (mcs_cmd == null) { result = $"Can't find MCS command:[{mcs_cmd_id}] in database."; } else { CancelActionType actType = default(CancelActionType); if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Transferring) { actType = CancelActionType.CmdCancel; isSuccess = scApp.TransferService.AbortOrCancel(mcs_cmd_id, actType); if (isSuccess) { result = "OK"; } else { result = "Send command cancel/abort failed."; } } else if (mcs_cmd.TRANSFERSTATE < sc.E_TRAN_STATUS.Canceling) { actType = CancelActionType.CmdAbort; isSuccess = scApp.TransferService.AbortOrCancel(mcs_cmd_id, actType); if (isSuccess) { result = "OK"; } else { result = "Send command cancel/abort failed."; } } else { result = $"MCS command:[{mcs_cmd_id}] can't excute cancel / abort,\r\ncurrent state:{mcs_cmd.TRANSFERSTATE}"; } } } else { string ohtc_cmd_id = cmd_id; if (string.IsNullOrWhiteSpace(ohtc_cmd_id)) { result = $"Vehicle:[{vh_id}] do not have command."; } else { ACMD ohtc_cmd = scApp.CMDBLL.GetCMD_OHTCByID(ohtc_cmd_id); if (ohtc_cmd == null) { result = $"Can't find vehicle command:[{ohtc_cmd_id}] in database."; } else { CancelActionType actType = ohtc_cmd.CMD_STATUS >= E_CMD_STATUS.Execution ? CancelActionType.CmdAbort : CancelActionType.CmdCancel; isSuccess = scApp.VehicleService.Send.Cancel(assignVH.VEHICLE_ID, ohtc_cmd_id, actType); if (isSuccess) { result = "OK"; } else { result = "Send vehicle status request failed."; } } } } } else { result = $"Vehicle :[{vh_id}] not found!"; } } catch (Exception ex) { isSuccess = false; result = "Execption happend!"; logger.Error(ex, "Execption:"); } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["AVEHICLES/PauseEvent"] = (p) => { bool isSuccess = false; SCApplication scApp = SCApplication.getInstance(); string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; string event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty; PauseEvent pauseEvent = default(PauseEvent); isSuccess = Enum.TryParse(event_type, out pauseEvent); if (isSuccess) { isSuccess = scApp.VehicleService.Send.Pause(vh_id, pauseEvent, PauseType.Normal); } var response = (Response)(isSuccess ? "OK" : "NG"); response.ContentType = restfulContentType; return(response); }; Post["AVEHICLES/PauseStatusChange"] = (p) => { bool isSuccess = false; string result = string.Empty; SCApplication scApp = SCApplication.getInstance(); string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; string pauseType = Request.Query.pauseType.Value ?? Request.Form.pauseType.Value ?? string.Empty; string event_type = Request.Query.event_type.Value ?? Request.Form.event_type.Value ?? string.Empty; PauseType pause_type = default(PauseType); PauseEvent pauseEvent = default(PauseEvent); isSuccess = Enum.TryParse(pauseType, out pause_type); if (isSuccess) { isSuccess = Enum.TryParse(event_type, out pauseEvent); if (isSuccess) { isSuccess = scApp.VehicleService.Send.Pause(vh_id, pauseEvent, pause_type); if (isSuccess) { result = "OK"; } else { result = $"Send pause request to vehicle:{vh_id} failed."; } } else { result = $"Can't recognize Pause Event:{event_type}."; } } else { result = $"Can't recognize Pause Type:{pauseType}."; } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["AVEHICLES/ModeStatusChange"] = (p) => { string result = string.Empty; bool isSuccess = false; SCApplication scApp = SCApplication.getInstance(); string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; string modeStatus = Request.Query.modeStatus.Value ?? Request.Form.modeStatus.Value ?? string.Empty; VHModeStatus mode_status = default(VHModeStatus); isSuccess = Enum.TryParse(modeStatus, out mode_status); try { if (isSuccess) { scApp.VehicleBLL.cache.updataVehicleMode(vh_id, mode_status); result = "OK"; } else { result = $"Can't recognize mode status:{modeStatus}."; } } catch (Exception ex) { result = $"Update vehicle:{vh_id} mode status failed."; logger.Error(ex, "Exception"); } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["AVEHICLES/ResetAlarm"] = (p) => { var scApp = SCApplication.getInstance(); string result = string.Empty; bool isSuccess = true; string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; try { isSuccess = scApp.VehicleService.Send.AlarmReset(vh_id); if (isSuccess) { result = "OK"; } else { result = "Reset alarm failed."; } } catch (Exception ex) { result = "Reset alarm failedwith exception happened."; } var response = (Response)result; response.ContentType = restfulContentType; return(response); }; Post["Engineer/ForceCmdFinish"] = (p) => { var scApp = SCApplication.getInstance(); string vh_id = Request.Query.vh_id.Value ?? Request.Form.vh_id.Value ?? string.Empty; bool isSuccess = scApp.CMDBLL.forceUpdataCmdStatus2FnishByVhID(vh_id); if (isSuccess) { var vh = scApp.VehicleBLL.cache.getVehicle(vh_id); //vh.NotifyVhExcuteCMDStatusChange(); vh.onExcuteCommandStatusChange(); } var response = (Response)(isSuccess ? "OK" : "NG"); response.ContentType = restfulContentType; return(response); }; }
protected virtual void S1F3ReceiveSelectedEquipmentStatusRequest(object sender, SECSEventArgs e) { try { S1F3 s1f3 = ((S1F3)e.secsHandler.Parse <S1F3>(e)); SCUtility.secsActionRecordMsg(scApp, true, s1f3); int count = s1f3.SVID.Count(); S1F4 s1f4 = new S1F4(); s1f4.SECSAgentName = scApp.EAPSecsAgentName; s1f4.SystemByte = s1f3.SystemByte; s1f4.SV = new SXFY[count]; for (int i = 0; i < count; i++) { if (s1f3.SVID[i] == SECSConst.VID_AlarmsSet) { //TODO Set Alarm List s1f4.SV[i] = new S6F11.RPTINFO.RPTITEM.VIDITEM_04(); } else if (s1f3.SVID[i] == SECSConst.VID_ControlState) { string control_state = SCAppConstants.LineHostControlState.convert2MES(line.Host_Control_State); s1f4.SV[i] = new S6F11.RPTINFO.RPTITEM.VIDITEM_06() { CONTROLSTATE = control_state }; } else if (s1f3.SVID[i] == SECSConst.VID_ActiveVehicles) { List <AVEHICLE> vhs = scApp.getEQObjCacheManager().getAllVehicle(); int vhs_count = vhs.Count; S6F11.RPTINFO.RPTITEM.VIDITEM_71[] VEHICLEINFOs = new S6F11.RPTINFO.RPTITEM.VIDITEM_71[vhs_count]; for (int j = 0; j < vhs_count; j++) { VEHICLEINFOs[j] = new S6F11.RPTINFO.RPTITEM.VIDITEM_71() { VHINFO = new S6F11.RPTINFO.RPTITEM.VIDITEM_71.VEHICLEINFO() { VEHICLE_ID = vhs[j].VEHICLE_ID, VEHICLE_STATE = "2" } }; } s1f4.SV[i] = new S6F11.RPTINFO.RPTITEM.VIDITEM_53() { VEHICLEINFO = VEHICLEINFOs }; } else if (s1f3.SVID[i] == SECSConst.VID_SCState) { //string sc_state = SCAppConstants.LineSCState.convert2MES(line.SCStats); //s1f4.SV[i] = new S6F11.RPTINFO.RPTITEM.VIDITEM_73() //{ // SCSTATE = sc_state //}; } else if (s1f3.SVID[i] == SECSConst.VID_EnhancedTransfers) { List <ATRANSFER> mcs_cmds = scApp.CMDBLL.loadUnfinishedTransfer(); int cmd_count = mcs_cmds.Count; S6F11.RPTINFO.RPTITEM.VIDITEM_13[] EnhancedTransferCmds = new S6F11.RPTINFO.RPTITEM.VIDITEM_13[cmd_count]; for (int k = 0; k < cmd_count; k++) { ATRANSFER mcs_cmd = mcs_cmds[k]; string transfer_state = SCAppConstants.TransferState.convert2MES(mcs_cmd.TRANSFERSTATE); EnhancedTransferCmds[k] = new S6F11.RPTINFO.RPTITEM.VIDITEM_13(); EnhancedTransferCmds[k].TRANSFER_STATE.TRANSFER_STATE = transfer_state; EnhancedTransferCmds[k].COMMAND_INFO.COMMAND_ID.COMMAND_ID = mcs_cmd.ID; EnhancedTransferCmds[k].COMMAND_INFO.PRIORITY.PRIORITY = mcs_cmd.PRIORITY.ToString(); EnhancedTransferCmds[k].TRANSFER_INFO.CARRIER_ID = mcs_cmd.CARRIER_ID; EnhancedTransferCmds[k].TRANSFER_INFO.SOURCE_PORT = mcs_cmd.HOSTSOURCE; EnhancedTransferCmds[k].TRANSFER_INFO.DESTINATION_PORT = mcs_cmd.HOSTDESTINATION; } s1f4.SV[i] = new S6F11.RPTINFO.RPTITEM.VIDITEM_76() { EnhancedTransferCmd = EnhancedTransferCmds }; } else if (s1f3.SVID[i] == SECSConst.VID_Spec_Version) { s1f4.SV[i] = new S6F11.RPTINFO.RPTITEM.VIDITEM_114() { SPEC_VERSION = string.Empty // TODO fill in }; } else if (s1f3.SVID[i] == SECSConst.VID_Enhanced_Carriers) { //List<AVEHICLE> has_carry_vhs = scApp.getEQObjCacheManager().getAllVehicle().Where(vh => vh.HAS_CST == 1).ToList(); //int carry_vhs_count = has_carry_vhs.Count; S6F11.RPTINFO.RPTITEM.VIDITEM_10[] carrier_info = new S6F11.RPTINFO.RPTITEM.VIDITEM_10[0]; } else if (s1f3.SVID[i] == SECSConst.VID_Current_Port_States) { List <APORTSTATION> port_station = scApp.MapBLL.loadAllPort(); int port_count = port_station.Count; var vid_118 = new S6F11.RPTINFO.RPTITEM.VIDITEM_118(); vid_118.PORT_INFO = new S6F11.RPTINFO.RPTITEM.VIDITEM_354[port_count]; for (int j = 0; j < port_count; j++) { vid_118.PORT_INFO[j] = new S6F11.RPTINFO.RPTITEM.VIDITEM_354(); vid_118.PORT_INFO[j].PORT_ID.PORT_ID = port_station[j].PORT_ID; vid_118.PORT_INFO[j].PORT_TRANSFTER_STATE.PORT_TRANSFER_STATE = ((int)port_station[j].PORT_STATUS).ToString(); } s1f4.SV[i] = vid_118; } else { s1f4.SV[i] = new S6F11.RPTINFO.RPTITEM.VIDITEM_04(); } } TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s1f4); SCUtility.secsActionRecordMsg(scApp, false, s1f4); } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "S1F3_Receive_Eqpt_Stat_Req", ex.ToString()); } }