79 lines
1.5 KiB
Go
79 lines
1.5 KiB
Go
package repository
|
|
|
|
type IBP struct {
|
|
Spk *IBPRefMap
|
|
Emp *IBPRefMap
|
|
}
|
|
|
|
func NewIBP() *IBP {
|
|
return &IBP{
|
|
Spk: &IBPRefMap{
|
|
buttonMap: make(map[string]*Button),
|
|
relayMap: make(map[string]*Relay),
|
|
alarmMap: make(map[string]*Alarm),
|
|
lightMap: make(map[string]*Light),
|
|
},
|
|
Emp: &IBPRefMap{
|
|
buttonMap: make(map[string]*Button),
|
|
relayMap: make(map[string]*Relay),
|
|
alarmMap: make(map[string]*Alarm),
|
|
lightMap: make(map[string]*Light),
|
|
},
|
|
}
|
|
}
|
|
|
|
type IBPRefMap struct {
|
|
buttonMap map[string]*Button
|
|
relayMap map[string]*Relay
|
|
alarmMap map[string]*Alarm
|
|
lightMap map[string]*Light
|
|
}
|
|
|
|
func (ibp *IBPRefMap) AddButton(btn *Button) {
|
|
ibp.buttonMap[btn.Id()] = btn
|
|
}
|
|
|
|
func (ibp *IBPRefMap) AddRelay(relay *Relay) {
|
|
ibp.relayMap[relay.Id()] = relay
|
|
}
|
|
|
|
func (ibp *IBPRefMap) AddLight(light *Light) {
|
|
ibp.lightMap[light.Id()] = light
|
|
}
|
|
|
|
func (ibp *IBPRefMap) AddAlarm(fmq *Alarm) {
|
|
ibp.alarmMap[fmq.Id()] = fmq
|
|
}
|
|
|
|
func (ibp *IBPRefMap) Buttons() []*Button {
|
|
var buttons []*Button
|
|
for _, b := range ibp.buttonMap {
|
|
buttons = append(buttons, b)
|
|
}
|
|
return buttons
|
|
}
|
|
|
|
func (ibp *IBPRefMap) Relays() []*Relay {
|
|
var relays []*Relay
|
|
for _, b := range ibp.relayMap {
|
|
relays = append(relays, b)
|
|
}
|
|
return relays
|
|
}
|
|
|
|
func (ibp *IBPRefMap) Alarms() []*Alarm {
|
|
var alarms []*Alarm
|
|
for _, b := range ibp.alarmMap {
|
|
alarms = append(alarms, b)
|
|
}
|
|
return alarms
|
|
}
|
|
|
|
func (ibp *IBPRefMap) Lights() []*Light {
|
|
var lights []*Light
|
|
for _, b := range ibp.lightMap {
|
|
lights = append(lights, b)
|
|
}
|
|
return lights
|
|
}
|