private static void LoadListValues(XmlNodeList inputNodes, CodedComment comment) { foreach (XmlNode inputNode in inputNodes) { var valueId = inputNode.GetXmlNodeValue("@A"); var description = inputNode.GetXmlNodeValue("@B"); if (string.IsNullOrEmpty(valueId) || string.IsNullOrEmpty(description)) continue; if (comment.Values == null) { comment.Values = new Dictionary<string, EnumerationMember>(); comment.Comment.EnumeratedMembers = new List<EnumerationMember>(); } var listValue = new EnumerationMember { Value = description }; comment.Comment.EnumeratedMembers.Add(listValue); comment.Values[valueId] = listValue; } }
private EnumeratedValue DecodeMachineInfo(string clientNAME) { if (string.IsNullOrEmpty(clientNAME) || clientNAME.Length != 16) { return(null); } byte deviceGroup; if (!byte.TryParse(clientNAME.Substring(0, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out deviceGroup)) { return(null); } deviceGroup >>= 4; if ((deviceGroup & 0x07) != 2) // Agricultural devices { return(null); } byte deviceClass; if (!byte.TryParse(clientNAME.Substring(2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out deviceClass)) { return(null); } deviceClass >>= 1; AgGateway.ADAPT.ApplicationDataModel.Representations.EnumerationMember machineType = DefinedTypeEnumerationInstanceList.dtiTractor.ToModelEnumMember(); //Default DeviceOperationType deviceType = DeviceOperationTypes.SingleOrDefault(d => d.ClientNAMEMachineType == deviceClass); if (deviceType != null) { machineType = deviceType.MachineEnumerationMember.ToModelEnumMember(); } return(new EnumeratedValue { Representation = RepresentationInstanceList.dtMachineType.ToModelRepresentation(), Value = machineType }); }