Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local start_time
- local debug_out = ""
- local t_max = 500
- local t_index = 0
- local function init()
- start_time = getTime()/100
- debug_out = "\r\n\r\nInit'g idscan.lua @ " .. start_time .. " seconds after startup \r\n\r\n"
- serialWrite(debug_out)
- end
- -- periodically called function
- local function run()
- local temp_info_str = ""
- t_index = t_index + 1
- if t_index <= t_max then
- local ctl_name = getSwitchName(t_index)
- local tbd_val = getValue(t_index)
- local tbd_info = getFieldInfo(t_index)
- temp_info_str = "info: " .. tostring(tbd_info)
- if tbd_info ~= nil then
- local tbd_info_id = getFieldInfo(t_index).id
- local tbd_info_name = getFieldInfo(t_index).name
- local tbd_info_desc = getFieldInfo(t_index).desc
- local tbd_info_unitid = getFieldInfo(t_index).unit
- temp_info_str = temp_info_str .. " | " .. "id: " .. tostring(tbd_info_id) .. " | "
- temp_info_str = temp_info_str .. "name: " .. tostring(tbd_info_name) .. " | "
- temp_info_str = temp_info_str .. "desc: " .. tostring(tbd_info_desc) .. " | "
- temp_info_str = temp_info_str .. "unitid: " .. tostring(tbd_info_unitid)
- end
- if ctl_name ~= nil then
- local sw_val = getSwitchValue(t_index)
- if sw_val ~= nil then
- serialWrite(tostring(t_index) .. ": sw_" .. ctl_name .. " = " .. tostring(sw_val) .. " (".. temp_info_str .. ")\r\n")
- else
- serialWrite(tostring(t_index) .. ": sw_" .. ctl_name .. " = nil" .. " (".. temp_info_str .. ")\r\n")
- end
- else
- -- so not a switch - lets see if a val and info can be fetched
- if tbd_val ~= nil then
- serialWrite(tostring(t_index) .. ": tbd_" .. "????" .. " = " .. tostring(tbd_val) .. " (".. temp_info_str .. ")\r\n")
- else
- serialWrite(tostring(t_index) .. ": tbd_" .. "????" .. " = nil" .. " (".. temp_info_str .. ")\r\n")
- end
- end
- else
- serialWrite(".")
- end
- end
- return {run=run, init=init}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement