2023-12-25 10:07:59 +08:00
|
|
|
|
package repository
|
|
|
|
|
|
|
|
|
|
import "joylink.club/rtsssimulation/repository/model/proto"
|
|
|
|
|
|
|
|
|
|
//ISCS BAS 大系统相关
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
// AirPavilion 风亭(排、送)
|
|
|
|
|
type AirPavilion struct {
|
2023-12-25 10:07:59 +08:00
|
|
|
|
Identity
|
2023-12-25 13:40:00 +08:00
|
|
|
|
Code string
|
|
|
|
|
PavilionType proto.AirPavilion_Type //风亭子类型
|
2024-01-02 17:32:09 +08:00
|
|
|
|
PortA *PipePort //风亭A端口连接的设备
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func NewAirPavilion(id string, code string, pavilionType proto.AirPavilion_Type) *AirPavilion {
|
|
|
|
|
return &AirPavilion{
|
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_AirPavilion},
|
|
|
|
|
Code: code,
|
|
|
|
|
PavilionType: pavilionType,
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *AirPavilion) PortNum() int {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
2023-12-25 10:07:59 +08:00
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
// AirPavilionPort 风亭端口
|
|
|
|
|
//
|
|
|
|
|
// implement DevicePort
|
|
|
|
|
type AirPavilionPort struct {
|
|
|
|
|
port proto.Port
|
2023-12-25 14:40:15 +08:00
|
|
|
|
device *AirPavilion
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *AirPavilionPort) Port() proto.Port {
|
|
|
|
|
return p.port
|
|
|
|
|
}
|
|
|
|
|
func (p *AirPavilionPort) Device() PortedDevice {
|
|
|
|
|
return p.device
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// Valve 阀门(电动调节阀、电动风阀)
|
|
|
|
|
type Valve struct {
|
2023-12-25 10:07:59 +08:00
|
|
|
|
Identity
|
2023-12-25 13:40:00 +08:00
|
|
|
|
Code string
|
|
|
|
|
ValveType proto.Valve_Type //阀门子类型
|
2023-12-29 17:00:26 +08:00
|
|
|
|
PortA *PipePort //阀门A端口连接的设备
|
|
|
|
|
PortB *PipePort //阀门B端口连接的设备
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func NewValve(id string, code string, valveType proto.Valve_Type) *Valve {
|
|
|
|
|
return &Valve{
|
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_Valve},
|
|
|
|
|
Code: code,
|
|
|
|
|
ValveType: valveType,
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *Valve) PortNum() int {
|
|
|
|
|
return 2
|
|
|
|
|
}
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func (p *Valve) Ports() []*PipePort {
|
|
|
|
|
var ports []*PipePort
|
|
|
|
|
if p.PortA != nil {
|
|
|
|
|
ports = append(ports, p.PortA)
|
|
|
|
|
}
|
|
|
|
|
if p.PortB != nil {
|
|
|
|
|
ports = append(ports, p.PortB)
|
|
|
|
|
}
|
|
|
|
|
return ports
|
|
|
|
|
}
|
2023-12-25 10:07:59 +08:00
|
|
|
|
|
2023-12-25 14:09:29 +08:00
|
|
|
|
// ValvePort 阀门端口
|
2023-12-25 13:40:00 +08:00
|
|
|
|
//
|
|
|
|
|
// implement DevicePort
|
|
|
|
|
type ValvePort struct {
|
|
|
|
|
port proto.Port
|
|
|
|
|
device *Valve
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *ValvePort) Port() proto.Port {
|
|
|
|
|
return p.port
|
|
|
|
|
}
|
|
|
|
|
func (p *ValvePort) Device() PortedDevice {
|
|
|
|
|
return p.device
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
//////////////////////////////////////////////////
|
|
|
|
|
|
2023-12-25 10:07:59 +08:00
|
|
|
|
// GasMixingChamber 混合室静压箱(气体)
|
|
|
|
|
// 有四个端口,ABC三个端口为输入口,D端口为输出口
|
|
|
|
|
type GasMixingChamber struct {
|
|
|
|
|
Identity
|
2023-12-29 17:00:26 +08:00
|
|
|
|
Code string
|
|
|
|
|
PortsA []*PipePort //A端多个输入口
|
|
|
|
|
PortsB []*PipePort //B端多个输出口
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewGasMixingChamber(id string, code string) *GasMixingChamber {
|
|
|
|
|
return &GasMixingChamber{
|
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_GasMixingChamber},
|
|
|
|
|
Code: code,
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *GasMixingChamber) PortNum() int {
|
|
|
|
|
return 4
|
|
|
|
|
}
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func (p *GasMixingChamber) IsInput(pipeId string) bool {
|
|
|
|
|
for _, portA := range p.PortsA {
|
|
|
|
|
if pipeId == portA.pipe.Id() {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
|
|
|
|
|
// GasMixingChamberPort 混合室静压箱端口
|
|
|
|
|
//
|
|
|
|
|
// implement DevicePort
|
|
|
|
|
type GasMixingChamberPort struct {
|
|
|
|
|
port proto.Port
|
|
|
|
|
device *GasMixingChamber
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *GasMixingChamberPort) Port() proto.Port {
|
|
|
|
|
return p.port
|
|
|
|
|
}
|
|
|
|
|
func (p *GasMixingChamberPort) Device() PortedDevice {
|
|
|
|
|
return p.device
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////
|
2023-12-25 10:07:59 +08:00
|
|
|
|
|
|
|
|
|
// CombinationAirConditioner 组合式空调
|
|
|
|
|
// 有四个端口,新风输入端口A,工作风输出端口B;
|
|
|
|
|
// 端口C输出风再通过端口D输入,通过C->D实现对风再处理。
|
|
|
|
|
type CombinationAirConditioner struct {
|
|
|
|
|
Identity
|
2023-12-25 13:40:00 +08:00
|
|
|
|
Code string
|
2023-12-29 17:00:26 +08:00
|
|
|
|
PortA *PipePort //新风输入A端口连接的设备
|
|
|
|
|
PortB *PipePort //工作风输出B端口连接的设备
|
|
|
|
|
PortC *PipePort //C端口连接的设备
|
|
|
|
|
PortD *PipePort //D端口连接的设备
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewCombinationAirConditioner(id string, code string) *CombinationAirConditioner {
|
|
|
|
|
return &CombinationAirConditioner{
|
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_CombinationAirConditioner},
|
|
|
|
|
Code: code,
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *CombinationAirConditioner) PortNum() int {
|
|
|
|
|
return 4
|
|
|
|
|
}
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func (p *CombinationAirConditioner) Ports() []*PipePort {
|
|
|
|
|
var ports []*PipePort
|
|
|
|
|
if p.PortA != nil {
|
|
|
|
|
ports = append(ports, p.PortA)
|
|
|
|
|
}
|
2023-12-27 18:11:27 +08:00
|
|
|
|
if p.PortB != nil {
|
2023-12-29 17:00:26 +08:00
|
|
|
|
ports = append(ports, p.PortB)
|
2023-12-27 18:11:27 +08:00
|
|
|
|
}
|
|
|
|
|
if p.PortC != nil {
|
2023-12-29 17:00:26 +08:00
|
|
|
|
ports = append(ports, p.PortC)
|
2023-12-27 18:11:27 +08:00
|
|
|
|
}
|
|
|
|
|
if p.PortD != nil {
|
2023-12-29 17:00:26 +08:00
|
|
|
|
ports = append(ports, p.PortD)
|
2023-12-27 18:11:27 +08:00
|
|
|
|
}
|
2023-12-29 17:00:26 +08:00
|
|
|
|
return ports
|
2023-12-27 18:11:27 +08:00
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
|
|
|
|
|
// CombinationAirConditionerPort 组合式空调端口
|
|
|
|
|
//
|
|
|
|
|
// implement DevicePort
|
|
|
|
|
type CombinationAirConditionerPort struct {
|
|
|
|
|
port proto.Port
|
|
|
|
|
device *CombinationAirConditioner
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *CombinationAirConditionerPort) Port() proto.Port {
|
|
|
|
|
return p.port
|
|
|
|
|
}
|
|
|
|
|
func (p *CombinationAirConditionerPort) Device() PortedDevice {
|
|
|
|
|
return p.device
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////
|
2023-12-25 10:07:59 +08:00
|
|
|
|
|
|
|
|
|
// AirPurificationDevice 净化装置(对组合式空调B端口输出的工作风进行净化)
|
|
|
|
|
// 有两个端口,端口A输入,端口B输出
|
|
|
|
|
type AirPurificationDevice struct {
|
|
|
|
|
Identity
|
2023-12-25 13:40:00 +08:00
|
|
|
|
Code string
|
2023-12-29 17:00:26 +08:00
|
|
|
|
PortA *PipePort //A端口连接的设备
|
|
|
|
|
PortB *PipePort //B端口连接的设备
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewAirPurificationDevice(id string, code string) *AirPurificationDevice {
|
|
|
|
|
return &AirPurificationDevice{
|
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_AirPurificationDevice},
|
|
|
|
|
Code: code,
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *AirPurificationDevice) PortNum() int {
|
|
|
|
|
return 2
|
|
|
|
|
}
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func (p *AirPurificationDevice) Ports() []*PipePort {
|
|
|
|
|
var ports []*PipePort
|
|
|
|
|
if p.PortA != nil {
|
|
|
|
|
ports = append(ports, p.PortA)
|
|
|
|
|
}
|
|
|
|
|
if p.PortB != nil {
|
|
|
|
|
ports = append(ports, p.PortB)
|
|
|
|
|
}
|
|
|
|
|
return ports
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
|
|
|
|
|
// AirPurificationDevicePort 净化装置端口
|
|
|
|
|
//
|
|
|
|
|
// implement DevicePort
|
|
|
|
|
type AirPurificationDevicePort struct {
|
|
|
|
|
port proto.Port
|
|
|
|
|
device *AirPurificationDevice
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *AirPurificationDevicePort) Port() proto.Port {
|
|
|
|
|
return p.port
|
|
|
|
|
}
|
|
|
|
|
func (p *AirPurificationDevicePort) Device() PortedDevice {
|
|
|
|
|
return p.device
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////
|
2023-12-25 10:07:59 +08:00
|
|
|
|
|
|
|
|
|
// AirCurtain 空气幕
|
|
|
|
|
type AirCurtain struct {
|
|
|
|
|
Identity
|
|
|
|
|
Code string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewAirCurtain(id string, code string) *AirCurtain {
|
|
|
|
|
return &AirCurtain{
|
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_AirCurtain},
|
|
|
|
|
Code: code,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
//////////////////////////////////////////////////////////
|
|
|
|
|
|
2023-12-25 10:07:59 +08:00
|
|
|
|
// Fan 风机
|
|
|
|
|
type Fan struct {
|
|
|
|
|
Identity
|
2023-12-25 17:31:35 +08:00
|
|
|
|
Code string
|
|
|
|
|
FanType proto.Fan_Type
|
2023-12-26 17:52:28 +08:00
|
|
|
|
*fanRunningModel
|
2023-12-29 17:00:26 +08:00
|
|
|
|
PortA *PipePort //A端口连接的设备,风机出风口即排风口,输出端口
|
|
|
|
|
PortB *PipePort //B端口连接的设备,风机进风口,输入端口
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 17:31:35 +08:00
|
|
|
|
func NewFan(id string, code string, fanType proto.Fan_Type) *Fan {
|
2023-12-25 10:07:59 +08:00
|
|
|
|
return &Fan{
|
2023-12-26 17:52:28 +08:00
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_Fan},
|
|
|
|
|
Code: code,
|
|
|
|
|
FanType: fanType,
|
|
|
|
|
fanRunningModel: newFanRunningModel(fanType),
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-25 13:40:00 +08:00
|
|
|
|
func (p *Fan) PortNum() int {
|
|
|
|
|
return 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FanPort 风机端口
|
|
|
|
|
//
|
|
|
|
|
// implement DevicePort
|
|
|
|
|
type FanPort struct {
|
|
|
|
|
port proto.Port
|
|
|
|
|
device *Fan
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *FanPort) Port() proto.Port {
|
|
|
|
|
return p.port
|
|
|
|
|
}
|
|
|
|
|
func (p *FanPort) Device() PortedDevice {
|
|
|
|
|
return p.device
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-26 17:52:28 +08:00
|
|
|
|
type fanRunningModel struct {
|
|
|
|
|
maxSpeed float32
|
|
|
|
|
acTime uint16
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *fanRunningModel) MotorMaxSpeed() float32 {
|
|
|
|
|
return m.maxSpeed
|
|
|
|
|
}
|
|
|
|
|
func (m *fanRunningModel) MotorAcTime() uint16 {
|
|
|
|
|
return m.acTime
|
|
|
|
|
}
|
|
|
|
|
func newFanRunningModel(fanType proto.Fan_Type) *fanRunningModel {
|
|
|
|
|
switch fanType {
|
|
|
|
|
case proto.Fan_CommonFan:
|
|
|
|
|
return &fanRunningModel{maxSpeed: 3000, acTime: 2000}
|
|
|
|
|
case proto.Fan_HighLowSpeedFan:
|
|
|
|
|
return &fanRunningModel{maxSpeed: 6000, acTime: 4000}
|
|
|
|
|
case proto.Fan_FcBypassFan:
|
|
|
|
|
return &fanRunningModel{maxSpeed: 6000, acTime: 3000}
|
|
|
|
|
case proto.Fan_SoftStartFan:
|
|
|
|
|
return &fanRunningModel{maxSpeed: 100, acTime: 4000}
|
|
|
|
|
default:
|
|
|
|
|
return &fanRunningModel{maxSpeed: 3000, acTime: 2000}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-25 13:40:00 +08:00
|
|
|
|
////////////////////////////////////////////////
|
2023-12-25 10:07:59 +08:00
|
|
|
|
|
2023-12-29 17:00:26 +08:00
|
|
|
|
// Environment 环境
|
|
|
|
|
// 有多个输入口,统一为端口A
|
|
|
|
|
// 有多个输出口,统一为端口B
|
|
|
|
|
type Environment struct {
|
2023-12-25 10:07:59 +08:00
|
|
|
|
Identity
|
2023-12-25 13:40:00 +08:00
|
|
|
|
Code string
|
|
|
|
|
PortsA []DevicePort // 有多个输入口,统一为端口A,用来为环境补充新鲜空气;
|
|
|
|
|
PortsB []DevicePort // 有多个输出口,统一为端口B,用户将环境的混浊气体排除;
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func NewEnvironment(id string, code string) *Environment {
|
|
|
|
|
return &Environment{
|
|
|
|
|
Identity: &identity{id: id, deviceType: proto.DeviceType_DeviceType_Environment},
|
2023-12-25 14:09:29 +08:00
|
|
|
|
Code: code,
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func (p *Environment) PortNum() int {
|
2023-12-25 13:40:00 +08:00
|
|
|
|
return len(p.PortsA) + len(p.PortsB)
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-29 17:00:26 +08:00
|
|
|
|
// EnvironmentPort 气体环境端口
|
2023-12-25 13:40:00 +08:00
|
|
|
|
//
|
|
|
|
|
// implement DevicePort
|
2023-12-29 17:00:26 +08:00
|
|
|
|
type EnvironmentPort struct {
|
2023-12-25 13:40:00 +08:00
|
|
|
|
port proto.Port
|
2023-12-29 17:00:26 +08:00
|
|
|
|
device *Environment
|
2023-12-25 13:40:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func (p *EnvironmentPort) Port() proto.Port {
|
2023-12-25 13:40:00 +08:00
|
|
|
|
return p.port
|
|
|
|
|
}
|
2023-12-29 17:00:26 +08:00
|
|
|
|
func (p *EnvironmentPort) Device() PortedDevice {
|
2023-12-25 13:40:00 +08:00
|
|
|
|
return p.device
|
2023-12-25 10:07:59 +08:00
|
|
|
|
}
|