Created
July 24, 2014 17:31
-
-
Save rafrombrc/c9a04aa1e09da87ab3df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("circular_buffer") | |
require("cjson") | |
-- 300 rows, 11 cols, 1s per row | |
cbuf = circular_buffer.new(300, 11, 1) | |
cbuf_idxs = {} | |
for i=2, 12, 1 do | |
cbuf_idxs[i-1] = cbuf:set_header(i-1, tostring(i), "sum") | |
end | |
local debug = {this = "is a test"} | |
function process_message() | |
local value = read_message("Payload") | |
local ts = read_message("Timestamp") | |
value = tonumber(value) | |
cbuf:add(ts, cbuf_idxs[value-1], 1) | |
debug["timestamp"] = ts | |
return 0 | |
end | |
function timer_event(ns) | |
inject_payload("cbuf", "Value Counts", cbuf) | |
inject_payload("txt", "debug", cjson.encode(debug)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment