Commit 0863a5f9 authored by Pavel Vainerman's avatar Pavel Vainerman

Перенёс испрвления из другой рабочей ветки.

parent 92f74164
......@@ -1259,9 +1259,9 @@ end_private(false)
if( smTestID == DefaultObjectId )
smTestID = getSMTestID();
activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 40000);
activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 90000);
int msec = conf->getArgPInt("--" + argprefix + "startup-timeout", 30000);
int msec = conf->getArgPInt("--" + argprefix + "startup-timeout", 50000);
ptStartUpTimeout.setTiming(msec);
// ===================== <variables> =====================
......@@ -1730,9 +1730,9 @@ askPause(uniset_conf()->getPIntProp(cnode,"askPause",2000))
vmonit(smReadyTimeout);
vmonit(activateTimeout);
activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 40000);
activateTimeout = conf->getArgPInt("--" + argprefix + "activate-timeout", 90000);
int msec = conf->getArgPInt("--" + argprefix + "startup-timeout", 30000);
int msec = conf->getArgPInt("--" + argprefix + "startup-timeout", 60000);
ptStartUpTimeout.setTiming(msec);
}
......
......@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 2016-12-01+03:00
// generate timestamp: 2016-12-12+03:00
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#define UObject_SK_H_
......@@ -29,7 +29,7 @@ class UObject_SK:
public uniset::UniSetObject
{
public:
UObject_SK( uniset::ObjectId id, xmlNode* node = uniset::uniset_conf()->getNode("UObject"), const std::string& argprefix = "" );
UObject_SK( uniset::ObjectId id, xmlNode* node=uniset::uniset_conf()->getNode("UObject"), const std::string& argprefix="" );
UObject_SK();
virtual ~UObject_SK();
......@@ -43,60 +43,54 @@ class UObject_SK:
virtual bool setMsg( uniset::ObjectId code, bool state = true ) noexcept;
inline std::shared_ptr<DebugStream> log() noexcept
{
return mylog;
}
inline std::shared_ptr<uniset::LogAgregator> logAgregator() noexcept
{
return loga;
}
inline std::shared_ptr<DebugStream> log() noexcept { return mylog; }
inline std::shared_ptr<uniset::LogAgregator> logAgregator() noexcept { return loga; }
void init_dlog( std::shared_ptr<DebugStream> d ) noexcept;
// "синтаксический сахар"..для логов
#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
#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
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
......@@ -113,19 +107,16 @@ class UObject_SK:
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string str( uniset::ObjectId id, bool showLinkName = true ) const;
std::string str( uniset::ObjectId id, bool showLinkName=true ) const;
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string strval( uniset::ObjectId id, bool showLinkName = true ) const;
std::string strval( uniset::ObjectId id, bool showLinkName=true ) const;
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars()
{
return std::move(vmon.pretty_str());
}
inline std::string dumpVars(){ return std::move(vmon.pretty_str()); }
// ------------------------------------------------------------
std::string help() noexcept;
......@@ -161,25 +152,22 @@ class UObject_SK:
virtual void callback() noexcept override;
virtual void processingMessage( const uniset::VoidMessage* msg ) override;
virtual void sysCommand( const uniset::SystemMessage* sm ) {};
virtual void askSensors( UniversalIO::UIOCommand cmd ) {}
virtual void sensorInfo( const uniset::SensorMessage* sm ) override {}
virtual void timerInfo( const uniset::TimerMessage* tm ) override {}
virtual void sysCommand( const uniset::SystemMessage* sm ){};
virtual void askSensors( UniversalIO::UIOCommand cmd ){}
virtual void sensorInfo( const uniset::SensorMessage* sm ) override{}
virtual void timerInfo( const uniset::TimerMessage* tm ) override{}
virtual void sigterm( int signo ) override;
virtual bool activateObject() override;
virtual std::string getMonitInfo()
{
return ""; /*!< пользовательская информация выводимая в getInfo() */
}
virtual std::string getMonitInfo(){ return ""; } /*!< пользовательская информация выводимая в getInfo() */
#ifndef DISABLE_REST_API
virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ) {} /*!< для пользовательских данных в httpGet() */
virtual void httpGetUserData( Poco::JSON::Object::Ptr& jdata ){} /*!< для пользовательских данных в httpGet() */
virtual Poco::JSON::Object::Ptr httpDumpIO();
virtual Poco::JSON::Object::Ptr httpRequestLog( const Poco::URI::QueryParameters& p );
#endif
// Выполнение очередного шага программы
virtual void step() {}
virtual void step(){}
void preAskSensors( UniversalIO::UIOCommand cmd );
void preSysCommand( const uniset::SystemMessage* sm );
......@@ -208,15 +196,9 @@ class UObject_SK:
xmlNode* confnode;
/*! получить числовое свойство из конф. файла по привязанной confnode */
int getIntProp(const std::string& name)
{
return uniset::uniset_conf()->getIntProp(confnode, name);
}
int getIntProp(const std::string& name) { return uniset::uniset_conf()->getIntProp(confnode, name); }
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline const std::string getProp(const std::string& name)
{
return uniset::uniset_conf()->getProp(confnode, name);
}
inline const std::string getProp(const std::string& name) { return uniset::uniset_conf()->getProp(confnode, name); }
uniset::timeout_t smReadyTimeout; /*!< время ожидания готовности SM */
std::atomic_bool activated;
......@@ -267,9 +249,11 @@ class UObject_SK:
}
};
std::unordered_map<const uniset::ObjectId, size_t, StatHashFn> smStat; /*!< количество сообщений по датчикам */
std::unordered_map<const uniset::ObjectId,size_t, StatHashFn> smStat; /*!< количество сообщений по датчикам */
size_t processingMessageCatchCount = { 0 }; /*!< количество исключений пойманных в processingMessage */
std::string ostate = { "" }; /*!< состояние процесса (выводится в getInfo()) */
bool end_private; // вспомогательное поле (для внутреннего использования при генерировании кода)
};
......
......@@ -8,4 +8,9 @@ libUniSet2Extensions_la_LIBADD = $(SIGC_LIBS) $(POCO_LIBS) $(top_builddir)/lib
libUniSet2Extensions_la_SOURCES = Extensions.cc SMInterface.cc Calibration.cc SingleProcess.cc \
IOBase.cc DigitalFilter.cc PID.cc MTR.cc VTypes.cc UObject_SK.cc
UObject_SK.cc: $(top_builddir)/Utilities/codegen/*.xsl
$(SHEL) $(top_builddir)/Utilities/codegen/uniset2-codegen -l $(top_builddir)/Utilities/codegen -n UObject --no-main $(top_builddir)/Utilities/codegen/tests/uobject.src.xml
mv -f UObject_SK.h ../include/
include $(top_builddir)/include.mk
......@@ -75,7 +75,7 @@ namespace uniset
namespace UHttp
{
// текущая версия API
const std::string UHTTP_API_VERSION = "v0";
const std::string UHTTP_API_VERSION="v01";
/*! интерфейс для объекта выдающего json-данные */
class IHttpRequest
......
......@@ -4430,6 +4430,58 @@ fail:
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_supplier_node_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
long arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
long val2 ;
int ecode2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
if (!PyArg_ParseTuple(args,(char *)"OO:ShortIOInfo_supplier_node_set",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_supplier_node_set" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
ecode2 = SWIG_AsVal_long(obj1, &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ShortIOInfo_supplier_node_set" "', argument " "2"" of type '" "long""'");
}
arg2 = static_cast< long >(val2);
if (arg1) (arg1)->supplier_node = arg2;
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_ShortIOInfo_supplier_node_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *arg1 = (UTypes::ShortIOInfo *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject * obj0 = 0 ;
long result;
if (!PyArg_ParseTuple(args,(char *)"O:ShortIOInfo_supplier_node_get",&obj0)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_UTypes__ShortIOInfo, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ShortIOInfo_supplier_node_get" "', argument " "1"" of type '" "UTypes::ShortIOInfo *""'");
}
arg1 = reinterpret_cast< UTypes::ShortIOInfo * >(argp1);
result = (long) ((arg1)->supplier_node);
resultobj = SWIG_From_long(static_cast< long >(result));
return resultobj;
fail:
return NULL;
}
SWIGINTERN PyObject *_wrap_new_ShortIOInfo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
UTypes::ShortIOInfo *result = 0 ;
......@@ -5403,6 +5455,8 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"ShortIOInfo_tv_nsec_get", _wrap_ShortIOInfo_tv_nsec_get, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_supplier_set", _wrap_ShortIOInfo_supplier_set, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_supplier_get", _wrap_ShortIOInfo_supplier_get, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_supplier_node_set", _wrap_ShortIOInfo_supplier_node_set, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_supplier_node_get", _wrap_ShortIOInfo_supplier_node_get, METH_VARARGS, NULL},
{ (char *)"new_ShortIOInfo", _wrap_new_ShortIOInfo, METH_VARARGS, NULL},
{ (char *)"delete_ShortIOInfo", _wrap_delete_ShortIOInfo, METH_VARARGS, NULL},
{ (char *)"ShortIOInfo_swigregister", ShortIOInfo_swigregister, METH_VARARGS, NULL},
......
......@@ -168,6 +168,8 @@ class ShortIOInfo:
__swig_getmethods__["tv_nsec"] = _pyUniSet.ShortIOInfo_tv_nsec_get
__swig_setmethods__["supplier"] = _pyUniSet.ShortIOInfo_supplier_set
__swig_getmethods__["supplier"] = _pyUniSet.ShortIOInfo_supplier_get
__swig_setmethods__["supplier_node"] = _pyUniSet.ShortIOInfo_supplier_node_set
__swig_getmethods__["supplier_node"] = _pyUniSet.ShortIOInfo_supplier_node_get
def __init__(self):
this = _pyUniSet.new_ShortIOInfo()
......
......@@ -22,8 +22,11 @@
// -------------------------------------------------------------------------
using namespace std;
using namespace Poco::Net;
using namespace uniset;
using namespace UHttp;
// -------------------------------------------------------------------------
namespace uniset
{
using namespace UHttp;
// -------------------------------------------------------------------------
UHttpRequestHandler::UHttpRequestHandler(std::shared_ptr<IHttpRequestRegistry> _registry ):
registry(_registry)
......@@ -166,4 +169,6 @@ Poco::JSON::Object::Ptr IHttpRequest::httpRequest( const string& req, const Poco
throw uniset::SystemError(err.str());
}
// -------------------------------------------------------------------------
} // end of namespace uniset
// -------------------------------------------------------------------------
#endif
......@@ -21,8 +21,10 @@
#include "Exceptions.h"
// -------------------------------------------------------------------------
using namespace Poco::Net;
using namespace uniset;
using namespace UHttp;
// -------------------------------------------------------------------------
namespace uniset
{
using namespace UHttp;
// -------------------------------------------------------------------------
UHttpServer::UHttpServer(std::shared_ptr<IHttpRequestRegistry>& supplier, const std::string& _host, int _port ):
......@@ -76,4 +78,6 @@ std::shared_ptr<DebugStream> UHttpServer::log()
return mylog;
}
// -------------------------------------------------------------------------
} // end of namespace uniset
// -------------------------------------------------------------------------
#endif // #ifndef DISABLE_REST_API
......@@ -203,7 +203,7 @@ namespace uniset
if( mylog.is_crit() )
mylog.crit() << err.str() << endl;
throw SystemError( err.str() );
throw uniset::SystemError( err.str() );
}
try
......@@ -219,7 +219,18 @@ namespace uniset
if( mylog.is_crit() )
mylog.crit() << err.str() << endl;
throw SystemError( err.str() );
throw uniset::SystemError( err.str() );
}
catch( std::exception& ex )
{
ostringstream err;
err << myname << "(evprepare): " << ex.what();
if( mylog.is_crit() )
mylog.crit() << err.str() << endl;
throw uniset::SystemError( err.str() );
}
sock->setBlocking(false);
......
......@@ -386,6 +386,7 @@ src/Communications/TCP/UTCPStream.cc
src/Communications/TCP/UTCPSocket.cc
src/Communications/TCP/USocket.cc
src/Communications/Http/UHttpRequestHandler.cc
src/Communications/Http/UHttpServer.cc
src/Communications/ComPort.cc
src/Communications/ComPort485F.cc
src/Communications/Makefile.am
......
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