public void UpDateLoadParameters(string[] telegramFields, IATCLoadType load, string index = "") { load.TUType = telegramFields.GetFieldValue(TelegramFields.tuType, index); load.Source = telegramFields.GetFieldValue(TelegramFields.source, index); load.Destination = telegramFields.GetFieldValue(TelegramFields.destination, index); load.PresetStateCode = telegramFields.GetFieldValue(TelegramFields.presetStateCode, index); Color c = LoadColor(telegramFields.GetFieldValue(TelegramFields.color, index)); if (c != DefaultLoadColour) { if (load is IATCCaseLoadType) { load.Color = c; } else if (load is IATCPalletLoadType) { ATCEuroPallet palletLoad = load as ATCEuroPallet; palletLoad.LoadColor = c; } } float weight; float.TryParse(telegramFields.GetFieldValue(TelegramFields.weight), out weight); load.Weight = weight; }
protected ATCEuroPallet CreateEuroPallet(string mts, string tuIdent, string tuType, string source, string destination, string presetStateCode, float height, float width, float length, float weight, Color color, PalletStatus status) { EuroPalletInfo palletInfo = new EuroPalletInfo(); palletInfo.LoadColor = color;//LoadColor(color); palletInfo.Status = status; palletInfo.filename = Experior.Dematic.Base.EuroPallet.Mesh; palletInfo.color = Color.Peru; //LoadHeight includes the height of the pallet (145mm) palletInfo.LoadHeight = height; palletInfo.LoadWidth = width; palletInfo.LoadLength = length; //TODO: Weight //Set the dimensions of a EuroPallet (This is the standard size) palletInfo.length = 1.2f; palletInfo.width = 0.8f; palletInfo.height = 0.145f; ATCEuroPallet palletLoad = new ATCEuroPallet(palletInfo); palletLoad.TUIdent = tuIdent; palletLoad.TUType = tuType; palletLoad.Source = source; palletLoad.Destination = destination; palletLoad.PresetStateCode = presetStateCode; palletLoad.PalletWeight = weight; //Add project fields to load Load.Items.Add(palletLoad); if (ProjectFields.Count > 0) { foreach (string field in ProjectFields) { palletLoad.ProjectFields.Add(field, ""); } } return(palletLoad); }
/// <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); }