static async Task UpdateCameraSerialNumber(string portName, IProgress <int> progress) { using (var device = new AsyncDevice(portName)) { progress.Report(20); var serialNumber = SerialNumberHelper.GetCameraSerialNumber(); progress.Report(50); await device.WriteUInt64Async(ConfigurationRegisters.CameraSerialNumber, serialNumber); await device.CommandAsync(HarpCommand.Reset(ResetMode.Save)); progress.Report(100); } }
IEnumerable <HarpMessage> WriteRegisters(bool savePersistent) { var triggerState = configuration.TriggerState; yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.Config, (ushort)configuration.Config)); yield return(HarpCommand.WriteByte(ConfigurationRegisters.ScreenBrightness, (byte)configuration.ScreenBrightness)); yield return(HarpCommand.WriteByte(ConfigurationRegisters.TriggerState, TriggerHelper.FromFrameFlags(triggerState))); yield return(HarpCommand.WriteByte(ConfigurationRegisters.TriggerStateLength, (byte)triggerState.Length)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.TriggerPeriod, (ushort)configuration.TriggerPeriod)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.TriggerTimeUpdateOutputs, (ushort)configuration.DwellTime)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.TriggerLaserOn, (ushort)configuration.TriggerLaserOn)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.TriggerLaserOff, (ushort)configuration.TriggerLaserOff)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.DacL415, LedPowerConverter.ClampLedPower((ushort)configuration.L415))); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.DacL470, LedPowerConverter.ClampLedPower((ushort)configuration.L470))); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.DacL560, LedPowerConverter.ClampLedPower((ushort)configuration.L560))); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.DacLaser, (ushort)configuration.LaserAmplitude)); yield return(HarpCommand.WriteByte(ConfigurationRegisters.Out0Conf, (byte)configuration.DigitalOutput0)); yield return(HarpCommand.WriteByte(ConfigurationRegisters.Out1Conf, (byte)configuration.DigitalOutput1)); yield return(HarpCommand.WriteByte(ConfigurationRegisters.In0Conf, (byte)configuration.DigitalInput0)); yield return(HarpCommand.WriteByte(ConfigurationRegisters.In1Conf, (byte)configuration.DigitalInput1)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.StimPeriod, (ushort)configuration.PulsePeriod)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.StimOn, (ushort)configuration.PulseWidth)); yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.StimReps, (ushort)configuration.PulseCount)); if (savePersistent) { yield return(HarpCommand.WriteUInt16(ConfigurationRegisters.StimWavelength, 0)); yield return(HarpCommand.Reset(ResetMode.Save)); } }
IEnumerable <HarpMessage> ResetRegisters(bool resetDefault) { var resetMode = resetDefault ? ResetMode.RestoreDefault : ResetMode.RestoreEeprom; yield return(HarpCommand.Reset(resetMode)); }