Example #1
0
 /// <summary>
 /// This method is called whenever a load arrives at its destination sorterfixpoint (The load is on the carrier on top of the sorterfixpoint).
 /// </summary>
 /// <param name="master"></param>
 /// <param name="carrier">The carrier that arrives with the load</param>
 /// <param name="destination">The destination sorter fix point.</param>
 /// <param name="load">The load that has arrived.</param>
 /// <param name="discharged">If true then the load has been added to the chute</param>
 void Control_Load_Arrived_At_Destination(SorterMasterControl master, SorterCarrier carrier, SorterElementFixPoint destination, Load load, bool discharged)
 {
     if (discharged)
     {
         //Load was successfully discarged to the chute
         foreach (var c in loadToCarriers[load])
         {
             //Free other carriers
             SorterMasterElement.Control.DeleteReservation(c);
             c.Color = Color.Empty;
         }
         loadToCarriers.Remove(load);
     }
     else
     {
         //Failed to discharge. 50/50 Take a round and try again or go to dump chute
         var dumpchute = master.FixPoints.FirstOrDefault(c => c.DumpChute);
         if (Environment.Random.Next(0, 2) == 0 && dumpchute != null)
         {
             carrier.Color = Color.Red;
             master.SetLoadDestination(load, dumpchute);
         }
         else
         {
             carrier.Color = Color.Orange;
             master.SetLoadDestination(load, destination);
         }
     }
 }
Example #2
0
        /// <summary>
        /// This method is called whenever a load arrives at the actionpoint induction.InductionPoint.
        /// </summary>
        /// <param name="master"></param>
        /// <param name="induction">The sorterfixpoint with the reference to the actionpoint where the load is (induction.InductionPoint).</param>
        /// <param name="load">The load that has arrived</param>
        void Control_Load_Arrived_At_Induction(SorterMasterControl master, SorterElementFixPoint induction, Load load)
        {
            load.Stop();

            //Minimum distance before induction point to look for free carriers
            var distance          = SorterMasterElement.Control.Speed * inductionTime;
            var carriersToReserve = (uint)Environment.Random.Next(1, 3);//Change this to be dependent on size
            var carriers          = SorterMasterElement.Control.FirstFreeCarriers(distance, induction, carriersToReserve);

            if (!carriers.Any())
            {
                Environment.Log.Write(Name + ": Induction " + induction.Name + " no free carrier found!", Color.Red);
                Environment.Scene.Pause();
                return;
            }

            //Remember carriers assigned to this load.
            loadToCarriers[load] = carriers;

            //Reserve all carriers
            foreach (var sorterCarrier in  carriers)
            {
                sorterCarrier.Color = Color.Yellow;  //Just for visualization
                SorterMasterElement.Control.ReserveCarrier(sorterCarrier, induction.InductionPoint);
            }

            var carrier = carriers.First();

            //Notify about arrival "inductionTime" seconds before arrival
            SorterMasterElement.Control.NotifyArrival(carrier, induction, inductionTime);
        }
Example #3
0
        void Control_Carrier_Arrived_At_Induction(SorterMasterControl master, SorterCarrier carrier, SorterElementFixPoint induction)
        {
            //Carrier is now "inductionTime" seconds before induct point. Start releasing the load
            float distancetosorter = Math.Abs(induction.LocalOffset.Z) / (float)Math.Sin(Trigonometry.Angle2Rad(induction.LocalYaw));

            distancetosorter += (induction.InductionPoint.ActiveLoad.Route.Length - induction.InductionPoint.ActiveLoad.Distance);
            StartInducting(carrier, induction, induction.InductionPoint.ActiveLoad, inductionTime, distancetosorter);
        }
Example #4
0
        /// <summary>
        /// This method is called whenever a load arrives at its destination sorterfixpoint (The load is on the carrier on top of the sorterfixpoint).
        /// </summary>
        /// <param name="master"></param>
        /// <param name="carrier">The carrier that arrives with the load</param>
        /// <param name="destination">The destination sorter fix point.</param>
        /// <param name="load">The load that has arrived.</param>
        /// <param name="discharged">If true then the load has been added to the chute</param>
        void Control_Load_Arrived_At_Destination(SorterMasterControl master, SorterCarrier carrier, SorterElementFixPoint destination, Load load, bool discharged)
        {
            if (discharged)
            {
                //Load was successfully discarged to the chute
                foreach (var c in loadToCarriers[load])
                {
                    //Free other carriers
                    SorterMasterElement.Control.DeleteReservation(c);
                    c.Color = Color.Empty;
                }
                loadToCarriers.Remove(load);

                string sendTelegram = mheController_Sorter.CreateTelegramFromLoad(TelegramTypes.SorterTransportFinishedTelegram, (ATCCaseLoad)load);
                sendTelegram = sendTelegram.SetFieldValue(TelegramFields.mts, mheController_Sorter.Name);
                mheController_Sorter.SendTelegram(sendTelegram, ConnectionChannel.Main, true);
            }
            else if (destination.ChutePoint != null)
            {
                //BG Note - This was nonsense... the load should always do a lap
                //Failed to discharge. 50/50 Take a round and try again or go to dump chute
                //var dumpchute = master.FixPoints.FirstOrDefault(c => c.DumpChute);
                //if (Environment.Random.Next(0, 2) == 0 && dumpchute != null)
                //{
                //    carrier.Color = Color.Red;
                //    master.SetLoadDestination(load, dumpchute);
                //}
                //else
                //{
                //    carrier.Color = Color.Orange;
                //    master.SetLoadDestination(load, destination);
                //}

                //Send an exception that the load cannot discharge
                string sendTelegram = mheController_Sorter.CreateTelegramFromLoad(TelegramTypes.SorterTransportFinishedTelegram, (ATCCaseLoad)load);
                sendTelegram = sendTelegram.SetFieldValue(TelegramFields.mts, mheController_Sorter.Name);
                sendTelegram = sendTelegram.SetFieldValue(TelegramFields.stateCode, "DN");
                mheController_Sorter.SendTelegram(sendTelegram, ConnectionChannel.Main, true);

                carrier.Color = Color.Orange;
                master.SetLoadDestination(load, destination);
            }
            else //The load has been sent to the next induction point and needs to send a new transport request
            {
                SorterMasterElement.Control.SetLoadDestination(load, NextInductPoint(destination));

                string sendTelegram = mheController_Sorter.CreateTelegramFromLoad(TelegramTypes.TransportRequestTelegram, (ATCCaseLoad)load);
                sendTelegram = sendTelegram.SetFieldValue(TelegramFields.location, destination.Name);
                sendTelegram = sendTelegram.InsertField("CarrierID", string.Format("STCR{0}{1}", SorterID, carrier.Index.ToString().PadLeft(4, '0')));
                sendTelegram = sendTelegram.SetFieldValue(TelegramFields.mts, mheController_Sorter.NameDespatch);

                mheController_Sorter.SendTelegram(sendTelegram, ConnectionChannel.Despatch, true);
            }
        }
Example #5
0
        /// <summary>
        /// This method is called whenever a load arrives at the actionpoint induction.InductionPoint.
        /// </summary>
        /// <param name="master"></param>
        /// <param name="induction">The sorterfixpoint with the reference to the actionpoint where the load is (induction.InductionPoint).</param>
        /// <param name="load">The load that has arrived</param>
        void Control_Load_Arrived_At_Induction(SorterMasterControl master, SorterElementFixPoint induction, Load load)
        {
            load.Stop();

            //Minimum distance before induction point to look for free carriers
            var distance          = SorterMasterElement.Control.Speed * inductionTime;
            var carriersToReserve = (uint)Environment.Random.Next(1, 3);//Change this to be dependent on size
            var carriers          = SorterMasterElement.Control.FirstFreeCarriers(distance, induction, carriersToReserve);

            if (!carriers.Any())
            {
                //Environment.Log.Write(Name + ": Induction " + induction.Name + " no free carrier found!", Color.Red);
                Environment.Log.Write("Name here TODO" + ": Induction " + induction.Name + " no free carrier found!", Color.Red);

                Environment.Scene.Pause();
                return;
            }

            //Remember carriers assigned to this load.
            loadToCarriers[load] = carriers;

            //Reserve all carriers
            foreach (var sorterCarrier in carriers)
            {
                sorterCarrier.Color = Color.Yellow;  //Just for visualization
                SorterMasterElement.Control.ReserveCarrier(sorterCarrier, induction.InductionPoint);
            }

            var    carrier      = carriers.First();
            string sendTelegram = mheController_Sorter.CreateTelegramFromLoad(TelegramTypes.TransportRequestTelegram, (ATCCaseLoad)load);

            sendTelegram = sendTelegram.SetFieldValue(TelegramFields.location, load.CurrentActionPoint.ParentAssembly);
            SorterInduction inductStation = (SorterInduction)Assembly.Get(load.CurrentActionPoint.ParentAssembly);

            inductStation.CurrentLoad = load;
            sendTelegram = sendTelegram.InsertField("CarrierID", string.Format("STCR{0}{1}", SorterID, carrier.Index.ToString().PadLeft(4, '0')));
            sendTelegram = sendTelegram.SetFieldValue(TelegramFields.mts, mheController_Sorter.NameDespatch);

            mheController_Sorter.SendTelegram(sendTelegram, ConnectionChannel.Despatch, true);

            //Notify about arrival "inductionTime" seconds before arrival
            SorterMasterElement.Control.NotifyArrival(carrier, induction, inductionTime);
        }