modelRT/model/attribute_model.go

96 lines
2.5 KiB
Go
Raw Normal View History

2025-07-31 16:52:21 +08:00
// Package model define model struct of model runtime service
package model
import (
"modelRT/orm"
)
2025-07-31 16:52:21 +08:00
// AttrModelInterface define basic attr model type interface
type AttrModelInterface interface {
GetGridInfo() *orm.Grid
GetZoneInfo() *orm.Zone
GetStationInfo() *orm.Station
GetComponentInfo() *orm.Component
2025-08-27 17:33:10 +08:00
GetAttrValue() interface{} // New method to get the attribute value
2025-07-31 16:52:21 +08:00
IsLocal() bool
}
// LongAttrInfo structure define long attribute key info of component
type LongAttrInfo struct {
AttrGroupName string
AttrKey string
AttrValue interface{}
GridInfo *orm.Grid
ZoneInfo *orm.Zone
StationInfo *orm.Station
ComponentInfo *orm.Component
}
// GetGridInfo define return the grid information in the long attribute
func (l *LongAttrInfo) GetGridInfo() *orm.Grid {
return l.GridInfo
}
// GetZoneInfo define return the zone information in the long attribute
func (l *LongAttrInfo) GetZoneInfo() *orm.Zone {
return l.ZoneInfo
}
// GetStationInfo define return the station information in the long attribute
func (l *LongAttrInfo) GetStationInfo() *orm.Station {
return l.StationInfo
}
// GetComponentInfo define return the component information in the long attribute
func (l *LongAttrInfo) GetComponentInfo() *orm.Component {
return l.ComponentInfo
}
// IsLocal define return the is_local information in the long attribute
func (l *LongAttrInfo) IsLocal() bool {
return true
2025-07-31 16:52:21 +08:00
}
2025-08-27 17:33:10 +08:00
// GetAttrValue define return the attribute value
func (l *LongAttrInfo) GetAttrValue() interface{} {
return l.AttrValue
}
2025-07-31 16:52:21 +08:00
// ShortAttrInfo structure define short attribute key info of component
type ShortAttrInfo struct {
AttrGroupName string
AttrKey string
AttrValue interface{}
ComponentInfo *orm.Component
}
// GetGridInfo define return the grid information in the short attribute
func (s *ShortAttrInfo) GetGridInfo() *orm.Grid {
return nil
}
// GetZoneInfo define return the zone information in the short attribute
func (s *ShortAttrInfo) GetZoneInfo() *orm.Zone {
return nil
}
// GetStationInfo define return the station information in the short attribute
func (s *ShortAttrInfo) GetStationInfo() *orm.Station {
return nil
}
// GetComponentInfo define return the component information in the short attribute
func (s *ShortAttrInfo) GetComponentInfo() *orm.Component {
return s.ComponentInfo
}
// IsLocal define return the is_local information in the short attribute
func (s *ShortAttrInfo) IsLocal() bool {
return false
2025-07-31 16:52:21 +08:00
}
2025-08-27 17:33:10 +08:00
// GetAttrValue define return the attribute value
func (l *ShortAttrInfo) GetAttrValue() interface{} {
return l.AttrValue
}