/*! \fn ThreadContrl::RefreshMonitors(CMonitorList &lstMonitor) */ void ThreadContrl::RefreshMonitors(CMonitorList &lstMonitor) { if(lstMonitor.size()==1) { puts("Enter"); Monitor *pm=lstMonitor.front(); ExecuteMonitor(pm); lstMonitor.pop_front(); delete pm; return ; } CMonitorList::iterator it; for(it=lstMonitor.begin();it!=lstMonitor.end();it++) { Monitor *pM=*it; pM->m_isRefresh=true; while(1) { MonitorThread *pThread=(MonitorThread*)GetIdleThread(); if(pThread) { pThread->ExecuteMonitor(pM); break; } else { ThreadEx::sleep(1000); continue; } } } //wait for monitor complete BOOL hasRuning; for(int n=0;n<300;n++) { hasRuning=TRUE; for(it=lstMonitor.begin();it!=lstMonitor.end();it++) { if((*it)->GetRunning()) { hasRuning=FALSE; break; } } if(hasRuning) break; ThreadEx::sleep(1000); } }
void testmonitor(void) { putil=new Util; try{ putil->Init(); LoadConfig lc; lc.LoadAll(); CMonitorList Monitorlst; lc.CreateMonitors(Monitorlst); int count =Monitorlst.size(); printf("%d monitor be load\n",count); //Monitor *pM=NULL; //POSITION pos=Monitorlst.GetHeadPosition(); //POSITION pos2=NULL,pos3=NULL; CMonitorList::iterator it=Monitorlst.begin(); ReturnData* prd=NULL; int n=0; while(Monitorlst.size()>0) { // pM=Monitorlst.RemoveTail(); Monitor*pM=Monitorlst.front(); Monitorlst.pop_front(); // pM=Monitorlst.GetNext(pos); printf("\n------------MonitorID:%s----------------\n",pM->GetMonitorID()); printf("MonitorID:%s\nClass:%s\nMonitorType:%d\nSEID:%s\nParentID:%s\nFrequency:%d\n", \ (char*)pM->GetMonitorID(),(char*)pM->GetMonitorClass(),pM->GetMonitorType(),pM->GetSEID().c_str(),pM->GetParentID().c_str(), \ pM->GetFrequency()); puts("\n@@Parameter list@@"); CStringList &lst=pM->GetParameterList(); CStringList::iterator it2; it2=lst.begin(); while(it2!=lst.end()) printf("%s\n",*it2++); puts("\n+++ReturnList+++\n"); CReturnDataList&rdl=pM->GetReutrnList(); CReturnDataList::iterator it3; // pos3=rdl.GetHeadPosition(); it3=rdl.begin(); while(it3!=rdl.end()) { //prd=rdl.GetNext(pos3); prd=*it3++; printf("Label:%s\nName:%s\nUnit:%s\nType:%s\n",(char *)prd->m_Label,(char *)prd->m_Name,(char *)prd->m_Unit,(char *)prd->m_Type); } puts("\n===StateCondition===\n"); StateCondition ** sct=pM->GetStateCondition(); StateCondition *psct=sct[0]; printf("Expression:%s\nStateType:%d\n",(char *)psct->m_Expression,psct->m_Type); CStateConditionItemList&Item=psct->GetStateConditionList(); //pos2=Item.GetHeadPosition(); CStateConditionItemList::iterator it4; it4=Item.begin(); while(it4!=Item.end()) { // StateConditionItem *psti=Item.GetNext(pos2); StateConditionItem *psti=*it4++; printf("ItemID:%d\nOperator:%s\nName:%s\nValue:%s\n",psti->m_ItemID,(char*)psti->m_Operator,(char*)psti->m_ParamName,(char *)psti->m_ParamValue); } psct=sct[1]; printf("Expression:%s\nStateType:%d\n",(char *)psct->m_Expression,psct->m_Type); CStateConditionItemList&Item2=psct->GetStateConditionList(); // pos2=Item2.GetHeadPosition(); it4=Item2.begin(); while(it4!=Item2.end()) { // StateConditionItem *psti=Item2.GetNext(pos2); StateConditionItem *psti=*it4++; printf("ItemID:%d\nOperator:%s\nName:%s\nValue:%s\n",psti->m_ItemID,(char*)psti->m_Operator,(char*)psti->m_ParamName,(char *)psti->m_ParamValue); } psct=sct[2]; printf("Expression:%s\nStateType:%d\n",(char *)psct->m_Expression,psct->m_Type); CStateConditionItemList&Item3=psct->GetStateConditionList(); // pos2=Item3.GetHeadPosition(); it4=Item3.begin(); while(it4!=Item3.end()) { // StateConditionItem *psti=Item3.GetNext(pos2); StateConditionItem *psti=*it4++; printf("ItemID:%d\nOperator:%s\nName:%s\nValue:%s\n",psti->m_ItemID,(char*)psti->m_Operator,(char*)psti->m_ParamName,(char *)psti->m_ParamValue); } n++; delete pM; } printf("Total %d monitors\n",n); } catch(MSException &e) { printf("putil init exception:%s\n",e.Description); return ; } }