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