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


C++ Tester::SetInterval方法代码示例

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


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

示例1: main_int

int main_int(int argc, char** argv)
{
   SessionManager* smgr;
   Tester engine;
   Object::Vector list;
   Object::AttributeMap args;
//   ClassKey ckey;
   MethodResponse result;
   std::string id;
   const char* host = argc>1 ? argv[1] : "127.0.0.1";
   int port = argc>2 ? atoi(argv[2]) : 5672;
   uint32_t trigger_id;
   int32_t interval;
   time_t first_event, second_event;

   engine.init(host, port);
   smgr = engine.GetSessionManager();

   smgr->getObjects(list, "agent");
   smgr->getObjects(list, "condortrigger");
   cout << "Currently installed triggers:" << endl;
   for (Object::Vector::iterator iter = list.begin(); iter != list.end(); iter++)
   {
      cout << "Trigger ID: " << atoll(iter->getIndex().c_str()) << endl;
      iter->invokeMethod("GetTriggerName", args, result);
      cout << "Trigger Name: " << result.arguments.begin()->second->str() << endl;
      iter->invokeMethod("GetTriggerQuery", args, result);
      cout << "Trigger Query: " << result.arguments.begin()->second->str() << endl;
      iter->invokeMethod("GetTriggerText", args, result);
      cout << "Trigger Text: " << result.arguments.begin()->second->str() << endl << endl;
   }

   // Set the evaluation interval to 5 seconds
   engine.SetInterval(5);
   interval = engine.GetInterval();

   if (interval != 5)
   {
      cout << "Error: Interval was not to 5 seconds" << endl;
   }

   // Add a trigger and verify an event is received
   engine.AddTrigger("TestTrigger", "(SlotID == 1)", "$(Machine) has a slot 1");

   while (false == engine.GetEventReceived())
   {
      sleep(1);
   }
   first_event = time(NULL);
   engine.ResetEventReceived();

   while (false == engine.GetEventReceived())
   {
      sleep(1);
   }
   second_event = time(NULL);
   engine.ResetEventReceived();

   if ((second_event - first_event) > 6)
   {
      cout << "Error: Trigger evaluations occurring greater than evey 5 seconds" << endl;
   }
   else
   {
      cout << "Trigger evaluations occurring every 5 seconds" << endl;
   }

   // Retrieve the ID of the trigger added
   smgr->getObjects(list, "agent");
   smgr->getObjects(list, "condortrigger");
   for (Object::Vector::iterator iter = list.begin(); iter != list.end(); iter++)
   {
      iter->invokeMethod("GetTriggerName", args, result);
      if (result.arguments.begin()->second->str() == "TestTrigger")
      {
         cout << "Getting trigger id" << endl;
         trigger_id = atoll(iter->getIndex().c_str());
         break;
      }
   }

   // Change the trigger Name and verify an event is received
   engine.ChangeTriggerName(trigger_id, "Changed Test Trigger");
   while (false == engine.GetEventReceived())
   {
      sleep(1);
   }
   engine.ResetEventReceived();

   // Change the trigger query and text and verify an event is received
   engine.ChangeTriggerQuery(trigger_id, "(SlotID > 0)");
   engine.ChangeTriggerText(trigger_id, "$(Machine) has a slot $(SlotID)");
   while (false == engine.GetEventReceived())
   {
      sleep(1);
   }
   engine.ResetEventReceived();

   // Remove the trigger
   engine.RemoveTrigger(trigger_id);
//.........这里部分代码省略.........
开发者ID:AlainRoy,项目名称:htcondor,代码行数:101,代码来源:test_triggers.cpp


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