示例#1
0
        private void SorterTransportMissionTelegramReceived(string[] telegramFields)
        {
            string      tuIdent  = telegramFields.GetFieldValue(TelegramFields.tuIdent);
            ATCCaseLoad caseLoad = ATCCaseLoad.GetCaseFromIdentification(tuIdent) as ATCCaseLoad;

            if (caseLoad != null)
            {
                //Add the sorter load data to the project fields
                AddorAppendField(caseLoad, TelegramFields.plcTrackingId.ToString(), telegramFields.GetFieldValue(TelegramFields.plcTrackingId));
                AddorAppendField(caseLoad, TelegramFields.carrierId.ToString(), telegramFields.GetFieldValue(TelegramFields.carrierId));
                AddorAppendField(caseLoad, TelegramFields.loadingType.ToString(), telegramFields.GetFieldValue(TelegramFields.loadingType));
                AddorAppendField(caseLoad, TelegramFields.dischargeCode.ToString(), telegramFields.GetFieldValue(TelegramFields.dischargeCode));
                AddorAppendField(caseLoad, TelegramFields.transportUnitDataStatus.ToString(), telegramFields.GetFieldValue(TelegramFields.transportUnitDataStatus));
                AddorAppendField(caseLoad, TelegramFields.recirculationReason.ToString(), telegramFields.GetFieldValue(TelegramFields.recirculationReason));
                AddorAppendField(caseLoad, TelegramFields.recircCounter.ToString(), telegramFields.GetFieldValue(TelegramFields.recircCounter));

                caseLoad.Destination = telegramFields.GetFieldValue(TelegramFields.destination);

                List <SorterElementFixPoint> destinations = sorterElement.Control.FixPointsWithChutePoint;
                SorterElementFixPoint        destination  = destinations.Find(x => x.Name == caseLoad.Destination);
                if (destination != null)
                {
                    sorterElement.Control.SetLoadDestination(caseLoad, destination);
                }
            }
            else
            {
                Log.Write(string.Format("{0} Error SorterTransportMissionTelegram; Cannot find Load from TUIdent {1}", Name, tuIdent), Color.Orange);
            }
        }
示例#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);
        }
示例#3
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);
                }
            }
        }
示例#4
0
 private void EndFixPoint_UnSnapped(FixPoint fixpoint)
 {
     if (sorterElementFixPoint != null)
     {
         sorterElementFixPoint.InductionPoint = null;
         sorterElementFixPoint = null;
     }
 }
示例#5
0
 private void StartFixPoint_UnSnapped(FixPoint fixpoint)
 {
     if (sorterElementFixPoint != null)
     {
         sorterElementFixPoint.ChutePoint = null;
         sorterElementFixPoint            = null;
     }
 }
示例#6
0
        private void EndFixPoint_Snapped(FixPoint fixpoint, FixPoint.SnapEventArgs e)
        {
            if (fixpoint.UserData is SorterElementFixPoint)
            {
                sorterElementFixPoint = (SorterElementFixPoint)fixpoint.UserData;
                sorterElementFixPoint.InductionPoint = inductionPoint;
                return;
            }

            e.Cancel = true;
        }
示例#7
0
 public override void Dispose()
 {
     EndFixPoint.OnSnapped   -= EndFixPoint_Snapped;
     EndFixPoint.OnUnSnapped -= EndFixPoint_UnSnapped;
     StartFixPoint.OnSnapped -= StartFixPoint_Snapped;
     if (sorterElementFixPoint != null)
     {
         sorterElementFixPoint.InductionPoint = null;
         sorterElementFixPoint = null;
     }
     base.Dispose();
 }
示例#8
0
        private void StartFixPoint_Snapped(FixPoint fixpoint, FixPoint.SnapEventArgs e)
        {
            if (sorterElementFixPoint != null)
            {
                sorterElementFixPoint.ChutePoint = null;
                sorterElementFixPoint            = null;
            }

            if (fixpoint.UserData is SorterElementFixPoint)
            {
                sorterElementFixPoint            = (SorterElementFixPoint)fixpoint.UserData;
                sorterElementFixPoint.ChutePoint = chutePoint;
                return;
            }

            e.Cancel = true;
        }
示例#9
0
 /// <summary>
 /// Finds the next induction point from the current induction point (even if there is only 1)
 /// </summary>
 /// <param name="induction">The current incucion point</param>
 /// <returns></returns>
 SorterElementFixPoint NextInductPoint(SorterElementFixPoint induction)
 {
     for (int i = 0; i < SorterMasterElement.Control.FixPointsWithInductionPoint.Count; i++)
     {
         if (SorterMasterElement.Control.FixPointsWithInductionPoint[i] == induction)
         {
             if (i == SorterMasterElement.Control.FixPointsWithInductionPoint.Count - 1)
             {
                 return(SorterMasterElement.Control.FixPointsWithInductionPoint[0]);
             }
             else
             {
                 return(SorterMasterElement.Control.FixPointsWithInductionPoint[i + 1]);
             }
         }
     }
     return(null);
 }
示例#10
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);
        }
示例#11
0
        public override void Dispose()
        {
            if (sorterElementFixPoint != null)
            {
                sorterElementFixPoint.ChutePoint = null;
                sorterElementFixPoint            = null;
            }

            EndFixPoint.OnSnapped     -= EndFixPoint_Snapped;
            StartFixPoint.OnSnapped   -= StartFixPoint_Snapped;
            StartFixPoint.OnUnSnapped -= StartFixPoint_UnSnapped;

            chutePoint.OnEnter -= chutePoint_OnEnter;
            chutePoint.Dispose();

            readyTimer.OnElapsed -= readyTimer_OnElapsed;
            readyTimer.Dispose();

            base.Dispose();
        }
示例#12
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);
         }
     }
 }
示例#13
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);
            }
        }
示例#14
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);
        }
示例#15
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);
        }
示例#16
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);
         }
     }
 }