Arduino C++ Library for VLCB
Loading...
Searching...
No Matches
VLCB Namespace Reference

Classes

class  LEDUserInterface
 User interface "service" that communicates with LEDs and a push button. More...
class  SerialUserInterface
 User interface "service" that communicates via a serial connection. More...
class  CanTransport
 Interface base class for CAN transport implementations. More...
class  SerialGC
 Implementation of the Transport interface class to support the gridconnect protocol over serial connection. More...
class  CAN2515
 Transport implementation for the MCP2515/25625 CAN controllers. More...
class  TimedResponse
 Manage tasks that respond with messages at timed intervals. More...
class  AbstractEventTeachingService
 Base class for teaching services. More...
class  CanService
 Service for sending and receiving messages on a CAN bus. More...
class  ConsumeOwnEventsService
 Service for consuming events that this node has produced. More...
class  EventConsumerService
 Service for consuming events. More...
class  EventProducerService
 Service for producing events. More...
class  EventSlotTeachingService
 Slot Event Teaching Service. More...
class  EventTeachingService
 Classic Event Teaching Service. More...
class  InternalDiagnosticsService
 A dummy service that reports internal metrics as service diagnostics. More...
class  MinimumNodeService
 Mandatory Service for node. More...
class  NodeVariableService
 Service for managing node variables. More...
class  Service
 Interface base class for all VLCB services. More...

Functions

Startup Functions
void checkStartupAction (byte greenLedPin, byte yellowLedPin, byte pushButtonPin)
void begin ()
Module Configuration
void setServices (std::initializer_list< Service * > services)
void setVersion (char maj, char min, char patch)
void setModuleId (byte manu, byte moduleId)
void setName (char *mname)
void setNumNodeVariables (byte n)
 Set number of node variables that the module will use.
void setEventsStart (byte n)
 Optional: Sets the address where event data starts in the EEPROM.
void setMaxEvents (byte n)
 Set the max number of events the module can handle.
void setNumEventVariables (byte n)
 Set the number of event variables that are used by each stored event.
Module Configuration Access
VlcbModeParams getCurrentMode ()
byte getCANID ()
unsigned int getNodeNum ()
unsigned int getFreeEEPROMbase ()
byte readNV (byte nv)
void writeNV (byte nv, byte val)
byte getEventEVval (byte idx, byte evnum)
byte findExistingEventByEv (int evIndex, byte value)
byte findExistingEvent (unsigned int nn, unsigned int en)
bool isEventIndexValid (byte eventIndex)
bool doesEventExistAtIndex (byte eventIndex)
byte findEmptyEventSpace ()
void createEventAtIndex (byte eventIndex, unsigned int nn, unsigned int en)
void writeEventVariable (byte eventIndex, byte evIndex, byte value)
bool sendMessageWithNN (VlcbOpCodes opc)
bool sendMessageWithNN (VlcbOpCodes opc, byte b1)
bool sendMessageWithNN (VlcbOpCodes opc, byte b1, byte b2)
bool sendMessageWithNN (VlcbOpCodes opc, byte b1, byte b2, byte b3)
bool sendMessageWithNN (VlcbOpCodes opc, byte b1, byte b2, byte b3, byte b4)
bool sendMessageWithNN (VlcbOpCodes opc, byte b1, byte b2, byte b3, byte b4, byte b5)
void addTimedResponse (TimedResponse::Task *task)
void resetModule ()
Running
void process ()

Detailed Description

VLCB API

This VLCB library is built with an object-oriented architecture described in the design document. It uses a Controller object for the core tasks, a Configuration object for storing module configurations and a set of services.

The VLCB module code can be written in two different styles. One style is to define these objects and calling member functions of these objects.

The other style is to use functions in the VLCB namespace. These functions are "free" functions and do not require objects. These VLCB namespace functions are provided for convenience and clarity. Some are just forwarding calls to these objects while others do more work to simplify writing module code.

The example sketches are using the VLCB function style.

VLCB functions

These functions are in the VLCB namespace to avoid name clashes with other libraries. Prefix each call with VLCB:: or add a using namespace VLCB; directive at the top of your code file.

Function Documentation

◆ checkStartupAction()

void VLCB::checkStartupAction ( byte greenLedPin,
byte yellowLedPin,
byte pushButtonPin )

This is a helper function that can be called at the beginning of the setup() function. It performs a few checks at startup of the module. At the moment does:

  1. Checks if the push button is pressed. If so it will reset the module to factory settings, i.e. write all EEPROM with 0xFF bytes.

◆ begin()

void VLCB::begin ( )

Call this function in the setup() function, after all configuration is complete. This initialises the internals of the VLCB library.

◆ setServices()

void VLCB::setServices ( std::initializer_list< Service * > services)

Set up the services to be used by the module. These services must be defined above in the code, outside any functions. The used services shall be listed with curly brackets, called an "initializer list". A call will look like this:

setServices( { service1, service2, ... } );
void setServices(std::initializer_list< Service * > services)

◆ setVersion()

void VLCB::setVersion ( char maj,
char min,
char patch )

Set major, minor and patch versions for the module. Note that maj and patch versions are numbers while min is a letter.

◆ setModuleId()

void VLCB::setModuleId ( byte manu,
byte moduleId )

Set the module identification for the module. manu shall either be one of:

  • MANU_MERG (165) for modules that are shared and have a moduleId that is registered within the VLCBDEFS repository to ensure that it is globally unique.
  • MANU_DEV (value 13) for private modules where the moduleId is not registered in VLCBDEFS. The moduleId only needs to be unique within the network of the developer.

◆ setName()

void VLCB::setName ( char * mname)

Set the name of the module. The name shall be a string of max 7 characters.

◆ setNumNodeVariables()

void VLCB::setNumNodeVariables ( byte n)

Set number of node variables that the module will use.

◆ setEventsStart()

void VLCB::setEventsStart ( byte n)

Optional: Sets the address where event data starts in the EEPROM.

◆ setMaxEvents()

void VLCB::setMaxEvents ( byte n)

Set the max number of events the module can handle.

◆ setNumEventVariables()

void VLCB::setNumEventVariables ( byte n)

Set the number of event variables that are used by each stored event.

◆ getCurrentMode()

VlcbModeParams VLCB::getCurrentMode ( )

◆ getCANID()

byte VLCB::getCANID ( )

◆ getNodeNum()

unsigned int VLCB::getNodeNum ( )

◆ getFreeEEPROMbase()

unsigned int VLCB::getFreeEEPROMbase ( )

◆ readNV()

byte VLCB::readNV ( byte nv)

◆ writeNV()

void VLCB::writeNV ( byte nv,
byte val )

◆ getEventEVval()

byte VLCB::getEventEVval ( byte idx,
byte evnum )

◆ findExistingEventByEv()

byte VLCB::findExistingEventByEv ( int evIndex,
byte value )

◆ findExistingEvent()

byte VLCB::findExistingEvent ( unsigned int nn,
unsigned int en )

◆ isEventIndexValid()

bool VLCB::isEventIndexValid ( byte eventIndex)

◆ doesEventExistAtIndex()

bool VLCB::doesEventExistAtIndex ( byte eventIndex)

◆ findEmptyEventSpace()

byte VLCB::findEmptyEventSpace ( )

◆ createEventAtIndex()

void VLCB::createEventAtIndex ( byte eventIndex,
unsigned int nn,
unsigned int en )

◆ writeEventVariable()

void VLCB::writeEventVariable ( byte eventIndex,
byte evIndex,
byte value )

◆ sendMessageWithNN() [1/6]

bool VLCB::sendMessageWithNN ( VlcbOpCodes opc)

◆ sendMessageWithNN() [2/6]

bool VLCB::sendMessageWithNN ( VlcbOpCodes opc,
byte b1 )

◆ sendMessageWithNN() [3/6]

bool VLCB::sendMessageWithNN ( VlcbOpCodes opc,
byte b1,
byte b2 )

◆ sendMessageWithNN() [4/6]

bool VLCB::sendMessageWithNN ( VlcbOpCodes opc,
byte b1,
byte b2,
byte b3 )

◆ sendMessageWithNN() [5/6]

bool VLCB::sendMessageWithNN ( VlcbOpCodes opc,
byte b1,
byte b2,
byte b3,
byte b4 )

◆ sendMessageWithNN() [6/6]

bool VLCB::sendMessageWithNN ( VlcbOpCodes opc,
byte b1,
byte b2,
byte b3,
byte b4,
byte b5 )

◆ addTimedResponse()

void VLCB::addTimedResponse ( TimedResponse::Task * task)

◆ resetModule()

void VLCB::resetModule ( )

◆ process()

void VLCB::process ( )

Call this in the loop()function. It lets the VLCB library core execute its tasks such as check for new incoming messages and run queued tasks.