UniSet @VERSION@
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:
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#ifndef DISABLE_REST_API
49 virtual Poco::JSON::Object::Ptr httpGetMyInfo( Poco::JSON::Object::Ptr root ) override;
50#endif
51 std::shared_ptr<ModbusRTUMaster> mbrtu = nullptr;
52 std::mutex mbMutex;
53 std::string devname;
54 ComPort::Speed defSpeed = { ComPort::ComSpeed38400 };
55 ComPort::Parity parity;
56 ComPort::CharacterSize csize;
57 ComPort::StopBits stopBits;
58 bool use485F = { false };
59 bool transmitCtl = { false };
60
61 virtual void step() override;
62 virtual bool poll() override;
63 virtual std::shared_ptr<ModbusClient> initMB( bool reopen = false ) override;
64
65 private:
67
68 bool rs_pre_clean = { false };
69 };
70 // --------------------------------------------------------------------------
71} // end of namespace uniset
72// -----------------------------------------------------------------------------
73#endif // _RS_EXCHANGE_H_
74// -----------------------------------------------------------------------------
Definition MBExchange.h:60
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:400
Definition AccessConfig.h:30
long ObjectId
Definition UniSetTypes_i.idl:30