Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Copyright Lego11 2026
- -- Programma monitoraggio centrali
- cardReader1 = peripheral.wrap("left")
- cardReader2 = peripheral.wrap("right")
- while true do
- time = http.get("http://172.16.20.220/luanet/servlets/timestamp.php").readAll()
- print("Inizio lettura: " .. time)
- for i=1,9 do
- a,b,c,d = cardReader1.get(i)
- if (type(b) == "string" and b == "OK") then
- name, fuel, power = string.match(c, "(.*),(.*),(.*)")
- if (type(name) == "string" and type(fuel) == "string" and type(power) == "string") then
- reading = tostring(textutils.serialize(d.average))
- print("Scheda [S" .. i .. "]: " .. name .. " - " .. fuel .. " - " .. power .. " kW - " .. reading .. " kW")
- restURI = string.gsub("http://172.16.20.220/luanet/servlets/ergb/centrali.php?centrale=" .. name .. "&combustibile=" .. fuel .. "&shunt=" .. reading .. "&potenza=" .. power .. "&time=" .. time, "%s", "%%20")
- rest = http.get(restURI).readAll()
- print(rest)
- else
- print("Scheda [S" .. i .. "] non valida")
- end
- else
- print("Scheda [S" .. i .. "] non riconosciuta o non presente")
- end
- sleep(1)
- end
- for i=1,9 do
- a,b,c,d = cardReader2.get(i)
- if (type(b) == "string" and b == "OK") then
- name, fuel, power = string.match(c, "(.*),(.*),(.*)")
- if (type(name) == "string" and type(fuel) == "string" and type(power) == "string") then
- reading = tostring(textutils.serialize(d.average))
- print("Scheda [Da" .. i .. "]: " .. name .. " - " .. fuel .. " - " .. power .. " kW - " .. reading .. " kW")
- restURI = string.gsub("http://172.16.20.220/luanet/servlets/ergb/centrali.php?centrale=" .. name .. "&combustibile=" .. fuel .. "&shunt=" .. reading .. "&potenza=" .. power .. "&time=" .. time, "%s", "%%20")
- rest = http.get(restURI).readAll()
- print(rest)
- else
- print("Scheda [D" .. i .. "] non valida")
- end
- else
- print("Scheda [D" .. i .. "] non riconosciuta o non presente")
- end
- sleep(1)
- end
- for i=30,1,-1 do
- print("Attesa: " .. i)
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment