Example #1
0
        // 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();
        }
Example #2
0
        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();
        }
Example #3
0
 static void configure(Usc usc, string filename)
 {
     Stream file = File.Open(filename, FileMode.Open);
     StreamReader sr = new StreamReader(file);
     List<String> warnings = new List<string>();
     UscSettings settings = ConfigurationFile.load(sr, warnings);
     usc.fixSettings(settings, warnings);
     usc.setUscSettings(settings, true);
     sr.Close();
     file.Close();
     usc.reinitialize();
 }
Example #4
0
        static void configure(Usc usc, string filename)
        {
            Stream        file     = File.Open(filename, FileMode.Open);
            StreamReader  sr       = new StreamReader(file);
            List <String> warnings = new List <string>();
            UscSettings   settings = ConfigurationFile.load(sr, warnings);

            usc.fixSettings(settings, warnings);
            usc.setUscSettings(settings, true);
            sr.Close();
            file.Close();
            usc.reinitialize();
        }
Example #5
0
        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();
        }