cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsOpenIGTLink.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Ali Uneri
7  Created on: 2009-08-10
8 
9  (C) Copyright 2009-2012 Johns Hopkins University (JHU), All Rights Reserved.
10 
11 --- begin cisst license - do not edit ---
12 
13 This software is provided "as is" under an open source license, with
14 no warranty. The complete license can be found in license.txt and
15 http://www.cisst.org/cisst/license.txt.
16 
17 --- end cisst license ---
18 */
19 
49 #ifndef _mtsOpenIGTLink_h
50 #define _mtsOpenIGTLink_h
51 
56 #include <sawOpenIGTLink/sawOpenIGTLinkExport.h> // always include last
57 
58 
59 class sawOpenIGTLinkData; // class containing igtl type data
60 
61 
63 {
65 
66  public:
68  mtsOpenIGTLink(const std::string & taskName, const double period) :
69  mtsTaskPeriodic(taskName, period, false, 500) {}
71  mtsTaskPeriodic(arg) {}
72 
74  ~mtsOpenIGTLink(void) {}
75 
76  void Configure(const std::string & hostAndPort);
77  void Startup(void);
78  void Run(void);
79  void Cleanup(void);
80 
81  protected:
83  void Initialize(void);
84 
88  bool SendFrame(const prmPositionCartesianGet & frameCISST);
89 
93  bool ReceiveHeader(std::string & messageType);
94 
98  bool ReceiveFrame(prmPositionCartesianGet & frameCISST);
99 
101  void SkipMessage(void);
102 
103  enum ConnectionTypes { SERVER, CLIENT };
105 
106  std::string Host;
107  unsigned int Port;
109 
112  std::vector<osaSocket *> Sockets;
113 
114  std::string MessageType;
115  sawOpenIGTLinkData * IGTLData;
118 };
119 
121 
122 #endif // _mtsOpenIGTLink_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: mtsTaskPeriodic.h:38
Definition: osaSocketServer.h:52
const int CMN_DYNAMIC_CREATION_ONEARG
Definition: cmnClassRegisterMacros.h:333
virtual void Startup(void)
Definition: mtsComponent.h:262
void Initialize(void)
Declaration of osaSocketServerThis class implements a TCP server capable of handling multiple clients...
virtual void Configure(const std::string &CMN_UNUSED(filename)="")
Definition: mtsTask.h:218
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Defines a periodic task.
virtual void Run(void)=0
Declaration of osaSocketThis is a cross-platform socket library with basic support for UDP (datagram)...
Definition: osaSocket.h:171
Definition: mtsTaskPeriodic.h:80
virtual void Cleanup(void)
Definition: mtsComponent.h:267
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76
Definition: prmPositionCartesianGet.h:37