Exemplo n.º 1
0
/**
 * SLOT
 * Takes a shot from the local player.
 * Places the shot on the oponents board or send the
 * coordinates through the network.
 * @param index
 */
bool Battleships::playersShoot(const int index)
{
    setLocalePlayersTurn(false);
    addShoot();
    bool isHit = false;
    if (m_playerMode == SinglePlayer) {
        const Ship *hiddenShip = m_foesGameBoard->shootAt(index);
        if (hiddenShip) {
            setInfoText("You hit one of the ships.");
        } else {
            setInfoText("You shot into the water.");
        }
        if (! m_foesGameBoard->hasUndestroyedShip()) {
            setWinnerName(playerName());
            setCurrentView("GameOverDialog");
        }
        emit botShoot();
    } else {
        m_indexLastShot = index;
        QJsonObject object;
        object.insert("type", "SHOT");
        QJsonObject options;
        QPoint pt = m_foesGameBoard->getPointObject(index);
        options.insert("x", pt.x());
        options.insert("y", pt.y());
        object.insert("options", options);
        QJsonDocument *message = new QJsonDocument(object);
        emit sendMessage(message);
    }

    return isHit;
}
Exemplo n.º 2
0
//! Create Scene
void MapDrivePlugIn::open(){
  irr::scene::ISceneManager* SMgr = 0;
  irr::scene::ISceneNode* SRoot = 0;
  if(irrPointers.SMgr){
    SMgr = irrPointers.SMgr;
    SRoot = irrPointers.SMgr->getRootSceneNode();
#ifdef useIrrExtensions13
    //! Create "ground plane"
    if(nGround) irrPointers.SMgr->addToDeletionQueue(nGround);
    nGround = irrPointers.SMgr->addGridSceneNode();
    nGround->setPosition(irr::core::vector3df(0,0,0));
    nGround->setAccentlineColor(nGround->getGridColor());
#endif
  }

  // make new MapDriver
  vehicle = new MapDriver(SMgr, SRoot);
  vehicles.push_back(vehicle);
  OpenSteerDemo::selectedVehicle = vehicle;
  // marks as obstacles map cells adjacent to the path
  usePathFences = true;
  // scatter random rock clumps over map
  useRandomRocks = true;
  setInfoText(Text2);
}
Exemplo n.º 3
0
//! Create Scene
void CtfPlugIn::open(){
  irr::scene::ISceneManager* SMgr = 0;
  irr::scene::ISceneNode* SRoot = 0;
  if(irrPointers.SMgr){
    SMgr = irrPointers.SMgr;
    SRoot = irrPointers.SMgr->getRootSceneNode();
#ifdef useIrrExtensions13
    //! Create "ground plane"
    if(nGround) irrPointers.SMgr->addToDeletionQueue(nGround);
    nGround = irrPointers.SMgr->addGridSceneNode();
    nGround->setPosition(irr::core::vector3df(0,0,0));
    nGround->setAccentlineColor(nGround->getGridColor());
#endif
  }
  resetCount = 0;
  // create the seeker ("hero"/"attacker")
  ctfSeeker = new CtfSeeker(SMgr, SRoot);
  all.push_back(ctfSeeker);
  // create the specified number of enemies,
  // storing pointers to them in an array.
  for(int i = 0; i < maxEnemyCount; i++){
    ctfEnemies[i] = new CtfEnemy(SMgr, SRoot);
    all.push_back(ctfEnemies[i]);
  }
  lstObstacleMesh.clear();
  CtfBase::obstacleCount = -1;
  CtfBase::initializeObstacles();

  setInfoText(Text2);
}
Exemplo n.º 4
0
void RemoteOM::connectSocket()
{
    if (socket && socket->state() == QTcpSocket::ConnectedState)
    {
        closeSocket();
        ui->ledPower->hide();
        setInfoText("Connection closed");
        return;
    }

    if (socket->state() != QAbstractSocket::ConnectedState)
    {
        QString ipaddress = "";
        QString port = "";

        ipaddress = dialog->set_ipaddress;
        port = dialog->set_port;

        if (ipaddress.isEmpty() || port.isEmpty())
        {
            QMessageBox::information(this, tr("Remote OM"), tr("Please select settings."));
            return;
        }
        socket->connectToHost(ipaddress, port.toInt());
        if (!socket->waitForConnected(5000)) {
            emit error(socket->error());
            return;
        }

        if (socket && socket->state() == QAbstractSocket::ConnectedState)
        {
            setInfoText("Connected to Remote OM.");
            ui->ledPower->show();
        }
        else
        {
            setInfoText("The host was not found. Please check the host name and port settings.");
        }
    }

    connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(displayError(QAbstractSocket::SocketError)));
    connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
                SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
                Qt::DirectConnection);
}
void GLWidget::updateGyroY(double gyroY_)
{
    dataFlowing = 1;
    setInfoText("");
    gyroY = gyroY_;
    if (abs(gyroY - 1650) < 20) gyroY = 1650;
    gyroY -= 1650;
}
Exemplo n.º 6
0
void RemoteOM::on_buttonReset_clicked()
{
    setInfoText("Resetting PA.");

    QByteArray temp;
    temp.append(82);
    sendData(temp);
}
Exemplo n.º 7
0
/**
 * Simulates a bot behaviour. Shoots randomly to the locale
 * players game board.
 * @return          True if bot hit a ship.
 */
bool Battleships::botShoot()
{
    ShipPosition position = getRandomShipPosition(m_playersGameBoard->getGameBoardSize());
    const Ship* hiddenShip = m_playersGameBoard->shoot(position.x, position.y);
    if (hiddenShip != 0) {
        setInfoText("One of your ships is hidden.");
    } else {
        setInfoText("Foe shot into the water.");
    }
    if (! m_playersGameBoard->hasUndestroyedShip()) {
        setWinnerName("Foe");
        setCurrentView("GameOverDialog");
    }
    setLocalePlayersTurn(true);

    return (hiddenShip != 0);
}
Exemplo n.º 8
0
/**
 * Interpret shot replay message.
 * @param object
 */
void Battleships::shotReplay(const QJsonObject &object)
{
    QModelIndex fieldIndex = m_foesGameBoard->index(m_indexLastShot);
    QJsonObject options = object.value("options").toObject();
    if (options.value("result") == "miss") {
        m_foesGameBoard->setData(fieldIndex, QVariant(Board::HiddenField), Board::ModifyFieldStateRole);
        setInfoText("Shot went into water.");
    }
    else if (options.value("result") == "hit") {
        m_foesGameBoard->setData(fieldIndex, QVariant(Board::HiddenShip), Board::ModifyFieldStateRole);
        setInfoText("You hit a ship.");
    }
    else if (options.value("result") == "sunk") {
        m_foesGameBoard->setData(fieldIndex, QVariant(Board::HiddenShip), Board::ModifyFieldStateRole);
        setInfoText(options.value("ship").toString() + " hit and sunk.");
    }
}
Exemplo n.º 9
0
void RemoteOM::on_buttonFaults_clicked()
{
    setInfoText("Listing 20 last fault codes.");

    QByteArray temp;
    temp.append(70);
    sendData(temp);

}
Exemplo n.º 10
0
//! Create Scene
void MicTestPlugIn::open(){
  irr::scene::ISceneManager* SMgr = 0;
  irr::scene::ISceneNode* SRoot = 0;
  if(irrPointers.SMgr){
    SMgr = irrPointers.SMgr;
    SRoot = irrPointers.SMgr->getRootSceneNode();
#ifdef useIrrExtensions13
    //! Create "ground plane"
    if(nGround) irrPointers.SMgr->addToDeletionQueue(nGround);
    nGround = irrPointers.SMgr->addGridSceneNode(1,2);
    nGround->setPosition(irr::core::vector3df(0,0,0));
    nGround->setScale(irr::core::vector3df(20,0,10));
    nGround->setAccentlineColor(nGround->getGridColor());
    //! Create "nGoal1"
    if(nGoal1) irrPointers.SMgr->addToDeletionQueue(nGoal2);
    nGoal1 = irrPointers.SMgr->addGridSceneNode(1,2);
    nGoal1->setPosition(irr::core::vector3df(-20,0,0));
    nGoal1->setScale(irr::core::vector3df(1,0,7));
    nGoal1->setAccentlineColor(nGoal1->getGridColor());
    //! Create "nGoal2"
    if(nGoal2) irrPointers.SMgr->addToDeletionQueue(nGoal2);
    nGoal2 = irrPointers.SMgr->addGridSceneNode(1,2);
    nGoal2->setPosition(irr::core::vector3df(20,0,0));
    nGoal2->setScale(irr::core::vector3df(1,0,7));
    nGoal2->setAccentlineColor(nGoal2->getGridColor());
#endif
  }
  // Make a field
  m_bbox = new AABBox(Vec3(-20,0,-10), Vec3(20,0,10));
  // Red goal
  m_TeamAGoal = new AABBox(Vec3(-21,0,-7), Vec3(-19,0,7));
  // Blue Goal
  m_TeamBGoal = new AABBox(Vec3(19,0,-7), Vec3(21,0,7));
  // Make a ball
  m_Ball = new Ball(m_bbox, SMgr, SRoot);
  // Build team A
  m_PlayerCountA = 8;
  for(unsigned int i=0; i < m_PlayerCountA ; i++){
    Player* pMicTest = new Player(TeamA, m_AllPlayers, m_Ball, true, i, SMgr, SRoot);
    pMicTest->Mesh.setColor(irr::video::SColor(255, 0,200,0));
    TeamA.push_back(pMicTest);
    m_AllPlayers.push_back(pMicTest);
  }
  // Build Team B
  m_PlayerCountB = 8;
  for(unsigned int i=0; i < m_PlayerCountB ; i++){
    Player *pMicTest = new Player(TeamB, m_AllPlayers, m_Ball, false, i, SMgr, SRoot);
    pMicTest->Mesh.setColor(irr::video::SColor(255, 0,0,200));
    TeamB.push_back(pMicTest);
    m_AllPlayers.push_back(pMicTest);
  }
  OpenSteerDemo::selectedVehicle = m_Ball;
  m_redScore = 0;
  m_blueScore = 0;
  setInfoText(Text2);
}
DialogReconstructMarkerRecords::DialogReconstructMarkerRecords(QWidget *parent) :
    QFDialog(parent),
    ui(new Ui::DialogReconstructMarkerRecords)
{
    ui->setupUi(this);
    setWindowTitle("Reconstruct Marker Records");
    setInfoText(0,0);
    connect(ui->comboBox, SIGNAL(currentIndexChanged(QString)),this,SLOT(setLabelTextChannel(QString)));
    ui->radioButtonReconstruct->toggle();
}
Exemplo n.º 12
0
//Socket calls
void RemoteOM::on_buttonPower_clicked()
{
    //Try connect socket if not connected
    //qDebug() << "Socket state power button clicked " << socket->state();
    if (socket->state() != QAbstractSocket::ConnectedState)
    {
        connectSocket();

        if (socket && socket->state() == QAbstractSocket::ConnectedState)
        {
            setInfoText("Connected to Remote OM.");
            ui->ledPower->show();
        }
        else
        {
            setInfoText("The host was not found. Please check the host name and port settings.");
            return;
        }
    }

    //Turn PA on
    if(ui->ledPA->isHidden())
    {
        setInfoText("Turning PA on.");

        QByteArray temp;
        temp.append(62);
        sendData(temp);
        ui->ledPA->show();

    }
    else
    {
        setInfoText("Turning PA off.");

        QByteArray temp;
        temp.append(60);
        sendData(temp);
        ui->ledPA->hide();
    }

}
Exemplo n.º 13
0
void RemoteOM::on_buttonOperate_clicked()
{

    //Turn to opearate mode
    if (ui->ledOperate->isHidden())
    {
        setInfoText("Turn to operating mode.");

        QByteArray temp;
        temp.append(79);
        sendData(temp);
    }
    else
    {
        setInfoText("Turn to stand by mode.");

        QByteArray temp;
        temp.append(83);
        sendData(temp);
    }
}
Exemplo n.º 14
0
//
//  STOP
//
bool CFtpd::stop() {
    
    // Stopping server needs calling WaitForSingleObject, which would block the application
    // If it's run from the main application thread.
    // So let's start another thread
    unsigned long   ThreadAddr;
    m_StopServerThread = CreateThread(NULL, 50, StopServerThread, this, 0, &ThreadAddr);

    log(LOG_DEBUG, "DEBUG - smallftpd server was stopped - CFtpd::stop()\r\n");
    
    setInfoText(INFO_SERVER_STOPPED);
    return true;
}
Exemplo n.º 15
0
void RemoteOM::closeSocket()
{
    if (socket && socket->state() == QAbstractSocket::ConnectedState)
    {
        //TURN PA OFF
        QByteArray temp;
        temp.append(60);
        sendData(temp);
        ui->ledPA->hide();

        socket->waitForBytesWritten();
        setInfoText("Closing connection and software, please wait.");
        socket->close();
    }
}
Exemplo n.º 16
0
/**
 * Take a shot from oponent.
 * Send replay message.
 * @param object
 */
void Battleships::takeShot(const QJsonObject &object)
{
    QJsonObject options = object.value("options").toObject();
    quint8 x = options.value("x").toInt();
    quint8 y = options.value("y").toInt();
    const Ship *hiddenShip = m_playersGameBoard->shoot(x, y);
    QJsonObject replayObject;
    replayObject.insert("type", "SHOT_REPLAY");
    QJsonObject replayOptions;
    replayObject.insert("options", replayOptions);
    if (hiddenShip != 0) {
        replayOptions.insert("result", "hit");
        if (hiddenShip->isDestroyed()) {
            replayOptions.insert("result", "sunk");
            replayOptions.insert("ship", hiddenShip->name());
            QList<QPoint> pointList = hiddenShip->getPointList();
            replayOptions.insert("fields", getJsonArrayOfPointList(pointList));
        }
        setInfoText("Incoming fire hit a ship.");
    } else {
        replayOptions.insert("result", "miss");
        setInfoText("Incoming fire goes into water.");
    }
    QJsonDocument *message = new QJsonDocument(replayObject);
    emit sendMessage(message);
    // Is game over ?
    if (hiddenShip->isDestroyed() && ! m_playersGameBoard->hasUndestroyedShip()) {
        QJsonObject finishedObject;
        finishedObject.insert("type", "FINISHED");
        QJsonObject finishedOptions;
        finishedOptions.insert("reason", "won");
        QJsonDocument *message = new QJsonDocument(finishedObject);
        emit sendMessage(message);
    }
    setLocalePlayersTurn(true);
}
Exemplo n.º 17
0
void RemoteOM::sendData(QByteArray input)
{

    //Try connect socket
    if (socket->state() == QAbstractSocket::ConnectedState)
    {        
        socket->write(input);
        sent = input.at(0);
    }
    else
    {
        setInfoText("The host was not found. Please check the host name and port settings.");
    }

}
Exemplo n.º 18
0
/**
 * Got a finished message over network.
 * Interpret the reason.
 * @param object
 */
void Battleships::finishedMessage(const QJsonObject &object)
{
    QJsonObject options = object.value("options").toObject();
    if (options.value("reason") == "won") {
        setInfoText("You have won the game.");
        setWinnerName(m_playerName);
        setCurrentView("GameOverDialog");
    }
    else if (options.value("reason") == "quit") {
        setWinnerName("No one");
        setCurrentView("GameOverDialog");
    }
    else if (options.value("reason") == "error") {
        // Error ?
    }
    emit closeConnection();
}
Exemplo n.º 19
0
//
//  START
//
bool CFtpd::start() {
    SOCKADDR_IN     sockAddr;
    unsigned long   ThreadAddr;
    int nRet;


    m_ShouldStop = false;
    // log(LOG_DEBUG, LOG_STARTING);

    // Create the SOCKET
    // log(DEBUG_FILE, "Creating socket %d\r\n", m_ListeningSock);

    // Start Winsock up
    int nCode;
    WSAData wsaData;
    if ((nCode = WSAStartup(MAKEWORD(1, 1), &wsaData)) != 0) {
        log(LOG_DEBUG, "ERROR - WSAStartup() returned error code %d - CFtpd::start()\r\n", nCode);
    }

    m_ListeningSock = socket(PF_INET, SOCK_STREAM, 0);
    if (m_ListeningSock == INVALID_SOCKET) {
        log(LOG_DEBUG, "ERROR - %s - CFtpd::start()", LOG_ERROR_SOCKET);
        stop();
        return false;
    }

    // log(LOG_DEBUG, "Socket %d created\r\n", m_ListeningSock);

    // Define the SOCKET address
    sockAddr.sin_family = PF_INET;
    sockAddr.sin_port = htons(m_ListeningPort);
    sockAddr.sin_addr.s_addr = INADDR_ANY;

    // log(LOG_DEBUG, "Socket %d address defined\r\n", m_ListeningSock);

    // Bind the SOCKET
    nRet = bind(m_ListeningSock,(SOCKADDR *)&sockAddr, sizeof(SOCKADDR_IN));
    if (nRet == SOCKET_ERROR) {
        log(LOG_DEBUG, "ERROR - %s - CFtpd::start()", LOG_ERROR_BIND);
        stop();
        setInfoText(INFO_COULD_NOT_BIND);
        return false;
    }
    
    // log(LOG_DEBUG, "Socket %d bound\r\n", m_ListeningSock);

    // Listen for an incoming connection
    nRet = listen(m_ListeningSock, SOMAXCONN);
    if (nRet == SOCKET_ERROR) {
        log(LOG_DEBUG, "ERROR - %s - CFtpd::start()", LOG_ERROR_LISTEN);
        stop();
        return false;
    }

    // Start of the ListenThread
    m_ListeningThread = CreateThread(NULL, 50, ListenThread, this, 0, &ThreadAddr);
    if (m_ListeningThread == NULL) {
        log(LOG_DEBUG, "ERROR - %s - CFtpd::start()", LOG_ERROR_CREATE_THREAD);
        stop();
        return false;
    }
    // SetThreadPriority(listenThread, THREAD_PRIORITY_LOWEST);

    // log(LOG_DEBUG, LOG_STARTED);
    m_IsRunning = true;

    log(LOG_DEBUG, "DEBUG - ------------------------------------------\r\n");
    log(LOG_DEBUG, "DEBUG - smallftpd server was started\r\n");
    log(LOG_DEBUG, "DEBUG - smallftpd is now listening on port %d\r\n", m_ListeningPort);

    setInfoText(INFO_SERVER_RUNNING);
    return true;
}
Exemplo n.º 20
0
//Socket functions
void RemoteOM::readyRead()
{
    QByteArray bytes = socket->readAll();
    QString read(bytes);
    socket->flush();

    if (bytes.isNull() || bytes.isEmpty())
        return;

    //Read password
    if (read.contains("Password"))
    {
        QString password = dialog->set_password;
        if ( password.length() <= 0)
        {
            QMessageBox::information(this, tr("Remote OM"),
                                     tr("The connection requires a password. Please, define password in settings."));
            return;
        }

        setInfoText("Authenticating connection.");

        for(int i = 0; i < password.length(); i++)
        {
            QChar c = password.at(i).toAscii();
            QByteArray parr;
            parr.append(c);
            sendData(parr);
        }

        QByteArray temp;
        temp.append(13);
        sendData(temp);

        authenticate = true;

        return;
    }

    //Read faults.
    if (read.contains("LAST 20 FAULTS:"))
    {
        receiveFaults = true;
    }

    //Read all to faultBuffer until ASCII space is received
    if (receiveFaults)
    {
        for(int i = 0; i < bytes.length(); i++)
        {
            uchar t = (uchar)bytes.at(i);
            if (faultBuffer.size() > 20)
            {
                receiveFaults = false;
            }
            else
            {
                faultBuffer.append(t);
                return;
            }
        }
    }

    //Read faultBuffer first and then continue normally
    if (!receiveFaults && faultBuffer.size() > 1)
    {

        for(int i = 0; i < faultBuffer.length(); i++)
        {
            uchar t = (uchar)faultBuffer.at(i);
            //Receive faults
            switch (t)
            {
            case 48:
                setInfoText(mapResponse[48]);
                break;
            case 49:
                setInfoText(mapResponse[49]);
                break;
            case 50:
                setInfoText(mapResponse[50]);
                break;
            case 51:
                setInfoText(mapResponse[51]);
                break;
            case 52:
                setInfoText(mapResponse[52]);
                break;
            case 53:
                setInfoText(mapResponse[53]);
                break;
            case 54:
                setInfoText(mapResponse[54]);
                break;
            case 55:
                setInfoText(mapResponse[55]);
                break;
            case 56:
                setInfoText(mapResponse[56]);
                break;
            default:
                break;
            }
        }
        faultBuffer.clear();
    }

    for(int i = 0; i < bytes.length(); i++)
    {

        uchar t = (uchar)bytes.at(i);

        if (t > 127)
        {
            int d = (int)t;
            d = d - 128;

            ui->progressBar->setValue(d*1.4);
            return;
        }

        switch (t)
        {
        case 10:
            authBuffer.append(t);
            break;
        case 13:
            if (authenticate && authBuffer.at(0) == 10 && socket->state() == QAbstractSocket::ConnectedState)
            {
                setInfoText("Authentication succeeded");
            }
            else
            {
                setInfoText("Authentication failed.");
            }

            authenticate = false;
            authBuffer.clear();
            break;
        case 62:
            setInfoText(mapResponse[62]);
            ui->ledPA->show();
            sent = "";
            break;
        case 60:
            setInfoText(mapResponse[60]);
            ui->ledPA->hide();
            sent = "";
            stopFaultBlinking();
            stopWaitBlinking();
            break;
        case 83:
            setInfoText(mapResponse[83]);
            if (ui->ledStdby->isHidden())
                ui->ledStdby->show();

            if (!ui->ledOperate->isHidden())
                ui->ledOperate->hide();

            if (ui->ledPA->isHidden())
                ui->ledPA->show();

            stopWaitBlinking();
            sent = "";
            break;
        case 79:
            setInfoText(mapResponse[79]);
            if (ui->ledOperate->isHidden())
                ui->ledOperate->show();

            if (!ui->ledStdby->isHidden())
                ui->ledStdby->hide();

            if (ui->ledPA->isHidden())
                ui->ledPA->show();

            stopWaitBlinking();
            sent = "";
            break;
        case 76:
            setInfoText(mapResponse[76]);
            sent = "";
            receiveFaults = true;
            break;
        case 71:
            setInfoText(mapResponse[71]);
            sent = "";
            stopFaultBlinking();
            break;
        case 87:
            setInfoText(mapResponse[87]);

            if (ui->ledPA->isHidden())
                ui->ledPA->show();

            waitTimer->start(500);
            break;
        case 90:
            setInfoText(mapResponse[90]);
            ui->ledOperate->hide();

            stopWaitBlinking();
            ui->ledGrid->hide();
            ui->ledDrive->hide();
            ui->ledTune->hide();
            ui->ledSwr->hide();
            ui->ledStdby->show();

            break;
        case 84:
            setInfoText(mapResponse[84]);
            if (ui->ledFault->isHidden())
                ui->ledFault->show();

            break;
        case 49:
            setInfoText(mapResponse[49]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
            }
            else
            {
                ui->ledFault->hide();
            }

            startFaultTimer();
            break;
        case 50:
            setInfoText(mapResponse[50]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
            }
            else
            {
                ui->ledFault->hide();
            }

            startFaultTimer();
            break;
        case 51:
            setInfoText(mapResponse[51]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
                ui->ledSwr->show();
            }
            else
            {
                ui->ledFault->hide();
                ui->ledSwr->hide();
            }

            startFaultTimer();
            break;
        case 52:
            setInfoText(mapResponse[52]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
                ui->ledGrid->show();
            }
            else
            {
                ui->ledFault->hide();
                ui->ledGrid->hide();
            }

            startFaultTimer();
            break;
        case 53:
            setInfoText(mapResponse[53]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
                ui->ledDrive->show();
            }
            else
            {
                ui->ledFault->hide();
                ui->ledDrive->hide();
            }

            startFaultTimer();
            break;
        case 54:
            setInfoText(mapResponse[54]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
            }
            else
            {
                ui->ledFault->hide();
            }

            startFaultTimer();
            break;
        case 55:
            setInfoText(mapResponse[55]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
                ui->ledGrid->show();
            }
            else
            {
                ui->ledFault->hide();
                ui->ledGrid->hide();
            }

            startFaultTimer();
            break;
        case 56:
            setInfoText(mapResponse[56]);
            if (ui->ledFault->isHidden())
            {
                ui->ledFault->show();
                ui->ledTune->show();
            }
            else
            {
                ui->ledFault->hide();
                ui->ledTune->hide();
            }

            startFaultTimer();
            break;
        default:
            break;
        }
    }

    //Send not replied. Do one re-send.
    if  (sent.length() > 0)
    {

        QByteArray temp;
        temp.append(sent);
        sendData(temp);
        sent = "";
    }

}
void GLWidget::deviceFound(QMap<QString, QVariant> params)
{
    devicePresent = 1;
    setInfoText("waiting for data...");
}
Exemplo n.º 22
0
RemoteOM::RemoteOM(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::RemoteOM)
{

    mapResponse[48] = "No fault";
    mapResponse[49] = "IP. Plate current too high.";
    mapResponse[50] = "HV. Plate/anode voltage too low.";
    mapResponse[51] = "SWR. Excessive reflected power.";
    mapResponse[52] = "Ig2. Screen limit exceeded.";
    mapResponse[53] = "Overdrive. Too much drive from exciter.";
    mapResponse[54] = "FWD=0, Power output is zero with drive power higher than zero.";
    mapResponse[55] = "Igmax. 1st grid current limit exceeded.";
    mapResponse[56] = "Tune. Insufficient tuning - retune PA";
    mapResponse[62] = "PA turned on.";
    mapResponse[60] = "PA turned off.";
    mapResponse[83] = "PA turned to stand by mode.";
    mapResponse[79] = "PA turned to operating mode.";
    mapResponse[76] = "List 20 last fault codes.";
    mapResponse[71] = "Reset PA succeeded.";
    mapResponse[87] = "PA is heating up. Please wait.";
    mapResponse[90] = "Operating is not possible.";
    mapResponse[84] = "Fatal fault.";

    dialog = new SettingsDialog();

    ui->setupUi(this);
    createActions();

    //Init settings if startprofile is empty
    if (startProfile.isEmpty())
    {
        dialog->FirstChoice(startProfile.remove("\""));
        startProfile = "";
    }

    QTimer *timer = new QTimer(this);
    timer->setInterval(1000);
    timer->start();
    connect(timer, SIGNAL(timeout()), this, SLOT(TimeOut()));


    ui->menu->addAction(configureAct);
    ui->menu->addAction(exitAct);
    ui->ledDrive->hide();
    ui->ledGrid->hide();
    ui->ledOperate->hide();
    ui->ledPA->hide();
    ui->ledPower->hide();
    ui->ledStdby->hide();
    ui->ledSwr->hide();
    ui->ledTune->hide();
    ui->ledFault->hide();

    connect(ui->buttonConnect, SIGNAL(clicked()), this, SLOT(connectSocket()));
    socket = new QTcpSocket(this);
    ui->buttonPower->setStatusTip(tr("Turn PA ON/OFF."));
    ui->buttonOperate->setStatusTip(tr("Turn Operate ON/OFF."));
    ui->buttonConnect->setStatusTip(tr("Connect/Disconnect to Remote OM"));

    setInfoText("Connecting to Remote OM. Please wait.");

    receiveFaults = false;

    faultTimer = new QTimer(this);
    waitTimer = new QTimer(this);
    connect(faultTimer, SIGNAL(timeout()), this, SLOT(blinkFault()));
    connect(waitTimer, SIGNAL(timeout()), this, SLOT(blinkWait()));

    //Get settings
    if (!startProfile.isEmpty())
    {
       /* dialog->SetInitialSettings();
        QString show_ip = dialog->set_ipaddress;
        QString show_port = dialog->set_port;
        ui->txtCurrentSettings->setText("Current settings: "+show_ip+":"+show_port);*/
    }

}
void GLWidget::updateColorForVertex(int vertex, double r, double g, double b, double a)
{
    setInfoText("");
    model->updateColorForVertex(vertex, r, g, b, a);
}
void GLWidget::mousePressEvent(QMouseEvent* event)
{
    if (event->button() == Qt::LeftButton)
    {
#ifdef Q_OS_MAC
#else
	if (quitRect.contains(event->pos()))
	    QApplication::quit();
#endif

	if (rotationRect.contains(event->pos()))
	{
	    if (!headMovementOn)
	    {
		headMovementOn = 1;
		zeroRotation = 0;
	    }
	    else if (headMovementOn && !zeroRotation)
	    {
		headMovementOn = 1;
		zeroRotation = 1;
	    }
	    else if (headMovementOn && zeroRotation)
	    {
		headMovementOn = 0;
		zeroRotation = 0;
	    }
	}


	if (toggleRect.contains(event->pos()))
	{
	    if (sourceRecOn)
	    {

	    }
	    else
	    {
		sourceRecOn = 1;
		setInfoText("loading...");
		this->updateGL();
#ifdef Q_WS_MAEMO_5
		emit turnSourceReconstructionPowerOn(128,32,8*1,8*60, "emotiv");
#else
		emit turnSourceReconstructionPowerOn(64,2,8*1,8*30, QString("emocap"));
#endif

	    }
	}
	/*
	if (toggleRectEmocap.contains(event->pos()))
	{
	    if (sourceRecOn)
	    {

	    }
	    else
	    {
		sourceRecOn = 1;
#ifdef Q_WS_MAEMO_5
		emit turnSourceReconstructionPowerOn(128,32,8*1,8*60, "emocap");
#else
		emit turnSourceReconstructionPowerOn(128,16,8*1,8*30, QString("emocap"));
#endif

	    }

	}
	*/

	if (deltaRect.contains(event->pos()))
	    changeFrequency("delta");
	if (thetaRect.contains(event->pos()))
	    changeFrequency("theta");
	if (alphaRect.contains(event->pos()))
	    changeFrequency("alpha");
	if (lowBetaRect.contains(event->pos()))
	    changeFrequency("lowBeta");
	if (betaRect.contains(event->pos()))
	    changeFrequency("beta");
	if (logoRect.contains(event->pos()))
	    infoPressed = !infoPressed;
	else if (infoRect.contains(event->pos()))
	    infoPressed = 0;


	dragLastPosition = dragStartPosition = event->pos();
    }
}
Exemplo n.º 25
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicGridStatisticsDialog::updateFromRimView(RimGridView* rimView)
{
    m_currentRimView = rimView;
    setInfoText(m_currentRimView);
    setHistogramData(m_currentRimView);
}