AForge.Robotics.TeRK.Qwerk.Servos.SetPositions C# (CSharp) Метод

SetPositions() публичный Метод

Set positions of specified servos.

The mask and positions arrays specify which Qwerk's servo's state should be updated. If value of the mask array is set to , then corresponding servo's state is changed to the state, which is specified in positions array.

Incorrect length of or /// array. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public SetPositions ( bool mask, int positions ) : int[]
mask bool Mask array specifying which servos need to be set.
positions int Array of servos' positions to set. Each position is in [0, 255] range.
Результат int[]
            public int[] SetPositions( bool[] mask, int[] positions )
            {
                if ( ( mask.Length != Count ) || ( positions.Length != Count ) )
                {
                    throw new ArgumentException( "Incorrect length of mask or positions array." );
                }

                // check controller
                if ( servoController == null )
                {
                    throw new NotConnectedException( "Qwerk's service is not connected." );
                }

                try
                {
                    TeRKIceLib.ServoCommand command = CreateCommand( );

                    for ( int i = 0; i < Count; i++ )
                    {
                        command.servoMask[i]      = mask[i];
                        command.servoModes[i]     = TeRKIceLib.ServoMode.ServoMotorPositionControl;
                        command.servoPositions[i] = positions[i];
                        command.servoSpeeds[i]    = DefaultSpeed;
                    }

                    // execute servos' command
                    TeRKIceLib.ServoState state = servoController.execute( command );
                    return state.servoPositions;
                }
                catch
                {
                    throw new ConnectionLostException( "Connection is lost." );
                }
            }