Пример #1
0
        /// <summary>
        /// Start the motors for Degrees and try to keep individual speeds using Speed(X) while using a maximum power of MaxPower. After Degrees is reached stop the outputs using the EndState.
        ///
        /// TachoMotor.StartSpeedForDegreesAsync support moving the motor by degrees. It operates relative of its current position.
        /// AbsoluteMotor.GotoAbsolutePositionAsync allows moving the motor to an absolute position. It operates relative to a changeable zero position.
        /// The Position(Observable) (POS) is reflecting the position relative to a changeable zero position (firmware in-memory encoded)
        /// The AbsolutePosition(Observable) (APOS) is reflecting the position relative to marked zero position (physically encoded).
        /// </summary>
        /// <param name="degrees">The degrees each motor should run. However, the combined degrees (2 * degrees) are split propertional among the speeds.</param>
        /// <param name="speedOnMotor1"></param>
        /// <param name="speedOnMotor2"></param>
        /// <param name="maxPower">Maximum Power level used.</param>
        /// <param name="endState">After time has expired, either Float, Hold or Brake. Defaults to Brake.</param>
        /// <param name="profile">The speed profiles used (as flags) for acceleration and deceleration. Defaults to None.</param>
        /// <returns></returns>
        public async Task <PortFeedback> StartSpeedForDegreesAsync(uint degrees, sbyte speedOnMotor1, sbyte speedOnMotor2, byte maxPower, SpecialSpeed endState = SpecialSpeed.Brake, SpeedProfiles profile = SpeedProfiles.None)
        {
            AssertValidDegrees(degrees, nameof(degrees));
            AssertValidSpeed(speedOnMotor1, nameof(speedOnMotor1));
            AssertValidSpeed(speedOnMotor2, nameof(speedOnMotor2));
            AssertValidMaxPower(maxPower, nameof(maxPower));
            AssertIsConnected();
            AssertIsVirtualPort();

            var response = await _protocol.SendPortOutputCommandAsync(new PortOutputCommandStartSpeedForDegrees2Message(
                                                                          _portId,
                                                                          PortOutputCommandStartupInformation.ExecuteImmediately, PortOutputCommandCompletionInformation.CommandFeedback,
                                                                          degrees,
                                                                          speedOnMotor1, speedOnMotor2,
                                                                          maxPower,
                                                                          endState,
                                                                          profile)
            {
                HubId = _hubId,
            });

            return(response);
        }
Пример #2
0
        /// <summary>
        /// Start the motors with individual speeds calculated from the common given Speed using a powerlevel limited to the MaxPower value. And the GOTO the Absolute positions: AbsPos1 and AbsPos2.
        ///
        /// TachoMotor.StartSpeedForDegreesAsync support moving the motor by degrees. It operates relative of its current position.
        /// AbsoluteMotor.GotoAbsolutePositionAsync allows moving the motor to an absolute position. It operates relative to a changeable zero position.
        /// The Position(Observable) (POS) is reflecting the position relative to a changeable zero position (firmware in-memory encoded)
        /// The AbsolutePosition(Observable) (APOS) is reflecting the position relative to marked zero position (physically encoded).
        /// </summary>
        /// <param name="absolutePosition1">Absolute Position of motor 1 (0 is the position at the start of the motor)</param>
        /// <param name="absolutePosition2">Absolute Position of motor 2 (0 is the position at the start of the motor)</param>
        /// <param name="speed">The speed used to move to the absolute position.</param>
        /// <param name="maxPower">Maximum Power level used.</param>
        /// <param name="endState">After time has expired, either Float, Hold or Brake. Defaults to Brake.</param>
        /// <param name="profile">The speed profiles used (as flags) for acceleration and deceleration. Defaults to None.</param>
        /// <returns></returns>
        public async Task <PortFeedback> GotoPositionAsync(int absolutePosition1, int absolutePosition2, sbyte speed, byte maxPower, SpecialSpeed endState = SpecialSpeed.Brake, SpeedProfiles profile = SpeedProfiles.None)
        {
            AssertValidSpeed(speed, nameof(speed));
            AssertValidMaxPower(maxPower, nameof(maxPower));
            AssertIsConnected();
            AssertIsVirtualPort();

            var response = await _protocol.SendPortOutputCommandAsync(new PortOutputCommandGotoAbsolutePosition2Message()
            {
                HubId                 = _hubId,
                PortId                = _portId,
                StartupInformation    = PortOutputCommandStartupInformation.ExecuteImmediately,
                CompletionInformation = PortOutputCommandCompletionInformation.CommandFeedback,
                AbsolutePosition1     = absolutePosition1,
                AbsolutePosition2     = absolutePosition2,
                Speed                 = speed,
                MaxPower              = maxPower,
                EndState              = endState,
                Profile               = profile,
            });

            return(response);
        }
 public void PortOutputCommandEncoder_Encode_PortOutputCommandStartSpeedForTime2Message(string expectedData, byte port, ushort time, sbyte speed1, sbyte speed2, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
 => PortOutputCommandEncoder_Encode(expectedData, new PortOutputCommandStartSpeedForTime2Message()
 {
     PortId                = port,
     StartupInformation    = PortOutputCommandStartupInformation.ExecuteImmediately,
     CompletionInformation = PortOutputCommandCompletionInformation.CommandFeedback,
     Time     = time,
     Speed1   = speed1,
     Speed2   = speed2,
     MaxPower = maxPower,
     EndState = endState,
     Profile  = profile,
 });
Пример #4
0
        /// <summary>
        /// Start the motor(s) for Time ms. keeping a speed of Speed using a maximum power of MaxPower. After Time stopping the output using the EndState.
        /// </summary>
        /// <param name="timeInMs"></param>
        /// <param name="speed">
        /// - Speed Level in Percentage: 1 - 100 (CW), -1 - -100 (CCW)
        /// - Stop Motor (hold position): 0 (use StartPower for floating and braking)
        /// </param>
        /// <param name="maxPower">Maximum Power level used.</param>
        /// <param name="endState">After time has expired, either Float, Hold or Brake. Defaults to Brake.</param>
        /// <param name="profile">The speed profiles used (as flags) for acceleration and deceleration. Defaults to  None.</param>
        /// <returns></returns>
        public async Task <PortFeedback> StartSpeedForTimeAsync(ushort timeInMs, sbyte speed, byte maxPower, SpecialSpeed endState = SpecialSpeed.Brake, SpeedProfiles profile = SpeedProfiles.None)
        {
            AssertValidSpeed(speed, nameof(speed));
            AssertValidMaxPower(maxPower, nameof(maxPower));
            AssertIsConnected();

            var response = await _protocol.SendPortOutputCommandAsync(new PortOutputCommandStartSpeedForTimeMessage(
                                                                          _portId,
                                                                          PortOutputCommandStartupInformation.ExecuteImmediately, PortOutputCommandCompletionInformation.CommandFeedback,
                                                                          timeInMs,
                                                                          speed,
                                                                          maxPower,
                                                                          endState,
                                                                          profile)
            {
                HubId = _hubId,
            });

            return(response);
        }
 public void PortOutputCommandEncoder_Encode_PortOutputCommandStartSpeedForDegreesMessage(string expectedData, byte port, uint degrees, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
 => PortOutputCommandEncoder_Encode(expectedData, new PortOutputCommandStartSpeedForDegreesMessage()
 {
     PortId                = port,
     StartupInformation    = PortOutputCommandStartupInformation.ExecuteImmediately,
     CompletionInformation = PortOutputCommandCompletionInformation.CommandFeedback,
     Degrees               = degrees,
     Speed    = speed,
     MaxPower = maxPower,
     EndState = endState,
     Profile  = profile,
 });
 public void PortOutputCommandEncoder_Encode_PortOutputCommandGotoAbsolutePosition2Message(string expectedData, byte port, int absPos1, int absPos2, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
 => PortOutputCommandEncoder_Encode(expectedData, new PortOutputCommandGotoAbsolutePosition2Message()
 {
     PortId                = port,
     StartupInformation    = PortOutputCommandStartupInformation.ExecuteImmediately,
     CompletionInformation = PortOutputCommandCompletionInformation.CommandFeedback,
     AbsolutePosition1     = absPos1,
     AbsolutePosition2     = absPos2,
     Speed    = speed,
     MaxPower = maxPower,
     EndState = endState,
     Profile  = profile,
 });
Пример #7
0
        /// <summary>
        /// Start the motors for Degrees and try to keep individual speeds using Speed(X) while using a maximum power of MaxPower. After Degrees is reached stop the outputs using the EndState.
        ///
        /// TachoMotor.StartSpeedForDegreesAsync support moving the motor by degrees. It operates relative of its current position.
        /// AbsoluteMotor.GotoAbsolutePositionAsync allows moving the motor to an absolute position. It operates relative to a changeable zero position.
        /// The Position(Observable) (POS) is reflecting the position relative to a changeable zero position (firmware in-memory encoded)
        /// The AbsolutePosition(Observable) (APOS) is reflecting the position relative to marked zero position (physically encoded).
        /// </summary>
        /// <param name="degrees"></param>
        /// <param name="speed"></param>
        /// <param name="maxPower">Maximum Power level used.</param>
        /// <param name="endState">After time has expired, either Float, Hold or Brake.</param>
        /// <param name="profile">The speed profiles used (as flags) for acceleration and deceleration</param>
        /// <returns></returns>
        public async Task <PortFeedback> StartSpeedForDegreesAsync(uint degrees, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
        {
            AssertValidDegrees(degrees, nameof(degrees));
            AssertValidSpeed(speed, nameof(speed));
            AssertValidMaxPower(maxPower, nameof(maxPower));
            AssertIsConnected();

            var response = await _protocol.SendPortOutputCommandAsync(new PortOutputCommandStartSpeedForDegreesMessage()
            {
                HubId                 = _hubId,
                PortId                = _portId,
                StartupInformation    = PortOutputCommandStartupInformation.ExecuteImmediately,
                CompletionInformation = PortOutputCommandCompletionInformation.CommandFeedback,
                Degrees               = degrees,
                Speed                 = speed,
                MaxPower              = maxPower,
                EndState              = endState,
                Profile               = profile,
            });

            return(response);
        }
Пример #8
0
        /// <summary>
        /// Start the motors for Time ms. And try to keep individual speeds using Speed(X) while using a maximum power of MaxPower. After Time stopping the outputs using the EndState.
        /// </summary>
        /// <param name="timeInMs"></param>
        /// <param name="speedOnMotor1">
        /// - Speed Level in Percentage: 1 - 100 (CW), -1 - -100 (CCW)
        /// - Stop Motor (hold position): 0 (use StartPower for floating and braking)
        /// </param>
        /// <param name="speedOnMotor2">
        /// - Speed Level in Percentage: 1 - 100 (CW), -1 - -100 (CCW)
        /// - Stop Motor (hold position): 0 (use StartPower for floating and braking)
        /// </param>
        /// <param name="maxPower">Maximum Power level used.</param>
        /// <param name="endState">After time has expired, either Float, Hold or Brake.</param>
        /// <param name="profile">The speed profiles used (as flags) for acceleration and deceleration</param>
        /// <returns></returns>
        public async Task <PortFeedback> StartSpeedForTimeAsync(ushort timeInMs, sbyte speedOnMotor1, sbyte speedOnMotor2, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
        {
            AssertValidSpeed(speedOnMotor1, nameof(speedOnMotor1));
            AssertValidSpeed(speedOnMotor2, nameof(speedOnMotor2));
            AssertValidMaxPower(maxPower, nameof(maxPower));
            AssertIsConnected();
            AssertIsVirtualPort();

            var response = await _protocol.SendPortOutputCommandAsync(new PortOutputCommandStartSpeedForTime2Message()
            {
                HubId                 = _hubId,
                PortId                = _portId,
                StartupInformation    = PortOutputCommandStartupInformation.ExecuteImmediately,
                CompletionInformation = PortOutputCommandCompletionInformation.CommandFeedback,
                Time     = timeInMs,
                Speed1   = speedOnMotor1,
                Speed2   = speedOnMotor2,
                MaxPower = maxPower,
                EndState = endState,
                Profile  = profile,
            });

            return(response);
        }
 public void PortOutputCommandEncoder_Encode_PortOutputCommandStartSpeedForDegrees2Message(string expectedData, byte port, uint degrees, sbyte speed1, sbyte speed2, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
 => PortOutputCommandEncoder_Encode(expectedData, new PortOutputCommandStartSpeedForDegrees2Message(
                                        port,
                                        PortOutputCommandStartupInformation.ExecuteImmediately, PortOutputCommandCompletionInformation.CommandFeedback,
                                        Degrees: degrees,
                                        Speed1: speed1,
                                        Speed2: speed2,
                                        MaxPower: maxPower,
                                        EndState: endState,
                                        Profile: profile
                                        ));
 public void PortOutputCommandEncoder_Encode_PortOutputCommandStartSpeedForTimeMessage(string expectedData, byte port, ushort time, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
 => PortOutputCommandEncoder_Encode(expectedData, new PortOutputCommandStartSpeedForTimeMessage(
                                        port,
                                        PortOutputCommandStartupInformation.ExecuteImmediately, PortOutputCommandCompletionInformation.CommandFeedback,
                                        Time: time,
                                        Speed: speed,
                                        MaxPower: maxPower,
                                        EndState: endState,
                                        Profile: profile
                                        ));
 public void PortOutputCommandEncoder_Encode_PortOutputCommandGotoAbsolutePosition2Message(string expectedData, byte port, int absPos1, int absPos2, sbyte speed, byte maxPower, SpecialSpeed endState, SpeedProfiles profile)
 => PortOutputCommandEncoder_Encode(expectedData, new PortOutputCommandGotoAbsolutePosition2Message(
                                        port,
                                        PortOutputCommandStartupInformation.ExecuteImmediately, PortOutputCommandCompletionInformation.CommandFeedback,
                                        AbsolutePosition1: absPos1,
                                        AbsolutePosition2: absPos2,
                                        Speed: speed,
                                        MaxPower: maxPower,
                                        EndState: endState,
                                        Profile: profile
                                        ));