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

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

Set bounds for specified servos.

The method sets servos' physical bounds in which they may move. See documentation to Qwerk.Servos for clarification.

Incorrect length of , /// or array. No connection to Qwerk or its service. Connestion to Qwerk is lost.
public SetBounds ( bool mask, IntRange bounds ) : void
mask bool Mask array specifying which servos need to be set.
bounds AForge.IntRange Array of servos' bounds. Each bound may be in [0, 255] range.
Результат void
            public void SetBounds( bool[] mask, IntRange[] bounds )
            {
                if ( ( mask.Length != Count ) || ( bounds.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.Bounds[] nativeBounds = new TeRKIceLib.Bounds[Count];

                    for ( int i = 0; i < Count; i++ )
                    {
                        if ( mask[i] )
                        {
                            nativeBounds[i].min = bounds[i].Min;
                            nativeBounds[i].max = bounds[i].Max;
                        }
                    }

                    // set servos' bounds
                    servoController.setBounds( mask, nativeBounds );
                }
                catch
                {
                    throw new ConnectionLostException( "Connection is lost." );
                }
            }