void TripPlanner::error() { qDebug() << "ERROR: " << this->errorString(); //closeConnection(); // Try connecting again after 500ms QTimer::singleShot(500,this,SLOT(startSending())); }
void ProtocolConnection::internOnFrameSent(const Frame *frame) { //notify message onFrameSent(frame); //send next frame startSending(); }
TripPlanner::TripPlanner(char *name,char *id, QObject *parent):QTcpSocket(parent) { std::stringstream strValue; strValue << id; strValue >> busID; busName = QString(name); finished = false; lastStation = -1; // Determine Start Station station = 0.0; peopleGettingOff = 0; space = BUS_SPACE; // ... // Create widgets. //connectButton = new QPushButton("Connect"); //exitButton = new QPushButton("Exit"); //layout = new QHBoxLayout(this); // Connect button signals. // connect(connectButton, SIGNAL(clicked()), //this, SLOT(startSending())); /*connect(stopButton, SIGNAL(clicked()), this, SLOT(stopSearch())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));*/ // connect(exitButton, SIGNAL(clicked()), this, SLOT(close())); // Connect TCP socket signals. connect(&tcpSocket, SIGNAL(connected()), this, SLOT(sendRequest())); connect(&tcpSocket, SIGNAL(disconnected()), this, SLOT(connectionClosedByServer())); connect(&tcpSocket, SIGNAL(readyRead()), this, SLOT(updateTableWidget())); connect(&tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error())); //layout->addWidget(connectButton); //layout->addWidget(exitButton); startSending(); }
void MainWindow::on_startStopButton_pressed() { if (ui->startStopButton->text() == "Start") { startSending(); // Disable position controls ui->positionGroupBox->setEnabled(false); // Disable com port selection m_comPorts->setEnabled(false); ui->startStopButton->setText("Stop"); } else { ui->startStopButton->setText("Start"); m_gpsTimer->stop(); // Enable position controls ui->positionGroupBox->setEnabled(true); // Enable com port selection m_comPorts->setEnabled(true); } }
Sender::Sender(QWidget *parent) : QDialog(parent) { groupAddress = QHostAddress("239.255.43.21"); statusLabel = new QLabel(tr("Ready to multicast datagrams to group %1 on port 45454").arg(groupAddress.toString())); ttlLabel = new QLabel(tr("TTL for multicast datagrams:")); ttlSpinBox = new QSpinBox; ttlSpinBox->setRange(0, 255); QHBoxLayout *ttlLayout = new QHBoxLayout; ttlLayout->addWidget(ttlLabel); ttlLayout->addWidget(ttlSpinBox); startButton = new QPushButton(tr("&Start")); quitButton = new QPushButton(tr("&Quit")); buttonBox = new QDialogButtonBox; buttonBox->addButton(startButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); timer = new QTimer(this); udpSocket = new QUdpSocket(this); messageNo = 1; connect(ttlSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ttlChanged(int))); connect(startButton, SIGNAL(clicked()), this, SLOT(startSending())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); connect(timer, SIGNAL(timeout()), this, SLOT(sendDatagram())); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(statusLabel); mainLayout->addLayout(ttlLayout); mainLayout->addWidget(buttonBox); setLayout(mainLayout); setWindowTitle(tr("Multicast Sender")); ttlSpinBox->setValue(1); }
sender& sender::operator<<(std::istream& str){ char c; // std::cout<<"xxx: "<<str<<std::endl; //membaca seluruh str dan menyimpan ke string startSending(); std::string msg=""; while(str.get(c)){ msg+=c; if (msg.length()>=charperframe){ *this<<msg; msg=""; } } msg+=Endfile; *this<<msg; stopSending(); //harusnya dipanggil waktu baca EOF closefd(); return *this; }
void ProtocolConnection::sendFrame(const Frame *frame) { _frameQueue.push_back(frame); startSending(); }