Ejemplo n.º 1
0
Connection::Connection(QTcpSocket *socket, WebPage *page, QObject *parent) :
    QObject(parent) {
  m_socket = socket;
  m_page = page;
  m_commandParser = new CommandParser(socket, this);
  m_commandFactory = new CommandFactory(page, this);
  m_command = NULL;
  m_pageSuccess = true;
  m_commandWaiting = false;
  connect(m_socket, SIGNAL(readyRead()), m_commandParser, SLOT(checkNext()));
  connect(m_commandParser, SIGNAL(commandReady(QString, QStringList)), this, SLOT(commandReady(QString, QStringList)));
  connect(m_page, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
Ejemplo n.º 2
0
C_BCI_Package::C_BCI_Package()
    : bciState(BCI_OFF)
{
    //Setup Debug Logging
    createDebugDirectory();
    debugLog = SMART_DEBUG_LOG::Instance();
    debugLog->BCI_Log() << "Instantiating BCI Package..." << endl;

    //Repetitive Visual Stimulus API
    pRVS = C_RVS::Instance();

    //Device Input/Output
    pEEG_IO           = createEEG_IO(DEFAULT_EEG_TYPE);
    pBRS_IO           = createBRS_IO(DEFAULT_BRS_TYPE);
    pPCC_IO           = createPCC_IO(DEFAULT_PCC_TYPE);
    pFlasherIO        = createFlasher_IO(DEFAULT_FLASHER_TYPE);

    //Signal Processing, Judgement Algorithm, and Telemetry Management
    pSignalProcessing = C_SignalProcessing ::Instance();
    pJA               = C_JudgmentAlgorithm::Instance();
    pTelemetryManager = C_TelemetryManager ::Instance(this, pEEG_IO, pBRS_IO, pRVS, pPCC_IO, pJA);

    //Connection Status of Peripherals
    eegConnectionStatus      = NOT_CONNECTED;
    flasherConnectionStatus  = NOT_CONNECTED;
    pccConnectionStatus      = NOT_CONNECTED;
    brshConnectionStatus     = NOT_CONNECTED;

    //Process Commands when BRS Frames are Received
    QObject::connect(pBRS_IO, SIGNAL(BRSFrameReceived(brsFrameBufferType*)),
                     this   , SLOT(onBRSFrameReceived(brsFrameBufferType*)));

    //Process EEG Frames as they become available
    QObject::connect(pEEG_IO, SIGNAL(EEGFrameReceived(eegFrameBufferType*)),
                     this   , SLOT(onEEGFrameReceived(eegFrameBufferType*)));

    //Listen for Processed EEG Data
    QObject::connect(pSignalProcessing, SIGNAL(eegDataProcessed(resultsBufferType*)),
                     this             , SLOT(onEEGDataProcessed(resultsBufferType*)));

    //Listen for Emergency Stop Commands, and act on them immediately
    QObject::connect(pJA  , SIGNAL(RequestEmergencyStop()),
                     this , SLOT(onEmergencyStopRequested()), Qt::DirectConnection);

    //Listen for the Final PCC Command
    QObject::connect(pJA  , SIGNAL(commandReady()),
                     this , SLOT(onCommandReady()));

    debugLog->println(BCI_LOG, "BCI Package Instantiated Successfully", true);
}
Ejemplo n.º 3
0
void CommandParser::processArgument(const char *data) {
  if (m_argumentsExpected == -1) {
    m_argumentsExpected = QString(data).toInt();
  } else if (m_expectingDataSize == -1) {
    m_expectingDataSize = QString(data).toInt();
  } else {
    m_arguments.append(QString::fromUtf8(data));
  }

  if (m_arguments.length() == m_argumentsExpected) {
    emit commandReady(m_commandName, m_arguments);
    m_commandName = QString();
    m_arguments.clear();
    m_argumentsExpected = -1;
  }
}