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

This represents any device on the bus you want to talk to. More...

#include <can_partnered_control_function.hpp>

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

Public Member Functions

 PartneredControlFunction (std::uint8_t CANPort, const std::vector< NAMEFilter > NAMEFilters, CANLibBadge< PartneredControlFunction >)
 the constructor for a PartneredControlFunction, which is called by the factory function
 
 PartneredControlFunction (PartneredControlFunction &)=delete
 Deleted copy constructor for PartneredControlFunction to avoid slicing.
 
void add_parameter_group_number_callback (std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent, std::shared_ptr< InternalControlFunction > internalControlFunction=nullptr)
 This is how you get notified that this control function has sent you a destination specific message.
 
void remove_parameter_group_number_callback (std::uint32_t parameterGroupNumber, CANLibCallback callback, void *parent, std::shared_ptr< InternalControlFunction > internalControlFunction=nullptr)
 Removes a callback matching exactly the parameters passed in.
 
std::size_t get_number_parameter_group_number_callbacks () const
 Returns the number of parameter group number callbacks associated with this control function.
 
std::size_t get_number_name_filters () const
 Returns the number of NAME filter objects that describe the identity of this control function.
 
std::size_t get_number_name_filters_with_parameter_type (NAME::NAMEParameters parameter)
 Returns the number of NAME filters with a specific NAME parameter component, like manufacturer code.
 
bool get_name_filter_parameter (std::size_t index, NAME::NAMEParameters &parameter, std::uint32_t &filterValue) const
 Returns a NAME filter by index.
 
bool check_matches_name (NAME NAMEToCheck) const
 Checks to see if a NAME matches this CF's NAME filters.
 
- Public Member Functions inherited from isobus::ControlFunction
virtual bool destroy (std::uint32_t expectedRefCount=1)
 Destroys this control function, by removing it from the network manager.
 
std::uint8_t get_address () const
 Returns the current address of the control function.
 
bool get_address_valid () const
 Describes if the control function has a valid address (not NULL or global)
 
std::uint8_t get_can_port () const
 Returns the CAN channel index the control function communicates on.
 
NAME get_NAME () const
 Returns the NAME of the control function as described by its address claim message.
 
Type get_type () const
 Returns the Type of the control function.
 
std::string get_type_string () const
 Returns the 'Type' of the control function as a string.
 

Static Public Member Functions

static std::shared_ptr< PartneredControlFunctioncreate (std::uint8_t CANPort, const std::vector< NAMEFilter > NAMEFilters)
 The factory function to construct a partnered control function.
 
- Static Public Member Functions inherited from isobus::ControlFunction
static std::shared_ptr< ControlFunctioncreate (NAME NAMEValue, std::uint8_t addressValue, std::uint8_t CANPort)
 The factory function to construct a control function.
 

Private Member Functions

ParameterGroupNumberCallbackDataget_parameter_group_number_callback (std::size_t index)
 Returns a parameter group number associated with this control function by index.
 

Static Private Member Functions

static std::shared_ptr< ControlFunctioncreate (NAME, std::uint8_t, std::uint8_t)=delete
 Make inherited factory function private so that it can't be called.
 

Private Attributes

const std::vector< NAMEFilterNAMEFilterList
 A list of NAME parameters that describe this control function's identity.
 
std::vector< ParameterGroupNumberCallbackDataparameterGroupNumberCallbacks
 A list of all parameter group number callbacks associated with this control function.
 
bool initialized = false
 A way to track if the network manager has processed this CF against existing CFs.
 

Friends

class CANNetworkManager
 Allows the network manager to use get_parameter_group_number_callback.
 

Additional Inherited Members

- Public Types inherited from isobus::ControlFunction
enum class  Type { Internal , External , Partnered }
 The type of the control function. More...
 
- Protected Member Functions inherited from isobus::ControlFunction
 ControlFunction (NAME NAMEValue, std::uint8_t addressValue, std::uint8_t CANPort, Type type=Type::External)
 The protected constructor for the control function, which is called by the (inherited) factory function.
 
- Protected Attributes inherited from isobus::ControlFunction
const Type controlFunctionType
 The Type of the control function.
 
NAME controlFunctionNAME
 The NAME of the control function.
 
bool claimedAddressSinceLastAddressClaimRequest = false
 Used to mark CFs as stale if they don't claim within a certain time.
 
std::uint8_t address
 The address of the control function.
 
const std::uint8_t canPortIndex
 The CAN channel index of the control function.
 
- Static Protected Attributes inherited from isobus::ControlFunction
static Mutex controlFunctionProcessingMutex
 Protects the control function tables.
 

Detailed Description

This represents any device on the bus you want to talk to.

To communicate with a device on the bus, create one of these objects and tell it via the constructor what the identity of that device is using NAME fields like manufacturer code, function, and device class. The stack will take care of locating the device on the bus that matches that description, and will allow you to talk to it through passing this object to the appropriate send function in the network manager.

Definition at line 38 of file can_partnered_control_function.hpp.

Constructor & Destructor Documentation

◆ PartneredControlFunction()

isobus::PartneredControlFunction::PartneredControlFunction ( std::uint8_t CANPort,
const std::vector< NAMEFilter > NAMEFilters,
CANLibBadge< PartneredControlFunction >  )

the constructor for a PartneredControlFunction, which is called by the factory function

Parameters
[in]CANPortThe CAN channel associated with this control function definition
[in]NAMEFiltersA list of filters that describe the identity of the CF based on NAME components

Definition at line 21 of file can_partnered_control_function.cpp.

Here is the caller graph for this function:

Member Function Documentation

◆ add_parameter_group_number_callback()

void isobus::PartneredControlFunction::add_parameter_group_number_callback ( std::uint32_t parameterGroupNumber,
CANLibCallback callback,
void * parent,
std::shared_ptr< InternalControlFunction > internalControlFunction = nullptr )

This is how you get notified that this control function has sent you a destination specific message.

Add a callback function here to be notified when this device has sent you a message with the specified PGN. You can also get callbacks for any/all PGNs if you pass in CANLibParameterGroupNumber::Any as the PGN. Optionally you can use the parent pointer to get context inside your callback as to what C++ object the callback is destined for. Whatever you pass in parent will be passed back to you in the callback. In theory, you could use that variable for passing any arbitrary data through the callback also. You can add as many callbacks as you want, and can use the same function for multiple PGNs if you want.

Parameters
[in]parameterGroupNumberThe PGN you want to use to communicate, or CANLibParameterGroupNumber::Any
[in]callbackThe function you want to get called when a message is received with parameterGroupNumber from this CF
[in]parentA generic context variable that helps identify what object the callback was destined for
[in]internalControlFunctionAn internal control function to filter based on. If you supply this parameter the callback will only be called when messages from the partner are received with the specified ICF as the destination.

Definition at line 37 of file can_partnered_control_function.cpp.

◆ check_matches_name()

bool isobus::PartneredControlFunction::check_matches_name ( NAME NAMEToCheck) const

Checks to see if a NAME matches this CF's NAME filters.

Parameters
[in]NAMEToCheckThe NAME to check against this control function's filters
Returns
true if this control function matches the NAME that was passed in, false otherwise

Definition at line 89 of file can_partnered_control_function.cpp.

Here is the call graph for this function:

◆ create()

std::shared_ptr< PartneredControlFunction > isobus::PartneredControlFunction::create ( std::uint8_t CANPort,
const std::vector< NAMEFilter > NAMEFilters )
static

The factory function to construct a partnered control function.

Parameters
[in]CANPortThe CAN channel associated with this control function definition
[in]NAMEFiltersA list of filters that describe the identity of the CF based on NAME components
Returns
A shared pointer to a PartneredControlFunction object created with the parameters passed in

Definition at line 29 of file can_partnered_control_function.cpp.

Here is the call graph for this function:

◆ get_name_filter_parameter()

bool isobus::PartneredControlFunction::get_name_filter_parameter ( std::size_t index,
NAME::NAMEParameters & parameter,
std::uint32_t & filterValue ) const

Returns a NAME filter by index.

Parameters
[in]indexThe index of the filter to get
[out]parameterThe returned parameter type
[out]filterValueThe raw value of the filter associated with the parameter
Returns
true if a filter was returned successfully, false if the index was out of range

Definition at line 62 of file can_partnered_control_function.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_number_name_filters()

std::size_t isobus::PartneredControlFunction::get_number_name_filters ( ) const

Returns the number of NAME filter objects that describe the identity of this control function.

Returns
The number of NAME filter objects that describe the identity of this control function

Definition at line 57 of file can_partnered_control_function.cpp.

Here is the caller graph for this function:

◆ get_number_name_filters_with_parameter_type()

std::size_t isobus::PartneredControlFunction::get_number_name_filters_with_parameter_type ( NAME::NAMEParameters parameter)

Returns the number of NAME filters with a specific NAME parameter component, like manufacturer code.

Parameters
[in]parameterThe NAME parameter to check against
Returns
The number of NAME filters with a specific NAME parameter component

Definition at line 75 of file can_partnered_control_function.cpp.

◆ get_number_parameter_group_number_callbacks()

std::size_t isobus::PartneredControlFunction::get_number_parameter_group_number_callbacks ( ) const

Returns the number of parameter group number callbacks associated with this control function.

Returns
The number of parameter group number callbacks associated with this control function

Definition at line 52 of file can_partnered_control_function.cpp.

Here is the caller graph for this function:

◆ get_parameter_group_number_callback()

ParameterGroupNumberCallbackData & isobus::PartneredControlFunction::get_parameter_group_number_callback ( std::size_t index)
private

Returns a parameter group number associated with this control function by index.

Parameters
[in]indexThe index from which to get the PGN callback data object
Returns
A reference to the PGN callback data object at the index specified

Definition at line 175 of file can_partnered_control_function.cpp.

Here is the call graph for this function:

◆ remove_parameter_group_number_callback()

void isobus::PartneredControlFunction::remove_parameter_group_number_callback ( std::uint32_t parameterGroupNumber,
CANLibCallback callback,
void * parent,
std::shared_ptr< InternalControlFunction > internalControlFunction = nullptr )

Removes a callback matching exactly the parameters passed in.

Parameters
[in]parameterGroupNumberThe PGN associated with the callback being removed
[in]callbackThe callback function being removed
[in]parentA generic context variable that helps identify what object the callback was destined for
[in]internalControlFunctionThe ICF being used to filter messages against

Definition at line 42 of file can_partnered_control_function.cpp.

Friends And Related Symbol Documentation

◆ CANNetworkManager

friend class CANNetworkManager
friend

Allows the network manager to use get_parameter_group_number_callback.

Definition at line 103 of file can_partnered_control_function.hpp.

Member Data Documentation

◆ initialized

bool isobus::PartneredControlFunction::initialized = false
private

A way to track if the network manager has processed this CF against existing CFs.

Definition at line 115 of file can_partnered_control_function.hpp.

◆ NAMEFilterList

const std::vector<NAMEFilter> isobus::PartneredControlFunction::NAMEFilterList
private

A list of NAME parameters that describe this control function's identity.

Definition at line 113 of file can_partnered_control_function.hpp.

◆ parameterGroupNumberCallbacks

std::vector<ParameterGroupNumberCallbackData> isobus::PartneredControlFunction::parameterGroupNumberCallbacks
private

A list of all parameter group number callbacks associated with this control function.

Definition at line 114 of file can_partnered_control_function.hpp.


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