Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 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);
        }