Ejemplo n.º 1
0
void NodeJSDebugger::OnNodeOutput(clCommandEvent& event)
{
    wxUnusedVar(event);
    CL_DEBUG("Node debugger:\n%s", event.GetString());

    clDebugEvent eventLog(wxEVT_NODEJS_DEBUGGER_CONSOLE_LOG);
    eventLog.SetString(event.GetString());
    EventNotifier::Get()->AddPendingEvent(eventLog);
}
Ejemplo n.º 2
0
ConsoleWindow::ConsoleWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::ConsoleWindow),
    findNext(false)
{
    ui->setupUi(this);
    sourceModel = new ConsoleModel(this);
    model = new SortFilterProxyModel(this);
    model->setSourceModel(sourceModel);
    model->setFilterKeyColumn(0);
    ui->consoleListView->setModel(model);
    ui->consoleListView->setColumnWidth(0, 2000);

    connect(sourceModel, SIGNAL(beforeInserting()),
                     this, SLOT(setConditionalScroll()));
    connect(sourceModel, SIGNAL(afterInserting()),
                     this, SLOT(conditionalScroll()));

    connect(ui->btnSend, SIGNAL(clicked()),
                     this, SLOT(cmdSendClicked()));
    connect(ui->lineCmd, SIGNAL(textChanged(QString)),
                     this, SLOT(lineCmdChanged(QString)));

    _levelFilter = new QSignalMapper(this);
    connect(ui->checkEmerg, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    connect(ui->checkAlert, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    connect(ui->checkCrit, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    connect(ui->checkDebug, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    connect(ui->checkError, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    connect(ui->checkInfo, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    connect(ui->checkNotice, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    connect(ui->checkWarn, SIGNAL(clicked()), _levelFilter, SLOT(map()));
    _levelFilter->setMapping(ui->checkEmerg, SWITCH_LOG_CONSOLE);
    _levelFilter->setMapping(ui->checkAlert, SWITCH_LOG_ALERT);
    _levelFilter->setMapping(ui->checkCrit, SWITCH_LOG_CRIT);
    _levelFilter->setMapping(ui->checkDebug, SWITCH_LOG_DEBUG);
    _levelFilter->setMapping(ui->checkError, SWITCH_LOG_ERROR);
    _levelFilter->setMapping(ui->checkInfo, SWITCH_LOG_INFO);
    _levelFilter->setMapping(ui->checkNotice, SWITCH_LOG_NOTICE);
    _levelFilter->setMapping(ui->checkWarn, SWITCH_LOG_WARNING);
    connect(_levelFilter, SIGNAL(mapped(int)), this, SLOT(filterModelLogLevel(int)));

    connect(ui->btnFilterClear, SIGNAL(clicked()),
                     this, SLOT(filterClear()));
    connect(ui->lineFilter, SIGNAL(textChanged(QString)),
                     this, SLOT(filterStringChanged()));
    connect(ui->filterCaseSensitivityCheckBox, SIGNAL(toggled(bool)),
                     this, SLOT(filterStringChanged()));
    connect(ui->filterSyntaxComboBox, SIGNAL(currentIndexChanged(int)),
                     this, SLOT(filterStringChanged()));
    connect(ui->filterReverseCheckBox, SIGNAL(toggled(bool)),
                     this, SLOT(reverseFilterChecked()));

    connect(g_FSHost, SIGNAL(eventLog(QSharedPointer<switch_log_node_t>,switch_log_level_t)), this, SLOT(loggerHandler(QSharedPointer<switch_log_node_t>,switch_log_level_t)));

}
Ejemplo n.º 3
0
void jarvisNodeTestApp::connectNodeSignals(sJarvisNode* node)
{
    connect(node,SIGNAL(tx()),&m_rxWidget,SLOT(tx()));
    connect(node,SIGNAL(rx()),&m_rxWidget,SLOT(rx()));
    connect(node,SIGNAL(rawInput(QByteArray)),this,SLOT(console_log(QByteArray)));
    connect(node,SIGNAL(writeData(QByteArray)),this,SLOT(console_log(QByteArray)));
    connect(node,SIGNAL(incomingEvent(QString,jarvisEvents,QStringList)),this,SLOT(eventLog(QString,jarvisEvents,QStringList)));
    //connect(node,SIGNAL(newComponent(sJarvisNodeComponent*)),this,SLOT(addComponent(sJarvisNodeComponent*)));
    //connect(&m_sensorsTimer,SIGNAL(timeout()),this,SLOT(timedCmd()));
    connect(node,SIGNAL(sensorReads(QVector<QString>,QVector<double>)),this,SLOT(sensorRead(QVector<QString>,QVector<double>)));
    connect(node,SIGNAL(ready()),this,SLOT(nodeConnected()));
    connect(node,SIGNAL(disconnected()),this,SLOT(nodeDisconnected()));
    connect(ui->sliderUpdateInterval,SIGNAL(sliderMoved(int)),node,SLOT(setUpdateInterval(int)));
    connect(ui->btnReset,SIGNAL(clicked()),node,SLOT(resetNode()));
}
Ejemplo n.º 4
0
QModbusResponse QModbusServerPrivate::processGetCommEventLogRequest(const QModbusRequest &request)
{
    CHECK_SIZE_EQUALS(request);
    const QVariant tmp = q_func()->value(QModbusServer::DeviceBusy);
    if (tmp.isNull() || (!tmp.isValid())) {
        return QModbusExceptionResponse(request.functionCode(),
                                        QModbusExceptionResponse::ServerDeviceFailure);
    }
    const quint16 deviceBusy = tmp.value<quint16>();

    QVector<quint8> eventLog(int(m_commEventLog.size()));
    std::copy(m_commEventLog.cbegin(), m_commEventLog.cend(), eventLog.begin());

    // 6 -> 3 x 2 Bytes (Status, Event Count and Message Count)
    return QModbusResponse(request.functionCode(), quint8(eventLog.size() + 6), deviceBusy,
                           m_counters[Counter::CommEvent], m_counters[Counter::BusMessage], eventLog);
}
Ejemplo n.º 5
0
void FSHost::generalLoggerHandler(QSharedPointer<switch_log_node_t>node, switch_log_level_t level)
{
    emit eventLog(node, level);
}
Ejemplo n.º 6
0
int main(int argc,char* argv[]) {
	EmoEngine engine;
	ExpressionProcessor processor;
    MorseTranslator morse;

    SDL_Color txtColor   = {   0,  0,  0 },
              morseColor = { 255,  0,  0 },
              bgColor    = {   0,255,  0 },
              suggColor  = {   0,  0,255 };
    if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
        throw std::runtime_error("SDL init failed");
    }
    screenHandler screen;
    if(TTF_Init() < 0) {
        throw std::runtime_error("TTF init failed");
    }
    ttfQuitter _quitTTF;
    _quitTTF.foo();
    if(!(screen.screen = SDL_SetVideoMode(400,300,32,SDL_SWSURFACE|SDL_RESIZABLE))) {
        throw std::runtime_error("SDL surface init failed");
    }
    SDL_EnableUNICODE(1);

    fontHandler font;
    font.font = TTF_OpenFont("brain.ttf",20);
    SDL_WM_SetCaption("FTS: Facial Typing System",NULL);
    std::string txt = "";

    std::ofstream eventLog("logs/events.csv",std::ios_base::out|std::ios_base::trunc);

    bool locked = false;

    //morse.add(".--- --- . ");

    std::string morseToAdd = "";

    Uint32 prevFrameBegin = 0;
    bool running = true;
    while(running) {
        processor.processEvents(engine);

        Expression e;
        while(processor.getExpression(e)) {
            eventLog << e.time << "," << e.event << "," << e.power << ","
                     << !!(e.eyeState & Expression::BLINK) << ","
                     << !!(e.eyeState & Expression::LWINK) << ","
                     << !!(e.eyeState & Expression::RWINK) << ","
                     << !!(e.eyeState & Expression::RLOOK) << ","
                     << !!(e.eyeState & Expression::LLOOK) << std::endl;
            morseToAdd += exp2Morse(e);
        }

        Uint32 frameBegin = SDL_GetTicks();
        if(frameBegin-prevFrameBegin >= MS_PER_FRAME) {
            prevFrameBegin = frameBegin;
            SDL_Event e;
            while(SDL_PollEvent(&e)) {
                switch(e.type) {
                case SDL_QUIT:
                    running = false;
                    break;
                case SDL_VIDEORESIZE:
                    screen.screen = SDL_SetVideoMode(e.resize.w,e.resize.h, 32, SDL_SWSURFACE | SDL_RESIZABLE );
                    break;
                //case SDL_KEYDOWN: {
                //        std::string s;
                //        std::cout << s << std::endl;
                //        std::cout.flush();
                //        s += (char)e.key.keysym.unicode;
                //        morse.add(s);
                //    }
                //    break;
#ifdef DEBUG
                case SDL_KEYDOWN: {
                        std::string s = "";
                        s += (char)e.key.keysym.unicode;
                        morseToAdd += s;
                    }
                    break;
#endif
                default:
                    break;
                }
            }

            for(size_t i=0;i<morseToAdd.length();++i) {
                std::string morseText = morseToAdd.substr(i,1);
                if(morseText == "@") {
                    locked = true;
                } else if(locked && morseText == "^") {
                    locked = false;
                } else if(!locked && !morseText.empty()) {
                    morse.add(morseText);
                }
            }
            morseToAdd.clear();

            SDL_FillRect(screen.screen,NULL,SDL_MapRGB(screen.screen->format,255,255,255));

            std::cout << (morse.text()+morse.currWord()) << "|" << morse.morseLetter() << std::endl;

            int x,y;
            drawTextLines(screen.screen,font.font,0,0,(morse.text()+morse.currWord()),txtColor,&x,&y);
            std::string morseTxt = morse.morseLetter();
            if(morseTxt.empty()) {
                morseTxt = "_";
            }
            drawTextLines(screen.screen,font.font,x,y,morseTxt,morseColor,&x,&y);

            std::vector<std::pair<std::string,std::string> > suggestions = morse.morseSuggestions();
            std::vector<std::string> suggestionLines;
            size_t lineLength = 0;
            for(size_t i=0;i<suggestions.size() && i<10;++i) {
                size_t length = suggestions[i].first.length() + suggestions[i].second.length()+1;
                if(length > lineLength) {
                    lineLength = length;
                }
            }
            for(size_t i=0;i<suggestions.size() && i<10;++i) {
                size_t length = suggestions[i].first.length() + suggestions[i].second.length()+1;
                std::string pad = "";
                for(int i=length;i<lineLength;++i) {
                    pad += " ";
                }
                suggestionLines.push_back(suggestions[i].first+ " " + pad + suggestions[i].second);
            }
            SDL_Surface* morsePrompt = buildWindow(font.font,suggestionLines,0,txtColor,bgColor,bgColor);
            int morsePromptH = 0;
            if(morsePrompt) {
                if(x+morsePrompt->w >= screen.screen->w) {
                    int height;
                    TTF_SizeText(font.font,morseTxt.c_str(),NULL,&height);
                    y += height;
                    x = 0;
                }
                SDL_Rect windowLoc = { x,y,0,0 };
                x += morsePrompt->w;
                SDL_BlitSurface(morsePrompt,NULL,screen.screen,&windowLoc);
                SDL_FreeSurface(morsePrompt);
            }
            const std::vector<std::string>& wordSuggs = morse.wordSuggestions();
            SDL_Surface* suggPrompt = buildWindow(font.font,wordSuggs,morse.selectionIndex(),txtColor,suggColor,morseColor);
            if(suggPrompt) {
                if(x+suggPrompt->w >= screen.screen->w) {
                    int height;
                    TTF_SizeText(font.font,morseTxt.c_str(),NULL,&height);
                    y += height;
                    x = 0;
                }
                SDL_Rect windowLoc = { x,y,0,0 };
                x += suggPrompt->w;
                SDL_BlitSurface(suggPrompt,NULL,screen.screen,&windowLoc);
                SDL_FreeSurface(suggPrompt);
            }

            if(locked) {
                std::vector<std::string> lines;
                lines.push_back("Locked. Nod up to unlock");
                SDL_Surface* lockDialog = buildWindow(font.font,lines,0,morseColor,suggColor,suggColor);
                SDL_Rect loc = { (screen.screen->w - lockDialog->w)/2,
                                 (screen.screen->h - lockDialog->h)/2,0,0 };
                SDL_BlitSurface(lockDialog,NULL,screen.screen,&loc);
                SDL_FreeSurface(lockDialog);
            }

            SDL_Flip(screen.screen);
            //Uint32 frameEnd = SDL_GetTicks();
            //Uint32 frameTime = frameEnd-frameBegin;
            //std::cout << frameTime << "ms/frame" << std::endl;
            //std::cout.flush();
            //if(frameTime < MS_PER_FRAME) {
            //    SDL_Delay(MS_PER_FRAME-(SDL_GetTicks()-frameBegin));
            //}
        }
        SDL_Delay(1);
    }
    return 0;





}