org.yamcs.artemis.PpTupleTranslator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yamcs-artemis Show documentation
Show all versions of yamcs-artemis Show documentation
Yamcs Artemis senders/receivers
package org.yamcs.artemis;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.yamcs.StandardTupleDefinitions;
import org.yamcs.api.artemis.ArtemisApiException;
import org.yamcs.api.artemis.Protocol;
import org.yamcs.protobuf.Pvalue.ParameterData;
import org.yamcs.protobuf.Pvalue.ParameterData.Builder;
import org.yamcs.protobuf.Pvalue.ParameterValue;
import org.yamcs.protobuf.Yamcs.NamedObjectId;
import org.yamcs.yarch.DataType;
import org.yamcs.yarch.Tuple;
import org.yamcs.yarch.TupleDefinition;
/**
* Translates between Processed Parameter tuples and ActiveMQ messages.
*
* @author atu
*/
public class PpTupleTranslator implements TupleTranslator {
@Override
public ClientMessage buildMessage(ClientMessage msg, Tuple tuple) {
long genTime = (Long) tuple.getColumn(StandardTupleDefinitions.PARAMETER_COL_GENTIME);
msg.putLongProperty(StandardTupleDefinitions.PARAMETER_COL_GENTIME, genTime);
String ppGroup = (String) tuple.getColumn(StandardTupleDefinitions.PARAMETER_COL_GROUP);
msg.putStringProperty(StandardTupleDefinitions.PARAMETER_COL_GROUP, ppGroup);
msg.putIntProperty(StandardTupleDefinitions.PARAMETER_COL_SEQ_NUM,
(Integer) tuple.getColumn(StandardTupleDefinitions.PARAMETER_COL_SEQ_NUM));
msg.putLongProperty(StandardTupleDefinitions.PARAMETER_COL_RECTIME,
(Long) tuple.getColumn(StandardTupleDefinitions.PARAMETER_COL_RECTIME));
Builder b = ParameterData.newBuilder();
b.setGenerationTime(genTime);
b.setGroup(ppGroup);
for (int i = 4; i < tuple.size(); i++) {
// PP name is part of the instance
org.yamcs.parameter.ParameterValue ppValue = (org.yamcs.parameter.ParameterValue) tuple.getColumn(i);
b.addParameter(
ppValue.toGpb(NamedObjectId.newBuilder().setName(ppValue.getParameterQualifiedNamed()).build()));
}
Protocol.encode(msg, b.build());
return msg;
}
@Override
public Tuple buildTuple(ClientMessage message) {
Tuple t = null;
try {
ParameterData pd = (ParameterData) Protocol.decode(message, ParameterData.newBuilder());
TupleDefinition tupleDef = StandardTupleDefinitions.PARAMETER.copy();
ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy