source: flair-src/trunk/lib/FlairSensorActuator/src/VrpnClient.cpp@ 309

Last change on this file since 309 was 309, checked in by Sanahuja Guillaume, 3 years ago

vrpnlite support

File size: 2.7 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2013/04/03
6// filename: VrpnClient.cpp
7//
8// author: César Richard, Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Class to connect to a Vrpn server
14//
15/*********************************************************************/
16
17#include "VrpnClient.h"
18#include "VrpnClient_impl.h"
19#include <FrameworkManager.h>
20#include <TabWidget.h>
21#include <Layout.h>
22
23using std::string;
24using namespace flair::core;
25using namespace flair::gui;
26
27namespace {
28 flair::sensor::VrpnClient *singleton = NULL;
29}
30
31
32namespace flair {
33namespace sensor {
34
35VrpnClient *GetVrpnClient(void) { return singleton; }
36
37VrpnClient::VrpnClient(string name,
38 string address, uint8_t priority)
39 : Thread(getFrameworkManager(), name, priority) {
40 if (singleton != NULL) {
41 SimpleWarn("VrpnClient should be instanced only one time!\n");
42 SimpleWarn("Next calls to GetVrpnClient() will return the first created VrpnClient (%s)\n",singleton->ObjectName().c_str());
43 } else {
44 singleton = this;
45 }
46
47 pimpl_ = new VrpnClient_impl(this, name, address);
48}
49
50
51VrpnClient::VrpnClient(std::string name,
52 uint16_t port, uint8_t priority)
53 : Thread(getFrameworkManager(), name, priority) {
54 if (singleton != NULL) {
55 SimpleWarn("VrpnClient should be instanced only one time!\n");
56 SimpleWarn("Next calls to GetVrpnClient() will return the first created VrpnClient (%s)\n",singleton->ObjectName().c_str());
57 } else {
58 singleton = this;
59 }
60
61 pimpl_ = new VrpnClient_impl(this, name, port);
62}
63
64VrpnClient::VrpnClient(string name,
65 SerialPort *serialport, uint16_t us_period,
66 uint8_t priority)
67 : Thread(getFrameworkManager(), name, priority) {
68 if (singleton != NULL) {
69 SimpleWarn("VrpnClient should be instanced only one time!\n");
70 SimpleWarn("Next calls to GetVrpnClient() will return the first created VrpnClient (%s)\n",singleton->ObjectName().c_str());
71 } else {
72 singleton = this;
73 }
74
75 pimpl_ = new VrpnClient_impl(this, name, serialport, us_period);
76}
77
78VrpnClient::~VrpnClient() {
79 SafeStop();
80 Join();
81
82 delete pimpl_;
83}
84
85VrpnClient::ConnectionType_t VrpnClient::ConnectionType(void) const {
86 return pimpl_->connectionType;
87}
88
89Layout *VrpnClient::GetLayout(void) const {
90 return (Layout *)(pimpl_->setup_tab);
91}
92
93TabWidget *VrpnClient::GetTabWidget(void) const { return pimpl_->tab; }
94
95void VrpnClient::Run(void) { pimpl_->Run(); }
96
97} // end namespace sensor
98} // end namespace flair
Note: See TracBrowser for help on using the repository browser.