Exemplo n.º 1
0
            /// <summary>
            /// Set bounds for specified servos.
            /// </summary>
            ///
            /// <param name="mask">Mask array specifying which servos need to be set.</param>
            /// <param name="bounds">Array of servos' bounds. Each bound may be in [0, 255] range.</param>
            ///
            /// <remarks><para>The method sets servos' physical bounds in which they may move.
            /// See documentation to <see cref="Qwerk.Servos"/> for clarification.</para></remarks>
            ///
            /// <exception cref="ArgumentException">Incorrect length of <paramref name="mask"/>,
            /// or <paramref name="bounds"/> array.</exception>
            /// <exception cref="NotConnectedException">No connection to Qwerk or its service.</exception>
            /// <exception cref="ConnectionLostException">Connestion to Qwerk is lost.</exception>
            ///
            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.");
                }
            }
Exemplo n.º 2
0
            /// <summary>
            /// Set bounds for specified servos.
            /// </summary>
            /// 
            /// <param name="mask">Mask array specifying which servos need to be set.</param>
            /// <param name="bounds">Array of servos' bounds. Each bound may be in [0, 255] range.</param>
            ///
            /// <remarks><para>The method sets servos' physical bounds in which they may move.
            /// See documentation to <see cref="Qwerk.Servos"/> for clarification.</para></remarks>
            /// 
            /// <exception cref="ArgumentException">Incorrect length of <paramref name="mask"/>,
            /// or <paramref name="bounds"/> array.</exception>
            /// <exception cref="NotConnectedException">No connection to Qwerk or its service.</exception>
            /// <exception cref="ConnectionLostException">Connestion to Qwerk is lost.</exception>
            /// 
            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." );
                }
            }