/* * Start the sync process. * SyncSources are managed (created, initialized, deleted) inside * this method. When SyncSource array is ready, the method 'sync(sources**)' * is called to start the sync process. * * @param sourceNames: optional, a NULL terminated array of source names that * we want to sync. If NULL, sources to sync are chosen * from the configuration object (config). * @return: 0 on success, an error otherwise */ int SyncClient::sync(AbstractSyncConfig& config, char** sourceNames) { AbstractSyncSourceConfig* sc = NULL; SyncSource **sources = NULL; const char* currName; int currSource = 0, numActive = 0, numSources = 0; int ret = 0; ret = prepareSync(config); if (ret) { LOG.error("SyncClient: prepareSync returned error code: %d.", ret); goto finally; } // Get number of sources: from passed parameter or (if NULL) from config. numSources = 0; if (sourceNames) { while (sourceNames[numSources]) { numSources ++; } } else { numSources = config.getAbstractSyncSourceConfigsCount(); } // make room for all potential sync sources sources = new SyncSource* [numSources + 1]; // iterate over all configs and add those which the client // wants to have synchronized while (currSource < numSources) { // use only sources indicated in 'sourceNames' param if (sourceNames) { currName = sourceNames[currSource]; if (! (sc = config.getAbstractSyncSourceConfig(currName)) ) { if (sources) delete [] sources; return getLastErrorCode(); } } // use all available sources from config else { if (! (sc = config.getAbstractSyncSourceConfig(currSource)) ) { if (sources) delete [] sources; return getLastErrorCode(); } currName = sc->getName(); } ret = createSyncSource(currName, currSource, sc, sources + numActive); if (ret) { LOG.error("SyncClient: createSyncSource returned error code: %d.", ret); goto finally; } if (sources[numActive]) { numActive++; } currSource++; } sources[numActive] = NULL; ret = beginSync(sources); if (ret) { LOG.error("SyncClient: beginSync returned error code: %d.", ret); goto finally; } // // ready to synchronize // ret = sync(config, sources); if (ret) { goto finally; } ret = endSync(sources); if (ret) { LOG.error("SyncClient: endSync returned error code: %d.", ret); } finally: if (sources) { for (int i=0; sources[i]; i++) { delete sources[i]; } delete [] sources; } return ret; }
void stdc::ControllerImpl::applyAttrs(){ crtc::ItemNode::applyAttrs(); // stage two activation ( after dom tree building done ) //Находим УАРТ который рулит модулями if( uart = static_cast<stdc::UartImpl*>( find__("uart")) ){ ; } else{ crtcLog<<"stdc::Controller !! Ошибка адаптации не найден УАРТ (stdc:Uart)\n"; crtcEXIT("Критическая ошибка"); } //Найдем объект с порогами на значения limits = dynamic_cast<stdc::Ilimits*>(find__("stdc_limits")); if (!limits) crtcLog<<"stdc::Controller !! Не найден компонент с пороговыми значениями (<stdc:Limits id='stdc_limits' ... >)\n"; //Создаем список объектов ТИ //Подписываем себя на события от SectionProxy std::list<crtc::ItemImpl*> iis; long rc = _cntx_->registry()->getItems( "*", iis ); std::list<crtc::ItemImpl*>::iterator beg = iis.begin(); std::list<crtc::ItemImpl*>::iterator end = iis.end(); while (beg != end ){ std::string _repo = static_cast<crtc::ItemImpl*>(*beg)->getRepo__(); if (_repo == "IDL:stdc/SectionProxy:1.0" ){ crtc::ItemImpl *ss = 0; ss =find__( (*beg)->getId__() ); if (ss){ ss -> subs__("popup", this); //Создаем список объектов телеизмерений crtc::ItemNode* sectProxy = 0; sectProxy = ss; const char* _sectionId; if (sectProxy->hasAttribute("sectionId")) _sectionId = sectProxy->getAttributeText("sectionId"); else{ crtcLog<<"stdc::Controller::Error отсутствует аттрибут sectionId\n"; crtcEXIT("Критическая ошибка"); } if (sectProxy){ crtc::ItemNode *points = sectProxy->firstChild; while (points ){ const char *unit, *ak, *side, *key, *mode, *fasa, *subtitle, *label, *source; if (points->hasAttribute("unit")){ unit = points->getAttributeText("unit"); if (points->hasAttribute("ak")) ak = points->getAttributeText("ak"); else{ crtcLog<<"stdc::SectionProxy::Error в потомке "<<_sectionId<<" отсутвует аттрибут ak="". Номер модуля АК\n"; crtcEXIT("Критическая ошибка"); } if (points->hasAttribute("side")) side = points->getAttributeText("side"); else{ crtcLog<<"stdc::SectionProxy::Error в потомке "<<_sectionId<<" отсутвует аттрибут side="". Сторона мадуля АК.\n"; crtcEXIT("Критическая ошибка"); } if (points->hasAttribute("key")) key = points->getAttributeText("key"); else{ crtcLog<<"stdc::SectionProxy::Error в потомке "<<_sectionId<<" отсутвует аттрибут key="". Номер ключа\n"; crtcEXIT("Критическая ошибка"); } if (points->hasAttribute("mode")) mode = points->getAttributeText("mode"); else{ crtcLog<<"stdc::SectionProxy::Error в потомке "<<_sectionId<<" отсутвует аттрибут mode="". Режим работы ключа\n"; crtcEXIT("Критическая ошибка"); } if (points->hasAttribute("subtitle")) subtitle = points->getAttributeText("subtitle"); else{ crtcLog<<"stdc::SectionProxy::Error в потомке "<<_sectionId<<" отсутвует аттрибут subtite="". Название точки подключения.\n"; crtcEXIT("Критическая ошибка"); } //необязательные атрибуты if (points->hasAttribute("Phdop")) fasa = points->getAttributeText("Phdop"); else fasa =""; if (points->hasAttribute("source")) source = points->getAttributeText("source"); else source ="VAC"; //создаем элемент в таблице объектов измерения char buff[200]; if (std::string(ss->getId__()).find("Section") != std::string::npos ) snprintf(buff, sizeof(buff), "%sСП %s", _sectionId, subtitle); else if (std::string(ss->getId__()).find("Way") != std::string::npos ) snprintf(buff, sizeof(buff), "%sП %s", _sectionId, subtitle); else snprintf(buff, sizeof(buff), "%s %s", _sectionId, subtitle); //выясняем есть ли по этому объекту измерение изоляции bool isIsol=0; char ak_name[7]; snprintf(ak_name, sizeof(ak_name),"ak%s", ak ); if (strcmp("none", uart->getIon4Ak( ak_name ))) isIsol = 1; _in_items[std::string(unit) ] = new stdItem(ak, side, key, mode, unit, fasa, buff, ss, isIsol, source ); } points = points->nextSibling; } } } } beg++; } //check... if (_in_items.size() == 0 ) crtcEXIT ("Мега ошибка. Нету объектов измерения.\n Проверте: 1. Адаптацию 2. Собраны ли модули stdc::SectionProxy или stdc::IsolUnit"); //for test if (_in_debug){ std::cout<<"Известные объекты телеизмерений _in_items:\n"; StdItems::iterator begin = _in_items.begin(); StdItems::iterator end1 = _in_items.end(); while(begin!=end1){ std::cout<<begin->first.c_str(); std::cout<<" ak="<<begin->second->ak<<" side="<<begin->second->side<<" key="<<begin->second->key<<" mode="<<begin->second->mode; std::cout<<" unit='"<<begin->second->unit<<"' fasa="<<begin->second->fasa<<" title='"<<begin->second->label.c_str()<<"' isIsol= '"<<begin->second->isIsol<<"'\n"; begin++; } } //Подготовка для циклических измерений. if (_in_voltMeasureDelay < 3) _in_voltMeasureDelay == 3; registerForPoll__(_in_voltMeasureDelay); registerForStep__(); circleItem = _in_items.begin(); viewItem = _in_items.begin(); circleIsolIter = _in_items.begin(); createTZK(); readData(); //for syncAnalogData if ( _in_syncPort ) prepareSync(); //start circle diment circleIn(1); }