add telemetry machine code

This commit is contained in:
douxu 2025-09-01 16:15:30 +08:00
parent 37a1ccaadc
commit 3aab2c8a37
5 changed files with 40 additions and 9 deletions

31
constants/measurement.go Normal file
View File

@ -0,0 +1,31 @@
// Package constants define constant variable
package constants
const (
// DataSourceTypeCL3611 define CL3611 type
DataSourceTypeCL3611 = 1
// DataSourceTypePower104 define electricity 104 protocol type
DataSourceTypePower104 = 2
)
// channel name prefix
const (
ChannelPrefixTelemetry = "Telemetry"
ChannelPrefixTelesignal = "Telesignal"
ChannelPrefixTelecommand = "Telecommand"
ChannelPrefixTeleadjusting = "Teleadjusting"
ChannelPrefixSetpoints = "Setpoints"
)
// channel name suffix
const (
ChannelP = "P"
ChannelQ = "Q"
ChannelS = "S"
ChannelPS = "PS"
ChannelF = "F"
ChannelDeltaF = "deltaF"
ChannelUAB = "UAB"
ChannelUBC = "UBC"
ChannelUCA = "UCA"
)

View File

@ -67,17 +67,17 @@ func FillingShortAttrModel(ctx context.Context, tx *gorm.DB, attrItems []string,
// FillingLongAttrModel define filling long attribute model info // FillingLongAttrModel define filling long attribute model info
func FillingLongAttrModel(ctx context.Context, tx *gorm.DB, attrItems []string, attrModel *model.LongAttrInfo) error { func FillingLongAttrModel(ctx context.Context, tx *gorm.DB, attrItems []string, attrModel *model.LongAttrInfo) error {
grid, err := QueryGridByName(ctx, tx, attrItems[0]) grid, err := QueryGridByTagName(ctx, tx, attrItems[0])
if err != nil { if err != nil {
return err return err
} }
attrModel.GridInfo = &grid attrModel.GridInfo = &grid
zone, err := QueryZoneByName(ctx, tx, attrItems[1]) zone, err := QueryZoneByTagName(ctx, tx, attrItems[1])
if err != nil { if err != nil {
return err return err
} }
attrModel.ZoneInfo = &zone attrModel.ZoneInfo = &zone
station, err := QueryStationByName(ctx, tx, attrItems[2]) station, err := QueryStationByTagName(ctx, tx, attrItems[2])
if err != nil { if err != nil {
return err return err
} }

View File

@ -11,8 +11,8 @@ import (
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
) )
// QueryGridByName return the result of query circuit diagram grid info by tagName from postgresDB // QueryGridByTagName return the result of query circuit diagram grid info by tagName from postgresDB
func QueryGridByName(ctx context.Context, tx *gorm.DB, tagName string) (orm.Grid, error) { func QueryGridByTagName(ctx context.Context, tx *gorm.DB, tagName string) (orm.Grid, error) {
var grid orm.Grid var grid orm.Grid
// ctx超时判断 // ctx超时判断
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second) cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)

View File

@ -11,8 +11,8 @@ import (
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
) )
// QueryStationByName return the result of query circuit diagram Station info by tagName from postgresDB // QueryStationByTagName return the result of query circuit diagram Station info by tagName from postgresDB
func QueryStationByName(ctx context.Context, tx *gorm.DB, tagName string) (orm.Station, error) { func QueryStationByTagName(ctx context.Context, tx *gorm.DB, tagName string) (orm.Station, error) {
var station orm.Station var station orm.Station
// ctx超时判断 // ctx超时判断
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second) cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)

View File

@ -11,8 +11,8 @@ import (
"gorm.io/gorm/clause" "gorm.io/gorm/clause"
) )
// QueryZoneByName return the result of query circuit diagram Zone info by tagName from postgresDB // QueryZoneByTagName return the result of query circuit diagram Zone info by tagName from postgresDB
func QueryZoneByName(ctx context.Context, tx *gorm.DB, tagName string) (orm.Zone, error) { func QueryZoneByTagName(ctx context.Context, tx *gorm.DB, tagName string) (orm.Zone, error) {
var zone orm.Zone var zone orm.Zone
// ctx超时判断 // ctx超时判断
cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second) cancelCtx, cancel := context.WithTimeout(ctx, 5*time.Second)