VLCB
Loading...
Searching...
No Matches
MinimumNodeService.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 "Service.h"
9#include <vlcbdefs.hpp>
10
11namespace VLCB
12{
13
14struct VlcbMessage;
26{
27
28public:
30 virtual void process() override;
31 virtual void processAction(const Action &action) override;
32
33 virtual VlcbServiceTypes getServiceID() const override { return SERVICE_ID_MNS; }
34 virtual byte getServiceVersionID() const override { return 1; }
35
36 virtual void begin() override;
37
44 void setHeartBeat(bool f) { noHeartbeat = !f; }
46 void setSetupMode();
49 void setUninitialised();
51 void setNormal(unsigned int nn);
53private:
54
55 VlcbModeParams instantMode;
58 void initSetupFromUninitialised();
61 void initSetupFromNormal();
63 void initSetupCommon();
67 void heartbeat();
68
69 unsigned long lastHeartbeat = 0;
70 byte heartbeatSequence = 0;
71 bool noHeartbeat = false;
72 unsigned int heartRate = 5000;
73 bool notFcuCompatible = false; //Compatible is default
74
77 void handleRequestNodeParameters();
80 void handleRequestNodeParameter(const VlcbMessage *msg, unsigned int nn);
83 void handleSetNodeNumber(const VlcbMessage *msg, unsigned int nn);
86 void handleRequestServiceDefinitions(const VlcbMessage *msg, unsigned int nn);
89 void handleModeMessage(const VlcbMessage *msg, unsigned int nn);
90
91protected:
95 virtual void handleMessage(const VlcbMessage *msg);
98 virtual void diagNodeNumberChanged() {};
99
101};
102}
Mandatory Service for node.
Definition MinimumNodeService.h:26
virtual void processAction(const Action &action) override
Called when there is an action available.
Definition MinimumNodeService.cpp:119
virtual void diagNodeNumberChanged()
Definition MinimumNodeService.h:98
virtual VlcbServiceTypes getServiceID() const override
Return a unique ID for this service.
Definition MinimumNodeService.h:33
virtual byte getServiceVersionID() const override
Return the version of the service specification implemented by this service.
Definition MinimumNodeService.h:34
void setUninitialised()
Definition MinimumNodeService.cpp:80
void setNormal(unsigned int nn)
Called when OPC_SNN is received. It will set MODE_NORMAL and the node number to nn.
Definition MinimumNodeService.cpp:69
void setHeartBeat(bool f)
Definition MinimumNodeService.h:44
virtual void handleMessage(const VlcbMessage *msg)
Definition MinimumNodeService.cpp:179
void setSetupMode()
Forces instantMode to SETUP_MODE for testing purposes only.
Definition MinimumNodeService.cpp:557
virtual void process() override
This method that be called regularly from the VLCB core to let the service perform regular tasks.
Definition MinimumNodeService.cpp:174
virtual void begin() override
This optional method is called at the beginning of the Arduino sketch. Define this method for the ser...
Definition MinimumNodeService.cpp:33
Interface base class for all VLCB services.
Definition Service.h:25
Definition AbstractEventTeachingService.cpp:13
An action to be performed.
Definition Controller.h:51
CAN/Controller message type.
Definition Controller.h:30
VlcbModeParams
Definition vlcbdefs.hpp:562
VlcbServiceTypes
Definition vlcbdefs.hpp:487
@ SERVICE_ID_MNS
Definition vlcbdefs.hpp:492