void ProgramData::check() { uint16_t v; v = getMaxCells(); if(battery.cells > v) battery.cells = v; v = getMaxIc(); if(battery.Ic > v) battery.Ic = v; v = getMaxId(); if(battery.Id > v) battery.Id = v; }
void StatusCacheManagerI::initialize() { MCE_INFO("StatusCacheManagerI::initialize -> start ..."); //queue_.setProps(10000); //start(); try { int large_id = 0; do { Statement sql; sql << "SELECT id, status FROM user_passport WHERE id > " << getMaxId() << " LIMIT 10000"; map<int, int> db_data; com::xiaonei::xce::QueryRunner("user_passport_status",com::xiaonei::xce::CDbRServer ).query( sql, StatusCacheResultHandler( large_id, db_data ) ); { for (map<int, int>::const_iterator it = db_data.begin(); it != db_data.end(); ++it) { if (it->second == 0 || it->second == 3) { _status.reset(it->first); } } } if (large_id > getMaxId()) { setMaxId(large_id); } else { setMaxId(STATUS_CACHE_SIZE); break; } MCE_INFO("StatusCacheManagerI::initialize -> initializing to " << large_id); } while (true); } catch (...) { MCE_WARN("StatusCacheManagerI::initialize -> loading exit with unknown exception."); } MCE_INFO("StatusCacheManagerI::initialize -> thread loading done."); { IceUtil::RWRecMutex::WLock lock(_inited_flag_mutex); _inited_flag = true; } MCE_INFO("StatusCacheManagerI::initialize -> thread all done."); }
void ImportF::fixSequence(const char *tableName,const char *columnName) { int maxId; char query[512]; // get the maximum id maxId = getMaxId(tableName,columnName); // calculate the new maximum id maxId++; // create the query sprintf(query,"SELECT setval('%s_%s_seq',%d);",tableName,columnName,maxId); printf("ImportF::fixSequence: [%s]\n",query); // execute the query execSQLCommand(query); }
void ProgramData::check() { uint16_t v; v = ANALOG_MIN_CHARGE; if(battery.capacity < v) battery.capacity = v; v = ANALOG_MAX_CHARGE; if(battery.capacity > v) battery.capacity = v; #ifdef ENABLE_TIME_LIMIT v = ANALOG_MAX_TIME_LIMIT; if(battery.time > v) battery.time = v; #endif v = getMaxCells(); if(battery.cells > v) battery.cells = v; v = 1; if(battery.cells < v) battery.cells = v; v = getMaxIc(); if(battery.Ic > v) battery.Ic = v; v = battery.Ic; if(battery.minIc > v) battery.minIc = v; v = getMaxId(); if(battery.Id > v) battery.Id = v; v = battery.Id; if(battery.minId > v) battery.minId = v; v = settings.minIc; if(battery.Ic < v) battery.Ic = v; if(battery.minIc < v) battery.minIc = v; v = settings.minId; if(battery.Id < v) battery.Id = v; if(battery.minId < v) battery.minId = v; }
void ProgramData::changeId(int direction) { change0ToMaxSmart(battery.Id, direction, getMaxId()); }