Commit 0c4a3da1 authored by Pavel Vainerman's avatar Pavel Vainerman

(codegen): добавил для пользовательских данных функцию getMonitInfo()

parent 5b906cdc
......@@ -46,12 +46,7 @@ SQL:
====
- добавить работу с History (при передаче указателя на SM в конструкторе).
Debug:
- в codegen встроить получение состояния всех переменных (dumpIO() + UniSetObject::getInfo()),
возможно написать на python утилиту "монитор".
- Сделать макрос с простым названием например NOTE(variable)(snap?)... пишуший в map var=value, а потом показывающий в getInfo() (и может dumpIO())
- дописать в codegen документацию по запуску и управлению логами через LogServer
......
......@@ -260,6 +260,8 @@
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */
virtual void testMode( bool state );
void updatePreviousValues();
void checkSensors();
......@@ -432,6 +434,7 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo()
inf &lt;&lt; i->info &lt;&lt; endl;
inf &lt;&lt; dumpIO() &lt;&lt; endl;
inf &lt;&lt; vmon.pretty_str() &lt;&lt; endl;
inf &lt;&lt; getMonitInfo() &lt;&lt; endl;
i->info = inf.str().c_str();
......
......@@ -13,7 +13,7 @@
Name: libuniset2
Version: 2.1
Release: alt7.1
Release: alt7.2
Summary: UniSet - library for building distributed industrial control systems
......@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Sun Jun 07 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.2
- (codegen): add user info function (getMonitInfo())
* Sat Jun 06 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt7.1
- (vmonit): new utilities (variables monitor)
......
......@@ -486,4 +486,7 @@ MyClass_SK.cc: myclass.src.xml
После этого они появяться в выводе утилиты uniset2-vmonit
\warning На данный момент поддерживаются только простые типы переменных (bool,short,int,long,double,float см. VMonitor)
Для пользовательской информации введена виртуальная функция std::string getMonitInfo(), переопределив которую,
можно сформировать свою информацию, которую можно будет удалённо читать.
*/
......@@ -8,13 +8,15 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2015-05-31+03:00
// generate timestamp: 2015-06-07+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
// -----------------------------------------------------------------------------
#include <memory>
#include <string>
#include <unordered_map>
#include <sstream>
#include "UniSetObject.h"
#include "LT_Object.h"
#include "UniXML.h"
......@@ -22,13 +24,14 @@
#include "DebugStream.h"
#include "LogServer.h"
#include "LogAgregator.h"
#include "VMonitor.h"
// -----------------------------------------------------------------------------
class UObject_SK:
public UniSetObject,
public LT_Object
{
public:
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node = UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix = "" );
UObject_SK( UniSetTypes::ObjectId id, xmlNode* node=UniSetTypes::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK();
virtual ~UObject_SK();
......@@ -38,63 +41,62 @@ class UObject_SK:
void askSensor( UniSetTypes::ObjectId sid, UniversalIO::UIOCommand, UniSetTypes::ObjectId node = UniSetTypes::uniset_conf()->getLocalNode() );
void updateValues();
virtual UniSetTypes::SimpleInfo* getInfo() override;
virtual bool setMsg( UniSetTypes::ObjectId code, bool state = true );
inline std::shared_ptr<DebugStream> log()
{
return mylog;
}
inline std::shared_ptr<LogAgregator> logAgregator()
{
return loga;
}
inline std::shared_ptr<DebugStream> log(){ return mylog; }
inline std::shared_ptr<LogAgregator> logAgregator(){ return loga; }
void init_dlog( std::shared_ptr<DebugStream> d );
// "синтаксический сахар"..для логов
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#ifndef mylogany
#define mylogany log()->any()
#endif
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#endif
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
/*!< вывод в строку значение всех входов и выходов в формате
/*! вывод в строку значение всех входов и выходов в формате
ObjectName:
in_xxx = val
in_xxx2 = val
......@@ -103,17 +105,20 @@ class UObject_SK:
*/
std::string dumpIO();
/*!< Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
/*! Вывод в строку названия входа/выхода в формате: in_xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string str( UniSetTypes::ObjectId id, bool showLinkName = true );
std::string str( UniSetTypes::ObjectId id, bool showLinkName=true );
/*!< Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string strval( UniSetTypes::ObjectId id, bool showLinkName = true );
std::string strval( UniSetTypes::ObjectId id, bool showLinkName=true );
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
// ------------------------------------------------------------
......@@ -141,12 +146,14 @@ class UObject_SK:
virtual void callback() override;
virtual void processingMessage( UniSetTypes::VoidMessage* msg ) override;
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) {};
virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override {}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override {}
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ){};
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override{}
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override{}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */
virtual void testMode( bool state );
void updatePreviousValues();
void checkSensors();
......@@ -164,7 +171,7 @@ class UObject_SK:
int resetMsgTime;
// Выполнение очередного шага программы
virtual void step() {}
virtual void step(){}
int sleep_msec; /*!< пауза между итерациями */
bool active;
......@@ -179,15 +186,9 @@ class UObject_SK:
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getIntProp(confnode, name);
}
int getIntProp(const std::string& name) { return UniSetTypes::uniset_conf()->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name)
{
return UniSetTypes::uniset_conf()->getProp(confnode, name);
}
inline const std::string getProp(const std::string& name) { return UniSetTypes::uniset_conf()->getProp(confnode, name); }
int smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated;
......@@ -204,6 +205,11 @@ class UObject_SK:
std::string logserv_host = {""};
int logserv_port = {0};
// snap
bool no_snap = {false};
VMonitor vmon;
private:
......
......@@ -88,7 +88,7 @@
private:
int myvar1;
bool myvar2;
logn myvar3;
long myvar3;
...
VMonitor vmon;
}
......
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