-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added switches to the status dashboard. Visuals are still ugly, but u…
…niformly so (#268)
- Loading branch information
1 parent
b7a5ef1
commit 08abb9d
Showing
4 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
dz3r-director/src/main/java/net/sf/dz3r/instrumentation/SwitchStatusProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.sf.dz3r.instrumentation; | ||
|
||
import net.sf.dz3r.device.actuator.Switch; | ||
import net.sf.dz3r.signal.Signal; | ||
import net.sf.dz3r.signal.SignalProcessor; | ||
import net.sf.dz3r.signal.health.SwitchStatus; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import reactor.core.publisher.Flux; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Consumes individual switch signal, emits switch status. | ||
* | ||
* @author Copyright © <a href="mailto:[email protected]">Vadim Tkachenko 2001-2023 | ||
*/ | ||
public class SwitchStatusProcessor implements SignalProcessor<Switch.State, SwitchStatus, String> { | ||
|
||
private final Logger logger = LogManager.getLogger(); | ||
|
||
private final String id; | ||
|
||
public SwitchStatusProcessor(String id) { | ||
this.id = id; | ||
|
||
logger.info("created switch status processor for id={}", id); | ||
} | ||
|
||
@Override | ||
public Flux<Signal<SwitchStatus, String>> compute(Flux<Signal<Switch.State, String>> in) { | ||
return in.map(this::compute); | ||
} | ||
|
||
private Signal<SwitchStatus, String> compute(Signal<Switch.State, String> source) { | ||
|
||
if (source.isError()) { | ||
// Nothing else matters | ||
return new Signal<>(source.timestamp, null, null, source.status, source.error); | ||
} | ||
|
||
// VT: FIXME: Pass/fail is the only thing of interest right now | ||
return new Signal<>(source.timestamp, new SwitchStatus(Optional.empty())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters