VLCB
Loading...
Searching...
No Matches
Service.h
Go to the documentation of this file.
1// Copyright (C) Sven Rosvall (sven@rosvall.ie)
2// This file is part of VLCB-Arduino project on https://github.com/SvenRosvall/VLCB-Arduino
3// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
4// The full licence can be found at: http://creativecommons.org/licenses/by-nc-sa/4.0/
5
6#pragma once
7
8#include <Arduino.h>
9#include <vlcbdefs.hpp>
10
11namespace VLCB
12{
13
14class Controller;
15struct Action;
16
25{
27protected:
29 bool isThisNodeNumber(unsigned int nodeNumber);
30
33
34public:
36 void setController(Controller * ctrl) { this->controller = ctrl; }
37
40 virtual void begin() {}
41
46 virtual VlcbServiceTypes getServiceID() const = 0;
47
52 virtual byte getServiceVersionID() const = 0;
53
59 virtual void process() {}
60
66 virtual void processAction(const Action & action) {};
67
72 virtual void reportDiagnostics(byte serviceIndex, byte diagnosticsCode);
73
75 virtual int getDiagnosticCount() { return 0; }
76
78 struct Data { byte data1, data2, data3; };
79
82 virtual Data getServiceData();
84};
85
86}
Main object in VLCB. Coordinates transport, ui, configuration and services.
Definition Controller.h:67
Interface base class for all VLCB services.
Definition Service.h:25
virtual void process()
This method that be called regularly from the VLCB core to let the service perform regular tasks.
Definition Service.h:59
virtual void reportDiagnostics(byte serviceIndex, byte diagnosticsCode)
Report a given diagnostic value.
Definition Service.cpp:17
virtual VlcbServiceTypes getServiceID() const =0
Return a unique ID for this service.
Controller * controller
Pointer to the Controller object that can be used by implementing classes.
Definition Service.h:32
bool isThisNodeNumber(unsigned int nodeNumber)
Helper function to decide if a given node number is the same as that assigned to this node.
Definition Service.cpp:12
virtual void processAction(const Action &action)
Called when there is an action available.
Definition Service.h:66
virtual int getDiagnosticCount()
report how many diagnostics this service supports.
Definition Service.h:75
virtual byte getServiceVersionID() const =0
Return the version of the service specification implemented by this service.
virtual Data getServiceData()
Return Data bytes specific for the implementing service. The meaning of each data byte is defined in ...
Definition Service.cpp:23
virtual void begin()
This optional method is called at the beginning of the Arduino sketch. Define this method for the ser...
Definition Service.h:40
void setController(Controller *ctrl)
Set a pointer to the controller object for use in implementing class.
Definition Service.h:36
Definition AbstractEventTeachingService.cpp:13
An action to be performed.
Definition Controller.h:51
Container for service data bytes.
Definition Service.h:78
byte data2
Definition Service.h:78
byte data3
Definition Service.h:78
byte data1
Definition Service.h:78
VlcbServiceTypes
Definition vlcbdefs.hpp:487