123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- package models
- import (
- "errors"
- "github.com/jinzhu/gorm"
- )
- // Device device model
- // device is a product instance, which is managed by our platform
- type Device struct {
- gorm.Model
- RecordId string `gorm:"column:record_id;size:32;index"`
- // which product the device belongs to
- ProductID string `gorm:"column:product_id;size:32;index"`
- // universal device identifier, generated from vendorid-productid-deviceserial
- DeviceIdentifier string `sql:"type:varchar(200);not null;unique;key"`
- // device secret which is auto generated by the platform
- DeviceSecret string `sql:"type:varchar(200);not null;"`
- // device key is used to auth a device
- DeviceKey string `sql:"type:varchar(200);not null;key;"`
- // device name
- DeviceName string `sql:"type:varchar(200);not null;"`
- // device desc
- DeviceDescription string `sql:"type:text;not null;"`
- // device version(the agent version)
- DeviceVersion string `sql:"type:text;not null;"`
- // vendor id
- VendorID string `gorm:"column:vendor_id;size:32;index"`
- //通讯模组名称
- ModuleName string
- }
- // DeviceQuery device query
- type DeviceQuery struct {
- Device
- ProductName string
- }
- // Devices
- type Devices struct {
- Device
- Status int
- }
- // DeviceChartData 设备数据图表
- type DeviceChartData struct {
- Dt string
- Count int
- }
- type UpgradeParams struct {
- VendorID string `json:"vendor_id"`
- DeviceID string `json:"device_id"`
- File []byte `json:"file"`
- FileName string `json:"file_name"`
- FileSize int64 `json:"file_size"`
- }
- // Validate 验证
- func (a *UpgradeParams) Validate() error {
- if a.DeviceID == "" {
- return errors.New("非法参数[DeviceID, Label]")
- }
- return nil
- }
- type Command string
- const (
- Report Command = "report" // 获取设备状态
- Restart Command = "restart" // 重启设备
- ClearData Command = "clearData" // 清除设备配置数据
- SetDataTrans Command = "setDataTrans" // 设备端自动上报配置
- GetInfo Command = "getInfo" // 获取网关信息(分控)
- ForceRun Command = "forceRun" // 远程控制某个模块强制运行
- SetDeviceId Command = "setDeviceId" // 写入设备 ID
- SetFjsqStatus Command = "setFjsqStatus" // 智能分集水器控制
- SetOutdoorPower Command = "setOutdoorPower" // 设置水系统外机电源状态
- SetOutdoorTemp Command = "setOutdoorTemp" // 设置水系统外机出水温度
- )
- type SendCommandParams struct {
- DeviceId string `json:"device_id"`
- Enable int `json:"enable"` // 是否启用(0:禁用,1:启用)
- Internal int `json:"internal"` // 间隔时间,单位:秒,范围:30~180,默认:30秒
- Module int `json:"module"` // 对应模块(1:新风模块2:加湿模块)
- ModulePower int `json:"module_power"` // 电源状态,1:开启,2关闭
- Id int `json:"id"` // 长度12个字节,如 YHK-16777216
- Prefix string `json:"prefix"` // 字符串
- Num int `json:"num"` // 1-8 对应1-8路电热执行器
- NumPower int `json:"num_power"` // 1:开启,0:关闭
- OutdoorPower int `json:"outdoor_power"` // 1:开启,0:关闭
- CoolModeTemp int `json:"cool_mode_temp"` // 制冷模式出水温度,0:代表不设置
- HeatModeTemp int `json:"heat_mode_temp"` // 制热模式出水温度,0:代表不设置
- }
- // Validate 验证
- func (a *SendCommandParams) Validate() error {
- if a.DeviceId == "" {
- return errors.New("非法参数[DeviceID, Label]")
- }
- return nil
- }
- type SplitDeviceStatus struct {
- Power int `json:"power"`
- Mode int `json:"mode"`
- FanSpeed int `json:"fan_speed"`
- SetTemp int `json:"set_temp"`
- EnvTemp int `json:"env_temp"`
- EnvHumidity int `json:"env_humidity"`
- EnvCo2 int `json:"env_co2"`
- EnvPm25 int `json:"env_pm25"`
- StatusCode int `json:"status_code"`
- StatusCodeMap map[string]int `json:"status_code_map"`
- AirMode int `json:"air_mode"`
- AcType int `json:"ac_type"`
- AirType int `json:"air_type"`
- HumType int `json:"hum_type"`
- }
|