|
|
@@ -21,47 +21,11 @@ type GetSceneParams struct {
|
|
|
}
|
|
|
|
|
|
type InfoScene struct {
|
|
|
- SceneId string `json:"scene_id"`
|
|
|
- Conditions []*Conditions `json:"conditions"`
|
|
|
- Actions []*Action `json:"actions"`
|
|
|
-}
|
|
|
-
|
|
|
-type Conditions struct {
|
|
|
- TaskId string `json:"task_id"`
|
|
|
- Times int `json:"times"` // 执行次数 -1 表示无限次
|
|
|
- Cron string `json:"cron"`
|
|
|
-
|
|
|
- Key string `json:"key"` // redis key
|
|
|
- DeviceType string `json:"device_type"` // 设备类型
|
|
|
- DeviceId string `json:"device_id"` // 设备id
|
|
|
- SubDeviceId string `json:"sub_device_id"` // 子设备id
|
|
|
- FieldType int `json:"field_type"` // 字段类型 1字符串 2数值
|
|
|
- Field string `json:"field"` // 字段名
|
|
|
- TargetValue string `json:"target_value"` // 值
|
|
|
- Operator int `json:"operator"` // 比较类型 数值比较 1 > 2 >= 3 = 4 <= 5 < 6 !=
|
|
|
-
|
|
|
- Location string `json:"location"` // 地点
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-type Action struct {
|
|
|
- DeviceID string `json:"device_id"` // 设备ID
|
|
|
- SubDeviceId string `json:"sub_device_id"` // 实体子设备Id,如果需要
|
|
|
- ActionExecutor string `json:"action_executor"` // 动作对象类型
|
|
|
- ExecutorProperty *TaskExecutorProperty `json:"executor_property"` // 动作执行明细
|
|
|
- PlcPubMessage *PlcPubMessage `json:"plc_pub_message"` // PLC消息
|
|
|
-}
|
|
|
-
|
|
|
-// TaskExecutorProperty 定时任务执行动作执行参数
|
|
|
-type TaskExecutorProperty struct {
|
|
|
- FunctionCode string `json:"function_code"`
|
|
|
- FunctionValue map[string]interface{} `json:"function_value"`
|
|
|
- DelaySeconds int64 `json:"delay_seconds"`
|
|
|
-}
|
|
|
-
|
|
|
-type PlcPubMessage struct {
|
|
|
- Topic string `json:"topic"`
|
|
|
- Payload []byte `json:"payload"`
|
|
|
+ Key string `json:"key"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Desc string `json:"desc"`
|
|
|
+ SceneId string `json:"scene_id"`
|
|
|
+ Config string `json:"config"`
|
|
|
}
|
|
|
|
|
|
type AllSceneResult struct {
|
|
|
@@ -70,8 +34,9 @@ type AllSceneResult struct {
|
|
|
}
|
|
|
type Info struct {
|
|
|
Key string `json:"key"`
|
|
|
+ Name string `json:"name"`
|
|
|
+ Desc string `json:"desc"`
|
|
|
SceneId string `json:"scene_id"`
|
|
|
- TaskId string `json:"task_id"`
|
|
|
Config string `json:"config"`
|
|
|
}
|
|
|
|
|
|
@@ -96,7 +61,7 @@ func NewSceneManager(host string, port int) *Manager {
|
|
|
}
|
|
|
|
|
|
func (a *Manager) SaveScene(info *Info) error {
|
|
|
- _, err := a.redisClient.DoVar("SET", info.Key, info.Config)
|
|
|
+ _, err := a.redisClient.DoVar("SET", info.Key, info)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|