Search code examples
autodesk-forgeautodesk-viewer

Setting up a CSV Data Adapter locally


I am trying to set up the Data Visualization extension to use data from csv file for the sensors based on this example:

https://forge.autodesk.com/en/docs/dataviz/v1/developers_guide/advanced_topics/csv_adapter/

So the csv data I am trying to use is the default Hyperion-1.csv in folder server\gateways\csv. Do I need to add/change some other settings as well?

It is showing the following error in Chrome console:

Error message in chrome console

I have these settings for the csv in .env file.enter image description here

And these in devices.json in server\gateways\synthetic-data folder.enter image description here


Solution

  • I've just taken the following steps to enable the CSV data adapter which seemed to work fine:

    1. Clone the repo: git clone https://github.com/Autodesk-Forge/forge-dataviz-iot-reference-app
    2. Install dependencies: npm install
    3. Create a copy of server/env_template and rename it to server/.env
    4. Modify the contents of server/.env, commenting out all the initial env. variables, uncommenting the CSV-related env. vars, and setting their corresponding values:
    # FORGE_CLIENT_ID=
    # FORGE_CLIENT_SECRET=
    # FORGE_ENV=AutodeskProduction
    # FORGE_API_URL=https://developer.api.autodesk.com
    # FORGE_CALLBACK_URL=http://localhost:9000/oauth/callback
    # 
    # FORGE_BUCKET=
    # ENV=local
    # ADAPTER_TYPE=local
    
    
    ## Please uncomment the following part if you want to connect to Azure IoTHub and Time Series Insights
    ## Connect to Azure IoTHub and Time Series Insights
    # ADAPTER_TYPE=azure
    # AZURE_IOT_HUB_CONNECTION_STRING=
    # AZURE_TSI_ENV=
    # 
    ## Azure Service Principle
    # AZURE_CLIENT_ID=
    # AZURE_APPLICATION_SECRET=
    # AZURE_TENANT_ID=
    # AZURE_SUBSCRIPTION_ID=
    #
    ## Path to Device Model configuration File
    # DEVICE_MODEL_JSON=
    ## End - Connect to Azure IoTHub and Time Series Insights
    
    ## Please uncomment the following part if you want to use a CSV file as the time series provider
    ADAPTER_TYPE=csv
    CSV_MODEL_JSON=server/gateways/synthetic-data/device-models.json
    CSV_DEVICE_JSON=server/gateways/synthetic-data/devices.json
    CSV_FOLDER=server/gateways/csv/
    CSV_DATA_START=2011-02-01T08:00:00.000Z
    CSV_DATA_END=2011-02-20T13:51:10.511Z
    CSV_DELIMITER="\t"
    CSV_LINE_BREAK="\n"
    CSV_TIMESTAMP_COLUMN="time"
    CSV_FILE_EXTENSION=".csv"
    ## End - Please uncomment the following part if you want to use a CSV file as the time series provider
    
    1. Run the app with ENV set to "local": ENV=local npm run dev

    After these steps the app is running successfully, however you'll get some other errors because the server/gateways/csv folder only contains data for a single sensor (Hyperion-1).

    Btw. I've been working on an alternative DataViz sample app that aims to be simpler and easier to reuse: https://github.com/petrbroz/forge-iot-extensions-demo (which uses https://github.com/petrbroz/forge-iot-extensions under the hood).