/// <summary> Creates a command. </summary> /// <param name="devices"> The devices. </param> /// <param name="addresses"> The addresses. </param> /// <param name="command"> The command. </param> /// <param name="wait"> The wait. </param> /// <param name="parameter1"> The first parameter. </param> /// <param name="parameter2"> The second parameter. </param> /// <returns> The new command. </returns> public SequenceItem CreateCommand(ELLDevices devices, List <char> addresses, ELLCommands command, TimeSpan wait, decimal parameter1, ELLBaseDevice.DeviceDirection parameter2) { if (!addresses.Any()) { return(null); } ELLDevice device = devices.AddressedDevice(addresses.First()) as ELLDevice; if (device == null) { return(null); } if (addresses.Count == 1) { switch (command) { case ELLCommands.GetPosition: return(new SequenceItem(command, device.Address, device.GetPosition, command.GetStringValue(), wait)); case ELLCommands.Forward: return(new SequenceItem(command, device.Address, device.JogForward, command.GetStringValue(), wait)); case ELLCommands.Backward: return(new SequenceItem(command, device.Address, device.JogBackward, command.GetStringValue(), wait)); case ELLCommands.Home: return(new SequenceItem(command, device.Address, () => device.Home(parameter2), command.GetStringValue(), wait)); case ELLCommands.MoveRelative: return(new SequenceItem(command, device.Address, () => device.MoveRelative(parameter1), command.GetStringValue(), wait)); case ELLCommands.MoveAbsolute: return(new SequenceItem(command, device.Address, () => device.MoveAbsolute(parameter1), command.GetStringValue(), wait)); case ELLCommands.SetJogstepSize: return(new SequenceItem(command, device.Address, () => device.SetJogstepSize(parameter1), command.GetStringValue(), wait)); } } else { switch (command) { case ELLCommands.Forward: return(new SequenceItem(command, device.Address, () => device.JogForward(addresses), command.GetStringValue(), wait)); case ELLCommands.Backward: return(new SequenceItem(command, device.Address, () => device.JogBackward(addresses), command.GetStringValue(), wait)); case ELLCommands.Home: return(new SequenceItem(command, device.Address, () => device.Home(addresses, parameter2), command.GetStringValue(), wait)); case ELLCommands.MoveRelative: return(new SequenceItem(command, device.Address, () => device.MoveRelative(addresses, parameter1), command.GetStringValue(), wait)); case ELLCommands.MoveAbsolute: return(new SequenceItem(command, device.Address, () => device.MoveAbsolute(addresses, parameter1), command.GetStringValue(), wait)); } } return(null); }
// device 4////////// controll/////////////////////////////////////////////////////////////////////////////////////// private void RotationMount4HomeButton_Click(object sender, EventArgs e) { if (addressedDevice4 != null) { addressedDevice4.Home(); OutputWindowString = OutputWindowString + "Device 4 is homed\n"; PrintOutBox.Text = OutputWindowString; } }
// device 1 control/////////////////////////////////////////////////////////////////////////////////////////////////// private void RotationMount1HomeButton_Click(object sender, EventArgs e) { OutputWindowString = OutputWindowString + "Mount 1 home button is clicked\n"; PrintOutBox.Text = OutputWindowString; if (addressedDevice1 != null) { addressedDevice1.Home(); OutputWindowString = OutputWindowString + "Device 1 is homed\n"; PrintOutBox.Text = OutputWindowString; } }
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; } } } } } }
private void rotateAndrecord(object sender, EventArgs e) { WriteToFile("Home offset is " + homeOffset.ToString() + Environment.NewLine + "theta0 (Initial angle from Home) is (deg) " + theta0TextBox.Text + Environment.NewLine); WriteToFile("angle from Home(deg)" + "\t" + "angle from theta0(deg)" + "\t" + "photocurrent" + Environment.NewLine); for (int i = 0; i < Convert.ToInt32(numberOfRepeatsTextBox.Text); i++) { decimal dtheta = Convert.ToDecimal(dthetaTextBox.Text); decimal theta = 0; decimal fromtheta0 = Convert.ToDecimal(theta0TextBox.Text); addressedDevice.Home(ELLBaseDevice.DeviceDirection.AntiClockwise); Thread.Sleep(5000); addressedDevice.MoveRelative(fromtheta0); Thread.Sleep(3000); while (theta <= Convert.ToDecimal(totalRotationTextBox.Text) + dtheta) { angleTextBox.Text = theta.ToString(); var krochmann = ReadKrochmann(); string s = theta.ToString() + "\t" + fromtheta0.ToString() + "\t" + krochmann + Environment.NewLine; addressedDevice.MoveRelative(dtheta); Thread.Sleep(1500); WriteToFile(s); Thread.Sleep(500); theta += dtheta; fromtheta0 += dtheta; } } }