UniSet @VERSION@
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// --------------------------------------------------------------------------
31namespace uniset
32{
33 // -------------------------------------------------------------------------
36 public UniSetObject,
37 protected LProcessor
38 {
39 public:
40
41 PassiveLProcessor(uniset::ObjectId objId, xmlNode* cnode,
42 uniset::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr, const std::string& prefix = "lproc" );
43 virtual ~PassiveLProcessor();
44
45 enum Timers
46 {
47 tidStep
48 };
49
50 static void help_print( int argc, const char* const* argv );
51
52 static std::shared_ptr<PassiveLProcessor> init_plproc( int argc, const char* const* argv,
53 uniset::ObjectId shmID, const std::shared_ptr<SharedMemory>& ic = nullptr,
54 const std::string& prefix = "plproc" );
55
56 protected:
58 LProcessor("", nullptr),
59 shm(0), maxHeartBeat(0) {};
60
61 virtual void step() override;
62 virtual void getInputs() override;
63 virtual void setOuts() override;
64
65 void sysCommand( const uniset::SystemMessage* msg ) override;
66 void sensorInfo( const uniset::SensorMessage* sm ) override;
67 void timerInfo( const uniset::TimerMessage* tm ) override;
68 void askSensors( const UniversalIO::UIOCommand cmd );
69 // void initOutput();
70
71 void initIterators();
72 virtual bool activateObject() override;
73 virtual bool deactivateObject() override;
74
75 std::shared_ptr<SMInterface> shm;
76
77 private:
78 PassiveTimer ptHeartBeat;
80 int maxHeartBeat = { 10 };
81 IOController::IOStateList::iterator itHeartBeat;
82 std::mutex mutex_start;
83 std::atomic_bool cannceled = { false };
84 };
85 // --------------------------------------------------------------------------
86} // end of namespace uniset
87// ---------------------------------------------------------------------------
88#endif
Definition LProcessor.h:122
Definition PassiveLProcessor.h:38
virtual bool deactivateObject() override
Деактивация объекта (переопределяется для необходимых действий при завершении работы)
Definition PassiveLProcessor.cc:222
virtual bool activateObject() override
Активизация объекта (переопределяется для необходимых действий после активизации)
Definition PassiveLProcessor.cc:208
virtual void getInputs() override
Definition PassiveLProcessor.cc:108
Пассивный таймер
Definition PassiveTimer.h:94
Definition MessageType.h:127
Definition MessageType.h:171
Definition MessageType.h:214
Definition UniSetObject.h:80
Definition AccessConfig.h:30
const ObjectId DefaultObjectId
Definition UniSetTypes.h:71
long ObjectId
Definition UniSetTypes_i.idl:30