UniSet  2.6.0
LProcessor.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 LProcessor_H_
18 #define LProcessor_H_
19 // --------------------------------------------------------------------------
103 // --------------------------------------------------------------------------
104 #include <list>
105 #include <atomic>
106 #include "UniSetTypes.h"
107 #include "UInterface.h"
108 #include "Element.h"
109 #include "Schema.h"
110 // --------------------------------------------------------------------------
111 namespace uniset
112 {
113  // --------------------------------------------------------------------------
115  {
116  public:
117  explicit LProcessor( const std::string& name = "" );
118  virtual ~LProcessor();
119 
120  void open( const std::string& lfile );
121 
122  inline bool isOpen() const
123  {
124  return !fSchema.empty();
125  }
126 
127  virtual void execute( const std::string& lfile = "" );
128 
129  virtual void terminate()
130  {
131  canceled = true;
132  }
133 
134  inline std::shared_ptr<SchemaXML> getSchema()
135  {
136  return sch;
137  }
138 
139  inline int getSleepTime() const
140  {
141  return sleepTime;
142  }
143 
144  protected:
145 
146  virtual void build( const string& lfile );
147 
148  virtual void step();
149 
150  virtual void getInputs();
151  virtual void processing();
152  virtual void setOuts();
153 
154  struct EXTInfo
155  {
156  uniset::ObjectId sid;
157  UniversalIO::IOType iotype;
158  bool state;
159  std::shared_ptr<Element> el;
160  int numInput = { -1};
161  };
162 
163  struct EXTOutInfo
164  {
165  uniset::ObjectId sid;
166  UniversalIO::IOType iotype;
167  std::shared_ptr<Element> el;
168  };
169 
170  typedef std::list<EXTInfo> EXTList;
171  typedef std::list<EXTOutInfo> OUTList;
172 
173  EXTList extInputs;
174  OUTList extOuts;
175 
176  std::shared_ptr<SchemaXML> sch;
177 
178  UInterface ui;
179  timeout_t sleepTime = { 200 };
180  timeout_t smReadyTimeout = { 30000 } ;
182  std::string logname = { "" };
183 
184  std::atomic_bool canceled = {false};
185 
186  std::string fSchema = {""};
187 
188  private:
189  };
190  // --------------------------------------------------------------------------
191 } // end of namespace uniset
192 // ---------------------------------------------------------------------------
193 #endif
virtual void getInputs()
Definition: LProcessor.cc:162
Definition: CallbackTimer.h:29
timeout_t smReadyTimeout
Definition: LProcessor.h:180
Definition: UInterface.h:54
Definition: LProcessor.h:163
Definition: LProcessor.h:114
Definition: LProcessor.h:154
long ObjectId
Definition: UniSetTypes_i.idl:30