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