UniSet 2.41.2
RTUExchange.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// -----------------------------------------------------------------------------
17#ifndef _RTUEXCHANGE_H_
18#define _RTUEXCHANGE_H_
19// -----------------------------------------------------------------------------
20#include <ostream>
21#include <string>
22#include <map>
23#include <vector>
24#include "MBExchange.h"
25#include "modbus/ModbusRTUMaster.h"
26#include "RTUStorage.h"
27// --------------------------------------------------------------------------
28namespace uniset
29{
30 // -----------------------------------------------------------------------------
31 class RTUExchange:
32 public MBExchange
33 {
34 public:
35 RTUExchange( uniset::ObjectId objId, xmlNode* cnode,
36 uniset::ObjectId shmID,
37 const std::shared_ptr<SharedMemory>& ic = nullptr, const std::string& prefix = "rs" );
38 virtual ~RTUExchange();
39
41 static std::shared_ptr<RTUExchange> init_rtuexchange( int argc, const char* const* argv,
42 uniset::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr,
43 const std::string& prefix = "rs" );
44
45 static void help_print( int argc, const char* const* argv );
46
47 protected:
48 std::shared_ptr<ModbusRTUMaster> mbrtu = nullptr;
49 std::mutex mbMutex;
50 std::string devname;
51 ComPort::Speed defSpeed = { ComPort::ComSpeed38400 };
52 ComPort::Parity parity;
53 ComPort::CharacterSize csize;
54 ComPort::StopBits stopBits;
55 bool use485F = { false };
56 bool transmitCtl = { false };
57
58 virtual void step() override;
59 virtual bool poll() override;
60 virtual std::shared_ptr<ModbusClient> initMB( bool reopen = false ) override;
61
62 private:
63 RTUExchange();
64
65 bool rs_pre_clean = { false };
66 };
67 // --------------------------------------------------------------------------
68} // end of namespace uniset
69// -----------------------------------------------------------------------------
70#endif // _RS_EXCHANGE_H_
71// -----------------------------------------------------------------------------
static std::shared_ptr< RTUExchange > init_rtuexchange(int argc, const char *const *argv, uniset::ObjectId shmID, const std::shared_ptr< SharedMemory > &ic=nullptr, const std::string &prefix="rs")
Определения ModbusMaster/rtuexchange.cc:412
Определения Calibration.h:27
long ObjectId
Определения UniSetTypes_i.idl:30