本文整理汇总了C++中Port::close方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::close方法的具体用法?C++ Port::close怎么用?C++ Port::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkSendReceive
void checkSendReceive()
{
report(0,"check matrix send/receive");
Port portIn;
Port portOut;
MThread2 *receiverThread=new MThread2(&portIn);
MThread1 *senderThread=new MThread1(&portOut);
portOut.open("/harness_sig/mtest/o");
portIn.open("/harness_sig/mtest/i");
Network::connect("/harness_sig/mtest/o", "/harness_sig/mtest/i");
receiverThread->start();
senderThread->start();
receiverThread->stop();
senderThread->stop();
portOut.close();
portIn.close();
checkTrue(senderThread->success, "Send matrix test");
checkTrue(receiverThread->success, "Receive matrix test");
delete receiverThread;
delete senderThread;
}
示例2: close
/*
* Close function, to perform cleanup.
*/
bool close()
{
vergencePort.close();
handlerPort.close();
suspendPort.close();
return true;
}
示例3: close
bool close()
{
// order does matter!
imageInPort.close();
coordPort.close();
imageOutPort.close();
return true;
}
示例4: testCloseOpenRepeats
virtual void testCloseOpenRepeats() {
report(0,"check that opening-closing-opening etc is ok...");
report(0,"non-buffered port:");
Port p;
p.open("/test1");
p.open("/test2");
p.open("/test3");
p.close();
p.open("/test4");
p.close();
report(0,"buffered port:");
BufferedPort<Bottle> p2, p3;
p2.open("/test1");
p2.open("/test2");
p2.open("/in");
p3.open("/out");
Network::connect("/out","/in");
p3.prepare().fromString("10 20 30");
p3.write();
report(0,"wait for input...");
p2.read(true);
report(0,"... got it");
p3.prepare().fromString("10 20 30");
p3.write();
p2.open("/test1");
p3.open("/test2");
Network::connect("/test2","/test1");
p3.prepare().fromString("10 20 30");
p3.write();
report(0,"wait for input...");
p2.read(true);
report(0,"... got it");
report(0,"fast loop on temporary port");
for (int i=0; i<20; i++) {
Port p;
Port p2;
p.open("...");
p2.open("...");
p.close();
}
Port pa;
pa.open("...");
for (int i=0; i<20; i++) {
Port p;
p.enableBackgroundWrite(true);
p.open("...");
NetworkBase::connect(p.getName(),pa.getName());
Bottle b("10 20 30");
p.write(b);
pa.read(b);
p.close();
}
}
示例5: close
bool close()
{
// Close ports
rpcPort.close();
imInPort.close();
imOutPort.close();
tempOutPort.close();
coordsInPort.close();
trackInPort.close();
coordsOutPort.close();
return true;
}
示例6: close
bool close()
{
igaze->restoreContext(startup_context_gaze);
drvGaze.close();
iarm->restoreContext(startup_context_arm);
drvArm.close();
imgLPortIn.close();
imgRPortIn.close();
imgLPortOut.close();
imgRPortOut.close();
rpcPort.close();
return true;
}
示例7: close
virtual bool close()
{
rpcPort.interrupt();
rpcPort.close();
thread.stop();
velThread.stop();
velPort.interrupt();
velPort.close();
velInitPort.interrupt();
velInitPort.close();
return true;
}
示例8: close
void close()
{
mutex.wait();
if (dump_code)
{
fclose(fout_code);
}
port_out_code.close();
port_out_img.close();
BufferedPort<Image>::close();
mutex.post();
}
示例9: close
bool close(){
cout << "closing .." << endl;
vGrabber.close();
outPort.close();
handlerPort.close();
return true;
}
示例10: companion_sigint_handler
static void companion_sigint_handler(int sig) {
double now = Time::now();
static double firstCall = now;
static bool showedMessage = false;
static bool unregistered = false;
done = 1;
//sleep(1);
if (now-firstCall<2) {
Port *port = companion_active_port;
if (!showedMessage) {
showedMessage = true;
//YARP_LOG_INFO("Interrupting...");
}
if (companion_unregister_name!="") {
if (!unregistered) {
unregistered = true;
NetworkBase::unregisterName(companion_unregister_name);
if (port!=NULL) {
NetworkBase::unregisterName(port->getName());
}
exit(1);
}
}
if (port!=NULL) {
port->interrupt();
#ifndef YARP2_WINDOWS
port->close();
#endif
}
} else {
fprintf(stderr,"Aborting...\n");
exit(1);
}
}
示例11: close
bool close() override
{
t->stop();
if (type==bottle)
{
p_bottle->interrupt();
p_bottle->close();
delete p_bottle;
}
else
{
p_image->interrupt();
p_image->close();
delete p_image;
}
rpcPort.interrupt();
rpcPort.close();
delete t;
delete q;
return true;
}
示例12: threadRelease
virtual void threadRelease() {
/* Stop and close ports */
cportL->interrupt();
cportR->interrupt();
susPort->interrupt();
cportL->close();
cportR->close();
susPort->close();
delete cportL;
delete cportR;
delete susPort;
/* stop motor interfaces and close */
gaze->stopControl();
clientGazeCtrl.close();
carm->stopControl();
clientArmCart.close();
robotTorso.close();
robotHead.close();
robotArm.close();
}
示例13: rosToKind
std::string TcpRosStream::rosToKind(const char *rosname) {
if (ConstString(rosname)=="") return "";
std::map<std::string, std::string> kinds = rosToKind();
if (kinds.find(rosname)!=kinds.end()) {
return kinds[rosname];
}
Port port;
port.openFake("yarpidl_rosmsg");
if (port.addOutput("/typ")) {
Bottle cmd, resp;
cmd.addString(ConstString("twiddle ") + rosname);
dbg_printf("QUERY yarpidl_rosmsg %s\n", cmd.toString().c_str());
port.write(cmd,resp);
dbg_printf("GOT yarpidl_rosmsg %s\n", resp.toString().c_str());
ConstString txt = resp.get(0).asString();
if (txt!="?") return txt;
}
port.close();
if (ConstString(rosname)!="") {
fprintf(stderr, "Do not know anything about type '%s'\n", rosname);
fprintf(stderr, "Could not connect to a type server to look up type '%s'\n", rosname);
::exit(1);
}
return "";
}
示例14: close
virtual bool close()
{
rpcPort.interrupt();
rpcPort.close();
return true;
}
示例15: client
int client(int nframes)
{
double delay = 0;
int count = 0;
int wait = 10;
Port port;
port.open("/profiling/port2");
while(!Network::connect("/profiling/port","/profiling/port2"))
{
fprintf(stderr, "Waiting for connection\n");
Time::delay(0.5);
}
while(count<nframes)
{
Bottle datum;
port.read(datum);
double t=datum.get(0).asDouble();
double now=Time::now();
delay+=(now-t)*1000;
count++;
// remove this to spare cpu time
fprintf(stderr, "%lf\n", (now-t)*1000);
}
port.close();
fprintf(stderr, "Received: %d average latency %.3lf[ms]\n",
count, delay/count);
return 0;
}