Documentation
¶
Overview ¶
Package scene 执行动作
Package scene 执行动作 ¶
Package scene 触发条件 ¶
Package scene 触发器
Index ¶
- Constants
- func TermCompareAll[dt constraints.Ordered](t CmpType, data dt, values []dt) bool
- type Action
- type ActionAlarm
- type ActionAlarmMode
- type ActionDevice
- type ActionDeviceType
- type ActionExecutor
- type ActionRepo
- type Actions
- type AlarmRelieve
- type AlarmRepo
- type CmpType
- type ColumnSchema
- type DeviceOperationOperator
- type DeviceRepo
- type DeviceSelector
- type FindWithTriggerDto
- type Info
- type InfoFilter
- type Infos
- type OperationSchema
- type Repo
- type Serial
- type StateKeep
- type StateKeepType
- type Term
- type TermColumnType
- type TermConditionType
- type TermRepo
- type Terms
- type TimeRange
- type TimeUnit
- type Timer
- type Trigger
- type TriggerDevice
- type TriggerDevices
- type TriggerSerial
- type TriggerType
- type UnitTime
Constants ¶
View Source
const ( StateKeepTypeDuration = "duration" StateKeepTypeRepeating = "repeating" )
Variables ¶
This section is empty.
Functions ¶
func TermCompareAll ¶ added in v0.4.1
func TermCompareAll[dt constraints.Ordered](t CmpType, data dt, values []dt) bool
Types ¶
type Action ¶
type Action struct { Executor ActionExecutor `json:"executor"` //执行器类型 notify: 通知 delay:延迟 device:设备输出 alarm: 告警 Delay *UnitTime `json:"delay"` Alarm *ActionAlarm `json:"alarm"` Device *ActionDevice `json:"device"` }
type ActionAlarm ¶
type ActionAlarm struct {
Mode ActionAlarmMode `json:"mode"` //告警模式 trigger: 触发告警 relieve: 解除告警
}
func (*ActionAlarm) Execute ¶ added in v0.4.1
func (a *ActionAlarm) Execute(ctx context.Context, repo ActionRepo) error
func (*ActionAlarm) Validate ¶
func (a *ActionAlarm) Validate() error
type ActionAlarmMode ¶
type ActionAlarmMode string
const ( ActionAlarmModeTrigger ActionAlarmMode = "trigger" ActionAlarmModeRelieve ActionAlarmMode = "relieve" )
type ActionDevice ¶ added in v0.4.1
type ActionDevice struct { ProductID string `json:"productID"` //产品id Selector DeviceSelector `json:"selector"` //设备选择方式 fixed:指定的设备 SelectorValues []string `json:"selectorValues"` //选择的列表 选择的列表, fixed类型是设备名列表 Type ActionDeviceType `json:"type"` // 云端向设备发起属性控制: propertyControl 应用调用设备行为:action todo:通知设备上报 DataID string `json:"dataID"` // 属性的id及事件的id Value string `json:"value"` //传的值 }
func (*ActionDevice) Execute ¶ added in v0.4.1
func (a *ActionDevice) Execute(ctx context.Context, repo ActionRepo) error
func (*ActionDevice) Validate ¶ added in v0.4.1
func (a *ActionDevice) Validate() error
type ActionDeviceType ¶ added in v0.4.1
type ActionDeviceType string
const ( ActionDeviceTypePropertyControl ActionDeviceType = "propertyControl" ActionDeviceTypeAction ActionDeviceType = "action" )
type ActionExecutor ¶
type ActionExecutor string
操作执行器类型
const ( ActionExecutorNotify ActionExecutor = "notify" //通知 ActionExecutorDelay ActionExecutor = "delay" //延迟 ActionExecutorDevice ActionExecutor = "device" //设备输出 ActionExecutorAlarm ActionExecutor = "alarm" //告警 )
type ActionRepo ¶ added in v0.4.1
type ActionRepo struct { DeviceInteract deviceinteract.DeviceInteract DeviceM devicemanage.DeviceManage Alarm AlarmRepo Device devices.Core Serial Serial Scene *Info }
type Actions ¶
type Actions []*Action
type AlarmRelieve ¶ added in v0.4.1
type AlarmRepo ¶ added in v0.4.1
type AlarmRepo interface { //告警触发 AlarmTrigger(ctx context.Context, in TriggerSerial) error //告警解除 AlarmRelieve(ctx context.Context, in AlarmRelieve) error }
type ColumnSchema ¶ added in v0.4.1
type ColumnSchema struct { ProductID string `json:"productID"` //产品id DeviceName string `json:"deviceName"` DataID []string `json:"dataID"` //属性的id及事件的id aa.bb.cc TermType CmpType `json:"termType"` //动态条件类型 eq: 相等 not:不相等 btw:在xx之间 gt: 大于 gte:大于等于 lt:小于 lte:小于等于 in:在xx值之间 Values []string `json:"values"` //条件值 参数根据动态条件类型会有多个参数 }
ColumnSchema 物模型类型 属性,事件
func (*ColumnSchema) IsHit ¶ added in v0.4.1
func (c *ColumnSchema) IsHit(ctx context.Context, columnType TermColumnType, repo TermRepo) bool
func (*ColumnSchema) Validate ¶ added in v0.4.1
func (c *ColumnSchema) Validate() error
type DeviceOperationOperator ¶
type DeviceOperationOperator string
const ( DeviceOperationOperatorConnected DeviceOperationOperator = "connected" DeviceOperationOperatorDisConnected DeviceOperationOperator = "disConnected" DeviceOperationOperatorReportProperty DeviceOperationOperator = "reportProperty" )
type DeviceRepo ¶ added in v0.4.1
type DeviceSelector ¶ added in v0.4.1
type DeviceSelector string
const ( DeviceSelectorAll DeviceSelector = "all" DeviceSelectorFixed DeviceSelector = "fixed" )
type FindWithTriggerDto ¶ added in v0.4.1
type Info ¶
type Info struct { ID int64 `json:"id"` Name string `json:"name"` Desc string `json:"desc"` CreatedTime time.Time `json:"createdTime"` TriggerType TriggerType `json:"triggerType"` //触发类型 device: 设备触发 timer: 定时触发 manual:手动触发 Trigger Trigger `json:"trigger"` //多种触发方式 When Terms `json:"when"` Then Actions `json:"then"` Status int64 `json:"state"` // 状态(1启用 2禁用) }
type InfoFilter ¶
type InfoFilter struct { Name string `json:"name"` Status int64 TriggerType TriggerType AlarmID int64 //绑定的告警id }
type OperationSchema ¶ added in v0.4.1
type OperationSchema struct { DataID []string `json:"dataID"` //选择为属性或事件时需要填该字段 属性的id及事件的id aa.bb.cc TermType CmpType `json:"termType"` //动态条件类型 eq: 相等 not:不相等 btw:在xx之间 gt: 大于 gte:大于等于 lt:小于 lte:小于等于 in:在xx值之间 Values []string `json:"values"` //比较条件列表 StateKeep *StateKeep `json:"stateKeep"` //状态保持 todo }
func (*OperationSchema) IsHit ¶ added in v0.4.1
func (o *OperationSchema) IsHit(dataID string, param application.ParamValue) bool
func (*OperationSchema) Validate ¶ added in v0.4.1
func (o *OperationSchema) Validate() error
type Repo ¶
type Repo interface { Insert(ctx context.Context, info *Info) (id int64, err error) Update(ctx context.Context, info *Info) error Delete(ctx context.Context, id int64) error FindOne(ctx context.Context, id int64) (*Info, error) FindOneByName(ctx context.Context, name string) (*Info, error) FindByFilter(ctx context.Context, filter InfoFilter, page *def.PageInfo) (Infos, error) CountByFilter(ctx context.Context, filter InfoFilter) (size int64, err error) }
type StateKeep ¶ added in v0.4.1
type StateKeep struct { Type StateKeepType `json:"type"` //持续时间: duration 重复次数 repeating Value int64 `json:"value"` //持续的时间或重复的次数 Unit TimeUnit `json:"unit"` //时间单位 second:秒 minute:分钟 hour:小时 week:星期 month:月 }
StateKeep 状态保持
type StateKeepType ¶ added in v0.4.1
type StateKeepType string
func (StateKeepType) Validate ¶ added in v0.4.1
func (s StateKeepType) Validate() error
type Term ¶
type Term struct { ColumnType TermColumnType `json:"columnType"` //字段类型 property:属性 event:事件 sysTime:系统时间 ColumnSchema *ColumnSchema `json:"columnSchema"` //物模型类型 ColumnTime *TimeRange `json:"columnTime"` //时间类型 只支持后面几种特殊字符:* - , NextCondition TermConditionType `json:"netCondition"` //和下个条件的关联类型 or and ChildrenCondition TermConditionType `json:"childrenCondition"` //和嵌套条件的关联类型 or and Terms Terms `json:"terms"` //嵌套条件 }
type TermColumnType ¶
type TermColumnType string
const ( TermColumnTypeProperty TermColumnType = "property" TermColumnTypeEvent TermColumnType = "event" //TermColumnTypeReportTime TermColumnType = "reportTime" TermColumnTypeSysTime TermColumnType = "sysTime" )
func (TermColumnType) Validate ¶ added in v0.4.1
func (t TermColumnType) Validate() error
type TermConditionType ¶
type TermConditionType string
const ( TermConditionTypeOr TermConditionType = "or" TermConditionTypeAnd TermConditionType = "and" )
type TimeRange ¶ added in v0.4.1
type TimeRange struct { Type string `json:"type"` //时间类型 cron Cron string `json:"cron"` // cron表达式 }
TimeRange 时间范围 只支持后面几种特殊字符:* - ,
type Trigger ¶
type Trigger struct { Device TriggerDevices `json:"device"` Timer *Timer `json:"timer"` }
func (*Trigger) Validate ¶
func (t *Trigger) Validate(triggerType TriggerType) error
type TriggerDevice ¶
type TriggerDevice struct { ProductID string `json:"productID"` //产品id Selector DeviceSelector `json:"selector"` //设备选择方式 all: 全部 fixed:指定的设备 SelectorValues []string `json:"selectorValues"` //选择的列表 选择的列表, fixed类型是设备名列表 Operator DeviceOperationOperator `json:"operator"` //触发类型 connected:上线 disConnected:下线 reportProperty:属性上报 reportEvent: 事件上报 OperationSchema *OperationSchema `json:"operationSchema"` //物模型类型的具体操作 reportProperty:属性上报 reportEvent: 事件上报 }
func (*TriggerDevice) Validate ¶
func (t *TriggerDevice) Validate() error
type TriggerDevices ¶ added in v0.4.1
type TriggerDevices []*TriggerDevice
func (TriggerDevices) IsTriggerWithConn ¶ added in v0.4.1
func (t TriggerDevices) IsTriggerWithConn(device devices.Core, operator DeviceOperationOperator) bool
IsTrigger 判断触发器是否命中
func (TriggerDevices) IsTriggerWithProperty ¶ added in v0.4.1
func (t TriggerDevices) IsTriggerWithProperty(reportInfo *application.PropertyReport) bool
IsTrigger 判断触发器是否命中属性上报类型
func (TriggerDevices) Validate ¶ added in v0.4.1
func (t TriggerDevices) Validate() error
type TriggerSerial ¶ added in v0.4.1
type TriggerType ¶
type TriggerType string
const ( TriggerTypeDevice TriggerType = "device" TriggerTypeTimer TriggerType = "timer" TriggerTypeManual TriggerType = "manual" )
Click to show internal directories.
Click to hide internal directories.