Commit f2e95a15 authored by Pavel Vainerman's avatar Pavel Vainerman

(LogicProcessor): небольшой рефакторинг

(ProxyManager): update todo list
parent c9d1055e
......@@ -70,6 +70,11 @@ namespace uniset
}
}
}
// -------------------------------------------------------------------------
size_t Element::outCount() const
{
return outs.size();
}
// -------------------------------------------------------------------------
void Element::setChildOut()
......@@ -80,6 +85,11 @@ namespace uniset
it.el->setIn(it.num, _myout);
}
// -------------------------------------------------------------------------
Element::ElementID Element::getId() const
{
return myid;
}
// -------------------------------------------------------------------------
std::shared_ptr<Element> Element::find( const ElementID& id )
{
for( const auto& it : outs )
......@@ -120,4 +130,28 @@ namespace uniset
}
}
// -------------------------------------------------------------------------
size_t Element::inCount() const
{
return ins.size();
}
// -------------------------------------------------------------------------
ostream& operator<<( ostream& os, Element& el )
{
return os << "[" << el.getType() << "]" << el.getId();
}
ostream& operator<<( ostream& os, std::shared_ptr<Element> el )
{
if( el )
return os << (*(el.get()));
return os;
}
// -------------------------------------------------------------------------
long TOR::getOut() const
{
return (myout ? 1 : 0);
}
// -------------------------------------------------------------------------
} // end of namespace uniset
......@@ -63,10 +63,8 @@ namespace uniset
virtual void setIn( size_t num, long value ) = 0;
virtual long getOut() const = 0;
inline ElementID getId() const
{
return myid;
}
ElementID getId() const;
virtual std::string getType() const
{
return "?type?";
......@@ -76,30 +74,14 @@ namespace uniset
virtual void addChildOut( std::shared_ptr<Element> el, size_t in_num );
virtual void delChildOut( std::shared_ptr<Element> el );
inline size_t outCount() const
{
return outs.size();
}
size_t outCount() const;
virtual void addInput( size_t num, long value = 0 );
virtual void delInput( size_t num );
inline size_t inCount() const
{
return ins.size();
}
friend std::ostream& operator<<(std::ostream& os, Element& el )
{
return os << "[" << el.getType() << "]" << el.getId();
}
friend std::ostream& operator<<(std::ostream& os, std::shared_ptr<Element> el )
{
if( el )
return os << (*(el.get()));
size_t inCount() const;
return os;
}
friend std::ostream& operator<<(std::ostream& os, Element& el );
friend std::ostream& operator<<(std::ostream& os, std::shared_ptr<Element> el );
protected:
Element(): myid(DefaultElementID) {}; // нельзя создать элемент без id
......@@ -146,10 +128,7 @@ namespace uniset
virtual ~TOR();
virtual void setIn( size_t num, long value ) override;
virtual long getOut() const override
{
return (myout ? 1 : 0);
}
virtual long getOut() const override;
virtual std::string getType() const override
{
......
......@@ -59,6 +59,11 @@ void LProcessor::open( const string& lfile )
build(lfile);
}
// -------------------------------------------------------------------------
bool LProcessor::isOpen() const
{
return !fSchema.empty();
}
// -------------------------------------------------------------------------
void LProcessor::execute( const std::string& lfile )
{
if( !lfile.empty() )
......@@ -87,6 +92,21 @@ void LProcessor::execute( const std::string& lfile )
}
}
// -------------------------------------------------------------------------
void LProcessor::terminate()
{
canceled = true;
}
// -------------------------------------------------------------------------
std::shared_ptr<SchemaXML> LProcessor::getSchema()
{
return sch;
}
// -------------------------------------------------------------------------
timeout_t LProcessor::getSleepTime() const noexcept
{
return sleepTime;
}
// -------------------------------------------------------------------------
void LProcessor::step()
{
getInputs();
......
......@@ -124,27 +124,15 @@ namespace uniset
void open( const std::string& lfile );
inline bool isOpen() const
{
return !fSchema.empty();
}
bool isOpen() const;
virtual void execute( const std::string& lfile = "" );
timeout_t getSleepTime() const noexcept;
virtual void terminate()
{
canceled = true;
}
std::shared_ptr<SchemaXML> getSchema();
inline std::shared_ptr<SchemaXML> getSchema()
{
return sch;
}
virtual void execute( const std::string& lfile = "" );
inline int getSleepTime() const
{
return sleepTime;
}
virtual void terminate();
protected:
......
......@@ -117,7 +117,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
{
try
{
for( auto& it : extInputs )
for( auto&& it : extInputs )
shm->askSensor(it.sid, cmd);
}
catch( const uniset::Exception& ex )
......@@ -129,7 +129,7 @@ void PassiveLProcessor::askSensors( UniversalIO::UIOCommand cmd )
// -------------------------------------------------------------------------
void PassiveLProcessor::sensorInfo( const uniset::SensorMessage* sm )
{
for( auto& it : extInputs )
for( auto&& it : extInputs )
{
if( it.sid == sm->id )
it.value = sm->value;
......@@ -230,7 +230,7 @@ void PassiveLProcessor::initIterators()
void PassiveLProcessor::setOuts()
{
// выcтавляем выходы
for( auto& it : extOuts )
for( auto&& it : extOuts )
{
try
{
......@@ -249,7 +249,7 @@ void PassiveLProcessor::setOuts()
// -------------------------------------------------------------------------
void PassiveLProcessor::sigterm( int signo )
{
for( auto& it : extOuts )
for( auto&& it : extOuts )
{
try
{
......
......@@ -101,5 +101,10 @@ namespace uniset
{
delay = timeMS;
}
timeout_t TDelay::getDelay() const
{
return delay;
}
// -------------------------------------------------------------------------
} // end of namespace uniset
......@@ -42,10 +42,7 @@ namespace uniset
}
void setDelay( timeout_t timeMS );
inline timeout_t getDelay() const
{
return delay;
}
timeout_t getDelay() const;
protected:
TDelay(): myout(false), delay(0) {};
......
......@@ -34,6 +34,8 @@ namespace uniset
* Пасивный объект не имеющий самостоятельного потока обработки сообщений, но имеющий
* уникальный идентификатор. Предназначен для работы под управлением ProxyManager.
*
* \todo Перейти на shared_ptr, weak_ptr для взаимодействия с ProxyManager
*
*/
class PassiveObject
{
......
......@@ -33,7 +33,9 @@ namespace uniset
//----------------------------------------------------------------------------
/*! \class ProxyManager
* Менеджер пассивных объектов, который выступает вместо них во всех внешних связях....
* Менеджер пассивных объектов, который выступает вместо них во всех внешних связях...
*
* \todo Перейти на shared_ptr, weak_ptr для взаимодействия с PassiveObject
*/
class ProxyManager:
public UniSetObject
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment