[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 |
|
---|
| 23 | using std::string;
|
---|
| 24 | using namespace flair::core;
|
---|
| 25 | using namespace flair::gui;
|
---|
| 26 |
|
---|
[122] | 27 | namespace {
|
---|
| 28 | flair::sensor::VrpnClient *singleton = NULL;
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 |
|
---|
[15] | 32 | namespace flair {
|
---|
| 33 | namespace sensor {
|
---|
[3] | 34 |
|
---|
[122] | 35 | VrpnClient *GetVrpnClient(void) { return singleton; }
|
---|
| 36 |
|
---|
| 37 | VrpnClient::VrpnClient(string name,
|
---|
[330] | 38 | string address, uint8_t priority,ConnectionType_t connectionType)
|
---|
[122] | 39 | : Thread(getFrameworkManager(), name, priority) {
|
---|
| 40 | if (singleton != NULL) {
|
---|
[294] | 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;
|
---|
[122] | 45 | }
|
---|
[309] | 46 |
|
---|
[330] | 47 | pimpl_ = new VrpnClient_impl(this, name, address,connectionType);
|
---|
[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) {
|
---|
[294] | 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;
|
---|
[122] | 59 | }
|
---|
[294] | 60 |
|
---|
[15] | 61 | pimpl_ = new VrpnClient_impl(this, name, serialport, us_period);
|
---|
[3] | 62 | }
|
---|
| 63 |
|
---|
[15] | 64 | VrpnClient::~VrpnClient() {
|
---|
| 65 | SafeStop();
|
---|
| 66 | Join();
|
---|
[3] | 67 |
|
---|
[15] | 68 | delete pimpl_;
|
---|
[3] | 69 | }
|
---|
| 70 |
|
---|
[309] | 71 | VrpnClient::ConnectionType_t VrpnClient::ConnectionType(void) const {
|
---|
| 72 | return pimpl_->connectionType;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
[15] | 75 | Layout *VrpnClient::GetLayout(void) const {
|
---|
| 76 | return (Layout *)(pimpl_->setup_tab);
|
---|
[3] | 77 | }
|
---|
| 78 |
|
---|
[15] | 79 | TabWidget *VrpnClient::GetTabWidget(void) const { return pimpl_->tab; }
|
---|
[3] | 80 |
|
---|
[15] | 81 | void VrpnClient::Run(void) { pimpl_->Run(); }
|
---|
[3] | 82 |
|
---|
| 83 | } // end namespace sensor
|
---|
| 84 | } // end namespace flair
|
---|