File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,16 +11,6 @@ ModbusMultiServer::ModbusMultiServer(QObject *parent)
1111 : QObject{parent}
1212 ,_workerThread(new QThread(this ))
1313{
14- {
15- static int reg = qRegisterMetaType<QModbusRequest>();
16- Q_UNUSED (reg);
17- }
18-
19- {
20- static int reg = qRegisterMetaType<QModbusResponse>();
21- Q_UNUSED (reg);
22- }
23-
2414 moveToThread (_workerThread);
2515 _workerThread->start ();
2616
Original file line number Diff line number Diff line change 11#ifndef MODBUSMULTISERVER_H
22#define MODBUSMULTISERVER_H
33
4- #include < QObject>
54#include < QThread>
6- #include < QTcpSocket>
75#include < QModbusServer>
86#include " modbusdataunitmap.h"
97#include " modbuswriteparams.h"
@@ -95,7 +93,5 @@ private slots:
9593 QMap<int , ModbusDataUnitMap> _modbusDataUnitMaps;
9694 QList<QSharedPointer<ModbusServer>> _modbusServerList;
9795};
98- Q_DECLARE_METATYPE (QModbusRequest)
99- Q_DECLARE_METATYPE(QModbusResponse)
10096
10197#endif // MODBUSMULTISERVER_H
Original file line number Diff line number Diff line change @@ -14,6 +14,20 @@ ModbusServer::ModbusServer(QObject* parent)
1414 : QObject(parent)
1515 ,_counters()
1616{
17+ {
18+ static int reg = qRegisterMetaType<QModbusRequest>();
19+ Q_UNUSED (reg);
20+ }
21+
22+ {
23+ static int reg = qRegisterMetaType<QModbusResponse>();
24+ Q_UNUSED (reg);
25+ }
26+
27+ {
28+ static int reg = qRegisterMetaType<QModbusDataUnit>();
29+ Q_UNUSED (reg);
30+ }
1731}
1832
1933// /
Original file line number Diff line number Diff line change @@ -173,6 +173,10 @@ class ModbusServer : public QObject
173173 QHash<int , QString> _errorsString;
174174};
175175
176+ Q_DECLARE_METATYPE (QModbusRequest)
177+ Q_DECLARE_METATYPE(QModbusResponse)
178+ Q_DECLARE_METATYPE(QModbusDataUnit)
179+
176180Q_DECLARE_LOGGING_CATEGORY(QT_MODBUS)
177181Q_DECLARE_LOGGING_CATEGORY(QT_MODBUS_LOW)
178182
Original file line number Diff line number Diff line change @@ -2175,7 +2175,7 @@ MODBUS Point Type:
21752175<context >
21762176 <name >ModbusMultiServer</name >
21772177 <message >
2178- <location filename =" ../modbusmultiserver.cpp" line =" 948 " />
2178+ <location filename =" ../modbusmultiserver.cpp" line =" 938 " />
21792179 <source >Connection error. %1</source >
21802180 <translation >Ошибка подключения. %1</translation >
21812181 </message >
Original file line number Diff line number Diff line change @@ -2183,7 +2183,7 @@ MODBUS Point Type:
21832183<context >
21842184 <name >ModbusMultiServer</name >
21852185 <message >
2186- <location filename =" ../modbusmultiserver.cpp" line =" 948 " />
2186+ <location filename =" ../modbusmultiserver.cpp" line =" 938 " />
21872187 <source >Connection error. %1</source >
21882188 <translation >连接错误 %1</translation >
21892189 </message >
You can’t perform that action at this time.
0 commit comments