Beispiel #1
0
        public MainForm()
        {
            //setup window
            InitializeComponent();

            depthIndicator = new DepthIndicator()
            {
                Location = new Point(0, 100)
            };
            attitudeIndicator = new AttitudeIndicator()
            {
                Location = new Point(100, 100)
            };
            headingIndicator = new HeadingIndicator()
            {
                Location = new Point(600, 100)
            };
            Controls.Add(depthIndicator);
            Controls.Add(attitudeIndicator);
            Controls.Add(headingIndicator);

            //setup devices
            BetterSerialPort port = new BetterSerialPort("COM5", 500000);

            port.Open();
            portLabel.Text = string.Format("{0}@{1}baud", port.PortName, port.BaudRate);
            comms          = new SerialCommunication(port);
            comms.Stopped += comms_Stopped;
            comms.Started += comms_Started;
            //comms.Connect();

            depthSensor       = new DepthSensor();
            orientationSensor = new OrientationSensor();
            statusSensor      = new StatusSensor();
            propulsionSensor  = new PropulsionSensor();
            versionSensor     = new VersionSensor();

            statusActuator     = new StatusActuator();
            propulsionActuator = new PropulsionActuator();
            toolsActuator      = new ToolsActuator();

            //update displays when sensors polled
            orientationSensor.Updated += OrientationSensor_Updated;
            depthSensor.Updated       += DepthSensor_Updated;

            //get ROV firmware version info
            comms.Queue.Enqueue(versionSensor);

            //go Fullscreen
            //GoFullscreen(); //do this in the designer
        }
Beispiel #2
0
        public Main()
        {
            //Create Window
            InitializeComponent();
            //Fullscreen = true; //you can always do alt-enter to go fullscreen

            //Custom Window Code
            //(We cannot alter Designer-generated method InitializeComponent())
            comLabel.Text = string.Format("{0}@{1}baud", Properties.Settings.Default.PortName,
                                          Properties.Settings.Default.BaudRate);

            //Setup toolbar menu
            portNameComboBox.Items.AddRange(SerialPort.GetPortNames());
            portNameComboBox.SelectedItem = Properties.Settings.Default.PortName;
            baudRateComboBox.SelectedItem = "" + Properties.Settings.Default.BaudRate;

            //Comms Initialization
            comms = new SerialCommunication(
                new BetterSerialPort(Properties.Settings.Default.PortName,
                                     Properties.Settings.Default.BaudRate));
            comms.Started += OnCommsStarted;
            comms.Stopped += OnCommsStopped;
            comms.CommunicationException += OnCommsException;
            comms.TenElapsed             += OnTenElapsed;
            comms.HundredElapsed         += OnHundredElapsed;
            comms.ThousandElapsed        += OnThousandElapsed;

            //Data Structure Declarations
            List <ESCData>  escDataList  = new List <ESCData>();
            List <ToolData> toolDataList = new List <ToolData>();
            StatusData      status       = new StatusData();

            //Sensor Declarations
            imuSensor     = new OrientationSensor(new OrientationData());
            depthSensor   = new DepthSensor(new DepthData());
            statusSensor  = new StatusSensor(status);
            escSensors    = new PropulsionSensor(escDataList);
            versionSensor = new DiagnosticsSensor(new VersionData());

            //Actuator Declarations
            escActuators   = new PropulsionActuator(escDataList);
            statusActuator = new StatusActuator(status);
            toolActuators  = new ToolsActuator(toolDataList);

            //Controller Method Calls
            Sticks = GetSticks();
        }
Beispiel #3
0
        public MainForm()
        {
            //controller
            pilot        = X.Gamepad_1;
            pilot.Enable = true;
            pilot.Update(); //must call update right after setting enable to true in order for it to connect

            //setup window
            KeyPreview = true;
            InitializeComponent();
            armButton.Enabled   = false;
            resetButton.Enabled = false;

            //setup devices
            string portName = "COM6";

            try
            {
                portName = BetterSerialPort.GetPortNames()[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "No Serial ports available");
            }
            BetterSerialPort port = new BetterSerialPort(portName, 4800);

            portLabel.Text = string.Format("{0}@{1}baud", port.PortName, port.BaudRate);
            comms          = new SerialCommunication(port);
            comms.Stopped += comms_Stopped;
            comms.Started += comms_Started;
            comms.CommunicationException += Comms_CommunicationException;
            //comms.Connect();*/

            rov = new ROV(comms);

            //update displays when sensors polled
            rov.OrientationSensor.Updated += OrientationSensor_Updated;
            rov.DepthSensor.Updated       += DepthSensor_Updated;

            // enumerate video devices
            videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            for (int i = 0; i < videoDevices.Count; i++)
            {
                if (videoDevices[i].Name.Equals("OEM Device"))
                {
                    videoSource = new VideoCaptureDevice(videoDevices[i].MonikerString);
                    videoSource.CrossbarVideoInput = videoSource.AvailableCrossbarVideoInputs[1];
                    videoSource.VideoResolution    = videoSource.VideoCapabilities[1];
                }
            }
            // set NewFrame event handler
            try
            {
                videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
            }
            catch (NullReferenceException potato)
            {
                //fill in later, catch made temporarily to ignore NullReferenceException
            }
            picture.SizeMode = PictureBoxSizeMode.StretchImage;
        }