Esempio n. 1
0
 // Clears all Jrk and Maestro errors
 public static void clearAllErrors()
 {
     if (NumOfConnectedMaestros > 0)
     {
         usc.clearErrors();
     }
     if (NumOfConnectedJrks > 0)
     {
         Jrk1.clearErrors();
     }
     if (NumOfConnectedJrks > 1)
     {
         Jrk2.clearErrors();
     }
     if (NumOfConnectedJrks > 2)
     {
         Jrk3.clearErrors();
     }
     if (NumOfConnectedJrks > 3)
     {
         Jrk4.clearErrors();
     }
     if (NumOfConnectedJrks == 0)
     {
         MessageBox.Show("No Jrks Found");
     }
     else
     {
         MessageBox.Show("All Jrk and Maestro errors have been cleared.");
     }
 }
Esempio n. 2
0
        static unsafe void displayStatus(Usc usc)
        {
            MaestroVariables variables;
            ServoStatus[] servos;
            short[] stack;
            ushort[] call_stack;
            usc.getVariables(out variables, out stack, out call_stack, out servos);

            Console.WriteLine(" #  target   speed   accel     pos");
            for (int i = 0; i < usc.servoCount; i++)
            {
                Console.WriteLine("{0,2}{1,8}{2,8}{3,8}{4,8}", i,
                    servos[i].target, servos[i].speed,
                    servos[i].acceleration, servos[i].position);
            }

            Console.Write("errors: 0x"+variables.errors.ToString("X4"));
            foreach (var error in Enum.GetValues(typeof(uscError)))
            {
                if((variables.errors & (1<<(int)(uscError)error)) != 0)
                {
                    Console.Write(" "+error.ToString());
                }
            }
            usc.clearErrors();
            Console.WriteLine(); // end the line

            if(variables.scriptDone == 0)
                Console.WriteLine("SCRIPT RUNNING");
            else
                Console.WriteLine("SCRIPT DONE");

            Console.WriteLine("program counter: "+variables.programCounter.ToString());

            Console.Write("stack:          ");
            for (int i = 0; i < variables.stackPointer; i++)
            {
                if(i > stack.Length)
                {
                    Console.Write(" OVERFLOW (stack pointer = "+variables.stackPointer+")");
                    break;
                }
                Console.Write(stack[i].ToString().PadLeft(8, ' '));
            }
            Console.WriteLine();

            Console.Write("call stack:     ");
            for (int i = 0; i < variables.callStackPointer; i++)
            {
                if(i > call_stack.Length)
                {
                    Console.Write(" OVERFLOW (call stack pointer = "+variables.callStackPointer+")");
                    break;
                }
                Console.Write(call_stack[i].ToString().PadLeft(8, ' '));
            }
            Console.WriteLine();
        }
Esempio n. 3
0
        /// <summary>
        /// Connects to a Maestro using native USB and returns the Usc object
        /// representing that connection.  When you are done with the
        /// connection, you should close it using the Dispose() method so that
        /// other processes or functions can connect to the device later.  The
        /// "using" statement can do this automatically for you.
        /// </summary>
        void  connectToDevice()
        {
            try{
                // Get a list of all connected devices of this type.
                if (usbdevice == null)
                {
                    List <DeviceListItem> connectedDevices = Usc.getConnectedDevices();
                    foreach (DeviceListItem dli in connectedDevices)
                    {
                        if ((device == null))//|| (this.device == dli.serialNumber)
                        {
                            // If you have multiple devices connected and want to select a particular
                            // device by serial number, you could simply add a line like this:
                            // if (dli.serialNumber != "00012345"){ continue; }
                            Usc uscdevice = new Usc(dli); // Connect to the device.

                            usbdevice = uscdevice;
                            // Return the device.
                        }
                    }
                }
                if (usbdevice != null)
                {
                    usbdevice.clearErrors();
                    var settings = usbdevice.getUscSettings();
                    settings.channelSettings[channel].mode = ChannelMode.Servo;

                    Console.WriteLine("Set Startup Position Servo " + channel + " to " + settings.channelSettings[channel].home);
                    settings.servoPeriod = 20;


                    usbdevice.setUscSettings(settings, false);
                    //  usbdevice.setAcceleration(channel, 0);
                    usbdevice.setSpeed(channel, 0);
                }
                else
                {
                    throw new Exception("Could not find device.  Make sure it is plugged in to USB " +
                                        "and check your Device Manager (Windows) or run lsusb (Linux).");
                }
            }catch (Exception ex) {
                Console.WriteLine("Fehler beim Verbinden mit dem Servo " + ex.Message + ex.StackTrace.ToString());
            }
        }
Esempio n. 4
0
        static unsafe void displayStatus(Usc usc)
        {
            MaestroVariables variables;

            ServoStatus[] servos;
            short[]       stack;
            ushort[]      call_stack;
            usc.getVariables(out variables, out stack, out call_stack, out servos);

            Console.WriteLine(" #  target   speed   accel     pos");
            for (int i = 0; i < usc.servoCount; i++)
            {
                Console.WriteLine("{0,2}{1,8}{2,8}{3,8}{4,8}", i,
                                  servos[i].target, servos[i].speed,
                                  servos[i].acceleration, servos[i].position);
            }

            Console.Write("errors: 0x" + variables.errors.ToString("X4"));
            foreach (var error in Enum.GetValues(typeof(uscError)))
            {
                if ((variables.errors & (1 << (int)(uscError)error)) != 0)
                {
                    Console.Write(" " + error.ToString());
                }
            }
            usc.clearErrors();
            Console.WriteLine(); // end the line

            if (variables.scriptDone == 0)
            {
                Console.WriteLine("SCRIPT RUNNING");
            }
            else
            {
                Console.WriteLine("SCRIPT DONE");
            }

            Console.WriteLine("program counter: " + variables.programCounter.ToString());

            Console.Write("stack:          ");
            for (int i = 0; i < variables.stackPointer; i++)
            {
                if (i > stack.Length)
                {
                    Console.Write(" OVERFLOW (stack pointer = " + variables.stackPointer + ")");
                    break;
                }
                Console.Write(stack[i].ToString().PadLeft(8, ' '));
            }
            Console.WriteLine();

            Console.Write("call stack:     ");
            for (int i = 0; i < variables.callStackPointer; i++)
            {
                if (i > call_stack.Length)
                {
                    Console.Write(" OVERFLOW (call stack pointer = " + variables.callStackPointer + ")");
                    break;
                }
                Console.Write(call_stack[i].ToString().PadLeft(8, ' '));
            }
            Console.WriteLine();
        }