Exemple #1
0
	/**
	 * If the given message contains tags, this method can be used
	 * to parse its contents.
	 * @param sampleMsgString the contents of the message
	 */
	private void parseMessageWithTags(ByteString sampleMsgString) {
		logger.info("Tag recorder: got a tag!");

		final SvarogProtocol.Tag tagMsg;
		try {
			tagMsg = SvarogProtocol.Tag.parseFrom(sampleMsgString);
		} catch (Exception e) {
			logger.error("", e);
			return;
		}

		// TODO: By now we ignore field channels and assume that tag if for all channels
		final double tagLen = tagMsg.getEndTimestamp() - tagMsg.getStartTimestamp();

		TagStyle style = tagSet.getStyle(SignalSelectionType.CHANNEL, tagMsg.getName());

		if (style == null) {
			style = stylesGenerator.getSmartStyleFor(tagMsg.getName(), tagLen, -1);
			tagSet.addStyle(style);
		}

		final MonitorTag tag = new MonitorTag(style,
											  tagMsg.getStartTimestamp(),
											  tagLen,
											  -1);

		for (SvarogProtocol.Variable v : tagMsg.getDesc().getVariablesList()) {
			if (v.getKey().equals("annotation")) {
				tag.setAnnotation(v.getValue());
			}
			else {
				tag.addAttributeToTag(v.getKey(), v.getValue());
			}
		}
		publish(tag);
	}