WPILib 2012
WPILibRoboticsLibraryforFRC
Dashboard.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef __DASHBOARD_H__
00008 #define __DASHBOARD_H__
00009 
00010 #include "DashboardBase.h"
00011 #include "NetworkCommunication/FRCComm.h"
00012 #include <stack>
00013 #include <vector>
00014 #include <vxWorks.h>
00015 
00020 class Dashboard : public DashboardBase
00021 {
00022 public:
00023         explicit Dashboard(SEM_ID statusDataSemaphore);
00024         virtual ~Dashboard();
00025 
00026         enum Type {kI8, kI16, kI32, kU8, kU16, kU32, kFloat, kDouble, kBoolean, kString, kOther};
00027         enum ComplexType {kArray, kCluster};
00028 
00029         void AddI8(INT8 value);
00030         void AddI16(INT16 value);
00031         void AddI32(INT32 value);
00032         void AddU8(UINT8 value);
00033         void AddU16(UINT16 value);
00034         void AddU32(UINT32 value);
00035         void AddFloat(float value);
00036         void AddDouble(double value);
00037         void AddBoolean(bool value);
00038         void AddString(char* value);
00039         void AddString(char* value, INT32 length);
00040 
00041         void AddArray();
00042         void FinalizeArray();
00043         void AddCluster();
00044         void FinalizeCluster();
00045 
00046         void Printf(const char *writeFmt, ...);
00047 
00048         INT32 Finalize();
00049         void GetStatusBuffer(char** userStatusData, INT32* userStatusDataSize);
00050         void Flush() {}
00051 private:
00052         static const INT32 kMaxDashboardDataSize = USER_STATUS_DATA_SIZE - sizeof(UINT32) * 3 - sizeof(UINT8); // 13 bytes needed for 3 size parameters and the sequence number
00053 
00054         // Usage Guidelines...
00055         DISALLOW_COPY_AND_ASSIGN(Dashboard);
00056 
00057         bool ValidateAdd(INT32 size);
00058         void AddedElement(Type type);
00059         bool IsArrayRoot();
00060 
00061         char *m_userStatusData;
00062         INT32 m_userStatusDataSize;
00063         char *m_localBuffer;
00064         char *m_localPrintBuffer;
00065         char *m_packPtr;
00066         std::vector<Type> m_expectedArrayElementType;
00067         std::vector<INT32> m_arrayElementCount;
00068         std::vector<INT32*> m_arraySizePtr;
00069         std::stack<ComplexType> m_complexTypeStack;
00070         SEM_ID m_printSemaphore;
00071         SEM_ID m_statusDataSemaphore;
00072 };
00073 
00074 #endif
00075 
 All Classes Functions Variables