jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame] | 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 SENSORBASE_H_
|
| 8 | #define SENSORBASE_H_
|
| 9 |
|
| 10 | #include "ChipObject/NiRio.h"
|
| 11 | #include "ErrorBase.h"
|
| 12 | #include <stdio.h>
|
| 13 | #include "Base.h"
|
| 14 |
|
| 15 | /**
|
| 16 | * Base class for all sensors.
|
| 17 | * Stores most recent status information as well as containing utility functions for checking
|
| 18 | * channels and error processing.
|
| 19 | */
|
| 20 | class SensorBase: public ErrorBase {
|
| 21 | public:
|
| 22 | SensorBase();
|
| 23 | virtual ~SensorBase();
|
| 24 | static void DeleteSingletons();
|
| 25 | static UINT32 GetDefaultAnalogModule() { return 1; }
|
| 26 | static UINT32 GetDefaultDigitalModule() { return 1; }
|
| 27 | static UINT32 GetDefaultSolenoidModule() { return 1; }
|
| 28 | static bool CheckAnalogModule(UINT8 moduleNumber);
|
| 29 | static bool CheckDigitalModule(UINT8 moduleNumber);
|
| 30 | static bool CheckPWMModule(UINT8 moduleNumber);
|
| 31 | static bool CheckRelayModule(UINT8 moduleNumber);
|
| 32 | static bool CheckSolenoidModule(UINT8 moduleNumber);
|
| 33 | static bool CheckDigitalChannel(UINT32 channel);
|
| 34 | static bool CheckRelayChannel(UINT32 channel);
|
| 35 | static bool CheckPWMChannel(UINT32 channel);
|
| 36 | static bool CheckAnalogChannel(UINT32 channel);
|
| 37 | static bool CheckSolenoidChannel(UINT32 channel);
|
| 38 |
|
| 39 | static const UINT32 kSystemClockTicksPerMicrosecond = 40;
|
| 40 | static const UINT32 kDigitalChannels = 14;
|
| 41 | static const UINT32 kAnalogChannels = 8;
|
| 42 | static const UINT32 kAnalogModules = 2;
|
| 43 | static const UINT32 kDigitalModules = 2;
|
| 44 | static const UINT32 kSolenoidChannels = 8;
|
| 45 | static const UINT32 kSolenoidModules = 2;
|
| 46 | static const UINT32 kPwmChannels = 10;
|
| 47 | static const UINT32 kRelayChannels = 8;
|
| 48 | static const UINT32 kChassisSlots = 8;
|
| 49 | protected:
|
| 50 | void AddToSingletonList();
|
| 51 |
|
| 52 | private:
|
| 53 | DISALLOW_COPY_AND_ASSIGN(SensorBase);
|
| 54 | static SensorBase *m_singletonList;
|
| 55 | SensorBase *m_nextSingleton;
|
| 56 | };
|
| 57 |
|
| 58 |
|
| 59 | #endif
|