Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.yamcs;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yamcs.mdb.MdbFactory;
import org.yamcs.xtce.SequenceContainer;
import org.yamcs.mdb.Mdb;
/**
* Stores the value of the streamConfiguration parameter from yamcs.instance.yaml Used to create the streams at Yamcs
* startup and by various other services (recording, processor, ...)
*
*/
public class StreamConfig {
public enum StandardStreamType {
CMD_HIST, TM, PARAM, TC, EVENT, PARAMETER_ALARM, EVENT_ALARM, SQL_FILE, INVALID_TM;
public static StandardStreamType fromString(String s) {
for (StandardStreamType v : values()) {
if (v.name().replace("_", "").equals(s.toUpperCase())) {
return v;
}
}
throw new IllegalArgumentException("No stream type by this name");
}
}
List entries = new ArrayList<>();
static Map instances = new HashMap<>();
Logger log = LoggerFactory.getLogger(this.getClass().getName());
public static synchronized StreamConfig getInstance(String yamcsInstance) throws ConfigurationException {
return instances.computeIfAbsent(yamcsInstance, StreamConfig::new);
}
public static synchronized void removeInstance(String instanceName) {
instances.remove(instanceName);
}
@SuppressWarnings("unchecked")
private StreamConfig(String yamcsInstance) {
Mdb mdb = MdbFactory.getInstance(yamcsInstance);
YamcsServerInstance instance = YamcsServer.getServer().getInstance(yamcsInstance);
YConfiguration instanceConfig = instance.getConfig();
if (!instanceConfig.containsKey("streamConfig")) {
log.warn("No streamConfig defined for instance {}", yamcsInstance);
return;
}
YConfiguration streamConfigAll = instanceConfig.getConfig("streamConfig");
for (String streamType : streamConfigAll.getRoot().keySet()) {
if ("alarm".equals(streamType)) {
log.warn("Deprecation in streamConfig, please change 'alarm' into 'parameterAlarm'"
+ " (since version 4.10 there is also eventAlarm)");
streamType = "parameterAlarm";
}
StandardStreamType type = null;
try {
type = StandardStreamType.fromString(streamType);
} catch (IllegalArgumentException e) {
throw new ConfigurationException("Unknown stream type '" + streamType + "'");
}
Object o = streamConfigAll.get(streamType);
if (o instanceof String) {
addEntry(type, (String) o);
} else if (o instanceof List) {
List