Lydia - Printhead
Loading...
Searching...
No Matches
Component Class Reference

The Component class represents a generic component. More...

#include <Component.h>

Inheritance diagram for Component:
[legend]

Public Member Functions

void clearFlag (byte flag)
 Clears a specific flag for the component.
 
 Component ()
 Default constructor for the Component class.
 
 Component (String _name)
 Constructor for the Component class with a specified name.
 
 Component (String _name, short _id)
 Constructor for the Component class with a specified name and ID.
 
 Component (String _name, short _id, int _flags)
 Constructor for the Component class with a specified name, ID, and flags.
 
 Component (String _name, short _id, int _flags, Component *_owner)
 Constructor for the Component class with a specified name, ID, flags, and owner.
 
virtual short debug ()
 Virtual function to debug the component.
 
virtual short debug (short val0, short val1)
 Virtual function to debug the component.
 
virtual short destroy ()
 Virtual function to destroy the component.
 
void disable ()
 Disables the component.
 
void enable ()
 Enables the component.
 
bool enabled ()
 Checks if the component is enabled.
 
bool hasFlag (byte flag)
 Checks if the component has a specific flag.
 
virtual short info ()
 Virtual function to display information about the component.
 
virtual short info (short val0, short val1)
 Virtual function to display information about the component.
 
virtual short loop ()
 Virtual function to run the component in a loop.
 
virtual short onError (short id, short error)
 
virtual short onMessage (int id, E_CALLS verb, E_MessageFlags flags, const void *user, Component *src)
 Handles incoming messages.
 
virtual short onRawResponse (short size, uint8_t rxBuffer[])
 
virtual short onRegisterMethods (Bridge *bridge)
 
virtual short onResponse (short error)
 
void setFlag (byte flag)
 Sets a specific flag for the component.
 
virtual short setup ()
 Virtual function to set up the component.
 
 ~Component ()
 Destructor for the Component class.
 
- Public Member Functions inherited from ModbusGateway
short getAddress ()
 
MB_FC getFunctionCode ()
 
short getNumberAddresses ()
 
virtual String getRegisterDescription (short flags=0)
 
const chargetRegisterMode ()
 
 ModbusGateway ()
 
 ModbusGateway (short _addr)
 
 ModbusGateway (short _addr, short _fc)
 
void setAddress (short _addr)
 
void setFunctionCode (MB_FC fc)
 
void setGateway (Mudbus *mudbus)
 
void setNumberAddresses (short _nbAddr)
 
void setRegisterMode (MB_REGISTER_MODE mode)
 

Public Attributes

int flags
 The run flags for the component.
 
const short id
 The ID of the component.
 
millis_t last
 The last tick time in milliseconds.
 
String name
 The name of the component.
 
int nFlags
 The network capabilities of the component.
 
millis_t now
 The current time in milliseconds.
 
Componentowner
 The owner of the component.
 
- Public Attributes inherited from ModbusGateway
short addr
 
MB_FC fn
 
uchar lastMQSlot
 
Mudbusmudbus
 
short nbAddr
 
short registerMode
 

Static Public Attributes

static const int COMPONENT_DEFAULT = 1 << OBJECT_RUN_FLAGS::E_OF_LOOP | 1 << OBJECT_RUN_FLAGS::E_OF_SETUP
 The default run flags for a component.
 
static const int COMPONENT_NO_ID = 0
 The default ID for a component.
 

Detailed Description

The Component class represents a generic component.

Definition at line 20 of file Component.h.

Constructor & Destructor Documentation

◆ Component() [1/5]

Component::Component ( )
inline

Default constructor for the Component class.

Definition at line 36 of file Component.h.

36 : name("NO_NAME"), id(0),
37 flags(OBJECT_RUN_FLAGS::E_OF_NONE),
38 nFlags(OBJECT_NET_CAPS::E_NCAPS_NONE) {}
int nFlags
The network capabilities of the component.
Definition Component.h:206
const short id
The ID of the component.
Definition Component.h:196
String name
The name of the component.
Definition Component.h:191
int flags
The run flags for the component.
Definition Component.h:201

◆ Component() [2/5]

Component::Component ( String _name)
inline

Constructor for the Component class with a specified name.

Parameters
_nameThe name of the component.

Definition at line 44 of file Component.h.

45 flags(OBJECT_RUN_FLAGS::E_OF_NONE),
46 nFlags(OBJECT_NET_CAPS::E_NCAPS_NONE) {}
static const int COMPONENT_NO_ID
The default ID for a component.
Definition Component.h:31
Definition xtimer.h:21

◆ Component() [3/5]

Component::Component ( String _name,
short _id )
inline

Constructor for the Component class with a specified name and ID.

Parameters
_nameThe name of the component.
_idThe ID of the component.

Definition at line 53 of file Component.h.

53 : name(_name),
54 id(_id),
55 flags(OBJECT_RUN_FLAGS::E_OF_NONE),
56 nFlags(OBJECT_NET_CAPS::E_NCAPS_NONE) {}

◆ Component() [4/5]

Component::Component ( String _name,
short _id,
int _flags )
inline

Constructor for the Component class with a specified name, ID, and flags.

Parameters
_nameThe name of the component.
_idThe ID of the component.
_flagsThe run flags for the component.

Definition at line 64 of file Component.h.

64 : name(_name),
65 id(_id),
67 nFlags(OBJECT_NET_CAPS::E_NCAPS_NONE)
68 {
69 }

◆ Component() [5/5]

Component::Component ( String _name,
short _id,
int _flags,
Component * _owner )
inline

Constructor for the Component class with a specified name, ID, flags, and owner.

Parameters
_nameThe name of the component.
_idThe ID of the component.
_flagsThe run flags for the component.
_ownerThe owner of the component.

Definition at line 78 of file Component.h.

78 : name(_name),
79 id(_id),
82 nFlags(OBJECT_NET_CAPS::E_NCAPS_NONE) {}
Component * owner
The owner of the component.
Definition Component.h:211

◆ ~Component()

Component::~Component ( )
inline

Destructor for the Component class.

Definition at line 87 of file Component.h.

87{}

Member Function Documentation

◆ clearFlag()

void Component::clearFlag ( byte flag)
inline

Clears a specific flag for the component.

Parameters
flagThe flag to clear.

Definition at line 158 of file Component.h.

159 {
160 CBI(flags, flag);
161 }
#define CBI(n, b)
Definition macros.h:154

◆ debug() [1/2]

virtual short Component::debug ( )
inlinevirtual

Virtual function to debug the component.

Parameters
streamThe stream to output the debug information to.
Returns
The error code indicating the success or failure of the operation.

Reimplemented in Pos3Analog, MotorLoad, POT, Relay, StatusLight, StepperController, ModbusBridge, OmronPID, OmronVFD, H7TC, PID, App, Bridge, and SerialMessage.

Definition at line 100 of file Component.h.

100{ return E_OK; }
#define E_OK

◆ debug() [2/2]

virtual short Component::debug ( short val0,
short val1 )
inlinevirtual

Virtual function to debug the component.

Parameters
streamThe stream to output the debug information to.
Returns
The error code indicating the success or failure of the operation.

Definition at line 107 of file Component.h.

107{ return E_OK; }

◆ destroy()

virtual short Component::destroy ( )
inlinevirtual

Virtual function to destroy the component.

Returns
The error code indicating the success or failure of the operation.

Definition at line 93 of file Component.h.

93{ return E_OK; }

◆ disable()

void Component::disable ( )
inline

Disables the component.

Definition at line 174 of file Component.h.

175 {
176 setFlag(OBJECT_RUN_FLAGS::E_OF_DISABLED);
177 }
void setFlag(byte flag)
Sets a specific flag for the component.
Definition Component.h:149

◆ enable()

void Component::enable ( )
inline

Enables the component.

Definition at line 166 of file Component.h.

167 {
168 clearFlag(OBJECT_RUN_FLAGS::E_OF_DISABLED);
169 }
void clearFlag(byte flag)
Clears a specific flag for the component.
Definition Component.h:158

◆ enabled()

bool Component::enabled ( )
inline

Checks if the component is enabled.

Returns
True if the component is enabled, false otherwise.

Definition at line 183 of file Component.h.

184 {
185 return !hasFlag(OBJECT_RUN_FLAGS::E_OF_DISABLED);
186 }
bool hasFlag(byte flag)
Checks if the component has a specific flag.
Definition Component.h:140

◆ hasFlag()

bool Component::hasFlag ( byte flag)
inline

Checks if the component has a specific flag.

Parameters
flagThe flag to check.
Returns
True if the component has the flag, false otherwise.

Definition at line 140 of file Component.h.

141 {
142 return TEST(flags, flag);
143 }
#define TEST(n, b)
Definition macros.h:152

◆ info() [1/2]

virtual short Component::info ( )
inlinevirtual

Virtual function to display information about the component.

Parameters
streamThe stream to output the information to.
Returns
The error code indicating the success or failure of the operation.

Reimplemented in MotorLoad, StatusLight, StepperController, ModbusBridge, OmronPID, OmronVFD, H7TC, and App.

Definition at line 114 of file Component.h.

114{ return E_OK; }

◆ info() [2/2]

virtual short Component::info ( short val0,
short val1 )
inlinevirtual

Virtual function to display information about the component.

Parameters
streamThe stream to output the information to.
Returns
The error code indicating the success or failure of the operation.

Reimplemented in Pos3Analog, POT, and Relay.

Definition at line 121 of file Component.h.

121{ return E_OK; }

◆ loop()

virtual short Component::loop ( )
inlinevirtual

Virtual function to run the component in a loop.

Returns
The error code indicating the success or failure of the operation.

Reimplemented in Pos3Analog, MotorLoad, POT, Relay, StatusLight, StepperController, ModbusBridge, OmronPID, OmronVFD, PHApp, H7TC, TC, App, and SerialMessage.

Definition at line 133 of file Component.h.

133{ return E_OK; }

◆ onError()

virtual short Component::onError ( short id,
short error )
inlinevirtual

Reimplemented in PHApp.

Definition at line 246 of file Component.h.

246{ return E_OK; }

◆ onMessage()

virtual short Component::onMessage ( int id,
E_CALLS verb,
E_MessageFlags flags,
const void * user,
Component * src )
inlinevirtual

Handles incoming messages.

This function is called when a message is received by the component. It processes the message and returns a short value indicating the status of the operation.

Parameters
idThe ID of the message.
verbThe type of operation to be performed.
flagsThe flags associated with the message.
userA pointer to user-defined data.
srcThe source component that sent the message.
Returns
A short value indicating the status of the operation.

Reimplemented in Bridge.

Definition at line 241 of file Component.h.

242 {
243 return E_OK;
244 }

◆ onRawResponse()

virtual short Component::onRawResponse ( short size,
uint8_t rxBuffer[] )
inlinevirtual

Reimplemented in OmronPID, and OmronVFD.

Definition at line 248 of file Component.h.

248{ return E_OK; }

◆ onRegisterMethods()

short Component::onRegisterMethods ( Bridge * bridge)
virtual

Registers methods for the component with the specified bridge. This method should be overridden by derived classes to provide custom method registration logic.

Parameters
bridgeThe bridge to register methods with.
Returns
The status code indicating the success or failure of the method registration.

Reimplemented in Pos3Analog, POT, Relay, StatusLight, StepperController, OmronPID, OmronVFD, and PHApp.

Definition at line 4 of file Component.cpp.

5{
6 return E_OK;
7}

◆ onResponse()

virtual short Component::onResponse ( short error)
inlinevirtual

Reimplemented in OmronPID, and OmronVFD.

Definition at line 247 of file Component.h.

247{ return E_OK; }

◆ setFlag()

void Component::setFlag ( byte flag)
inline

Sets a specific flag for the component.

Parameters
flagThe flag to set.

Definition at line 149 of file Component.h.

150 {
151 SBI(flags, flag);
152 }
#define SBI(n, b)
Definition macros.h:153

◆ setup()

virtual short Component::setup ( )
inlinevirtual

Virtual function to set up the component.

Returns
The error code indicating the success or failure of the operation.

Reimplemented in Pos3Analog, MotorLoad, POT, Relay, StatusLight, StepperController, ModbusBridge, OmronPID, OmronVFD, PHApp, H7TC, TC, App, Bridge, and SerialMessage.

Definition at line 127 of file Component.h.

127{ return E_OK; }

Member Data Documentation

◆ COMPONENT_DEFAULT

const int Component::COMPONENT_DEFAULT = 1 << OBJECT_RUN_FLAGS::E_OF_LOOP | 1 << OBJECT_RUN_FLAGS::E_OF_SETUP
static

The default run flags for a component.

Definition at line 26 of file Component.h.

◆ COMPONENT_NO_ID

const int Component::COMPONENT_NO_ID = 0
static

The default ID for a component.

Definition at line 31 of file Component.h.

◆ flags

int Component::flags

The run flags for the component.

Definition at line 201 of file Component.h.

◆ id

const short Component::id

The ID of the component.

Definition at line 196 of file Component.h.

◆ last

millis_t Component::last

The last tick time in milliseconds.

Definition at line 221 of file Component.h.

◆ name

String Component::name

The name of the component.

Definition at line 191 of file Component.h.

◆ nFlags

int Component::nFlags

The network capabilities of the component.

Definition at line 206 of file Component.h.

◆ now

millis_t Component::now

The current time in milliseconds.

Definition at line 216 of file Component.h.

◆ owner

Component* Component::owner

The owner of the component.

Definition at line 211 of file Component.h.


The documentation for this class was generated from the following files: