com.github.jy2.commandline.picocli.topic.TopicHzCommand Maven / Gradle / Ivy
package com.github.jy2.commandline.picocli.topic;
import java.util.function.Consumer;
import com.github.jy2.commandline.picocli.Main;
import com.github.jy2.commandline.picocli.topic.completion.TopicNameCompletionCandidates;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParentCommand;
@Command(name = "hz", description = "Print publishing rate of topics")
public class TopicHzCommand implements Runnable {
@ParentCommand
TopicCommand parent;
@Parameters(index = "0", description = "Name of the topic", completionCandidates = TopicNameCompletionCandidates.class)
String topicName;
@Option(names = { "--period" }, description = "Measurement period in seconds")
double periodSeconds = 1;
public void run() {
System.out.printf("Subscribed to topic: %s, minimal measurement period: %.3f s\n", topicName, periodSeconds);
System.out.println("Press Crtl-C to stop");
Class type = Main.introspector.getTopicType(topicName);
TopicEchoCommand.subscriber = Main.di.createSubscriber(topicName, type, 5, 50);
TopicEchoCommand.subscriber.addMessageListener(new Consumer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy