blob: 8638b5eaa95a4f61dc82087e69d9202a3cacef3d [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2008. All Rights Reserved.
3 */
4/* Open Source Software - may be modified and shared by FRC teams. The code */
5/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
6/*----------------------------------------------------------------------------*/
7#pragma once
8
9#include "ErrorBase.h"
10#include <stdio.h>
11#include "Base.h"
12
13/**
14 * Base class for all sensors.
15 * Stores most recent status information as well as containing utility functions
16 * for checking
17 * channels and error processing.
18 */
19class SensorBase : public ErrorBase {
20 public:
21 SensorBase();
22 virtual ~SensorBase() = default;
23
24 SensorBase(const SensorBase&) = delete;
25 SensorBase& operator=(const SensorBase&) = delete;
26
27 static void DeleteSingletons();
28
29 static uint32_t GetDefaultSolenoidModule() { return 0; }
30
31 static bool CheckSolenoidModule(uint8_t moduleNumber);
32 static bool CheckDigitalChannel(uint32_t channel);
33 static bool CheckRelayChannel(uint32_t channel);
34 static bool CheckPWMChannel(uint32_t channel);
35 static bool CheckAnalogInput(uint32_t channel);
36 static bool CheckAnalogOutput(uint32_t channel);
37 static bool CheckSolenoidChannel(uint32_t channel);
38 static bool CheckPDPChannel(uint32_t channel);
39
40 static const uint32_t kDigitalChannels = 26;
41 static const uint32_t kAnalogInputs = 8;
42 static const uint32_t kAnalogOutputs = 2;
43 static const uint32_t kSolenoidChannels = 8;
44 static const uint32_t kSolenoidModules = 2;
45 static const uint32_t kPwmChannels = 20;
46 static const uint32_t kRelayChannels = 8;
47 static const uint32_t kPDPChannels = 16;
48 static const uint32_t kChassisSlots = 8;
49
50 protected:
51 void AddToSingletonList();
52
53 static void* m_digital_ports[kDigitalChannels];
54 static void* m_relay_ports[kRelayChannels];
55 static void* m_pwm_ports[kPwmChannels];
56
57 private:
58 static SensorBase* m_singletonList;
59 SensorBase* m_nextSingleton = nullptr;
60};