public new static int GetSize(FileVersion version = FileVersion.Current) { var size = InoutPoint.GetSize(version); switch (version) { case FileVersion.Current: return(size + 16); default: throw new FileVersionNotImplementedException(version); } }
/// <summary> /// FileVersion.Current - Need 46 bytes /// </summary> /// <param name="bytes"></param> /// <param name="offset"></param> /// <param name="version"></param> public InputPoint(byte[] bytes, int offset = 0, FileVersion version = FileVersion.Current) : base(bytes, offset, version) { offset += InoutPoint.GetSize(FileVersion); int valueRaw; Unit unit; byte filterRaw; byte calibrationHRaw; byte calibrationLRaw; byte decomRaw; switch (FileVersion) { case FileVersion.Current: valueRaw = bytes.ToInt32(ref offset); filterRaw = bytes.ToByte(ref offset); decomRaw = bytes.ToByte(ref offset); SubId = bytes.ToBoolean(ref offset); SubProduct = bytes.ToBoolean(ref offset); Control = (OffOn)bytes.ToByte(ref offset); AutoManual = (AutoManual)bytes.ToByte(ref offset); DigitalAnalog = (DigitalAnalog)bytes.ToByte(ref offset); CalibrationSign = (Sign)bytes.ToByte(ref offset); SubNumber = SubNumberFromByte(bytes.ToByte(ref offset)); calibrationHRaw = bytes.ToByte(ref offset); calibrationLRaw = bytes.ToByte(ref offset); unit = UnitFromByte(bytes.ToByte(ref offset), DigitalAnalog); break; default: throw new FileVersionNotImplementedException(FileVersion); } Value = new VariableValue(valueRaw, unit); Filter = (int)Math.Pow(2, filterRaw); CalibrationH = calibrationHRaw / 10.0; CalibrationL = calibrationLRaw / 10.0; //Status var statusIndex = decomRaw % 16; if (statusIndex >= (int)InputStatus.Normal && statusIndex <= (int)InputStatus.Shorted) { Status = (InputStatus)statusIndex; } else { Status = InputStatus.Normal; } //Jumper var jumperIndex = decomRaw / 16; if (jumperIndex >= (int)Jumper.Thermistor && jumperIndex <= (int)Jumper.To10V) { Jumper = (Jumper)jumperIndex; } else { Jumper = jumperIndex == 4 ? (Jumper)4 //TODO: NOT MINE: Fix for T3DemoRev6.prg : Jumper.Thermistor; } CheckOffset(offset, GetSize(FileVersion)); }