private void MoveRelative()
 {
     if (Owner.IsConnected)
     {
         ELLPaddlePolariser.PolarizerPaddlePositions positions = new ELLPaddlePolariser.PolarizerPaddlePositions()
         {
             Paddle1 = _paddlesTable[ELLPaddlePolariser.PaddleIDs.Paddle1].Displacement,
             Paddle2 = _paddlesTable[ELLPaddlePolariser.PaddleIDs.Paddle2].Displacement,
             Paddle3 = _paddlesTable[ELLPaddlePolariser.PaddleIDs.Paddle3].Displacement,
         };
         Owner.BackgroundThreadManager.RunBackgroundFunction((s, e) => ELLPaddleStage.MoveRelative(positions));
     }
 }
示例#2
0
        private void ParameterUpdate(MessageUpdater.UpdateTypes type, char address, object data)
        {
            switch (type)
            {
            case MessageUpdater.UpdateTypes.DeviceInfo:
            {
                DeviceID info = data as DeviceID;
                if ((info != null) && _deviceViewModels.ContainsKey(address))
                {
                    _dispatcher.BeginInvoke(() => _deviceViewModels[address].Description = info.Description());
                }
            }
            break;

            case MessageUpdater.UpdateTypes.MotorInfo:
            {
                MotorInfo info = data as MotorInfo;
                if ((info != null) && _deviceViewModels.ContainsKey(address))
                {
                    ELLMotorViewModel first = _deviceViewModels[address].Motors.FirstOrDefault(motor => motor.MotorID == info.MotorID);
                    if (first != null)
                    {
                        _dispatcher.BeginInvoke(() => first.UpdateInfo(info));
                    }
                }
            }
            break;

            case MessageUpdater.UpdateTypes.Status:
            {
                DeviceStatus status = data as DeviceStatus;
                if (status != null)
                {
                    switch (status.Status)
                    {
                    case DeviceStatus.DeviceStatusValues.OK:
                        break;

                    case DeviceStatus.DeviceStatusValues.Busy:
                        break;

                    default:
                        MessageBox.Show(string.Format("Device error: {0}", status.Status.GetStringValue()), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        break;
                    }
                }
            }
            break;

            case MessageUpdater.UpdateTypes.Position:
            {
                try
                {
                    decimal position = (decimal)data;
                    if (_deviceViewModels.ContainsKey(address))
                    {
                        _dispatcher.BeginInvoke(() => _deviceViewModels[address].UpdatePosition(position));
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            break;

            case MessageUpdater.UpdateTypes.PolarizerPositions:
            {
                try
                {
                    ELLPaddlePolariser.PolarizerPaddlePositions positions = (ELLPaddlePolariser.PolarizerPaddlePositions)data;
                    if (_deviceViewModels.ContainsKey(address))
                    {
                        ELLPaddlePolariserViewModel paddleViewModel = _deviceViewModels[address] as ELLPaddlePolariserViewModel;
                        if (paddleViewModel != null)
                        {
                            _dispatcher.BeginInvoke(() => paddleViewModel.UpdatePaddlePosition(positions));
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            break;

            case MessageUpdater.UpdateTypes.PaddlePosition:
            {
                try
                {
                    ELLPaddlePolariser.PaddlePosition position = (ELLPaddlePolariser.PaddlePosition)data;
                    if (_deviceViewModels.ContainsKey(address))
                    {
                        ELLPaddlePolariserViewModel paddleViewModel = _deviceViewModels[address] as ELLPaddlePolariserViewModel;
                        if (paddleViewModel != null)
                        {
                            _dispatcher.BeginInvoke(() => paddleViewModel.UpdatePaddlePosition(position));
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            break;

            case MessageUpdater.UpdateTypes.HomeOffset:
            {
                try
                {
                    decimal homeOffset = (decimal)data;
                    if (_deviceViewModels.ContainsKey(address))
                    {
                        _dispatcher.BeginInvoke(() => _deviceViewModels[address].UpdateHomeOffset(homeOffset));
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            break;

            case MessageUpdater.UpdateTypes.JogstepSize:
            {
                try
                {
                    decimal jogStep = (decimal)data;
                    if (_deviceViewModels.ContainsKey(address))
                    {
                        _dispatcher.BeginInvoke(() => _deviceViewModels[address].UpdateJogstepSize(jogStep));
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(string.Format("Device error: status {0}", e.Message), "Device Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            break;
            }
        }
 /// <summary>   Updates the paddle position described by positions. </summary>
 /// <param name="positions">    The positions. </param>
 public void UpdatePaddlePosition(ELLPaddlePolariser.PolarizerPaddlePositions positions)
 {
     _paddlesTable[ELLPaddlePolariser.PaddleIDs.Paddle1].Position = positions.Paddle1;
     _paddlesTable[ELLPaddlePolariser.PaddleIDs.Paddle2].Position = positions.Paddle2;
     _paddlesTable[ELLPaddlePolariser.PaddleIDs.Paddle3].Position = positions.Paddle3;
 }