Ejemplo n.º 1
0
void xPLChrono::AdvanceConfigure()
{
    int i;
    int nb;

    LOG_ENTER;

    ConfigsDelete();
    nb = m_AdvanceConfig.GetNbConfig();

    for(i=0; i<nb; i++)
    {
        std::map<std::string, std::string>* config;
        string configName;
        string source;
        string unit;
        string razPeriod;
        string razUnit;
        string strBool;
        bool saveValue;
        Counter counter;


        config = m_AdvanceConfig.GetConfig(i);

        configName = (*config)["configname"];
        source     = (*config)["source"];
        unit       = (*config)["unit"];
        razPeriod  = (*config)["resetperiod"];
        razUnit    = (*config)["resetunit"];
        strBool    = (*config)["savevalue"];
        saveValue  = (strBool=="1") ? true : false;

        if(source=="")
        {
            LOG_WARNING(m_Log) << "Counter " << configName << ": No source, Counter ignored";
            continue;
        }

        LOG_VERBOSE(m_Log) << "New Counter " << configName << ":" << source << " unit " << unit << ", razPeriod " << razPeriod << " " <<razUnit;
        counter.Set(source, unit, razPeriod, razUnit, saveValue);
        m_Counters[configName] = counter;
        m_DeviceCount[source]++;

        m_Sensors.AddSensorMessage(configName, xPL::SchemaSensorTypeUtility::count, 0);
        RequestValue(source);
    }
    LoadData();

	LOG_EXIT_OK;
}
Ejemplo n.º 2
0
void xPLChrono::ConfigChange(const string& configName)
{
    std::map<std::string, std::string>* config;
    std::map<std::string, Counter>::iterator it;
    string source;
    string unit;
    string razPeriod;
    string razUnit;
    string strBool;
    bool saveValue;
    Counter counter;


    config = m_AdvanceConfig.GetConfig(configName);

    source  = (*config)["source"];
    unit    = (*config)["unit"];
    razPeriod  = (*config)["resetperiod"];
    razUnit    = (*config)["resetunit"];
    strBool    = (*config)["savevalue"];
    saveValue  = (strBool=="1") ? true : false;

    it = m_Counters.find(configName);

    if(it==m_Counters.end())
    {
        LOG_VERBOSE(m_Log) << "New counter " << configName << ":" << source;
        counter.Set(source, unit, razPeriod, razUnit, saveValue);
        m_Counters[configName] = counter;
        m_DeviceCount[source]++;
        m_Sensors.AddSensorMessage(configName, xPL::SchemaSensorTypeUtility::count, 0);
    }
    else
    {
        LOG_VERBOSE(m_Log) << "Modify counter " << configName << ":" << source;
        m_DeviceCount[it->second.GetSource()]--;
        it->second.Set(source, unit, razPeriod, razUnit, saveValue);
        m_DeviceCount[source]++;
    }

    if(source=="")
        LOG_WARNING(m_Log) << "Counter " << configName << ": No source, Counter ignored";
    else
        RequestValue(source);
}