Beispiel #1
0
        public void Output(Motor nMotor, int nPower, MotorMode nMode, MotorRegulation nReg, int nTurnRatio, MotorRunState nRunState, long nTacho)
        {
            byte[] data = new byte[12];

            data[0] = 0x80;
            data[1] = 0x04;
            data[2] = (byte)nMotor;
            data[3] = (byte)nPower;
            data[4] = (byte)nMode;
            data[5] = (byte)nReg;
            data[6] = (byte)nTurnRatio;
            data[7] = (byte)nRunState;

            data[8] = (byte)(nTacho & 0xff);
            data[9] = (byte)(nTacho >> 8);
            data[10] = (byte)(nTacho >> 16);
            data[11] = (byte)(nTacho >> 24);

            Tx(data);
        }
Beispiel #2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="MotorState"/> class.
            /// </summary>
            /// 
            /// <param name="power">Power, [-100, 100].</param>
            /// <param name="turnRatio">Turn ratio, [-100, 100].</param>
            /// <param name="mode">Mode (bit field).</param>
            /// <param name="regulation">Regulation mode.</param>
            /// <param name="runState">Run state.</param>
            /// <param name="tachoLimit">The value determines motor's run limit.</param>
            /// 
            public MotorState( int power, int turnRatio, MotorMode mode,
                MotorRegulationMode regulation, MotorRunState runState, int tachoLimit )
            {
                Power      = power;
                TurnRatio  = turnRatio;
                Mode       = mode;
                Regulation = regulation;
                RunState   = runState;
                TachoLimit = tachoLimit;

                TachoCount      = 0;
                BlockTachoCount = 0;
                RotationCount   = 0;
            }
Beispiel #3
0
        public void GetMotorState(Motor port, out byte power, out MotorMode mode, out MotorRegulation regulation, out byte turnRatio, out MotorRunState state, out long tachoLimit, out long tachoCount, out long blockTachoCount, out long rotationCount)
        {
            mre.Reset();
            GetOutputState(port);
            if (!mre.WaitOne(1000, false))
                throw new NxtTimeout();

            if (nError > 0)
                throw new InvalidResult();

            power = result[4];
            mode = (MotorMode)result[5];
            regulation = (MotorRegulation)result[6];
            turnRatio = result[7];
            state = (MotorRunState)result[8];
            tachoLimit = Buffer2Long(result, 9);
            tachoCount = Buffer2SignedLong(result, 13);
            blockTachoCount = Buffer2SignedLong(result, 17);
            rotationCount = Buffer2SignedLong(result, 21);
        }
Beispiel #4
0
        public void GetMotorState(Motor port, out byte power, out MotorMode mode, out MotorRegulation regulation, out byte turnRatio, out MotorRunState state, out long tachoLimit, out long tachoCount, out long blockTachoCount, out long rotationCount)
        {
            mre.Reset();
            GetOutputState(port);
            if (!mre.WaitOne(1000, false))
            {
                throw new NxtTimeout();
            }

            if (nError > 0)
            {
                throw new InvalidResult();
            }

            power           = result[4];
            mode            = (MotorMode)result[5];
            regulation      = (MotorRegulation)result[6];
            turnRatio       = result[7];
            state           = (MotorRunState)result[8];
            tachoLimit      = Buffer2Long(result, 9);
            tachoCount      = Buffer2SignedLong(result, 13);
            blockTachoCount = Buffer2SignedLong(result, 17);
            rotationCount   = Buffer2SignedLong(result, 21);
        }
Beispiel #5
0
        public void Output(Motor nMotor, int nPower, MotorMode nMode, MotorRegulation nReg, int nTurnRatio, MotorRunState nRunState, long nTacho)
        {
            byte[] data = new byte[12];

            data[0] = 0x80;
            data[1] = 0x04;
            data[2] = (byte)nMotor;
            data[3] = (byte)nPower;
            data[4] = (byte)nMode;
            data[5] = (byte)nReg;
            data[6] = (byte)nTurnRatio;
            data[7] = (byte)nRunState;

            data[8]  = (byte)(nTacho & 0xff);
            data[9]  = (byte)(nTacho >> 8);
            data[10] = (byte)(nTacho >> 16);
            data[11] = (byte)(nTacho >> 24);

            Tx(data);
        }
		internal async Task SetOutputStateAsyncInternal(MotorPort motorPort, short power, MotorModes motorMode, MotorRegulationMode motorRegulation,
			short turnRatio, MotorRunState runState, uint tachoLimit)
		{
			await brick.SendCommandAsyncInternal(RequestTelegram.SetOutputState(motorPort, power, motorMode, motorRegulation, 
				turnRatio, runState, tachoLimit));
		}
		SetOutputStateAsync(MotorPort motorPort, short power, MotorModes motorModes, MotorRegulationMode regulationMode,
			short turnRatio, MotorRunState runState, uint tachoLimit)
		{
			return SetOutputStateAsyncInternal(motorPort, power, motorModes, regulationMode, turnRatio, runState, tachoLimit)
#if WINRT
			.AsAsyncAction()
#endif
			;
		}