Пример #1
0
        public void Process_GetOutputState(byte[] reply)
        {
            if (getOutputDelegate == null)
            {
                return;
            }

            MotorState state = new MotorState();

            state.Power      = (sbyte)reply[4];
            state.Mode       = (NXTOutputMode)reply[5];
            state.Regulation = (NXTOutputRegulationMode)reply[6];
            state.TurnRatio  = (sbyte)reply[7];
            state.RunState   = (NXTOutputRunState)reply[8];

            // tacho limit
            state.TachoLimit = reply[9] | (reply[10] << 8) |
                               (reply[11] << 16) | (reply[12] << 24);
            // tacho count
            state.TachoCount = reply[13] | (reply[14] << 8) |
                               (reply[15] << 16) | (reply[16] << 24);
            // block tacho count
            state.BlockTachoCount = reply[17] | (reply[18] << 8) |
                                    (reply[19] << 16) | (reply[20] << 24);
            // rotation count
            state.RotationCount = reply[21] | (reply[22] << 8) |
                                  (reply[23] << 16) | (reply[24] << 24);

            object[] args = new object[1];
            args[0] = state;
            Program.form1.Invoke(getOutputDelegate, args);
        }
Пример #2
0
        public void Process_GetOutputState(byte[] reply )
        {
            if (getOutputDelegate == null) return;

            MotorState state = new MotorState();
            state.Power = (sbyte)reply[4];
            state.Mode = (NXTOutputMode)reply[5];
            state.Regulation = (NXTOutputRegulationMode)reply[6];
            state.TurnRatio = (sbyte)reply[7];
            state.RunState = (NXTOutputRunState)reply[8];

            // tacho limit
            state.TachoLimit = reply[9] | (reply[10] << 8) |
                    (reply[11] << 16) | (reply[12] << 24);
            // tacho count
            state.TachoCount = reply[13] | (reply[14] << 8) |
                    (reply[15] << 16) | (reply[16] << 24);
            // block tacho count
            state.BlockTachoCount = reply[17] | (reply[18] << 8) |
                    (reply[19] << 16) | (reply[20] << 24);
            // rotation count
            state.RotationCount = reply[21] | (reply[22] << 8) |
                    (reply[23] << 16) | (reply[24] << 24);

            object[] args = new object[1];
            args[0] = state;
            Program.form1.Invoke(getOutputDelegate, args);
        }