Ejemplo n.º 1
0
SSMRESULT StopSSMCore()
{
    SSMRESULT res = SSM_E_FAIL;

    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->stopCore());

CLEANUP:
    return res;
}
Ejemplo n.º 2
0
SSMRESULT CreateQueryEngine(IQueryEngine **ppQueryEngine)
{
    SSMRESULT res = SSM_E_FAIL;

    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->createQueryEngine(ppQueryEngine));

CLEANUP:
    return res;
}
Ejemplo n.º 3
0
SSMRESULT GetInstalledModelList(std::vector<ISSMResource *> *pList)
{
    SSMRESULT res = SSM_E_FAIL;

    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
    g_pSoftSensorManager->getInstalledModelList(pList);

CLEANUP:
    return res;
}
Ejemplo n.º 4
0
SSMRESULT CreateGlobalInstanceRepo()
{
    SSMRESULT res = SSM_E_FAIL;

    if (g_mtxGlobalInstance != NULL)
        SSM_CLEANUP_ASSERT(SSM_E_OUTOFMEMORY);

    if (g_globalInstance != NULL)
        SSM_CLEANUP_ASSERT(SSM_E_OUTOFMEMORY);

    g_mtxGlobalInstance = new CSimpleMutex();
    SSM_CLEANUP_NULL_ASSERT(g_mtxGlobalInstance);
    g_globalInstance = new std::map<OID, IBase *>();
    SSM_CLEANUP_NULL_ASSERT(g_globalInstance);

    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IThreadPool, (IBase **)&g_pThreadPool));

CLEANUP:
    return res;
}
Ejemplo n.º 5
0
SSMRESULT TerminateSSMCore(bool factoryResetFlag)
{
    SSMRESULT res = SSM_E_FAIL;

    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->terminateCore(factoryResetFlag));

CLEANUP:
    SAFE_RELEASE(g_pSoftSensorManager);
    DestroyGlobalInstanceRepo();
    return res;
}
Ejemplo n.º 6
0
void CEvaluationEngine::terminateEngine()
{
    SSMRESULT           res = SSM_E_FAIL;
    sqlite3             *pBackupFile = NULL;
    sqlite3_backup      *pBackup = NULL;
    std::stringstream   sstream;

    //Remove all triggers on db side
    m_mtxTriggerId.lock();
    for (std::map<int, IEvaluationEngineEvent *>::iterator itor = m_mapTriggers.begin();
         itor != m_mapTriggers.end(); ++itor)
    {
        sstream << "drop trigger WatchInsertModel" << itor->first << ";" << std::ends;
        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
        sstream.str("");

        sstream << "drop trigger WatchUpdateModel" << itor->first << ";" << std::ends;
        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
        sstream.str("");
    }
    m_mtxTriggerId.unlock();

    if (strlen(LOCATION_SSM_DB_DUMP) > 0)
    {
        CHK_SQLITE(sqlite3_open(LOCATION_SSM_DB_DUMP, &pBackupFile), SQLITE_OK);
        pBackup = sqlite3_backup_init(pBackupFile, "main", m_pSQLite3, "main");
        CHK_SQLITE(sqlite3_errcode(pBackupFile), SQLITE_OK);
        SSM_CLEANUP_NULL_ASSERT(pBackup);
        CHK_SQLITE(sqlite3_backup_step(pBackup, -1), SQLITE_DONE);
        CHK_SQLITE(sqlite3_backup_finish(pBackup), SQLITE_OK);
        CHK_SQLITE(sqlite3_close(pBackupFile), SQLITE_OK);
    }

    CHK_SQLITE(sqlite3_close(m_pSQLite3), SQLITE_OK);

    m_pSQLite3 = NULL;

    res = SSM_S_OK;
CLEANUP:
    return;
}
Ejemplo n.º 7
0
SSMRESULT CEvaluationEngine::initializeEngine()
{
    SSMRESULT           res = SSM_E_FAIL;
    sqlite3             *pBackupFile = NULL;
    sqlite3_backup      *pBackup = NULL;

    const char *strCreate_ModelRelationTable =
        "create table [ModelRelation]\
		(\
		modelId integer primary key autoincrement,\
		modelName text NOT NULL,\
		lPos int NOT NULL,\
		rPos int NOT NULL\
		);";

    const char *strCreate_DataRelationTable =
        "create table [DataRelation]\
		(\
		id integer primary key autoincrement,\
		modelId int NOT NULL,\
		lPos int NOT NULL,\
		rPos int NOT NULL,\
		dataId int NOT NULL\
		);";

    //Create rootModel
    const char *strRootModel = "insert into [ModelRelation] values (null, 'root', 1, 2);";

    const char *tblRoot =
        "create table [ModelData1](dataId integer primary key autoincrement, name text);";

    const char *rootData = "insert into [ModelData1] values (null, 'root');";

    const char *rootRelation = "insert into [DataRelation] values (null, 1, 1, 2, 1);";

    CHK_SQLITE(sqlite3_open_v2(LOCATION_SSM_DB, &m_pSQLite3,
                               SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL), SQLITE_OK);

    CHK_SQLITE(sqlite3_create_function_v2(m_pSQLite3, "OnSQLTrigger", 3, SQLITE_UTF8, NULL,
                                          onSQLTrigger, NULL, NULL, NULL),
               SQLITE_OK);

    if (strlen(LOCATION_SSM_DB_DUMP) > 0 &&
        sqlite3_open_v2(LOCATION_SSM_DB_DUMP, &pBackupFile, SQLITE_OPEN_READWRITE, NULL) == SQLITE_OK)
    {
        pBackup = sqlite3_backup_init(m_pSQLite3, "main", pBackupFile, "main");
        CHK_SQLITE(sqlite3_errcode(pBackupFile), SQLITE_OK);
        SSM_CLEANUP_NULL_ASSERT(pBackup);
        CHK_SQLITE(sqlite3_backup_step(pBackup, -1), SQLITE_DONE);
        CHK_SQLITE(sqlite3_backup_finish(pBackup), SQLITE_OK);
        CHK_SQLITE(sqlite3_close(pBackupFile), SQLITE_OK);
        res = SSM_S_OK;
    }
    else
    {
        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strCreate_ModelRelationTable));
        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strCreate_DataRelationTable));

        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strRootModel));
        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(tblRoot));
        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(rootData));
        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(rootRelation));
    }

CLEANUP:
    return res;
}