Documentation
¶
Overview ¶
Package task 设备场景任务运行模块;接收,编排,运行场景任务 task.Manager 启动会加载 scene,包装成 Task,并且加入优先级队列,然后设定每天 23:55:00 进行第二天任务编排 scene 对应的 Task 运行时,会将对应 scene task 包装成 Task,并且加入优先级队列
Index ¶
- func DeviceStateChange(em event.EventMessage) error
- func IsConditionSatisfied(condition entity.SceneCondition) bool
- func IsConditionsSatisfied(scene entity.Scene, isTrigByTimer bool) bool
- func IsInTimePeriod(scene entity.Scene) bool
- func SetManager(m Manager)
- type LocalManager
- func (m *LocalManager) AddSceneTask(scene entity.Scene)
- func (m *LocalManager) AddSceneTaskWithTime(scene entity.Scene, t time.Time)
- func (m *LocalManager) DeleteSceneTask(sceneID int)
- func (m *LocalManager) DeviceStateChange(d entity.Device, attr entity.Attribute) error
- func (m *LocalManager) RestartSceneTask(sceneID int) error
- func (m *LocalManager) Run(ctx context.Context)
- type Manager
- type Task
- type TaskFunc
- type WrapperFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeviceStateChange ¶ added in v1.9.1
func DeviceStateChange(em event.EventMessage) error
func IsConditionSatisfied ¶
func IsConditionSatisfied(condition entity.SceneCondition) bool
IsConditionSatisfied 判断设备状态是否满足条件
func IsConditionsSatisfied ¶
IsConditionsSatisfied 场景条件是否满足 isTrigByTimer 是否由定时条件触发
func SetManager ¶
func SetManager(m Manager)
Types ¶
type LocalManager ¶
type LocalManager struct {
// contains filtered or unexported fields
}
LocalManager Task 服务
func NewLocalManager ¶
func NewLocalManager() *LocalManager
func (*LocalManager) AddSceneTask ¶
func (m *LocalManager) AddSceneTask(scene entity.Scene)
AddSceneTask 添加场景任务(执行或者开启时调用)
func (*LocalManager) AddSceneTaskWithTime ¶ added in v1.9.1
func (m *LocalManager) AddSceneTaskWithTime(scene entity.Scene, t time.Time)
func (*LocalManager) DeleteSceneTask ¶
func (m *LocalManager) DeleteSceneTask(sceneID int)
DeleteSceneTask 删除场景任务
func (*LocalManager) DeviceStateChange ¶
DeviceStateChange 设备状态变化触发场景
func (*LocalManager) RestartSceneTask ¶
func (m *LocalManager) RestartSceneTask(sceneID int) error
RestartSceneTask 重启场景对应的任务(就是删除然后重新添加任务)
type Manager ¶
type Manager interface { AddSceneTask(entity.Scene) DeleteSceneTask(sceneID int) RestartSceneTask(sceneID int) error DeviceStateChange(d entity.Device, attr entity.Attribute) error Run(ctx context.Context) }
func GetManager ¶
func GetManager() Manager
type Task ¶
type Task struct { ID string Value string // The Value of the item; arbitrary. Priority int64 // 使用 Parent *Task // 父任务 // contains filtered or unexported fields }
Task 将场景转化为任务
func (*Task) WithWrapper ¶
func (item *Task) WithWrapper(wrappers ...WrapperFunc) *Task
WithWrapper 设置 Wrapper
Click to show internal directories.
Click to hide internal directories.