InterfaceTester::InterfaceTester( int Number, int Range ) { commandNumber = Number; commandRange = Range; createCommands(); // генерируем команды clock_t vectorTime = Testing( Vector, false ); std::cout << "Vector is tested. Time : " << vectorTime << std::endl; clock_t treapTime = Testing( Treap, true ); std::cout << "Treap is tested. Time : " << treapTime << std::endl; bool flag = ( vectorAns.size() == treapAns.size() ); // сравниваем количество ответов там и там if( !flag ) std::cout << "- Answers have different size. - " << std::endl; int k = 0; // если их поровну - сравниваем овтеты if( flag ) for( int i = 0; i < vectorAns.size(); ++i ) { flag = ( vectorAns[i] == treapAns[i] ); if( !flag ) { ++k; } } // выводим результат тестирования if( flag ) std::cout << "+ Answers are the same. Tested succesfuly. + " << std::endl; else std::cout << "- Answers are different. Tested unsuccesfuly. - . Number of wrong answers " << k << std::endl; }
/** * Constructor that takes an existing ircInterface instance */ omnibot::omnibot(ircInterface* irc_):_irc(irc_),_nicks(),_manager(_irc, _nicks),/*_blocker(OmniBlocker::create()),*/_passedIrc(true){ //std::cout << std::hex << &irc_ << std::dec << std::endl; ircLog::instance()->logf(FILENAME, "ircInteface instance: %x", &irc_); _irc->registerForNotify(this); _commands = new std::vector<OmniCommand*>(); createCommands(); ircLog::instance()->logf(FILENAME, "size of _commands after createCommands %u", _commands->size()); }
/** * Constructor that creates a new instance of irc interface when the bot is created. */ omnibot::omnibot():_irc(new ircInterface()), _nicks(), _manager(_irc, _nicks),_passedIrc(false){ /* should create an irc instance here and connec but i don't think this is possible... you would need a default server... maybe I should just take the empty constructor out*/ //ircLog::instance()->logf(FILENAME, "ircInteface instance: %x", &irc_); _irc->registerForNotify(this); _commands = new std::vector<OmniCommand*>(); createCommands(); ircLog::instance()->logf(FILENAME, "size of _commands after createCommands %u", _commands->size()); }
//------------------------------------------------------------------------------ CPatch::CPatch() : commands_( createCommands() ) { }
KiloWindow::KiloWindow(QWidget *parent): QWidget(parent), device(0), sending(false), connected(false) { // Create status bar status = new QStatusBar(); status->showMessage("disconnected."); status->setSizeGripEnabled(false); // Create status bar button connect_button = new QToolButton(status); status->addPermanentWidget(connect_button); connect_button->setText("Connect"); connect(connect_button, SIGNAL(clicked()), this, SLOT(toggleConnection())); // Create serial input window and its trigger button serial_button = new QPushButton("Serial Input"); serial = new SerialWindow("Serial Input", this); QObject::connect(serial_button, SIGNAL(clicked()), this, SLOT(serialShow())); // Create calibration window and its trigger button calib_button = new QPushButton("Calibration"); calib = new CalibWindow("Calibration Values", this); QObject::connect(calib_button, SIGNAL(clicked()), this, SLOT(calibShow())); connect(calib, SIGNAL(calibUID(int)), this, SLOT(calibUID(int))); connect(calib, SIGNAL(calibLeft(int)), this, SLOT(calibLeft(int))); connect(calib, SIGNAL(calibRight(int)), this, SLOT(calibRight(int))); connect(calib, SIGNAL(calibStraight(int)), this, SLOT(calibStraight(int))); connect(calib, SIGNAL(calibStop()), this, SLOT(calibStop())); connect(calib, SIGNAL(calibSave()), this, SLOT(calibSave())); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(createDeviceSelect()); vbox->addWidget(createFileInput()); vbox->addWidget(createCommands()); vbox->addWidget(serial_button); vbox->addWidget(calib_button); vbox->addWidget(status); setLayout(vbox); setWindowTitle("Kilobots Toolkit"); setWindowIcon(QIcon(":/images/kilogui.png")); setWindowState(Qt::WindowActive); vusb_conn = new VUSBConnection(); ftdi_conn = new FTDIConnection(); serial_conn = new SerialConnection(); connect(ftdi_conn, SIGNAL(readText(QString)), serial, SLOT(addText(QString))); connect(serial_conn, SIGNAL(readText(QString)), serial, SLOT(addText(QString))); connect(vusb_conn, SIGNAL(error(QString)), this, SLOT(showError(QString))); connect(vusb_conn, SIGNAL(status(QString)), this, SLOT(vusbUpdateStatus(QString))); connect(ftdi_conn, SIGNAL(error(QString)), this, SLOT(showError(QString))); connect(ftdi_conn, SIGNAL(status(QString)), this, SLOT(ftdiUpdateStatus(QString))); connect(serial_conn, SIGNAL(error(QString)), this, SLOT(showError(QString))); connect(serial_conn, SIGNAL(status(QString)), this, SLOT(serialUpdateStatus(QString))); // Create thread QThread *thread = new QThread(); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); // Move connections to thread vusb_conn->moveToThread(thread); ftdi_conn->moveToThread(thread); serial_conn->moveToThread(thread); // Start thread and open connections thread->start(); vusb_conn->open(); ftdi_conn->open(); serial_conn->open(); }