Ejemplo n.º 1
0
        void MainFormLoad(object sender, System.EventArgs e)
        {
            FindAvailableSerialPorts();
            MakeThrusterGraphs();

            #region Servo init
            servo1         = new AdvancedServo();
            servo1.Attach += new AttachEventHandler(servo1_Attach);
            try{
                servo1.open();
            }
            catch (PhidgetException pe)
            {
                MessageBox.Show(pe.ToString());
            }
            #endregion

            //InitDirectInput();

            cameraAngle1.MaxAngle  = camMaxAngle;
            cameraAngle1.MinAngle  = camMinAngle;
            cameraAngle1.FlipGraph = true;

            errorCheck.Enabled             = true;
            joystickDetectionTimer.Enabled = true;
            timer1.Enabled = true;
            if (serialPort1.IsOpen)
            {
                serialPort1.Close();
            }

            LoadSettings();
        }
Ejemplo n.º 2
0
 public void Attach()
 {
     if (_serialNumber > 0 && _servoBoard == null)
     {
         _servoBoard         = new AdvancedServo();
         _servoBoard.Attach += new AttachEventHandler(ServoBoard_Attach);
         _servoBoard.open(_serialNumber);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Trys to initialize the controller. Returns an exception (no throw). Ensure
        /// you are registered to the PanTiltReady event prior to calling
        /// </summary>
        /// <returns></returns>
        public PanTiltControllerException TryInitialize()
        {
            try
            {
                m_ServoController.open();
            }
            catch (PhidgetException e)
            {
                return(new PanTiltControllerException("Could not open connection to servo controller. Chec driver installation. Is it attached?", e));
            }

            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initialises a configuration form
        /// TODO - refactor
        /// </summary>
        public ConfigurationForm(ref List<Phidget> devicesToBeConfigured, String windowName)
        {
            Helper.Logger("HaptiQ_API.ConfigurationForm.ConfigurationForm::Configuration Form started");
            InitializeComponent();
            this.TopMost = true;

            this._devicesToBeConfigured = devicesToBeConfigured;
            this._windowName = windowName;

            _actuatorsValues = new Tuple<int, int>[MAX_NUMBER_ACTUATORS];

            // Initialise combo boxes - XXX move to separate method
            var servoBoards = new List<int>();
            var intfKits = new List<int>();
            intfKits.Add(0); // no intfKit board
            foreach (Phidget phidget in devicesToBeConfigured)
            {
                if (phidget.GetType() == typeof(AdvancedServo))
                {
                    servoBoards.Add(phidget.SerialNumber);
                }
                else if (phidget.GetType() == typeof(InterfaceKit))
                {
                    intfKits.Add(phidget.SerialNumber);
                }
            }
            ServoBoardsComboBox.DataSource = servoBoards;
            InterfaceKitsComboBox.DataSource = intfKits; 
            ServoBoardsComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            InterfaceKitsComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            ServoBoardsComboBox.SelectedValueChanged += new EventHandler(ServoBoardsComboBox_SelectedValueChanged);
            _currentAdvancedServoBoard = new AdvancedServo();
            _currentAdvancedServoBoard.open((int)ServoBoardsComboBox.SelectedItem);
            _currentAdvancedServoBoard.waitForAttachment();

            InterfaceKitsComboBox.SelectedValueChanged += new EventHandler(InterfaceKitsComboBox_SelectedValueChanged);

            var inputIdentifiers = new List<String>();
            inputIdentifiers.Add("Tag");
            inputIdentifiers.Add("Glyph");
            InputIdentifiersComboBox.DataSource = inputIdentifiers;
            InputIdentifiersComboBox.DropDownStyle = ComboBoxStyle.DropDownList;

            this.TopMost = false;
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            //Declare an Advanced Servo object
            AdvancedServo advServo = new AdvancedServo();

            //Hook the basic event handlers
            advServo.Attach += new AttachEventHandler(advServo_Attach);
            advServo.Detach += new DetachEventHandler(advServo_Detach);
            advServo.Error  += new ErrorEventHandler(advServo_Error);

            //hook the phidget specific event handlers
            //I decided to leave out the current change event handler for readability.
            advServo.PositionChange += new PositionChangeEventHandler
                                           (advServo_PositionChange);
            advServo.VelocityChange += new VelocityChangeEventHandler
                                           (advServo_VelocityChange);

            //open the Servo object for device connections
            advServo.open();

            //Get the program to wait for an Advanced Servo to be attached
            Console.WriteLine("Waiting for Advanced Servo to be attached...");
            advServo.waitForAttachment();

            //Set the initial position for the servo motor.  I set it to 15 here just
            //since I am going to cycle through the positive values to show a basic
            //full movement
            if (advServo.Attached)
            {
                advServo.servos[0].Acceleration  = 1000.00; //max 4590, min 0
                advServo.servos[0].VelocityLimit = 1000.00; //max 1500, min 0
                advServo.servos[0].Position      = 30.00;   //range is -23 to 232
            }

            //Wait for the motor to finish getting to position and let user continue
            Console.WriteLine("Press any key to continue...");
            Console.Read();

            //Move the motor from position value 30 to 200, we sleep for 500
            //milliseconds to give the motor enough time to move to the set position
            if (advServo.Attached)
            {
                advServo.servos[0].Position = 200; //range is -23 to 232
                Thread.Sleep(500);
            }

            //Wait for the events to fire and display, user input will continue the
            //program
            Console.WriteLine("Press any key to end...");
            Console.Read();


            //user input was read so we can terminate the program now, close the
            //AdvancedServo object. Left out the current change event handler for
            //readability.
            advServo.PositionChange -= new PositionChangeEventHandler
                                           (advServo_PositionChange);
            advServo.VelocityChange -= new VelocityChangeEventHandler
                                           (advServo_VelocityChange);

            //user input was read so we can terminate the program now, close the
            //AdvancedServo object
            advServo.close();

            //set the object to null to get it out of memory
            advServo = null;

            Console.WriteLine("ok");
        }
Ejemplo n.º 6
0
		void MainFormLoad(object sender, System.EventArgs e)
		{
            FindAvailableSerialPorts();
            MakeThrusterGraphs();

			#region Servo init
			servo1 = new AdvancedServo();
			servo1.Attach += new AttachEventHandler(servo1_Attach);
			try{
			servo1.open();
			}
			catch (PhidgetException pe)
            {
                MessageBox.Show(pe.ToString());
            }
			#endregion
			
			//InitDirectInput();

            cameraAngle1.MaxAngle = camMaxAngle;
            cameraAngle1.MinAngle = camMinAngle;
            cameraAngle1.FlipGraph = true;

            errorCheck.Enabled = true;
            joystickDetectionTimer.Enabled = true;
			timer1.Enabled = true;
			if(serialPort1.IsOpen){serialPort1.Close();}

            LoadSettings();

		}
Ejemplo n.º 7
0
        private void initialiseServoBoard()
        {
            //Declare an Advanced Servo object
            _advServo = new AdvancedServo();
            //Hook the basic event handlers
            _advServo.Attach += new AttachEventHandler(advServo_Attach);
            _advServo.Detach += new DetachEventHandler(advServo_Detach);
            _advServo.Error += new ErrorEventHandler(advServo_Error);
            _advServo.PositionChange += new PositionChangeEventHandler(advServo_PositionChange);

            _advServo.open(configuration.idServoBoard);
            Helper.Logger("HaptiQ_API.HaptiQ.HaptiQ::Waiting for HaptiQ (" + _id + ") ServoBoard(" + configuration.idServoBoard + ") to be attached.");
            _advServo.waitForAttachment();
            Helper.Logger("HaptiQ_API.HaptiQ.HaptiQ::HaptiQ (" + _id + ") ServoBoard(" + configuration.idServoBoard + ") Connected");
            setAllActuatorsToMinPosition();
        }