static void SaveSettings(string fileName, FP3002Configuration configuration) { using (var writer = XmlWriter.Create(fileName, new XmlWriterSettings { Indent = true })) { var serializer = new XmlSerializer(typeof(FP3002Configuration)); serializer.Serialize(writer, configuration); } }
public LedCalibrationEditor(FP3002Configuration configuration) { InitializeComponent(); converter = new LedPowerConverter(); slider470.Converter = converter; slider470.Value = DefaultCalibrationPower; Commands = Observable.Merge( SetTriggerMode(Constant, DefaultCalibrationPower, DefaultTriggerPeriod, DefaultDwellTime).ToObservable(Scheduler.Immediate), FromSlider(slider470, ConfigurationRegisters.DacL470), ClearTriggerMode(configuration.TriggerState, configuration.L470, configuration.TriggerPeriod, configuration.DwellTime)); }
public FP3002CalibrationEditorForm(FP3002 capture, IServiceProvider provider) { InitializeComponent(); instance = capture; device = CreateDevice(); serviceProvider = provider; photometry = new PhotometryData(); configuration = new FP3002Configuration(); configuration.Regions = instance.Regions; propertyGrid.SelectedObject = configuration; rowHeaderFormat = new StringFormat(); rowHeaderFormat.Alignment = StringAlignment.Far; rowHeaderFormat.LineAlignment = StringAlignment.Center; }
bool SetActiveConfiguration(FP3002Configuration activeConfiguration) { if (activeConfiguration.SerialNumber != configuration.SerialNumber && MessageBox.Show(this, Properties.Resources.MatchingSerialNumbers_Warning, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return(false); } propertyGrid.SelectedObject = activeConfiguration; configuration = activeConfiguration; instance.Regions = configuration.Regions ?? instance.Regions; ValidateSettings(); SetTriggerState(); return(true); }
private void ValidateDeviceFirmware() { if (configuration.WhoAmI == 0) { return; } if (configuration.WhoAmI != FP3002Configuration.DeviceWhoAmI) { MessageBox.Show(this, Properties.Resources.InvalidDeviceID_Error, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); CloseDevice(); Close(); return; } if (deviceFirmware == null) { deviceFirmware = configuration.GetFirmwareMetadata(); var targetFirmware = FP3002Configuration.GetTargetFirmwareMetadata(); if (!targetFirmware.Supports(nameof(FP3002), deviceFirmware.HardwareVersion, assemblyNumber: 0)) { MessageBox.Show(this, Properties.Resources.UnsupportedHardwareVersion_Error, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); CloseDevice(); Close(); return; } if (deviceFirmware.FirmwareVersion > targetFirmware.FirmwareVersion) { MessageBox.Show(this, Properties.Resources.UpdateDriverVersion_Error, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); CloseDevice(); Close(); return; } if (!deviceFirmware.FirmwareVersion.Satisfies(targetFirmware.FirmwareVersion) || ModifierKeys == (Keys.Shift | Keys.Control | Keys.Alt)) { if (MessageBox.Show(this, Properties.Resources.UpdateDeviceFirmware_Question, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { CloseDevice(); SetConnectionStatus(ConnectionStatus.Reset); var targetDeviceFirmware = FP3002Configuration.GetTargetDeviceFirmware(); using (var firmwareDialog = new FP3002FirmwareDialog(instance.PortName, targetDeviceFirmware)) { firmwareDialog.ShowDialog(this); } deviceFirmware = null; ResetDevice(); return; } else if (deviceFirmware.FirmwareVersion.Major < targetFirmware.FirmwareVersion.Major) { MessageBox.Show(this, Properties.Resources.UnsupportedFirmwareVersion_Error, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); CloseDevice(); Close(); return; } } if (configuration.CameraSerialNumber == 0 || ModifierKeys == (Keys.Shift | Keys.Control)) { if (MessageBox.Show(this, Properties.Resources.UpdateCameraSerialNumber_Warning, Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { CloseDevice(); using (var firmwareDialog = new FP3002CameraRegistrationDialog(instance.PortName)) { firmwareDialog.ShowDialog(this); } ResetDevice(); return; } } } propertyGrid.Refresh(); SetConnectionStatus(ConnectionStatus.Ready); }