// function for evaluating a text file program for the motors public static void runScript(Usc usc, string fileName) { //Getting program text from text file string text = new StreamReader(fileName).ReadToEnd(); MessageBox.Show(text); BytecodeProgram program = BytecodeReader.Read(text, usc.servoCount != 6); BytecodeReader.WriteListing(program, fileName + ".lst"); // Stops any previous scripts that are running usc.setScriptDone(1); // ??? usc.eraseScript(); List <byte> byteList = program.getByteList(); if (byteList.Count > usc.maxScriptLength) { MessageBox.Show("Script too long for device (" + byteList.Count + " bytes)"); } if (byteList.Count < usc.maxScriptLength) { byteList.Add((byte)Opcode.QUIT); } // Setting up subroutines usc.setSubroutines(program.subroutineAddresses, program.subroutineCommands); // Loading the bytes usc.writeScript(byteList); // Restarting usc.reinitialize(); }
static void program(Usc usc, string filename) { string text = (new StreamReader(filename)).ReadToEnd(); BytecodeProgram program = BytecodeReader.Read(text, usc.servoCount != 6); BytecodeReader.WriteListing(program, filename + ".lst"); usc.setScriptDone(1); usc.eraseScript(); List <byte> byteList = program.getByteList(); if (byteList.Count > usc.maxScriptLength) { throw new Exception("Script too long for device (" + byteList.Count + " bytes)"); } if (byteList.Count < usc.maxScriptLength) { byteList.Add((byte)Opcode.QUIT); } System.Console.WriteLine("Setting up subroutines..."); usc.setSubroutines(program.subroutineAddresses, program.subroutineCommands); System.Console.WriteLine("Loading " + byteList.Count + " bytes..."); usc.writeScript(byteList); System.Console.WriteLine("Restarting..."); usc.reinitialize(); }
static void program(Usc usc, string filename) { string text = (new StreamReader(filename)).ReadToEnd(); BytecodeProgram program = BytecodeReader.Read(text, usc.servoCount != 6); BytecodeReader.WriteListing(program,filename+".lst"); usc.setScriptDone(1); usc.eraseScript(); List<byte> byteList = program.getByteList(); if (byteList.Count > usc.maxScriptLength) { throw new Exception("Script too long for device (" + byteList.Count + " bytes)"); } if (byteList.Count < usc.maxScriptLength) { byteList.Add((byte)Opcode.QUIT); } System.Console.WriteLine("Setting up subroutines..."); usc.setSubroutines(program.subroutineAddresses, program.subroutineCommands); System.Console.WriteLine("Loading "+byteList.Count+" bytes..."); usc.writeScript(byteList); System.Console.WriteLine("Restarting..."); usc.reinitialize(); }