common_models

package module
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 13 Imported by: 3

README

common_models 通用结构体模块

开发语言和版本

golang ,版本 go1.23.1

平台支持

安心云4.0

使用方式:
  1. 设置 go 环境
    set GOPRIVATE=gitea.anxinyun.cn
  2. 查询go 版本
    go list -m -versions gitea.anxinyun.cn/container/common_models
    如若 GOPRIVATE=gitea.anxinyun.cn 生效,则会返回 common_models 的版本信息。
    如若无版本信息返回,有可能是没有 container 的权限,也有可能环境变量设置没有生效。

异常情况处理:

  1. https://gitea.anxinyun.cn/container 访问权限,可以联系下管理员(刘歆毅)。
  2. 环境变量设置不生效
    解决方法,在GoLand工具中进行设置:
    1)打开 Settings
    2)Go > GOROOT,Download Go SDK
    3)Go > Go Modules,设置环境变量 GOPRIVATE=gitea.anxinyun.cn
依赖包管理

common_models 如若有修改,必须需要同步升级 common_utils、et-go

Documentation

Index

Constants

View Source
const (
	Iota_Alarm_Status_Resolved = "resolved"
	Iota_Alarm_Status_Firing   = "firing"
	Iota_Alarm_OutOfRange      = "OutOfRange"
	Iota_Alarm_LinkStatus      = "LinkStatus"

	Alarm_Mode_Generation = "AlarmGeneration"
	//自动恢复
	Alarm_Mode_AutoElimination = "AlarmAutoElimination"
	// 告警类型
	Alarm_Type_Dtu_LinkStatus   = "2001" // DTU下线
	Alarm_Type_Device_Status    = "3001"
	Alarm_Type_Timeout          = "3003"
	Alarm_Type_Data_Parse_Error = "3004"
	Alarm_Type_OutRange         = "3005"
	Alarm_Type_Data_Interupt    = "3006"
	// 超阈值
	Alarm_Type_Over_Threshold = "3007"
	// 变化速率超阈值
	Alarm_Type_Over_ChangeRate_Threshold = "3008"
	Alarm_Type_OutRange_Legacy           = "5001"

	// 告警码
	Alarm_Code_OutRange      = "30050001"
	Alarm_Code_OutRange_Iota = "5001"
	Alarm_Code_OffLine       = "20010001"

	// 告警源类型:DTU
	Alarm_Source_DTU = 0
	// 告警源类型: 设备
	Alarm_Source_Device = 1
	// 告警源类型: 测点
	Alarm_Source_Station = 2

	// 发起者: et-recv
	Alarm_Sponsor_Recv = "et.recv"

	// 发起者 et-analyze
	Alarm_Sponsor_Threshold = "et.analyze"
	Alarm_Sponsor_Operator  = "operator"
	// 智慧应用
	Alarm_Sponsor_SmartApp = "smart.app"

	// Alarm 缓存相关常量
	Alarm_Cache_Prefix     = "alarm"
	Alarm_Cache_Prefix_Agg = "AggThreshold"
	ALARM_SOURCE_DEVICE    = 1
	ALARM_SOURCE_STATION   = 2
)
View Source
const (
	RawTypeVib  = "vib"
	RawTypeDiag = "diag"
)
View Source
const (
	Filter_CalcMedian = 1 // 取中值

	Filter_LimitAmp = 2 // 限幅

	Filter_CalcMeanValue = 3 // 滑动平均

	Filter_CalcStvMean = 4 // 方差判断平均

	Filter_CalcWindow = 5 // 滤波算法

	Filter_ExtreAverage = 6 // 去极值移动平均

	Filter_WeightAverage = 7 // 加权滑动平均

	Filter_MedianMean = 8 // 中值平均

	Filter_RangeMean = 9 // 限幅平均

	Filter_Interrupt = 10 // 中断

	Filter_RandomReplacer = 9999 // 特殊算法: 数据替换
)
View Source
const (

	// 无公式
	FormulaType_None = 0

	// 振动
	FormulaType_vibCalc = 122

	// 爆破(三向)振动
	FormulaType_vibThreeCalc = 222

	// 振动索力识别公式
	FormulaType_cableRecognize = 120

	// 噪声
	FormulaType_vibNoise = 141

	// 动应变
	FormulaType_vibStrain = 148

	// 渗流计算
	FormulaType_seepage = 106

	// 应变花
	FormulaType_strainRosette = 207

	// 输电塔自动调平计算公式
	FormulaType_towerBalance = 212

	// 雷达物位计干滩计算公式
	FormulaType_radarDryBeach = 213

	// 单轴倾角仪测量双向角度
	FormulaType_comp2 = 214

	// 单向位移计测三向位移
	FormulaType_comp3 = 215

	// 进水量监测
	FormulaType_Inflow = 208

	// 流量/渗流量 计算
	FormulaType_Flow = 110

	// 管道轴向应力
	FormulaType_AxialStress = 216

	// 出水量计算
	FormulaType_Outflow = 136

	// 三角堰经验公式
	FormulaType_TriSeepageEmp = 137

	// 空气数据修正公式
	FormulaType_AirCorrect = 142

	// 插值计算
	FormulaType_Interpolation = 144

	// radar插值计算
	FormulaType_InterpolationRadar = 157
	// radar插值计算2 (初值-测值)
	FormulaType_InterpolationRadar2 = 158

	// 差异沉降倾斜率
	FormulaType_InclinationSlope = 221

	// 减除值,取极值
	FormulaType_DefaultMaxMin = 156

	// 雷达物位计干滩计算公式
	FormulaType_radarDryBeach2 = 224

	// 北斗星空支撑轴力公式1
	FormulaType_axialSupportForce1 = 261
	// 北斗星空支撑轴力公式2
	FormulaType_axialSupportForce2 = 262
	// 东江大桥应变温补公式
	FormulaType_strainCompensationByTemperature = 303
)

Variables

This section is empty.

Functions

func AlarmRedisKey

func AlarmRedisKey(sourceType int, sourceId string) string

AlarmRedisKey 格式:alarm:sourceType:sourceId, 如:alarm:2:100

func AlarmRedisKey_Agg

func AlarmRedisKey_Agg(structId int, factorId int) string

AlarmRedisKey_Agg 格式:AggThreshold:structId:factorId, 如:AggThreshold:1:106

Types

type AggData

type AggData struct {
	Date        time.Time
	SensorId    int
	StructId    int
	FactorId    int
	AggTypeId   int                // 聚集类型 : 10分钟/30分钟/3小时/6小时/12小时/时/日/周/月聚集
	AggMethodId int                // 聚集方法 : 平均值/最大值/最小值
	Agg         map[string]float64 // 聚集数据
	Changed     map[string]float64 // 变化量
	ThingId     string
}

func (*AggData) GetDeviceId added in v0.0.9

func (the *AggData) GetDeviceId() string

GetDeviceId 返回SensorId

func (*AggData) GetThingId added in v0.0.8

func (the *AggData) GetThingId() string

func (*AggData) Q added in v0.0.8

func (the *AggData) Q() string

func (*AggData) R added in v0.0.8

func (the *AggData) R() string

func (*AggData) T added in v0.0.8

func (the *AggData) T() time.Time

type AggThreshold

type AggThreshold struct {
	Items AggThresholdItems
}

AggThreshold 阈值模型

func (*AggThreshold) FindThresholdInRange

func (t *AggThreshold) FindThresholdInRange(items []AggThresholdItem, m float64) *AggThresholdItem

FindThresholdInRange 阈值判断

func (*AggThreshold) GetThresholdsByItem

func (t *AggThreshold) GetThresholdsByItem(items []AggThresholdItem, itemID int) []AggThresholdItem

GetThresholdsByItem 根据监测项ID获取阈值

func (*AggThreshold) GetThresholdsByTime

func (t *AggThreshold) GetThresholdsByTime(date time.Time) []AggThresholdItem

GetThresholdsByTime 根据时间获取阈值

type AggThresholdItem

type AggThresholdItem struct {
	Item        int     `json:"item"` // item -> t_factor_proto_item(id)
	FieldName   string  `json:"field_name"`
	Name        string  `json:"name"`
	Level       int     `json:"level"`
	Lower       float64 `json:"lower"`
	Upper       float64 `json:"upper"`
	Begin       *int    `json:"begin"`                  // 分时阈值起始时间(24小时制 0~24)
	End         *int    `json:"end"`                    // 分时阈值结束时间(24小时制 0~24)
	AggCategory *int    `json:"agg_category,omitempty"` // 在JSON编码时,如果此字段为空,则忽略该字段
	FuncType    *int    `json:"func_type,omitempty"`    // 在JSON编码时,如果此字段为空,则忽略该字段
}

AggThresholdItem 阈值项模型

func (*AggThresholdItem) IsTimeSegmented

func (t *AggThresholdItem) IsTimeSegmented() bool

func (*AggThresholdItem) RangeText

func (t *AggThresholdItem) RangeText() string

type AggThresholdItems

type AggThresholdItems []AggThresholdItem

AggThresholdItems 自定义类型,[]AggThresholdItem 的别名

func (*AggThresholdItems) MarshalBinary

func (t *AggThresholdItems) MarshalBinary() (data []byte, err error)

func (*AggThresholdItems) UnmarshalBinary

func (t *AggThresholdItems) UnmarshalBinary(data []byte) error

type Alarm

type Alarm struct {
	IsAlarm   bool
	Code      string
	AlarmType string
	Level     int
	Content   string
	Sponsor   string
}

func NewAlarmOverThreshold

func NewAlarmOverThreshold(level int, content string) *Alarm

NewAlarmOverThreshold 超阈值告警

func NewAlarmRecoverThreshold

func NewAlarmRecoverThreshold() *Alarm

NewAlarmRecoverThreshold 阈值恢复告警

func NewOverChangingRateThreshold

func NewOverChangingRateThreshold(level int, content string) *Alarm

NewOverChangingRateThreshold 变化速率超阈值告警

func NewRecoverChangingRateThreshold

func NewRecoverChangingRateThreshold() *Alarm

NewRecoverChangingRateThreshold 变化速率阈值恢复告警

func (*Alarm) ToAlarmMsg

func (a *Alarm) ToAlarmMsg(stationInfo StationInfo, acqTime time.Time) AlarmMsg

ToAlarmMsg 将测点信息 -> 告警信息

type AlarmCode

type AlarmCode struct {
	Id       int    `json:"id"`
	Code     string `json:"code"`
	Name     string `json:"name"`
	TypeCode string `json:"typeCode"`
	Level    int    `json:"level"`
}

func (*AlarmCode) MarshalBinary

func (m *AlarmCode) MarshalBinary() (data []byte, err error)

redis序列化

func (*AlarmCode) UnmarshalBinary

func (m *AlarmCode) UnmarshalBinary(data []byte) error

redis序列化

type AlarmMsg

type AlarmMsg struct {
	MessageMode   string         `json:"messageMode"`
	StructureId   int            `json:"structureId"`
	StructureName string         `json:"structureName"`
	SourceId      string         `json:"sourceId"`
	SourceName    string         `json:"sourceName"`
	AlarmTypeCode string         `json:"alarmTypeCode"`
	AlarmCode     string         `json:"alarmCode"`
	Content       string         `json:"content"`
	AcqTime       time.Time      `json:"time"`
	SourceTypeId  int            `json:"sourceTypeId"` // 0:DTU, 1:传感器, 2:测点
	Sponsor       string         `json:"sponsor"`      // 消息的发起者 "et.recv"
	Extras        map[string]any `json:"extras"`
	SubDevices    []string       `json:"subDevices"`
}

type AnalyzeData

type AnalyzeData struct {
	Raw     float64 `json:"raw"`
	IsValid bool    `json:"isValid"`
	Data    float64 `json:"data"`
}

type Annotations

type Annotations struct {
	Summary     string `json:"summary"`
	Description string `json:"description"`
}

type CacheWinSave

type CacheWinSave struct {
	*CacheWindow
	AllData []AnalyzeData `json:"allData"`
}

type CacheWindow

type CacheWindow struct {
	Id string

	WindowSize  int    //窗体大小
	MethodId    int    //滑窗方法
	CreatReason string //创建原因
	LatestData  any

	Params FilterParams
	//过期控制
	Expire expirationInfo
	// contains filtered or unexported fields
}

CacheWindow 存储大量测点缓存数据

func NewCacheWindow

func NewCacheWindow(id string, size, methodId int, params FilterParams, creatReason string) CacheWindow

func (*CacheWindow) CheckExpiration

func (c *CacheWindow) CheckExpiration() bool

func (*CacheWindow) DeQueue

func (c *CacheWindow) DeQueue() any

func (*CacheWindow) DeQueueAll

func (c *CacheWindow) DeQueueAll() []any

func (*CacheWindow) DeQueueAllAnalyzeData

func (c *CacheWindow) DeQueueAllAnalyzeData() []AnalyzeData

func (*CacheWindow) DeQueueAllData

func (c *CacheWindow) DeQueueAllData() ([]float64, bool)

func (*CacheWindow) DeQueueAllRaw

func (c *CacheWindow) DeQueueAllRaw() ([]float64, bool)

func (*CacheWindow) EnQueue

func (c *CacheWindow) EnQueue(d any)

func (*CacheWindow) EnQueueAnalyzeData

func (c *CacheWindow) EnQueueAnalyzeData(d AnalyzeData)

func (*CacheWindow) Latest

func (c *CacheWindow) Latest() any

func (*CacheWindow) LatestByAnalyzeData

func (c *CacheWindow) LatestByAnalyzeData() (AnalyzeData, bool)

func (*CacheWindow) LatestByRange

func (c *CacheWindow) LatestByRange(size int) []any

func (*CacheWindow) Len

func (c *CacheWindow) Len() int

Len 获取窗口里有效长度(数据数量)

func (*CacheWindow) MarshalBinary

func (c *CacheWindow) MarshalBinary() (data []byte, err error)

redis序列化

func (*CacheWindow) ReInitialRing

func (c *CacheWindow) ReInitialRing()

func (*CacheWindow) Size

func (c *CacheWindow) Size() int

func (*CacheWindow) ToSaveCache

func (c *CacheWindow) ToSaveCache() CacheWinSave

func (*CacheWindow) UnmarshalBinary

func (c *CacheWindow) UnmarshalBinary(data []byte) error

redis序列化

type CorrItemData added in v0.0.8

type CorrItemData struct {
	StationId   int                    `json:"station_id"`
	StationName string                 `json:"station_name"`
	IsBase      *bool                  `json:"is_base,omitempty"`
	PhyData     map[string]interface{} `json:"phy_data"`
	ThemeData   map[string]interface{} `json:"theme_data"`
}

级联测点数据

type Data

type Data struct {
	Type   int            `json:"type"`
	Data   map[string]any `json:"data"`
	Result struct {
		Code     int    `json:"code"`
		Msg      string `json:"msg"`
		Detail   string `json:"detail"`
		ErrTimes int    `json:"errTimes"`
		Dropped  bool   `json:"dropped"`
	} `json:"result"`
}

func (*Data) Success

func (the *Data) Success() bool

type DataUnit

type DataUnit struct {
	Name        string      `json:"name"`
	Dimension   string      `json:"dimension"`
	Description string      `json:"description"`
	Coef        float64     `json:"coef"`
	Base        bool        `json:"base"`
	Alternative interface{} `json:"alternative"`
}

type DataUnitArray

type DataUnitArray []DataUnit

func (*DataUnitArray) MarshalBinary

func (m *DataUnitArray) MarshalBinary() (data []byte, err error)

redis序列化

func (*DataUnitArray) UnmarshalBinary

func (m *DataUnitArray) UnmarshalBinary(data []byte) error

redis序列化

type DeployInstance

type DeployInstance struct {
	DeviceMetaId string `json:"deviceMetaId"`
	Visibility   string `json:"visibility"`
	Name         string `json:"name"`
	From         ToFrom
	To           ToFrom
}

type DeviceData

type DeviceData struct {
	DeviceId    string
	Name        string
	ThingId     string
	StructId    int
	TaskId      string
	AcqTime     time.Time
	RealTime    time.Time
	ErrCode     int
	Raw         map[string]any
	RawUnit     map[string]string
	DeviceInfo  DeviceInfo
	DimensionId string
	//数据类型 常见有 comm="" ,RawTypeVib="vib"
	DataType string
}

func (*DeviceData) GetVibrationData

func (d *DeviceData) GetVibrationData() VibrationData

type DeviceFactorProto

type DeviceFactorProto struct {
	Formula  int               `json:"formula"`
	FieldVal map[string]string `json:"field_val"`
	//MultiFormula   interface{}       `json:"multi_formula"`
	//MultiFields    interface{}       `json:"multi_fields"`
	//UnitConversion interface{}       `json:"unit_conversion"`
	//纪录  数据输入输出的转换系数
	FieldValUnitK map[string]float64
}

func (*DeviceFactorProto) MarshalBinary

func (m *DeviceFactorProto) MarshalBinary() (data []byte, err error)

redis序列化

func (*DeviceFactorProto) UnmarshalBinary

func (m *DeviceFactorProto) UnmarshalBinary(data []byte) error

redis序列化

type DeviceInfo

type DeviceInfo struct {
	Id         string     `json:"id"`
	Name       string     `json:"name"`
	Structure  Structure  `json:"structure"`
	DeviceMeta DeviceMeta `json:"device_meta"`
}

type DeviceMeta

type DeviceMeta struct {
	Id           string           `json:"id"`
	Name         string           `json:"name"`
	Model        string           `json:"model"`
	Properties   []iotaProperty   `json:"properties"`
	Capabilities []iotaCapability `json:"capabilities"`
}

func (*DeviceMeta) GetOutputProps

func (m *DeviceMeta) GetOutputProps() (out map[string]string)

func (*DeviceMeta) GetOutputUnit

func (m *DeviceMeta) GetOutputUnit() (out map[string]string)

func (*DeviceMeta) MarshalBinary

func (m *DeviceMeta) MarshalBinary() (data []byte, err error)

redis序列化

func (*DeviceMeta) UnmarshalBinary

func (m *DeviceMeta) UnmarshalBinary(data []byte) error

redis序列化

type DeviceNode

type DeviceNode struct {
	Id    string
	Name  string
	Depth int

	Child []DeviceNode
	// contains filtered or unexported fields
}

func (*DeviceNode) SearchSub

func (the *DeviceNode) SearchSub(deviceId string) (subList []string)

func (*DeviceNode) SearchSubAll

func (the *DeviceNode) SearchSubAll(deviceId string) (subList []string)

type DeviceProto

type DeviceProto struct {
	Formula      int
	FieldVal     map[string]string
	MultiFormula int

	UnitConversion map[string]float64
	// contains filtered or unexported fields
}

type DeviceTree

type DeviceTree struct {
	Node DeviceNode
}

type Dimension

type Dimension struct {
	Id      string `json:"id"`
	ThingId string `json:"thingId"`
	Name    string `json:"name"`
}

type EsGroupTheme

type EsGroupTheme struct {
	StructId    int                `json:"struct_id"`
	GroupId     int                `json:"group_id"`
	GroupName   string             `json:"group_name"`
	GroupType   string             `json:"group_type"`
	TaskId      string             `json:"task_id"`
	CorrItems   []StationGroupInfo `json:"corr_items"`
	Data        []CorrItemData     `json:"data"`
	CollectTime time.Time          `json:"collect_time"`
	CreateTime  time.Time          `json:"create_time"`
}

EsGroupTheme 分组主题数据结构体

func (EsGroupTheme) MarshalJSON added in v0.0.11

func (the EsGroupTheme) MarshalJSON() ([]byte, error)

type EsRaw

type EsRaw struct {
	StructId       int               `json:"structId"`
	IotaDeviceName string            `json:"iota_device_name"`
	Data           map[string]any    `json:"data"`
	CollectTime    time.Time         `json:"collect_time"`
	Meta           map[string]string `json:"meta"`
	IotaDevice     string            `json:"iota_device"`
	CreateTime     time.Time         `json:"create_time"`
}

type EsRawResp

type EsRawResp struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total    int      `json:"total"`
		MaxScore float64  `json:"max_score"`
		Hits     []HitRaw `json:"hits"`
	} `json:"hits"`
}

type EsTheme

type EsTheme struct {
	SensorName      string         `json:"sensor_name"`
	FactorName      string         `json:"factor_name"`
	FactorProtoCode string         `json:"factor_proto_code"`
	Data            map[string]any `json:"data"`
	FactorProtoName string         `json:"factor_proto_name"`
	Factor          int            `json:"factor"`
	CollectTime     time.Time      `json:"collect_time"`
	Sensor          int            `json:"sensor"`
	Structure       int            `json:"structure"`
	IotaDevice      []string       `json:"iota_device"`
	CreateTime      time.Time      `json:"create_time"`
}

func (EsTheme) MarshalJSON added in v0.0.11

func (the EsTheme) MarshalJSON() ([]byte, error)

type EsThemeResp

type EsThemeResp struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total    int        `json:"total"`
		MaxScore float64    `json:"max_score"`
		Hits     []HitTheme `json:"hits"`
	} `json:"hits"`
}

type EsVbRaw

type EsVbRaw struct {
	StructId       int            `json:"structId"`
	IotaDeviceName string         `json:"iota_device_name"`
	Param          map[string]any `json:"param"`
	Data           map[string]any `json:"data"`
	CollectTime    time.Time      `json:"collect_time"`
	IotaDevice     string         `json:"iota_device"`
	CreateTime     time.Time      `json:"create_time"`
	// contains filtered or unexported fields
}

func (*EsVbRaw) FlatMapDynamicVib

func (the *EsVbRaw) FlatMapDynamicVib() []EsVbRaw

FlatMapDynamicVib 振动数据打散

type Factor

type Factor struct {
	Id        int               `json:"id"`
	Name      string            `json:"name"`
	ProtoCode string            `json:"protoCode"`
	ProtoName string            `json:"protoName"`
	Items     []ProtoItem       `json:"items"`
	Units     map[string]string `json:"units"`
}

func (*Factor) GetFieldNames

func (f *Factor) GetFieldNames() []string

GetFieldNames 获取监测原型监测项

func (*Factor) GetProtoItem

func (f *Factor) GetProtoItem(fieldName string) *ProtoItem

func (*Factor) MarshalBinary

func (f *Factor) MarshalBinary() (data []byte, err error)

redis序列化

func (*Factor) UnmarshalBinary

func (f *Factor) UnmarshalBinary(data []byte) error

redis序列化

type Filter

type Filter struct {
	Items FilterItems
}

type FilterItem

type FilterItem struct {
	Item           int            `json:"item"`
	FieldName      string         `json:"field_name"`
	Name           string         `json:"name"`
	MethodId       int            `json:"method"`
	Params         FilterParams   `json:"Params"`
	WindowSize     int            `json:"window_size"`
	Iswork         string         `json:"iswork"` //没用,默认都是false,只要存在都是启用的
	RInit          float64        `json:"RInit"`
	InternalParams InternalParams `json:"internal_params"`
	R              float64        `json:"R"`
	InvalidCount   int            `json:"InvalidCount"`
}

type FilterItems

type FilterItems []FilterItem

func (*FilterItems) MarshalBinary

func (t *FilterItems) MarshalBinary() (data []byte, err error)

func (*FilterItems) UnmarshalBinary

func (t *FilterItems) UnmarshalBinary(data []byte) error

type FilterParams

type FilterParams struct {
	Kt string `json:"Kt"`
	Rt string `json:"Rt"`
	Dt string `json:"Dt"`
	Ru string `json:"Ru"`
}

type Formula

type Formula struct {
	Id         int            `json:"id"`
	Expression string         `json:"expression"`
	Params     []FormulaParam `json:"params"`
	IoFields   IoFields       `json:"ioFields"`
	Type       string         `json:"type"`
}

func (*Formula) MarshalBinary

func (m *Formula) MarshalBinary() (data []byte, err error)

redis序列化

func (*Formula) UnmarshalBinary

func (m *Formula) UnmarshalBinary(data []byte) error

redis序列化

type FormulaParam

type FormulaParam struct {
	Name    string  `json:"name"`
	Alias   string  `json:"alias"`
	Unit    string  `json:"unit"`
	Default float64 `json:"default"`
}

type GroupItem

type GroupItem struct {
	StationId   int                    `json:"sensor"`
	ParamsValue map[string]interface{} `json:"params_value"`
	SubItems    map[string]GroupItem   `json:"subItems,omitempty"`
}

func (*GroupItem) CorrItems

func (gi *GroupItem) CorrItems() []GroupItem

CorrItems 基点的级联参考基点和参考测点

func (*GroupItem) GetDoubleParam

func (gi *GroupItem) GetDoubleParam(key string) (float64, error)

GetDoubleParam 返回param的float64值

type HitRaw

type HitRaw struct {
	Index  string  `json:"_index"`
	Type   string  `json:"_type"`
	Id     string  `json:"_id"`
	Score  float64 `json:"_score"`
	Source EsRaw   `json:"_source"`
}

type HitTheme

type HitTheme struct {
	Index  string  `json:"_index"`
	Type   string  `json:"_type"`
	Id     string  `json:"_id"`
	Score  float64 `json:"_score"`
	Source EsTheme `json:"_source"`
}

type IDataTrace added in v0.0.8

type IDataTrace interface {
	// 数据时间
	T() time.Time

	// 定位标记
	Q() string

	// 定位标记
	R() string

	GetThingId() string

	GetDeviceId() string
}

type IRpcData added in v0.0.8

type IRpcData interface {
	GetThingId() string
}

type InternalParams

type InternalParams struct {
	Kt string `json:"kt"`
	Rt string `json:"rt"`
	Dt string `json:"dt"`
	Ru string `json:"ru"`
}

type IoFields

type IoFields struct {
	Input  []ItemParam `json:"input"`
	Output []ItemParam `json:"output"`
}

func (*IoFields) GetInFieldUnit

func (the *IoFields) GetInFieldUnit(Field string) string

func (*IoFields) GetOutFieldUnit

func (the *IoFields) GetOutFieldUnit(Field string) string

type IotaAlarm

type IotaAlarm struct {
	Id          string      `json:"id"`
	Status      string      `json:"status"`
	RepeatTimes int         `json:"repeatTimes"`
	StartsAt    time.Time   `json:"startsAt"`
	Severity    int         `json:"severity"`
	Labels      Labels      `json:"labels"`
	Annotations Annotations `json:"annotations"`
}

func (*IotaAlarm) R_

func (the *IotaAlarm) R_() string

type IotaData

type IotaData struct {
	UserId      string    `json:"userId"`
	ThingId     string    `json:"thingId"`
	DimensionId string    `json:"dimensionId"`
	DimCapId    string    `json:"dimCapId"`
	CapId       string    `json:"capId"`
	DeviceId    string    `json:"deviceId"`
	ScheduleId  string    `json:"scheduleId"`
	TaskId      string    `json:"taskId"`
	JobId       int       `json:"jobId"`
	JobRepeatId int       `json:"jobRepeatId"`
	TriggerTime time.Time `json:"triggerTime"`
	RealTime    time.Time `json:"realTime"`
	FinishTime  time.Time `json:"finishTime"`
	Seq         int       `json:"seq"`
	Released    bool      `json:"released"`
	Data        Data      `json:"data"`
}

func (*IotaData) GetDeviceId added in v0.0.9

func (the *IotaData) GetDeviceId() string

func (*IotaData) GetThingId added in v0.0.8

func (the *IotaData) GetThingId() string

func (*IotaData) Q added in v0.0.8

func (the *IotaData) Q() string

func (*IotaData) R added in v0.0.8

func (the *IotaData) R() string

func (*IotaData) ReadTaskId

func (the *IotaData) ReadTaskId() (taskId string)

ReadTaskId 支持内部字段定义任务ID (_acq_number)

func (*IotaData) T added in v0.0.8

func (the *IotaData) T() time.Time

type IotaDevice

type IotaDevice struct {
	Id           string     `json:"id"`
	Name         string     `json:"name"`
	Properties   string     `json:"properties"`
	DeviceMetaId string     `json:"deviceMetaId"`
	ThingId      string     `json:"thingId"`
	DeviceMeta   DeviceMeta `json:"deviceMeta"`
}

func (*IotaDevice) MarshalBinary

func (m *IotaDevice) MarshalBinary() (data []byte, err error)

redis序列化

func (*IotaDevice) UnmarshalBinary

func (m *IotaDevice) UnmarshalBinary(data []byte) error

redis序列化

type IotaInstance

type IotaInstance struct {
	Instance DeployInstance `json:"instance"`
	Type     string         `json:"type"` //s.l or  s.d  or s.iota
}

type IotaInstances

type IotaInstances struct {
	Instances map[string]IotaInstance `json:"instances"`
}

func (*IotaInstances) MarshalBinary

func (m *IotaInstances) MarshalBinary() (data []byte, err error)

redis序列化

func (*IotaInstances) UnmarshalBinary

func (m *IotaInstances) UnmarshalBinary(data []byte) error

redis序列化

type IotaScheme

type IotaScheme struct {
	Id        string     `json:"id"`
	Name      string     `json:"name"`
	Mode      string     `json:"mode"`
	Interval  int        `json:"interval"`
	Unit      string     `json:"unit"`
	BeginTime *time.Time `json:"beginTime"`
	EndTime   *time.Time `json:"endTime,omitempty"`
	Dimension Dimension  `json:"dimension"`
}

func (*IotaScheme) IntervalSecs

func (s *IotaScheme) IntervalSecs() int

IntervalSecs 间隔秒

func (*IotaScheme) MarshalBinary

func (s *IotaScheme) MarshalBinary() (data []byte, err error)

redis序列化

func (*IotaScheme) SimpleEquals

func (s *IotaScheme) SimpleEquals(other *IotaScheme) bool

SimpleEquals 调度模式一致(模式 & 间隔 & 时间单位)

func (*IotaScheme) SimpleEqualsInt

func (s *IotaScheme) SimpleEqualsInt(iv int) bool

SimpleEqualsInt 周期调度的分钟数相等(周期 & 间隔 & 分钟)

func (*IotaScheme) UnmarshalBinary

func (s *IotaScheme) UnmarshalBinary(data []byte) error

redis序列化

type ItemParam

type ItemParam struct {
	Name string `json:"name"`
	Unit string `json:"unit"`
}

type Labels

type Labels struct {
	AlertName   string `json:"id"`
	DeviceId    string `json:"deviceId"`
	TaskId      string `json:"taskId"`
	DimensionId string `json:"dimensionId"`
	ThingId     string `json:"thingId"`
	UserId      string `json:"userId"`
}

type NodeArgs

type NodeArgs struct {
	ID        string   // 节点标识符
	NodeType  string   // 节点类型:iota数据处理、聚集数据处理 类似的
	Status    string   // 节点状态:例如健康状态、负载情况、可用性等信息
	Resources string   // 节点资源情况:CPU、内存、存储等资源的容量和使用情况等信息
	Addr      string   // 网络地址
	ThingIds  []string // 处理的thingId
}

type ProcessData

type ProcessData struct {
	//设备信息
	DeviceData DeviceData
	//测点信息
	Stations []Station //设备可对应多个测点
}

type Proto

type Proto struct {
	Code  string      `json:"code"`
	Name  string      `json:"name"`
	Items []ProtoItem `json:"items"`
}

func (*Proto) GetProtoItem

func (p *Proto) GetProtoItem(fieldName string) *ProtoItem

func (*Proto) MarshalBinary

func (p *Proto) MarshalBinary() (data []byte, err error)

redis序列化

func (*Proto) UnmarshalBinary

func (p *Proto) UnmarshalBinary(data []byte) error

redis序列化

type ProtoItem

type ProtoItem struct {
	Id        int    `json:"id"`
	Name      string `json:"name"`
	FieldName string `json:"field_name"`
	UnitName  string `json:"unit_name"`
	Precision int    `json:"precision"`
}

type RpcReply added in v0.0.8

type RpcReply struct {
	Result  bool
	Message string
}

RpcReply RPC方法的回复对象

type SecureStationDevice

type SecureStationDevice struct {
	FormulaId         int            `json:"formula_id"` //单设备测点 公式id redis里面原本没有 20240326后加
	Params            map[string]any `json:"params"`
	IotaDeviceId      string         `json:"iota_device_id"`
	IotaDeviceSerial  int            `json:"iota_device_serial"`
	FormulaInfo       Formula
	DeviceFactorProto DeviceFactorProto
}

func (*SecureStationDevice) LogMsg

func (s *SecureStationDevice) LogMsg() string

type Station

type Station struct {
	// 测点基本信息:名称、监测因素、监测原型、结构物、IOT-Things信息等
	Info StationInfo
	// 测点数据包括:设备数据 + 主题数据
	Data StationData
	// 测点阈值
	Threshold *Threshold
}

Station 测点模型 = 基本信息 + 数据 + 阈值

func (*Station) GetProtoFields

func (the *Station) GetProtoFields() []string

GetProtoFields 获取监测原型的监测项

func (*Station) LogMsg

func (the *Station) LogMsg() string

func (*Station) MarshalBinary

func (the *Station) MarshalBinary() (data []byte, err error)

redis序列化

func (*Station) UnmarshalBinary

func (the *Station) UnmarshalBinary(data []byte) error

redis序列化

type StationArrayObj

type StationArrayObj []Station

func (*StationArrayObj) MarshalBinary

func (m *StationArrayObj) MarshalBinary() (data []byte, err error)

redis序列化

func (*StationArrayObj) UnmarshalBinary

func (m *StationArrayObj) UnmarshalBinary(data []byte) error

redis序列化

type StationData

type StationData struct {
	//测点包含-计算后的设备单点数据
	DeviceCalcData map[string]any
	//测点最终数据(主题数据)
	ThemeData   map[string]any
	PhyData     map[string]any
	CollectTime time.Time
	AlarmLevel  int
}

func (*StationData) GetThemeFields

func (s *StationData) GetThemeFields() []string

GetThemeFields 获取主题数据的监测项

func (*StationData) GetValidThemeData

func (s *StationData) GetValidThemeData() (map[string]float64, bool)

GetValidThemeData 获取有效的主题数据(数据规整为:非空float64)

type StationGroup

type StationGroup struct {
	Id        int         `json:"id"`
	Name      string      `json:"name"`
	GroupType string      `json:"group_type"`
	Items     []GroupItem `json:"items"`
	Params    map[string]interface{}
}

func (*StationGroup) AllCorrItems

func (g *StationGroup) AllCorrItems() []GroupItem

AllCorrItems 分组的关联项 = Items + 该分组的级联 ref_base、ref_point(可能有多层)

func (*StationGroup) GetItem added in v0.0.8

func (g *StationGroup) GetItem(stationId int) *GroupItem

func (*StationGroup) GetSettlementBaseItem

func (g *StationGroup) GetSettlementBaseItem() *GroupItem

GetSettlementBaseItem 获取沉降分组的基点

func (*StationGroup) MarshalBinary

func (g *StationGroup) MarshalBinary() (data []byte, err error)

redis序列化

func (*StationGroup) R

func (g *StationGroup) R() string

func (*StationGroup) UnmarshalBinary

func (g *StationGroup) UnmarshalBinary(data []byte) error

redis序列化

type StationGroupInfo

type StationGroupInfo struct {
	StationId int                    `json:"station"`
	GroupId   int                    `json:"group"`
	Params    map[string]interface{} `json:"params"`
	Name      string                 `json:"name"`
	GroupType string                 `json:"group_type"`
}

StationGroupInfo 测点的分组信息(对应 ET3.0 的 secure_station_group )

func (*StationGroupInfo) MarshalBinary

func (g *StationGroupInfo) MarshalBinary() (data []byte, err error)

redis序列化

func (*StationGroupInfo) UnmarshalBinary

func (g *StationGroupInfo) UnmarshalBinary(data []byte) error

redis序列化

type StationInfo

type StationInfo struct {
	Id            int            `json:"id"`
	Name          string         `json:"name"`
	StructureId   int            `json:"structure"`
	ThingId       string         `json:"thingId"`
	StructureName string         `json:"struct_name"`
	FactorId      int            `json:"factor"`
	IsManualData  bool           `json:"manual_data"`
	FormulaId     int            `json:"formula"`
	ParamsValue   map[string]any `json:"params_value"`
	Factor        Factor
	ProtoCode     string `json:"proto"`
	Proto         Proto
	Devices       []SecureStationDevice
	Labels        string
	CombineInfo   string
	Group         StationGroup   `json:"group,omitempty"`
	CorrGroups    []StationGroup `json:"corr_group_ids,omitempty"` // 关联的分组ID
}

func (*StationInfo) GetDeviceIdArray

func (the *StationInfo) GetDeviceIdArray() []string

func (*StationInfo) MarshalBinary

func (m *StationInfo) MarshalBinary() (data []byte, err error)

redis序列化

func (*StationInfo) UnmarshalBinary

func (m *StationInfo) UnmarshalBinary(data []byte) error

redis序列化

type Structure

type Structure struct {
	ThingId   string  `json:"thingId"`
	Id        int     `json:"id"`
	Name      string  `json:"name"`
	SType     string  `json:"type"`
	OrgId     int     `json:"orgId"`     //结构物归属的组织ID
	Latitude  float64 `json:"latitude"`  //纬度
	Longitude float64 `json:"longitude"` //经度
}

type ThingStruct

type ThingStruct struct {
	ThingId string `json:"thingId"`
	Id      int    `json:"id"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	OrgId   int    `json:"orgId"`
}

func (*ThingStruct) MarshalBinary

func (m *ThingStruct) MarshalBinary() (data []byte, err error)

redis序列化

func (*ThingStruct) UnmarshalBinary

func (m *ThingStruct) UnmarshalBinary(data []byte) error

redis序列化

type Threshold

type Threshold struct {
	Items ThresholdItems
}

Threshold 阈值模型

func (*Threshold) FindThresholdInRange

func (t *Threshold) FindThresholdInRange(items []ThresholdItem, m float64) *ThresholdItem

FindThresholdInRange 阈值判断

func (*Threshold) GetThresholdsByItem

func (t *Threshold) GetThresholdsByItem(items []ThresholdItem, itemID int) []ThresholdItem

GetThresholdsByItem 根据监测项ID获取阈值

func (*Threshold) GetThresholdsByTime

func (t *Threshold) GetThresholdsByTime(date time.Time) []ThresholdItem

GetThresholdsByTime 根据时间获取阈值

type ThresholdAlarmDetail

type ThresholdAlarmDetail struct {
	Level   int
	Content string
}

func (ThresholdAlarmDetail) ToString

func (t ThresholdAlarmDetail) ToString() string

type ThresholdItem

type ThresholdItem struct {
	Item        int     `json:"item"` // item -> t_factor_proto_item(id)
	FieldName   string  `json:"field_name"`
	Name        string  `json:"name"`
	Level       int     `json:"level"`
	Lower       float64 `json:"lower"`
	Upper       float64 `json:"upper"`
	Begin       *int    `json:"begin"`                  // 分时阈值起始时间(24小时制 0~24)
	End         *int    `json:"end"`                    // 分时阈值结束时间(24小时制 0~24)
	AggCategory *int    `json:"agg_category,omitempty"` // 在JSON编码时,如果此字段为空,则忽略该字段
}

ThresholdItem 阈值项模型

func (*ThresholdItem) IsTimeSegmented

func (t *ThresholdItem) IsTimeSegmented() bool

func (*ThresholdItem) RangeText

func (t *ThresholdItem) RangeText() string

type ThresholdItems

type ThresholdItems []ThresholdItem

ThresholdItems 自定义类型,[]ThresholdItem的别名

func (*ThresholdItems) MarshalBinary

func (t *ThresholdItems) MarshalBinary() (data []byte, err error)

func (*ThresholdItems) UnmarshalBinary

func (t *ThresholdItems) UnmarshalBinary(data []byte) error

type ToFrom

type ToFrom struct {
	ShapeType      string `json:"shapeType"`
	OwnerShapeType string `json:"ownerShapeType"`
	OwnerSvgId     string `json:"ownerSvgId"`
}

type VibrationData

type VibrationData struct {
	Version       byte
	SampleFreq    float64
	FilterFreq    float64
	GainAmplifier byte
	TriggerType   byte
	Data          []float64 // 原始波形数据
	Unit          string
}

VibrationData 振动数据

func (*VibrationData) FormatParams

func (v *VibrationData) FormatParams() map[string]any

Directories

Path Synopsis
constant

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL