public static DisplayData UpdateDisplayData(DisplayData displayData, RespondingCommands cmd) { if (displayData == null) { displayData = new DisplayData(); } var result = WriteRespondingCommand(cmd); switch (cmd) { case Vici8145Lib.RespondingCommands.MainDisplayValue: displayData = ParseResult.ParseMainDisplayData(displayData, result); break; case Vici8145Lib.RespondingCommands.SecondDisplayValue: displayData = ParseResult.ParseSecondDisplayData(displayData, result); break; case Vici8145Lib.RespondingCommands.AnalogeBarValue: displayData = ParseResult.ParseBarDisplayData(displayData, result); break; default: throw new ArgumentOutOfRangeException(nameof(cmd), cmd, null); } displayData.RawData = result; return(displayData); }
private static void AddPrefix(DisplayData displayData) { switch (displayData.Prefixis) { case PrefixEnum.Kilo: displayData.Unit = @"k" + displayData.Unit; break; case PrefixEnum.Mega: displayData.Unit = "M" + displayData.Unit; break; case PrefixEnum.Micro: displayData.Unit = "μ" + displayData.Unit; break; case PrefixEnum.Milli: displayData.Unit = "m" + displayData.Unit; break; case PrefixEnum.Pica: displayData.Unit = "p" + displayData.Unit; break; default: displayData.Unit = displayData.Unit; break; } }
public static DisplayData ParseMainDisplayData(DisplayData displayData, byte[] data) { ParseUnits(data, displayData); displayData.Prefixis = ParsePrefix(data); displayData.Hold = ParseHold(data); displayData.Rel = ParseRel(data); displayData.Sign = ParserSign(data); displayData.MainDisplayValue = ParseMainDisplayValue(data); displayData.MinMax = ParseMinMax(data); displayData.Auto = IsAutoRange(data[2]); return(displayData); }
public static void ParseUnits(byte[] toParse, DisplayData dispData) { _temperature = false; _resistance = false; _isAc = false; _adjustDecPos = _adjustDecPos2 = _adjustDecPos2 = 0; var mode = (toParse[1] & 0b0111_1000) >> 3; dispData.Select = ParseSelect(toParse[1] & 3, mode, dispData, toParse); if (dispData.Select == "AC") { _isAc = true; } }
private static string ParseSelect(int select, int mode, DisplayData d, byte[] rawdata) { _generator = false; _resistance = false; _isAc = false; d.ShowBar = true; d.Unit2 = ""; switch (select) { case 00: switch (mode) { case 0xE: d.Unit1 = d.Unit = "V"; d.Entities = EntitiesEnum.Voltage; return("DC"); case 0xF: d.Unit1 = d.Unit = "V"; d.Entities = EntitiesEnum.Voltage; return("AC"); case 0xD: d.Unit1 = d.Unit = "mV"; d.Entities = EntitiesEnum.Voltage; return("DC"); case 0x6: d.Unit1 = d.Unit = "mA"; d.Entities = EntitiesEnum.Current; return("DC"); case 0x5: d.Unit = "A"; d.Entities = EntitiesEnum.Current; return("DC"); case 0xC: d.Unit1 = d.Unit = "Ω"; d.Unit2 = "Ω"; _resistance = true; d.Entities = EntitiesEnum.Resistance; AddPrefix(d); return(""); case 0x9: if (rawdata[2] != 0x98) { d.Unit1 = d.Unit = "nF"; } else { d.Unit1 = d.Unit = "µF"; } d.ShowBar = false; d.Entities = EntitiesEnum.Capacity; return("Capacitor"); case 0x8: d.Unit = "°C"; d.Unit1 = "°F"; d.Entities = EntitiesEnum.Temp; _temperature = true; d.ShowBar = false; _adjustDecPos = _adjustDecPos2 = 1; return("Temp"); case 0xA: d.Entities = EntitiesEnum.Frequency; d.Unit = "Hz"; d.Unit1 = "% duty"; d.ShowBar = false; return(""); case 0x4: d.Unit = "Hz"; d.Unit1 = "Duty"; _generator = true; d.Entities = EntitiesEnum.Generator; return("Generator"); case 0xb: d.Unit = "V"; d.Unit1 = ""; d.Entities = EntitiesEnum.Diode; return("Diode"); } break; case 1: switch (mode) { case 0xE: d.Unit = "V"; d.Unit1 = "Hz"; _adjustDecPos2 = 1; return("AC+DC"); case 0xF: _adjustDecPos2 = 1; d.Unit = "V"; d.Unit1 = "Hz"; return("AC"); case 0xD: _adjustDecPos = _adjustDecPos2 = 1; d.Unit = "mV"; d.Unit1 = "Hz"; return("AC"); case 0x6: d.Unit = "mA"; return("AC"); case 0x5: d.Unit = "A"; return("AC"); case 0xC: d.Unit = ">>"; return(""); case 0x8: d.Unit = "°C"; d.Unit1 = "°F"; _temperature = true; _adjustDecPos = _adjustDecPos2 = 1; d.ShowBar = false; return("Temp Ext"); case 0xA: d.Unit = "MHz"; d.Unit1 = ""; _adjustDecPos = _adjustDecPos2 = -2; return("Hi"); } break; case 2: switch (mode) { case 0xE: d.Unit1 = "Hz"; d.Unit = "dBm"; _adjustDecPos = rawdata[2] == 0xc8 ? 10 : 2; _adjustDecPos2 = 1; return(""); case 0xf: d.Unit1 = "Hz"; d.Unit = "dBm"; _adjustDecPos2 = 1; return("AC"); case 0xD: d.Unit1 = "Hz"; d.Unit = "dBm"; _adjustDecPos = rawdata[2] == 0xc8 ? 10 : 2; _adjustDecPos2 = 1; return(""); case 0x6: d.Unit = "mA"; d.Unit1 = "mA AC"; return("AC+DC"); case 0x5: d.Unit = "A"; d.Unit1 = "A AC"; return("AC+DC"); case 0xC: d.Unit = "Hi"; return(""); case 0xA: d.Unit = "RPM"; d.Unit1 = ""; return(""); } break; case 3: switch (mode) { case 0x6: d.Unit1 = "Hz"; d.Unit = "mA"; return("AC"); case 0x5: d.Unit1 = "Hz"; d.Unit = "A"; return("AC"); } break; } return(""); }