2023-09-28 14:10:15 +08:00
|
|
|
package repository
|
|
|
|
|
|
|
|
import "joylink.club/rtsssimulation/repository/model/proto"
|
|
|
|
|
2023-09-28 14:34:00 +08:00
|
|
|
// 组合的电子元件
|
|
|
|
type IGroupedElectronicComponent interface {
|
|
|
|
Identity
|
|
|
|
Code() string
|
|
|
|
}
|
|
|
|
|
2023-09-28 14:10:15 +08:00
|
|
|
// Relay 继电器
|
|
|
|
type Relay struct {
|
|
|
|
Identity
|
|
|
|
code string
|
|
|
|
model proto.Relay_Model
|
|
|
|
}
|
|
|
|
|
|
|
|
func newRelay(id string, code string, model proto.Relay_Model) *Relay {
|
|
|
|
return &Relay{
|
|
|
|
Identity: identity{
|
|
|
|
id: id,
|
|
|
|
deviceType: proto.DeviceType_DeviceType_Relay,
|
|
|
|
},
|
|
|
|
code: code,
|
|
|
|
model: model,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Relay) Code() string {
|
|
|
|
return r.code
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Relay) Model() proto.Relay_Model {
|
|
|
|
return r.model
|
|
|
|
}
|
|
|
|
|
|
|
|
// ElectronicComponentGroup 电子元件组合
|
|
|
|
type ElectronicComponentGroup struct {
|
|
|
|
code string
|
2023-09-28 14:34:00 +08:00
|
|
|
components []IGroupedElectronicComponent
|
2023-09-28 14:10:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ElectronicComponentGroup) Code() string {
|
|
|
|
return r.code
|
|
|
|
}
|
|
|
|
|
2023-09-28 14:34:00 +08:00
|
|
|
func (r *ElectronicComponentGroup) Components() []IGroupedElectronicComponent {
|
2023-09-28 14:10:15 +08:00
|
|
|
return r.components
|
|
|
|
}
|
|
|
|
|
|
|
|
// PhaseFailureProtector 断相保护器
|
|
|
|
type PhaseFailureProtector struct {
|
|
|
|
Identity
|
|
|
|
code string
|
|
|
|
}
|
|
|
|
|
2023-09-28 14:34:00 +08:00
|
|
|
func (dbq *PhaseFailureProtector) Code() string {
|
|
|
|
return dbq.code
|
|
|
|
}
|
|
|
|
|
2023-09-28 14:10:15 +08:00
|
|
|
func newPhaseFailureProtector(id string, code string) *PhaseFailureProtector {
|
|
|
|
return &PhaseFailureProtector{
|
|
|
|
Identity: identity{
|
|
|
|
id: id,
|
|
|
|
deviceType: proto.DeviceType_DeviceType_PhaseFailureProtector,
|
|
|
|
},
|
|
|
|
code: code,
|
|
|
|
}
|
|
|
|
}
|
2023-10-13 15:26:25 +08:00
|
|
|
|
|
|
|
// 按钮
|
|
|
|
type Button struct {
|
|
|
|
Identity
|
|
|
|
code string
|
|
|
|
buttonType proto.Button_ButtonType
|
2023-10-18 14:08:10 +08:00
|
|
|
hasLight bool
|
2023-10-13 15:26:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewButton(id string, code string, buttonType proto.Button_ButtonType) *Button {
|
|
|
|
return &Button{
|
|
|
|
Identity: identity{id, proto.DeviceType_DeviceType_Button},
|
|
|
|
code: code,
|
|
|
|
buttonType: buttonType,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (btn *Button) Code() string {
|
|
|
|
return btn.code
|
|
|
|
}
|
|
|
|
|
|
|
|
func (btn *Button) GetBtnType() proto.Button_ButtonType {
|
|
|
|
return btn.buttonType
|
|
|
|
}
|
|
|
|
|
2023-10-18 11:17:08 +08:00
|
|
|
func (btn *Button) SetLight() {
|
2023-10-18 14:08:10 +08:00
|
|
|
btn.hasLight = true
|
2023-10-18 11:17:08 +08:00
|
|
|
}
|
|
|
|
|
2023-10-18 14:08:10 +08:00
|
|
|
func (btn *Button) HasLight() bool {
|
|
|
|
return btn.hasLight
|
2023-10-18 11:17:08 +08:00
|
|
|
}
|
|
|
|
|
2023-10-13 15:26:25 +08:00
|
|
|
// 报警器
|
|
|
|
type Alarm struct {
|
|
|
|
Identity
|
|
|
|
code string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Alarm) Code() string {
|
|
|
|
return a.code
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewAlarm(id string, code string) *Alarm {
|
|
|
|
return &Alarm{
|
|
|
|
Identity: identity{id, proto.DeviceType_DeviceType_Alarm},
|
|
|
|
code: code,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 指示灯
|
|
|
|
type Light struct {
|
|
|
|
Identity
|
|
|
|
code string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Light) Code() string {
|
|
|
|
return a.code
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLight(id string, code string) *Light {
|
|
|
|
return &Light{
|
|
|
|
Identity: identity{id, proto.DeviceType_DeviceType_Light},
|
|
|
|
code: code,
|
|
|
|
}
|
|
|
|
}
|
2023-10-20 13:13:44 +08:00
|
|
|
|
|
|
|
// 钥匙
|
|
|
|
type Key struct {
|
|
|
|
Identity
|
|
|
|
code string
|
|
|
|
gear int32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Key) Code() string {
|
|
|
|
return a.code
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewKey(id string, code string, gear int32) *Key {
|
|
|
|
return &Key{
|
|
|
|
Identity: identity{id, proto.DeviceType_DeviceType_Key},
|
|
|
|
code: code,
|
|
|
|
gear: gear,
|
|
|
|
}
|
|
|
|
}
|