Beispiel #1
0
        public void ResetPos(Motor nMotor)
        {
            byte[] data = new byte[4];

            data[0] = 0x80;
            data[1] = 0x0a;
            data[2] = (byte)nMotor;
            data[3] = 0;

            Tx(data);
        }
Beispiel #2
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 #3
0
        public long ReadMotorRotationCount(Motor port)
        {
            mre.Reset();
            GetOutputState(port);
            if (!mre.WaitOne(1000, false))
                throw new NxtTimeout();

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

            return Buffer2SignedLong(result, 21);
        }
Beispiel #4
0
 public bool IsMotorRunning(Motor port)
 {
     return (GetMotorRunState(port) != MotorRunState.Idle);
 }
Beispiel #5
0
        public void GetOutputState(Motor nMotor)
        {
            byte[] data = new byte[3];

            data[0] = 0x00;
            data[1] = 0x06;
            data[2] = (byte)nMotor;

            Tx(data, 25);
        }
Beispiel #6
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 #7
0
        public MotorRunState GetMotorRunState(Motor port)
        {
            mre.Reset();
            GetOutputState(port);
            if (!mre.WaitOne(1000, false))
                throw new NxtTimeout();

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

            return (MotorRunState)result[8];
        }
Beispiel #8
0
 public bool IsMotorRunning(Motor port)
 {
     return(GetMotorRunState(port) != MotorRunState.Idle);
 }