CuteHMI - Modbus (CuteHMI.Modbus.2)
TCPClientConfig.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_TCPCLIENTCONFIG_HPP
2 #define H_EXTENSIONS_CUTEHMI_MODBUS_2_INCLUDE_CUTEHMI_MODBUS_INTERNAL_TCPCLIENTCONFIG_HPP
3 
4 #include "Config.hpp"
5 
6 #include <QObject>
7 #include <QString>
8 #include <QReadWriteLock>
9 
10 namespace cutehmi {
11 namespace modbus {
12 namespace internal {
13 
14 class CUTEHMI_MODBUS_PRIVATE TCPClientConfig:
15  public Config
16 {
17  Q_OBJECT
18 
19  public:
20  static constexpr int MIN_SLAVE_ADDRESS = 1; // Can be 1 to 247 according to http://www.simplymodbus.ca/FAQ.htm
21  static constexpr int MAX_SLAVE_ADDRESS = 247; // Can be 1 to 247 according to http://www.simplymodbus.ca/FAQ.htm
22  static const char * INITIAL_HOST;
23  static constexpr int INITIAL_PORT = 502;
24  static constexpr int INITIAL_SLAVE_ADDRESS = MIN_SLAVE_ADDRESS;
25 
26  explicit TCPClientConfig(QObject * parent = nullptr);
27 
28  QString host() const;
29 
30  void setHost(const QString & host);
31 
32  int port() const;
33 
34  void setPort(int port);
35 
36  int slaveAddress() const;
37 
38  void setSlaveAddress(int slaveAddress);
39 
40  private:
41  struct Members
42  {
43  QString host = INITIAL_HOST;
44  int port = INITIAL_PORT;
45  int slaveAddress = INITIAL_SLAVE_ADDRESS;
46  mutable QReadWriteLock lock;
47  };
48 
49  MPtr<Members> m;
50 };
51 
52 }
53 }
54 }
55 
56 #endif
57 
58 //(c)C: Copyright © 2019, Michał Policht <michal@policht.pl>. All rights reserved.
59 //(c)C: This file is a part of CuteHMI.
60 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
61 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
62 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
cutehmi::MPtr< Members >
QObject
cutehmi
QString
cutehmi::modbus::internal::TCPClientConfig::INITIAL_HOST
static const char * INITIAL_HOST
Definition: TCPClientConfig.hpp:22
std::internal
T internal(T... args)
cutehmi::modbus::internal::Config
Definition: Config.hpp:10
QReadWriteLock
cutehmi::modbus::internal::TCPClientConfig
Definition: TCPClientConfig.hpp:14