Add new constant for progress in percent.
This commit is contained in:
99
common/ismas/ApismClient.h
Normal file
99
common/ismas/ApismClient.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef APISM_CLIENT_H_INCLUDED
|
||||
#define APISM_CLIENT_H_INCLUDED
|
||||
|
||||
#include "ISMASData.h"
|
||||
#include "ApismTcpClient.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractSocket>
|
||||
#include <QTcpSocket>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonParseError>
|
||||
#include <QJsonValue>
|
||||
#include <QScopedPointer>
|
||||
|
||||
|
||||
QDebug operator<<(QDebug debug, ISMAS::REQUEST request);
|
||||
QString& operator<<(QString& str, ISMAS::REQUEST request);
|
||||
|
||||
namespace nsApismInterface {
|
||||
enum class RESULT_STATE : quint8 {
|
||||
SUCCESS = 1,
|
||||
ERROR_BACKEND = 2, // error from backand (e.g. backend replies with error)
|
||||
ERROR_NETWORK = 3, // error from network (e.g. host not available)
|
||||
ERROR_TIMEOUT = 4, // the operation timed out
|
||||
ERROR_PROCESS = 5, // internal plugin error (e.g. bug in implementation)
|
||||
ERROR_RETRY = 6, // retry operation
|
||||
INFO = 7
|
||||
};
|
||||
}
|
||||
|
||||
// class ISMAS::EventData;
|
||||
class ApismClient : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ApismClient(QObject *parent = 0);
|
||||
virtual ~ApismClient() = 0;
|
||||
|
||||
quint32 getLastError();
|
||||
const QString & getLastErrorDescription();
|
||||
|
||||
ISMAS::REQUEST getCurrentRequest() const { return currentRequest; }
|
||||
void setCurrentRequest(ISMAS::REQUEST r) { currentRequest = r; }
|
||||
|
||||
void resetRetryCounter() { retryCounter = 0; }
|
||||
int getRetryCounter() const { return retryCounter; }
|
||||
int incrRetryCounter() { return ++retryCounter; }
|
||||
|
||||
ApismTcpClient *tcpSendClient() { return apismTcpSendClient.get(); }
|
||||
ApismTcpClient *tcpRequestResponseClient() { return apismTcpRequestResponseClient.get(); }
|
||||
|
||||
public slots:
|
||||
void sendSelfTest();
|
||||
void sendRequestParameter();
|
||||
void restartApism();
|
||||
|
||||
signals:
|
||||
void sendReqSelfResponse(nsApismInterface::RESULT_STATE result, QJsonObject response);
|
||||
void sendReqParameterResponse(nsApismInterface::RESULT_STATE result, QJsonObject response);
|
||||
|
||||
private slots:
|
||||
virtual void onReceivedResponse(QByteArray response) = 0;
|
||||
virtual void onSendClientResponseTimeout() = 0;
|
||||
virtual void onRequestResponseClientResponseTimeout() = 0;
|
||||
virtual void onRequestResponseClientConnectTimeout() = 0;
|
||||
virtual void onRequestResponseClientConnectionClosedByRemoteHost() = 0;
|
||||
|
||||
private:
|
||||
QScopedPointer<ApismTcpClient> apismTcpSendClient;
|
||||
QScopedPointer<ApismTcpClient> apismTcpRequestResponseClient;
|
||||
|
||||
quint32 lastError;
|
||||
QString lastErrorDescription;
|
||||
|
||||
ISMAS::REQUEST currentRequest;
|
||||
|
||||
// counter, incremented if we get an offline response from ISMAS
|
||||
// causes a resend of the currentRequest.
|
||||
int retryCounter;
|
||||
|
||||
// true, if ISMAS REQ_ISAMASPARAMETER got a valid response
|
||||
bool flagValidParameter;
|
||||
|
||||
void private_handlePingResponse(QJsonObject response);
|
||||
void private_handleReqSelfResponse(QJsonObject response);
|
||||
void private_handleReqPingResponse(QJsonObject response);
|
||||
void private_handleParameterResponse(QJsonObject response);
|
||||
void private_handleFileUploadResponse(QJsonObject response);
|
||||
void private_handleErrorResponse(QString errorString);
|
||||
|
||||
public:
|
||||
void handleISMASResponseError();
|
||||
void handleISMASOfflineResponseError();
|
||||
};
|
||||
|
||||
#endif // APISM_CLIENT_H_INCLUDED
|
Reference in New Issue
Block a user