void UnitCfg::Configure () { // configure the unit by invoking the specific config from the driver DLL fNew = false; Driver * p = FindDriver(UnitType->currentText()); if(p) { DOAUDIT(tr("Configure Unit:") + Name->currentText()); p->UnitConfigure(this,Name->currentText(),"(default)"); // invoked the unit level configuration } }
ErrorStatus::FileError PersistentMgr::Save(LPCTSTR filename,PersistentModel& model) { ErrorStatus::FileError errorMark; Driver * pDriver = FindDriver(filename); if(pDriver == NULL) { errorMark = ErrorStatus::UnRegisterType; } else { errorMark = pDriver->Save(filename,model); delete pDriver; pDriver = NULL; } return errorMark; }
void UnitCfg::QueryResponse (QObject *p, const QString &c, int State, QObject*caller) // notify transaction completerequestrt needs the name record addedivityLled int2);, tion text,repprint int2);ate text); { if(p != this) return; IT_IT("UnitCfg::QueryResponse"); switch (State) { case tList: { // fill the name list box GetConfigureDb ()->FillComboBox (Name, "NAME"); Name->setCurrentItem (0); SelChanged (0); Name->setFocus (); ButtonState (true); }; break; case tItem: { IT_COMMENT("Received User Data"); // fill the fields Comment->setText (UndoEscapeSQLText(GetConfigureDb()->GetString ("COMMENT"))); SetComboItem (UnitType, GetConfigureDb ()->GetString ("UNITTYPE")); Enabled->setChecked (GetConfigureDb ()->GetString ("ENABLED").toInt ()); Comment->setFocus (); ButtonState (true); }; break; case tDrop: { int n = GetConfigureDb()->GetNumberResults(); QStringList list; QString point_list = "("; if (n) { for(int i = 0; i < n; i++,GetConfigureDb()->FetchNext()) { if(i) { point_list += ","; }; point_list += "'" + GetConfigureDb()->GetString("NAME") + "'"; // list << GetConfigureDb()->GetString ("NAME"); }; point_list += ");"; } QString cmd ="delete from TAGS_DB where NAME in " + point_list; GetCurrentDb ()->DoExec (0,cmd,0); // cmd ="delete from CVAL_DB where NAME in " + point_list; GetCurrentDb ()->DoExec (0,cmd,0); if(!list.isEmpty()) { QStringList::Iterator it = list.begin(); for(;it != list.end();++it) { QString cmd = "drop table "+ (*it) + ";"; GetResultDb()->DoExec(0,cmd,0); } } //TO DO APA caricare tutti i Driver *p in un dizionario come fa il monitor //e poi usarli quando e' necessario Driver * p = FindDriver(UnitType->currentText()); if(p) { DOAUDIT(tr("Drop Unit Tables:") + Name->currentText()); p->DropAllSpecTables(list); // invoked the unit level drop tables } } break; case tNew: case tDelete: case tApply: ButtonState (true); default: break; }; };
void SampleCfg::QueryResponse (QObject *p, const QString &, int State, QObject*caller) // notify transaction completerequestrt needs the name record addedivityoints listamples text);;dtod text,enddate text); { if(p != this) return; IT_IT("SampleCfg::QueryResponse"); switch (State) { case tList: { // fill the name list box List->clear(); int n = GetConfigureDb()->GetNumberResults(); for(int i = 0; i < n; i++,GetConfigureDb()->FetchNext()) { (void) new QListViewItem(List,GetConfigureDb ()->GetString("NAME"),UndoEscapeSQLText(GetConfigureDb()->GetString("COMMENT"))); }; List->setCurrentItem (List->firstChild()); List->setFocus(); SelChanged(0); // force the top item to fetch // }; break; // we have chained a transaction case tUnitList: { GetConfigureDb ()->FillComboBox (Unit, "NAME"); Unit->insertItem (tr(NONE_STR)); SetComboItem(Unit,tr(NONE_STR)); ButtonState (true); }; break; case tItem: { // // fill the fields // Comment->setText (UndoEscapeSQLText(GetConfigureDb()->GetString ("COMMENT"))); Units->setEditText (GetConfigureDb ()->GetString ("UNITS")); Enabled->setChecked (GetConfigureDb ()->GetBool ("ENABLED")); Fileable->setChecked (GetConfigureDb ()->GetBool ("FILEABLE")); LogMode->setChecked (GetConfigureDb ()->GetBool("LOGMODE")); Retrigger->setChecked (GetConfigureDb ()->GetBool("RETRIGGER")); AlarmThreshold->setValue(GetConfigureDb ()->GetInt("ALARMTHRESHOLD")); //Comment->setFocus (); List->setFocus(); ButtonState (true); // // save the input index and type until we have sorted out the Unit -> Unit Class -> type list -> input indices // tmp_ip_index = GetConfigureDb ()->GetString ("IPINDEX"); tmp_type = GetConfigureDb ()->GetString ("QTYPE"); // // IT_COMMENT2("Handling tItem new type , index %s %s", (const char *) tmp_ip_index, (const char *)tmp_type); // Now query the driver DLL for what the input type options are and what input indices are available if(Unit->currentText() != GetConfigureDb ()->GetString ("UNIT")) { // this is an expensive operation - so avoid where possible SetComboItem (Unit, GetConfigureDb ()->GetString ("UNIT")); UnitChanged (0); } else { // unit type has not changed // has the input type changed SetComboItem(Type,tmp_type); // set to the target type TypeChanged(0); // get the list of permitted input indices // }; }; break; case tUnitType: { unit_type = tr(NONE_STR); if(GetConfigureDb ()->GetNumberResults() > 0) { unit_type = GetConfigureDb()->GetString("UNITTYPE"); // store it pCfgDriver = FindDriver(unit_type); // get the driver interface object // // set the permitted types // Type->clear(); // if(pCfgDriver) { // what types ar epermitted pCfgDriver->SetTypeList(Type, Unit->currentText()); } else { // there is no driver - set all to none Type->insertItem(tr(NONE_STR)); tmp_ip_index = tr(NONE_STR); tmp_type = tr(NONE_STR); InputIndex->clear(); InputIndex->insertItem(tr(NONE_STR)); }; // SetComboItem(Type,tmp_type); // set to the target type TypeChanged(0); // handle the change of type - this set the permitted indices // }; }; break; case tConfigLoad: { #ifdef DEPRECATED_IEC104_CONFIG if(Name->text() == GetConfigureDb()->GetString("IKEY")) // may be several queued up #else if(Name->text() == GetConfigureDb()->GetString("NAME")) // may be several queued up #endif { emit LoadConfig (Name->text()); // ask it to load - we pass in the obejct name // it a given that the current configuration record is the property record // pass even if nothing as the dialog shoudl provide defaults when no data is found }; }; break; case tTagList: { // got the current tag list - look up what it should be int n = GetConfigureDb()->GetNumberResults(); QStringList list; if(pCfgDriver) { pCfgDriver->GetTagList(Type->currentText(),list,Unit->currentText(),Name->text()); QStringList currentList; // current list of tags // if(n) { for(int j = 0; j < n; j++,GetConfigureDb()->FetchNext()) { currentList << GetConfigureDb()->GetString("TAG"); }; pCfgDriver->CheckTags(Name->text(), currentList, list); } else { //we are creating a new sample point pCfgDriver->CreateSamplePoint(Name->text(), list, " "); } }; ButtonState (true); }; break; case tIpIndex: { // // Edit the list - remove those in use int n = GetConfigureDb ()->GetNumberResults(); InputIndex->clear(); if(n > 0) { for(int i= 0; i < n; i++,GetConfigureDb()->FetchNext()) { int id = CurrentTypeList.findIndex(GetConfigureDb()->GetString("IPINDEX")); if(id != -1) { CurrentTypeList.remove(CurrentTypeList.at(id)); // delete it }; }; }; // for(unsigned i = 0; i < CurrentTypeList.count(); i++) { InputIndex->insertItem(CurrentTypeList[i]); }; // InputIndex->insertItem(tmp_ip_index); SetComboItem(InputIndex,tmp_ip_index); // }; break; case tNew: ButtonState (true); default: break; }; //cerr << "Exit QueryResponse " << endl; };