Documentation
¶
Overview ¶
Package repo 本文件是提供设备模型数据存储的信息
Index ¶
Constants ¶
View Source
const ( TypeProperty = "property" //事件-操作类型:属性或信息上报(Topic:$thing/up/property/{ProductID}/{DeviceName}) TypeEvent = "event" //事件-操作类型:事件上报(Topic:$thing/up/event/{ProductID}/{DeviceName}) TypeAction = "action" //事件-操作类型:行为上报(Topic:$thing/up/action/{ProductID}/{DeviceName}) EventReport = "report" //设备上报的信息 EventInfo = "info" //信息 EventAlert = "alert" //告警 EventFault = "fault" //故障 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeviceBasicInfo ¶ added in v0.5.1
type DeviceBasicInfo struct {
devices.Core
Imei string `json:"imei,omitempty"` //设备的 IMEI 号信息,非必填项
Mac string `json:"mac,omitempty"` //设备的 MAC 信息,非必填项
Version string `json:"version,omitempty"` //固件版本
HardInfo string `json:"hardInfo,omitempty"` //模组具体硬件型号
SoftInfo string `json:"softInfo,omitempty"` //模组软件版本
Position *def.Point `json:"position,omitempty"` //设备基础信息-坐标信息
Tags map[string]string `json:"tags,omitempty"` //设备标签信息
}
设备基础信息
type EventData ¶
type EventData struct {
Identifier string `json:"identifier"` //标识符
Type string `json:"type" ` //事件类型: 信息:info 告警alert 故障:fault
Params map[string]any `json:"params" ` //事件参数
TimeStamp time.Time `json:"timeStamp" ` //时间戳
}
EventData 事件数据
type FilterOpt ¶
type FilterOpt struct {
Page def.PageInfo2
ProductID string
DeviceNames []string
DataID string
Types []string //事件类型: 信息:info 告警alert 故障:fault
Order int32 //0:aes(默认,从久到近排序) 1:desc(时间从近到久排序)
Interval int64 //间隔(单位毫秒) 如果这个值不为零值 则时间的开始和结束必须有效及聚合函数不应该为空
Fill string //指定窗口区间数据缺失的情况下的填充模式
ArgFunc string //聚合函数 avg:平均值 first:第一个参数 last:最后一个参数 count:总数 twa: 时间加权平均函数 参考:https://docs.taosdata.com/taos-sql/function
}
FILL 语句指定某一窗口区间数据缺失的情况下的填充模式。填充模式包括以下几种: 不进行填充:NONE(默认填充模式)。 VALUE 填充:固定值填充,此时需要指定填充的数值。例如:FILL(VALUE, 1.23)。这里需要注意,最终填充的值受由相应列的类型决定,如 FILL(VALUE, 1.23),相应列为 INT 类型,则填充值为 1。 PREV 填充:使用前一个非 NULL 值填充数据。例如:FILL(PREV)。 NULL 填充:使用 NULL 填充数据。例如:FILL(NULL)。 LINEAR 填充:根据前后距离最近的非 NULL 值做线性插值填充。例如:FILL(LINEAR)。 NEXT 填充:使用下一个非 NULL 值填充数据。例如:FILL(NEXT)。
type LatestFilter ¶ added in v0.4.1
type Param ¶
type Param struct {
Identifier string `json:"identifier"` //标识符
Name string `json:"name"` //功能名称
Desc string `json:"gesc"` //描述
Mode schema.PropertyMode `json:"mode"` //读写乐行:rw(可读可写) r(只读)
Required bool `json:"required"` //是否必须
Type schema.EventType `json:"type"` //事件类型: 信息:info 告警alert 故障:fault
Value struct {
Type schema.DataType `json:"type"` //参数类型:bool int string struct float timestamp array enum
Mapping map[string]string `json:"mapping,omitempty"` //枚举及bool类型:bool enum
Min string `json:"min,omitempty"` //数值最小值:int string float
Max string `json:"max,omitempty"` //数值最大值:int string float
Start string `json:"start,omitempty"` //初始值:int float
Step string `json:"step,omitempty"` //步长:int float
Unit string `json:"unit,omitempty"` //单位:int float
Value any `json:"value"`
} `json:"value"` //数据定义
}
func (*Param) SetByDefine ¶ added in v0.5.1
type PropertyData ¶
type PropertyData struct {
Identifier string `json:"identifier"` //标识符
Param any `json:"property" ` //一个属性的参数
TimeStamp time.Time `json:"timeStamp" ` //时间戳
}
PropertyData 属性数据
func (PropertyData) String ¶ added in v0.4.1
func (p PropertyData) String() string
type Req ¶
type Req struct {
deviceMsg.CommonMsg
Params map[string]any `json:"params,omitempty"` //参数列表
Identifiers []string `json:"identifiers,omitempty"` //内为希望设备上报的属性列表,不填为获取全部
Version string `json:"version,omitempty"` //协议版本,默认为1.0。
EventID string `json:"eventId,omitempty"` //事件的 Id,在数据模板事件中定义。
ActionID string `json:"actionId,omitempty"` //数据模板中的行为标识符,由开发者自行根据设备的应用场景定义
Type string `json:"type,omitempty"` //表示获取什么类型的信息(report:表示设备上报的信息 info:信息 alert:告警 fault:故障)
}
func (*Req) FmtReqParam ¶ added in v0.5.1
type Resp ¶
type SchemaDataRepo ¶
type SchemaDataRepo interface {
// InsertEventData 插入事件数据
InsertEventData(ctx context.Context, productID string, deviceName string, event *EventData) error
// InsertPropertyData 插入一条属性数据
InsertPropertyData(ctx context.Context, t *schema.Model, productID string, deviceName string, property *PropertyData) error
// InsertPropertiesData 插入多条属性数据 params key为属性的id,val为属性的值
InsertPropertiesData(ctx context.Context, t *schema.Model, productID string, deviceName string, params map[string]any, timestamp time.Time) error
// GetEventDataWithID 根据事件id获取事件信息
GetEventDataByFilter(ctx context.Context, filter FilterOpt) ([]*EventData, error)
GetEventCountByFilter(ctx context.Context, filter FilterOpt) (int64, error)
// GetPropertyDataByID 根据属性id获取属性信息
GetPropertyDataByID(ctx context.Context, filter FilterOpt) ([]*PropertyData, error)
GetLatestPropertyDataByID(ctx context.Context, filter LatestFilter) (*PropertyData, error)
GetPropertyCountByID(ctx context.Context, filter FilterOpt) (int64, error)
}
Click to show internal directories.
Click to hide internal directories.