2 Replies Latest reply on Mar 30, 2017 3:01 PM by polinao RSS
    tlichtenberger Newbie

    Filling InfoTable with values doesn´t work

    Hello! I am currently working on Project in Thingworx: My Goal is to visualize data I get from a csv file in two line Charts.

    For that, I created a Mashup with a big TextBox, in which i copypaste the csv data in runtime. In addition, i have an grid widget and two linechart widgets.

     

    First of all, after pasting the csv data into the TextBox, a Service is called which parses the data and fills the infotable. The Service's Output is a infotable and the Input Parameter is a string. By now, it Looks like the infotable is filled with empty values so i am kind of confused right now...

     

    My service looks like this:

    var txt = CSVinput;
    var i = 0;

    //var valArray = txt.replace("\n"," ");
    var valArray = txt.split(" ");

    var params = {
    infoTableName : "InfoTable", 
    dataShapeName : "LogDataShape"
    };
    var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

    var cnt = 0;
    while (i < valArray.length-1){
        var row = new Object();
        if(cnt == 0){
      row.DateTime = valArray[i] + " " + valArray[i+1];
            cnt = 1;
        }
    else if(cnt == 1){
            row.Temperature = valArray[i];
            cnt = 2;
        }
        else if(cnt == 2){
            row.Press_601_mbar = valArray[i];
            cnt = 3;
        }
        else if(cnt == 3){
            row.Press_651_mbar = valArray[i];
            cnt = 0;
            result.AddRow(row);
        }
    i++;
    }

     

    the Input string looks like this: in the TextBox, there is exactly one space between each value and I asume a "\n"-endline at the end of the last value.

       

    DateTimePress_601_mbarPress_651_mbarTemp_518a_°C
    02.03.201723:40:15-93-33235.4
    02.03.201723:40:16-95-33335.4
    02.03.201723:40:17-97-33435.4
    02.03.201723:40:18-99-33335.4
    02.03.201723:40:19-101-33335.4
    02.03.201723:40:20-102-33635.4
    02.03.201723:40:21-101-33835.4
    02.03.201723:40:22-95-34335.4
    02.03.201723:40:23-88-34635.4
    02.03.201723:40:24-85-35335.4
    02.03.201723:40:25-83-35635.3
    02.03.201723:40:26-85-35835.4
    02.03.201723:40:27-87-35635.4
    02.03.201723:40:28-88-35635.4

     

    I would really really appreciate any kind of advice or help you can give me!!

    Thank you so much in advance!