The documentation for the v1.x version of the API has been moved (Javascript API v1.x). All new code should use this v2.x API.



interface AnaAlarm {
  minimum: number;
  maximum: number;
  alarm_enable: boolean;
  alarm_status: boolean;
  abort: boolean;
  abort_inhibit: boolean;
  tries_needed: number;
  tries_now: number;

Represents the information associated with an analog alarm block reading. This object will be found using the data property of the DataReply object.


interface BasStatus {
  on?: boolean;
  ready?: boolean;
  remote?: boolean;
  positive?: boolean;
  ramp?: boolean;

Represents the information associated with a device's basic status property. This object is found using the data property of the DataReply object.

It should be noted that the DPM protocol for basic status information is going to change. The control system is moving towards a more expressive form for basic status and this interface isn't capable of representing it.


interface DataReply {
  ref_id: number;
  timestamp: number;
    | number
    | string
    | AnaAlarm
    | DigAlarm
    | BasStatus
    | Array<number>
    | Array<string>
    | ArrayBuffer;

The first parameter to the callback will receive an object with this interface. ref_id is a unique value that indicates with which request this reading is associated. The timestamp property represents the time the reading was taken and is in units of milliseconds since 1970. The data property holds the actual data reading and will be of the type that matches the request.





DPM Class

The DPM class manages communication with the Data Pool. The API is, to first order, the same as v1.x. The main difference is that these methods return promises which allows an application to do other things while the promises are waiting to resolve. It also allows errors to be reported to the application (the v1.x API didn't report errors when setting up the requests.) Lastly, this API removes the protocol compiler messages from the API and, instead, uses the interfaces described above to provide a more consistent form.

DPM(server?: string, conn?: ACNET)

Creates a new instance of a DPM object. Both arguments are optional and, if not provided, creates a DPM object that will create a new ACNET connection object and automatically choose an available DPM. The first parameter, if given, should be a string specifying the node name of the DPM to use. Note: choosing a DPM prevents the DPM object from automatically switching to a different DPM when the DPM in use goes away. The second parameter, if given, is an ACNET connection object to use for the communications.

addRequest(req: string, cb: (DataReply, DeviceInfo) => void, ecb?: DataStatus): Promise<void>

Stages a data acquisition request. The first parameter is a string containing a DRF2 request. The second parameter is a callback function which will get called as the data arrives. The third, optional parameter is a callback function that gets called when an error occurs that's associated with the DRF2 request. This function can be called many times to set up DRF2-to-callback mappings. start() must be called in order to start the actual data acquisition.

clear(): Promise<void>

Empties the list of requests. Currently running acquisition will continue until start() is called. This function can be used to remove unwanted requests before adding new acquisition requests.

start(redir?: string): Promise<void>

Starts data acquisition using the latest list of requests. The optional parameter specifies a redirection model to use. If omitted, data is obtained from the live control system.

stop(): Promise<void>

Stops data acquisition.