IGSTK
igstkSerialCommunicationSimulator.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkSerialCommunicationSimulator.h,v $
5  Language: C++
6  Date: $Date: 2008-02-11 01:41:51 $
7  Version: $Revision: 1.11 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __igstkSerialCommunicationSimulator_h
19 #define __igstkSerialCommunicationSimulator_h
20 
21 #include <fstream>
22 #include <iomanip>
23 #include <map>
24 #include <vector>
25 
26 #include "igstkBinaryData.h"
28 
29 namespace igstk
30 {
31 
40 {
41 public:
42 
46 
47 public:
48 
50  typedef std::ifstream FileType;
51 
53  void SetFileName(const char* filename);
54 
56  const char *GetFileName() const;
57 
58 protected:
59 
61 
64 
67 
69  virtual ResultType InternalOpenPort( void );
70 
73  virtual ResultType InternalUpdateParameters( void );
74 
76  virtual ResultType InternalClosePort( void );
77 
79  virtual ResultType InternalSendBreak( void );
80 
82  virtual void InternalSleep( unsigned int milliseconds );
83 
85  virtual ResultType InternalPurgeBuffers( void );
86 
88  virtual ResultType InternalWrite( const char *message,
89  unsigned int numberOfBytes );
90 
92  virtual ResultType InternalRead( char *data, unsigned int numberOfBytes,
93  unsigned int &bytesRead );
94 
96  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
97 
98 private:
99 
101  typedef std::map<BinaryData, std::vector<BinaryData> > ResponseTableType;
102 
104  typedef std::map<BinaryData, std::vector<double> > ResponseTimeType;
105 
108  typedef std::map<BinaryData, unsigned> ResponseCounterType;
109 
111  FileType m_File;
112 
114  std::string m_FileName;
115 
117  ResponseTableType m_ResponseTable;
118 
120  ResponseTimeType m_TimeTable;
121 
123  ResponseCounterType m_CounterTable;
124 
126  BinaryData m_Command;
127 
128 };
129 
130 } // end namespace igstk
131 
132 #endif // __igstkSerialCommunicationSimulator_h