public void ResetMotorPosition(NXTOutputPort outputPort, bool relativeToLastMovement, bool sendResponse = true) { byte[] command = new byte[4]; byte[] reply = new byte[3]; command[0] = sendResponse ? (byte)NXTCommandType.DIRECT_RESPONSE : (byte)NXTCommandType.DIRECT_NORESPONSE; command[1] = (byte)NXTCommandCode.RESETMOTORPOSITION; command[2] = (byte)outputPort; command[3] = (byte)(relativeToLastMovement ? 1 : 0); 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("---------------------------------------"); }
public void GetOutputState(NXTOutputPort outputPort, bool sendResponse = true) { byte[] command = new byte[3]; byte[] reply = new byte[25]; command[0] = sendResponse ? (byte)NXTCommandType.DIRECT_RESPONSE : (byte)NXTCommandType.DIRECT_NORESPONSE; command[1] = (byte)NXTCommandCode.GETOUTPUTSTATE; command[2] = (byte)outputPort; SendCommand(command, reply); if (!sendResponse) { return; } }
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 readconfig(String newFilename) { this.filename = newFilename; this.commands.Clear(); int counter = 0; string line; Command cmd = null; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader(this.filename); while ((line = file.ReadLine()) != null) { Console.WriteLine(line); counter++; if (line[0] == '[') { cmd = new Command(line); continue; } // Grabbing the port string[] words = line.Split(','); NXTOutputPort port = NXTOutputPort.PortA; int direction = Convert.ToInt16(words[1]); int power = Convert.ToInt16(words[2]); if (words[0].Equals("0")) { port = NXTOutputPort.PortA; } else if (words[0].Equals("1")) { port = NXTOutputPort.PortB; } else if (words[0].Equals("2")) { port = NXTOutputPort.PortC; } cmd.motors[(int)port].port = port; cmd.motors[(int)port].direction = direction; cmd.motors[(int)port].power = power; //After last motor add command to list if (port == NXTOutputPort.PortC) { addcommand(cmd); } } file.Close(); // Suspend the screen. Console.ReadLine(); }
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 GetOutputState(NXTOutputPort outputPort, bool sendResponse = true) { byte[] command = new byte[3]; byte[] reply = new byte[25]; command[0] = sendResponse ? (byte)NXTCommandType.DIRECT_RESPONSE : (byte)NXTCommandType.DIRECT_NORESPONSE; command[1] = (byte)NXTCommandCode.GETOUTPUTSTATE; command[2] = (byte)outputPort; SendCommand(command, reply); if (!sendResponse) return; }
public Motor(NXTOutputPort port, int direction, int power) { this.port = port; this.direction = direction; this.power = power; }