S7 Contrib vars to table

#1

Hy fellows;

I'm learning about Node-red, I'm a PLC programer and I'm trying to make a simple table, what is the best way to perform it? "this is the flow..."

[{"id":"d4d0e1ed.32f82","type":"tab","label":"Flow 2"},{"id":"b197a359.0a129","type":"debug","z":"d4d0e1ed.32f82","name":"tabelafinal","active":false,"console":"false","complete":"true","x":690,"y":180,"wires":[]},{"id":"cda94a49.1ce738","type":"ui_template","z":"d4d0e1ed.32f82","group":"90c79bc4.11d9e8","name":"","order":0,"width":0,"height":0,"format":"<!DOCTYPE html>\n<html>\n<body>\n\n<h2>Basic HTML Table</h2>\n\n<table style=&quot;width:100%&quot; id=&quot;table&quot; border=&quot;1&quot;>\n <tr>\n <th>Sample 1</th>\n <th>Sample 2</th> \n <th>Sample 3</th>\n </tr>\n <tr>\n <td>Var 1</td>\n <td>Var 2</td>\n <td>Var 3</td>\n </tr>\n \n</table>\n\n</body>\n</html>","storeOutMessages":true,"fwdInMessages":true,"x":540,"y":120,"wires":[["b197a359.0a129"]]},{"id":"c07e23b5.002ae","type":"debug","z":"d4d0e1ed.32f82","name":"S71200Log","active":false,"console":"false","complete":"true","x":330,"y":200,"wires":[]},{"id":"65492108.50f5f","type":"s7 in","z":"d4d0e1ed.32f82","endpoint":"3ae16e4d.97c452","mode":"all","variable":"Air Flow Main Blower","diff":false,"name":"S71200","x":150,"y":120,"wires":[["c07e23b5.002ae","cda94a49.1ce738"]]},{"id":"90c79bc4.11d9e8","type":"ui_group","z":"","name":"Table with sample's Var","tab":"81897283.4000e","disp":true,"width":"32"},{"id":"3ae16e4d.97c452","type":"s7 endpoint","z":"","address":"192.168.10.10","port":"102","rack":"0","slot":"1","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","cycletime":"500","timeout":"1500","verbose":"off","name":"PLC1","vartable":[{"addr":"DB48,REAL94","name":"VAR 1"},{"addr":"DB48,REAL110","name":"VAR 2"},{"addr":"DB48,REAL90","name":"VAR 3"}]},{"id":"81897283.4000e","type":"ui_tab","z":"","name":"Table with Sample's Var","icon":"dashboard","order":3}]

0 Likes

#2

when pasting flows, please follow the directions in How to import a flow into the editor

You can edit your post to fix the flow.

0 Likes

#3

Hi, I just use the top right option "export" on the node-red to export my 4 nodes, it's a wrong mode? How can Is the right way?

0 Likes

#4

Please read the article that @zenofmud linked to

0 Likes

#5

Hi everybody;

Sorry by the delay and my poor english, now can anybody copy and past my flow to help me?

Tks...

0 Likes

#6

Since you are new to learning about NR, I suggest you go to the 'flows' tab of the website and search for 'table' and uncheck the 'nodes' box.

You should find a number of flows showing examples of creating tables. Import some of tehm and see if you understant them. This should help you figure out what you need to do.

If you get stuck, please ask a specific question and provide the flow you are using.

0 Likes

#7

So, I start to view the examples of this page:
https://flows.nodered.org/flow/796e6b70ad239ea4c118d2911ff2f2ed, and this https://flows.nodered.org/flow/76cd6afbd14426f88656c90aedf10423, but the numbers of this examples are fixed by hand in the function node, how can I adapt one of this functions to read the payload value and the topic name of my "S7 In" node? Have anybody another example flow to adapt?

My "S7 In" it's config to answer "All variables, one per message", and I have more 2 options, "one variable" and "All Variables".

The debug node of my "S7 IN" node answer to me 3 objects at same time, it's my 3 variables:

image

0 Likes

#8

are all of these going to be part of the data you need to save? If so you should use a join node to create one message with the key:value pair of each of those messagesf

0 Likes

#9

Try this.

[{"id":"8926661f.7ec008","type":"inject","z":"b4aaf4e3.27fb68","name":"","topic":"","payload":"{\"VAR1\":10,\"VAR2\":20,\"VAR3\":30,\"VAR4\":40}","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":330,"y":420,"wires":[["42a7b0af.3e192"]]},{"id":"909f9c7f.19b33","type":"debug","z":"b4aaf4e3.27fb68","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":670,"y":300,"wires":[]},{"id":"6a43ae9b.ca7af","type":"s7 in","z":"b4aaf4e3.27fb68","endpoint":"aa4a1fa7.53de48","mode":"all","variable":"","diff":true,"name":"","x":350,"y":320,"wires":[["909f9c7f.19b33","42a7b0af.3e192"]]},{"id":"2c68fb9.f9d5a04","type":"ui_template","z":"b4aaf4e3.27fb68","group":"1d8875f2.ba71aa","name":"","order":2,"width":0,"height":0,"format":"\n<style>\n {{msg.style}}\n</style>\n\n\n<div id=tables>\n<table>\n <tr>\n <td class=\"column\">{{msg.payload.VAR1}}</td>\n <td class=\"column\">{{msg.payload.VAR2}}</td>\n </tr> \n <tr>\n <td class=\"column\">{{msg.payload.VAR3}}</td>\n <td class=\"column\">{{msg.payload.VAR4}}</td>\n </tr>\n</table>\n</div>\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":860,"y":380,"wires":[[]]},{"id":"42a7b0af.3e192","type":"template","z":"b4aaf4e3.27fb68","name":"css","field":"style","fieldType":"msg","format":"css","syntax":"mustache","template":"\n\ntable {\n border: 0px solid black;\n //width: -moz-available;\n width: 50%;\n float: left;\n}\n\nth, td {\n border: 2px solid black;\n border-collapse: collapse;\n font-size: 50px;\n overflow:hidden;\n height: 74px;\n padding: 8px;\n}\n","output":"str","x":630,"y":380,"wires":[["2c68fb9.f9d5a04"]]},{"id":"aa4a1fa7.53de48","type":"s7 endpoint","z":"","address":"192.168.102.240","port":"102","rack":"0","slot":"2","localtsaphi":"01","localtsaplo":"00","remotetsaphi":"01","remotetsaplo":"00","connmode":"rack-slot","cycletime":"1000","timeout":"3000","verbose":"default","name":"","vartable":[{"addr":"DB555,INT2","name":"VAR1"},{"addr":"DB555,S4.16","name":"VAR2"},{"addr":"DB555,INT22","name":"VAR3"},{"addr":"DB555,S24.16","name":"VAR4"}]},{"id":"1d8875f2.ba71aa","type":"ui_group","name":"Group 1","tab":"3f5dffa2.f7cbf","order":1,"disp":true,"width":6},{"id":"3f5dffa2.f7cbf","type":"ui_tab","name":"Tab 2","icon":"dashboard","order":2}]

0 Likes