function api:set_handler(handler, watch_data)
end
local api = sys:data_api()
api:set_handler({
on_comm = function(src_app, dev_sn, dir, timestamp, ...) end, -- watch_data = true
on_stat = function(src_app, dev_sn, state, prop, value, timestamp) end, -- watch_data = true
on_input = function(src_app, dev_sn, input, prop, value, timestamp, quality) end, -- watch_data = true
on_add_device = function(src_app, dev_sn, props) end, -- watch_data = true
on_del_device = function(src_app, dev_sn, props) end, -- watch_data = true
on_mod_device = function(src_app, dev_sn) end, -- watch_data = true
on_output = function(src_app, dev_sn, output, prop, value, timestamp) end, -- 数据输出项回调
on_output_result = function(src_app, priv, result, err) end, -- 数据输出项请求执行结果回调
on_command = function(src_app, dev_sn, command, params) end, -- 命令回调
on_command_result = function(src_app, priv, result, err) end, -- 命令请求执行结果回调
on_ctrl = function(src_app, command, params) end, -- 应用控制接口
on_ctrl_result = function(src_app, priv, result, err) end, -- 应用控制执行结果回调
})
API_VER: 5 API_VER 5支持了 on_output_result 和 on_command_result接口
function api:list_devices()
end
function api:add_device(sn, meta, inputs, outputs, commands)
end
--- 创建设备模型
local inputs = {
{name="tag1", desc="tag1 desc", unit="KV", vt="float"},
{name="tag2", desc="tag2 desc", unit="KV", vt="float"}
}
local outputs = {
{name="output1", desc="output1 desc", unit="V"},
}
local commands = {
{name="command1", desc="command desc"},
}
local meta = self._api:default_meta()
meta.name = "Example Device"
meta.description = "Example Device Meta"
--- 生成设备模型对象
local dev = self._api:add_device(sn, meta, inputs, outputs, commands)
function api:del_device(dev)
end
获取设备对象实例。 此接口对象可以用来读取设备输入项数据,写入设备输出项,发送设备控制项。 当secret值被指定且与设备源应用中设定的secret值一致时,可获取设备的输入项数据写入的权限。 参考: device:share(secret)接口
function api:get_device(sn, secret)
end
function api:send_ctrl(app, ctrl, params)
end
function api:cleanup()
end
function api:_dump_comm(sn, dir, ...)
end
api:_fire_event(sn, level, data, timestamp)