sasaki77 / archiverappliance-datasource

EPICS Archiver Appliance plugin for Grafana dashboard
https://sasaki77.github.io/archiverappliance-datasource
MIT License
14 stars 7 forks source link

ENH: add array format option function #89

Closed sasaki77 closed 2 years ago

sasaki77 commented 2 years ago

This PR fixes #83.

arrayFormat function provides 3 types of array format: timeseries, index, and dt-space.

Assume that we have following array data:

[
    {
        "meta": {
            "name": "PV:NAME",
            "waveform": true,
            "PREC": "0"
        },
        "data": [
            {
                "millis": 1577804410000,
                "val": [
                    val1_1, val1_2, val1_3, val1_4, ..., val1_361
                ]
            },
            {
                "millis": 1577804510000,
                "val": [
                    val2_1, val2_2, val2_3, val2_4, ..., val2_361
                ]
            }
        ]
    }
]

Each format should return as following:

timeseries

time PV:NAME[0] PV:NAME[1] ... PV:NAME[360]
1577804410000 val1_1 val1_2 ... val1_361
1577804510000 val2_1 val2_2 ... val2_361

index

index 2020-01-01T00:00:10.000Z 2020-01-01T00:01:50.000Z
0 val1_1 val2_1
1 val1_2 val2_2
... ... ...
360 val1_361 val2_361

dt-space

time PV:NAME
1577804410000 val1_1
1577804410001 val1_2
... ...
1577804410360 val1_361
1577804510000 val2_1
1577804510001 val2_2
... ...
1577804510360 val2_361