Пример #1
0
 /// <summary> Constructor. </summary>
 /// <param name="owner">   The owner. </param>
 /// <param name="device">  The device. </param>
 /// <param name="motorID"> Identifier for the motor. </param>
 public ELLMotorViewModel(ELLDevicesViewModel owner, ELLBaseDevice device, char motorID)
 {
     _owner     = owner;
     _ellDevice = device;
     _motorID   = motorID;
     MotorName  = "Motor " + motorID;
 }
Пример #2
0
        private void connectToELLStageButton_Click(object sender, EventArgs e)
        {
            var args = new string[] { comPortComboBox1.SelectedItem.ToString(), "0" };


            // get the communication portELLStage
            portELLStage = (args.Length > 0) ? args[0] : comPortComboBox1.SelectedItem.ToString();
            // get the range of addresses used max range is '0' to 'F'
            char _minSearchLimit = (args.Length > 1 && ELLBaseDevice.IsValidAddress(char.ToUpper(args[1][0]))) ? char.ToUpper(args[1][0]) : '0';
            char _maxSearchLimit = (args.Length > 2 && ELLBaseDevice.IsValidAddress(char.ToUpper(args[2][0]))) ? char.ToUpper(args[2][0]) : '1';

            if (ELLDevicePort.Connect(portELLStage))
            {
                textBox1.Text = "Discover devices";
                // scan the portELLStage for connected devices using the given range of addresses
                List <string> devices = ellDevices.ScanAddresses(_minSearchLimit, _maxSearchLimit);

                foreach (string device in devices)
                {
                    // configure each device found
                    if (ellDevices.Configure(device))
                    {
                        // test each device found
                        textBox1.Text   = "Identify device " + device[0];
                        textBox1.Text   = "+++++++++++++++++++++++++";
                        addressedDevice = ellDevices.AddressedDevice(device[0]) as ELLDevice;

                        if (addressedDevice != null)
                        {
                            DeviceID deviceInfo = addressedDevice.DeviceInfo;
                            string   sttr       = "";
                            foreach (string str in deviceInfo.Description())
                            {
                                sttr += str + Environment.NewLine;
                            }
                            textBox1.Text = sttr;

                            switch (deviceInfo.DeviceType)
                            {
                            case DeviceID.DeviceTypes.OpticsRotator:
                                //addressedDevice.SetHomeOffset((decimal)0.0);
                                addressedDevice.Home(ELLBaseDevice.DeviceDirection.AntiClockwise);
                                Thread.Sleep(250);
                                homeOffset = addressedDevice.HomeOffset;
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
 protected ELLDeviceBaseViewModel(ELLDevicesViewModel owner, string deviceName, ELLBaseDevice device, int motorCount)
 {
     Owner           = owner;
     _device         = device;
     _deviceName     = deviceName;
     _fullDeviceName = string.Format("{0}:{1}", deviceName, _device.Address);
     for (int i = 0; i < motorCount; i++)
     {
         Motors.Add(new ELLMotorViewModel(owner, device, (char)('1' + i)));
     }
     _units      = _device.DeviceInfo.Units;
     Description = _device.DeviceInfo.Description();
 }
Пример #4
0
        public Form(string[] args)
        {
            InitializeComponent();
            OutputWindowString = OutputWindowString + "code version 1.1\n";
            PrintOutBox.Text   = OutputWindowString;

            port            = (args.Length > 0) ? args[0] : "COM3";
            _minSearchLimit = (args.Length > 1 && ELLBaseDevice.IsValidAddress(char.ToUpper(args[1][0]))) ? char.ToUpper(args[1][0]) : '0';
            _maxSearchLimit = (args.Length > 2 && ELLBaseDevice.IsValidAddress(char.ToUpper(args[2][0]))) ? char.ToUpper(args[2][0]) : '3';
            ellDevices      = new ELLDevices();


            /*
             * if (ELLDevicePort.Connect(port))
             * {
             *
             *   devices = ellDevices.ScanAddresses(_minSearchLimit, _maxSearchLimit);
             *   foreach (string device in devices)
             *   {
             *
             *      // configure each device found
             *      if (ellDevices.Configure(device))
             *      {
             *          addressedDevice1 = ellDevices.AddressedDevice(device[0]) as ELLDevice;
             *          addressedDevice2 = ellDevices.AddressedDevice(device[1]) as ELLDevice;
             *          addressedDevice3 = ellDevices.AddressedDevice(device[2]) as ELLDevice;
             *          addressedDevice4 = ellDevices.AddressedDevice(device[3]) as ELLDevice;
             *          if (addressedDevice1 != null)
             *          {
             *              addressedDevice1.Home();
             *              decimal val = addressedDevice1.Position;
             *              decimal roundedVal = Math.Round(val, 3);
             *              RotationMount1CurrentPosition.Text = roundedVal.ToString() + "deg";
             *
             *              OutputWindowString = OutputWindowString + "Device 1 is connected sucessfully\n";
             *              OutputWindowString = OutputWindowString + "Device 1 is homed\n\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *          else {
             *              OutputWindowString = OutputWindowString + "Device 1 is not connected\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *
             *          if (addressedDevice2 != null)
             *          {
             *              addressedDevice2.Home();
             *              decimal val = addressedDevice2.Position;
             *              decimal roundedVal = Math.Round(val, 3);
             *              RotationMount2CurrentPosition.Text = roundedVal.ToString() + "deg";
             *              OutputWindowString = OutputWindowString + "Device 2 is connected sucessfully\n";
             *              OutputWindowString = OutputWindowString + "Device 2 is homed\n\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *          else
             *          {
             *              OutputWindowString = OutputWindowString + "Device 2 is not connected\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *
             *          if (addressedDevice3 != null)
             *          {
             *              addressedDevice3.Home();
             *              decimal val = addressedDevice3.Position;
             *              decimal roundedVal = Math.Round(val, 3);
             *              RotationMount3CurrentPosition.Text = roundedVal.ToString() + "deg";
             *              OutputWindowString = OutputWindowString + "Device 3 is connected sucessfully\n";
             *              OutputWindowString = OutputWindowString + "Device 3 is homed\n\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *          else
             *          {
             *              OutputWindowString = OutputWindowString + "Device 3 is not connected\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *
             *          if (addressedDevice4 != null)
             *          {
             *              addressedDevice4.Home();
             *              decimal val = addressedDevice4.Position;
             *              decimal roundedVal = Math.Round(val, 3);
             *              RotationMount4CurrentPosition.Text = roundedVal.ToString() + "deg";
             *              OutputWindowString = OutputWindowString + "Device 4 is connected sucessfully\n";
             *              OutputWindowString = OutputWindowString + "Device 4 is homed\n\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *          else
             *          {
             *              OutputWindowString = OutputWindowString + "Device 4 is not connected\n";
             *              PrintOutBox.Text = OutputWindowString;
             *          }
             *
             *
             *      }
             *   }
             * }*/
        }