Example #1
0
        /// <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);
        }
        private void JogForward()
        {
            ELLDevice ellDevice = Device as ELLDevice;

            if (Owner.IsConnected && (ellDevice != null))
            {
                Owner.BackgroundThreadManager.RunBackgroundFunction((s, e) => ellDevice.JogForward());
            }
        }