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


C++ YARPSemaphore::Wait方法代码示例

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


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

示例1: Body

	virtual void Body()
    {
		int ct = 0;
		char txt[128] = "Hello there";
		char reply[128] = "Not set";

		YARPUniqueNameID* id = NULL;

		do 
		{
			out.Wait();
			cout << "Looking up name" << endl;
			cout.flush();
			out.Post();
			id = YARPNameService::LocateName(REG_LOCATE_NAME, NET_NAME);
			if (id->getServiceType () == YARP_NO_SERVICE_AVAILABLE)
			{
				ACE_DEBUG ((LM_DEBUG, "can't locate name, bailing out\n"));
				return;
			}

			id->setServiceType(YARP_TCP);
			YARPEndpointManager::CreateOutputEndpoint (*id);
			YARPEndpointManager::ConnectEndpoints (*id, SRC_NAME);

			YARPTime::DelayInSeconds(0.2);
		} 
		while (!id->isValid());

		int x = 42;
		while (!IsTerminated())
		{
			out.Wait();
			cout << "Preparing to send: " << txt << endl;
			cout.flush();
			out.Post();

			YARPMultipartMessage smsg(2);
			smsg.Set(0,txt,sizeof(txt));
			smsg.Set(1,(char*)(&x),sizeof(x));
			YARPMultipartMessage rmsg(2);
			double y = 999;
			rmsg.Set(0,reply,sizeof(reply));
			rmsg.Set(1,(char*)(&y),sizeof(y));
			cout << "***sending: " << txt << endl;
			cout.flush();
			YARPSocketSyncComm::Send(*id,smsg,rmsg);
			x++;

			out.Wait();
			cout << "Got reply : " << reply << " and number " << y << endl;
			cout.flush();
			out.Post();

			YARPTime::DelayInSeconds(2.0);

			ct++;
			sprintf(txt, "And a-%d", ct);
		}
    }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:60,代码来源:test04.cpp

示例2: Body

    virtual void Body()
    {
        int ct = 0;
        char txt[128] = "Hello there";
        char reply[128] = "Not set";

        YARPUniqueNameID* id = NULL;
        cout << "Here" << endl;
        cout.flush();

        do
        {
            out.Wait();
            cout << "Looking up name" << endl;
            cout.flush();
            out.Post();

            id = YARPNameService::LocateName(REG_LOCATE_NAME, NET_NAME);
            if (id->getServiceType () == YARP_NO_SERVICE_AVAILABLE)
            {
                ACE_DEBUG ((LM_DEBUG, "can't locate name, bailing out\n"));
                return;
            }

            YARPEndpointManager::CreateOutputEndpoint (*id);
            YARPEndpointManager::ConnectEndpoints (*id, SRC_NAME);

            if (!id->isValid())
            {
                YARPTime::DelayInSeconds(0.2);
            }
        }
        while (!id->isValid());

        while (!IsTerminated())
        {
            out.Wait();
            cout << "Preparing to send: " << txt << endl;
            cout.flush();
            out.Post();

            YARPSyncComm::Send(id->getNameID(),txt,sizeof(txt),reply,sizeof(reply));

            out.Wait();
            cout << "Got reply : " << reply << endl;
            cout.flush();
            out.Post();

            YARPTime::DelayInSeconds(2.0);

            ct++;
            sprintf(txt, "And a-%d", ct);
        }
    }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:54,代码来源:test02.cpp

示例3: SetGyro

 void SetGyro(double n_yaw, double n_pitch, double n_roll)
   { 
     mutex.Wait();
     state.yaw = n_yaw;  state.pitch = n_pitch;  state.roll = n_roll; 
     last_gyro_time = YARPTime::GetTimeAsSeconds();
     mutex.Post();
   }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:7,代码来源:egomap-working.cpp

示例4: main

int main()
{
  in_gyro.Register("/egomap/i:gyro");
  in_eye.Register("/egomap/i:eye");
  out_dir.Register("/egomap/o:dir");

  while (1)
    {
      wake_up_call.Wait();

      HeadState state;
      int ok = head_state_manager.Get(state);
      if (ok)
	{
	  CogGaze dir;
	  dir.Apply(state.joints);
	  
	  printf("LEFT %+8.2f %+8.2f %+8.2f      RIGHT %+8.2f %+8.2f %+8.2f\n", 
		 dir.theta_left*180.0/M_PI, 
		 dir.phi_left*180.0/M_PI,
		 dir.roll_left*180.0/M_PI,
		 dir.theta_right*180.0/M_PI, 
		 dir.phi_right*180.0/M_PI,
		 dir.roll_right*180.0/M_PI);
	}
      //YARPTime::DelayInSeconds(0.05);
    }

  return 0;
}
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:30,代码来源:egomap-working.cpp

示例5: OnRead

 virtual void OnRead()
   {
     assert(Read(0));
     state_mutex.Wait();
     state_joint = Content();
     state_mutex.Post();
   }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:7,代码来源:egomap-spiderman.cpp

示例6: MarkTarget

void MarkTarget(int id)
{
  printf("Marking current region as target %d\n", id);
  state_mutex.Wait();
  target_manager.Set(id,global_theta,global_phi);
  state_mutex.Post();
}
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:7,代码来源:egomap-spiderman.cpp

示例7: SetJoints

 void SetJoints(JointPos& j)
   {
     mutex.Wait();
     state.joints = j;
     last_neck_time = YARPTime::GetTimeAsSeconds(); 
     mutex.Post();
   }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:7,代码来源:egomap-working.cpp

示例8: RegisterName

int YARPSocketNameService::RegisterName(const char *name)
{

  int name_status = -1;
  int result = -1;

  //static YARPInputSocket sock;
  //sock.Register(name);
  //test_global = &sock;

  DBG(5) printf("^^^^^^^^ checking for previous definitions\n");
  if (GetThreadSocket()==NULL)
    {
      DBG(5) printf("^^^^^^^^ checks out okay\n");
      int pid = my_getpid();
      mutex.Wait();
      DBG(5) printf("^^^^^^^^ creating\n");
      YARPInputSocket *is = new YARPInputSocket;
      is_map[pid] = is;
      DBG(5) printf("^^^^^^^^ preparing to register\n");
      is->Register(name);
      result = is->GetAssignedPort();
      mutex.Post();
      DBG(5) printf("^^^^^^^^ Made an input socket handler\n");
      fflush(stdout);
    }

  return result;
}
开发者ID:paulfitz,项目名称:poker,代码行数:29,代码来源:YARPSocketNameService.cpp

示例9: ResetControl

void ResetControl()
{
  mutex.Wait();
  HeadMessage& msg = out_cmd.Content();
  msg.type = HeadMsgNonValid;
  out_cmd.Write();
  mutex.Post();
}
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:8,代码来源:egomap-spiderman.cpp

示例10: SetEyes

 void SetEyes(double n_tilt, double n_left_pan, double n_right_pan)
   { 
     mutex.Wait();
     state.tilt = n_tilt;  state.left_pan = n_left_pan;  
     state.right_pan = n_right_pan;
     last_eyes_time = YARPTime::GetTimeAsSeconds(); 
     mutex.Post();
   }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:8,代码来源:egomap-working.cpp

示例11: Get

 int Get(HeadState& dest)
   {
     int result = IsValid();
     mutex.Wait();
     dest = state;
     mutex.Post();
     return result;
   }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:8,代码来源:egomap-working.cpp

示例12: BeginObservations

  void BeginObservations()
    {
      if (!observing)
	{
	  mutex.Wait();
	  UpdateActivity();
	  observing = 1;
	}
    }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:9,代码来源:face_tracker.cpp

示例13: IsValid

  int IsValid()
    {
      double now = YARPTime::GetTimeAsSeconds();
      mutex.Wait();
      int result = /*(now-last_gyro_time<1)&&*/(now-last_eyes_time<1)&&
	(now-last_neck_time<1);
      mutex.Post();
      return result;
    }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:9,代码来源:egomap-working.cpp

示例14: SetNeck

  void SetNeck(double n_tilt, double n_roll,
	       double n_lean, double n_pan)
    {
      mutex.Wait();
      state.neck_tilt = n_tilt;
      state.neck_roll = n_roll;
      state.neck_lean = n_lean;
      state.neck_pan = n_pan;
      //last_neck_time = YARPTime::GetTimeAsSeconds(); 
      mutex.Post();
    }
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:11,代码来源:egomap-working.cpp

示例15: RemovePort

// LATER: find out why this is commented out.
static void RemovePort(YARPPort *port)
{
	ACE_UNUSED_ARG(port);

	port_list_mutex.Wait();

//#ifndef __QNX__
	//  port_list.erase(port);
//#endif
	port_list_mutex.Post();
}
开发者ID:robotology-legacy,项目名称:yarp1,代码行数:12,代码来源:YARPPort.cpp


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