private void RandomGenerates_TranTask_Clear_Drity(string car_type) { List <TranTask> lstTranTask = dicTranTaskSchedule_Clear_Dirty[car_type]; int task_RandomIndex = rnd_Index.Next(lstTranTask.Count - 1); Console.WriteLine(string.Format("Car Type:{0},Index:{1}", car_type, task_RandomIndex)); TranTask tranTask = lstTranTask[task_RandomIndex]; //Task.Run(() => mcsManager.sendTranCmd(tranTask.SourcePort, tranTask.DestinationPort)); //sendTranCmd("CST02", tranTask.SourcePort, tranTask.DestinationPort); }
private void tryCreatMCSCommand(E_VH_TYPE vh_type, List <string> load_port_lst) { int vh_count = scApp.VehicleBLL.getActVhCount(vh_type); if (vh_count == 0 || load_port_lst == null) { return; } int unfinished_cmd_count = scApp.CMDBLL.getCMD_MCSIsUnfinishedCount(load_port_lst); int task_RandomIndex = 0; TranTask tranTask = null; APORTSTATION source_port_station = null; APORTSTATION destination_port_station = null; string carrier_id = null; string find_task_type = vh_type.ToString().Substring(0, 1);; if (unfinished_cmd_count < vh_count) { bool is_find = false; if (!dicTranTaskSchedule_Clear_Dirty.ContainsKey(find_task_type)) { return; } var task_list_clean = dicTranTaskSchedule_Clear_Dirty[find_task_type].ToList(); do { task_RandomIndex = rnd_Index.Next(task_list_clean.Count - 1); tranTask = task_list_clean[task_RandomIndex]; source_port_station = scApp.getEQObjCacheManager().getPortStation(tranTask.SourcePort); destination_port_station = scApp.getEQObjCacheManager().getPortStation(tranTask.DestinationPort); if ((source_port_station != null && !SCUtility.isEmpty(source_port_station.CST_ID)) && scApp.CMDBLL.getCMD_MCSIsUnfinishedCountByCarrierID(source_port_station.CST_ID) == 0 && (destination_port_station != null && SCUtility.isEmpty(destination_port_station.CST_ID)) && scApp.CMDBLL.getCMD_MCSIsUnfinishedCountByPortID(destination_port_station.PORT_ID) == 0) { carrier_id = source_port_station.CST_ID; is_find = true; } else { task_list_clean.RemoveAt(task_RandomIndex); if (task_list_clean.Count == 0) { return; } } SpinWait.SpinUntil(() => false, 1); } while (!is_find); if (is_find) { sendTranCmd(carrier_id, tranTask.SourcePort, tranTask.DestinationPort); } } }
private void Taichung() { bool isMCS_CmdInQueue = scApp.CMDBLL.getCMD_MCSIsQueueCount() > 0; if (isMCS_CmdInQueue) { return; } int task_RandomIndex = rnd_Index.Next(tranTasks.Count - 1); TranTask tranTask = tranTasks[task_RandomIndex]; //if (SCUtility.isMatche(tranTask.SourcePort, tranTask.DestinationPort)) // return; sendTranCmd(tranTask.SourcePort, tranTask.DestinationPort); }