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 |
|
---|
23 | using std::string;
|
---|
24 | using namespace flair::core;
|
---|
25 | using namespace flair::gui;
|
---|
26 |
|
---|
27 | namespace {
|
---|
28 | flair::sensor::VrpnClient *singleton = NULL;
|
---|
29 | }
|
---|
30 |
|
---|
31 |
|
---|
32 | namespace flair {
|
---|
33 | namespace sensor {
|
---|
34 |
|
---|
35 | VrpnClient *GetVrpnClient(void) { return singleton; }
|
---|
36 |
|
---|
37 | VrpnClient::VrpnClient(string name,
|
---|
38 | string address, uint8_t priority)
|
---|
39 | : Thread(getFrameworkManager(), name, priority) {
|
---|
40 | if (singleton != NULL) {
|
---|
41 | Err("VrpnClient must be instanced only one time\n");
|
---|
42 | return;
|
---|
43 | }
|
---|
44 |
|
---|
45 | singleton = this;
|
---|
46 | pimpl_ = new VrpnClient_impl(this, name, address);
|
---|
47 | }
|
---|
48 |
|
---|
49 | VrpnClient::VrpnClient(string name,
|
---|
50 | SerialPort *serialport, uint16_t us_period,
|
---|
51 | uint8_t priority)
|
---|
52 | : Thread(getFrameworkManager(), name, priority) {
|
---|
53 | if (singleton != NULL) {
|
---|
54 | Err("VrpnClient must be instanced only one time\n");
|
---|
55 | return;
|
---|
56 | }
|
---|
57 |
|
---|
58 | singleton = this;
|
---|
59 | pimpl_ = new VrpnClient_impl(this, name, serialport, us_period);
|
---|
60 | }
|
---|
61 |
|
---|
62 | VrpnClient::~VrpnClient() {
|
---|
63 | SafeStop();
|
---|
64 | Join();
|
---|
65 |
|
---|
66 | delete pimpl_;
|
---|
67 | }
|
---|
68 |
|
---|
69 | Layout *VrpnClient::GetLayout(void) const {
|
---|
70 | return (Layout *)(pimpl_->setup_tab);
|
---|
71 | }
|
---|
72 |
|
---|
73 | TabWidget *VrpnClient::GetTabWidget(void) const { return pimpl_->tab; }
|
---|
74 |
|
---|
75 | bool VrpnClient::UseXbee(void) const { return pimpl_->UseXbee(); }
|
---|
76 |
|
---|
77 | void VrpnClient::Run(void) { pimpl_->Run(); }
|
---|
78 |
|
---|
79 | } // end namespace sensor
|
---|
80 | } // end namespace flair
|
---|