10#ifndef ISOBUS_TASK_CONTROLLER_SERVER_HPP
11#define ISOBUS_TASK_CONTROLLER_SERVER_HPP
19#include <condition_variable>
34 ThereAreErrorsInTheDDOP = 0x01,
35 TaskControllerRanOutOfMemoryDuringActivation = 0x02,
37 DifferentDDOPExistsWithSameStructureLabel = 0x08
44 ObjectPoolIsReferencedByTaskData = 0,
45 ServerCannotCheckForObjectPoolReferences = 1,
46 ErrorDetailsNotAvailable = 0xFF
53 MethodOrAttributeNotSupported = 0x01,
54 UnknownObjectReference = 0x02,
56 DDOPWasDeletedFromVolatileMemory = 0x08
86 SupportsDocumentation = 0x01,
87 SupportsTCGEOWithoutPositionBasedControl = 0x02,
88 SupportsTCGEOWithPositionBasedControl = 0x04,
89 SupportsPeerControlAssignment = 0x08,
90 SupportsImplementSectionControl = 0x10,
91 ReservedOption1 = 0x20,
92 ReservedOption2 = 0x40,
93 ReservedOption3 = 0x80
99 ProcessDataCommandNotSupported = 0x01,
100 InvalidElementNumber = 0x02,
101 DDINotSupportedByElement = 0x04,
102 TriggerMethodNotSupported = 0x08,
103 ProcessDataNotSettable = 0x10,
104 InvalidOrUnsupportedIntervalOrThreshold = 0x20,
105 ProcessDataValueDoesNotConformToDDIDefinition = 0x40,
106 ProcessDataValueIsOutOfOperationalRangeOfThisDevice = 0x80
128 std::uint8_t numberBoomsSupported,
129 std::uint8_t numberSectionsSupported,
130 std::uint8_t numberChannelsSupportedForPositionBasedControl,
164 virtual bool change_designator(std::shared_ptr<ControlFunction> clientControlFunction, std::uint16_t objectIDToAlter,
const std::vector<std::uint8_t> &designator) = 0;
225 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;
240 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;
258 bool send_request_value(std::shared_ptr<ControlFunction> clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber)
const;
269 bool send_time_interval_measurement_command(std::shared_ptr<ControlFunction> clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t timeInterval)
const;
280 bool send_distance_interval_measurement_command(std::shared_ptr<ControlFunction> clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t distanceInterval)
const;
323 bool send_set_value_and_acknowledge(std::shared_ptr<ControlFunction> clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t processDataValue)
const;
333 bool send_set_value(std::shared_ptr<ControlFunction> clientControlFunction, std::uint16_t dataDescriptionIndex, std::uint16_t elementNumber, std::uint32_t processDataValue)
const;
351#if !defined CAN_STACK_DISABLE_THREADS && !defined ARDUINO
384 TaskTotalsActive = 0x01,
385 BusySavingDataToNVM = 0x02,
386 BusyReadingDataFromNVM = 0x04,
387 BusyExecutingACommand = 0x08,
394 RequestVersion = 0x00,
403 RequestStructureLabel = 0x00,
465 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;
474 bool send_version(std::shared_ptr<ControlFunction> clientControlFunction)
const;
480 std::shared_ptr<ActiveClient>
get_active_client(std::shared_ptr<ControlFunction> clientControlFunction)
const;
493 bool send_structure_label(std::shared_ptr<ControlFunction> clientControlFunction, std::vector<std::uint8_t> &structureLabel,
const std::vector<std::uint8_t> &extendedStructureLabel)
const;
499 bool send_localization_label(std::shared_ptr<ControlFunction> clientControlFunction,
const std::array<std::uint8_t, 7> &localizationLabel)
const;
522 std::uint8_t activationErrorBitfield,
523 std::uint8_t objectPoolErrorBitfield,
524 std::uint16_t parentOfFaultingObject,
525 std::uint16_t faultingObject)
const;
557 const std::uint8_t *dataBuffer,
558 std::uint32_t dataLength,
567#if !defined CAN_STACK_DISABLE_THREADS && !defined ARDUINO
General constants used throughout this library.
CANPriority
Defines all the CAN frame priorities that can be encoded in a frame ID.
@ Priority5
Priority highest - 5.
A class that represents a generic CAN message of arbitrary length.
An interface for requesting and parsing the ISO11783 language command PGN, 0xFE0F.
A helper class to assign TC server options. You can use this by doing something like this: TaskContro...
Stores information about a client that is currently being communicated with.
std::shared_ptr< ControlFunction > clientControlFunction
The control function used to communicate with the client.
ActiveClient(std::shared_ptr< ControlFunction > clientControlFunction)
Constructor for an active client object which stores information about a client that is currently bei...
std::uint32_t lastStatusMessageTimestamp_ms
The timestamp of the last status message sent to the client.
std::uint32_t clientDDOPsize_bytes
The size of the client's DDOP in bytes.
bool isDDOPActive
Whether or not the client's DDOP is active.
std::uint16_t numberOfObjectPoolSegments
The number of object pool segments that have been sent to the client.
std::uint32_t statusBitfield
The status bitfield that the client is reporting to us.
An ISO11783-10 task controller (or data logger) server. A task controller collects task data from con...
bool get_task_totals_active() const
Returns whether a task is currently active or not.
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...
std::uint32_t lastStatusMessageTimestamp_ms
The timestamp of the last status message sent on the bus.
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....
TaskControllerVersion
Enumerates the different versions of the task controller standard.
@ SecondPublishedEdition
The version of the second edition published as the final draft International Standard(E2....
@ FinalDraftInternationalStandardFirstEdition
The version of the FDIS.1 (final draft International Standard, first edition).
@ DraftInternationalStandard
The version of the DIS (draft International Standard).
@ SecondEditionDraft
The version of the second edition published as a draft International Standard(E2.DIS).
@ FirstPublishedEdition
The version of the FDIS.2 and the first edition published ss an International Standard.
virtual ~TaskControllerServer()
Destructor for a TC server.
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,...
std::condition_variable updateWakeupCondition
A condition variable you can optionally use to update the interface when messages are received.
const TaskControllerVersion reportedVersion
The version of the TC that will be reported to the clients.
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 c...
TechnicalDataCommandParameters
Enumerates the subcommands for determining the technical capabilities of a TC, DL,...
@ ParameterVersion
The Request Version message allows the TC, DL, and the client to determine the ISO 11783-10 version o...
@ IdentifyTaskController
The Version message is sent in response to the request version message and contains the ISO 11783-10 ...
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.
void terminate()
Shuts down the TC server, unregisters PGN callbacks.
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_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 valu...
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 distanc...
void process_rx_messages()
Processes messages received from task controller clients.
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 t...
ServerStatusBit
Enumerates the different status bits that can be sent in the status message.
void initialize()
Initializes the task controller server.
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 objec...
ProcessDataCommands
Enumerates the different process data commands that can be sent to the client.
@ MeasurementMaximumWithinThreshold
The client has to send the value of this data element to the TC or DL when the value is lower than th...
@ MeasurementMinimumWithinThreshold
The client has to send the value of this data element to the TC or DL when the value is higher than t...
@ DeviceDescriptor
Transfer and management of device descriptors.
@ Value
This command is used both to answer a request value command and to set the value of a process data en...
@ PeerControlAssignment
This message is used to establish a connection between a setpoint value source and a setpoint value u...
@ TechnicalCapabilities
Used for determining the technical capabilities of a TC, DL, or client.
@ MeasurementChangeThreshold
The client has to send the value of this data element to the TC or DL when the value change is higher...
@ RequestValue
Used when the value of the data entity specified by the data dictionary identifier is requested.
@ MeasurementTimeInterval
The process data value is the time interval for sending the data element specified by the data dictio...
@ MeasurementDistanceInterval
The process data value is the distance interval for sending the data element specified by the data di...
@ SetValueAndAcknowledge
This command is used to set the value of a process data entity and request a reception acknowledgemen...
@ ClientTask
Sent by the client as a status message every 2s.
@ Acknowledge
Message is a Process Data Acknowledge (PDACK).
@ Status
Message is a Task Controller Status message.
std::mutex messagesMutex
A mutex used to protect the rxMessageQueue.
std::uint8_t currentCommandSourceAddress
The current command source address to send in the status message.
std::deque< CANMessage > rxMessageQueue
A queue of messages received from the clients which will be processed when update is called.
bool send_status_message() const
Sends a status message broadcast.
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 a...
static void store_rx_message(const CANMessage &message, void *parentPointer)
Stores messages received from task controller clients for processing later.
void update()
This must be called periodically for the interface to operate correctly.
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 th...
ObjectPoolErrorCodes
Enumerates the different error codes that can be returned when processing a DDOP.
const std::uint8_t numberChannelsSupportedForPositionBasedControlToReport
The number of channels that will be reported as supported by the TC.
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 t...
LanguageCommandInterface & get_language_command_interface()
Returns the language command interface used to communicate with the client which language/units are i...
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 t...
const std::uint8_t numberSectionsSupportedToReport
The number of sections that will be reported as supported by the TC.
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 ...
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_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...
const std::uint8_t numberBoomsSupportedToReport
The number of booms that will be reported as supported by the TC.
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....
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.
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)....
TaskControllerServer(TaskControllerServer &)=delete
Deleted copy constructor.
LanguageCommandInterface languageCommandInterface
The language command interface used to communicate with the client which language/units are in use.
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....
TaskControllerServer & operator=(const TaskControllerServer &)=delete
Deleted assignment operator.
bool send_version(std::shared_ptr< ControlFunction > clientControlFunction) const
Sends the version message to a client.
std::deque< std::shared_ptr< ActiveClient > > activeClients
A list of clients that are currently being communicated with.
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.
ProcessDataAcknowledgeErrorCodes
Enumerates all PDACK error codes that can be sent to or from the client.
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 get_initialized() const
Returns whether or not the task controller server has been initialized.
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.
const std::uint8_t optionsBitfieldToReport
The options bitfield that will be reported as supported by the TC.
bool initialized
Whether or not the task controller server has been initialized.
std::condition_variable & get_condition_variable()
Returns a condition variable which you can optionally use to wake up your server's thread when messag...
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_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 en...
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.
static constexpr std::uint32_t STATUS_MESSAGE_RATE_MS
The rate at which status messages are sent to the clients in milliseconds.
DeviceDescriptorCommandParameters
Enumerates subcommands for the transfer and management of device descriptors. These device descriptor...
@ ObjectPoolTransferResponse
Enables the client to transfer (part of) the device descriptor object pool to the TC.
@ LocalizationLabel
Allows the client to determine the availability of the requested device descriptor localization.
@ ObjectPoolTransfer
Sent in response to Request Object-pool Transfer message.
@ DeleteObjectPoolResponse
This is a message to delete the device descriptor object pool for the client that sends this message.
@ DeleteObjectPool
Sent by a client to complete its connection procedure to a TC or DL or to disconnect from a TC or DL.
@ RequestLocalizationLabel
The Structure Label message is sent by the TC or DL to inform the client about the availability of th...
@ RequestObjectPoolTransfer
/// Sent by the TC or DL to inform the client about the availability of the requested localization ve...
@ RequestObjectPoolTransferResponse
/// The Request Object-pool Transfer message allows the client to determine whether it is allowed to ...
@ ObjectPoolActivateDeactivateResponse
Sent by a client to complete its connection procedure to a TC or DL or to disconnect from a TC or DL.
@ StructureLabel
Allows the client to determine the availability of the requested device descriptor structure.
@ ChangeDesignator
TC response to a Object-pool Delete message.
@ ObjectPoolActivateDeactivate
Response to an object pool transfer message.
@ ChangeDesignatorResponse
This message is used to update the designator of an object.
ObjectPoolDeletionErrors
Enumerates the different error codes that can be returned when deleting a device descriptor object po...
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 interv...
std::shared_ptr< InternalControlFunction > serverControlFunction
The control function used to communicate with the clients.
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....
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.
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 ...
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_mess...
ServerOptions
Enumerates the different options that can be reported by the server. Each option is a bit in a bitfie...
std::uint8_t currentCommandByte
The current command byte to send in the status message.
ObjectPoolActivationError
Enumerates the different error codes that can be returned when activating a device descriptor object ...
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 lis...
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....
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.
std::uint8_t currentStatusByte
The current status byte to send in the status message.
Defines a set of values found in the isobus language command message from ISO11783-7 commonly used in...
Defines a helper class to assign TC server options.
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...
constexpr std::uint8_t NULL_CAN_ADDRESS
The NULL CAN address defined by J1939 and ISO11783.