write_command(conn,"screen_add "..pageid)
write_command(conn,"screen_set "..pageid.." -cursor off -name "..pagetitle.." -duration "..graph_duration)
write_command(conn,"widget_add "..pageid.." "..pageid..".title title")
- write_command(conn,"widget_add "..pageid.." "..pageid..".max string")
- write_command(conn,"widget_add "..pageid.." "..pageid..".min string")
- for k = 3,height-1 do
- write_command(conn,"widget_add "..pageid.." "..pageid..".place"..trim(tostring(k)).." string")
- end
- for k=1,width do
- write_command(conn,"widget_add "..pageid.." "..pageid..".bar"..trim(tostring(k)).." vbar")
- end
+ if height>2 then
+ write_command(conn,"widget_add "..pageid.." "..pageid..".max string")
+ write_command(conn,"widget_add "..pageid.." "..pageid..".min string")
+ for k = 3,height-1 do
+ write_command(conn,"widget_add "..pageid.." "..pageid..".place"..trim(tostring(k)).." string")
+ end
+ end
write_command(conn,"widget_set "..pageid.." "..pageid..".title \"".. pagetitle.."\"")
end
end
local vals = {}
local maxval = -99999999
local minval = 99999999
+ local len
for k=width,1,-1 do
if row then
val = row["val"] * def["scale"]
if val and (val < minval) then minval = val; end
end
minval = math.floor(minval)
- local minvalstr = trim(tostring(minval))
maxval = math.ceil(maxval)
- local maxvalstr = trim(tostring(maxval))
- local len = math.max(string.len(minvalstr),string.len(maxvalstr))
- write_command(conn,"widget_set "..pageid.." "..pageid..".max "..trim(tostring(width-string.len(maxvalstr)+1)).." 2 "..maxvalstr)
- for k = 3,height-1 do
- write_command(conn,"widget_set "..pageid.." "..pageid..".place"..trim(tostring(k)).." "..trim(tostring(width-len+1)).." "..k.." \" "..string.rep("-",len-1).."\"")
- end
- write_command(conn,"widget_set "..pageid.." "..pageid..".min "..trim(tostring(width-string.len(minvalstr)+1)).." "..height.." "..minvalstr)
+ if height>2 then
+ local minvalstr = trim(tostring(minval))
+ local maxvalstr = trim(tostring(maxval))
+ len = math.max(string.len(minvalstr),string.len(maxvalstr))
+ write_command(conn,"widget_set "..pageid.." "..pageid..".max "..trim(tostring(width-string.len(maxvalstr)+1)).." 2 "..maxvalstr)
+ write_command(conn,"widget_set "..pageid.." "..pageid..".min "..trim(tostring(width-string.len(minvalstr)+1)).." "..height.." "..minvalstr)
+ for k = 3,height-1 do
+ write_command(conn,"widget_set "..pageid.." "..pageid..".place"..trim(tostring(k)).." "..trim(tostring(width-len+1)).." "..k.." \" "..string.rep("-",len-1).."\"")
+ end
+ else
+ len = 0
+ end
local m = width
+ for k=1,width do
+ write_command(conn,"widget_del "..pageid.." "..pageid..".bar"..trim(tostring(k)))
+ end
for k = width-len,1,-1 do
val = vals[m]
if val then
else
h = 0
end
+ write_command(conn,"widget_add "..pageid.." "..pageid..".bar"..trim(tostring(k)).." vbar")
write_command(conn,"widget_set "..pageid.." "..pageid..".bar"..trim(tostring(k)).." "..k.." "..height.." "..h)
m = m - 1
end
- for k= m,1,-1 do
- write_command(conn,"widget_set "..pageid.." "..pageid..".bar"..trim(tostring(k)).." 0 0 0")
- end
end
end
end
while true do
- vals = process_file()
- process_vals(vals)
+ pcall( function ()
- if log_con then
- process_graphs()
- end
+ vals = process_file()
+ process_vals(vals)
+
+ if log_con then
+ process_graphs()
+ end
- os.execute("inotifywait -e MODIFY \""..weather_file.."\"")
- socket.sleep(3)
+ os.execute("inotifywait -e MODIFY \""..weather_file.."\"")
+
+ end)
+
+ socket.sleep(3)
end