Exemplo n.º 1
0
int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    qmlRegisterType<Graph>("Graph", 1, 0, "Graph");

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    app.setWindowIcon(QIcon(":/content/icon.png"));

    QMLHandlerCppSide alertLamp(engine.rootObjects()[0], "alertLamp");
    QMLHandlerCppSide lineSens(engine.rootObjects()[0], "lineSens");
    QMLHandlerCppSide textAccelX(engine.rootObjects()[0], "textAccelX");
    QMLHandlerCppSide textAccelY(engine.rootObjects()[0], "textAccelY");
    QMLHandlerCppSide textAccelZ(engine.rootObjects()[0], "textAccelZ");
    QMLHandlerCppSide textGyroX(engine.rootObjects()[0], "textGyroX");
    QMLHandlerCppSide textGyroY(engine.rootObjects()[0], "textGyroY");
    QMLHandlerCppSide textGyroZ(engine.rootObjects()[0], "textGyroZ");
    QMLHandlerCppSide textCurStatus(engine.rootObjects()[0], "textCurStatus");
    QMLHandlerCppSide comboSetStatus(engine.rootObjects()[0], "comboSetStatus");
    QMLHandlerCppSide textCurSpeed(engine.rootObjects()[0], "textCurSpeed");
    QMLHandlerCppSide editSetSpeed(engine.rootObjects()[0], "editSetSpeed");
    QMLHandlerCppSide wheels(engine.rootObjects()[0], "wheels");
    QMLHandlerCppSide carAccelY(engine.rootObjects()[0], "carAccelY");
    QMLHandlerCppSide carGyroX(engine.rootObjects()[0], "carGyroX");
    QMLHandlerCppSide carGyroY(engine.rootObjects()[0], "carGyroY");
    QMLHandlerCppSide carGyroZ(engine.rootObjects()[0], "carGyroZ");
    QMLHandlerCppSide statusHistory(engine.rootObjects()[0], "statusHistory");
    QMLHandlerCppSide speedGraph(engine.rootObjects()[0], "speedGraph");
    QMLHandlerCppSide buttonConDiscon(engine.rootObjects()[0], "buttonConDiscon");
    QMLHandlerCppSide buttonSendStatus(engine.rootObjects()[0], "buttonSendStatus");
    QMLHandlerCppSide buttonSendSpeed(engine.rootObjects()[0], "buttonSendSpeed");
    QMLHandlerCppSide buttonCarSelfTest(engine.rootObjects()[0], "buttonCarSelfTest");

    GuiHandler guihandle(&alertLamp, &lineSens, &textAccelX, &textAccelY, &textAccelZ, &textGyroX, &textGyroY, &textGyroZ, &textCurStatus, &comboSetStatus, &textCurSpeed, &editSetSpeed, &wheels, &carAccelY, &carGyroX, &carGyroY, &carGyroZ, &statusHistory, &speedGraph, &buttonConDiscon, &buttonSendStatus, &buttonSendSpeed, &buttonCarSelfTest);
    Robot mikrobi;

    QObject::connect(&guihandle, SIGNAL(buttonConClicked()), &mikrobi, SLOT(connect()));
    QObject::connect(&guihandle, SIGNAL(buttonDisClicked()), &mikrobi, SLOT(disconnect()));
    QObject::connect(&guihandle, SIGNAL(buttonCarSelfTestClicked()), &mikrobi, SLOT(selfTest()));
    QObject::connect(&guihandle, SIGNAL(buttonSendStatusClicked(QString)), &mikrobi, SLOT(status(QString)));
    QObject::connect(&guihandle, SIGNAL(buttonSendSpeedClicked(float)), &mikrobi, SLOT(speed(float)));

    QObject::connect(&mikrobi, SIGNAL(connected()), &guihandle, SLOT(robotConnected()));
    QObject::connect(&mikrobi, SIGNAL(setAlert(int)), &guihandle, SLOT(setAlert(int)));
    QObject::connect(&mikrobi, SIGNAL(disconnected()), &guihandle, SLOT(robotDisconnected()));

    QObject::connect(&mikrobi, SIGNAL(setLedStrip(QVarLengthArray<bool>)), &guihandle, SLOT(setLedStrip(QVarLengthArray<bool>)));
    QObject::connect(&mikrobi, SIGNAL(setTextAccelX(float)), &guihandle, SLOT(setTextAccelX(float)));
    QObject::connect(&mikrobi, SIGNAL(setTextAccelY(float)), &guihandle, SLOT(setTextAccelY(float)));
    QObject::connect(&mikrobi, SIGNAL(setTextAccelZ(float)), &guihandle, SLOT(setTextAccelZ(float)));
    QObject::connect(&mikrobi, SIGNAL(setTextGyroX(float)), &guihandle, SLOT(setTextGyroX(float)));
    QObject::connect(&mikrobi, SIGNAL(setTextGyroY(float)), &guihandle, SLOT(setTextGyroY(float)));
    QObject::connect(&mikrobi, SIGNAL(setTextGyroZ(float)), &guihandle, SLOT(setTextGyroZ(float)));
    QObject::connect(&mikrobi, SIGNAL(setTextStatus(QString)), &guihandle, SLOT(setTextStatus(QString)));
    QObject::connect(&mikrobi, SIGNAL(setTextSpeed(float)), &guihandle, SLOT(setTextSpeed(float)));
    QObject::connect(&mikrobi, SIGNAL(setWheels(QVarLengthArray<float>, const float)), &guihandle, SLOT(setWheels(QVarLengthArray<float>, const float)));
    QObject::connect(&mikrobi, SIGNAL(setCarAccelY(QVarLengthArray<float>, float)), &guihandle, SLOT(setCarAccelY(QVarLengthArray<float>, float)));
    QObject::connect(&mikrobi, SIGNAL(setCarGyroX(float)), &guihandle, SLOT(setCarGyroX(float)));
    QObject::connect(&mikrobi, SIGNAL(setCarGyroY(float)), &guihandle, SLOT(setCarGyroY(float)));
    QObject::connect(&mikrobi, SIGNAL(setCarGyroZ(float)), &guihandle, SLOT(setCarGyroZ(float)));
    QObject::connect(&mikrobi, SIGNAL(drawSpeedGraph(float)), &guihandle, SLOT(drawSpeedGraph(float)));
    QObject::connect(&mikrobi, SIGNAL(setTextStatus(QString)), &guihandle, SLOT(addStatusHistory(QString)));

    return app.exec();
}
Exemplo n.º 2
0
MissionWidget::MissionWidget(QWidget *parent, QString mName, JoystickWidget *joystick,  Ui::NautilusCommander *gui, SendAction *sa) :
    QWidget(parent)
{
     this->missionName=mName;
     this->ui=gui;

     m_sSettingsFile = QString("%1/%2/settings.ini").arg(createPath("Missions")).arg(missionName);
     loadSettings();

     //Create Mission Folder.
     QString missionFolder=QString("%1/%2").arg(createPath("Missions")).arg(missionName);
     if(!QDir(missionFolder).exists()){
         QDir().mkdir(missionFolder);
     }

    lblLightsOff=ui->label_switchOff;
    lblLightsOn=ui->label_switchOn;
    lblLightsOn->setVisible(false);
    islightsOn=false;

    righLeft=-1;
    upDown=-1;

    statusVideoOff=ui->statusVideoOff;
    statusVideoOff->setVisible(true);
    isRecording=false;

    lblScreenShot=ui->label_toastSS;
    lblScreenShot->setVisible(false);


    missionNameLabel=ui->lblMissionName;
    missionNameLabel->setText(missionName);

    batteryROVPB=ui->progressBattRov;
    panCamera=ui->panCamera;
    tiltCamera=ui->tiltCamera;

    statusErrorBox=ui->statusErrorBox;
    statusErrorBox->setVisible(false);
    lblError=ui->lblError;


    sendAction=sa;
    connect(this->sendAction,SIGNAL(offline()),this,SLOT(robotDisconnected()));
    status=checkStatus();

    if(status!=-1)
    sendAction->sendComando(START_ROBOT);  //ReEnable the robot


    /********************************  Joystick *****************************************************/
    this->joystick=joystick;
    connect(joystick,SIGNAL(updateStatus(bool)),this,SLOT(updateControlStatus(bool)));
    connect(this->joystick,SIGNAL(joystickAxisEvent(QString,int)),this,SLOT(axisEvent(QString,int)));
    connect(this->joystick,SIGNAL(joystickButtonEvent(QString, QGameControllerButtonEvent*)),this,SLOT(buttonEvent(QString,QGameControllerButtonEvent*)));

    rtsp=new openRTSP(0,missionName,numVideos);
    connect(this,SIGNAL(saveVideo()),rtsp,SLOT(saveVideo()));


    dataThread=new DataThread(ui->progressBattControl, ui->progressBattRov,ui->labelDepthValue);
    dataThread->start();



    mplayer=ui->mplayerWG;    
    //connect(mplayer,SIGNAL(stateChanged(int)),this,SLOT(updatePlayerStatus(int)));
    mplayer->start();    
    mplayer->load("rtsp://*****:*****@10.5.5.110:554");
    mplayer->setVisible(true);


    isCameraOnline=true;

    speedDial=ui->dial;
    speedDial->setNotchesVisible(false);

    speeds[0][0]=3;speeds[0][1]=10;speeds[0][2]=14;speeds[0][3]=20;//speeds[0][4]=13;//speeds[0][5]=15;speeds[0][6]=18;speeds[0][7]=22;
    speeds[1][0]=1580;speeds[1][1]=1610;speeds[1][2]=1640;speeds[1][3]=1670;//speeds[1][4]=1670;
    speeds[2][0]=1420;speeds[2][1]=1390;speeds[2][2]=1360;speeds[2][3]=1330;//speeds[2][4]=1330; y = 3000-x
    dialIndex=0;
    lastCommand="";
    speedDial->setValue(speeds[0][0]);

}