/// <summary> The DeviceID Constructor. </summary> /// <param name="idString"> The identifier string defining the device. <Br />This is obtained as an output from the <see cref="ELLDevices.ScanAddresses(char, char)"/> function.</param> /// \include ScanDevices_snippet.txt internal DeviceID(string idString) { DeviceInfo di = new DeviceInfo(); DeviceInfo deviceInfo = Serialization.DeserializeMsg <DeviceInfo>(idString.ToBytes(Marshal.SizeOf(di))); Address = deviceInfo.Address; SerialNo = Serialization.ToString(deviceInfo.serialNo); Year = deviceInfo.year.ToInt(); Firmware = deviceInfo.firmware.ToDecimal(10); byte hw = (byte)deviceInfo.hardware.ToInt(true); Hardware = hw & 0x7F; Imperial = hw >= 0x80; Travel = deviceInfo.travel.ToInt(true); PulsePerPosition = deviceInfo.pulsePerPosition.ToInt(true); DeviceType = (DeviceTypes)(deviceInfo.deviceType.ToInt(true)); switch (DeviceType) { case DeviceTypes.Shutter: case DeviceTypes.Actuator: MotorCount = 1; break; case DeviceTypes.Shutter4: case DeviceTypes.Rotator: case DeviceTypes.RotaryStage: case DeviceTypes.LinearStage: case DeviceTypes.LinearStage2: case DeviceTypes.OpticsRotator: case DeviceTypes.RotaryStage18: case DeviceTypes.LinearStage17: case DeviceTypes.LinearStage20: MotorCount = 2; break; case DeviceTypes.Paddle: MotorCount = 3; break; default: MotorCount = 1; break; } switch (DeviceType) { case DeviceTypes.Paddle: _unitFactor = (Decimal)(PulsePerPosition - 1) / Travel; _unitType = UnitTypes.Degrees; FormatStr = "{0:0.0##}"; break; case DeviceTypes.Rotator: case DeviceTypes.OpticsRotator: case DeviceTypes.RotaryStage: case DeviceTypes.RotaryStage18: _unitFactor = PulsePerPosition / 360.0m; _unitType = UnitTypes.Degrees; FormatStr = "{0:0.0##}"; break; default: if (Imperial) { _unitType = UnitTypes.Inches; _unitFactor = 25.4m * PulsePerPosition; FormatStr = "{0:0.0###}"; } else { _unitType = UnitTypes.MM; _unitFactor = PulsePerPosition; FormatStr = "{0:0.0##}"; } break; } Units = _unitType.GetStringValue(); }