LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accesing historical data using Citadel web service

Solved!
Go to solution

Hi there, my question is about getting historical data across the Citadel web service. I am using Labview 2017 and the DSC Module and running the example given by NI in "Find Examples/ Toolkits and Modules/ Dataloging and Supervisory Control/ Data and Alarm Historical Logging/ Database Direct write Demo.lvproj.LV-Example.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

On this document we can find how to use the webservice

Here

 

I am trying to acces historical data using the webservice API, and the documentation says I could specify many parameters for a desired response from the server. My necesity is this:

  1. I need information from a trace
  2. I want a JSON formated Response
  3. I need a Start timestamp and an End timestamp

So, I think the URL for my request should look like this:

 

http://localhost:3580/nicitadel/trace/PORTJOCARR3/My_Process/MyTrace?OUTPUT_FORMAT=JSON&start=2018-10-23T14:15:33-06:00&end=2018-10-23T14:15:35-06:00

 

It suposed that I will receive a dataset with all the data between the START and END timestamps, but the server is giving me this ResponseTest using PostmanTest using Postman

 

I've used Postman for testing the API, but any Web Browser will work.

0 Kudos
Message 1 of 6
(3,093 Views)
Solution
Accepted by topic author Jocarrit

It looks like the response you're getting is valid with status code 200 and a valid JSON message.

 

I tried the example VI you're using, and it's writing bad data. Or rather, it's writing with a very small time interval (0.5ms) which can't be queried via the web service. Heck, Citadel only really supports 1ms data, and that's pushing it to the limit. 100ms is much more reasonable.

 

If you modify the example VI and set the wavform dt to something more sensible, say 0.1s, then run it, then run your web service it should work.

citadel_example_fix.PNG

 

Example of web service response:

{ "firstTimestamp":"2018-10-25T09:18:16+08:00",
   "sampleInterval":1,
   "data": [0.000000,0.270000,0.560000,0.790000,0.940000,0.990000,0.970000,0.83...(more data not shown)

 




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 2 of 6
(3,069 Views)

Thank you  MichaelBalzer, definitely this is the answer. And it's confirm I was confuse in the way Citadel store logs. But this drive me to three more questions:

 

  1. I have to calculate the timestamps of each value based on the first Timestamp and the interval, right?
  2. What happened in processes which I dont have a permanent interval between each log?
  3. when I export a traceview data to text on NI MAX, I do have each value with its timestamp, is not posible to get this data on the web API?time.png

 

0 Kudos
Message 3 of 6
(3,046 Views)

I'm not overly familiar with the web services side of Citadel, so these are just my best guesses. Perhaps someone from NI can respond?

 

1. Based on the JSON response, yes.

2. I'm guessing it'll interpolate the values to the nearest time interval, but is probably worth verifying.

3. Not as far as I can see. It looks like the web service response only provides t0 and dt, and the documentation doesn't mentioned anything about a timestamp per data point. So you'll need to calculate timestamps.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 4 of 6
(3,034 Views)

I appreciate all your help. I think your guesses are right too. The documentation has a lack of exmples

0 Kudos
Message 5 of 6
(3,016 Views)

Hello! Question on this topic.
How can I change the decimal point in the JSON response?
Changing the settings for language and regional settings do not help ...

json reply.png

2020-10-23_15-50-13.png

0 Kudos
Message 6 of 6
(2,187 Views)