/** * Open GOSS channel * @param comm communicator for whatever module is opening the channel * @param topic channel topic. This must be chosen from list of topics * used to initialize the GOSSUtils object */ void gridpack::goss::GOSSUtils::openGOSSChannel(gridpack::parallel::Communicator &comm, std::string topic) { p_grp = comm.getGroup(); if (!p_open && GA_Pgroup_nodeid(p_grp) == 0) { printf("Opening Channel\n"); #ifndef GOSS_DEBUG std::auto_ptr<ActiveMQConnectionFactory> connectionFactory(new ActiveMQConnectionFactory(p_URI)); // Create a Connection p_connection = connectionFactory->createConnection(p_username, p_passwd); p_connection->start(); // Create a Session p_session = p_connection->createSession(Session::AUTO_ACKNOWLEDGE); #endif // Create the destination (Topic or Queue) std::string new_topic("topic.goss.gridpack."); //std::string new_topic("topic/goss/gridpack/"); // Make sure there is no white space around topic gridpack::utility::StringUtils utils; utils.trim(topic); new_topic.append(topic); p_current_topic = topic; printf("new topic = %s\n", new_topic.c_str()); #ifndef GOSS_DEBUG p_destination = p_session->createTopic(new_topic); // Create a MessageProducer from the Session to the Topic p_producer = p_session->createProducer(p_destination); p_producer->setDeliveryMode(DeliveryMode::NON_PERSISTENT); char sbuf[256]; gridpack::utility::CoarseTimer *timer = gridpack::utility::CoarseTimer::instance(); sprintf(sbuf,"_goss_channel_opened %f",timer->currentTime()); std::auto_ptr<TextMessage> message(p_session->createTextMessage(sbuf)); sprintf(sbuf,"_goss_channel_opened topic: %s %f",topic.c_str(), timer->currentTime()); printf("%s\n",sbuf); p_producer->send(message.get()); #endif p_open = true; } else { if (GA_Pgroup_nodeid(p_grp) == 0) { printf("ERROR: Channel already opened\n"); } } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), topicModel(new QStandardItemModel(parent)), topicFilter(new QSortFilterProxyModel(parent)), listModel(new QStandardItemModel(parent)), md(nullptr) { ui->setupUi(this); // Add the icons ui->actionConnect->setIcon(QIcon(":/images/network_server_database.png")); ui->actionRefresh->setIcon(QIcon(":/images/refresh.png")); ui->actionExit->setIcon(QIcon(":/images/exit.png")); ui->actionAbout_mywebQApp->setIcon(QIcon(":/images/info.png")); ui->toolBar->addAction(ui->actionConnect); ui->toolBar->addAction(ui->actionRefresh); ui->toolBar->addSeparator(); ui->toolBar->addAction(ui->actionExit); move(550,100); // the topic views topicFilter->setSourceModel(topicModel); ui->topicTableView->setModel(topicFilter); //ui->topicTableView->setSelectionBehavior(QAbstractItemView::SelectRows); // the list views ui->listTableView->setModel(listModel); // signals and slots connect( ui->actionConnect, SIGNAL(triggered()), this, SLOT(connect2mysql()) ); connect( ui->actionAbout_mywebQApp, SIGNAL(triggered()), this, SLOT(about()) ); connect( ui->actionExit, SIGNAL(triggered()), this, SLOT(close()) ); // topics and lists connect( ui->actionRefresh, SIGNAL(triggered()), this, SLOT(load_topics()) ); connect( ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filter_topics(QString)) ); connect( ui->addTopicButton, SIGNAL(clicked()), this, SLOT(new_topic()) ); connect( ui->saveTopicButton, SIGNAL(clicked()), this, SLOT(save_topic()) ); connect( ui->deleteTopicButton, SIGNAL(clicked()), this, SLOT(delete_topic()) ); connect( ui->EditTopicButton, SIGNAL(clicked()), this, SLOT(edit_topic()) ); connect( ui->topicTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(load_lists()) ); connect( ui->topicTableView, SIGNAL(activated(QModelIndex)), this, SLOT(load_lists()) ); connect( ui->addListButton, SIGNAL(clicked()), this, SLOT(new_list()) ); connect( ui->saveListButton, SIGNAL(clicked()), this, SLOT(save_list()) ); connect( ui->deleteListButton, SIGNAL(clicked()), this, SLOT(delete_list()) ); connect( ui->EditListButton, SIGNAL(clicked()), this, SLOT(edit_list()) ); }