Hello,
I am trying to write an CSV, with the data from two real variables, but only when a boolean is true or when I change a variable status. It doesn't work. If I put in the flow a boolean, it will write but with the status of that variable (TRUE).
Also, If I have the function, I don't understand why I have 2 duplicated rows, every time (most probably because on debugging node I have same - but i don't know how to make to have only one).
Is this any ideas? Thanks very much for help.
And the flow:
{
"id": "e5b093538a456090",
"type": "group",
"z": "a0e25e7b2fd00f38",
"name": "Sending data to excel",
"style": {
"label": true
},
"nodes": [
"23e6ea12df7a314d",
"52ebb1c6b9acdf44",
"df291718238d71f6",
"a38814e8796ddb63",
"1e4b079df1a96814",
"311bae7ef5f785ed",
"dbfa625dd2195017",
"99a275c7dddca3f3"
],
"x": 14,
"y": 2439,
"w": 992,
"h": 162
},
{
"id": "23e6ea12df7a314d",
"type": "s7 in",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"endpoint": "4f6c10e39b6f89f4",
"mode": "single",
"variable": "rVibrationForward",
"diff": true,
"name": "",
"x": 130,
"y": 2480,
"wires": [
[
"1e4b079df1a96814"
]
]
},
{
"id": "52ebb1c6b9acdf44",
"type": "s7 in",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"endpoint": "4f6c10e39b6f89f4",
"mode": "single",
"variable": "rVibrationReverse",
"diff": true,
"name": "",
"x": 130,
"y": 2560,
"wires": [
[
"99a275c7dddca3f3"
]
]
},
{
"id": "df291718238d71f6",
"type": "debug",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"name": "debug 16",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 760,
"y": 2480,
"wires": []
},
{
"id": "a38814e8796ddb63",
"type": "function",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"name": "function 3",
"func": "var vibrfw = flow.get(\"rVibrationForward\");\nvar vibrrev = flow.get(\"rVibrationReverse\");\nvar d=new Date();\nvar time=d.toLocaleTimeString();\nvar m = { 'Time': time, 'Forward': vibrfw, 'Reverse': vibrrev};\nreturn {payload:m};",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 580,
"y": 2520,
"wires": [
[
"df291718238d71f6",
"dbfa625dd2195017"
]
]
},
{
"id": "1e4b079df1a96814",
"type": "change",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"name": "",
"rules": [
{
"t": "set",
"p": "rVibrationForward",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 370,
"y": 2480,
"wires": [
[
"a38814e8796ddb63"
]
]
},
{
"id": "311bae7ef5f785ed",
"type": "file",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"name": "excel_output",
"filename": "D:\\Personal\\NodeREd\\excel_output.csv",
"filenameType": "str",
"appendNewline": true,
"createDir": true,
"overwriteFile": "false",
"encoding": "utf8",
"x": 910,
"y": 2560,
"wires": [
[]
]
},
{
"id": "dbfa625dd2195017",
"type": "csv",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"name": "",
"sep": ",",
"hdrin": true,
"hdrout": "none",
"multi": "one",
"ret": "\\n",
"temp": "Time, Forward, Reverse",
"skip": "1",
"strings": true,
"include_empty_strings": "",
"include_null_values": "",
"x": 750,
"y": 2560,
"wires": [
[
"311bae7ef5f785ed"
]
]
},
{
"id": "99a275c7dddca3f3",
"type": "change",
"z": "a0e25e7b2fd00f38",
"g": "e5b093538a456090",
"name": "",
"rules": [
{
"t": "set",
"p": "rVibrationReverse",
"pt": "flow",
"to": "payload",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 370,
"y": 2560,
"wires": [
[
"a38814e8796ddb63"
]
]
},
{
"id": "4f6c10e39b6f89f4",
"type": "s7 endpoint",
"transport": "iso-on-tcp",
"address": "192.168.0.1",
"port": "102",
"rack": "0",
"slot": "1",
"localtsaphi": "01",
"localtsaplo": "00",
"remotetsaphi": "01",
"remotetsaplo": "00",
"connmode": "rack-slot",
"adapter": "",
"busaddr": "2",
"cycletime": "200",
"timeout": "2000",
"name": "",
"vartable": [
{
"addr": "M151.0",
"name": "b_OK_parts"
},
{
"addr": "M151.1",
"name": "b_NOK_parts"
},
{
"addr": "MW2",
"name": "int_OK_parts"
},
{
"addr": "MW6",
"name": "int_NOK_parts"
},
{
"addr": "M0.1",
"name": "Light_ON"
},
{
"addr": "M0.6",
"name": "b_InitializeInProcess"
},
{
"addr": "M0.4",
"name": "b_StartLinePressed"
},
{
"addr": "M1.3",
"name": "b_DeinitializeInProcess"
},
{
"addr": "M0.5",
"name": "b_StopLinePressed"
},
{
"addr": "MW7",
"name": "intState"
},
{
"addr": "MW10",
"name": "intState2"
},
{
"addr": "MW9",
"name": "inTemperature"
},
{
"addr": "MW12",
"name": "intHumidity"
},
{
"addr": "M14.0",
"name": "bLed"
},
{
"addr": "DB5,X312.0",
"name": "bStartLW"
},
{
"addr": "DB5,R0",
"name": "bFrequencyLW"
},
{
"addr": "DB5,R298",
"name": "rPTEmtyingTimeoutLW"
},
{
"addr": "DB5,X4.0",
"name": "bStopLW"
},
{
"addr": "DB5,X302.1",
"name": "bStartedFW"
},
{
"addr": "DB5,WORD6",
"name": "intStateFW"
},
{
"addr": "DB5,X302.2",
"name": "bFreezeState"
},
{
"addr": "DB5,R308",
"name": "rVibrationForward"
},
{
"addr": "DB5,R304",
"name": "rVibrationReverse"
}
]
}
]