AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
|
An ISO11783-10 task controller (or data logger) server. A task controller collects task data from connected implements, and optionally controls them. This interface supports the CAN layer of TC-SC, TC-GEO, and TC-BAS. More...
#include <isobus_task_controller_server.hpp>
Classes | |
class | ActiveClient |
Stores information about a client that is currently being communicated with. More... | |
Public Types | |
enum class | ObjectPoolActivationError : std::uint8_t { NoErrors = 0x00 , ThereAreErrorsInTheDDOP = 0x01 , TaskControllerRanOutOfMemoryDuringActivation = 0x02 , AnyOtherError = 0x04 , DifferentDDOPExistsWithSameStructureLabel = 0x08 } |
Enumerates the different error codes that can be returned when activating a device descriptor object pool. More... | |
enum class | ObjectPoolDeletionErrors : std::uint8_t { ObjectPoolIsReferencedByTaskData = 0 , ServerCannotCheckForObjectPoolReferences = 1 , ErrorDetailsNotAvailable = 0xFF } |
Enumerates the different error codes that can be returned when deleting a device descriptor object pool. More... | |
enum class | ObjectPoolErrorCodes : std::uint8_t { NoErrors = 0x00 , MethodOrAttributeNotSupported = 0x01 , UnknownObjectReference = 0x02 , AnyOtherError = 0x04 , DDOPWasDeletedFromVolatileMemory = 0x08 } |
Enumerates the different error codes that can be returned when processing a DDOP. More... | |
enum class | ProcessDataCommands : std::uint8_t { TechnicalCapabilities = 0x00 , DeviceDescriptor = 0x01 , RequestValue = 0x02 , Value = 0x03 , MeasurementTimeInterval = 0x04 , MeasurementDistanceInterval = 0x05 , MeasurementMinimumWithinThreshold = 0x06 , MeasurementMaximumWithinThreshold = 0x07 , MeasurementChangeThreshold = 0x08 , PeerControlAssignment = 0x09 , SetValueAndAcknowledge = 0x0A , Reserved = 0x0B , Reserved2 = 0x0C , Acknowledge = 0x0D , Status = 0x0E , ClientTask = 0x0F } |
Enumerates the different process data commands that can be sent to the client. More... | |
enum class | ServerOptions : std::uint8_t { SupportsDocumentation = 0x01 , SupportsTCGEOWithoutPositionBasedControl = 0x02 , SupportsTCGEOWithPositionBasedControl = 0x04 , SupportsPeerControlAssignment = 0x08 , SupportsImplementSectionControl = 0x10 , ReservedOption1 = 0x20 , ReservedOption2 = 0x40 , ReservedOption3 = 0x80 } |
Enumerates the different options that can be reported by the server. Each option is a bit in a bitfield, with 1 meaning the option is supported and 0 meaning it is not. For example, if the server supports documentation and peer control assignment, but not the other options, the bitfield would be 0b00001001. More... | |
enum class | ProcessDataAcknowledgeErrorCodes : std::uint8_t { ProcessDataCommandNotSupported = 0x01 , InvalidElementNumber = 0x02 , DDINotSupportedByElement = 0x04 , TriggerMethodNotSupported = 0x08 , ProcessDataNotSettable = 0x10 , InvalidOrUnsupportedIntervalOrThreshold = 0x20 , ProcessDataValueDoesNotConformToDDIDefinition = 0x40 , ProcessDataValueIsOutOfOperationalRangeOfThisDevice = 0x80 } |
Enumerates all PDACK error codes that can be sent to or from the client. More... | |
enum class | TaskControllerVersion : std::uint8_t { DraftInternationalStandard = 0 , FinalDraftInternationalStandardFirstEdition = 1 , FirstPublishedEdition = 2 , SecondEditionDraft = 3 , SecondPublishedEdition = 4 , Unknown = 0xFF } |
Enumerates the different versions of the task controller standard. More... | |
Public Member Functions | |
TaskControllerServer (std::shared_ptr< InternalControlFunction > internalControlFunction, std::uint8_t numberBoomsSupported, std::uint8_t numberSectionsSupported, std::uint8_t numberChannelsSupportedForPositionBasedControl, const TaskControllerOptions &options, TaskControllerVersion versionToReport=TaskControllerVersion::SecondPublishedEdition) | |
Constructor for a TC server. | |
virtual | ~TaskControllerServer () |
Destructor for a TC server. | |
TaskControllerServer (TaskControllerServer &)=delete | |
Deleted copy constructor. | |
TaskControllerServer & | operator= (const TaskControllerServer &)=delete |
Deleted assignment operator. | |
virtual bool | activate_object_pool (std::shared_ptr< ControlFunction > clientControlFunction, ObjectPoolActivationError &activationError, ObjectPoolErrorCodes &objectPoolError, std::uint16_t &parentObjectIDOfFaultyObject, std::uint16_t &faultyObjectID)=0 |
This function will be called by the server when the client wants to activate its DDOP. You should implement this function to activate the DDOP and return whether or not it was successful. Generally this means that you will want to parse the pool, and make sure its schema is valid at this time. You can use our DeviceDescriptorObjectPool class to help you with this. | |
virtual bool | change_designator (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t objectIDToAlter, const std::vector< std::uint8_t > &designator)=0 |
This function will be called by the server when the client wants to change the designator of an object. This could be called because the client wants to change the name of an implement, or the name of a section, or change the active language being used in the DDOP's designators. You should implement this function to change the designator of the object and return whether or not it was successful. | |
virtual bool | deactivate_object_pool (std::shared_ptr< ControlFunction > clientControlFunction)=0 |
This function will be called by the server when the client wants to deactivate its DDOP. You should implement this function to deactivate the DDOP and return whether or not it was successful. | |
virtual bool | delete_device_descriptor_object_pool (std::shared_ptr< ControlFunction > clientControlFunction, ObjectPoolDeletionErrors &returnedErrorCode)=0 |
This function will be called by the server when the client wants to delete its DDOP. Each client is allowed to have one DDOP, so deletion is not required, but a client might be kind and delete its DDOP when it is no longer needed. You should implement this function to delete the DDOP and return whether or not it was successful. | |
virtual bool | get_is_stored_device_descriptor_object_pool_by_structure_label (std::shared_ptr< ControlFunction > clientControlFunction, const std::vector< std::uint8_t > &structureLabel, const std::vector< std::uint8_t > &extendedStructureLabel)=0 |
This function will be called by the server when the server needs to know if it has previously saved to non volatile memory (NVM) a DDOP which is identified by the provided structure label, and optionally also the provided extended structure label. You should implement this function to return whether or not the DDOP is stored in NVM. | |
virtual bool | get_is_stored_device_descriptor_object_pool_by_localization_label (std::shared_ptr< ControlFunction > clientControlFunction, const std::array< std::uint8_t, 7 > &localizationLabel)=0 |
This function will be called by the server when the server needs to know if it has previously saved to non volatile memory (NVM) a DDOP which is identified by the provided localization label. You should implement this function to return whether or not the DDOP is stored in NVM. | |
virtual bool | get_is_enough_memory_available (std::uint32_t numberBytesRequired)=0 |
This function will be called by the server when the client wants to transfer its DDOP to the server and needs to know if the server has enough memory available to store the DDOP. You should implement this function to return whether or not the server has enough memory available to store the DDOP. | |
virtual void | identify_task_controller (std::uint8_t taskControllerNumber)=0 |
This function will be called if someone requests that the TC identify itself. If this gets called, you should display the TC number for 3 seconds if your TC has a visual interface. | |
virtual void | on_client_timeout (std::shared_ptr< ControlFunction > clientControlFunction)=0 |
This function will be called by the server when a connected client times out. You should implement this function to do whatever you want to do when a client times out. Generally this means you will want to also deactivate the DDOP for that client. | |
virtual void | on_process_data_acknowledge (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint8_t errorCodesFromClient, ProcessDataCommands processDataCommand)=0 |
This function will be called by the server when a client sends an acknowledgement for a process data command that was sent to it. This can be useful to know if the client received the command or not when using the set_value_and_acknowledge command. | |
virtual bool | on_value_command (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::int32_t processDataValue, std::uint8_t &errorCodes)=0 |
This function will be called by the server when a client sends a value command to the TC. You should implement this function to do whatever you want to do when a client sends a value command. This could be anything from setting a value in your program, to sending a command to a connected implement. The client could be telling you that a section's state changed, or that a boom's position changed, etc. Therefore this is probably the most important function to implement to get your TC "working". Use the ISOBUS data dictionary to determine what the dataDescriptionIndex and elementNumber mean. | |
virtual bool | store_device_descriptor_object_pool (std::shared_ptr< ControlFunction > clientControlFunction, const std::vector< std::uint8_t > &objectPoolData, bool appendToPool)=0 |
This function is called when the server wants you to save a DDOP to non volatile memory (NVM). You should implement this function to save the DDOP to NVM. If appendToPool is true, you should append the DDOP to the existing DDOP in NVM. | |
bool | send_request_value (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber) const |
Sends a request to a client for an element's value of a particular DDI. | |
bool | send_time_interval_measurement_command (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t timeInterval) const |
Sends a time interval measurement command. The process data value for this command is the time interval for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL cyclic with this time interval. | |
bool | send_distance_interval_measurement_command (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t distanceInterval) const |
Sends a distance interval measurement command. The process data value for this command is the distance interval for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL cyclic with this distance interval. | |
bool | send_minimum_threshold_measurement_command (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t minimum) const |
Sends a minimum threshold measurement command. The process data value for this command is the minimum threshold for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL when the value is higher than the threshold value. | |
bool | send_maximum_threshold_measurement_command (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t maximum) const |
Sends a maximum threshold measurement command. The process data value for this command is the maximum threshold for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL when the value is lower than the threshold value. | |
bool | send_change_threshold_measurement_command (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t threshold) const |
Sends a change threshold measurement command. The process data value for this command is the change threshold for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL when the value change is higher than or equal to the change threshold since last transmission. | |
bool | send_set_value_and_acknowledge (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t processDataValue) const |
Sends a set value and acknowledge command. This command is used to set the value of a process data entity and request a reception acknowledgement from the recipient. The set value command process data value is the value of the data entity specified by the data dictionary identifier. | |
bool | send_set_value (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t processDataValue) const |
Sends a set value command without requesting an acknowledgement. This command is used to set the value of a process data entity. The set value command process data value is the value of the data entity specified by the data dictionary identifier. | |
void | set_task_totals_active (bool isTaskActive) |
Use this to set the reported task state in the status message. Basically, this should be set to true when the user starts a job, and false when the user stops a job. | |
bool | get_task_totals_active () const |
Returns whether a task is currently active or not. | |
LanguageCommandInterface & | get_language_command_interface () |
Returns the language command interface used to communicate with the client which language/units are in use. The language command is very important for the TC to function correctly, so it is recommended that you call this function and configure the language command interface before calling initialize(). | |
std::condition_variable & | get_condition_variable () |
Returns a condition variable which you can optionally use to wake up your server's thread when messages are received from the client. | |
void | initialize () |
Initializes the task controller server. | |
bool | get_initialized () const |
Returns whether or not the task controller server has been initialized. | |
void | terminate () |
Shuts down the TC server, unregisters PGN callbacks. | |
void | update () |
This must be called periodically for the interface to operate correctly. | |
Protected Types | |
enum class | ServerStatusBit : std::uint8_t { TaskTotalsActive = 0x01 , BusySavingDataToNVM = 0x02 , BusyReadingDataFromNVM = 0x04 , BusyExecutingACommand = 0x08 , OutOfMemory = 0x80 } |
Enumerates the different status bits that can be sent in the status message. More... | |
enum class | TechnicalDataCommandParameters : std::uint8_t { RequestVersion = 0x00 , ParameterVersion = 0x01 , IdentifyTaskController = 0x02 } |
Enumerates the subcommands for determining the technical capabilities of a TC, DL, or client. More... | |
enum class | DeviceDescriptorCommandParameters : std::uint8_t { RequestStructureLabel = 0x00 , StructureLabel = 0x01 , RequestLocalizationLabel = 0x02 , LocalizationLabel = 0x03 , RequestObjectPoolTransfer = 0x04 , RequestObjectPoolTransferResponse = 0x05 , ObjectPoolTransfer = 0x06 , ObjectPoolTransferResponse = 0x07 , ObjectPoolActivateDeactivate = 0x08 , ObjectPoolActivateDeactivateResponse = 0x09 , DeleteObjectPool = 0x0A , DeleteObjectPoolResponse = 0x0B , ChangeDesignator = 0x0C , ChangeDesignatorResponse = 0x0D } |
Enumerates subcommands for the transfer and management of device descriptors. These device descriptor messages are defined in ISO11783-10 B.6. More... | |
Protected Member Functions | |
void | process_rx_messages () |
Processes messages received from task controller clients. | |
bool | send_generic_process_data_default_payload (std::uint8_t multiplexer, std::shared_ptr< ControlFunction > destination) const |
This sends a process data message with all FFs in the payload except for the command byte. Useful for avoiding a lot of boilerplate code when sending process data messages. | |
bool | send_measurement_command (std::shared_ptr< ControlFunction > clientControlFunction, std::uint8_t commandValue, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t processDataValue) const |
Sends a measurement command to the client. | |
bool | send_status_message () const |
Sends a status message broadcast. | |
bool | send_version (std::shared_ptr< ControlFunction > clientControlFunction) const |
Sends the version message to a client. | |
std::shared_ptr< ActiveClient > | get_active_client (std::shared_ptr< ControlFunction > clientControlFunction) const |
Checks to see if we are communicating with a control function that is already in our list of active clients. If we are, it returns a pointer to our active client object for that control function. | |
bool | nack_process_data_command (std::shared_ptr< ControlFunction > clientControlFunction) const |
Sends a negative acknowledge for a the process data PGN which indicates to clients that we aren't listening to them because they aren't following the protocol. | |
bool | send_structure_label (std::shared_ptr< ControlFunction > clientControlFunction, std::vector< std::uint8_t > &structureLabel, const std::vector< std::uint8_t > &extendedStructureLabel) const |
Sends a response to a request structure label command. | |
bool | send_localization_label (std::shared_ptr< ControlFunction > clientControlFunction, const std::array< std::uint8_t, 7 > &localizationLabel) const |
Sends a response to a request localization label command. | |
bool | send_request_object_pool_transfer_response (std::shared_ptr< ControlFunction > clientControlFunction, bool isEnoughMemory) const |
Sends a response to a request object pool transfer command. | |
bool | send_object_pool_transfer_response (std::shared_ptr< ControlFunction > clientControlFunction, std::uint8_t errorBitfield, std::uint32_t sizeBytes) const |
Sends a response to an object pool transfer. | |
bool | send_object_pool_activate_deactivate_response (std::shared_ptr< ControlFunction > clientControlFunction, std::uint8_t activationErrorBitfield, std::uint8_t objectPoolErrorBitfield, std::uint16_t parentOfFaultingObject, std::uint16_t faultingObject) const |
Sends a response to an object pool activate/deactivate command. | |
bool | send_delete_object_pool_response (std::shared_ptr< ControlFunction > clientControlFunction, bool deletionResult, std::uint8_t errorCode) const |
Sends a response to a delete object pool command. | |
bool | send_change_designator_response (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t objectID, std::uint8_t errorCode) const |
Sends a response to a change designator command. | |
bool | send_process_data_acknowledge (std::shared_ptr< ControlFunction > clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint8_t errorBitfield, ProcessDataCommands processDataCommand) const |
Sends a process data acknowledge message to the client. | |
bool | send_process_data_to_client (std::shared_ptr< ControlFunction > clientControlFunction, const std::uint8_t *dataBuffer, std::uint32_t dataLength, CANIdentifier::CANPriority priority=CANIdentifier::CANPriority::Priority5) const |
Sends a process data message to a client with a slightly shorter signature than calling send_can_message. | |
Static Protected Member Functions | |
static void | store_rx_message (const CANMessage &message, void *parentPointer) |
Stores messages received from task controller clients for processing later. | |
Protected Attributes | |
LanguageCommandInterface | languageCommandInterface |
The language command interface used to communicate with the client which language/units are in use. | |
std::shared_ptr< InternalControlFunction > | serverControlFunction |
The control function used to communicate with the clients. | |
std::deque< CANMessage > | rxMessageQueue |
A queue of messages received from the clients which will be processed when update is called. | |
std::deque< std::shared_ptr< ActiveClient > > | activeClients |
A list of clients that are currently being communicated with. | |
std::condition_variable | updateWakeupCondition |
A condition variable you can optionally use to update the interface when messages are received. | |
std::mutex | messagesMutex |
A mutex used to protect the rxMessageQueue. | |
std::uint32_t | lastStatusMessageTimestamp_ms = 0 |
The timestamp of the last status message sent on the bus. | |
const TaskControllerVersion | reportedVersion |
The version of the TC that will be reported to the clients. | |
const std::uint8_t | numberBoomsSupportedToReport |
The number of booms that will be reported as supported by the TC. | |
const std::uint8_t | numberSectionsSupportedToReport |
The number of sections that will be reported as supported by the TC. | |
const std::uint8_t | numberChannelsSupportedForPositionBasedControlToReport |
The number of channels that will be reported as supported by the TC. | |
const std::uint8_t | optionsBitfieldToReport |
The options bitfield that will be reported as supported by the TC. | |
std::uint8_t | currentStatusByte = 0 |
The current status byte to send in the status message. | |
std::uint8_t | currentCommandByte = 0 |
The current command byte to send in the status message. | |
std::uint8_t | currentCommandSourceAddress = NULL_CAN_ADDRESS |
The current command source address to send in the status message. | |
bool | initialized = false |
Whether or not the task controller server has been initialized. | |
Static Protected Attributes | |
static constexpr std::uint32_t | STATUS_MESSAGE_RATE_MS = 2000 |
The rate at which status messages are sent to the clients in milliseconds. | |
An ISO11783-10 task controller (or data logger) server. A task controller collects task data from connected implements, and optionally controls them. This interface supports the CAN layer of TC-SC, TC-GEO, and TC-BAS.
Definition at line 26 of file isobus_task_controller_server.hpp.
|
strongprotected |
Enumerates subcommands for the transfer and management of device descriptors. These device descriptor messages are defined in ISO11783-10 B.6.
Definition at line 401 of file isobus_task_controller_server.hpp.
|
strong |
Enumerates the different error codes that can be returned when activating a device descriptor object pool.
Definition at line 31 of file isobus_task_controller_server.hpp.
|
strong |
Enumerates the different error codes that can be returned when deleting a device descriptor object pool.
Definition at line 42 of file isobus_task_controller_server.hpp.
|
strong |
Enumerates the different error codes that can be returned when processing a DDOP.
Definition at line 50 of file isobus_task_controller_server.hpp.
|
strong |
Enumerates all PDACK error codes that can be sent to or from the client.
Definition at line 97 of file isobus_task_controller_server.hpp.
|
strong |
Enumerates the different process data commands that can be sent to the client.
Definition at line 60 of file isobus_task_controller_server.hpp.
|
strong |
Enumerates the different options that can be reported by the server. Each option is a bit in a bitfield, with 1 meaning the option is supported and 0 meaning it is not. For example, if the server supports documentation and peer control assignment, but not the other options, the bitfield would be 0b00001001.
Definition at line 84 of file isobus_task_controller_server.hpp.
|
strongprotected |
Enumerates the different status bits that can be sent in the status message.
Definition at line 382 of file isobus_task_controller_server.hpp.
|
strong |
Enumerates the different versions of the task controller standard.
Definition at line 110 of file isobus_task_controller_server.hpp.
|
strongprotected |
Enumerates the subcommands for determining the technical capabilities of a TC, DL, or client.
Definition at line 392 of file isobus_task_controller_server.hpp.
isobus::TaskControllerServer::TaskControllerServer | ( | std::shared_ptr< InternalControlFunction > | internalControlFunction, |
std::uint8_t | numberBoomsSupported, | ||
std::uint8_t | numberSectionsSupported, | ||
std::uint8_t | numberChannelsSupportedForPositionBasedControl, | ||
const TaskControllerOptions & | options, | ||
TaskControllerVersion | versionToReport = TaskControllerVersion::SecondPublishedEdition ) |
Constructor for a TC server.
[in] | internalControlFunction | The control function to use to communicate with the clients. |
[in] | numberBoomsSupported | The number of booms to report as supported by the TC. |
[in] | numberSectionsSupported | The number of sections to report as supported by the TC. |
[in] | numberChannelsSupportedForPositionBasedControl | The number of channels to report as supported by the TC. |
[in] | options | The options to report as supported by the TC. See the TaskControllerOptions object for more info. |
[in] | versionToReport | The version of the task controller standard to report as supported by the TC. Generally you should leave this as 4 (SecondPublishedEdition). |
Definition at line 22 of file isobus_task_controller_server.cpp.
|
virtual |
Destructor for a TC server.
Definition at line 38 of file isobus_task_controller_server.cpp.
|
pure virtual |
This function will be called by the server when the client wants to activate its DDOP. You should implement this function to activate the DDOP and return whether or not it was successful. Generally this means that you will want to parse the pool, and make sure its schema is valid at this time. You can use our DeviceDescriptorObjectPool class to help you with this.
[in] | clientControlFunction | The control function which is requesting the activation. |
[out] | activationError | The error code to return if the activation fails. |
[out] | objectPoolError | This error code tells the client if there was an error in the DDOP. |
[out] | parentObjectIDOfFaultyObject | If there was an error in the DDOP, this is the parent object ID of the object that caused the error. Otherwise you should return 0xFFFF |
[out] | faultyObjectID | If there was an error in the DDOP, this is the object ID of the object that caused the error. Otherwise you should return 0xFFFF |
|
pure virtual |
This function will be called by the server when the client wants to change the designator of an object. This could be called because the client wants to change the name of an implement, or the name of a section, or change the active language being used in the DDOP's designators. You should implement this function to change the designator of the object and return whether or not it was successful.
[in] | clientControlFunction | The control function which is requesting the designator change. |
[in] | objectIDToAlter | The object ID of the object to change the designator of. |
[in] | designator | The new designator to set for the object. |
|
pure virtual |
This function will be called by the server when the client wants to deactivate its DDOP. You should implement this function to deactivate the DDOP and return whether or not it was successful.
[in] | clientControlFunction | The control function which is requesting the deactivation. |
|
pure virtual |
This function will be called by the server when the client wants to delete its DDOP. Each client is allowed to have one DDOP, so deletion is not required, but a client might be kind and delete its DDOP when it is no longer needed. You should implement this function to delete the DDOP and return whether or not it was successful.
[in] | clientControlFunction | The control function which is requesting the deletion. |
[out] | returnedErrorCode | The error code to return if the deletion fails. |
|
protected |
Checks to see if we are communicating with a control function that is already in our list of active clients. If we are, it returns a pointer to our active client object for that control function.
[in] | clientControlFunction | The control function to check for. |
Definition at line 805 of file isobus_task_controller_server.cpp.
std::condition_variable & isobus::TaskControllerServer::get_condition_variable | ( | ) |
Returns a condition variable which you can optionally use to wake up your server's thread when messages are received from the client.
Definition at line 144 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::get_initialized | ( | ) | const |
Returns whether or not the task controller server has been initialized.
Definition at line 123 of file isobus_task_controller_server.cpp.
|
pure virtual |
This function will be called by the server when the client wants to transfer its DDOP to the server and needs to know if the server has enough memory available to store the DDOP. You should implement this function to return whether or not the server has enough memory available to store the DDOP.
[in] | numberBytesRequired | The number of bytes required to store the DDOP. |
|
pure virtual |
This function will be called by the server when the server needs to know if it has previously saved to non volatile memory (NVM) a DDOP which is identified by the provided localization label. You should implement this function to return whether or not the DDOP is stored in NVM.
[in] | clientControlFunction | The control function which is requesting the information. |
[in] | localizationLabel | The localization label of the DDOP to check for. |
|
pure virtual |
This function will be called by the server when the server needs to know if it has previously saved to non volatile memory (NVM) a DDOP which is identified by the provided structure label, and optionally also the provided extended structure label. You should implement this function to return whether or not the DDOP is stored in NVM.
[in] | clientControlFunction | The control function which is requesting the information. |
[in] | structureLabel | The structure label of the DDOP to check for. (always 7 bytes) |
[in] | extendedStructureLabel | The extended structure label of the DDOP to check for. (up to 32 bytes) |
LanguageCommandInterface & isobus::TaskControllerServer::get_language_command_interface | ( | ) |
Returns the language command interface used to communicate with the client which language/units are in use. The language command is very important for the TC to function correctly, so it is recommended that you call this function and configure the language command interface before calling initialize().
Definition at line 138 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::get_task_totals_active | ( | ) | const |
Returns whether a task is currently active or not.
Definition at line 106 of file isobus_task_controller_server.cpp.
|
pure virtual |
This function will be called if someone requests that the TC identify itself. If this gets called, you should display the TC number for 3 seconds if your TC has a visual interface.
[in] | taskControllerNumber | The task controller number to display. |
void isobus::TaskControllerServer::initialize | ( | ) |
Initializes the task controller server.
Definition at line 111 of file isobus_task_controller_server.cpp.
|
protected |
Sends a negative acknowledge for a the process data PGN which indicates to clients that we aren't listening to them because they aren't following the protocol.
[in] | clientControlFunction | The control function to send the message to |
Definition at line 821 of file isobus_task_controller_server.cpp.
|
pure virtual |
This function will be called by the server when a connected client times out. You should implement this function to do whatever you want to do when a client times out. Generally this means you will want to also deactivate the DDOP for that client.
[in] | clientControlFunction | The control function which timed out. |
|
pure virtual |
This function will be called by the server when a client sends an acknowledgement for a process data command that was sent to it. This can be useful to know if the client received the command or not when using the set_value_and_acknowledge command.
[in] | clientControlFunction | The control function which sent the acknowledgement. |
[in] | dataDescriptionIndex | The data description index of the data element that was acknowledged. |
[in] | elementNumber | The element number of the data element that was acknowledged. |
[in] | errorCodesFromClient | The error codes that the client sent in the acknowledgement. This will be a bitfield defined by the ProcessDataAcknowledgeErrorCodes enum. |
[in] | processDataCommand | The process data command that was acknowledged. |
|
pure virtual |
This function will be called by the server when a client sends a value command to the TC. You should implement this function to do whatever you want to do when a client sends a value command. This could be anything from setting a value in your program, to sending a command to a connected implement. The client could be telling you that a section's state changed, or that a boom's position changed, etc. Therefore this is probably the most important function to implement to get your TC "working". Use the ISOBUS data dictionary to determine what the dataDescriptionIndex and elementNumber mean.
[in] | clientControlFunction | The control function which sent the value command. |
[in] | dataDescriptionIndex | The data description index of the data element that was sent. |
[in] | elementNumber | The element number of the data element that was sent. |
[in] | processDataValue | The process data value that was sent. |
[out] | errorCodes | You should return any errors that occurred while processing the value command in this variable as defined by the ProcessDataAcknowledgeErrorCodes enum. This will be sent back to the client if an acknowledgement is requested. |
|
protected |
Processes messages received from task controller clients.
This is called by update() and processes messages that were received from clients. Because update is called by your application, this means that messages are processed on your application's thread, rather than on the CAN stack's thread, which avoids a bunch of mutexing in your app. You can get a condition variable from get_condition_variable() which you can use to wake up your application's thread to process messages if you want to avoid polling the interface at a high rate.
Definition at line 195 of file isobus_task_controller_server.cpp.
|
protected |
Sends a response to a change designator command.
[in] | clientControlFunction | The control function to send the message to |
[in] | objectID | The object ID that was changed |
[in] | errorCode | The error code to send |
Definition at line 999 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_change_threshold_measurement_command | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber, | ||
std::uint32_t | threshold ) const |
Sends a change threshold measurement command. The process data value for this command is the change threshold for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL when the value change is higher than or equal to the change threshold since last transmission.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | threshold | The change threshold for sending the data element specified by the data dictionary identifier. |
Definition at line 81 of file isobus_task_controller_server.cpp.
|
protected |
Sends a response to a delete object pool command.
[in] | clientControlFunction | The control function to send the message to |
[in] | deletionResult | Whether or not the object pool was deleted |
[in] | errorCode | The error code to send |
Definition at line 976 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_distance_interval_measurement_command | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber, | ||
std::uint32_t | distanceInterval ) const |
Sends a distance interval measurement command. The process data value for this command is the distance interval for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL cyclic with this distance interval.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | distanceInterval | The distance interval for sending the data element specified by the data dictionary identifier. |
Definition at line 66 of file isobus_task_controller_server.cpp.
|
protected |
This sends a process data message with all FFs in the payload except for the command byte. Useful for avoiding a lot of boilerplate code when sending process data messages.
[in] | multiplexer | The multiplexer value to send in the message. |
[in] | destination | The control function to send the message to. |
Definition at line 713 of file isobus_task_controller_server.cpp.
|
protected |
Sends a response to a request localization label command.
[in] | clientControlFunction | The control function to send the message to |
[in] | localizationLabel | The localization label to send |
Definition at line 877 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_maximum_threshold_measurement_command | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber, | ||
std::uint32_t | maximum ) const |
Sends a maximum threshold measurement command. The process data value for this command is the maximum threshold for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL when the value is lower than the threshold value.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | maximum | The maximum threshold for sending the data element specified by the data dictionary identifier. |
Definition at line 76 of file isobus_task_controller_server.cpp.
|
protected |
Sends a measurement command to the client.
[in] | clientControlFunction | The control function to send the message to |
[in] | commandValue | The command value to send |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | processDataValue | The process data value to send |
Definition at line 744 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_minimum_threshold_measurement_command | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber, | ||
std::uint32_t | minimum ) const |
Sends a minimum threshold measurement command. The process data value for this command is the minimum threshold for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL when the value is higher than the threshold value.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | minimum | The minimum threshold for sending the data element specified by the data dictionary identifier. |
Definition at line 71 of file isobus_task_controller_server.cpp.
|
protected |
Sends a response to an object pool activate/deactivate command.
[in] | clientControlFunction | The control function to send the message to |
[in] | activationErrorBitfield | The error bitfield to send for the activation |
[in] | objectPoolErrorBitfield | The error bitfield to send for the object pool |
[in] | parentOfFaultingObject | The parent of the object that caused the error (or 0xFFFF if there is no error or it's unknown) |
[in] | faultingObject | The object that caused the error (or 0xFFFF if there is no error or it's unknown) |
Definition at line 949 of file isobus_task_controller_server.cpp.
|
protected |
Sends a response to an object pool transfer.
[in] | clientControlFunction | The control function to send the message to |
[in] | errorBitfield | The error bitfield to send |
[in] | sizeBytes | The size of the object pool in bytes |
Definition at line 925 of file isobus_task_controller_server.cpp.
|
protected |
Sends a process data acknowledge message to the client.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element that was acknowledged. |
[in] | elementNumber | The element number of the data element that was acknowledged. |
[in] | errorBitfield | The error bitfield to send (see ProcessDataAcknowledgeErrorCodes enum) |
[in] | processDataCommand | The process data command that was acknowledged. (or 0x0F if N/A) |
Definition at line 1022 of file isobus_task_controller_server.cpp.
|
protected |
Sends a process data message to a client with a slightly shorter signature than calling send_can_message.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataBuffer | The data to send |
[in] | dataLength | The data buffer length |
[in] | priority | The priority of the message, normally 5 |
Definition at line 1046 of file isobus_task_controller_server.cpp.
|
protected |
Sends a response to a request object pool transfer command.
[in] | clientControlFunction | The control function to send the message to |
[in] | isEnoughMemory | Whether or not there is enough memory available to transfer the object pool. |
Definition at line 901 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_request_value | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber ) const |
Sends a request to a client for an element's value of a particular DDI.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The Data Description Index being requested |
[in] | elementNumber | The element number being requested |
Definition at line 43 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_set_value | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber, | ||
std::uint32_t | processDataValue ) const |
Sends a set value command without requesting an acknowledgement. This command is used to set the value of a process data entity. The set value command process data value is the value of the data entity specified by the data dictionary identifier.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | processDataValue | The process data value to send |
Definition at line 91 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_set_value_and_acknowledge | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber, | ||
std::uint32_t | processDataValue ) const |
Sends a set value and acknowledge command. This command is used to set the value of a process data entity and request a reception acknowledgement from the recipient. The set value command process data value is the value of the data entity specified by the data dictionary identifier.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | processDataValue | The process data value to send |
Definition at line 86 of file isobus_task_controller_server.cpp.
|
protected |
Sends a status message broadcast.
Definition at line 769 of file isobus_task_controller_server.cpp.
|
protected |
Sends a response to a request structure label command.
[in] | clientControlFunction | The control function to send the message to |
[in] | structureLabel | The structure label to send |
[in] | extendedStructureLabel | The extended structure label to send |
Definition at line 848 of file isobus_task_controller_server.cpp.
bool isobus::TaskControllerServer::send_time_interval_measurement_command | ( | std::shared_ptr< ControlFunction > | clientControlFunction, |
std::uint16_t | dataDescriptionIndex, | ||
std::uint16_t | elementNumber, | ||
std::uint32_t | timeInterval ) const |
Sends a time interval measurement command. The process data value for this command is the time interval for sending the data element specified by the data dictionary identifier.The client has to send the value of this data element to the TC or DL cyclic with this time interval.
[in] | clientControlFunction | The control function to send the message to |
[in] | dataDescriptionIndex | The data description index of the data element to send the command for |
[in] | elementNumber | The element number of the data element to send the command for |
[in] | timeInterval | The time interval for sending the data element specified by the data dictionary identifier. |
Definition at line 61 of file isobus_task_controller_server.cpp.
|
protected |
Sends the version message to a client.
[in] | clientControlFunction | The control function to send the message to |
Definition at line 788 of file isobus_task_controller_server.cpp.
void isobus::TaskControllerServer::set_task_totals_active | ( | bool | isTaskActive | ) |
Use this to set the reported task state in the status message. Basically, this should be set to true when the user starts a job, and false when the user stops a job.
[in] | isTaskActive | Whether a task is currently active or not. |
Definition at line 96 of file isobus_task_controller_server.cpp.
|
pure virtual |
This function is called when the server wants you to save a DDOP to non volatile memory (NVM). You should implement this function to save the DDOP to NVM. If appendToPool is true, you should append the DDOP to the existing DDOP in NVM.
[in] | clientControlFunction | The control function which is requesting the save. |
[in] | objectPoolData | The DDOP itself as a binary blob. |
[in] | appendToPool | Whether or not to append the DDOP to the existing DDOP in NVM, or overwrite it. |
|
staticprotected |
Stores messages received from task controller clients for processing later.
This is used to avoid processing messages on the CAN stack's thread. Messages are actually processed in process_rx_messages which is called by update(). Because update is called by your application, this means that messages are processed on your application's thread, which avoids a bunch of mutexing in your app.
[in] | message | The message received from the client. |
[in] | parentPointer | A context variable that can be used to find this class's instance. |
Definition at line 180 of file isobus_task_controller_server.cpp.
void isobus::TaskControllerServer::terminate | ( | ) |
Shuts down the TC server, unregisters PGN callbacks.
Definition at line 128 of file isobus_task_controller_server.cpp.
void isobus::TaskControllerServer::update | ( | ) |
This must be called periodically for the interface to operate correctly.
This function must be called periodically. You have some choices on how to do this: First, you could poll it at a high rate in your main thread, at least 2-3x as fast as your fastest triggered message. Second, you could call it at a slower rate (something like 250-500 ms), and update it when the condition variable is notified. You can get the condition variable by calling get_condition_variable() if threading is enabled in the CAN stack. Third, you could run this in a separate thread, but again, you should call it at least 2-3x as fast as your fastest triggered message. Calling this often ensures timed out clients are pruned, and messages are processed in a timely fashion, which is important for the TC to function correctly and for agronomic/implement performance.
Definition at line 150 of file isobus_task_controller_server.cpp.
|
protected |
A list of clients that are currently being communicated with.
Definition at line 566 of file isobus_task_controller_server.hpp.
|
protected |
The current command byte to send in the status message.
Definition at line 578 of file isobus_task_controller_server.hpp.
|
protected |
The current command source address to send in the status message.
Definition at line 579 of file isobus_task_controller_server.hpp.
|
protected |
The current status byte to send in the status message.
Definition at line 577 of file isobus_task_controller_server.hpp.
|
protected |
Whether or not the task controller server has been initialized.
Definition at line 580 of file isobus_task_controller_server.hpp.
|
protected |
The language command interface used to communicate with the client which language/units are in use.
Definition at line 563 of file isobus_task_controller_server.hpp.
|
protected |
The timestamp of the last status message sent on the bus.
Definition at line 571 of file isobus_task_controller_server.hpp.
|
protected |
A mutex used to protect the rxMessageQueue.
Definition at line 569 of file isobus_task_controller_server.hpp.
|
protected |
The number of booms that will be reported as supported by the TC.
Definition at line 573 of file isobus_task_controller_server.hpp.
|
protected |
The number of channels that will be reported as supported by the TC.
Definition at line 575 of file isobus_task_controller_server.hpp.
|
protected |
The number of sections that will be reported as supported by the TC.
Definition at line 574 of file isobus_task_controller_server.hpp.
|
protected |
The options bitfield that will be reported as supported by the TC.
Definition at line 576 of file isobus_task_controller_server.hpp.
|
protected |
The version of the TC that will be reported to the clients.
Definition at line 572 of file isobus_task_controller_server.hpp.
|
protected |
A queue of messages received from the clients which will be processed when update is called.
Definition at line 565 of file isobus_task_controller_server.hpp.
|
protected |
The control function used to communicate with the clients.
Definition at line 564 of file isobus_task_controller_server.hpp.
|
staticconstexprprotected |
The rate at which status messages are sent to the clients in milliseconds.
Definition at line 561 of file isobus_task_controller_server.hpp.
|
protected |
A condition variable you can optionally use to update the interface when messages are received.
Definition at line 568 of file isobus_task_controller_server.hpp.