Fabian Märki eb1bdee425 Progress
2015-08-21 11:06:58 +02:00
2015-05-27 16:59:20 +02:00
2015-08-10 11:44:08 +02:00
2015-08-21 10:29:07 +02:00
2015-08-21 08:42:40 +02:00
2015-05-26 16:33:57 +02:00
2015-05-27 16:59:20 +02:00
2015-06-10 17:06:30 +02:00
2015-07-09 17:00:09 +02:00
2015-07-30 12:16:31 +02:00
2015-08-21 11:06:58 +02:00
2015-07-08 16:18:47 +02:00

#Overview

This project provides a REST interface to execute queries on the databuffer.

Requirements

This project requires Java 8 or greater.

Deployment

Use the instructions provided by ch.psi.daq.install to install the application on a server.

Application Properties

Following files define and describe application properties:

It is possible to overwrite properties by defining new values in ${HOME}/.config/daq/queryrest.properties

REST Interface

Query Channel Names

Request

POST http://<host>:<port>/channels

Data

{"regex": "TRFCA|TRFCB", "dbMode": "databuffer"}
Explanation

Example

curl -H "Content-Type: application/json" -X POST -d '{"regex": "TRFCA|TRFCB"}' http://sf-nube-14.psi.ch:8080/channels

Query Data

Request

GET http://<host>:<port>/query

Data

A request is performed using JSON. The JSON query defines the channels to be queried, the range, and how the data should be aggregated (this is optional but highly recommended).

There exist following fields:

Example

curl -H "Content-Type: application/json" -X POST -d '{"channels":["channel1","channel2"],"startPulseId":0,"endPulseId":4}' http://sf-nube-14.psi.ch:8080/query

Response example

The response is in JSON.

[
   {
      "channel":"channel1",
      "data":[
         {
            "pulseId":0,
            "iocMillis":0,
            "iocNanos":0,
            "globalMillis":0,
            "globalNanos":0,
            "value":0
         },
         {
            "pulseId":2,
            "iocMillis":2,
            "iocNanos":2,
            "globalMillis":2,
            "globalNanos":2,
            "value":2
         },
         {
            "pulseId":4,
            "iocMillis":4,
            "iocNanos":4,
            "globalMillis":4,
            "globalNanos":4,
            "value":4
         }
      ]
   },
   {
      "channel":"channel2",
      "data":[
         {
            "pulseId":1,
            "iocMillis":1,
            "iocNanos":1,
            "globalMillis":1,
            "globalNanos":1,
            "value":1
         },
         {
            "pulseId":3,
            "iocMillis":3,
            "iocNanos":3,
            "globalMillis":3,
            "globalNanos":3,
            "value":3
         }
      ]
   }
]

Example Queries

Following examples build on a waveform data (see below). They also work for scalars (consider it as a waveform of length = 1) and images (waveform of length = dimX * dimY).

Visualized data

[
   {
      "channel":"Channel_01",
      "data":[
         {
            "iocMillis":0,
            "iocNanos":0,
            "pulseId":0,
            "globalMillis":0,
            "globalNanos":0,
            "shape":[
               4
            ],
            "value":[
               1,
               2,
               3,
               4
            ]
         },
         {
            "iocMillis":10,
            "iocNanos":0,
            "pulseId":1,
            "globalMillis":10,
            "globalNanos":0,
            "shape":[
               4
            ],
            "value":[
               2,
               3,
               4,
               5
            ]
         },
         {
            "iocMillis":20,
            "iocNanos":0,
            "pulseId":2,
            "globalMillis":20,
            "globalNanos":0,
            "shape":[
               4
            ],
            "value":[
               3,
               4,
               5,
               6
            ]
         },
         {
            "iocMillis":30,
            "iocNanos":0,
            "pulseId":3,
            "globalMillis":30,
            "globalNanos":0,
            "shape":[
               4
            ],
            "value":[
               4,
               5,
               6,
               7
            ]
         }
      ]
   }
]

Query Examples

Query by Pulse-Id Range
{
   "startPulseId":0,
   "endPulseId":3,
   "channels":[
      "Channel_01"
   ]
}
Command
curl -H "Content-Type: application/json" -X POST -d '{"startPulseId":0,"endPulseId":3,"channels":["Channel_01"]}' http://sf-nube-14.psi.ch:8080/query
Response

See JSON representation of the data above.

Query by Time Range
{
   "startMillis":0,
   "startNanos":0,
   "endMillis":30,
   "endNanos":999999,
   "channels":[
      "Channel_01"
   ]
}
Command
curl -H "Content-Type: application/json" -X POST -d '{"startMillis":0,"startNanos":0,"endMillis":30,"endNanos":999999,"channels":["Channel_01"]}' http://sf-nube-14.psi.ch:8080/query
Response

See JSON representation of the data above.

Query by Date Range
{
   "startDate":"1970/01/01 01:00:00.000",
   "startNanos":0,
   "endDate":"1970/01/01 01:00:00.030",
   "endNanos":999999,
   "channels":[
      "Channel_01"
   ]
}

Supported formats: yyyy/MM/dd HH:mm:ss.SSS and dd.MM.yyyy HH:mm:ss.SSS

Command
curl -H "Content-Type: application/json" -X POST -d '{"startDate":"1970/01/01 01:00:00.000","startNanos":0,"endDate":"1970/01/01 01:00:00.030","endNanos":999999,"channels":["Channel_01"]}' http://sf-nube-14.psi.ch:8080/query
Response

See JSON representation of the data above.

Querying Archiver Appliance
{
   "dbmode":"archiverappliance",
   "startMillis":0,
   "startNanos":0,
   "endMillis":30,
   "endNanos":999999,
   "channels":[
      "Channel_01"
   ]
}

Archiver Appliance supports queries by time range and date range only (as it has no notion about pulse-id).

Command
curl -H "Content-Type: application/json" -X POST -d '{"dbmode":"archiverappliance","startMillis":0,"startNanos":0,"endMillis":30,"endNanos":999999,"channels":["Channel_01"]}' http://sf-nube-14.psi.ch:8080/query
Response

See JSON representation of the data above.

Querying for Specific Fields

Allows for server side optimizations since not all data needs to be retrieved.

{
   "fields":["pulseId","value"]
   "startPulseId":0,
   "endPulseId":3,
   "channels":[
      "Channel_01"
   ]
}

Archiver Appliance supports queries by time range and date range only (as it has no notion about pulse-id).

Command
curl -H "Content-Type: application/json" -X POST -d '{"fields":["pulseId","value"],"startPulseId":0,"endPulseId":3,"channels":["Channel_01"]}' http://sf-nube-14.psi.ch:8080/query
Response
[
   {
      "channel":"Channel_01",
      "data":[
         {
            "pulseId":0,
            "value":[
               1,
               2,
               3,
               4
            ]
         },
         {
            "pulseId":1,
            "value":[
               2,
               3,
               4,
               5
            ]
         },
         {
            "pulseId":2,
            "value":[
               3,
               4,
               5,
               6
            ]
         },
         {
            "pulseId":3,
            "value":[
               4,
               5,
               6,
               7
            ]
         }
      ]
   }
]
Description
Copy of ch.psi.daq.queryrest from git.psi.ch. This contains the documentation of the GLS API.
Readme 1.6 MiB
Languages
Java 100%