AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
This represents any device on the bus you want to talk to. More...
#include <can_partnered_control_function.hpp>
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 ¶meter, 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< PartneredControlFunction > | create (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< ControlFunction > | create (NAME NAMEValue, std::uint8_t addressValue, std::uint8_t CANPort) |
The factory function to construct a control function. | |
Private Member Functions | |
ParameterGroupNumberCallbackData & | get_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< ControlFunction > | create (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< NAMEFilter > | NAMEFilterList |
A list of NAME parameters that describe this control function's identity. | |
std::vector< ParameterGroupNumberCallbackData > | parameterGroupNumberCallbacks |
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. | |
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.
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
[in] | CANPort | The CAN channel associated with this control function definition |
[in] | NAMEFilters | A 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.
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.
[in] | parameterGroupNumber | The PGN you want to use to communicate, or CANLibParameterGroupNumber::Any |
[in] | callback | The function you want to get called when a message is received with parameterGroupNumber from this CF |
[in] | parent | A generic context variable that helps identify what object the callback was destined for |
[in] | internalControlFunction | An 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.
bool isobus::PartneredControlFunction::check_matches_name | ( | NAME | NAMEToCheck | ) | const |
Checks to see if a NAME matches this CF's NAME filters.
[in] | NAMEToCheck | The NAME to check against this control function's filters |
Definition at line 89 of file can_partnered_control_function.cpp.
|
static |
The factory function to construct a partnered control function.
[in] | CANPort | The CAN channel associated with this control function definition |
[in] | NAMEFilters | A list of filters that describe the identity of the CF based on NAME components |
Definition at line 29 of file can_partnered_control_function.cpp.
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.
[in] | index | The index of the filter to get |
[out] | parameter | The returned parameter type |
[out] | filterValue | The raw value of the filter associated with the parameter |
Definition at line 62 of file can_partnered_control_function.cpp.
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.
Definition at line 57 of file can_partnered_control_function.cpp.
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.
[in] | parameter | The NAME parameter to check against |
Definition at line 75 of file can_partnered_control_function.cpp.
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.
Definition at line 52 of file can_partnered_control_function.cpp.
|
private |
Returns a parameter group number associated with this control function by index.
[in] | index | The index from which to get the PGN callback data object |
Definition at line 175 of file can_partnered_control_function.cpp.
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.
[in] | parameterGroupNumber | The PGN associated with the callback being removed |
[in] | callback | The callback function being removed |
[in] | parent | A generic context variable that helps identify what object the callback was destined for |
[in] | internalControlFunction | The ICF being used to filter messages against |
Definition at line 42 of file can_partnered_control_function.cpp.
|
friend |
Allows the network manager to use get_parameter_group_number_callback.
Definition at line 103 of file can_partnered_control_function.hpp.
|
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.
|
private |
A list of NAME parameters that describe this control function's identity.
Definition at line 113 of file can_partnered_control_function.hpp.
|
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.