コード例 #1
0
ファイル: MainForm.cs プロジェクト: darius-kia/1819-Core
        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
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: tjrov/1819-Core
        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();
        }