UniSet 2.45.1
PassiveLProcessor.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 PassiveLProcessor_H_
18#define PassiveLProcessor_H_
19// --------------------------------------------------------------------------
20#include <map>
21#include <memory>
22#include "UniSetTypes.h"
23#include "UniSetObject.h"
24#include "Extensions.h"
25#include "SharedMemory.h"
26#include "UInterface.h"
27#include "SMInterface.h"
28#include "LProcessor.h"
29#include "USingleProcess.h"
30#ifndef DISABLE_REST_API
31#include <Poco/JSON/Object.h>
32#include "UHttpRequestHandler.h"
33#endif
34// --------------------------------------------------------------------------
35namespace uniset
36{
37 // -------------------------------------------------------------------------
39 class PassiveLProcessor:
40 public UniSetObject,
41 protected LProcessor
42 {
43 public:
44
45 PassiveLProcessor(uniset::ObjectId objId, xmlNode* cnode,
46 uniset::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr, const std::string& prefix = "lproc" );
47 virtual ~PassiveLProcessor();
48
49 enum Timers
50 {
51 tidStep
52 };
53
54 static void help_print( int argc, const char* const* argv );
55
56 static std::shared_ptr<PassiveLProcessor> init_plproc( int argc, const char* const* argv,
57 uniset::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr,
58 const std::string& prefix = "plproc" );
59
60 protected:
61 PassiveLProcessor():
62 LProcessor("", nullptr),
63 shm(0), maxHeartBeat(0) {};
64
65 virtual void step() override;
66 virtual void getInputs() override;
67 virtual void setOuts() override;
68
69 void sysCommand( const uniset::SystemMessage* msg ) override;
70 void sensorInfo( const uniset::SensorMessage* sm ) override;
71 void timerInfo( const uniset::TimerMessage* tm ) override;
72 void askSensors( const UniversalIO::UIOCommand cmd );
73 // void initOutput();
74
75 void initIterators();
76 virtual bool activateObject() override;
77 virtual bool deactivateObject() override;
78
79 std::shared_ptr<SMInterface> shm;
80
81#ifndef DISABLE_REST_API
82 virtual Poco::JSON::Object::Ptr httpRequest( const UHttp::HttpRequestContext& ctx ) override;
83 virtual Poco::JSON::Object::Ptr httpHelp( const Poco::URI::QueryParameters& p ) override;
84
85 private:
86 Poco::JSON::Object::Ptr httpSchema();
87 Poco::JSON::Object::Ptr httpSchemaElements();
88 Poco::JSON::Object::Ptr httpSchemaInputs();
89 Poco::JSON::Object::Ptr httpSchemaOutputs();
90 Poco::JSON::Object::Ptr httpSchemaConnections();
91#endif
92
93 private:
94 PassiveTimer ptHeartBeat;
96 int maxHeartBeat = { 10 };
97 IOController::IOStateList::iterator itHeartBeat;
98 std::mutex mutex_start;
99 std::atomic_bool cannceled = { false };
100 };
101 // --------------------------------------------------------------------------
102} // end of namespace uniset
103// ---------------------------------------------------------------------------
104#endif
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы).
Определения PassiveLProcessor.cc:225
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации).
Определения PassiveLProcessor.cc:211
virtual void getInputs() override
Определения PassiveLProcessor.cc:111
Пассивный таймер
Определения PassiveTimer.h:94
Определения MessageType.h:127
Определения MessageType.h:171
Определения MessageType.h:214
UniSetObject(const std::string &name, const std::string &section)
Определения UniSetObject.cc:89
Определения Calibration.h:27
const ObjectId DefaultObjectId
Определения UniSetTypes.h:71
long ObjectId
Определения UniSetTypes_i.idl:30
Определения UHttpRequestHandler.h:87