/// <summary> /// Create transport telegrams only from load, do not use for any other type of telegram /// </summary> /// <param name="telegramType"></param> /// <param name="load"></param> /// <returns></returns> public string CreateTelegramFromLoad(TelegramTypes telegramType, Case_Load load) { string telegram = Template.CreateTelegram(this, telegramType); DCICaseData caseData = load.Case_Data as DCICaseData; //Populate the correct field values telegram = telegram.SetFieldValue(this, TelegramFields.Source, caseData.Source); telegram = telegram.SetFieldValue(this, TelegramFields.Current, caseData.Current); telegram = telegram.SetFieldValue(this, TelegramFields.Destination, caseData.Destination); telegram = telegram.SetFieldValue(this, TelegramFields.TUIdent, load.Identification); telegram = telegram.SetFieldValue(this, TelegramFields.TUType, caseData.TUType); telegram = telegram.SetFieldValue(this, TelegramFields.TULength, (caseData.Length * 1000).ToString("0000")); telegram = telegram.SetFieldValue(this, TelegramFields.TUWidth, (caseData.Width * 1000).ToString("0000")); telegram = telegram.SetFieldValue(this, TelegramFields.TUHeight, (caseData.Height * 1000).ToString("0000")); telegram = telegram.SetFieldValue(this, TelegramFields.TUWeight, (caseData.Weight * 1000).ToString("000000")); telegram = telegram.SetFieldValue(this, TelegramFields.EventCode, caseData.EventCode); telegram = telegram.SetFieldValue(this, TelegramFields.DropIndex, caseData.DropIndex.ToString()); telegram = telegram.SetFieldValue(this, TelegramFields.ShuttleDynamics, caseData.ShuttleDynamics); telegram = telegram.SetFieldValue(this, TelegramFields.LiftDynamics, caseData.LiftDynamics); telegram = telegram.SetFieldValue(this, TelegramFields.SourceShuttleExtension, caseData.SourceShuttleExtension); telegram = telegram.SetFieldValue(this, TelegramFields.DestinationShuttleExtension, caseData.DestinationShuttleExtension); if (DCIVersion == DCIVersions._1_60) { telegram = telegram.SetFieldValue(this, TelegramFields.CaseConveyorDynamics, caseData.CaseConveyorDynamics); } return(telegram); }
public override void HandleTelegrams(string[] telegramFields, TelegramTypes type) { if (controls.Count != 1) { Log.Write(string.Format("Controller {0} has no 'MHE_Control' or Too many 'MHE_Controls' have been created, cannot process the telegram, restart the model to resolve the issue", Name)); return; } var control = controls[0] as MHEControl_PalletCrane; switch (type) { case TelegramTypes.StartTransportTelegram: control.StartTransportTelegramReceived(telegramFields); break; //case TelegramTypes.StartMultipleTransportTelegram: // control.StartMultipleTransportTelegramReceived(telegramFields); // break; case TelegramTypes.RequestStateTelegram: control.RequestStateTelegramReceived(telegramFields); break; default: break; } }
public static event OverrideTelegramReceived OnOverrideTelegramReceived; //Return true if the message was handled elsewhere (Routing Script) public virtual void Connection_OnTelegramReceived(Core.Communication.TCPIP.Connection sender, string telegram) { if (InvokeRequired) { Core.Environment.Invoke(() => Connection_OnTelegramReceived(sender, telegram)); return; } try { if (telegram.GetFieldValue(this, TelegramFields.Flow) == "A") { int result = 0; if (int.TryParse(telegram.GetFieldValue(this, TelegramFields.CycleNo), out result) && result == lastAckCycle) //This will ignore ack if its in the wrong sequence { if (LogAll) { LogTelegrams(string.Format("{0} {1}>{2}: {3}", DateTime.Now.ToString(), ReceiverID, SenderID, telegram), Color.Black); } waitingForAck = false; ackResendCount = 0; ackTimer.Stop(); SendBuffer(); } return; } LogTelegrams(string.Format("{0} {1}>{2}: {3}", DateTime.Now.ToString(), ReceiverID, SenderID, telegram), Color.Black); //Check if this is an ack telegram TelegramTypes type = telegram.GetTelegramType(this); if (telegram.GetFieldValue(this, TelegramFields.Flow) == "R") { string ackTelegram = string.Format("/,A,{0},{1},{2},{3},{4},{5},{6},0030,##", telegram.GetFieldValue(this, TelegramFields.Type), VFCIdentifier, PLCIdentifier, telegram.GetFieldValue(this, TelegramFields.CycleNo), telegram.GetFieldValue(this, TelegramFields.Code), telegram.GetFieldValue(this, TelegramFields.BlocksCount), telegram.GetFieldValue(this, TelegramFields.BlocksType)); SendAckOnly(ackTelegram); } if (OnOverrideTelegramReceived == null || !OnOverrideTelegramReceived(this, telegram)) { HandleTelegrams(telegram, telegram.GetTelegramType(this)); } } catch (Exception se) { Experior.Core.Environment.Log.Write("Exception recieving telegram: "); Experior.Core.Environment.Log.Write(se); } }
public ATCTray CreateCaseTray(TelegramTypes Type, string[] Telegram) { ATCTray newLoad = null; if (Type == TelegramTypes.CreateTuTelegram) { string length = Telegram.GetFieldValue(TelegramFields.length); string width = Telegram.GetFieldValue(TelegramFields.width); string height = Telegram.GetFieldValue(TelegramFields.height); string weight = Telegram.GetFieldValue(TelegramFields.weight); string color = Telegram.GetFieldValue(TelegramFields.color); length = (length == null) ? CaseLoadLength : length; width = (width == null) ? CaseLoadWidth : width; height = (height == null) ? CaseLoadHeight : height; weight = (weight == null) ? CaseLoadWeight : weight; color = (Color == null) ? DefaultLoadColor.ToString() : color; newLoad = CreateTray( Telegram.GetFieldValue(TelegramFields.mts), Telegram.GetFieldValue(TelegramFields.tuIdent), Telegram.GetFieldValue(TelegramFields.tuType), Telegram.GetFieldValue(TelegramFields.location), //Location Telegram.GetFieldValue(TelegramFields.destination), Telegram.GetFieldValue(TelegramFields.presetStateCode), 0.2f, 0.4f, 0.6f, 100, color, TrayStatus.Loaded, 5); } //Deal with additional project specific fields if (newLoad != null) { foreach (string field in ProjectFields) { string fieldValue = Telegram.GetFieldValue(field); if (fieldValue != null) { if (newLoad.ProjectFields.ContainsKey(field)) { newLoad.ProjectFields[field] = fieldValue; } else { newLoad.ProjectFields.Add(field, fieldValue); } } } } return(newLoad); }
public string CreateTelegramFromLoad(TelegramTypes telegramType, IATCLoadType load) { List <TelegramFields> fieldList = Telegrams.TelegramSignatures[telegramType]; string telegram = string.Empty.InsertType(telegramType); foreach (TelegramFields tf in fieldList) { telegram = telegram.AppendField(tf, load.GetPropertyValueFromEnum(tf)); } if (fieldList.Contains(TelegramFields.mts)) { telegram = telegram.SetFieldValue(TelegramFields.mts, this.Name); } if (fieldList.Contains(TelegramFields.stateCode)) { telegram = telegram.SetFieldValue(TelegramFields.stateCode, load.PresetStateCode); } //If the PLC has further additional telegram fields but they are not on the load yet they need to be added if (ProjectFields.Count > 0) { Dictionary <string, string> loadProjectFields = new Dictionary <string, string>(); foreach (string field in ProjectFields) { if (load.ProjectFields.Keys.Contains(field)) { //Field already exists copy into new version loadProjectFields.Add(field, load.ProjectFields[field]); } else { loadProjectFields.Add(field, ""); } } if (loadProjectFields.Count > 0) { load.ProjectFields = loadProjectFields; } } foreach (string field in load.ProjectFields.Keys) { if (telegram.Contains(string.Format(",{0}='", field))) { telegram = telegram.SetFieldValue(field, load.ProjectFields[field]); } else { telegram = telegram.AppendField(field, load.ProjectFields[field]); } } return(telegram + "#"); }
public virtual Case_Load CreateCaseLoad(TelegramTypes Type, string Telegram, int blockPosition = 0) { Case_Load newLoad = null; string length = Telegram.GetFieldValue(this, TelegramFields.TULength, blockPosition); string width = Telegram.GetFieldValue(this, TelegramFields.TUWidth); string height = Telegram.GetFieldValue(this, TelegramFields.TUHeight); string weight = Telegram.GetFieldValue(this, TelegramFields.TUWeight); //IEmulationController emulation = Core.Assemblies.Assembly.Items.Values.ToList().FirstOrDefault(x => x is IEmulationController) as IEmulationController; newLoad.Case_Data = CreateDCICaseData(Telegram, blockPosition); return(newLoad); }
public override void HandleTelegrams(string[] telegramFields, TelegramTypes type) { switch (type) { case TelegramTypes.StartTransportTelegram: StartTransportTelegramReceived(telegramFields); break; case TelegramTypes.SorterTransportMissionTelegram: SorterTransportMissionTelegramReceived(telegramFields); break; default: break; } }
public override void HandleTelegrams(string[] telegramFields, TelegramTypes type) { switch (type) { case TelegramTypes.CreateTuTelegram: CreateTuTelegramReceived(telegramFields); break; case TelegramTypes.DeleteTuTelegram: DeleteTuTelegramReceived(telegramFields); break; default: break; } }
public override void HandleTelegrams(string telegram, TelegramTypes type) { if (type == TelegramTypes.StatusRequest) { StatusRequest(telegram); } else if (type == TelegramTypes.TUMission) { if (telegram.GetNumberOfBlocks(this) > 1) { TUMissionMultiBlock(telegram); } else { TUMissionSingleBlock(telegram); } } }
public int GetTelegramLength(TelegramTypes telegramType) //[BG] I hate this!! { //Make some code that hard codes the lengths of telegrams switch (telegramType) { case TelegramTypes.TUCancel: case TelegramTypes.TUDataRequest: case TelegramTypes.TUException: case TelegramTypes.TULocationLeft: case TelegramTypes.TUMission: case TelegramTypes.TUMissionCancel: case TelegramTypes.TUNotification: case TelegramTypes.TUReport: return(144); case TelegramTypes.StatusRequest: case TelegramTypes.SetDateTime: case TelegramTypes.LocationRequest: case TelegramTypes.StartMaterialFlow: //case TelegramTypes.StopMaterialFlow: case TelegramTypes.FaultTextReq: return(44); case TelegramTypes.Status: //case TelegramTypes.StatusMaterialFlow: case TelegramTypes.SetDevice: return(46); case TelegramTypes.StatusEnd: case TelegramTypes.Live: return(30); case TelegramTypes.MoveMission: //case TelegramTypes.MoveReport: return(60); case TelegramTypes.ExStatus: return(110); case TelegramTypes.FaultTextDef: return(236); } return(0); }
/// <summary> /// Create the EuroPallet load from a message from ATC /// </summary> public virtual ATCEuroPallet CreateEuroPallet(TelegramTypes Type, string[] Telegram) { ATCEuroPallet newLoad = null; float length; bool lengthIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.length), out length); float width; bool widthIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.width), out width); float height; bool heightIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.height), out height); float weight; bool weightIsFloat = float.TryParse(Telegram.GetFieldValue(TelegramFields.weight), out weight); string color = Telegram.GetFieldValue(TelegramFields.color); PalletStatus palletStatus = PalletStatus.Loaded; EmulationATC emulation = Core.Assemblies.Assembly.Items.Values.ToList().FirstOrDefault(x => x is EmulationATC) as EmulationATC; if (emulation != null) { length = (!lengthIsFloat || length == 0f) ? emulation.PalletLoadLength : length / 1000; width = (!widthIsFloat || width == 0f) ? emulation.PalletLoadWidth : width / 1000; height = (!heightIsFloat || height == 0f) ? emulation.PalletLoadHeight : height / 1000; weight = (!weightIsFloat || weight == 0f) ? emulation.PalletLoadWeight : weight; } if (Type == TelegramTypes.StartTransportTelegram) { newLoad = CreateEuroPallet( Telegram.GetFieldValue(TelegramFields.mts), Telegram.GetFieldValue(TelegramFields.tuIdent), Telegram.GetFieldValue(TelegramFields.tuType), Telegram.GetFieldValue(TelegramFields.source), //Source Telegram.GetFieldValue(TelegramFields.destination), Telegram.GetFieldValue(TelegramFields.presetStateCode), height, width, length, weight, LoadColor(Telegram.GetFieldValue(TelegramFields.color)), palletStatus); } else if (Type == TelegramTypes.CreateTuTelegram) { newLoad = CreateEuroPallet( Telegram.GetFieldValue(TelegramFields.mts), Telegram.GetFieldValue(TelegramFields.tuIdent), Telegram.GetFieldValue(TelegramFields.tuType), Telegram.GetFieldValue(TelegramFields.location), //Location Telegram.GetFieldValue(TelegramFields.destination), Telegram.GetFieldValue(TelegramFields.presetStateCode), height, width, length, weight, LoadColor(Telegram.GetFieldValue(TelegramFields.color)), palletStatus); } if (newLoad != null) { //Add project fields to load foreach (string field in ProjectFields) { string fieldValue = Telegram.GetFieldValue(field); if (fieldValue != null) { // Update if field already exists | Insert New if (newLoad.ProjectFields.ContainsKey(field)) { newLoad.ProjectFields[field] = fieldValue; } else { newLoad.ProjectFields.Add(field, fieldValue); } } } return(newLoad); } return(null); }
/// <summary> /// Create the case load from a message from ATC /// </summary> public virtual ATCCaseLoad CreateCaseLoad(TelegramTypes Type, string[] Telegram) { ATCCaseLoad newLoad = null; string length = Telegram.GetFieldValue(TelegramFields.length); string width = Telegram.GetFieldValue(TelegramFields.width); string height = Telegram.GetFieldValue(TelegramFields.height); string weight = Telegram.GetFieldValue(TelegramFields.weight); string color = Telegram.GetFieldValue(TelegramFields.color); EmulationATC emulation = Core.Assemblies.Assembly.Items.Values.ToList().FirstOrDefault(x => x is EmulationATC) as EmulationATC; if (emulation != null) { length = (length == null || length == "0") ? emulation.CaseLoadLength : length; width = (width == null || width == "0") ? emulation.CaseLoadWidth : width; height = (height == null || height == "0") ? emulation.CaseLoadHeight : height; weight = (weight == null || weight == "0") ? emulation.CaseLoadWeight : weight; } if (Type == TelegramTypes.StartTransportTelegram) { newLoad = CreateCaseLoad( Telegram.GetFieldValue(TelegramFields.mts), Telegram.GetFieldValue(TelegramFields.tuIdent), Telegram.GetFieldValue(TelegramFields.tuType), Telegram.GetFieldValue(TelegramFields.source), //Source Telegram.GetFieldValue(TelegramFields.destination), Telegram.GetFieldValue(TelegramFields.presetStateCode), height, width, length, weight, Telegram.GetFieldValue(TelegramFields.color)); } else if (Type == TelegramTypes.CreateTuTelegram) { newLoad = CreateCaseLoad( Telegram.GetFieldValue(TelegramFields.mts), Telegram.GetFieldValue(TelegramFields.tuIdent), Telegram.GetFieldValue(TelegramFields.tuType), Telegram.GetFieldValue(TelegramFields.location), //Location Telegram.GetFieldValue(TelegramFields.destination), Telegram.GetFieldValue(TelegramFields.presetStateCode), height, width, length, weight, Telegram.GetFieldValue(TelegramFields.color)); } if (newLoad != null) { //Add project fields to load foreach (string field in ProjectFields) { string fieldValue = Telegram.GetFieldValue(field); if (fieldValue != null) { // Update if field already exists | Insert New if (newLoad.ProjectFields.ContainsKey(field)) { newLoad.ProjectFields[field] = fieldValue; } else { newLoad.ProjectFields.Add(field, fieldValue); } } } return(newLoad); } return(null); }
/// <summary> /// The actual controller will handle the telegrams, this method is called when a telegram has been received /// </summary> public abstract void HandleTelegrams(string[] telegramFields, TelegramTypes type);
/// <summary> /// The actual controller will handle the telegrams, this method is called when a telegram has been received /// </summary> public abstract void HandleTelegrams(string telegram, TelegramTypes type);
private void TUMissionMultiBlock(string telegram) { string currentLoc = string.Empty; DematicActionPoint locA = null, locB = null; MultiShuttle ms = null; TelegramTypes type = telegram.GetTelegramType(this); //List<string> indexTags; //List<string> messageBodies = Telegrams.DeMultaplise(telegram, telegram.GetTelegramType(), out indexTags); //string[] messageBodySplit = messageBodies.First().Split(',');//don't care which message is used as both on the same conveyor string current = telegram.GetFieldValue(this, TelegramFields.Current); string destLoc0 = telegram.GetFieldValue(this, TelegramFields.Destination, 0); string destLoc1 = telegram.GetFieldValue(this, TelegramFields.Destination, 1); string tuIdent0 = telegram.GetFieldValue(this, TelegramFields.TUIdent, 0); string tuIdent1 = telegram.GetFieldValue(this, TelegramFields.TUIdent, 1); string aisle = GetPSDSLocFields(current, PSDSRackLocFields.Aisle); string side = GetPSDSLocFields(current, PSDSRackLocFields.Side); string destA = null, destB = null; // takes the form aasyyxz: aa=aisle, s = side, yy = level, x = conv type see enum ConveyorTypes , Z = loc A or B e.g. 01R05OA string loc = string.Format("{0}{1}{2}P", aisle, side, GetPSDSLocFields(current, PSDSRackLocFields.Level)); ms = GetMultishuttleFromAisleNum(loc + "A"); locA = ms.ConveyorLocations.Find(x => x.LocName == loc + "A"); locB = ms.ConveyorLocations.Find(x => x.LocName == loc + "B"); if ((locA != null && locA.Active) && (locB != null && locB.Active)) { string messageA = telegram.Split(',').ToList().Find(x => x.Contains(locA.ActiveLoad.Identification)); string messageB = telegram.Split(',').ToList().Find(x => x.Contains(locB.ActiveLoad.Identification)); if (destLoc0 == null || destLoc1 == null) { Log.Write(string.Format("{0}: Invalid destinations sent in TUMission - Logically Grouped", Name), Color.Red); return; } if (telegram.GetFieldValue(this, TelegramFields.Destination, 0).LocationType() == LocationTypes.DropStation) //Assume that both going to DS { destA = string.Format("{0}{1}{2}{3}A", aisle, side, GetPSDSLocFields(destLoc0, PSDSRackLocFields.Level), GetPSDSLocFields(destLoc0, PSDSRackLocFields.ConvType)); destB = destA; } else if (telegram.GetFieldValue(this, TelegramFields.Destination).LocationType() == LocationTypes.RackConvIn) { //need to calculate which way around the loads are on the PS and ensure that the elevator task is correct if (locA.ActiveLoad.Identification == tuIdent0) { destA = string.Format("{0}{1}{2}{3}B", aisle, side, GetLocFields(destLoc0, PSDSRackLocFields.Level), GetLocFields(destLoc0, PSDSRackLocFields.ConvType)); } else if (locA.ActiveLoad.Identification == tuIdent1) { destA = string.Format("{0}{1}{2}{3}B", aisle, side, GetLocFields(destLoc1, PSDSRackLocFields.Level), GetLocFields(destLoc1, PSDSRackLocFields.ConvType)); } else { Log.Write(string.Format("Error {0}: The tuIdent at the PS does not match the tuIdent in the TU Mission - Logically Grouped (Position A"), Color.Orange); return; } if (locB.ActiveLoad.Identification == tuIdent0) { destB = string.Format("{0}{1}{2}{3}B", aisle, side, GetLocFields(destLoc0, PSDSRackLocFields.Level), GetLocFields(destLoc0, PSDSRackLocFields.ConvType)); } else if (locB.ActiveLoad.Identification == tuIdent1) { destB = string.Format("{0}{1}{2}{3}B", aisle, side, GetLocFields(destLoc1, PSDSRackLocFields.Level), GetLocFields(destLoc1, PSDSRackLocFields.ConvType)); } else { Log.Write(string.Format("Error {0}: The tuIdent at the PS does not match the tuIdent in the TU Mission - Logically Grouped (Position A"), Color.Orange); return; } } else { destA = GetRackDestinationFromDCIBinLocation(telegram, 0); destB = GetRackDestinationFromDCIBinLocation(telegram, 1); } if (messageA != null && messageB != null) { ElevatorTask et = new ElevatorTask(locA.ActiveLoad.Identification, locB.ActiveLoad.Identification) { LoadCycle = Cycle.Double, Flow = TaskType.Infeed, SourceLoadA = locA.LocName, SourceLoadB = locB.LocName, DestinationLoadA = destA, DestinationLoadB = destB, UnloadCycle = Cycle.Single }; if (et.DestinationLoadA == et.DestinationLoadB) { et.UnloadCycle = Cycle.Double; } UpDateLoadParameters(telegram, (Case_Load)locA.ActiveLoad, 1); UpDateLoadParameters(telegram, (Case_Load)locB.ActiveLoad, 0); ms.elevators.First(x => x.ElevatorName == side + aisle).ElevatorTasks.Add(et); //ms.elevators[side+aisle].ElevatorTasks.Add(et); } else { Log.Write("ERROR: Load ids from telegram do not match active load ids in TU Mission - Logically Grouped", Color.Red); return; } } else { Log.Write("ERROR: Can't find locations or can't find loads on the locations named in TU Mission - Logically Grouped", Color.Red); } }