WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
Dashboard.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef __DASHBOARD_H__
8 #define __DASHBOARD_H__
9 
10 #include "DashboardBase.h"
11 #include "NetworkCommunication/FRCComm.h"
12 #include <stack>
13 #include <vector>
14 #include <vxWorks.h>
15 
20 class Dashboard : public DashboardBase
21 {
22 public:
23  explicit Dashboard(SEM_ID statusDataSemaphore);
24  virtual ~Dashboard();
25 
26  enum Type {kI8, kI16, kI32, kU8, kU16, kU32, kFloat, kDouble, kBoolean, kString, kOther};
27  enum ComplexType {kArray, kCluster};
28 
29  void AddI8(int8_t value);
30  void AddI16(int16_t value);
31  void AddI32(int32_t value);
32  void AddU8(uint8_t value);
33  void AddU16(uint16_t value);
34  void AddU32(uint32_t value);
35  void AddFloat(float value);
36  void AddDouble(double value);
37  void AddBoolean(bool value);
38  void AddString(char* value);
39  void AddString(char* value, int32_t length);
40 
41  void AddArray();
42  void FinalizeArray();
43  void AddCluster();
44  void FinalizeCluster();
45 
46  void Printf(const char *writeFmt, ...);
47 
48  int32_t Finalize();
49  void GetStatusBuffer(char** userStatusData, int32_t* userStatusDataSize);
50  void Flush() {}
51 private:
52  static const int32_t kMaxDashboardDataSize = USER_STATUS_DATA_SIZE - sizeof(uint32_t) * 3 - sizeof(uint8_t); // 13 bytes needed for 3 size parameters and the sequence number
53 
54  // Usage Guidelines...
55  DISALLOW_COPY_AND_ASSIGN(Dashboard);
56 
57  bool ValidateAdd(int32_t size);
58  void AddedElement(Type type);
59  bool IsArrayRoot();
60 
61  char *m_userStatusData;
62  int32_t m_userStatusDataSize;
63  char *m_localBuffer;
64  char *m_localPrintBuffer;
65  char *m_packPtr;
66  std::vector<Type> m_expectedArrayElementType;
67  std::vector<int32_t> m_arrayElementCount;
68  std::vector<int32_t*> m_arraySizePtr;
69  std::stack<ComplexType> m_complexTypeStack;
70  SEM_ID m_printSemaphore;
71  SEM_ID m_statusDataSemaphore;
72 };
73 
74 #endif
75 
virtual ~Dashboard()
Definition: Dashboard.cpp:43
void AddBoolean(bool value)
Definition: Dashboard.cpp:155
Definition: DashboardBase.h:13
void AddI16(int16_t value)
Definition: Dashboard.cpp:71
void AddU32(uint32_t value)
Definition: Dashboard.cpp:119
void GetStatusBuffer(char **userStatusData, int32_t *userStatusDataSize)
Definition: Dashboard.cpp:331
void AddCluster()
Definition: Dashboard.cpp:236
void AddArray()
Definition: Dashboard.cpp:196
void FinalizeArray()
Definition: Dashboard.cpp:211
void AddFloat(float value)
Definition: Dashboard.cpp:131
void AddDouble(double value)
Definition: Dashboard.cpp:143
void AddU16(uint16_t value)
Definition: Dashboard.cpp:107
void AddI8(int8_t value)
Definition: Dashboard.cpp:59
Dashboard(SEM_ID statusDataSemaphore)
Definition: Dashboard.cpp:21
void AddU8(uint8_t value)
Definition: Dashboard.cpp:95
Definition: Dashboard.h:20
void Printf(const char *writeFmt,...)
Definition: Dashboard.cpp:264
void AddI32(int32_t value)
Definition: Dashboard.cpp:83
void FinalizeCluster()
Definition: Dashboard.cpp:247
void AddString(char *value)
Definition: Dashboard.cpp:167
int32_t Finalize()
Definition: Dashboard.cpp:298