WPILib 2012
WPILibRoboticsLibraryforFRC
SmartDashboard/SendableGyro.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2011. 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 __SENDABLE_GYRO_H__
00008 #define __SENDABLE_GYRO_H__
00009 
00010 #include "Gyro.h"
00011 #include "NetworkTables/NetworkTableChangeListener.h"
00012 #include "SmartDashboard/SmartDashboardData.h"
00013 #include "Task.h"
00014 
00015 class NetworkTable;
00016 
00021 class SendableGyro : public Gyro, public SmartDashboardData, public NetworkTableChangeListener
00022 {
00023 public:
00024         SendableGyro(UINT8 moduleNumber, UINT32 channel);
00025         SendableGyro(UINT32 channel);
00026         SendableGyro(AnalogChannel* channel);
00027         virtual ~SendableGyro();
00028 
00029         // Gyro overrides
00030         virtual float GetAngle();
00031         virtual void Reset();
00032 
00033         void SetUpdatePeriod(double period);
00034         double GetUpdatePeriod();
00035         void ResetToAngle(double angle);
00036 
00037         // SmartDashboardData interface
00038         virtual std::string GetType() {return "Gyro";}
00039         virtual NetworkTable *GetTable();
00040 
00041 private:
00042         // NetworkTableChangeListener interface
00043         virtual void ValueChanged(NetworkTable *table, const char *name, NetworkTables_Types type);
00044         virtual void ValueConfirmed(NetworkTable *table, const char *name, NetworkTables_Types type) {}
00045 
00046         void PublishTaskRun();
00047 
00048         static int InitPublishTask(SendableGyro *obj) {obj->PublishTaskRun();return 0;}
00049 
00051         double m_offset;
00053         double m_period;
00054         NetworkTable *m_table;
00055         Task m_publisher;
00056         bool m_runPublisher;
00057 };
00058 
00059 #endif
 All Classes Functions Variables