WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
SensorBase.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2016. 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 the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "ErrorBase.h"
11 #include <stdio.h>
12 #include "Base.h"
13 
20 class SensorBase : public ErrorBase {
21  public:
22  SensorBase();
23  virtual ~SensorBase() = default;
24 
25  SensorBase(const SensorBase&) = delete;
26  SensorBase& operator=(const SensorBase&) = delete;
27 
28  static void DeleteSingletons();
29 
30  static uint32_t GetDefaultSolenoidModule() { return 0; }
31 
32  static bool CheckSolenoidModule(uint8_t moduleNumber);
33  static bool CheckDigitalChannel(uint32_t channel);
34  static bool CheckRelayChannel(uint32_t channel);
35  static bool CheckPWMChannel(uint32_t channel);
36  static bool CheckAnalogInput(uint32_t channel);
37  static bool CheckAnalogOutput(uint32_t channel);
38  static bool CheckSolenoidChannel(uint32_t channel);
39  static bool CheckPDPChannel(uint32_t channel);
40 
41  static const uint32_t kDigitalChannels = 26;
42  static const uint32_t kAnalogInputs = 8;
43  static const uint32_t kAnalogOutputs = 2;
44  static const uint32_t kSolenoidChannels = 8;
45  static const uint32_t kSolenoidModules = 2;
46  static const uint32_t kPwmChannels = 20;
47  static const uint32_t kRelayChannels = 8;
48  static const uint32_t kPDPChannels = 16;
49  static const uint32_t kChassisSlots = 8;
50 
51  protected:
52  void AddToSingletonList();
53 
54  static void* m_digital_ports[kDigitalChannels];
55  static void* m_relay_ports[kRelayChannels];
56  static void* m_pwm_ports[kPwmChannels];
57 
58  private:
59  static SensorBase* m_singletonList;
60  SensorBase* m_nextSingleton = nullptr;
61 };
static bool CheckDigitalChannel(uint32_t channel)
Check that the digital channel number is valid.
Definition: SensorBase.cpp:108
static bool CheckAnalogOutput(uint32_t channel)
Check that the analog output number is valid.
Definition: SensorBase.cpp:160
static bool CheckRelayChannel(uint32_t channel)
Check that the digital channel number is valid.
Definition: SensorBase.cpp:121
static bool CheckPWMChannel(uint32_t channel)
Check that the digital channel number is valid.
Definition: SensorBase.cpp:134
Base class for all sensors.
Definition: SensorBase.h:20
Base class for most objects.
Definition: ErrorBase.h:66
void AddToSingletonList()
Add sensor to the singleton list.
Definition: SensorBase.cpp:71
static void DeleteSingletons()
Delete all the singleton classes on the list.
Definition: SensorBase.cpp:81
static bool CheckPDPChannel(uint32_t channel)
Verify that the power distribution channel number is within limits.
Definition: SensorBase.cpp:180
static bool CheckSolenoidModule(uint8_t moduleNumber)
Check that the solenoid module number is valid.
Definition: SensorBase.cpp:95
static bool CheckAnalogInput(uint32_t channel)
Check that the analog input number is value.
Definition: SensorBase.cpp:147
static bool CheckSolenoidChannel(uint32_t channel)
Verify that the solenoid channel number is within limits.
Definition: SensorBase.cpp:170
SensorBase()
Creates an instance of the sensor base and gets an FPGA handle.
Definition: SensorBase.cpp:33