Compare commits

...

3 Commits

Author SHA1 Message Date
douxu 375655017e fix bug of load component info 2024-12-12 16:17:31 +08:00
douxu d9cc5f3738 init async motor table and busbar section table create sql 2024-12-10 16:36:59 +08:00
douxu 829279b22b init async motor model and optimize model select func 2024-12-09 16:05:48 +08:00
8 changed files with 269 additions and 29 deletions

View File

@ -6,6 +6,6 @@ const (
NullableType = iota
// BusbarType 母线类型
BusbarType
// AsynchronousMotorType 异步电动机类型
AsynchronousMotorType
// AsyncMotorType 异步电动机类型
AsyncMotorType
)

13
main.go
View File

@ -91,11 +91,24 @@ func main() {
engine := gin.Default()
engine.Use(limiter.Middleware)
// diagram api
engine.GET("/model/diagram_load", handler.CircuitDiagramLoadHandler)
engine.POST("/model/diagram_create", handler.CircuitDiagramCreateHandler)
engine.POST("/model/diagram_update", handler.CircuitDiagramUpdateHandler)
engine.POST("/model/diagram_delete", handler.CircuitDiagramDeleteHandler)
// dashborad api
dashboard := engine.Group("/dashboard", limiter.Middleware)
{
dashboard.GET("/load", nil)
dashboard.GET("/query", nil)
dashboard.POST("/create", nil)
dashboard.POST("/update", nil)
dashboard.POST("/delete", nil)
}
// engine.Group()
// Swagger UI
engine.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

View File

@ -10,14 +10,13 @@ import (
func SelectModelByType(modelType int) BasicModelInterface {
if modelType == constant.BusbarType {
return &orm.BusbarSection{}
} else if modelType == constant.AsyncMotorType {
return &orm.AsyncMotor{}
}
return nil
}
// SelectModelNameByType define select the data structure name for parsing based on the input model type
func SelectModelNameByType(modelType int) string {
if modelType == constant.BusbarType {
return "BusBarSection"
}
return ""
return SelectModelByType(modelType).ReturnTableName()
}

93
orm/async_motor.go Normal file
View File

@ -0,0 +1,93 @@
// Package orm define database data struct
package orm
import "github.com/gofrs/uuid"
// AsyncMotor define asynchronous motor model
type AsyncMotor struct {
UUID uuid.UUID `gorm:"column:global_uuid;primaryKey"`
NoLoadVoltage float64 // 空载电压
NoLoadElectricCurrent float64 // 空载电流
NoLoadPower float64 // 空载电功率
BlockageF1Frequency float64 // 堵转 f1 频率
BlockageF1Voltage float64 // 堵转 f1 频率电压
BlockageF1ElectricCurrent float64 // 堵转 f1 频率电流
BlockageF1Power float64 // 堵转 f1 频率电功率
BlockageF2Frequency float64 // 堵转 f2 频率
BlockageF2Voltage float64 // 堵转 f2 频率电压
BlockageF2ElectricCurrent float64 // 堵转 f2 频率电流
BlockageF2Power float64 // 堵转 f2 频率电功率
APhaseDCResistance float64 // A相直流电阻
BPhaseDCResistance float64 // B相直流电阻
CPhaseDCResistance float64 // C相直流电阻
RunningStatorResistance float64 // 运行定子电阻r1
StartUpStatorResistance float64 // 启动定子电阻r1
ColdStateStatorResistance float64 // 冷态定子电阻r1
RunningStatorReactance float64 // 运行定子电抗x1
StartUpStatorReactance float64 // 启动定子电抗x1
ColdStateStatorReactance float64 // 冷态定子电抗x1
RunningEquivalentResistanceOfRotor float64 // 运行转子等值电阻r2
StartUpEquivalentResistanceOfRotor float64 // 启动转子等值电阻r2
ColdStateEquivalentResistanceOfRotor float64 // 冷态转子等值电阻r2
RunningEquivalentReactanceOfRotor float64 // 运行转子等值电抗x2
StartUpEquivalentReactanceOfRotor float64 // 启动转子等值电抗x2
ColdStateEquivalentReactanceOfRotor float64 // 冷态转子等值电抗x2
RunningExcitationResistance float64 // 运行励磁电阻Rfe
StartUpExcitationResistance float64 // 启动励磁电阻Rfe
ColdStateExcitationResistance float64 // 冷态励磁电阻Rfe
RunningExcitationReactance float64 // 运行励磁电抗Xm
StartUpExcitationReactance float64 // 启动励磁电抗Xm
ColdStateExcitationReactance float64 // 冷态励磁电抗Xm
RunningTemperature int // 运行温度
StartUpTemperature int // 启动温度
ColdStateTemperature int // 冷态温度
// 热限制曲线参数
EIS string // 电动机定子绕组绝缘结构热分级,枚举值类型105(A)/120(E)/130(B)/155(F)/180(H),默认值155(F)
TemperatureLimit int // 温度限值,范围值0-1000
TemperatureRiseLimit int // 温升限值,范围值0-1000
ColdStateAllowsContinuousStartingTimes int // 冷态允许连续起动次数
HotStateAllowsContinuousStartingtimes int // 热态允许连续起动次数
ProhibitionOfRestartForShortestTime float64 // 禁止重起动最短时间
HotStateAllowsBlockageTime float64 // 热态允许堵转时间Ta
ColdStateAllowsBlockageTime float64 // 冷态允许堵转时间To
ElectricMotorHeatingTimeConstant float64 // 电动机发热时间常数Twu
ElectricMotorHeatDissipationTimeConstant float64 // 电动机散热时间常数Tcd
ThermalLoadCurve []float64 // 热载曲线坐标点
CompensationForEnvConditions int // 环境条件补偿环境温度
MinLimitOfTerminalVoltage int // 机端电压下限
MaxLimitOfStarts int // 起动次数上限
StartingStrategy string // 起动策略
NormalStartUpTime int // 起动转正常时间
RestartBatch int // 再起动批次
ElectricCurrentMeasurementLevel string // 电流测量级
VoltageMeasurementLevel string // 电压测量级
ElectricCurrentProtectionLevel1 string // 电流保护级1
ElectricCurrentProtectionLevel2 string // 电流保护级1
VoltageProtectionLevel string // 电压保护级
Trend string // 潮流
Frequency string // 频率
StatusMeasurementPoint string // 状态测点
Machinery string // 机械
}
/*
(1)温度的格式为正整数0~500
(2)电阻和电抗的参数为正实数三位整数五位小数的格式XXX.XXXXX
*/
// TableName func respresent return table name of asynchronous motor
func (a *AsyncMotor) TableName() string {
return "AsyncMotor"
}
// SetUUID func implement BasicModelInterface interface
func (a *AsyncMotor) SetUUID(uuid uuid.UUID) {
a.UUID = uuid
return
}
// ReturnTableName func implement BasicModelInterface interface
func (a *AsyncMotor) ReturnTableName() string {
return "AsyncMotor"
}

View File

@ -3,13 +3,14 @@ package orm
import "github.com/gofrs/uuid"
// BusbarSection define busbar section model
type BusbarSection struct {
// 母线基本参数
Name string // 母线端名称,默认值BusX
BusbarName string // 母线端名称,默认值BusX
BusbarNumber int // 母线编号,默认值1
UUID uuid.UUID `gorm:"column:uuid;primaryKey"`
UUID uuid.UUID `gorm:"column:global_uuid;primaryKey"`
StandardVoltage float32 // 标准电压,单位kV,范围值在000.01~500.00
Desc string // 描述
BusbarDesc string // 描述
IsService bool // 是否服役,值为运行/退出
Status string // 状态,值为现役/新建/计划/检修/库存可用/库存报废
PowerGridName string // 当前工程电网的顶层建模时的电网名称
@ -23,9 +24,9 @@ type BusbarSection struct {
DynamicStableCurrent float32 // 母线动稳定电流,范围值0.01~65536
MinLoadAdjustmentCoefficient int // 最小母线负荷调整系数,范围值0-100
MaxLoadAdjustmentCoefficient int // 最大母线负荷调整系数,范围值0-500
BusbarType int // 母线类型,默认值PQ
ReferenceVoltage float32 // 母线类型,单位kV,默认值37
ReferenceVCurrent float32 // 母线类型,单位MVA,默认值100
BusbarType string // 母线类型,默认值PQ
ReferenceVoltage float32 // 基准电压,单位kV,默认值37
ReferenceCurrent float32 // 基准电流,单位MVA,默认值100
MinS3Capacities float32 // 最小三项短路容量,范围值0.00~65536.00
MaxS3Capacities float32 // 最大三项短路容量,范围值0.00~65536.00
MinS3Current float32 // 最小三项短路电流,范围值0.00~65536.00
@ -36,17 +37,17 @@ type BusbarSection struct {
MaxS1Capacity float32 // 最大单项短路容量,范围值0.00~65536.00
MinS1Current float32 // 最小单项短路电流,范围值0.00~65536.00
MaxS1Current float32 // 最大单项短路电流,范围值0.00~65536.00
MinS1Impedance float32 // 最小单项短路阻抗,默认值 0.1,范围值0.0000~100.0000
MaxS1Impedance float32 // 最大单项短路阻抗,默认值 0.05,范围值0.0000~100.0000
MinZ1Impedance float32 // 最小单项短路阻抗,默认值 0.1,范围值0.0000~100.0000
MaxZ1Impedance float32 // 最大单项短路阻抗,默认值 0.05,范围值0.0000~100.0000
// 母线稳定参数
UnderVoltageWarningThreshold int // 欠压预警阈值
UnderVoltageWarningRunningTime float32 // 欠压预警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
UnderVoltageWarningRunningTime int // 欠压预警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
UnderVoltageAlarmThreshold int // 欠压告警阈值
UnderVoltageAlarmRunningTime float32 // 欠压告警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
UnderVoltageAlarmRunningTime int // 欠压告警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
OverVoltageWarningThreshold int // 过压预警阈值
OverVoltageWarningRunningTime float32 // 过压预警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
OverVoltageWarningRunningTime int // 过压预警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
OverVoltageAlarmThreshold int // 过压告警阈值
OverVoltageAlarmRunningTime float32 // 过压告警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
OverVoltageAlarmRunningTime int // 过压告警运行时间,默认值 10s,默认单位秒默认范围值0s-100s
PMax float32 // 有功储备裕度最大值
QMax float32 // 无功储备裕度最大值
Ulim float32 // 电压裕度
@ -62,7 +63,7 @@ type BusbarSection struct {
StatusMeasurementPoint []string // 状态测点测点
}
// TableName func respresent return table name of BusbarSection
// TableName func respresent return table name of busbar section
func (b *BusbarSection) TableName() string {
return "BusbarSection"
}
@ -84,13 +85,13 @@ func NewBusbarSection(name string) (*BusbarSection, error) {
return nil, err
}
return &BusbarSection{
Name: name,
UUID: uuid,
BusbarName: name,
UUID: uuid,
}, nil
}
func (b *BusbarSection) BusNameLenCheck() bool {
if len([]rune(b.Name)) > 20 {
if len([]rune(b.BusbarName)) > 20 {
return false
}
return true
@ -104,7 +105,7 @@ func (b *BusbarSection) BusVoltageCheck() bool {
}
func (b *BusbarSection) BusDescLenCheck() bool {
if len([]rune(b.Desc)) > 100 {
if len([]rune(b.BusbarDesc)) > 100 {
return false
}
return true

View File

@ -11,6 +11,7 @@ import (
"modelRT/diagram"
"modelRT/model"
cmap "github.com/orcaman/concurrent-map/v2"
"go.uber.org/zap"
)
@ -26,12 +27,8 @@ var ParseFunc = func(parseConfig interface{}) {
cancelCtx, cancel := context.WithTimeout(modelParseConfig.Context, 5*time.Second)
defer cancel()
pgClient := database.GetPostgresDBClient()
componentKey := modelParseConfig.ComponentInfo.GlobalUUID.String()
unmarshalMap, err := diagram.GetComponentMap(componentKey)
if err != nil {
logger.Error("get component map from overviewMap failed", zap.String("component_key", componentKey), zap.Error(err))
panic(err)
}
uuid := modelParseConfig.ComponentInfo.GlobalUUID.String()
unmarshalMap := cmap.New[any]()
tableName := model.SelectModelNameByType(modelParseConfig.ComponentInfo.ComponentType)
result := pgClient.Table(tableName).WithContext(cancelCtx).Find(&unmarshalMap)
@ -41,6 +38,7 @@ var ParseFunc = func(parseConfig interface{}) {
logger.Error("query component detail info from table is empty", zap.String("table_name", tableName))
}
unmarshalMap.Set("id", modelParseConfig.ComponentInfo.ID)
unmarshalMap.Set("uuid", modelParseConfig.ComponentInfo.GlobalUUID.String())
unmarshalMap.Set("created_time", modelParseConfig.ComponentInfo.VisibleID)
unmarshalMap.Set("parent_id", modelParseConfig.ComponentInfo.GridID)
unmarshalMap.Set("type", modelParseConfig.ComponentInfo.ZoneID)
@ -53,5 +51,7 @@ var ParseFunc = func(parseConfig interface{}) {
unmarshalMap.Set("id", modelParseConfig.ComponentInfo.Context)
unmarshalMap.Set("parent_id", modelParseConfig.ComponentInfo.Comment)
unmarshalMap.Set("type", modelParseConfig.ComponentInfo.InService)
diagram.StoreComponentMap(uuid, &unmarshalMap)
return
}

72
sql/async_motor.sql Normal file
View File

@ -0,0 +1,72 @@
CREATE TABLE public."AsyncMotor" (
id serial NOT NULL,
global_uuid uuid NOT NULL,
noload_voltage decimal(7, 2) NOT NULL,
noload_electric_current decimal(7, 2) NOT NULL,
noload_power decimal(7, 2) NOT NULL,
blockage_f1_frequency decimal(5, 2) NOT NULL,
blockage_f1_voltage decimal(7, 2) NOT NULL,
blockage_f1_electric_current decimal(7, 2) NOT NULL,
blockage_f1_power decimal(7, 2) NOT NULL,
blockage_f2_frequency decimal(5, 2) NOT NULL,
blockage_f2_voltage decimal(7, 2) NOT NULL,
blockage_f2_electric_current decimal(7, 2) NOT NULL,
blockage_f2_power decimal(7, 2) NOT NULL,
a_phase_dc_resistance decimal(7, 2) NOT NULL,
b_phase_dc_resistance decimal(7, 2) NOT NULL,
c_phase_dc_resistance decimal(7, 2) NOT NULL,
running_stator_resistance decimal(8, 5) NOT NULL,
startup_stator_resistance decimal(8, 5) NOT NULL,
coldstate_stator_resistance decimal(8, 5) NOT NULL,
running_stator_reactance decimal(8, 5) NOT NULL,
startup_stator_reactance decimal(8, 5) NOT NULL,
coldstate_stator_reactance decimal(8, 5) NOT NULL,
running_equivalent_resistance_of_rotor decimal(8, 5) NOT NULL,
startup_equivalent_resistance_of_rotor decimal(8, 5) NOT NULL,
coldstate_equivalent_resistance_of_rotor decimal(8, 5) NOT NULL,
running_equivalent_reactance_of_rotor decimal(8, 5) NOT NULL,
startup_equivalent_reactance_of_rotor decimal(8, 5) NOT NULL,
coldtsate_equivalent_reactance_of_rotor decimal(8, 5) NOT NULL,
running_excitation_resistance decimal(8, 5) NOT NULL,
startup_excitation_resistance decimal(8, 5) NOT NULL,
coldstate_excitation_resistance decimal(8, 5) NOT NULL,
running_excitation_reactance decimal(8, 5) NOT NULL,
startup_excitation_reactance decimal(8, 5) NOT NULL,
coldstate_excitation_reactance decimal(8, 5) NOT NULL,
running_temperature integer NOT NULL,
startup_temperature integer NOT NULL,
coldstate_temperature integer NOT NULL,
eis character varying(10) default 'f' NOT NULL,
temperature_limit integer NOT NULL,
temperature_rise_limit integer NOT NULL,
coldstate_allows_continuous_starting_times integer default 2 NOT NULL,
hotstate_allows_continuous_starting_times integer default 1 NOT NULL,
prohibition_of_restart_for_shortest_time decimal(4, 1) default 30 NOT NULL,
hotstate_allows_blockage_time decimal(5, 2) default 10 NOT NULL,
coldstate_allows_blockage_time decimal(5, 2) default 6 NOT NULL,
electric_motor_heating_time_constant decimal(5, 2) default 100 NOT NULL,
electric_motor_heat_dissipation_time_constant decimal(5, 2) default 300 NOT NULL,
thermal_load_curve decimal(5, 2) [] NOT NULL,
compensation_for_env_conditions decimal(5, 2) NOT NULL,
min_limit_of_terminal_voltage integer default 80 NOT NULL,
max_limit_of_tarts integer NOT NULL,
starting_strategy character varying(10) NOT NULL,
normal_startup_time integer NOT NULL,
restart_batch integer NOT NULL,
electric_current_measurement_level character varying(10) NOT NULL,
voltage_measurement_level character varying(10) NOT NULL,
electric_current_protection_level1 character varying(10) NOT NULL,
electric_current_protection_level2 character varying(10) NOT NULL,
voltage_protection_level character varying(10) NOT NULL,
trend character varying(10) NOT NULL,
frequency character varying(10) NOT NULL,
status_measurement_point character varying(10) NOT NULL,
machinery character varying(10) NOT NULL,
context jsonb NULL,
comment character varying(4096) NULL
);
ALTER TABLE
public."AsyncMotor"
ADD
CONSTRAINT "AsyncMotor_pkey" PRIMARY KEY (global_uuid)

62
sql/busbar_section.sql Normal file
View File

@ -0,0 +1,62 @@
CREATE TABLE public."BusbarSection" (
id serial NOT NULL,
global_uuid uuid NOT NULL,
busbar_number integer NOT NULL,
busbar_name character varying(20) default 'Busx' NOT NULL,
standard_voltage decimal(5, 2) NOT NULL,
busbar_desc character varying(100) NOT NULL,
is_service boolean NULL default false,
status character varying(10) NOT NULL,
power_grid_name character varying(10) NOT NULL,
region_name character varying(10) NOT NULL,
factory_station_name character varying(10) NOT NULL,
voltage_percent_value decimal(5, 2) default 100 NOT NULL,
voltage_calculcated_value decimal(5, 2) default 35 NOT NULL,
phase_angle decimal(5, 2) default 0 NOT NULL,
rated_current decimal(7, 2) default 1000 NOT NULL,
dynamic_stable_current decimal(7, 2) default 40 NOT NULL,
min_load_adjustment_coefficient integer default 100 NOT NULL,
max_load_adjustment_coefficient integer default 100 NOT NULL,
busbar_type character varying(10) NOT NULL,
min_s3_capacities decimal(7, 2) default 0 NOT NULL,
max_s3_capacities decimal(7, 2) default 0 NOT NULL,
min_s3_current decimal(7, 2) default 0 NOT NULL,
max_s3_current decimal(7, 2) default 0 NOT NULL,
max_z3_impedance decimal(6, 3) default 0.05 NOT NULL,
min_z3_impedance decimal(6, 3) default 0.1 NOT NULL,
min_s1_capacity decimal(7, 2) default 0 NOT NULL,
max_s1_capacity decimal(7, 2) default 0 NOT NULL,
min_s1_current decimal(7, 2) default 0 NOT NULL,
max_s1_current decimal(7, 2) default 0 NOT NULL,
min_z1_impedance decimal(7, 4) default 0 NOT NULL,
max_z1_impedance decimal(7, 4) default 0 NOT NULL,
reference_voltage decimal(5, 2) default 37 NOT NULL,
reference_current decimal(7, 2) default 100 NOT NULL,
under_voltage_warning_threshold integer default 95 NOT NULL,
under_voltage_warning_running_time integer default 10 NOT NULL,
under_voltage_alarm_threshold integer default 90 NOT NULL,
under_voltage_alarm_running_time integer default 10 NOT NULL,
over_voltage_warning_threshold integer default 105 NOT NULL,
over_voltage_warning_running_time integer default 60 NOT NULL,
over_voltage_alarm_threshold integer default 110 NOT NULL,
over_voltage_alarm_running_time integer default 10 NOT NULL,
p_max decimal(7, 2) default 0 NOT NULL,
q_max decimal(7, 2) default 0 NOT NULL,
ulim decimal(5, 2) default 90 NOT NULL,
plim decimal(5, 2) default 30 NOT NULL,
qlim decimal(5, 2) default 30 NOT NULL,
measurement_level_current character varying(10) NOT NULL,
measurement_level_voltage character varying(10) NOT NULL,
protection_level_current character varying(10) NOT NULL,
protection_level_voltage_t character varying(10) NOT NULL,
trend character varying(10) NOT NULL,
frequency character varying(10) NOT NULL,
status_measurement_point character varying(10) NOT NULL,
context jsonb NULL,
comment character varying(4096) NULL
);
ALTER TABLE
public."BusbarSection"
ADD
CONSTRAINT "BusbarSection_pkey" PRIMARY KEY (global_uuid)