mirror of
https://github.com/x-tools-author/x-tools.git
synced 2025-09-15 15:28:40 +08:00
chore: update files of project
This commit is contained in:
parent
9f4943bb29
commit
0dc3bd1fc0
@ -36,8 +36,3 @@ SAKBaseTool::~SAKBaseTool()
|
||||
wait();
|
||||
}
|
||||
}
|
||||
|
||||
void SAKBaseTool::inputBytes(const QByteArray &bytes)
|
||||
{
|
||||
emit bytesOutput(bytes);
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class SAKBaseTool : public QThread
|
||||
public:
|
||||
explicit SAKBaseTool(QObject *parent = Q_NULLPTR);
|
||||
virtual ~SAKBaseTool();
|
||||
virtual void inputBytes(const QByteArray &bytes);
|
||||
virtual void inputBytes(const QByteArray &bytes) = 0;
|
||||
|
||||
int toolType() { return m_type; }
|
||||
void setToolType(int type) { m_type = type; }
|
||||
|
||||
@ -19,10 +19,9 @@ SAKEmitterTool::SAKEmitterTool(QObject *parent)
|
||||
: SAKTableModelTool{parent}
|
||||
{}
|
||||
|
||||
void SAKEmitterTool::inputBytes(const QByteArray &bytes, const QVariant &context)
|
||||
void SAKEmitterTool::inputBytes(const QByteArray &bytes)
|
||||
{
|
||||
Q_UNUSED(bytes)
|
||||
Q_UNUSED(context)
|
||||
}
|
||||
|
||||
QVariant SAKEmitterTool::itemContext(int index)
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
|
||||
public:
|
||||
explicit SAKEmitterTool(QObject *parent = Q_NULLPTR);
|
||||
virtual void inputBytes(const QByteArray &bytes, const QVariant &context = QJsonObject()) final;
|
||||
virtual void inputBytes(const QByteArray &bytes) override;
|
||||
|
||||
public:
|
||||
virtual QString cookHeaderString(const QString &str) override;
|
||||
|
||||
@ -435,12 +435,11 @@ QString SAKResponserTool::cookHeaderString(const QString &str)
|
||||
return "--";
|
||||
}
|
||||
|
||||
void SAKResponserTool::inputBytes(const QByteArray &bytes, const QVariant &context)
|
||||
void SAKResponserTool::inputBytes(const QByteArray &bytes)
|
||||
{
|
||||
mInputContextListMutex.lock();
|
||||
mInputContextList.append({bytes, context});
|
||||
mInputContextList.append(bytes);
|
||||
mInputContextListMutex.unlock();
|
||||
;
|
||||
}
|
||||
|
||||
void SAKResponserTool::run()
|
||||
@ -470,7 +469,7 @@ void SAKResponserTool::run()
|
||||
outputTimer = nullptr;
|
||||
}
|
||||
|
||||
void SAKResponserTool::try2output(const SAKResponserTool::InputContext &ctx, QObject *receiver)
|
||||
void SAKResponserTool::try2output(const QByteArray &bytes, QObject *receiver)
|
||||
{
|
||||
mItemsMutex.lock();
|
||||
auto items = mItems;
|
||||
@ -498,14 +497,14 @@ void SAKResponserTool::try2output(const SAKResponserTool::InputContext &ctx, QOb
|
||||
if (item.data.itemOption == always) {
|
||||
enableResponse = true;
|
||||
} else if (item.data.itemOption == echo) {
|
||||
resBytes = ctx.bytes;
|
||||
resBytes = bytes;
|
||||
enableResponse = true;
|
||||
} else if (item.data.itemOption == contain) {
|
||||
enableResponse = (ctx.bytes.contains(refBytes));
|
||||
enableResponse = (bytes.contains(refBytes));
|
||||
} else if (item.data.itemOption == discontain) {
|
||||
enableResponse = (!ctx.bytes.contains(refBytes));
|
||||
enableResponse = (!bytes.contains(refBytes));
|
||||
} else if (item.data.itemOption == eaual) {
|
||||
enableResponse = (ctx.bytes == refBytes);
|
||||
enableResponse = (bytes == refBytes);
|
||||
}
|
||||
|
||||
if (!enableResponse) {
|
||||
|
||||
@ -116,9 +116,9 @@ public:
|
||||
|
||||
public:
|
||||
explicit SAKResponserTool(QObject *parent = nullptr);
|
||||
Q_INVOKABLE virtual QVariant itemContext(int index) final;
|
||||
Q_INVOKABLE virtual QVariant itemContext(int index) override;
|
||||
virtual QString cookHeaderString(const QString &str) override;
|
||||
virtual void inputBytes(const QByteArray &bytes, const QVariant &context = QJsonObject()) final;
|
||||
virtual void inputBytes(const QByteArray &bytes) override;
|
||||
|
||||
protected:
|
||||
virtual void run() final;
|
||||
@ -136,14 +136,7 @@ protected:
|
||||
int role = Qt::DisplayRole) const final;
|
||||
|
||||
private:
|
||||
struct InputContext
|
||||
{
|
||||
QByteArray bytes;
|
||||
QVariant context;
|
||||
};
|
||||
|
||||
private:
|
||||
QVector<InputContext> mInputContextList;
|
||||
QVector<QByteArray> mInputContextList;
|
||||
QMutex mInputContextListMutex;
|
||||
|
||||
QVector<ResponserData> mItems;
|
||||
@ -158,7 +151,7 @@ private:
|
||||
QVariant columnDisplayRoleData(const ResponserData &item, int column) const;
|
||||
QByteArray referenceBytes(const ResponserItem &item) const;
|
||||
QByteArray responseBytes(const ResponserItem &item) const;
|
||||
void try2output(const InputContext &ctx, QObject *receiver);
|
||||
void try2output(const QByteArray &bytes, QObject *receiver);
|
||||
|
||||
private:
|
||||
QString itemEnable();
|
||||
|
||||
@ -26,11 +26,11 @@ SAKStorerTool::~SAKStorerTool()
|
||||
mInputContextListMutex.unlock();
|
||||
}
|
||||
|
||||
void SAKStorerTool::inputBytes(const QByteArray &bytes, const QVariant &context)
|
||||
void SAKStorerTool::inputBytes(const QByteArray &bytes)
|
||||
{
|
||||
if (isEnable()) {
|
||||
mInputContextListMutex.lock();
|
||||
mInputContextList.append({bytes, context});
|
||||
mInputContextList.append(bytes);
|
||||
mInputContextListMutex.unlock();
|
||||
}
|
||||
}
|
||||
@ -161,9 +161,7 @@ void SAKStorerTool::write2file()
|
||||
if (file.open(QFile::WriteOnly | QFile::Text | QFile::Append)) {
|
||||
QTextStream outStream(&file);
|
||||
while (!mInputContextList.isEmpty()) {
|
||||
auto ctx = mInputContextList.takeFirst();
|
||||
auto bytes = ctx.bytes;
|
||||
auto context = ctx.context;
|
||||
auto bytes = mInputContextList.takeFirst();
|
||||
this->mParametersMutex.lock();
|
||||
int format = this->mParameters.format;
|
||||
this->mParametersMutex.unlock();
|
||||
@ -190,25 +188,6 @@ void SAKStorerTool::write2file()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QString txFlag = "Tx: ";
|
||||
const QString rxFlag = "Rx: ";
|
||||
QString flag = context.toJsonObject().value("flag").toString();
|
||||
flag = (flag == "rx" ? rxFlag : txFlag);
|
||||
|
||||
if (flag == txFlag) {
|
||||
if (!mParameters.saveTx) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag == rxFlag) {
|
||||
if (!mParameters.saveRx) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
str = dtStr + flag + str;
|
||||
outStream << str << "\n";
|
||||
}
|
||||
file.close();
|
||||
} else {
|
||||
|
||||
@ -28,7 +28,7 @@ public:
|
||||
explicit SAKStorerTool(QObject *parent = nullptr);
|
||||
~SAKStorerTool();
|
||||
|
||||
virtual void inputBytes(const QByteArray &bytes, const QVariant &context = QJsonObject()) final;
|
||||
virtual void inputBytes(const QByteArray &bytes) override;
|
||||
|
||||
public:
|
||||
int saveFormat();
|
||||
@ -71,12 +71,7 @@ private:
|
||||
} mParameters;
|
||||
QMutex mParametersMutex;
|
||||
|
||||
struct InputContext
|
||||
{
|
||||
QByteArray bytes;
|
||||
QVariant context;
|
||||
};
|
||||
QList<InputContext> mInputContextList;
|
||||
QList<QByteArray> mInputContextList;
|
||||
QMutex mInputContextListMutex;
|
||||
|
||||
private:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user