CARMA C++
TelemetryInfo.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_ANTENNA_BIMA_TELEMETRYINFO_H
11 #define CARMA_ANTENNA_BIMA_TELEMETRYINFO_H
12 
13 #include <iostream>
14 #include <string>
15 
16 #include "carma/canbus/Utilities.h"
17 #include "carma/util/Trace.h"
18 
19 namespace carma
20 {
21  namespace antenna
22  {
23  namespace bima
24  {
25  class TelemetryInfo
26  {
27 
28  public:
29  TelemetryInfo()
30  {
31  for ( int i = 0; i < 7; i++ )
32  {
33  _name[i] = new std::string( "(unknown)" );
34  _comment[i] =
35  new std::string( "This sub-telemetry id has no definition" );
36  _msgId = (carma::canbus::msgType)0;
37  _addr[i] = '\0';
38  _size[i] = 2; // default size in bytes
39  _len = 0;
40  _sem_num[i] = _global_sem_num++;
41  CPTRACE( carma::util::Trace::TRACE7, "Created TelemetryInfo instance: "
42  << "_name[" << i << "]: " << _name[i]->c_str()
43  << " _comment[" << i << "]: " << _comment[i]->c_str()
44  << " _msgId: 0x" << std::hex << _msgId
45  << " _addr[" << i << "]: " << _addr[i]
46  << " _size[" << i << "]: " << _size[i]
47  << " _len: " << _len
48  << " _sem_num: " << _sem_num[i] );
49  }
50  }
51 
52  ~TelemetryInfo()
53  {
54  }
55 
56  // number of individual items in packet
57  int getLength()
58  {
59  return _len;
60  }
61 
62  // size in bytes of this particular item
63  int getSize( int seq )
64  {
65  return _size[seq];
66  }
67 
68  const char *getName( int seq )
69  {
70  return _name[seq]->c_str();
71  }
72 
73  unsigned short getAddr( int seq )
74  {
75  return _addr[seq];
76  }
77 
78  unsigned short getSemNum( int seq )
79  {
80  return _sem_num[seq];
81  }
82 
83  void setMsgId( carma::canbus::msgType msgId )
84  {
85  _msgId = msgId;
86  }
87 
88  void setPacketName( char *theName )
89  {
90  _packetName = new std::string( theName );
91  }
92 
93  std::string getPacketName()
94  {
95  return std::string( *_packetName );
96  }
97 
98  void resetGlobalNum()
99  {
100  _global_sem_num = 0;
101  }
102 
103  void set( int sequenceNum, char *name, char *comment, short addr, int size )
104  {
105  CPTRACE( carma::util::Trace::TRACE7, "TelemetryInfo.set("
106  << sequenceNum << ", " << name << ", " << comment << ", "
107  << addr << ", " << size << ")" );
108 
109  if ( sequenceNum > -1 && sequenceNum < 8 )
110  {
111  CPTRACE( carma::util::Trace::TRACE7,
112  "_name[" << sequenceNum << "]"
113  << ": " << (char *)_name[sequenceNum]->c_str() );
114 
115  if ( _name[sequenceNum] != (std::string *)NULL )
116  delete _name[sequenceNum];
117 
118  _name[sequenceNum] = new std::string(name);
119 
120  CPTRACE( carma::util::Trace::TRACE7,
121  "_comment[" << sequenceNum << "]"
122  << ": " << (char *)_comment[sequenceNum]->c_str() );
123 
124  if ( _comment[sequenceNum] != (std::string *)NULL )
125  delete _comment[sequenceNum];
126 
127  _comment[sequenceNum] = new std::string(comment);
128 
129  _addr[sequenceNum] = addr;
130  _size[sequenceNum] = size;
131 
132  if ( (sequenceNum+1) > _len )
133  _len = (sequenceNum+1);
134 
135  }
136 
137  }
138 
139  std::string *_packetName;
140  std::string *_name[8];
141  std::string *_comment[8];
142  carma::canbus::msgType _msgId;
143  unsigned short _addr[8];
144  int _size[8];
145  int _len;
146  unsigned short _sem_num[8];
147  static unsigned short _global_sem_num;
148 
149 
150  }; // class TelemetryInfo
151 
152  } // namespace bima
153  } // namespace antenna
154 } // namespace carma
155 
156 #endif // CARMA_ANTENNA_BIMA_TELEMETRYINFO_H
#define CPTRACE(priorityLevel, message)
Old deprecated macro name for CARMA_CPTRACE.
Definition: Trace.h:78
Interface file for the carma::util::Trace class and related macros.
Declarations of carma::canbus utility functions.
unsigned short msgType
Carma Message id type.
Definition: Types.h:69