예제 #1
0
void gep::Renderer::render()
{
    m_pFontBuffer->getData().resize(0);
    m_pFontBuffer->getIndices().resize(0);
    m_pLinesBuffer->getData().resize(0);
    m_pLines2DBuffer->getData().resize(0);

    {
        auto& extractor = *static_cast<RendererExtractor*>(g_globalManager.getRendererExtractor());

        CommandBase* firstCommand = extractor.startReadCommands();
        SCOPE_EXIT { extractor.endReadCommands(); });

        prepareCommands(extractor, firstCommand);

        m_pFontBuffer->upload(m_pDeviceContext);
        m_pLinesBuffer->upload(m_pDeviceContext);
        m_pLines2DBuffer->upload(m_pDeviceContext);

        m_fontScreenSize.set(vec2((float)m_settings.screenResolution.x,
                                  (float)m_settings.screenResolution.y));
        m_textBillboardScreenSize.set(vec2((float)m_settings.screenResolution.x,
                                           (float)m_settings.screenResolution.y));
        m_lines2DScreenSize.set(vec2((float)m_settings.screenResolution.x,
                                     (float)m_settings.screenResolution.y));

        // Just clear the backbuffer
        auto clearColor = m_settings.clearColor;
        m_pDeviceContext->ClearRenderTargetView( m_pRenderTargetView, clearColor.data );
        m_pDeviceContext->ClearDepthStencilView( m_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0, 0 );

        executeCommands(extractor, firstCommand);
        execute2DCommands(extractor, firstCommand);
    }
예제 #2
0
파일: events.c 프로젝트: robotiko/rules
unsigned int assertTimers(void *handle) {
    unsigned short commandCount = 2;
    redisReply *reply;
    void *rulesBinding;
    unsigned int result = peekTimers(handle, &rulesBinding, &reply);
    if (result != RULES_OK) {
        return result;
    }

    result = prepareCommands(rulesBinding);
    if (result != RULES_OK) {
        freeReplyObject(reply);
        return result;
    }

    for (unsigned long i = 0; i < reply->elements; ++i) {
        result = removeTimer(rulesBinding, reply->element[i]->str);
        if (result != RULES_OK) {
            freeReplyObject(reply);
            return result;
        }

        ++commandCount;
        result = handleEvent(handle, reply->element[i]->str, &rulesBinding, ACTION_ASSERT_TIMER, &commandCount);
        if (result != RULES_OK && result != ERR_EVENT_NOT_HANDLED) {
            freeReplyObject(reply);
            return result;
        }
    }

    result = executeCommands(rulesBinding, commandCount);
    freeReplyObject(reply);
    return result;
}
예제 #3
0
파일: events.c 프로젝트: robotiko/rules
unsigned int completeAction(void *handle, void *actionHandle, char *session) {
    unsigned short commandCount = 4;
    actionContext *context = (actionContext*)actionHandle;
    redisReply *reply = context->reply;
    void *rulesBinding = context->rulesBinding;
    unsigned int result = prepareCommands(rulesBinding);
    if (result != RULES_OK) {
        freeReplyObject(reply);
        free(actionHandle);
        return result;
    }
    
    result = removeAction(rulesBinding, reply->element[0]->str);
    if (result != RULES_OK) {
        freeReplyObject(reply);
        free(actionHandle);
        return result;
    }

    if (reply->element[2]->type != REDIS_REPLY_NIL) {
        result = handleSession(handle, reply->element[2]->str, rulesBinding, ACTION_NEGATE_SESSION, &commandCount, 0);
        if (result != RULES_OK && result != ERR_EVENT_NOT_HANDLED) {
            freeReplyObject(reply);
            free(actionHandle);
            return result;
        }
    }
   
    for (unsigned long i = 4; i < reply->elements; i = i + 2) {
        if (strcmp(reply->element[i]->str, "null") != 0) {
            result = handleEvent(handle, reply->element[i]->str, &rulesBinding, ACTION_NEGATE_MESSAGE, &commandCount);
            if (result != RULES_OK) {
                freeReplyObject(reply);
                free(actionHandle);
                return result;
            }
        }
    }

    result = handleSession(handle, session, rulesBinding, ACTION_ASSERT_SESSION, &commandCount, 1);
    if (result != RULES_OK && result != ERR_EVENT_NOT_HANDLED) {
        freeReplyObject(reply);
        free(actionHandle);
        return result;
    }

    result = executeCommands(rulesBinding, commandCount);    
    freeReplyObject(reply);
    free(actionHandle);
    return result;
}
예제 #4
0
int OnlineSession::run(istream *in, ostream *out, bool interactive)
{
    map<string, int> commands;
    prepareCommands(commands);

    int res = 0;
    int count = 0;

    int cmd;
    string command;

    string sarg1, sarg2;
    int iarg1, iarg2, iarg3, iarg4, iarg5, iarg6, iarg7;
    double darg1;
    double *dparg1;
    TimeSeriesSet *t;

    clock_t time;

    res = 0;

    while (!in->eof()) {

        if (res != 0)
            *out << "Command returned with status " << res << "." << endl;

        if (interactive) {
            int width = out->width();
            *out << "[";

            out->width(3);
            *out << count;
            out->width(width);

            *out << "] > ";
            out->flush();
        }

        *in >> command;
        time = clock();

        if (command.size() > 0) {
            cmd = commands[command];
        }

        if (command.size() <= 0 || in->eof()) {
            cmd = _EXIT;
            *out << endl;
        }

        if (cmd == 0) {
            *out << "Unknown command '" << command << "'. Type 'help' for help." << endl;
            res = 1;
            count++;
            continue;
        }

        try {
            res = 0;
            switch (cmd) {
            case _EXIT:
                *out << "Quitting..." << endl;

                return iarg1;

            case _HELP:
                _print_help(out);

                break;

            case _LOAD_TSS:
                *in >> sarg1;

                *out << "Loading Time Series Set from file '" << sarg1 << "'." << endl;

                res = loadDataSet(new TimeSeriesSet(sarg1.c_str()));
                if (res >= 0) {
                    *out << "Dataset successfully loaded. Index: " << res << endl;
                    res = 0;
                } else {
                    *out << "Failed to load dataset." << endl;
                }

                break;

            case _SAVE_TSS:
                *in >> iarg1;
                *in >> sarg2;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << "Saving Time Series Set " << iarg1 << ":" << t->name << " to file '" << sarg2 << "'." << endl;

                res = saveDataSet(iarg1, sarg2.c_str());
                if (res == 0)
                    *out << "Dataset successfully saved." << endl;

                break;

            case _OLOAD_TSS:
                *in >> sarg1;
                *in >> iarg1 >> iarg2 >> iarg3;

                *out << "Loading Time Series Set from file '" << sarg1 << "' with N=" << iarg1 << ", L=" << iarg2 << ", and D=" << iarg3 << "." << endl;

                res = loadDataSet(new TimeSeriesSet(sarg1.c_str(), iarg1, iarg2, iarg3));
                if (res >= 0) {
                    *out << "Dataset successfully loaded. Index: " << res << endl;
                    res = 0;
                } else {
                    *out << "Failed to load dataset." << endl;
                }

                break;

            case _OSAVE_TSS:
                *in >> iarg1;
                *in >> sarg2;

                checkIndex(iarg1);
                t = dataSets[iarg1];

                *out << "Saving Time Series Set " << iarg1 << ":" << t->name << " to file '" << sarg2 << "'." << endl;
                res = saveDataSet(iarg1, sarg2.c_str(), true);
                if (res == 0)
                    *out << "Dataset successfully saved." << endl;
                break;

            case _DROP_TSS:
                *in >> iarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << "Dropping Time Series Set " << iarg1 << ":" << t->name << "." << endl;

                res = dropDataSet(iarg1);

                break;

            case _RAND_TSS:
                *in >> iarg1 >> iarg2 >> iarg3;

                *out << "Generating random Time Series Set with N=" << iarg1 << ", L=" << iarg2 << ", and range=" << iarg3 << "." << endl;

                res = loadDataSet(&TimeSeriesSet::randomSet(iarg1, iarg2, iarg3));
                if (res >= 0) {
                    *out << "Dataset successfully loaded. Index: " << res << endl;
                    res = 0;
                } else {
                    *out << "Failed to load dataset." << endl;
                }

                break;

            case _LIST_TSS:
                printDataSets(out);
                break;

            case _NORM_TSS:
                *in >> iarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << "Normalizing Time Series Set " << iarg1 << ":" << t->name << "." << endl;

                res = normalizeDataSet(iarg1);

                break;

            case _KSIM_TSS:
                *in >> iarg1 >> iarg2 >> iarg3 >> iarg4 >> iarg5 >> iarg6 >> iarg7;

                checkIndex(iarg1);
                checkIndex(iarg2);
                t = dataSets[iarg1];
                *out << "Getting the kSimilar for Time Series Set " << iarg1 << ":" << t->name;
                t = dataSets[iarg2];
                *out << ", query string at " << iarg3 << " in dataset " << iarg2 << ":" << t->name;
                *out << " in interval [" << iarg4 << "," << iarg5 << "] with k=" << iarg6 << " and strict="
                     << iarg7 << "." << endl;

                dparg1 = t->getInterval(iarg3,TimeInterval(iarg4, iarg5)).getData();
                kSimilar(iarg1, vector<double>(dparg1, dparg1 + (iarg5 - iarg4 + 1)),
                         TimeInterval(iarg4, iarg5), iarg6, iarg7);

                break;

            case _OUTLIER_TSS:
                *in >> iarg1 >> iarg2 >> iarg3;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << "Gettind dominant outlier on Time Series Set " << iarg1 << ":" << t->name
                     << " in the range [" << iarg2 << ", " << iarg3 << "]." << endl;

                dominantOutlier(iarg1, TimeInterval(iarg2, iarg3));

                break;

            case _GROUP_TSS:
                *in >> iarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];

                *out << ((groupings[iarg1] != NULL)?"Regrouping":"Grouping") << " Time Series Set "
                     << iarg1 << ":" << t->name << " with ST " << defaultST << "." << endl;

                genGrouping(iarg1, defaultST);

                break;

            case _NGROUP_TSS:
                *in >> iarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];

                *out << ((groupings[iarg1] != NULL)?"Regrouping":"Grouping") << " Time Series Set "
                     << iarg1 << ":" << t->name << " with ST " << defaultST << " (naive)." << endl;

                genNaiveGrouping(iarg1, defaultST);

                break;

            case _GROUP_ST_TSS:
                *in >> iarg1;
                *in >> darg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << ((groupings[iarg1]  == NULL)?"Grouping":"Regrouping") << " Time Series Set "
                     << iarg1 << ":" << t->name << " with ST " << darg1 << "." << endl;

                genGrouping(iarg1, darg1);

                break;

            case _NGROUP_ST_TSS:
                *in >> iarg1;
                *in >> darg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << ((groupings[iarg1]  == NULL)?"Grouping":"Regrouping") << " Time Series Set "
                     << iarg1 << ":" << t->name << " with ST " << darg1 << " (naive)." << endl;

                genNaiveGrouping(iarg1, darg1);

                break;

            case _LOAD_GROUP_TSS:
                *in >> iarg1;
                *in >> sarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << "Loading grouping data for Time Series Set "
                     << iarg1 << ":" << t->name << " at " << sarg1 << "." << endl;

                res = loadGrouping(iarg1, sarg1.c_str());

                break;

            case _SAVE_GROUP_TSS:
                *in >> iarg1;
                *in >> sarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << "Saving grouping data for Time Series Set "
                     << iarg1 << ":" << t->name << " to " << sarg1 << "." << endl;

                res = saveGrouping(iarg1, sarg1.c_str());

                break;

            case _DROP_GROUP_TSS:
                *in >> iarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                *out << "Dropping grouping data for Time Series Set "
                     << iarg1 << ":" << t->name << "." << endl;

                dropGrouping(iarg1);

                break;

            case _DESC_TSS:
                *in >> iarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                t->printDesc(out);

                break;

            case _PRINT_TSS:
                *in >> iarg1;

                checkIndex(iarg1);
                t = dataSets[iarg1];
                t->printData(out);

                break;

            case _DEBUG:
                *in >> iarg1;

                *out << "Setting debug to " << iarg1 << "." << endl;
                debug = iarg1;

                break;

            case _SET_DEF_ST:
                *in >> darg1;

                *out << "Setting default ST to " << darg1 << "." << endl;

                defaultST = darg1;

                break;

            case _GET_DEF_ST:
                *out << "default ST = " << defaultST << "." << endl;

                break;
            }

        } catch (exception &e) {
            *out << "Caught exception attempting operation:" << endl;
            *out << e.what() << endl;
        }

        time = clock() - time;
        (*out) << "Command used " << ((float)time/CLOCKS_PER_SEC) << " seconds." << endl << endl;

        count++;
    }

    return 0;
}