AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
isobus::Macro Class Reference

Defines a macro object. Performs a list of commands based on a message or event. More...

#include <isobus_virtual_terminal_objects.hpp>

Inheritance diagram for isobus::Macro:
[legend]
Collaboration diagram for isobus::Macro:
[legend]

Public Types

enum class  AttributeName : std::uint8_t { Type = 0 , NumberOfAttributes = 1 }
 Enumerates this object's attributes which are assigned an attribute ID. The Change Attribute command allows any writable attribute with an AID to be changed. More...
 
enum class  Command {
  HideShowObject = 0xA0 , EnableDisableObject = 0xA1 , SelectInputObject = 0xA2 , ControlAudioSignal = 0xA3 ,
  SetAudioVolume = 0xA4 , ChangeChildLocation = 0xA5 , ChangeSize = 0xA6 , ChangeBackgroundColour = 0xA7 ,
  ChangeNumericValue = 0xA8 , ChangeEndPoint = 0xA9 , ChangeFontAttributes = 0xAA , ChangeLineAttributes = 0xAB ,
  ChangeFillAttributes = 0xAC , ChangeActiveMask = 0xAD , ChangeSoftKeyMask = 0xAE , ChangeAttribute = 0xAF ,
  ChangePriority = 0xB0 , ChangeListItem = 0xB1 , ChangeStringValue = 0xB3 , ChangeChildPosition = 0xB4 ,
  ChangeObjectLabel = 0xB5 , ChangePolygonPoint = 0xB6 , LockUnlockMask = 0xBD , ExecuteMacro = 0xBE ,
  ChangePolygonScale = 0xB7 , GraphicsContextCommand = 0xB8 , SelectColourMap = 0xBA , ExecuteExtendedMacro = 0xBC
}
 A subset of the VT command multiplexors that support use in macros. More...
 
- Public Types inherited from isobus::VTObject
enum class  AttributeError : std::uint8_t { InvalidObjectID = 0 , InvalidAttributeID = 1 , InvalidValue = 2 , AnyOtherError = 4 }
 Enumerates the bit indices of the error fields that can be set when changing an attribute. More...
 

Public Member Functions

 Macro ()=default
 Constructor for a macro object.
 
 ~Macro () override=default
 Virtual destructor for a macro object.
 
VirtualTerminalObjectType get_object_type () const override
 Returns the VT object type of the underlying derived object.
 
std::uint32_t get_minumum_object_length () const override
 Returns the minimum binary serialized length of the associated object.
 
bool get_is_valid (const std::map< std::uint16_t, std::shared_ptr< VTObject > > &objectPool) const override
 Performs basic error checking on the object and returns if the object is valid.
 
bool set_attribute (std::uint8_t attributeID, std::uint32_t rawAttributeData, const std::map< std::uint16_t, std::shared_ptr< VTObject > > &objectPool, AttributeError &returnedError) override
 Sets an attribute and optionally returns an error code in the last parameter.
 
bool get_attribute (std::uint8_t attributeID, std::uint32_t &returnedAttributeData) const override
 Gets an attribute and returns the raw data in the last parameter.
 
bool add_command_packet (const std::vector< std::uint8_t > &command)
 Adds a macro command packet to this macro. Essentially these are CAN messages that represent normal ECU to VT commands that will be executed in order by this macro.
 
std::uint8_t get_number_of_commands () const
 Returns the number of stored command packets inside this macro (max 255)
 
bool get_command_packet (std::uint8_t index, std::vector< std::uint8_t > &command)
 Returns a command packet by index.
 
bool remove_command_packet (std::uint8_t index)
 Deletes a command packet from the macro by index.
 
bool get_are_command_packets_valid () const
 Returns if the command packets in this macro are valid.
 
- Public Member Functions inherited from isobus::VTObject
 VTObject ()=default
 Constructor for a generic VT object. Sets up default values and the pointer to the member object pool.
 
virtual ~VTObject ()=default
 Virtual destructor for a generic VT object.
 
std::uint16_t get_id () const
 Returns the object ID of this VT object.
 
void set_id (std::uint16_t value)
 Sets the object ID of this VT object.
 
std::uint16_t get_width () const
 Returns the width of this object in px.
 
void set_width (std::uint16_t value)
 Sets the width of this object in px.
 
std::uint16_t get_height () const
 Returns the height of this object in px.
 
void set_height (std::uint16_t value)
 Sets the height of this object in px.
 
std::uint8_t get_background_color () const
 Returns the background color attribute of this object.
 
void set_background_color (std::uint8_t value)
 Sets the background color attribute of this object.
 
std::uint16_t get_number_children () const
 Returns the number of child objects within this object.
 
void add_child (std::uint16_t objectID, std::int16_t relativeXLocation, std::int16_t relativeYLocation)
 Adds an object as a child to another object, which essentially creates a tree of object association.
 
std::uint16_t get_child_id (std::uint16_t index) const
 Returns the ID of the child by index, if one was added previously.
 
std::int16_t get_child_x (std::uint16_t index) const
 Returns the X offset of the child object associated with the specified index into the parent object.
 
std::int16_t get_child_y (std::uint16_t index) const
 Returns the Y offset of the child object associated with the specified index into the parent object.
 
void set_child_x (std::uint16_t index, std::int16_t xOffset)
 Sets the X offset of the child object associated with the specified index into the parent object.
 
void set_child_y (std::uint16_t index, std::int16_t yOffset)
 Sets the Y offset of the child object associated with the specified index into the parent object.
 
bool offset_all_children_with_id (std::uint16_t childObjectID, std::int8_t xOffset, std::int8_t yOffset)
 Offsets all child objects with the specified ID by the amount specified relative to its parent.
 
void remove_child (std::uint16_t objectIDToRemove, std::int16_t relativeXLocation, std::int16_t relativeYLocation)
 Removes an object reference from another object. All fields must exactly match for the object to be removed. This is because objects can have multiple of the same child at different places, so we can't infer which one to remove without the exact position.
 
void pop_child ()
 Removes the last added child object. This is meant to be a faster way to deal with objects that only have a max of 1 child.
 
std::uint8_t get_number_macros () const
 Returns the number of macros referenced by this object.
 
void add_macro (MacroMetadata macroToAdd)
 Adds a macro to the list of macros referenced by this object.
 
MacroMetadata get_macro (std::uint8_t index) const
 Returns the macro ID at the specified index.
 

Private Attributes

std::vector< std::vector< std::uint8_t > > commandPackets
 Macro command list.
 

Static Private Attributes

static constexpr std::uint32_t MIN_OBJECT_LENGTH = 5
 The fewest bytes of IOP data that can represent this object.
 
static const std::array< std::uint8_t, 28 > ALLOWED_COMMANDS_LOOKUP_TABLE
 The list of all allowed commands in a table for easy lookup when validating macro content.
 

Additional Inherited Members

- Static Public Member Functions inherited from isobus::VTObject
static std::shared_ptr< VTObjectget_object_by_id (std::uint16_t objectID, const std::map< std::uint16_t, std::shared_ptr< VTObject > > &objectPool)
 Returns a VT object from its member pool by ID, or the null id if it does not exist.
 
- Protected Attributes inherited from isobus::VTObject
std::vector< ChildObjectDatachildren
 List of child objects.
 
std::vector< MacroMetadatamacros
 List of macros referenced by this object.
 
std::uint16_t objectID = NULL_OBJECT_ID
 Object identifier. Shall be unique within the object pool.
 
std::uint16_t width = 0
 The width of the object. Not always applicable, but often used.
 
std::uint16_t height = 0
 The height of the object. Not always applicable, but often used.
 
std::uint8_t backgroundColor = 0
 The background color (from the VT colour table)
 

Detailed Description

Defines a macro object. Performs a list of commands based on a message or event.

Definition at line 4052 of file isobus_virtual_terminal_objects.hpp.

Member Enumeration Documentation

◆ AttributeName

enum class isobus::Macro::AttributeName : std::uint8_t
strong

Enumerates this object's attributes which are assigned an attribute ID. The Change Attribute command allows any writable attribute with an AID to be changed.

Definition at line 4057 of file isobus_virtual_terminal_objects.hpp.

◆ Command

enum class isobus::Macro::Command
strong

A subset of the VT command multiplexors that support use in macros.

Definition at line 4065 of file isobus_virtual_terminal_objects.hpp.

Member Function Documentation

◆ add_command_packet()

bool isobus::Macro::add_command_packet ( const std::vector< std::uint8_t > & command)

Adds a macro command packet to this macro. Essentially these are CAN messages that represent normal ECU to VT commands that will be executed in order by this macro.

Parameters
[in]commandThe command packet (CAN message data) to add
Returns
true if the command was added to the macro, otherwise false (maybe the max number of commands has been hit)

Definition at line 7571 of file isobus_virtual_terminal_objects.cpp.

◆ get_are_command_packets_valid()

bool isobus::Macro::get_are_command_packets_valid ( ) const

Returns if the command packets in this macro are valid.

Returns
true if the command packets in this macro are valid, otherwise false

Definition at line 7613 of file isobus_virtual_terminal_objects.cpp.

◆ get_attribute()

bool isobus::Macro::get_attribute ( std::uint8_t attributeID,
std::uint32_t & returnedAttributeData ) const
overridevirtual

Gets an attribute and returns the raw data in the last parameter.

Parameters
[in]attributeIDThe ID of the attribute to get
[out]returnedAttributeDataThe raw data of the attribute, as decoded in little endian format with unused bytes/bits set to zero. You may need to cast this to the correct type. If this function returns false, this value is undefined.
Returns
True if the attribute was retrieved, otherwise false (the attribute ID was invalid)

Implements isobus::VTObject.

Definition at line 7547 of file isobus_virtual_terminal_objects.cpp.

Here is the call graph for this function:

◆ get_command_packet()

bool isobus::Macro::get_command_packet ( std::uint8_t index,
std::vector< std::uint8_t > & command )

Returns a command packet by index.

Parameters
[in]indexThe index of the packet to retrieve
[out]commandThe returned command packet if the return value is true, otherwise the returned command packet content is undefined.
Returns
true if a valid command packet was returned, otherwise false (index out of range)

Definition at line 7588 of file isobus_virtual_terminal_objects.cpp.

◆ get_is_valid()

bool isobus::Macro::get_is_valid ( const std::map< std::uint16_t, std::shared_ptr< VTObject > > & objectPool) const
overridevirtual

Performs basic error checking on the object and returns if the object is valid.

Parameters
[in]objectPoolThe object pool to use when validating the object
Returns
true if the object passed basic error checks

Implements isobus::VTObject.

Definition at line 7536 of file isobus_virtual_terminal_objects.cpp.

◆ get_minumum_object_length()

std::uint32_t isobus::Macro::get_minumum_object_length ( ) const
overridevirtual

Returns the minimum binary serialized length of the associated object.

Returns
The minimum binary serialized length of the associated object

Implements isobus::VTObject.

Definition at line 7531 of file isobus_virtual_terminal_objects.cpp.

◆ get_number_of_commands()

std::uint8_t isobus::Macro::get_number_of_commands ( ) const

Returns the number of stored command packets inside this macro (max 255)

Returns
The number of stored command packets inside this macro

Definition at line 7583 of file isobus_virtual_terminal_objects.cpp.

◆ get_object_type()

VirtualTerminalObjectType isobus::Macro::get_object_type ( ) const
overridevirtual

Returns the VT object type of the underlying derived object.

Returns
The VT object type of the underlying derived object

Implements isobus::VTObject.

Definition at line 7526 of file isobus_virtual_terminal_objects.cpp.

◆ remove_command_packet()

bool isobus::Macro::remove_command_packet ( std::uint8_t index)

Deletes a command packet from the macro by index.

Parameters
[in]indexThe index of the packet to delete
Returns
true if the specified command packet was removed, otherwise false (index out of range)

Definition at line 7600 of file isobus_virtual_terminal_objects.cpp.

◆ set_attribute()

bool isobus::Macro::set_attribute ( std::uint8_t attributeID,
std::uint32_t rawAttributeData,
const std::map< std::uint16_t, std::shared_ptr< VTObject > > & objectPool,
AttributeError & returnedError )
overridevirtual

Sets an attribute and optionally returns an error code in the last parameter.

Parameters
[in]attributeIDThe ID of the attribute to change
[in]rawAttributeDataThe raw data to change the attribute to, as decoded in little endian format with unused bytes/bits set to zero.
[in]objectPoolThe object pool to use when validating the objects affected by setting this attribute
[out]returnedErrorIf this function returns false, this will be the error code. If the function returns true, this value is undefined.
Returns
True if the attribute was changed, otherwise false (check the returnedError in this case to know why).

Implements isobus::VTObject.

Definition at line 7541 of file isobus_virtual_terminal_objects.cpp.

Member Data Documentation

◆ ALLOWED_COMMANDS_LOOKUP_TABLE

const std::array< std::uint8_t, 28 > isobus::Macro::ALLOWED_COMMANDS_LOOKUP_TABLE
staticprivate
Initial value:
= {
static_cast<std::uint8_t>(Command::HideShowObject),
static_cast<std::uint8_t>(Command::EnableDisableObject),
static_cast<std::uint8_t>(Command::SelectInputObject),
static_cast<std::uint8_t>(Command::ControlAudioSignal),
static_cast<std::uint8_t>(Command::SetAudioVolume),
static_cast<std::uint8_t>(Command::ChangeChildLocation),
static_cast<std::uint8_t>(Command::ChangeSize),
static_cast<std::uint8_t>(Command::ChangeBackgroundColour),
static_cast<std::uint8_t>(Command::ChangeNumericValue),
static_cast<std::uint8_t>(Command::ChangeEndPoint),
static_cast<std::uint8_t>(Command::ChangeFontAttributes),
static_cast<std::uint8_t>(Command::ChangeLineAttributes),
static_cast<std::uint8_t>(Command::ChangeFillAttributes),
static_cast<std::uint8_t>(Command::ChangeActiveMask),
static_cast<std::uint8_t>(Command::ChangeSoftKeyMask),
static_cast<std::uint8_t>(Command::ChangeAttribute),
static_cast<std::uint8_t>(Command::ChangePriority),
static_cast<std::uint8_t>(Command::ChangeListItem),
static_cast<std::uint8_t>(Command::ChangeStringValue),
static_cast<std::uint8_t>(Command::ChangeChildPosition),
static_cast<std::uint8_t>(Command::ChangeObjectLabel),
static_cast<std::uint8_t>(Command::ChangePolygonPoint),
static_cast<std::uint8_t>(Command::LockUnlockMask),
static_cast<std::uint8_t>(Command::ExecuteMacro),
static_cast<std::uint8_t>(Command::ChangePolygonScale),
static_cast<std::uint8_t>(Command::GraphicsContextCommand),
static_cast<std::uint8_t>(Command::SelectColourMap),
static_cast<std::uint8_t>(Command::ExecuteExtendedMacro)
}

The list of all allowed commands in a table for easy lookup when validating macro content.

Definition at line 4162 of file isobus_virtual_terminal_objects.hpp.

◆ commandPackets

std::vector<std::vector<std::uint8_t> > isobus::Macro::commandPackets
private

Macro command list.

Definition at line 4163 of file isobus_virtual_terminal_objects.hpp.

◆ MIN_OBJECT_LENGTH

constexpr std::uint32_t isobus::Macro::MIN_OBJECT_LENGTH = 5
staticconstexprprivate

The fewest bytes of IOP data that can represent this object.

Definition at line 4161 of file isobus_virtual_terminal_objects.hpp.


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