/// <summary> Constructor. </summary> /// <param name="paddleDevice"> The paddle device. </param> /// <param name="paddleID"> Identifier for the paddle. </param> public ELLPaddleViewModel(ELLDevicesViewModel owner, ELLPaddlePolariser paddleDevice, ELLPaddlePolariser.PaddleIDs paddleID) { _owner = owner; _paddleDevice = paddleDevice; _paddleID = paddleID; Title = $"Paddle{_paddleID}"; TargetPosition = 180; Displacement = 5; MoveTime = 10; }
/// <summary> Constructor. </summary> /// <param name="owner"> The owner. </param> /// <param name="device"> The device. </param> public ELLPaddlePolariserViewModel(ELLDevicesViewModel owner, ELLPaddlePolariser device) : base(owner, "Paddle", device, 3) { ELLPaddleStage = device; Units = "deg"; _paddlesTable = new Dictionary <ELLPaddlePolariser.PaddleIDs, ELLPaddleViewModel>() { { ELLPaddlePolariser.PaddleIDs.Paddle1, new ELLPaddleViewModel(owner, device, ELLPaddlePolariser.PaddleIDs.Paddle1) }, { ELLPaddlePolariser.PaddleIDs.Paddle2, new ELLPaddleViewModel(owner, device, ELLPaddlePolariser.PaddleIDs.Paddle2) }, { ELLPaddlePolariser.PaddleIDs.Paddle3, new ELLPaddleViewModel(owner, device, ELLPaddlePolariser.PaddleIDs.Paddle3) }, }; Paddles = _paddlesTable.Values.ToList(); TargetHomeOffset = 90; TargetJogStepSize = 30; }
private void ConnectEx() { if (ELLDevicePort.IsConnected) { DisconnectEx(); } else { bool connected; try { connected = ELLDevicePort.Connect(SelectedPort); } catch (Exception ex) { OutputUpdate(ex.Message, OutputItem.OutputItemType.Error); connected = false; } IsConnected = ELLDevicePort.IsConnected; if (!connected) { return; } if (MinSearchLimit > MaxSearchLimit) { MaxSearchLimit = MinSearchLimit; } ELLDevicePort.DataSent = DataSent; ELLDevicePort.DataReceived = DataReceived; _deviceViewModels.Clear(); _ellDevice.ClearDevices(); List <string> devices = _ellDevice.ScanAddresses(MinSearchLimit, MaxSearchLimit); if (devices.Count > 0) { foreach (string deviceID in devices) { _ellDevice.Configure(deviceID); _ellDevice.Connect(); char address = deviceID[0]; ELLDeviceBaseViewModel vm = null; DeviceID.DeviceTypes deviceType = _ellDevice.AddressedDevice(address).DeviceInfo.DeviceType; if (deviceType == DeviceID.DeviceTypes.Paddle) { ELLPaddlePolariser device = _ellDevice.AddressedDevice(address) as ELLPaddlePolariser; vm = new ELLPaddlePolariserViewModel(this, device); } else { ELLDevice device = _ellDevice.AddressedDevice(address) as ELLDevice; switch (deviceType) { case DeviceID.DeviceTypes.Actuator: vm = new ELLActuatorViewModel(this, device); break; case DeviceID.DeviceTypes.Shutter: vm = new ELLShutterViewModel(this, device, 2); break; case DeviceID.DeviceTypes.Shutter4: vm = new ELLShutterViewModel(this, device, 4); break; case DeviceID.DeviceTypes.Rotator: vm = new ELLStageViewModel(this, device, 2, true, true, false); break; case DeviceID.DeviceTypes.OpticsRotator: vm = new ELLStageViewModel(this, device, 2, true, true, true); break; case DeviceID.DeviceTypes.RotaryStage18: vm = new ELLStageViewModel(this, device, 2, true, false, true); break; case DeviceID.DeviceTypes.RotaryStage: vm = new ELLStageViewModel(this, device, 2, true, false, false); break; case DeviceID.DeviceTypes.LinearStage: case DeviceID.DeviceTypes.LinearStage2: vm = new ELLStageViewModel(this, device, 2, false, false, false); break; case DeviceID.DeviceTypes.LinearStage17: case DeviceID.DeviceTypes.LinearStage20: vm = new ELLStageViewModel(this, device, 2, false, false, true); break; } } if (vm != null) { _deviceViewModels[address] = vm; foreach (ELLMotorViewModel motor in vm.Motors) { motor.GetMotorInfoDirect(); } vm.InitializeViewModel(); } _sequenceViewModel.DeviceTypes = _deviceViewModels.ToDictionary(item => item.Key, item => item.Value.Device.DeviceInfo.DeviceType); } } else { DisconnectEx(); } } }