Access the Alarms & Events Web Service

The LabVIEW Datalogging and Supervisory Control (DSC) Module includes the built-in LabVIEW Web service, nialarm.

The nialarm web service exposes the Alarms & Events VIs: Read Alarms, Read Events, Acknowledge Alarms, and Alarm Status.

Specifying the URL

You use a URL and HTTP methods to interact with the nialarm web service. Refer to the following table to specify the URL pattern, which consists of the web method and tag URL, and input parameters of the URL. Input parameters and XML tags in post data are case sensitive.

Description URL pattern HTTP method Input parameters
Queries alarm information. alarms/<tag_URL> GET host=HOSTNAME (localhost)OUTPUT_FORMAT={XML, JSON} (XML)
Queries event information. events/<tag_URL> GET host=HOSTNAME (localhost)OUTPUT_FORMAT={XML, JSON} (XML)
Queries alarm and event information. all/<tag_URL> GET host=HOSTNAME (localhost)OUTPUT_FORMAT={XML, JSON} (XML)
Queries a summary of the alarms associated with shared variables. alarmstatus/<tag_URL> GET host=HOSTNAMEminPriority=MIN_NUM (0)maxPriority=MAX_NUM (1000)showAcked=BOOL(TRUE|FALSE) (FALSE)OUTPUT_FORMAT={XML, JSON} (XML)
Acknowledges alarms by shared variable. alarms/<tag_URL> POSTPost data:ackUser=ACKUSERcomment=TEXT host=HOSTNAME (localhost)
Acknowledges alarms by alarm. alarms POSTPost data:AlarmUrl=ALARMURL*ackUser=ACKUSERcomment=TEXT None
Acknowledges alarms by alarm area. alarms POSTPost data:alarmArea=AREATEXT*ackUser=ACKUSERcomment=TEXT None
Acknowledges events by shared variable. events/<tag_URL> POSTPost data:N/A host=HOSTNAME (localhost)
Acknowledges alarms and events by shared variable. all/<tag_URL> POSTPost data:ackUser=ACKUSERcomment=TEXT host=HOSTNAME (localhost)
Note The default value of an input parameter appears in parentheses. An asterisk (*) appears next to required parameters.

Specifying the Tag URL

When constructing a URL to interact with the nialarm web service, you can specify the tag URL in one of the following formats:

  • Relative—Specifies the relative URL format, where tag_URL is defined by library or library/variable and both the variable and the web service reside on the host computer. You also can use the host parameter to specify the name of the computer where the variable resides. By default, the host parameter specifies the computer where the web service resides.
  • Webservice—Specifies the webservice URL format, where tag_URL is defined by ni.var.psp/library or ni.var.psp/library/variable.
  • VariableAPI—Specifies the variableAPI URL format, where tag_URL is defined by ni.var.psp://computer/library or ni.var.psp://computer/library/variable.
  • The following table shows possible example URLs:

    Web methodExample URLDescription
    allhttp://localhost:3580/nialarm/all/library1/variable2HTTP method: POSTPost data: ackUser=operator1&comment=testInvokes the all Web method to acknowledge the alarms and events associated with the shared variable at \\localhost\library1\variable2. This example also specifies that the alarms and events are acknowledged by the user operator1 with a comment test.
    alarmshttp://localhost:3580/nialarm/alarms/library1/variable1?host=remote-computerFrom the local computer, invokes the alarms Web method to retrieve all alarms for a variable on a computer named remote-computer. By default, information returns as an XML-formatted response because the URL does not specify the output format.
    alarmstatushttp://localhost:3580/nialarm/alarmstatus?minPriority=100&maxPriority=1000Invokes the alarmstatus Web method to retrieve the summaries of alarms whose priority is between 100 and 1000. By default, information returns as an XML-formatted response because the URL does not specify the output format.
    alarmshttp://localhost:3580/nialarm/alarmsHTTP method: POSTPost data: AlarmUrl=\\server1\library1\variable1.Alarms.HiHi&AlarmUrl=\\server2\library2\variable2.Alarms.Hi&ackUser=operator1Invokes the alarms Web method to acknowledge alarms specified by the AlarmUrl tag in the post data. You can specify optional parameters, such as ackUser and comment, by delimiting these parameters with an ampersand (&). You can specify multiple alarms you want to acknowledge by delimiting them with an ampersand.
    eventshttp://localhost:3580/nialarm/events/library1/variable1HTTP method: POSTPost data: N/AInvokes the events Web method to acknowledge the events associated with the shared variable at \\localhost\library1\variable1.

    Configuring Remote Access

    You can configure the nialarm web service to query alarms and events that reside on the same computer as the web service or that reside on other computers. By default, the web service can query alarms and events on other computers. To query alarms and events on the same computer as the Web service only, specify RemoteSupport=[FALSE] in the [NI_AlarmEvent_WS] section of the web service configuration file. The web service configuration file is located in the C:\ProgramData\National Instruments\WebServices\NI\nialarm\WebServices.ini directory.