当前位置: 首页>>代码示例>>C++>>正文


C++ Counter::Set方法代码示例

本文整理汇总了C++中Counter::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::Set方法的具体用法?C++ Counter::Set怎么用?C++ Counter::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Counter的用法示例。


在下文中一共展示了Counter::Set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AdvanceConfigure

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;
}
开发者ID:FragJage,项目名称:xPLChrono,代码行数:51,代码来源:xPLChrono.cpp

示例2: ConfigChange

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);
}
开发者ID:FragJage,项目名称:xPLChrono,代码行数:45,代码来源:xPLChrono.cpp


注:本文中的Counter::Set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。