| /*----------------------------------------------------------------------------*/ |
| /* Copyright (c) FIRST 2008. All Rights Reserved. */ |
| /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ |
| /*----------------------------------------------------------------------------*/ |
| |
| #ifndef SENSORBASE_H_ |
| #define SENSORBASE_H_ |
| |
| #include "ErrorBase.h" |
| #include <stdio.h> |
| #include "Base.h" |
| #include "Synchronized.h" |
| |
| /** |
| * Base class for all sensors. |
| * Stores most recent status information as well as containing utility functions for checking |
| * channels. |
| */ |
| class SensorBase: public ErrorBase { |
| public: |
| SensorBase(); |
| static void DeleteSingletons(); |
| static UINT32 GetDefaultAnalogModule() { return 1; } |
| static UINT32 GetDefaultDigitalModule() { return 1; } |
| static UINT32 GetDefaultSolenoidModule() { return 1; } |
| static bool CheckAnalogModule(UINT8 moduleNumber); |
| static bool CheckDigitalModule(UINT8 moduleNumber); |
| static bool CheckPWMModule(UINT8 moduleNumber); |
| static bool CheckRelayModule(UINT8 moduleNumber); |
| static bool CheckSolenoidModule(UINT8 moduleNumber); |
| static bool CheckDigitalChannel(UINT32 channel); |
| static bool CheckRelayChannel(UINT32 channel); |
| static bool CheckPWMChannel(UINT32 channel); |
| static bool CheckAnalogChannel(UINT32 channel); |
| static bool CheckSolenoidChannel(UINT32 channel); |
| |
| // NOT vxworks system clock ticks (returned by sysClkRateGet() from sysLib). |
| // TODO: Document what this actually is (has something to do with FPGA times). |
| // 40kHz clock? |
| static const UINT32 kSystemClockTicksPerMicrosecond = 40; |
| static const UINT32 kDigitalChannels = 14; |
| static const UINT32 kAnalogChannels = 8; |
| static const UINT32 kAnalogModules = 2; |
| static const UINT32 kDigitalModules = 2; |
| static const UINT32 kSolenoidChannels = 8; |
| static const UINT32 kSolenoidModules = 2; |
| static const UINT32 kPwmChannels = 10; |
| static const UINT32 kRelayChannels = 8; |
| |
| protected: |
| void AddToSingletonList(); |
| // Subclasses that don't use the singleton list mechanism should make this |
| // public, but ones that do should keep it protected so that users can not |
| // delete the singleton instance(s). |
| virtual ~SensorBase(); |
| |
| private: |
| DISALLOW_COPY_AND_ASSIGN(SensorBase); |
| static SensorBase *m_singletonList; |
| SensorBase *m_nextSingleton; |
| static ReentrantSemaphore m_singletonListSemaphore; |
| }; |
| |
| |
| #endif |