External Capture Data

Internally, the Capture system makes a single JSON file for every capture record.

Like other ARDI addons, this basic structure helps with backups and replication, making it very easy to copy, restore or modify existing data.

It also not only makes it easy to re-build databases in the event of data loss, but also makes it easy to integrate other sources of data into Capture.

For example, your daily reports can write JSON files into a capture folder. This gives you the power of incredibly flexible logic and analytics from Python reports while also using the simple user interface and API access of the Capture system.

Setting Up External Capture

To record captured data, you'll need to go through a couple of steps.

1) Create the capture configuration.

Create a new folder in your sites /capture folder - for example, /capture/externaldata. Add a 'config.json' file listing the uniqueid, name, keys and an empty steps array.

2) Write JSON files into the folder

Your data source should then write JSON files into the Capture folder, each having a unique name.

3) Request an Index Update

Once your data has been written, call the UPDATEINDEX API function. The system will then scan the new JSON files and import them into its database tables.

Capturing Report Data

The CaptureAPI Python library is also available to make writing captured data easy.

#Create a dictionary of values you want to write
value = {}
value['Average Speed'] = amt
value['Date'] = report.LocalTime(report.defaultstart).strftime("%Y-%m-%d %H:%M:%S")
 
#Setup the capture
cap = captureapi.CaptureData("http://myserver","mysitecapturefolder","name","Date",["Average Speed"],"Date")
 
#Write the data & refresh the index.
cap.WriteData(value)

This script takes care of each of the steps of the process, including…

* Creating the Capture folder and config file (if it hasn't already been created),
* Writing the JSON file, and
* Updating the index