예제 #1
0
SSMRESULT CSensingEngine::finalConstruct()
{
    SSMRESULT res = SSM_S_OK;

    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase **)&m_pContextRepository));

    SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextExecutor, (IBase **)&m_pContextExecutor)); //TEMP

CLEANUP:
    return res;
}
예제 #2
0
SSMRESULT CConditionedModel::finalConstruct()
{
    SSMRESULT res = SSM_E_FAIL;

    m_triggerId = -1;

    m_pConditionedModelEvent = NULL;

    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IEvaluationEngine, (IBase **)&m_pEvaluationEngine));

CLEANUP:
    return res;
}
예제 #3
0
SSMRESULT CResourceFinder::finalConstruct()
{
    SSMRESULT res = SSM_E_FAIL;

    OC::PlatformConfig cfg(OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0,
                           OC::QualityOfService::LowQos);

    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker));

    OC::OCPlatform::Configure(cfg);

    m_pResourceFinderEvent = NULL;

    m_multicastPresenceHandle = nullptr;

CLEANUP:
    return res;
}
예제 #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;
}
예제 #5
0
SSMRESULT CSoftSensorManager::initializeCore(IN std::string xmlDescription)
{
    SSMRESULT                   res = SSM_E_FAIL;
    rapidxml::xml_document<>    xmlDoc;
    std::string                 strKey;
    std::string                 strValue;
    rapidxml::xml_node<>        *root = NULL;
    rapidxml::xml_node<>        *itemSSMCore = NULL;
    rapidxml::xml_node<>        *itemDevice = NULL;

    std::string                 name;
    std::string                 type;
    std::string                 pathSoftSensors;
    std::string                 pathDescription;

    try
    {
        xmlDoc.parse<0>((char *)xmlDescription.c_str());

        root = xmlDoc.first_node();

        if (!root)
        {
            throw rapidxml::parse_error("No Root Element", 0);
        }

        strKey = root->name();

        if (strKey != "SSMCore")
        {
            throw rapidxml::parse_error("Invalid root tag name", 0);
        }

        for (itemSSMCore = root->first_node(); itemSSMCore; itemSSMCore = itemSSMCore->next_sibling())
        {
            strKey = itemSSMCore->name();

            if (strKey == "Device")
            {
                for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
                {
                    strKey = itemDevice->name();

                    if (strKey == "Name")
                    {
                        name = itemDevice->value();
                    }
                    else if (strKey == "Type")
                    {
                        type = itemDevice->value();
                    }
                    else
                    {
                        ;/*NULL*/
                    }
                }
            }
            else if (strKey == "Config")
            {
                for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
                {
                    strKey = itemDevice->name();

                    if (strKey == "SoftSensorRepository")
                    {
                        pathSoftSensors = itemDevice->value();
                    }
                    else if (strKey == "SoftSensorDescription")
                    {
                        pathDescription = itemDevice->value();
                    }
                    else
                    {
                        ;/*NULL*/
                    }
                }
            }
            else
            {
                ;/*NULL*/
            }
        }
    }
    catch (rapidxml::parse_error &e)
    {
        SSM_CLEANUP_ASSERT(SSM_E_INVALIDXML);
    }

    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ISensingEngine, (IBase **)&m_pSensingEngine));
    SSM_CLEANUP_ASSERT(m_pSensingEngine->queryInterface(OID_IContextRepository,
                       (IBase **)&m_pContextRepository));
    SSM_CLEANUP_ASSERT(m_pContextRepository->initRepository(name, type, pathSoftSensors,
                       pathDescription));

    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IPropagationEngine, (IBase **)&m_pPropagationEngine));

CLEANUP:
    if (res != SSM_S_OK)
    {
        terminateCore(false);
    }

    return res;
}