Example #1
0
        /// <summary>
        /// This method is called whenever a carrier arrives at the induction.
        /// Override this method to handle this event.
        /// If the method is not overridden it will try to add the load to the sorter and give it a random destination.
        /// </summary>
        /// <param name="carrier">The carrier that has arrived.</param>
        /// <param name="induction">The carrier is just above this sorterfixpoint.</param>
        void Arrived(SorterCarrier carrier, SorterElementFixPoint induction)
        {
            if (induction != null && induction.InductionPoint != null && induction.InductionPoint.Active)
            {
                Load load = induction.InductionPoint.ActiveLoad;
                if (SorterMasterElement.Control.AddLoadToCarrier(load, carrier, induction.InductionPoint))
                {
                    //Get a list of possible destinations
                    //List<SorterElementFixPoint> destinations = SorterMasterElement.Control.FixPointsWithChutePoint;
                    //int max = destinations.Count;
                    //if (max == 0)
                    //{
                    //    Environment.Log.Write("No valid destinations found!", Color.Red);
                    //    Environment.Scene.Pause();
                    //    return;
                    //}
                    //int random = Environment.Random.Next(0, max);
                    //SorterElementFixPoint destination = destinations[random];
                    //load.UserData = "Travelling on " + carrier + ", destination chute: " + destination.Name;

                    //Set the destination
                    List <SorterElementFixPoint> destinations = SorterMasterElement.Control.FixPointsWithChutePoint;
                    ATCCaseLoad           atcLoad             = load as ATCCaseLoad;
                    SorterElementFixPoint destination         = destinations.Find(x => x.Name == atcLoad.Destination);

                    if (destination == null) //Set the destination to be the next induct point if the destination has not been sent by MFC
                    {
                        destination = NextInductPoint(induction);
                    }

                    SorterMasterElement.Control.SetLoadDestination(load, destination);
                }
            }
        }
Example #2
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 #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 carrier arrives at the induction.
 /// Override this method to handle this event.
 /// If the method is not overridden it will try to add the load to the sorter and give it a random destination.
 /// </summary>
 /// <param name="carrier">The carrier that has arrived.</param>
 /// <param name="induction">The carrier is just above this sorterfixpoint.</param>
 void Arrived(SorterCarrier carrier, SorterElementFixPoint induction)
 {
     if (induction != null && induction.InductionPoint != null && induction.InductionPoint.Active)
     {
         Load load = induction.InductionPoint.ActiveLoad;
         if (SorterMasterElement.Control.AddLoadToCarrier(load, carrier, induction.InductionPoint))
         {
             //Get a list of possible destinations
             List <SorterElementFixPoint> destinations = SorterMasterElement.Control.FixPointsWithChutePoint;
             int max = destinations.Count;
             if (max == 0)
             {
                 Environment.Log.Write("No valid destinations found!", Color.Red);
                 Environment.Scene.Pause();
                 return;
             }
             int random = Environment.Random.Next(0, max);
             SorterElementFixPoint destination = destinations[random];
             load.UserData = "Travelling on " + carrier + ", destination chute: " + destination.Name;
             //Set the destination
             SorterMasterElement.Control.SetLoadDestination(load, destination);
         }
     }
 }
Example #6
0
        private void StartInducting(SorterCarrier carrier, SorterElementFixPoint induction, Load load, float inductiontime, float distancetosorter)
        {
            Vector3 direction = Trigonometry.DirectionYaw(Trigonometry.Yaw(load.Route.Orientation));

            load.Translate(() => Arrived(carrier, induction), direction * distancetosorter, inductiontime);
        }