Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Using convertcsv.com web service

This webservice allows sohisticated conversions. I prepared some templates for it to do common conversions. Follow the steps below and then choose the right template.json and format the input for the different use cades as outlined below.

  1. Open Convertcsv.com
  2. Import the according template JSON in Load Form

  3. Paste the list of sensors into the input field

    There is no feedback that the form was loaded successfully after uploading the template but it works.

Simple Sensor Config

This generates a config without severities or sensor classes.

  1. Load the Template File 
      File Modified
    You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.
    No files shared here yet.
  2. Drag and drop to upload or browse for files
  • Insert the symbol list with the following format

    Input
    ErsterSensor
    zweiterSensor
    DritterSensor


  • Locally with a bash script

    The following snippet creates a part of a sensor_config.xml from an CSV file and saved it into a file named generated_sensor_config.xml. It is not creating a full configuration but the sensor related parts necessary.

    Adjust the variables to match your CSV

    Change the variables sensor_name,register (MODBUS register) and device_name to match the column number of the CSV.  For example if you set sensor_name=$5, it will use column number five to extract the sensor name

    #!/bin/sh
    #
    # This is just a bare snippet, you have to change below parameters to work for other files. 
    #
    # It creates the <sensor></sensor> part of a sensor config XML from a CSV list
    #
    printf "\n\n\nCopy below this line.\n---------------------------------------------------\n" && \
     awk -F\; '{ device_name="gw_Wago_Modbus_TCP"; sensor_name=$1; register=$7; \
     print \
     "<sensor sensor_id=\"" sensor_name "\">\
     \t<sensor_class>unknown</sensor_class>\
     \t<sensor_gateway sensor_gateway_id=\"" device_name "\">\
     \t\t<demux>\
     \t\t\t<keys>\
     \t\t\t\t<key>"register"</key>\
     \t\t\t</keys>\n\t\t</demux>\
     \t</sensor_gateway>\
     </sensor>"};' wagomodbus2.csv > sensor_config_Sebastian.xml

    Variables

    The script uses three variables that have to be set to match your CSV.

    device_name

    The vendor or model of the actual device that provides the sensors, e.g. a Advantech_ADAM or a B_and_R_BC0087. This is a custom string that you can define individually.

    Pro Tip: A best practice is toi prefix the device name with gw (Gateway). The device name is taken to fill the <sensor_gateway> tag, prefixing it helps in larger configs to differ between the different object types like devices, sensors and sensor gateways.


    sensor_name=<column>

    The column number that holds the string to be used as the sensor name for each register, typically the description or human friendly name of the register.


    register=<column>

    The column number that holds the numeric register. This will be used within the demux section of the sensor config.

    <demux>
        <keys>
            <key> REGISTER </key>
        </keys>
    </demux>

    Example

    Source CSV File

    Root.750_494.rMinimumRmsCurrentL1;MD42;1000;0;System.Single;255;412372;2;0
    Root.750_494.rAverageRmsCurrentL1;MD43;1000;0;System.Single;255;412374;2;0
    Root.750_494.rPeakCurrentL1;MD44;1000;0;System.Single;255;412376;2;0

    In this example, we'll find the sensor name in column one, the Modbus register in column seven. The registers come from a Wago Modbus device, so we set this as our device name.

    Script

    #!/bin/sh
    #
    # This is just a bare snippet, you have to change below parameters to work for other files. 
    #
    # It creates the <sensor></sensor> part of a sensor config XML from a CSV list
    #
    printf "\n\n\nCopy below this line.\n---------------------------------------------------\n" && \
     awk -F\; '{ device_name="gw_Wago_Modbus_TCP"; sensor_name=$1; register=$7; \
     print \
     "<sensor sensor_id=\"" sensor_name "\">\
     \t<sensor_class>unknown</sensor_class>\
     \t<sensor_gateway sensor_gateway_id=\"" device_name "\">\
     \t\t<demux>\
     \t\t\t<keys>\
     \t\t\t\t<key>"register"</key>\
     \t\t\t</keys>\n\t\t</demux>\
     \t</sensor_gateway>\
     </sensor>"};' wagomodbus2.csv > sensor_config_Sebastian.xml

    Result

    Sensor Config
    <sensor sensor_id="Root.750_494.rMinimumRmsCurrentL1">
        <sensor_class>unknown</sensor_class>
        <sensor_gateway sensor_gateway_id="gw_Wago_Modbus_TCP">
            <demux>
                <keys>
                    <key>412372</key>
                </keys>
            </demux>
        </sensor_gateway>
    </sensor>
    <sensor sensor_id="Root.750_494.rAverageRmsCurrentL1">
        <sensor_class>unknown</sensor_class>
        <sensor_gateway sensor_gateway_id="gw_Wago_Modbus_TCP">
            <demux>
                <keys>
                    <key>412374</key>
                </keys>
            </demux>
        </sensor_gateway>
    </sensor>
    <sensor sensor_id="Root.750_494.rPeakCurrentL1">
        <sensor_class>unknown</sensor_class>
        <sensor_gateway sensor_gateway_id="gw_Wago_Modbus_TCP">
            <demux>
                <keys>
                    <key>412376</key>
                </keys>
            </demux>
        </sensor_gateway>
    </sensor>

    Final Steps

    The script only creates the sensor components for the final config. It will need to be embedded into a full /wiki/spaces/SOD/pages/24379410 that has the device section as well as a sensor gateway in it.

    • No labels