nativehost
Differences
This shows you the differences between two versions of the page.
| nativehost [2024/05/21 17:47] – created wikiadmin | nativehost [2024/05/21 17:55] (current) – wikiadmin | ||
|---|---|---|---|
| Line 168: | Line 168: | ||
| ===== Defining an SVIDRequest (S1F3) ===== | ===== Defining an SVIDRequest (S1F3) ===== | ||
| - | SVID request is much simpler; you publish a single value to " | + | SVID request is much simpler; you publish a single value to " |
| <code javascript> | <code javascript> | ||
| { | { | ||
| - | " | + | "SVID": { |
| - | " | + | " |
| + | |||
| + | " | ||
| + | | ||
| } | } | ||
| </ | </ | ||
| - | Notice again that the SVID must be a string, even though it has a numeric type. | + | Notice again that the " |
| + | |||
| + | Here is the end of the document converted into DokuWiki format: | ||
| ===== Subscribing to Topics ===== | ===== Subscribing to Topics ===== | ||
| Line 185: | Line 190: | ||
| <code cpp> | <code cpp> | ||
| // Subscribe to CEID events | // Subscribe to CEID events | ||
| + | wrapper-> | ||
| + | [](const char* topic, const transsecs:: | ||
| + | std::cout << " | ||
| + | std::cout << " | ||
| + | }); | ||
| + | |||
| + | // Subscribe to VID events | ||
| + | wrapper-> | ||
| + | [](const char* topic, the transsecs:: | ||
| + | std::cout << "LOTID received: " << value-> | ||
| + | }); | ||
| + | |||
| + | // Subscribe to control state updates | ||
| + | wrapper-> | ||
| + | [](const char* topic, the transsecs:: | ||
| + | std::cout << " | ||
| + | }); | ||
| + | </ | ||
| + | |||
| + | VID subscriptions will provide just the expected value. For example, the controlstate above might be called with a value with a long value of 5. | ||
| + | |||
| + | CEID subscriptions will provide a JSON object with the CEID and any associated reports. For example, the loaded subscription above Might return something like: | ||
| + | |||
| + | <code javascript> | ||
| + | { " | ||
| + | </ | ||
| + | |||
| + | ===== Defining Reports and Associating Them with CEIDs ===== | ||
| + | |||
| + | Reports can be defined and associated with CEIDs in the resulting JSON configuration. After characterizing the tool, the JSON configuration needs to be updated to include the report definitions and their associations. | ||
| + | |||
| + | Here is an excerpt of the JSON configuration before and after updating the RPTIDs: | ||
| + | |||
| + | ==== Before Updating RPTIDs: ==== | ||
| + | <code javascript> | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | // ... Other VIDs ... | ||
| + | ], | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | // ... Other CEIDs ... | ||
| + | ], | ||
| + | " | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== After Updating RPTIDs: ==== | ||
| + | <code javascript> | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | // ... Other VIDs ... | ||
| + | ], | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | // ... Other CEIDs ... | ||
| + | ], | ||
| + | " | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | In the initial characterized JSON, the rptids and ceids are not fully configured. In this example, CEID 7503 (LOADED) is associated with RPTID 80, which includes variables with IDs 33008 (CLOCK) and 1514 (LOTID). These will then be properly configured and linked when the new GEM model is set. | ||
| + | |||
| + | ===== Setting the GEM model ===== | ||
| + | |||
| + | The host's GEM model can be set from a JSON string. | ||
| + | |||
| + | <code cpp> | ||
| + | std:: | ||
| + | std::string gemModel((std:: | ||
| + | inputFile.close(); | ||
| + | |||
| + | wrapper-> | ||
| + | </ | ||
| + | |||
| + | ===== Full C++ Example ===== | ||
| + | |||
| + | Here is the complete C++ example combining all | ||
| + | |||
| + | the steps: | ||
| + | |||
| + | <code cpp> | ||
| + | #include < | ||
| + | #include " | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | int main(int argc, char **argv) { | ||
| + | transsecs:: | ||
| + | |||
| + | int port = 5010; | ||
| + | wrapper-> | ||
| + | wrapper-> | ||
| + | wrapper-> | ||
| + | wrapper-> | ||
| + | |||
| + | // For most cases, this should always be " | ||
| + | wrapper-> | ||
| + | |||
| + | // This section will characterize the tool and save the json to a file | ||
| + | // Characterizing the tool will cause the gem model to be overwritten, | ||
| + | |||
| + | std::string json = wrapper-> | ||
| + | std:: | ||
| + | outputFile << json; | ||
| + | outputFile.close(); | ||
| + | |||
| + | // Set the gem model to a prepared model for this example | ||
| + | std:: | ||
| + | std::string gemModel((std:: | ||
| + | inputFile.close(); | ||
| + | |||
| + | wrapper-> | ||
| + | |||
| + | // The ceid listener will receive a json string of any associated reports, as well as the ceid value | ||
| wrapper-> | wrapper-> | ||
| [](const char* topic, the transsecs:: | [](const char* topic, the transsecs:: | ||
| std::cout << " | std::cout << " | ||
| - | std::cout << " | + | std::cout << " |
| + | }); | ||
| + | // This listener will update with the values from lotid wherever it is received, for example in a report | ||
| + | wrapper-> | ||
| + | [](const char* topic, the transsecs:: | ||
| + | std::cout << "LOTID received: " << value-> | ||
| + | }); | ||
| + | |||
| + | // Can subscribe to any variable to receive updates. In this case, this will be triggered by an s1f3 we send in the main loop | ||
| + | wrapper-> | ||
| + | [](const char* topic, the transsecs:: | ||
| + | std::cout << " | ||
| + | }); | ||
| + | |||
| + | // Send an example s2f41 (host command). | ||
| + | std::string s2f41 = R" | ||
| + | wrapper-> | ||
| + | |||
| + | // Need to loop here because if the application exits, the wrapper will exit as well | ||
| + | while (true) { | ||
| + | std:: | ||
| + | // Send an example s1f3 (svid request) | ||
| + | // In this example 33003 is the controlstate SVID, so this will cause the listener above to print the received control state | ||
| + | wrapper-> | ||
| + | } | ||
| + | } | ||
| + | </ | ||
nativehost.1716328075.txt.gz · Last modified: by wikiadmin
