/// <summary> Constructor. </summary> /// <param name="owner"> The owner. </param> /// <param name="ellDevices"> The Elliptec device. </param> public ELLSequenceViewModel(ELLDevicesViewModel owner, ELLDevices ellDevices) { _owner = owner; _ellDevices = ellDevices; _sequence = new ELLSequenceXML(); Items = new ObservableCollection <ELLSequenceItemViewModel>(); }
/// <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); }
public MainForm() { InitializeComponent(); getFeedBack = new System.Windows.Forms.Timer(); getFeedBack.Tick += new EventHandler(FeedBack); getFeedBack.Interval = Convert.ToInt32(feedbackIntervalTextBox.Text) * 1000; ellDevices = new ELLDevices(); }
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; * } * * * } * } * }*/ }