Documentation
¶
Index ¶
- func DynamicRuleFunctions(m *MockRuntimeInfo) map[string]govaluate.ExpressionFunction
- func NewRuleExpressionParameters() map[string]interface{}
- type ComplexRuleItem
- type MockDataRule
- type MockDeviceCtrOption
- type MockDeviceTree
- type MockDeviceTreeConfig
- type MockDeviceTreeNode
- type MockRuntimeInfo
- type RandRuleItem
- type RuleCalcExtendParams
- type RuleFunctions
- func (rfs RuleFunctions) Float64(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) FloatValueFromFile(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) Int64(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) IntValueFromFile(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) KeyFloat64(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) KeyInt64(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) Rand(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) RandSeed(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) Sample(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) Timestamp(args ...interface{}) (interface{}, error)
- func (rfs RuleFunctions) ValueFromFile(args ...interface{}) (interface{}, error)
- type SampleRuleItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DynamicRuleFunctions ¶
func DynamicRuleFunctions(m *MockRuntimeInfo) map[string]govaluate.ExpressionFunction
func NewRuleExpressionParameters ¶
func NewRuleExpressionParameters() map[string]interface{}
Types ¶
type ComplexRuleItem ¶
type ComplexRuleItem struct {
Index int64 //序列值,从1开始,自动生成
Execs int64 //执行次数
Names []string `json:"names"` //命中名称
Condition string `json:"condition"` //执行条件
Expression string `json:"expression"` //计算公式
}
ComplexRuleItem 复杂规则
func (*ComplexRuleItem) GetData ¶
func (r *ComplexRuleItem) GetData(key string, value interface{}, params RuleCalcExtendParams) (interface{}, bool)
type MockDataRule ¶
type MockDataRule struct {
WhiteList []string `json:"whiteList"` //白名单,在白名单中的才可上传,空表示不限制
SampleRules map[string]*SampleRuleItem `json:"sample_rules"` //规则-随机取样本值
RandRules map[string]*RandRuleItem `json:"rand_rules"` //规则-取随机一个值
ComplexRules []*ComplexRuleItem `json:"complex_rules"` //复杂规则
WhiteMap map[string]bool `json:"-"`
}
MockDataRule 模拟仿真数据规则配置 目前暂不支持并发下处理
func NewMockDataRule ¶
func NewMockDataRule(s string) MockDataRule
func NewMockDataRuleFromFile ¶
func NewMockDataRuleFromFile(file string) MockDataRule
func TestMockDataRule ¶
func TestMockDataRule() MockDataRule
func (MockDataRule) GetData ¶
func (r MockDataRule) GetData(key string, value interface{}, params RuleCalcExtendParams) (interface{}, bool)
GetData 获取值
key=对应字段名,value=默认值 params,额外的计算参数 返回值: 对应值,是否需要使用
type MockDeviceCtrOption ¶
type MockDeviceCtrOption struct {
ThingModel string `json:"thing_model"` //指定物模型,空则取全局配置
DataRule string `json:"data_rule"` //指定数据规则,空则取全局配置
ReportProperty bool `json:"report_property"` //是否上报属性
ReportEvent bool `json:"report_event"` //是否上报事件
ReportOnline bool `json:"report_online"` //是否上报在线状态
}
func MergeMockDeviceCtrOption ¶
func MergeMockDeviceCtrOption(p1, p2 MockDeviceCtrOption) MockDeviceCtrOption
type MockDeviceTree ¶
type MockDeviceTree []*MockDeviceTreeNode
MockDeviceTree 模拟仿真用设备树信息
func (MockDeviceTree) Find ¶
func (tree MockDeviceTree) Find(id string) *MockDeviceTreeNode
Find 找节点
func (MockDeviceTree) Lookup ¶
func (tree MockDeviceTree) Lookup(f func(*MockDeviceTreeNode, *MockDeviceTreeNode, int))
Lookup 遍历树,f(parent,current,level)
type MockDeviceTreeConfig ¶
type MockDeviceTreeConfig struct {
Devices MockDeviceTree `json:"devices"`
ProductTypeCtr map[string]MockDeviceCtrOption `json:"product_type_ctr"` //产品类型对应控制内容
// contains filtered or unexported fields
}
MockDeviceTreeConfig 设备数配置
func NewMockDeviceTree ¶
func NewMockDeviceTree(s string) MockDeviceTreeConfig
func TestMockDeviceTree ¶
func TestMockDeviceTree() MockDeviceTreeConfig
func (MockDeviceTreeConfig) GetDeviceNode ¶
func (c MockDeviceTreeConfig) GetDeviceNode(deviceId string) (*MockDeviceTreeNode, bool)
type MockDeviceTreeNode ¶
type MockDeviceTreeNode struct {
DeviceId string `json:"device_id"` //设备id
DeviceName string `json:"device_name"` //设备名称
ProductType string `json:"product_type"` //设备类型
MockDeviceCtrOption //控制可选项
Children MockDeviceTree `json:"children"` // 子设备
}
type RandRuleItem ¶
type RandRuleItem struct {
Min float64 `json:"min"`
Max float64 `json:"max"`
Step float64 `json:"step"`
}
RandRuleItem 随机取值规则
func (RandRuleItem) GetData ¶
func (r RandRuleItem) GetData(key string, value interface{}, params RuleCalcExtendParams) (interface{}, bool)
type RuleCalcExtendParams ¶
type RuleCalcExtendParams map[string]interface{}
func MergeCalcExtendParams ¶
func MergeCalcExtendParams(ps ...RuleCalcExtendParams) RuleCalcExtendParams
MergeCalcExtendParams 合并计算扩展参数
type RuleFunctions ¶
type RuleFunctions struct {
}
func (RuleFunctions) Float64 ¶
func (rfs RuleFunctions) Float64(args ...interface{}) (interface{}, error)
Float64 转为float64
func (RuleFunctions) FloatValueFromFile ¶
func (rfs RuleFunctions) FloatValueFromFile(args ...interface{}) (interface{}, error)
func (RuleFunctions) Int64 ¶
func (rfs RuleFunctions) Int64(args ...interface{}) (interface{}, error)
Int64 转为int64
func (RuleFunctions) IntValueFromFile ¶
func (rfs RuleFunctions) IntValueFromFile(args ...interface{}) (interface{}, error)
func (RuleFunctions) KeyFloat64 ¶
func (rfs RuleFunctions) KeyFloat64(args ...interface{}) (interface{}, error)
func (RuleFunctions) KeyInt64 ¶
func (rfs RuleFunctions) KeyInt64(args ...interface{}) (interface{}, error)
func (RuleFunctions) Rand ¶
func (rfs RuleFunctions) Rand(args ...interface{}) (interface{}, error)
Rand 完全随机值, args子项含义依次为: min,max,step
func (RuleFunctions) RandSeed ¶
func (rfs RuleFunctions) RandSeed(args ...interface{}) (interface{}, error)
RandSeed 根据种子进行随机数, args子项含义依次为: min,max,step,seed
func (RuleFunctions) Sample ¶
func (rfs RuleFunctions) Sample(args ...interface{}) (interface{}, error)
func (RuleFunctions) Timestamp ¶
func (rfs RuleFunctions) Timestamp(args ...interface{}) (interface{}, error)
Timestamp 返回当前秒级时间戳,args子项含义一次为:offset(可不填)
func (RuleFunctions) ValueFromFile ¶
func (rfs RuleFunctions) ValueFromFile(args ...interface{}) (interface{}, error)
type SampleRuleItem ¶
type SampleRuleItem []interface{}
SampleRuleItem 样本随机规则
func (SampleRuleItem) GetData ¶
func (r SampleRuleItem) GetData(key string, value interface{}, params RuleCalcExtendParams) (interface{}, bool)
Click to show internal directories.
Click to hide internal directories.