Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Developing Server-Side Operations

NI InsightCM™ SDK Help

Edition Date: July 2017

Part Number: 375191C-01

»View Product Info
Download Help (Windows Only)

The provided ExampleServiceApp project located at <InstallDir>:\Program Files (x86)\National Instruments\LabVIEW\examples\InsightCM\ExampleServiceApp models the creation of a new C# service named CsharpExample. As this topic explains, the CsharpExample service demonstrates a typical pattern of interaction with the collection of other services that are running as part of InsightCM Server. The ExampleServiceApp project demonstrates how to build an executable that starts a service and then interacts with it.

Note  ExampleServiceApp.sln references InsightCM libraries located in <InstallDir>:\Program Files (x86)\National Instruments\LabVIEW\vi.lib\addons\InsightCM\Binaries\.

Routed and Non-Routed Messages

Services interact by sending each other routed messages, or by broadcasting messages without a specific endpoint. Services that are subscribed to a given broadcast message can receive a copy of the message and handle it appropriately without interfering with other subscribers. In this example project, the CsharpExample service registers the service for two external messages: TransConnectionStatusBroadcast and StorageFileAvailableBroadcast. The class then writes some of the message contents to the console when the messages are broadcast. The TransConnectionStatusBroadcast and StorageFileAvailableBroadcast messages are useful starting places for applications that modify a file after it is processed or execute a specific behavior when a device connects.

Callback Method

Services also declare a callback method that executes when the service receives a routed message. In the example project, the callback method logs to the console and executes a specific handler when the CsharpExample service receives the routed message called ServiceSendStringRoutedMessage.

Subscriber

Subscribers act as an additional endpoint that can handle messages independently from the class, which allows the service to act in parallel as opposed to the class processing incoming messages in serial. The example project creates a subscriber that is registered for ServiceSendStringRoutedMessage. The subscriber in the example project uses the same callback method as the class but also listens for ServiceSendStringRoutedMessage and executes if another service broadcasts that message. If the example project did not include a subscriber, the service would handle the ServiceSendStringRoutedMessage message only if it was routed. You can use subscribers to handle messages that are useful out of order. However, ensure that you consider how multithreaded execution might affect the service overall.

Using Methods in the ExampleServiceApp Project

The ExampleServiceApp project includes a collection of methods that interact with devices or other services supplied to demonstrate how to send and receive information for the rest of the system. You can reference these methods to find out how to send strings or binary data to other services or devices, and how to retrieve configuration information in the form of a synchronous message. For example, the RunCommand method handles different user inputs and interacts with the CsharpExample service accordingly. Use this method in conjunction with the ExampleServiceApp project as a starting point for extending server-side behavior by creating a service.


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit