diff --git a/apps/iot/include/iot.hrl b/apps/iot/include/iot.hrl index 4bf4116..858c667 100644 --- a/apps/iot/include/iot.hrl +++ b/apps/iot/include/iot.hrl @@ -14,6 +14,10 @@ -define(HOST_STATUS_OFFLINE, 2). -define(HOST_STATUS_DELETE, 3). +%% 终端状态 +-define(TERMINAL_STATUS_OFFLINE, 0). +-define(TERMINAL_STATUS_ONLINE, 1). + %% cpu相关 -record(cpu_metric, { %% cpu编号 @@ -48,6 +52,20 @@ status }). +%% 终端指标收集 +-record(terminal_metric, { + %% 标识 + symbol :: binary(), + %% 名称 + name :: binary(), + %% 当前最新值 + last_value = 0 :: number(), + %% 历史值序列, 队列;保存最近的100数值, 格式为: [{ts, value}] + serial_values = [] :: queue(), + %% 最后更新时间 + update_ts = 0 :: integer() +}). + %% 主机定义 -record(host, { %% ID @@ -66,10 +84,10 @@ status = ?HOST_STATUS_INACTIVE :: integer() }). -%% 主机指标 +%% 主机指标, 主机和指标之间是一对一的关系,可以分离出新的表 -record(host_metric, { %% ID - id :: binary(), + host_id :: binary(), %% cpu相关 cpus = [], %% cpu温度 @@ -82,14 +100,18 @@ interfaces = [] }). -%% 终端表 +%% 终端设备表 -record(terminal, { - %% ID + %% 设备ID id :: binary(), %% 关联主机 host_id :: binary(), %% 名称 name :: binary(), + %% 设备编码 + code :: binary(), + %% 接入协议 + access_protocol :: binary(), %% 产品ID,枚举类型 product_id :: integer(), %% 厂商ID,枚举类型 @@ -98,6 +120,8 @@ model :: binary(), %% 所在单元ID,管理系统负责 cell_id :: integer(), + %% 指标, 终端指标涉及到查询效率和更新效率的问题,因此合并到一起 + metrics = [] :: [#terminal_metric{}], %% 终端状态 status = 0 :: integer(), %% 最后上线时间 diff --git a/rebar.config b/rebar.config index fc9279c..0374bc8 100644 --- a/rebar.config +++ b/rebar.config @@ -13,7 +13,7 @@ [iot, sasl]}, - {mode, dev}, + % {mode, dev}, %% automatically picked up if the files %% exist but can be set manually, which