void System::updatePacketData() { updateBarometerData(); updateMagnetometerData(); updateAccelerometerData(); updateAnemometerData(); updateWindVaneData(); updateGPSData(); updateBatteryData(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), sentBytes(NULL) { ui->setupUi(this); //---- Menu Configuration ---- machineGroup = new QActionGroup(this); machineGroup->addAction(ui->actionScorpio); machineGroup->addAction(ui->actionQuadcopter); ui->actionScorpio->setChecked(true); viewGroup = new QActionGroup(this); viewGroup->addAction(ui->actionTracking); viewGroup->addAction(ui->actionTracking); viewGroup->addAction(ui->actionManual_Control); viewGroup->addAction(ui->actionCommand_Center); ui->actionCommand_Center->setChecked(true); //---- ---- //---- Statusbar ---- serialConnected=false; gpsFix=false; joystickConnected=false; gpsFooterStat = new QLabel(this); connectedFooterStat = new QLabel(this); joystickFooterStat = new QLabel(this); aliveFooterState = new QLabel(this); connectedGPSFooterStat = new QLabel(this); ui->statusBar->addPermanentWidget(gpsFooterStat); ui->statusBar->addPermanentWidget(connectedFooterStat); ui->statusBar->addPermanentWidget(aliveFooterState); ui->statusBar->addPermanentWidget(joystickFooterStat); ui->statusBar->addPermanentWidget(connectedGPSFooterStat); //---- ---- //---- Compass Graphics View ---- compassPixmap = new QPixmap(":/img/CompassSquare150.png"); ui->compassViewLabel->setPixmap(rotatePixmap(compassPixmap,0)); //---- ---- //---- Speedometer Graphics View ---- ui->speedometerViewLabel->setPixmap(updateSpeedIndicator(0)); //---- ---- //---- Steer Graphics View ---- ui->steerGraphicsView->setStyleSheet("background: transparent"); steerGraphicsScene = new QGraphicsScene(this); QBrush brush(QColor::fromRgb(59,174,227)); steerRailIndicator = steerGraphicsScene->addRect(0,22.5,148,15,Qt::NoPen,brush); brush.setColor(Qt::red); QPen pen(Qt::black); pen.setWidth(2); steerIndicator = steerGraphicsScene->addRect(67.5,5,15,50,Qt::NoPen,brush); updateSteerIndicator(-100); ui->steerGraphicsView->setScene(steerGraphicsScene); //---- ---- //---- Tracker View ---- ui->trackerGraphicsView-> setBackgroundBrush(QBrush(QColor::fromRgb(237,200,90),Qt::Dense4Pattern)); trackerScene = new QGraphicsScene(this); ui->trackerGraphicsView->setScene(trackerScene); QPolygonF NorthArrow; NorthArrow.append(QPointF(-5.,0)); NorthArrow.append(QPointF(0.,-20)); NorthArrow.append(QPointF(5.,0)); NorthArrow.append(QPointF(0.,-5.)); NorthArrow.append(QPointF(-5.,0)); brush.setColor(Qt::black); northArrowGraphicsItem = trackerScene->addPolygon(NorthArrow,Qt::NoPen,brush); northArrowGraphicsItem->setPos(800,10); northArrowGraphicsItem->setFlag(QGraphicsItem::ItemIgnoresTransformations); //Scorpio Graphics Item scorpio2DGraphicsItem = new GraphicsItemScorpio; trackerScene->addItem(scorpio2DGraphicsItem); scorpio2DGraphicsItem->setPos(500,150); wgs2utm(BASE_LATITUDE, BASE_LONGITUDE,&baseEasting,&baseNorthing, &baseUTMZone); lastPoKnown=false; //---- ---- brush.setColor(QColor(255, 0, 0, 180)); targetMarker = trackerScene->addEllipse(400,100,10,10,pen,brush); brush.setColor(QColor(255, 255, 0, 180)); baseMarker = trackerScene->addRect(0,0,10,10,pen,brush); //---- ---- connect(&timerTracker,SIGNAL(timeout()),this,SLOT(updateTrackerGraphics())); //TODO: another sig-slot for updating scene to zoom to fit timerTracker.start(100); //---- ---- ---- ---- //---- Joystick Initialization ---- myJoystick = new RR_SDLJoystick; myJoystickData = new RR_SDLJoystickData_t; QString *joystickInitError; if(!myJoystick->initJoystick(myJoystickData, joystickInitError)){ ui->plainTextEdit->insertPlainText("Error Connecting Joystick"); //TODO: Fix so that the insertPlainText takes the error code from Joystick Object. } else{ ui->plainTextEdit->insertPlainText("Joystick Connected!"); joystickConnected=true; connect(&timerJoystick,SIGNAL(timeout()),myJoystick ,SLOT(pollJoystick())); timerJoystick.start(150); } connect(myJoystick,SIGNAL(gotJoystick()),this,SLOT(updateGaugeIndicators())); connect(myJoystick,SIGNAL(gotJoystick()),this,SLOT(updateJoystickTelemetry())); //---- ---- //---- Serial ---- serialPort = new RR_QtSerial(57600,"COM26"); connect(&timerSerial,SIGNAL(timeout()), serialPort,SLOT(receiveBytes())); connect(ui->actionConnect,SIGNAL(triggered(bool)),serialPort,SLOT(switchSerial(bool))); connect(serialPort,SIGNAL(gotConnected(bool)),this,SLOT(updateSerialStatusBar(bool))); connect(serialPort,SIGNAL(gotConnected(bool)),ui->actionConnect,SLOT(setChecked(bool))); timerSerial.start(150); //----- GPS ------ serialGPSPort = new RR_QtSerial(57600,"COM19"); connect(&timerGPSSerial, SIGNAL(timeout()),serialGPSPort, SLOT(receiveBytes())); connect(ui->actionConnect_GPS, SIGNAL(triggered(bool)), serialGPSPort, SLOT(switchSerial(bool))); connect(serialGPSPort,SIGNAL(gotConnected(bool)),this,SLOT(updateGPSSerialStatusBar(bool))); connect(serialGPSPort,SIGNAL(gotConnected(bool)),ui->actionConnect_GPS,SLOT(setChecked(bool))); timerGPSSerial.start(150); //------- //---- GPS Data Serialization ---- receivedGPSData = new RR_QtTelemetryReceivedData_t; sentGPSData = new RR_QtTelemetrySentData_t; gps = new RR_QtTelemetry(receivedGPSData,sentGPSData); receivedGPSData->fix=false; connect(serialGPSPort,SIGNAL(gotBytes(QByteArray*)),gps,SLOT(decodeBytes(QByteArray*))); connect(gps,SIGNAL(gotDecodedMessage()),this,SLOT(updateGPSData())); //---- ---- //---- Telemetry ---- receivedTelemetryData = new RR_QtTelemetryReceivedData_t; sentTelemetryData = new RR_QtTelemetrySentData_t; telemetry = new RR_QtTelemetry(receivedTelemetryData,sentTelemetryData); receivedTelemetryData->fix=false; connect(this,SIGNAL(gotJoystickMessage()),telemetry,SLOT(sendMessage())); connect(telemetry,SIGNAL(gotEncodedBytes(QByteArray*)),serialPort,SLOT(sendBytes(QByteArray*))); connect(serialPort,SIGNAL(gotBytes(QByteArray*)),telemetry,SLOT(decodeBytes(QByteArray*))); connect(telemetry,SIGNAL(gotDecodedMessage()),this,SLOT(updateTelemetryGraphics())); //---- ---- //---- Text Display ---- connect(&timerSerialPrint,SIGNAL(timeout()),this, SLOT(printStuff())); timerSerialPrint.start(ui->printfreSlider->value()); connect(ui->printfreSlider, SIGNAL(sliderMoved(int)),&timerSerialPrint,SLOT(start(int))); connect(ui->clearPushButton,SIGNAL(clicked()),ui->plainTextEdit,SLOT(clear())); connect(ui->printfreSlider,SIGNAL(sliderMoved(int)),this,SLOT(setPrintFrequencyText())); setPrintFrequencyText(); //---- ---- //---- Test and Debug ---- connect(&timerTestDebug,SIGNAL(timeout()),this,SLOT(testdebug())); timerTestDebug.start(1000); //---- ---- connect(&timerStatusBarUpdate, SIGNAL(timeout()), this, SLOT(updateGPSStatbar())); timerStatusBarUpdate.start(500); //Pulse Check connect(&timerPulseCheck,SIGNAL(timeout()), this, SLOT(checkPulse())); pulseSamplingTime = 5000; timerPulseCheck.start(pulseSamplingTime); }