/// <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); } } }
/// <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); } }