/// <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, NXTOutputMode mode, NXTOutputRegulationMode regulation, NXTOutputRunState runState, int tachoLimit) { Power = power; TurnRatio = turnRatio; Mode = mode; Regulation = regulation; RunState = runState; TachoLimit = tachoLimit; TachoCount = 0; BlockTachoCount = 0; RotationCount = 0; }
public void SetOutputState(NXTOutputPort outputPort, sbyte powerSet, NXTOutputMode mode, NXTOutputRegulationMode regMode, sbyte turnRatio, NXTOutputRunState runState, ulong tachoLimit, bool sendResponse = false) { byte[] command = new byte[13]; byte[] reply = new byte[3]; command[0] = sendResponse ? (byte)NXTCommandType.DIRECT_RESPONSE : (byte)NXTCommandType.DIRECT_NORESPONSE; command[1] = (byte)NXTCommandCode.SETOUTPUTSTATE; command[2] = (byte)outputPort; command[3] = (byte)powerSet; command[4] = (byte)mode; command[5] = (byte)regMode; command[6] = (byte)turnRatio; command[7] = (byte)runState; command[8] = (byte)(tachoLimit); command[9] = (byte)(tachoLimit >> 8); command[10] = (byte)(tachoLimit >> 16); command[11] = (byte)(tachoLimit >> 24); command[12] = (byte)(tachoLimit >> 32); SendCommand(command, reply); }
public void SetOutputState(NXTOutputPort outputPort, sbyte powerSet, NXTOutputMode mode, NXTOutputRegulationMode regMode, sbyte turnRatio, NXTOutputRunState runState, ulong tachoLimit, bool sendResponse=false) { byte[] command = new byte[13]; byte[] reply = new byte[3]; command[0] = sendResponse ? (byte)NXTCommandType.DIRECT_RESPONSE : (byte)NXTCommandType.DIRECT_NORESPONSE; command[1] = (byte)NXTCommandCode.SETOUTPUTSTATE; command[2] = (byte)outputPort; command[3] = (byte)powerSet; command[4] = (byte)mode; command[5] = (byte)regMode; command[6] = (byte)turnRatio; command[7] = (byte)runState; command[8] = (byte)(tachoLimit); command[9] = (byte)(tachoLimit >> 8); command[10] = (byte)(tachoLimit >> 16); command[11] = (byte)(tachoLimit >> 24); command[12] = (byte)(tachoLimit >> 32); SendCommand(command, reply); }
public void OutputState(NXTOutputPort outputPort, sbyte powerSet, NXTOutputMode mode, NXTOutputRegulationMode regMode, sbyte turnRatio, NXTOutputRunState runState, ulong tachoLimit) { Log("--------- Output State ----------------"); Log("Output Port\t= " + outputPort.ToString()); Log("Power Set\t= " + powerSet.ToString()); Log("Output Mode\t= " + mode.ToString()); Log("Regulation Mode\t= " + regMode.ToString()); Log("Turn State\t= " + turnRatio.ToString()); Log("Run State\t= " + runState.ToString()); Log("Tacho Limit\t= " + tachoLimit.ToString()); Log("---------------------------------------"); }