public void StartNewTask() { //Check if a new task can be started if (thePalletCrane.CurrentHalfCycle == null && taskList.Count > 0) { PalletCraneTask selectedTask = null; foreach (var task in taskList) { if (thePalletCrane.DropStationAvailable || task.TaskType != PalletCraneTaskType.Retrieval) { selectedTask = task; break; } } if (selectedTask != null) { if (selectedTask != taskList[0]) //Move the selected task to the top of the list, then this becomes the current task { taskList.Remove(selectedTask); taskList.Insert(0, selectedTask); } thePalletCrane.StartPalletCraneHalfCycle(taskList[0].HalfCycles[0]); } } }
public void StartTransportTelegramReceived(string[] telegramFields) { //Create palletCrane tasklist from message PalletCraneTask newTask = new PalletCraneTask(new List <object> { telegramFields }); //Convert telegram to TelegramData //is it a storage, retreival, relocation or reject task type string source = telegramFields.GetFieldValue(TelegramFields.source); string destination = telegramFields.GetFieldValue(TelegramFields.destination); newTask.TaskType = GetTaskType(source, destination); if (newTask.TaskType == PalletCraneTaskType.Storage || newTask.TaskType == PalletCraneTaskType.Reject) //Store 1 in the racking from pick station { var pallet = thePalletCrane.PickStationPallet(source) as ATCEuroPallet; //This will only work if the pick station is on the RHS of the PalletCrane, Pickstation MergeSide set as left if (pallet == null || pallet.TUIdent != telegramFields.GetFieldValue(TelegramFields.tuIdent)) { Log.Write(string.Format("PalletCrane {0}: Loads at pick station and 'StartTransportTelegram' from ATC do not match, telegram ignored", thePalletCrane.Name)); return; } controller.UpDateLoadParameters(telegramFields, pallet); //Create the palletCrane half cycles float x, y; thePalletCrane.GetPickStationLocation(source, out x, out y); var pickFromPs = new PalletCraneHalfCycle //Pick from pick station { Cycle = PalletCraneCycle.PickPS, TuIdent = pallet.TUIdent, Length = x - thePalletCrane.LHDWidth / 2, Height = y, StationName = source }; newTask.HalfCycles.Add(pickFromPs); if (newTask.TaskType == PalletCraneTaskType.Storage) { var palletDrop = new PalletCraneHalfCycle //Drop the load in the racking { Cycle = PalletCraneCycle.DropRack, Lhd = 1, Length = GetXLoc(telegramFields, pallet), Height = GetYLoc(telegramFields, pallet), Depth = GetDepth(telegramFields, pallet), RackSide = GetSide(telegramFields, pallet), }; newTask.HalfCycles.Add(palletDrop); } else if (newTask.TaskType == PalletCraneTaskType.Reject) { thePalletCrane.GetDropStationLocation(destination, out x, out y); var dropToDs = new PalletCraneHalfCycle //Drop to the drop Station { Cycle = PalletCraneCycle.DropDS, TuIdent = pallet.TUIdent, Length = x - thePalletCrane.LHDWidth / 2, Height = y, StationName = destination }; newTask.HalfCycles.Add(dropToDs); } } else if (newTask.TaskType == PalletCraneTaskType.Retrieval || newTask.TaskType == PalletCraneTaskType.Relocation) { //Create the palletCrane half cycles var palletData = controller.CreateATCPalletData(telegramFields); string loadSource = telegramFields.GetFieldValue(TelegramFields.source); string loadTuIdent = telegramFields.GetFieldValue(TelegramFields.tuIdent); string loadDestination = telegramFields.GetFieldValue(TelegramFields.destination); int lhd = 1; PalletCraneHalfCycle loadPick = new PalletCraneHalfCycle { Cycle = PalletCraneCycle.PickRack, Lhd = lhd, Length = GetXLoc(loadSource), Height = GetYLoc(loadSource), Depth = GetDepth(loadSource), RackSide = GetSide(loadSource), TuIdent = loadTuIdent, PalletData = palletData }; newTask.HalfCycles.Add(loadPick); if (newTask.TaskType == PalletCraneTaskType.Retrieval) { float x, y; thePalletCrane.GetDropStationLocation(destination, out x, out y); var dropToDs = new PalletCraneHalfCycle //Drop to the drop Station { Cycle = PalletCraneCycle.DropDS, TuIdent = loadTuIdent, Length = x - thePalletCrane.LHDWidth / 2, Height = y, StationName = destination }; newTask.HalfCycles.Add(dropToDs); } else if (newTask.TaskType == PalletCraneTaskType.Relocation) { var loadDrop = new PalletCraneHalfCycle { Cycle = PalletCraneCycle.DropRack, Lhd = lhd, Length = GetXLoc(loadDestination), Height = GetYLoc(loadDestination), Depth = GetDepth(loadDestination), RackSide = GetSide(loadDestination), TuIdent = loadTuIdent, PalletData = palletData }; newTask.HalfCycles.Add(loadDrop); } } AddNewTasks(newTask); }
void AddNewTasks(PalletCraneTask newTask) { //If the crane isn't doing anything then start the new task taskList.Add(newTask); StartNewTask(); }