UniSet 2.32.1
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 // -----------------------------------------------------------------------------
32 public MBExchange
33 {
34 public:
36 const std::shared_ptr<SharedMemory>& ic = nullptr, const std::string& prefix = "rs" );
37 virtual ~RTUExchange();
38
40 static std::shared_ptr<RTUExchange> init_rtuexchange( int argc, const char* const* argv,
41 uniset::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr,
42 const std::string& prefix = "rs" );
43
44 static void help_print( int argc, const char* const* argv );
45
46 protected:
47 std::shared_ptr<ModbusRTUMaster> mbrtu = nullptr;
48 std::mutex mbMutex;
49 std::string devname;
50 ComPort::Speed defSpeed = { ComPort::ComSpeed38400 };
51 ComPort::Parity parity;
52 ComPort::CharacterSize csize;
53 ComPort::StopBits stopBits;
54 bool use485F = { false };
55 bool transmitCtl = { false };
56
57 virtual void step() override;
58 virtual bool poll() override;
59 virtual std::shared_ptr<ModbusClient> initMB( bool reopen = false ) override;
60
61 private:
63
64 bool rs_pre_clean = { false };
65 };
66 // --------------------------------------------------------------------------
67} // end of namespace uniset
68// -----------------------------------------------------------------------------
69#endif // _RS_EXCHANGE_H_
70// -----------------------------------------------------------------------------
Definition MBExchange.h:58
Definition RTUExchange.h:33
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")
Definition ModbusMaster/rtuexchange.cc:411
Definition Calibration.h:27
long ObjectId
Definition UniSetTypes_i.idl:30