My Project
Loading...
Searching...
No Matches
MTC4BTController.h
Go to the documentation of this file.
1#pragma once
2
3#include "BLEHubScanner.h"
4#include "BLELocomotive.h"
5#include "MController.h"
7
9{
10 public:
11 // MTC4BTController constructor.
13
14 // Locomotives under control of this controller.
15 std::vector<BLELocomotive *> Locomotives;
16
17 // Controller setup.
18 void Setup(MTC4BTConfiguration *config);
19
20 // Start the scanner
21 void SetupScanner();
22
23 // Controller loop.
24 void Loop();
25
26 // Returns a boolean value indicating whether this controller controls the loco with the given address.
27 bool HasLocomotive(uint address);
28
29 // Handles sys emergency brake command for all locos (under control of this controller).
30 void HandleSys(const bool ebrake);
31
32 // Handles the given loco command (if loco is under control if this controller).
33 void HandleLc(int locoAddress, int speed, int minSpeed, int maxSpeed, char *mode, bool dirForward);
34
35 // Handles the given trigger (if loco is under control of this controller).
36 void HandleTrigger(int locoAddress, MCTriggerSource source, std::string eventType, std::string eventId, std::string value);
37
38 private:
39 // Discovers new BLE devices.
40 static void discoveryLoop(void *parm);
41
42 // Initializes locomotives with the given configuration.
43 void initLocomotives(std::vector<BLELocomotiveConfiguration *> locoConfigs);
44
45 // Returns the locomotive with the given address.
46 BLELocomotive *getLocomotive(uint address);
47
48 // Reference to the configuration of this controller.
49 MTC4BTConfiguration *_config;
50
51 // Reference to the BLE Hub scanner used by this controller.
52 BLEHubScanner *_hubScanner;
53};
Definition BLEHubScanner.h:8
Definition BLELocomotive.h:11
Definition MController.h:20
Definition MTC4BTController.h:9
MTC4BTController()
Definition MTC4BTController.cpp:39
void HandleSys(const bool ebrake)
Definition MTC4BTController.cpp:81
bool HasLocomotive(uint address)
Definition MTC4BTController.cpp:76
void Setup(MTC4BTConfiguration *config)
Definition MTC4BTController.cpp:43
void SetupScanner()
Definition MTC4BTController.cpp:55
void HandleTrigger(int locoAddress, MCTriggerSource source, std::string eventType, std::string eventId, std::string value)
Definition MTC4BTController.cpp:107
void Loop()
Definition MTC4BTController.cpp:65
void HandleLc(int locoAddress, int speed, int minSpeed, int maxSpeed, char *mode, bool dirForward)
Definition MTC4BTController.cpp:87
std::vector< BLELocomotive * > Locomotives
Definition MTC4BTController.h:15
MCTriggerSource
Definition enums.h:77
Definition MTC4BTConfiguration.h:6