void MonitorPlugInActiveMQ::parseTopics(XMLNode config, Topics &topics, TopicInfo &referenceTopic)
{
	XMLNode topicNode;
	Topics::iterator i;
	TopicInfo *pTopicInfo;
	
	// defaults
	vector<string> channels;
	channels.push_back(ACTIVEMQ_KEY_POCSAG);
	channels.push_back(ACTIVEMQ_KEY_ZVEI);
	channels.push_back(ACTIVEMQ_KEY_FMS);
	
	for (unsigned int i = 0, m = channels.size(); i < m; i++)
	{
		pTopicInfo = new TopicInfo;
		initializeTopic(*pTopicInfo, referenceTopic);
		topics.insert(PairMapping(channels.at(i), pTopicInfo));
	}

	int nTopic = config.nChildNode(ACTIVEMQ_XMLNODE_TOPIC);
	
	for (int num = 0; num < nTopic ; ++num)
	{
		if (!((topicNode = config.getChildNode(ACTIVEMQ_XMLNODE_TOPIC, num))).isEmpty()) {
			std::string type = topicNode.getAttribute(ACTIVEMQ_XMLATTR_TYPE) ;
			
			if ((type == ACTIVEMQ_KEY_POCSAG) || (type == ACTIVEMQ_KEY_FMS) || (type == ACTIVEMQ_KEY_ZVEI)) {
				pTopicInfo = (topics.find(type))->second;
				parseTopic(topicNode, *pTopicInfo, referenceTopic);
			}
		}
	}
}
Esempio n. 2
0
Topics createRandomTopics(unsigned int i)
{
	Topics ret;
	h256 t(i);

	for (int j = 0; j < 8; ++j)
	{
		t = sha3(t);
		ret.push_back(t);
	}

	return ret;
}
/**
 * Putting it all together.
 *
 * @param  argc
 * @param  argv
 * @return
 */
int main(int argc, char* argv[]) {
  // Default options.
  icu::UnicodeString database = "dummy1";
  bool loop = false;
  bool echo = false;
  int rate = 1000;

  // Parse command line arguments.
  for (int i = 0; i < argc; i++) {
    if (0 == std::strcmp(argv[i], "-loop")) {
      loop = true;
    } else if (0 == std::strcmp(argv[i], "-echo")) {
      echo = true;
    } else if (0 == std::strncmp(argv[i], "-rate=", 6)) {
      rate = utils::toInt(std::string(argv[i]).substr(6));
    } else if (0 == std::strncmp(argv[i], "-database=", 10)) {
      database = utils::toUS(std::string(argv[i]).substr(10));
    }
  }

  // Initalize and run annotators
  AnnotationGateway gateway = AnnotationGateway();
  gateway.setParameter("Database", database);
  gateway.run();

  // Get required iterators.
  uima::Feature jnFtr = gateway.getFeature("JointState", "jointNames");
  uima::ANIterator jsIter = gateway.getANIterator("JointState");
  std::vector<std::string> jointNames;
  jointNames = utils::toVector(jsIter.get().getStringArrayFSValue(jnFtr));

  // Let user choose which joints to display.
  std::pair< std::vector<int>, std::vector<std::string> > selected;
  selected = chooseJoints(jointNames);

  std::string plot = choosePlot(selected.first.size());
  coutlinesep();

  // Initialize ros.
  ros::init(argc, argv, "rta_plotting");
  ros::NodeHandle node;

  // Fire off the topic!
  Topics topics = Topics(node, gateway, selected, rate, loop, echo);
  topics.plot(plot);

  return 0;
}
Esempio n. 4
0
void sealAndOpenSingleMessage(unsigned int i)
{
	Secret zero;
	Topics topics = createRandomTopics(i);
	bytes const payload = createRandomPayload(i);
	Message m1(payload);
	Envelope e = m1.seal(zero, topics, 1, 1);

	for (auto const& t: topics)
	{
		Topics singleTopic;
		singleTopic.push_back(t);
		Message m2(e, singleTopic, zero);
		comparePayloads(m1, m2);
	}
}
Esempio n. 5
0
AbridgedTopics dev::shh::abridge(Topics const& _topics)
{
	AbridgedTopics ret;
	ret.reserve(_topics.size());
	for (auto const& t: _topics)
		ret.push_back(abridge(t));
	return ret;
}
Esempio n. 6
0
static void showTopicList(const Topics& topics)
{
    if (topics.empty()) {
        std::cout << "Topic list is empty" << std::endl;
    } else {
        for (const auto& topic : topics) {
            std::cout << (boost::format("Topic: id '%1%', name '%2%', type '%3%'")
                % topic.id % topic.name % LoggingUtils::TopicSubscriptionTypeToString(topic.subscriptionType)) << std::endl;
        }
    }
}
Esempio n. 7
0
static bool isTopicsEqual(const Topics& actualTopics, const Topics& expectedTopics)
{
    if (actualTopics.size() != expectedTopics.size()) {
        return false;
    }

    for (const auto& actualTopic : actualTopics) {
        bool found = false;
        for (const auto& expectedTopic : expectedTopics) {
            if (actualTopic.id == expectedTopic.id && actualTopic.name == expectedTopic.name &&
                    actualTopic.subscriptionType == expectedTopic.subscriptionType)
            {
                found = true;
                break;
            }
        }
        if (!found) {
            return false;
        }
    }

   return true;
}
void MonitorPlugInActiveMQ::initializeTopics(Topics &topics)
{
	if (m_bConnected == false) {
		throw RuntimeException(__FILE__, __LINE__, "Tried to initialize topics without established ActiveMQ connection. Call initializeActiveMqConnection() first.");
	}

	Topics::iterator i;
	TopicInfo *pTopicInfo;

	// create new producers
	for (i = topics.begin(); i != topics.end(); i++)
	{
		pTopicInfo = i->second;
		
		if (pTopicInfo->bUseTopic) {
			pTopicInfo->destination = m_session->createTopic(pTopicInfo->destUri);
		} 
		else {
			pTopicInfo->destination = m_session->createQueue(pTopicInfo->destUri);
		}

		pTopicInfo->producer = m_session->createProducer(pTopicInfo->destination);

		if (pTopicInfo->bDeliveryModePersistent) {
			pTopicInfo->producer->setDeliveryMode(DeliveryMode::PERSISTENT);
		} 
		else {
			pTopicInfo->producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT);
		}
		
		FILE_LOG(logINFO) << "Topic destination \"" << pTopicInfo->destination << "\" created";
	}

	FILE_LOG(logINFO) << "Topics initialized";
		
	m_bTopicsInitialized = true;
}