Esempio n. 1
0
            /// <summary>
            /// Set state of all LEDs.
            /// </summary>
            ///
            /// <param name="ledsMask">Mask array specifying which LED's state need to be set.</param>
            /// <param name="states">Array of LEDs' states.</param>
            ///
            /// <remarks><para>The <paramref name="ledsMask"/> and <paramref name="states"/> arrays specify
            /// which Qwerk's on-board LED's state should be updated. If value of the <paramref name="ledsMask"/>
            /// array is set to <see langword="true"/>, then corresponding LED's state is changed to the state,
            /// which is specified in <paramref name="states"/> array.</para>
            /// </remarks>
            ///
            /// <exception cref="ArgumentException">Incorrect length of LEDs' masks or states array.</exception>
            /// <exception cref="NotConnectedException">No connection to Qwerk or its service.</exception>
            /// <exception cref="ConnectionLostException">Connestion to Qwerk is lost.</exception>
            ///
            public void SetLedsState(bool[] ledsMask, LedState[] states)
            {
                if ((ledsMask.Length != Count) || (states.Length != Count))
                {
                    throw new ArgumentException("Incorrect length of leds' masks or states array.");
                }

                TeRKIceLib.LEDMode[] modes = new TeRKIceLib.LEDMode[Count];

                for (int i = 0; i < Count; i++)
                {
                    modes[i] = modesMapping[(int)states[i]];
                }

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

                try
                {
                    // execute leds' command
                    ledController.execute(new TeRKIceLib.LEDCommand(ledsMask, modes));
                }
                catch
                {
                    throw new ConnectionLostException("Connection is lost.");
                }
            }
            /// <summary>
            /// Set state of all LEDs.
            /// </summary>
            /// 
            /// <param name="ledsMask">Mask array specifying which LED's state need to be set.</param>
            /// <param name="states">Array of LEDs' states.</param>
            /// 
            /// <remarks><para>The <paramref name="ledsMask"/> and <paramref name="states"/> arrays specify
            /// which Qwerk's on-board LED's state should be updated. If value of the <paramref name="ledsMask"/>
            /// array is set to <see langword="true"/>, then corresponding LED's state is changed to the state,
            /// which is specified in <paramref name="states"/> array.</para>
            /// </remarks>
            /// 
            /// <exception cref="ArgumentException">Incorrect length of LEDs' masks or states array.</exception>
            /// <exception cref="NotConnectedException">No connection to Qwerk or its service.</exception>
            /// <exception cref="ConnectionLostException">Connestion to Qwerk is lost.</exception>
            /// 
            public void SetLedsState( bool[] ledsMask, LedState[] states )
            {
                if ( ( ledsMask.Length != Count ) || ( states.Length != Count ) )
                {
                    throw new ArgumentException( "Incorrect length of leds' masks or states array." );
                }

                TeRKIceLib.LEDMode[] modes = new TeRKIceLib.LEDMode[Count];

                for ( int i = 0; i < Count; i++ )
                {
                    modes[i] = modesMapping[(int) states[i]];
                }

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

                try
                {
                    // execute leds' command
                    ledController.execute( new TeRKIceLib.LEDCommand( ledsMask, modes ) );
                }
                catch
                {
                    throw new ConnectionLostException( "Connection is lost." );
                }
            }