Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private void StartTransportTelegramReceived(string[] telegramFields)
        {
            SorterInduction si = (SorterInduction)Assembly.Get(telegramFields.GetFieldValue(TelegramFields.source));

            ((ATCCaseLoad)si.CurrentLoad).Destination = telegramFields.GetFieldValue(TelegramFields.destination);
        }