Esempio n. 1
0
 private string GetLoadIDFromCaseData(ATCCaseData cData)
 {
     if (cData != null)
     {
         return(cData.TUIdent);
     }
     return(string.Empty);
 }
Esempio n. 2
0
        public void StartTransportTelegramReceived(string[] telegramFields)
        {
            //Create miniload tasklist from message
            MiniloadTask newTasks = new MiniloadTask(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);

            newTasks.TaskType = GetTaskType(source, destination);

            if (newTasks.TaskType == MiniloadTaskType.Storage || newTasks.TaskType == MiniloadTaskType.Reject) //Store 1 in the racking from pick station
            {
                ATCCaseLoad LoadPos2 = theMiniload.Position2Load() as ATCCaseLoad;
                ATCCaseLoad LoadPos1 = theMiniload.Position1Load() as ATCCaseLoad;

                //This will only work if the pick station is on the RHS of the Miniload, Pickstation MergeSide set as left
                if (LoadPos1 == null || LoadPos1.TUIdent != telegramFields.GetFieldValue(TelegramFields.tuIdent) || LoadPos2 != null)
                {
                    Log.Write(string.Format("Miniload {0}: Loads at pick station and 'StartTransportTelegram' from ATC do not match, telegram ignored", theMiniload.Name));
                    return;
                }

                theMiniload.LockPickStation(); //Don't allow any more loads into the pick station

                //Set the Load in position 1 data correctly
                controller.UpDateLoadParameters(telegramFields, LoadPos1);

                //Create the miniload half cycles
                MiniloadHalfCycle pickFromPS = new MiniloadHalfCycle() //Pick from pick station
                {
                    Cycle       = MiniloadCycle.PickPS,
                    TuIdentPos1 = LoadPos1.TUIdent
                };
                newTasks.HalfCycles.Add(pickFromPS);

                if (newTasks.TaskType == MiniloadTaskType.Storage)
                {
                    MiniloadHalfCycle pos2Drop = new MiniloadHalfCycle() //Drop the load in the racking
                    {
                        Cycle       = MiniloadCycle.DropRack,
                        LHD         = 2,
                        Length      = GetXLoc(telegramFields, LoadPos1),
                        Height      = GetYLoc(telegramFields, LoadPos1),
                        Depth       = GetDepth(telegramFields, LoadPos1),
                        RackSide    = GetSide(telegramFields, LoadPos1),
                        TuIdentPos2 = LoadPos1.TUIdent
                    };
                    newTasks.HalfCycles.Add(pos2Drop);
                }

                else if (newTasks.TaskType == MiniloadTaskType.Reject)
                {
                    MiniloadHalfCycle dropToDS = new MiniloadHalfCycle() //Drop to the drop Station
                    {
                        Cycle       = MiniloadCycle.DropDS,
                        TuIdentPos2 = LoadPos1.TUIdent,
                    };
                    newTasks.HalfCycles.Add(dropToDS);
                }
            }
            else if (newTasks.TaskType == MiniloadTaskType.Retreival || newTasks.TaskType == MiniloadTaskType.Relocation)
            {
                //Create the miniload half cycles
                ATCCaseData caseData        = controller.CreateATCCaseData(telegramFields);
                string      loadSource      = telegramFields.GetFieldValue(TelegramFields.source);
                string      loadTUIdent     = telegramFields.GetFieldValue(TelegramFields.tuIdent);
                string      loadDestination = telegramFields.GetFieldValue(TelegramFields.destination);
                int         lhd             = 1;

                //Decide on what LHD the load is picked to
                if (newTasks.TaskType == MiniloadTaskType.Relocation && GetSide(loadDestination) == Side.Right)
                {
                    lhd = 2;
                }

                MiniloadHalfCycle loadPick = new MiniloadHalfCycle()
                {
                    Cycle       = MiniloadCycle.PickRack,
                    LHD         = lhd,
                    Length      = GetXLoc(loadSource),
                    Height      = GetYLoc(loadSource),
                    Depth       = GetDepth(loadSource),
                    RackSide    = GetSide(loadSource),
                    TuIdentPos1 = lhd == 1 ? loadTUIdent : null,
                    TuIdentPos2 = lhd == 2 ? loadTUIdent : null,
                    CaseData    = caseData
                };
                newTasks.HalfCycles.Add(loadPick);

                if (newTasks.TaskType == MiniloadTaskType.Retreival)
                {
                    MiniloadHalfCycle dropToDS = new MiniloadHalfCycle() //Drop to the drop Station
                    {
                        Cycle       = MiniloadCycle.DropDS,
                        TuIdentPos1 = loadTUIdent,
                    };
                    newTasks.HalfCycles.Add(dropToDS);
                }
                else if (newTasks.TaskType == MiniloadTaskType.Relocation)
                {
                    MiniloadHalfCycle loadDrop = new MiniloadHalfCycle()
                    {
                        Cycle       = MiniloadCycle.DropRack,
                        LHD         = lhd,
                        Length      = GetXLoc(loadDestination),
                        Height      = GetYLoc(loadDestination),
                        Depth       = GetDepth(loadDestination),
                        RackSide    = GetSide(loadDestination),
                        TuIdentPos1 = lhd == 1 ? loadTUIdent : null,
                        TuIdentPos2 = lhd == 2 ? loadTUIdent : null,
                        CaseData    = caseData
                    };
                    newTasks.HalfCycles.Add(loadDrop);
                }
            }

            AddNewTasks(newTasks);
        }
Esempio n. 3
0
        public void StartMultipleTransportTelegramReceived(string[] telegramFields)
        {
            //Create miniload tasklist from message
            List <string> indexMatches = new List <string>();
            List <string> telegrams    = Telegrams.DeMultaplise(telegramFields, TelegramTypes.StartMultipleTransportTelegram, out indexMatches);

            for (int i = 0; i < telegrams.Count; i++)
            {
                telegrams[i] = telegrams[i].Replace(string.Format("s{0}", indexMatches[i]), "");
            }

            MiniloadTask newTasks = new MiniloadTask(new List <object> {
                telegrams[0].Split(','), telegrams[1].Split(',')
            });                                                                                                              //Convert telegram to TelegramData
            //MiniloadTask newTasks = new MiniloadTask(telegramFields);

            int telegramCount = telegramFields.ArrayCount();

            if (telegramCount == 2)
            {
                //is it a storage, retreival, relocation or reject task type
                string source      = telegramFields.GetFieldValue(TelegramFields.sources, "[0]");
                string destination = telegramFields.GetFieldValue(TelegramFields.destinations, "[0]");

                newTasks.TaskType = GetTaskType(source, destination);

                if (newTasks.TaskType == MiniloadTaskType.Storage || newTasks.TaskType == MiniloadTaskType.Reject) //Store 2 in the racking from pick station
                {
                    ATCCaseLoad LoadPos1 = theMiniload.Position1Load() as ATCCaseLoad;
                    ATCCaseLoad LoadPos2 = theMiniload.Position2Load() as ATCCaseLoad;

                    //Check that the load in Pos 1 matches one of the messages, what is the index??
                    if ((LoadPos1 != null && LoadPos2 != null) && LoadPos1.TUIdent == telegramFields.GetFieldValue(TelegramFields.tuIdents, "[0]") && LoadPos2.TUIdent == telegramFields.GetFieldValue(TelegramFields.tuIdents, "[1]"))
                    {
                        //Now we know what data to put onto what load
                        controller.UpDateLoadParameters(telegramFields, LoadPos1, "[0]");
                        controller.UpDateLoadParameters(telegramFields, LoadPos2, "[1]");
                    }
                    else if ((LoadPos1 != null && LoadPos2 != null) && LoadPos1.TUIdent == telegramFields.GetFieldValue(TelegramFields.tuIdents, "[1]") && LoadPos2.TUIdent == telegramFields.GetFieldValue(TelegramFields.tuIdents, "[0]"))
                    {
                        //Also here we know what data to put on what load
                        controller.UpDateLoadParameters(telegramFields, LoadPos1, "[1]");
                        controller.UpDateLoadParameters(telegramFields, LoadPos2, "[0]");
                    }
                    else
                    {
                        //There is a problem
                        Log.Write(string.Format("Miniload {0}: Loads at pick station and 'MultipleStartTransportTelegram' from ATC do not match, telegram ignored", theMiniload.Name));
                        return;
                    }

                    MiniloadHalfCycle pickFromPS = new MiniloadHalfCycle() //Pick from pick station
                    {
                        Cycle       = MiniloadCycle.PickPS,
                        TuIdentPos1 = LoadPos1.TUIdent,
                        TuIdentPos2 = LoadPos2.TUIdent
                    };
                    newTasks.HalfCycles.Add(pickFromPS);

                    if (newTasks.TaskType == MiniloadTaskType.Storage)
                    {
                        //Create the half cycles first, then decide which one the miniload performs fisrt
                        MiniloadHalfCycle pos1Drop = new MiniloadHalfCycle() //Drop the first load
                        {
                            Cycle       = MiniloadCycle.DropRack,
                            LHD         = 1,
                            Length      = GetXLoc(telegramFields, LoadPos1),
                            Height      = GetYLoc(telegramFields, LoadPos1),
                            Depth       = GetDepth(telegramFields, LoadPos1),
                            RackSide    = GetSide(telegramFields, LoadPos1),
                            TuIdentPos1 = LoadPos1.TUIdent
                        };

                        MiniloadHalfCycle pos2Drop = new MiniloadHalfCycle() //Drop the second load
                        {
                            Cycle       = MiniloadCycle.DropRack,
                            LHD         = 2,
                            Length      = GetXLoc(telegramFields, LoadPos2),
                            Height      = GetYLoc(telegramFields, LoadPos2),
                            Depth       = GetDepth(telegramFields, LoadPos2),
                            RackSide    = GetSide(telegramFields, LoadPos2),
                            TuIdentPos2 = LoadPos2.TUIdent
                        };

                        if (pos1Drop.RackSide == null || pos2Drop.RackSide == null)
                        {
                            Log.Write(string.Format("Miniload {0}: 'MultipleStartTransportTelegram' cannot resolve drop side, telegram ignored", theMiniload.Name));
                            return;
                        }
                        else if (pos1Drop.RackSide == Side.Right && pos2Drop.RackSide == Side.Left)
                        {
                            Log.Write(string.Format("Miniload {0}: 'MulipleStartTransportTelegram' cannot perform drop, left load drop right and right load drop left not possible", theMiniload.Name));
                        }
                        else //We now know which loads are being sent to which side so that we can schedule the miniload accordingly
                        {
                            if ((pos1Drop.RackSide == Side.Left && pos2Drop.RackSide == Side.Left) || (pos1Drop.RackSide == Side.Left && (pos1Drop.Length < pos2Drop.Length))) //Both are going left or pos1 is going left, pos2 is going right and pos1 is the closest to the p/d
                            {
                                newTasks.HalfCycles.Add(pos1Drop);
                                newTasks.HalfCycles.Add(pos2Drop);
                            }
                            else
                            {
                                newTasks.HalfCycles.Add(pos2Drop);
                                newTasks.HalfCycles.Add(pos1Drop);
                            }
                        }
                    }
                    else if (newTasks.TaskType == MiniloadTaskType.Reject)
                    {
                        MiniloadHalfCycle dropToDS = new MiniloadHalfCycle() //Drop to the drop Station
                        {
                            Cycle       = MiniloadCycle.DropDS,
                            TuIdentPos1 = LoadPos1.TUIdent,
                            TuIdentPos2 = LoadPos2.TUIdent
                        };
                        newTasks.HalfCycles.Add(dropToDS);
                    }
                }
                else if (newTasks.TaskType == MiniloadTaskType.Retreival)
                {
                    //Initially i need to know which load i am going to pick first
                    string posASource = telegramFields.GetFieldValue(TelegramFields.sources, "[0]");
                    string posBSource = telegramFields.GetFieldValue(TelegramFields.sources, "[1]");

                    string posATuIdent = telegramFields.GetFieldValue(TelegramFields.tuIdents, "[0]");
                    string posBTuIdent = telegramFields.GetFieldValue(TelegramFields.tuIdents, "[1]");

                    Side? posASide = GetSide(posASource);
                    Side? posBSide = GetSide(posBSource);
                    float posAXLoc = GetXLoc(posASource);
                    float posBXLoc = GetXLoc(posBSource);

                    if (posASide == null || posBSide == null || posATuIdent == null || posBTuIdent == null)
                    {
                        //There is a problem
                        Log.Write(string.Format("Miniload {0}: Error processing drop missions from 'MultipleStartTransportTelegram', telegram ignored", theMiniload.Name));
                        return;
                    }

                    //Create the case data, this will be used by the miniload to create the load (from the controller)
                    ATCCaseData pos1CaseData = controller.CreateATCCaseData(telegramFields, "[0]");
                    ATCCaseData pos2CaseData = controller.CreateATCCaseData(telegramFields, "[1]");

                    int  LHDposA = 0, LHDposB = 0;
                    bool?AthenB = null;
                    if (posASide == Side.Left && posBSide == Side.Left)
                    {
                        if (posAXLoc > posBXLoc)
                        {
                            LHDposA = 2; LHDposB = 1; AthenB = true;
                        }
                        else
                        {
                            LHDposA = 1; LHDposB = 2; AthenB = false;
                        }
                    }
                    else if (posASide == Side.Right && posBSide == Side.Right)
                    {
                        if (posAXLoc > posBXLoc)
                        {
                            LHDposA = 1; LHDposB = 2; AthenB = true;
                        }
                        else
                        {
                            LHDposA = 2; LHDposB = 1; AthenB = false;
                        }
                    }
                    else if (posASide == Side.Left && posBSide == Side.Right)
                    {
                        LHDposA = 1; LHDposB = 2;
                        AthenB  = posAXLoc > posBXLoc ? true : false;
                    }
                    else if (posASide == Side.Right && posBSide == Side.Left)
                    {
                        LHDposA = 2; LHDposB = 1;
                        AthenB  = posAXLoc > posBXLoc ? true : false;
                    }

                    if (LHDposA == 0 || LHDposB == 0 || AthenB == null)
                    {
                        Log.Write(string.Format("Miniload {0}: Error calculating pickup order or LHD assignment", theMiniload.Name), Color.Red);
                        return;
                    }

                    MiniloadHalfCycle posAPick = new MiniloadHalfCycle()
                    {
                        Cycle       = MiniloadCycle.PickRack,
                        LHD         = LHDposA,
                        Length      = GetXLoc(posASource),
                        Height      = GetYLoc(posASource),
                        Depth       = GetDepth(posASource),
                        RackSide    = posASide,
                        TuIdentPos1 = posATuIdent,
                        CaseData    = pos1CaseData
                    };

                    MiniloadHalfCycle posBPick = new MiniloadHalfCycle()
                    {
                        Cycle       = MiniloadCycle.PickRack,
                        LHD         = LHDposB,
                        Length      = GetXLoc(posBSource),
                        Height      = GetYLoc(posBSource),
                        Depth       = GetDepth(posBSource),
                        RackSide    = posBSide,
                        TuIdentPos2 = posBTuIdent,
                        CaseData    = pos2CaseData
                    };

                    if (AthenB == true)
                    {
                        newTasks.HalfCycles.Add(posAPick);
                        newTasks.HalfCycles.Add(posBPick);
                    }
                    else
                    {
                        newTasks.HalfCycles.Add(posBPick);
                        newTasks.HalfCycles.Add(posAPick);
                    }

                    MiniloadHalfCycle dropToDS = new MiniloadHalfCycle() //Drop to the drop Station
                    {
                        Cycle       = MiniloadCycle.DropDS,
                        TuIdentPos1 = posATuIdent,
                        TuIdentPos2 = posBTuIdent
                    };
                    newTasks.HalfCycles.Add(dropToDS);
                }
                else if (newTasks.TaskType == MiniloadTaskType.Relocation)
                {
                    Log.Write(string.Format("Miniload {0}: cannot generate double relocation missions from 'MultipleStartTransportTelegram', telegram ignored", theMiniload.Name), Color.Red);
                    return;
                }
            }
            else if (telegramCount == 1)
            {
                //Not sure if this is needed or not, why send a multiple message with only 1 load in it?
            }

            AddNewTasks(newTasks);
        }