Hello everyone,
I have started using openCCsensors and what i want to do is use the information i get from machines to display on a monitor.
For example the stored energy in various storage devices or heat in a couple of reactors.
When i use the sensorview program I can see the information but I have no clue how to send it to my control room.
Is there a wiki or tutorial i am missing?
This is my setup:
- advanced computer with monitors in a "control room"
- computers with sensors to read my nuclear reactors
- all the computer are hooked up with wireless modems
What i want to do:
send the energy output and heat readings to the control room.
any help would be greatly appreciated
1
7 replies to this topic
#1
Posted 15 August 2013 - 04:20 PM
#2
Posted 15 August 2013 - 09:59 PM
You can use JSON or a text format, though json would be the best.
Use either http://dkolf.de/src/...on-lua.fsl/home or the computercraft one, http://www.computerc...-computercraft/
Use a timer/sleep to get data every x seconds, then send it with something like this:
Then on the computer you want to receive it, something like this would be used:
In the end you could modify 'sensorview' to use the data received over rednet, but this should be a good start for you
Edit: I might have misled you with dkjson, last I saw it worked, but I guess not!
Use this instead - https://raw.github.c...k/json/json.lua
Use either http://dkolf.de/src/...on-lua.fsl/home or the computercraft one, http://www.computerc...-computercraft/
Use a timer/sleep to get data every x seconds, then send it with something like this:
rednet.send(<computer id>, json.encode(sensorData))
Then on the computer you want to receive it, something like this would be used:
-- Load the file which could have been saved under 'dkjson' os.loadAPI('dkjson') -- Open rednet on the side, for this example it'll be right rednet.open('right') while true do local event, id, text = os.pullEvent() if event == "rednet_message" then local sensorData = json.decode(text); -- Display it somehow end end
In the end you could modify 'sensorview' to use the data received over rednet, but this should be a good start for you
Edit: I might have misled you with dkjson, last I saw it worked, but I guess not!
Use this instead - https://raw.github.c...k/json/json.lua
#3
Posted 29 August 2013 - 03:43 AM
or you can use the lua native format and don't have to use extra apis. just take textutils.serialize and textutils.deserialize.
#4
Posted 29 August 2013 - 09:50 AM
Or just send your table, no serialization needed.
#7
Posted 12 September 2013 - 04:11 PM
Not sure what you mean by userdata. I don't know about functions, but if they work, they should still work if they're inside a table.
#8
Posted 12 September 2013 - 04:28 PM
Unfortunately you can't send functions or metatables over rednet. If you put the functions in a table then that index disappears, leaving the rest of the table unaffected.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users