Public Responses
Worker APIs
Last updated
Worker APIs
Last updated
Send message to Caller from Worker
Asynchronous
rsp_
The images below are taken from the Workers Fundamentals example project.
A Public Response is a message that can be sent to a Caller from a Worker, however, the Caller must first register to receive the Response message from the Worker.
The image below demonstrates the use of a Public Response VI sending a message from a MHL case of Worker B to a MHL case of Worker A. Worker B doesn't know which case of the Caller the Response message will be sent to. It is up to the Caller, when initializing Worker B, to register the Response message, providing the Caller's MHL case that will receive the Response message to Worker B.
A Public Response VI is required to be wired in-line with a Worker's Main Data Wire, as shown in the block diagram image above. The Public Response VI will send a message to the Worker's Caller, IF the Caller has registered to receive the Response message.
Data that will be sent along with the message. By default, this is a typedef that has the same filename as the Public Response VI.
The priority of the message (default is Normal) can be set to either Low, Normal or High.
When this flag is TRUE, then meta-data about this message will be sent to the Workers Debug Server.
Every Public Response is created with a VTD VI. This VI is used by a Worker's Caller to convert the data sent with the Response message to its specific data type. This VI is placed in the registered Public Response MHL Case of the Caller.
Variant data that was sent along with the Response message.
The strictly typed data that was sent along with the response message. By default, this is a typedef that has the same filename as the Public Response VI.
Public Response typedefs are created with the same icon and filename as their matching Public Response VI. Their purpose is to provide a custom container (cluster) for the data that will be sent along with the message to the Public Response's registered MHL case of the Caller.
The MHL case that will receive a Public Response message exists in the Worker's Caller. A Caller must register to receive a Response message from a subWorker. The image below shows a MHL case in Worker A that will receive a Response message from Worker B. MHL cases that are created to receive a Response message will be added to the Worker's case structure section called --- RESPONSE CASES ---. To convert the data sent with the Response message to its specific data type, a Response VTD (Variant to Data) VI is used at the beginning of every registered Response MHL case.
Public Response VIs created by the Public API Builder tool are added to a Worker's Local API >> Responses folder. Their scope is set to protected because they are designed to be used only from within the Worker that owns them.
Public Response VTD VIs are added to a Worker's Public API >> Response VTDs folder. Their scope is set to public because they are designed to be used from a Worker's Caller.
A Public Response requires the name of the Caller's MHL case to be passed into the Worker through the Worker's Initialization Data.ctl. This process occurs when a Worker's Public Response is registered with the Worker's Caller.
Every time a new Public Response is created with the Public API Builder tool, a Case Label string control will be added automatically to the Worker's Response Cases.ctl typedef. The image below shows all of the Case Label string controls that have been added to a Worker's Response Cases.ctl typedef.
Every new Worker and Worker base class (Workers 5.0 onwards) wires a Worker's Response Cases.ctl from a Worker's Initialization Data.ctl typedef to the Response Cases.ctl contained within the Worker's Main Data Wire. Without this transfer of information to the Worker's Main Data Wire, the Public Response VIs won't have the required data to know which of the Caller's MHL cases to send the Public Response messages to.
Workers created in Workers 4.0 or before
The wiring shown in the <Initialize> MHL case above is automatically created for you in new Workers created in Workers 5.0. However if you are using Public Responses from a Worker created in Workers 4.0 or before, you will need to manually wire the Response Cases.ctl data into the Worker's Main Data Wire as shown in the image above.
Every Public Response VI filename takes the prefix: rsp_ (response). Every Public Response VI icon contains a pink glyph in its bottom-right corner. An example of a Public Response VI is shown below.
Every Public Response VTD VI filename takes the prefix: rspvtd_ (response variant to data). Every Public Response VTD VI icon contains a pink rectangular glyphin its bottom-right corner. An example of a Public Response VTD VI is shown below.