Skip to content

Commit

Permalink
add initiator parameter for client requests, to improve debug process
Browse files Browse the repository at this point in the history
  • Loading branch information
w0lek committed Nov 10, 2023
1 parent 758203d commit 3acaeba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/InteractivePathAnalysis/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Client::Client(

connect(m_toolsWidget, &ClientToolsWidget::getPathListRequested, this, &Client::runGetPathListScenario);

connect(m_toolsWidget, &ClientToolsWidget::highLightModeChanged, [this](){
onPathSelected(NCriticalPathSettings::instance().getLastSelectedPathId());
connect(m_toolsWidget, &ClientToolsWidget::highLightModeChanged, this, [this](){
onPathSelected(NCriticalPathSettings::instance().getLastSelectedPathId(), "hight light mode change");
});
//

Expand Down Expand Up @@ -88,29 +88,29 @@ void Client::handleResponse(const QByteArray& bytes)
}
}

void Client::sendRequest(const QByteArray& requestBytes)
void Client::sendRequest(const QByteArray& requestBytes, const QString& initiator)
{
if (!m_socket->isConnected()) {
m_socket->connect();
}
qDebug() << "sending:" << requestBytes;
qDebug() << "sending:" << requestBytes << QString("requested by [%1]").arg(initiator);
if (!m_socket->write(requestBytes)) {
qCritical() << "unable to send" << requestBytes;
}
}

void Client::runGetPathListScenario()
void Client::runGetPathListScenario(const QString& initiator)
{
QByteArray bytes = RequestCreator::instance().getPathListRequestTelegram(m_toolsWidget->nCriticalPathNum(),
m_toolsWidget->pathType(),
m_toolsWidget->detailesLevel(),
m_toolsWidget->isFlatRouting());
sendRequest(bytes);
sendRequest(bytes, initiator);
}

void Client::onPathSelected(const QString& pathId)
void Client::onPathSelected(const QString& pathId, const QString& initiator)
{
NCriticalPathSettings::instance().setLastSelectedPathId(pathId);
QByteArray bytes = RequestCreator::instance().getDrawPathIdTelegram(pathId, m_toolsWidget->highlightMode());
sendRequest(bytes);
sendRequest(bytes, initiator);
}
6 changes: 3 additions & 3 deletions src/InteractivePathAnalysis/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Client : public QObject
bool isConnected() const;

public slots:
void onPathSelected(const QString&);
void onPathSelected(const QString&, const QString&);

signals:
void critPathsDataReady(const QString&);
Expand All @@ -41,10 +41,10 @@ public slots:
QTimer m_timer;
#endif // ENABLE_AUTOMATIC_REQUEST

void sendRequest(const QByteArray&);
void sendRequest(const QByteArray&, const QString&);
void handleResponse(const QByteArray&);

private slots:
void runGetPathListScenario();
void runGetPathListScenario(const QString&);
};

6 changes: 4 additions & 2 deletions src/InteractivePathAnalysis/client/clienttoolswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ ClientToolsWidget::ClientToolsWidget(

// bnRequestPathList
m_bnRequestPathList = new PushButton("Get Path List");
connect(m_bnRequestPathList, &QPushButton::clicked, this, &ClientToolsWidget::getPathListRequested);
connect(m_bnRequestPathList, &QPushButton::clicked, [this](){
emit getPathListRequested("button click event");
});

QPushButton* bnPathsOptions = new QPushButton("Paths Cfg...");
layout->addWidget(bnPathsOptions);
Expand Down Expand Up @@ -351,7 +353,7 @@ void ClientToolsWidget::onConnectionStatusChanged(bool isConnected)
emit connectionStatusChanged(isConnected);
if (isConnected && m_isFirstTimeConnectedToParticularPnRViewInstance) {
#ifndef BYPASS_AUTO_PATH_LIST_FETCH
emit getPathListRequested();
emit getPathListRequested("socket connection resumed");
#endif
m_isFirstTimeConnectedToParticularPnRViewInstance = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/InteractivePathAnalysis/client/clienttoolswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public slots:

signals:
void connectionStatusChanged(bool);
void getPathListRequested();
void getPathListRequested(const QString&);
void highLightModeChanged();
void PnRViewProcessRunningStatus(bool);

Expand Down

0 comments on commit 3acaeba

Please sign in to comment.