VLCB
Loading...
Searching...
No Matches
VLCB Namespace Reference

Classes

class  RespondEvents
class  RespondEventVar
class  AbstractEventTeachingService
 Base class for teaching services. More...
class  ArrayHolder
class  CanService
 Service for sending and receiving messages on a CAN bus. More...
class  CanServiceWithDiagnostics
struct  CANFrame
 Represents a CAN frame sent on the CAN bus. More...
class  CanTransport
 Interface base class for CAN transport implementations. More...
class  CircularBuffer
class  Configuration
 a class to encapsulate Controller module configuration, events, NVs, EEPROM, etc More...
class  ConsumeOwnEventsService
 Service for consuming events that this node has produced. More...
struct  VlcbMessage
 CAN/Controller message type. More...
struct  Action
 An action to be performed. More...
class  Controller
 Main object in VLCB. Coordinates transport, ui, configuration and services. More...
class  DueEepromEmulationStorage
class  EepromExternalStorage
class  EepromInternalStorage
class  EventConsumerService
 Service for consuming events. More...
class  EventConsumerServiceWithDiagnostics
class  EventProducerService
 Service for producing events. More...
class  EventProducerServiceWithDiagnostics
class  EventSlotTeachingService
 Slot Event Teaching Service. More...
class  RespondEV
class  EventTeachingService
 Classic Event Teaching Service. More...
class  EventTeachingServiceWithDiagnostics
class  FlashStorage
class  InternalDiagnosticsService
 A dummy service that reports internal metrics as service diagnostics. More...
class  LED
 class to encapsulate a non-blocking LED More...
class  LEDUserInterface
 User interface "service" that communicates with LEDs and a push button. More...
class  LongMessageService
struct  receive_context_t
struct  send_context_t
class  LongMessageServiceEx
 a derived class to extend the base long message class to handle multiple concurrent messages, sending and receiving More...
class  RespondParam
class  RespondService
class  MinimumNodeService
 Mandatory Service for node. More...
class  ServiceDiagnosticsResponse
class  AllServiceDiagnosticsResponse
class  MinimumNodeServiceWithDiagnostics
class  RespondNodeVar
class  NodeVariableService
 Service for managing node variables. More...
class  Parameters
class  SerialGC
 Implementation of the Transport interface class to support the gridconnect protocol over serial connection. More...
class  SerialUserInterface
 User interface "service" that communicates via a serial connection. More...
class  Service
 Interface base class for all VLCB services. More...
class  Storage
 Interface for persistent storage. Used by Configuration class. More...
class  Switch
class  TimedResponse
 Manage tasks that respond with messages at timed intervals. More...
class  Transport
 Interface for statistics on the transport layer. More...

Enumerations

enum  EepromLocations {
  LOCATION_MODE = 0 , LOCATION_CANID = 1 , LOCATION_NODE_NUMBER_HIGH = 2 , LOCATION_NODE_NUMBER_LOW = 3 ,
  LOCATION_FLAGS = 4 , LOCATION_RESET_FLAG = 5 , LOCATION_RESERVED_SIZE = 10
}
enum  FlagBits { HEARTBEAT_BIT = 0 , EVENT_ACK_BIT = 1 , FCU_COMPATIBLE_BIT = 2 }
enum  ACTION : byte {
  ACT_MESSAGE_IN , ACT_MESSAGE_OUT , ACT_START_CAN_ENUMERATION , ACT_CHANGE_MODE ,
  ACT_RENEGOTIATE , ACT_INDICATE_ACTIVITY , ACT_INDICATE_WORK , ACT_INDICATE_MODE
}
 Type of Action. More...
enum  {
  LONG_MESSAGE_INCOMPLETE = 0 , LONG_MESSAGE_COMPLETE , LONG_MESSAGE_SEQUENCE_ERROR , LONG_MESSAGE_TIMEOUT_ERROR ,
  LONG_MESSAGE_CRC_ERROR , LONG_MESSAGE_TRUNCATED
}
 Controller long message status codes. More...

Functions

StoragecreateDefaultStorageForPlatform ()
bool encodeGridConnect (char *gcBuffer, CANFrame *frame)
bool decodeGridConnect (const char *gcBuffer, CANFrame *frame)
Startup Functions
void checkStartupAction (byte greenLedPin, byte yellowLedPin, byte pushButtonPin)
void begin ()
Module Configuration
void setServices (std::initializer_list< Service * > services)
void setName (char *mname)
void setVersion (char maj, char min, char patch)
void setModuleId (byte manu, byte moduleId)
void setNumNodeVariables (byte n)
 Set number of node variables that the module will use.
void setMaxEvents (byte n)
 Set the max number of events the module can handle.
void setEventsStart (byte n)
 Optional: Sets the address where event data starts in the EEPROM.
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 ()
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 addTimedResponseTask (TimedResponse::Task *task)
unsigned int getFreeEEPROMbase ()
void resetModule ()
Running
void process ()

Variables

const int DEFAULT_PRIORITY = 0xB
const int ACTION_QUEUE_SIZE = 8
const int FLASH_PAGE_SIZE = 512
const int NUM_FLASH_PAGES = 4
const int BLINK_RATE = 500
const int PULSE_ON_TIME = 10
const unsigned int SW_TR_HOLD = 4000U
const int PULSE_ACTIVITY = 20
const int PULSE_WORK = 250
const int LONG_MESSAGE_DEFAULT_DELAY = 20
const int LONG_MESSAGE_RECEIVE_TIMEOUT = 5000
const int NUM_EX_CONTEXTS = 4
const int EX_BUFFER_LEN = 64

Detailed Description

construct a Controller object with an external Configuration object named "config" that is defined in user code

Implementation of Controller Long Message Support RFC 0005 by Dave McCabe (M4933) Developed by Duncan Greenwood (M5767)

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.

Enumeration Type Documentation

◆ EepromLocations

Enumerator
LOCATION_MODE 
LOCATION_CANID 
LOCATION_NODE_NUMBER_HIGH 
LOCATION_NODE_NUMBER_LOW 
LOCATION_FLAGS 
LOCATION_RESET_FLAG 
LOCATION_RESERVED_SIZE 10 

◆ FlagBits

Enumerator
HEARTBEAT_BIT 
EVENT_ACK_BIT 
FCU_COMPATIBLE_BIT 

◆ ACTION

enum VLCB::ACTION : byte

Type of Action.

Enumerator
ACT_MESSAGE_IN 

A message coming in to the node.

ACT_MESSAGE_OUT 

A message sent out from the node.

ACT_START_CAN_ENUMERATION 

A request to start CAN enumeration from the user interface.

ACT_CHANGE_MODE 

A request to change mode from the user interface.

ACT_RENEGOTIATE 

A request to change node number from the user interface.

ACT_INDICATE_ACTIVITY 

Some minor activity happened that should be indicated by the user interface.

ACT_INDICATE_WORK 

Some work for the node occurred and should be indicated by the user interface.

ACT_INDICATE_MODE 

The mode has changed and should be indicated by the user interface.

◆ anonymous enum

anonymous enum

Controller long message status codes.

Enumerator
LONG_MESSAGE_INCOMPLETE 
LONG_MESSAGE_COMPLETE  
LONG_MESSAGE_SEQUENCE_ERROR  
LONG_MESSAGE_TIMEOUT_ERROR  
LONG_MESSAGE_CRC_ERROR  
LONG_MESSAGE_TRUNCATED  

Function Documentation

◆ createDefaultStorageForPlatform()

Storage * VLCB::createDefaultStorageForPlatform ( )

◆ encodeGridConnect()

bool VLCB::encodeGridConnect ( char * gcBuffer,
CANFrame * frame )

◆ decodeGridConnect()

bool VLCB::decodeGridConnect ( const char * gcBuffer,
CANFrame * frame )

◆ 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.

◆ 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)
Definition VLCB.cpp:31

◆ setName()

void VLCB::setName ( char * mname)

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

◆ 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.

◆ setNumNodeVariables()

void VLCB::setNumNodeVariables ( byte n)

Set number of node variables that the module will use.

◆ setMaxEvents()

void VLCB::setMaxEvents ( byte n)

Set the max number of events the module can handle.

◆ setEventsStart()

void VLCB::setEventsStart ( byte n)

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

◆ 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 ( )

◆ 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 )

◆ addTimedResponseTask()

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

◆ getFreeEEPROMbase()

unsigned int VLCB::getFreeEEPROMbase ( )

◆ resetModule()

void VLCB::resetModule ( )

◆ begin()

void VLCB::begin ( )

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

◆ 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.

Variable Documentation

◆ DEFAULT_PRIORITY

const int VLCB::DEFAULT_PRIORITY = 0xB

◆ ACTION_QUEUE_SIZE

const int VLCB::ACTION_QUEUE_SIZE = 8

◆ FLASH_PAGE_SIZE

const int VLCB::FLASH_PAGE_SIZE = 512

◆ NUM_FLASH_PAGES

const int VLCB::NUM_FLASH_PAGES = 4

◆ BLINK_RATE

const int VLCB::BLINK_RATE = 500

◆ PULSE_ON_TIME

const int VLCB::PULSE_ON_TIME = 10

◆ SW_TR_HOLD

const unsigned int VLCB::SW_TR_HOLD = 4000U

◆ PULSE_ACTIVITY

const int VLCB::PULSE_ACTIVITY = 20

◆ PULSE_WORK

const int VLCB::PULSE_WORK = 250

◆ LONG_MESSAGE_DEFAULT_DELAY

const int VLCB::LONG_MESSAGE_DEFAULT_DELAY = 20

◆ LONG_MESSAGE_RECEIVE_TIMEOUT

const int VLCB::LONG_MESSAGE_RECEIVE_TIMEOUT = 5000

◆ NUM_EX_CONTEXTS

const int VLCB::NUM_EX_CONTEXTS = 4

◆ EX_BUFFER_LEN

const int VLCB::EX_BUFFER_LEN = 64