public static MemoryMask From(XElement node) { var xWordSize = node.Attribute("wordSize"); var xMemoryType = node.Attribute("memoryType"); var xStart = node.Attribute("start"); var xEnd = node.Attribute("end"); var xMask = node.Attribute("mask"); var memType = AvrMemoryType.Flash; if (xMemoryType != null) { Enum.TryParse(xMemoryType.Value, true, out memType); } var start = 0; if (xStart != null) { DeviceInfoUtils.TryParseInt(xStart.Value, out start); } int?end = null; if (xEnd != null) { int endVal; if (DeviceInfoUtils.TryParseInt(xEnd.Value, out endVal)) { end = endVal; } } var wordSize = 1; if (xWordSize != null) { DeviceInfoUtils.TryParseInt(xWordSize.Value, out wordSize); } var mask = 0xffffffff; if (xMask != null) { DeviceInfoUtils.TryParseUInt(xMask.Value, out mask); } var res = new MemoryMask { MemoryType = memType, AddressStart = start, AddressEnd = end, WordSize = wordSize, Mask = mask }; return(res); }
private static StkDeviceCode ParseStkCode(string val) { StkDeviceCode res; if (Enum.TryParse(val, true, out res)) { return(res); } return((StkDeviceCode)DeviceInfoUtils.ParseInt(val)); }
public static DeviceBitsGroup From(XElement xBits) { var res = new DeviceBitsGroup(); var xName = xBits.Attribute("name"); var xDescription = xBits.Element("description"); res.Name = xName != null ? xName.Value : ""; res.Description = DeviceInfoUtils.FormatDescription(xDescription); foreach (var xBit in xBits.Elements("deviceBit")) { res.Bits.Add(DeviceBit.From(xBit)); } return(res); }
public static DeviceBit From(XElement xDeviceBit) { var xAddress = xDeviceBit.Attribute("address"); var xBit = xDeviceBit.Attribute("bit"); var xName = xDeviceBit.Attribute("name"); var xInverse = xDeviceBit.Attribute("inverse"); var xConstant = xDeviceBit.Attribute("constant"); var xHidden = xDeviceBit.Attribute("hidden"); var xDescription = xDeviceBit.Element("description"); return(new DeviceBit { Address = xAddress != null?ParseInt(xAddress.Value) : 0, Bit = xBit != null?int.Parse(xBit.Value) : 0, Name = xName != null ? xName.Value : "", Inverse = xInverse != null && xInverse.Value.ToLowerInvariant() == "true", Hidden = xHidden != null && xHidden.Value.ToLowerInvariant() == "true", Constant = xConstant != null ? new bool?(xConstant.Value == "1") : null, Description = DeviceInfoUtils.FormatDescription(xDescription) }); }