diff --git a/fi/iscs_fas.go b/fi/iscs_fas.go new file mode 100644 index 0000000..eb1ad39 --- /dev/null +++ b/fi/iscs_fas.go @@ -0,0 +1,36 @@ +package fi + +import ( + "fmt" + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/entity" +) + +// SmokeDetectorIsolateOperate 烟感隔离设置 +func SmokeDetectorIsolateOperate(w ecs.World, deviceId string, isolate bool) error { + r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] { + wd := entity.GetWorldData(w) + deviceEntry, ok := wd.EntityMap[deviceId] + if !ok { + return ecs.NewErrResult(fmt.Errorf("设备[%s]实体不存在", deviceId)) + } + // + if !(deviceEntry.HasComponent(component.SmokeDetectorType)) { + return ecs.NewErrResult(fmt.Errorf("设备[%s]不是烟感", deviceId)) + } + detector := component.SmokeDetectorType.Get(deviceEntry) + if isolate { + detector.Act = component.StaIsolate + } else { + if detector.Act == component.StaIsolate { + detector.Act = component.StaNon + } else { + return ecs.NewErrResult(fmt.Errorf("烟感[%s]当前不处于隔离态,不能执行取消隔离操作", deviceId)) + } + } + // + return ecs.NewOkEmptyResult() + }) + return r.Err +} diff --git a/sys/iscs_sys/iscs_fas_manual_fire_alarm_button.go b/sys/iscs_sys/iscs_fas_manual_fire_alarm_button.go new file mode 100644 index 0000000..62e8a00 --- /dev/null +++ b/sys/iscs_sys/iscs_fas_manual_fire_alarm_button.go @@ -0,0 +1,36 @@ +package iscs_sys + +import ( + "joylink.club/ecs" + "joylink.club/ecs/filter" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/consts" +) + +// ManualFireAlarmButtonSystem 手动火灾报警按钮 +type ManualFireAlarmButtonSystem struct { + query *ecs.Query +} + +func NewManualFireAlarmButtonSystem() *ManualFireAlarmButtonSystem { + return &ManualFireAlarmButtonSystem{ + query: ecs.NewQuery(filter.Contains(component.UidType, component.ManualFireAlarmButtonType)), + } +} +func (s *ManualFireAlarmButtonSystem) Update(w ecs.World) { + s.query.Each(w, func(entry *ecs.Entry) { + button := component.ManualFireAlarmButtonType.Get(entry) + // + button.Exception = consts.DeviceExceptionNon + if entry.HasComponent(component.DeviceFaultTag) { + button.Exception = consts.DeviceFault + } + if entry.HasComponent(component.DeviceCommunicationInterruptTag) { + button.Exception = consts.DeviceCommunicationInterrupt + } + //todo act + + // + button.Normal = button.Exception == consts.DeviceExceptionNon && button.Act == component.MfabNon + }) +}