Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
373b2172
Commit
373b2172
authored
May 18, 2018
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(codegen): added msgstr() function
parent
5b8d5825
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
185 additions
and
200 deletions
+185
-200
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+21
-0
UObject_SK.h
extensions/include/UObject_SK.h
+68
-82
UObject_SK.cc
extensions/lib/UObject_SK.cc
+96
-118
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
373b2172
...
@@ -249,6 +249,13 @@
...
@@ -249,6 +249,13 @@
*/
*/
std::string strval( uniset::ObjectId id, bool showLinkName=true ) const;
std::string strval( uniset::ObjectId id, bool showLinkName=true ) const;
/*! Вывод в строку названия датчика-сообщения: xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std::string msgstr( uniset::ObjectId id, bool showLinkName=true ) const;
/*! Вывод состояния внутренних переменных */
/*! Вывод состояния внутренних переменных */
inline std::string dumpVars(){ return vmon.pretty_str(); }
inline std::string dumpVars(){ return vmon.pretty_str(); }
// ------------------------------------------------------------
// ------------------------------------------------------------
...
@@ -1561,6 +1568,20 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
...
@@ -1561,6 +1568,20 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
return s.str();
return s.str();
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
std::string
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::msgstr( uniset::ObjectId id, bool showLinkName ) const
{
ostringstream s;
<xsl:for-each
select=
"//msgmap/item"
>
if( id ==
<xsl:value-of
select=
"@name"
/>
)
{
s
<<
"
<xsl:value-of
select=
"@name"
/>
";
if( showLinkName ) s
<<
"("
<<
ORepHelpers::getShortName( uniset_conf()->oind->getMapName(
<xsl:value-of
select=
"@name"
/>
))
<<
")";
return s.str();
}
</xsl:for-each>
return "";
}
// ----------------------------------------------------------------------------
std::string
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::str( uniset::ObjectId id, bool showLinkName ) const
std::string
<xsl:value-of
select=
"$CLASSNAME"
/>
_SK::str( uniset::ObjectId id, bool showLinkName ) const
{
{
ostringstream s;
ostringstream s;
...
...
extensions/include/UObject_SK.h
View file @
373b2172
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// generate timestamp: 201
7-09-01
+03:00
// generate timestamp: 201
8-05-18
+03:00
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#ifndef UObject_SK_H_
#define UObject_SK_H_
#define UObject_SK_H_
...
@@ -29,7 +29,7 @@ class UObject_SK:
...
@@ -29,7 +29,7 @@ class UObject_SK:
public
uniset
::
UniSetObject
public
uniset
::
UniSetObject
{
{
public
:
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
();
UObject_SK
();
virtual
~
UObject_SK
();
virtual
~
UObject_SK
();
...
@@ -43,60 +43,54 @@ class UObject_SK:
...
@@ -43,60 +43,54 @@ class UObject_SK:
virtual
bool
setMsg
(
uniset
::
ObjectId
code
,
bool
state
=
true
)
noexcept
;
virtual
bool
setMsg
(
uniset
::
ObjectId
code
,
bool
state
=
true
)
noexcept
;
inline
std
::
shared_ptr
<
DebugStream
>
log
()
noexcept
inline
std
::
shared_ptr
<
DebugStream
>
log
()
noexcept
{
return
mylog
;
}
{
inline
std
::
shared_ptr
<
uniset
::
LogAgregator
>
logAgregator
()
noexcept
{
return
loga
;
}
return
mylog
;
}
inline
std
::
shared_ptr
<
uniset
::
LogAgregator
>
logAgregator
()
noexcept
{
return
loga
;
}
void
init_dlog
(
std
::
shared_ptr
<
DebugStream
>
d
)
noexcept
;
void
init_dlog
(
std
::
shared_ptr
<
DebugStream
>
d
)
noexcept
;
// "синтаксический сахар"..для логов
// "синтаксический сахар"..для логов
#ifndef myinfo
#ifndef myinfo
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#define myinfo if( log()->debugging(Debug::INFO) ) log()->info()
#endif
#endif
#ifndef mywarn
#ifndef mywarn
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#define mywarn if( log()->debugging(Debug::WARN) ) log()->warn()
#endif
#endif
#ifndef mycrit
#ifndef mycrit
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#define mycrit if( log()->debugging(Debug::CRIT) ) log()->crit()
#endif
#endif
#ifndef mylog1
#ifndef mylog1
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#define mylog1 if( log()->debugging(Debug::LEVEL1) ) log()->level1()
#endif
#endif
#ifndef mylog2
#ifndef mylog2
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#define mylog2 if( log()->debugging(Debug::LEVEL2) ) log()->level2()
#endif
#endif
#ifndef mylog3
#ifndef mylog3
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#define mylog3 if( log()->debugging(Debug::LEVEL3) ) log()->level3()
#endif
#endif
#ifndef mylog4
#ifndef mylog4
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#define mylog4 if( log()->debugging(Debug::LEVEL4) ) log()->level4()
#endif
#endif
#ifndef mylog5
#ifndef mylog5
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#define mylog5 if( log()->debugging(Debug::LEVEL5) ) log()->level5()
#endif
#endif
#ifndef mylog6
#ifndef mylog6
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#define mylog6 if( log()->debugging(Debug::LEVEL6) ) log()->level6()
#endif
#endif
#ifndef mylog7
#ifndef mylog7
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#define mylog7 if( log()->debugging(Debug::LEVEL7) ) log()->level7()
#endif
#endif
#ifndef mylog8
#ifndef mylog8
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#define mylog8 if( log()->debugging(Debug::LEVEL8) ) log()->level8()
#endif
#endif
#ifndef mylog9
#ifndef mylog9
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#define mylog9 if( log()->debugging(Debug::LEVEL9) ) log()->level9()
#endif
#endif
#ifndef mylogany
#ifndef mylogany
#define mylogany log()->any()
#define mylogany log()->any()
#endif
#endif
#ifndef vmonit
#ifndef vmonit
#define vmonit( var ) vmon.add( #var, var )
#define vmonit( var ) vmon.add( #var, var )
#endif
#endif
// Вспомогательные функции для удобства логирования
// Вспомогательные функции для удобства логирования
// ------------------------------------------------------------
// ------------------------------------------------------------
...
@@ -113,19 +107,23 @@ class UObject_SK:
...
@@ -113,19 +107,23 @@ class UObject_SK:
\param id - идентификатор датчика
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
\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
/*! Вывод значения входа/выхода в формате: in_xxx(SensorName)=val
\param id - идентификатор датчика
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
\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
;
/*! Вывод в строку названия датчика-сообщения: xxx(SensorName)
\param id - идентификатор датчика
\param showLinkName - TRUE - выводить SensorName, FALSE - не выводить
*/
std
::
string
msgstr
(
uniset
::
ObjectId
id
,
bool
showLinkName
=
true
)
const
;
/*! Вывод состояния внутренних переменных */
/*! Вывод состояния внутренних переменных */
inline
std
::
string
dumpVars
()
inline
std
::
string
dumpVars
(){
return
vmon
.
pretty_str
();
}
{
return
vmon
.
pretty_str
();
}
// ------------------------------------------------------------
// ------------------------------------------------------------
std
::
string
help
()
const
noexcept
;
std
::
string
help
()
const
noexcept
;
...
@@ -161,29 +159,23 @@ class UObject_SK:
...
@@ -161,29 +159,23 @@ class UObject_SK:
virtual
void
callback
()
noexcept
override
;
virtual
void
callback
()
noexcept
override
;
virtual
void
processingMessage
(
const
uniset
::
VoidMessage
*
msg
)
override
;
virtual
void
processingMessage
(
const
uniset
::
VoidMessage
*
msg
)
override
;
virtual
void
sysCommand
(
const
uniset
::
SystemMessage
*
sm
)
{};
virtual
void
sysCommand
(
const
uniset
::
SystemMessage
*
sm
){};
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
)
{}
virtual
void
askSensors
(
UniversalIO
::
UIOCommand
cmd
){}
virtual
void
sensorInfo
(
const
uniset
::
SensorMessage
*
sm
)
override
{}
virtual
void
sensorInfo
(
const
uniset
::
SensorMessage
*
sm
)
override
{}
virtual
void
timerInfo
(
const
uniset
::
TimerMessage
*
tm
)
override
{}
virtual
void
timerInfo
(
const
uniset
::
TimerMessage
*
tm
)
override
{}
virtual
bool
activateObject
()
override
;
virtual
bool
activateObject
()
override
;
virtual
bool
deactivateObject
()
override
;
virtual
bool
deactivateObject
()
override
;
virtual
std
::
string
getMonitInfo
()
const
virtual
std
::
string
getMonitInfo
()
const
{
return
""
;
}
/*!< пользовательская информация выводимая в getInfo() */
{
virtual
std
::
string
getTypeOfMessage
(
int
t
)
const
{
return
uniset
::
strTypeOfMessage
(
t
);
}
/*!< получение названия типа сообщения. Используется в getInfo() */
return
""
;
/*!< пользовательская информация выводимая в getInfo() */
}
virtual
std
::
string
getTypeOfMessage
(
int
t
)
const
{
return
uniset
::
strTypeOfMessage
(
t
);
/*!< получение названия типа сообщения. Используется в getInfo() */
}
#ifndef DISABLE_REST_API
#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
httpDumpIO
();
virtual
Poco
::
JSON
::
Object
::
Ptr
httpRequestLog
(
const
Poco
::
URI
::
QueryParameters
&
p
);
virtual
Poco
::
JSON
::
Object
::
Ptr
httpRequestLog
(
const
Poco
::
URI
::
QueryParameters
&
p
);
#endif
#endif
// Выполнение очередного шага программы
// Выполнение очередного шага программы
virtual
void
step
()
{}
virtual
void
step
(){}
void
preAskSensors
(
UniversalIO
::
UIOCommand
cmd
);
void
preAskSensors
(
UniversalIO
::
UIOCommand
cmd
);
void
preSysCommand
(
const
uniset
::
SystemMessage
*
sm
);
void
preSysCommand
(
const
uniset
::
SystemMessage
*
sm
);
...
@@ -212,15 +204,9 @@ class UObject_SK:
...
@@ -212,15 +204,9 @@ class UObject_SK:
xmlNode
*
confnode
;
xmlNode
*
confnode
;
/*! получить числовое свойство из конф. файла по привязанной confnode */
/*! получить числовое свойство из конф. файла по привязанной confnode */
int
getIntProp
(
const
std
::
string
&
name
)
int
getIntProp
(
const
std
::
string
&
name
)
{
return
uniset
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
{
return
uniset
::
uniset_conf
()
->
getIntProp
(
confnode
,
name
);
}
/*! получить текстовое свойство из конф. файла по привязанной confnode */
/*! получить текстовое свойство из конф. файла по привязанной confnode */
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
uniset
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
{
return
uniset
::
uniset_conf
()
->
getProp
(
confnode
,
name
);
}
uniset
::
timeout_t
smReadyTimeout
;
/*!< время ожидания готовности SM */
uniset
::
timeout_t
smReadyTimeout
;
/*!< время ожидания готовности SM */
std
::
atomic_bool
activated
=
{
false
};
std
::
atomic_bool
activated
=
{
false
};
...
@@ -272,10 +258,10 @@ class UObject_SK:
...
@@ -272,10 +258,10 @@ 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 */
size_t
processingMessageCatchCount
=
{
0
};
/*!< количество исключений пойманных в processingMessage */
std
::
unordered_map
<
long
,
size_t
>
msgTypeStat
;
/*!< количество сообщений по типам */
std
::
unordered_map
<
long
,
size_t
>
msgTypeStat
;
/*!< количество сообщений по типам */
std
::
string
ostate
=
{
""
};
/*!< состояние процесса (выводится в getInfo()) */
std
::
string
ostate
=
{
""
};
/*!< состояние процесса (выводится в getInfo()) */
...
...
extensions/lib/UObject_SK.cc
View file @
373b2172
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// generate timestamp: 201
7-09-01
+03:00
// generate timestamp: 201
8-05-18
+03:00
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#include <memory>
#include <memory>
#include <iomanip>
#include <iomanip>
...
@@ -32,28 +32,28 @@ using namespace uniset;
...
@@ -32,28 +32,28 @@ using namespace uniset;
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
UObject_SK
::
UObject_SK
()
:
UObject_SK
::
UObject_SK
()
:
// Инициализация идентификаторов (имена берутся из конф. файла)
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables (public and proteced)
// variables (public and proteced)
// ------------------
// ------------------
active
(
false
),
active
(
false
),
idHeartBeat
(
DefaultObjectId
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
maxHeartBeat
(
10
),
confnode
(
0
),
confnode
(
0
),
smReadyTimeout
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
activated
(
false
),
askPause
(
2000
),
askPause
(
2000
),
forceOut
(
false
),
forceOut
(
false
),
// private variables
// private variables
end_private
(
false
)
end_private
(
false
)
{
{
mycrit
<<
"UObject: init failed!!!!!!!!!!!!!!!"
<<
endl
;
mycrit
<<
"UObject: init failed!!!!!!!!!!!!!!!"
<<
endl
;
throw
uniset
::
Exception
(
std
::
string
(
myname
+
": init failed!!!"
)
);
throw
uniset
::
Exception
(
std
::
string
(
myname
+
": init failed!!!"
)
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// ( val, confval, default val )
// ( val, confval, default val )
...
@@ -61,7 +61,6 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
...
@@ -61,7 +61,6 @@ static const std::string init3_str( const std::string& s1, const std::string& s2
{
{
if
(
!
s1
.
empty
()
)
if
(
!
s1
.
empty
()
)
return
s1
;
return
s1
;
if
(
!
s2
.
empty
()
)
if
(
!
s2
.
empty
()
)
return
s2
;
return
s2
;
...
@@ -75,41 +74,41 @@ static uniset::ObjectId init_node( xmlNode* cnode, const std::string& prop )
...
@@ -75,41 +74,41 @@ static uniset::ObjectId init_node( xmlNode* cnode, const std::string& prop )
auto
conf
=
uniset_conf
();
auto
conf
=
uniset_conf
();
if
(
conf
->
getProp
(
cnode
,
prop
).
empty
()
)
if
(
conf
->
getProp
(
cnode
,
prop
).
empty
()
)
return
conf
->
getLocalNode
();
return
conf
->
getLocalNode
();
return
conf
->
getNodeID
(
conf
->
getProp
(
cnode
,
prop
));
return
conf
->
getNodeID
(
conf
->
getProp
(
cnode
,
prop
));
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
UObject_SK
::
UObject_SK
(
ObjectId
id
,
xmlNode
*
cnode
,
const
std
::
string
&
_argprefix
)
:
UObject_SK
::
UObject_SK
(
ObjectId
id
,
xmlNode
*
cnode
,
const
std
::
string
&
_argprefix
)
:
UniSetObject
(
id
),
UniSetObject
(
id
),
// Инициализация идентификаторов (имена берутся из конф. файла)
// Инициализация идентификаторов (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// Используемые идентификаторы сообщений (имена берутся из конф. файла)
// variables
// variables
sleep_msec
(
150
),
sleep_msec
(
150
),
active
(
true
),
active
(
true
),
argprefix
(
(
_argprefix
.
empty
()
?
myname
+
"-"
:
_argprefix
)
),
argprefix
(
(
_argprefix
.
empty
()
?
myname
+
"-"
:
_argprefix
)
),
idHeartBeat
(
DefaultObjectId
),
idHeartBeat
(
DefaultObjectId
),
maxHeartBeat
(
10
),
maxHeartBeat
(
10
),
confnode
(
cnode
),
confnode
(
cnode
),
smReadyTimeout
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
activated
(
false
),
askPause
(
uniset_conf
()
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
askPause
(
uniset_conf
()
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
forceOut
(
false
),
forceOut
(
false
),
end_private
(
false
)
end_private
(
false
)
{
{
auto
conf
=
uniset_conf
();
auto
conf
=
uniset_conf
();
if
(
uniset
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
if
(
uniset
::
findArgParam
(
"--print-id-list"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
{
{
// abort();
// abort();
}
}
...
@@ -125,10 +124,10 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
...
@@ -125,10 +124,10 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
{
{
ostringstream
s
;
ostringstream
s
;
s
<<
argprefix
<<
"log"
;
s
<<
argprefix
<<
"log"
;
conf
->
initLogStream
(
mylog
,
s
.
str
());
conf
->
initLogStream
(
mylog
,
s
.
str
());
}
}
loga
=
make_shared
<
LogAgregator
>
(
myname
+
"-loga"
);
loga
=
make_shared
<
LogAgregator
>
(
myname
+
"-loga"
);
loga
->
add
(
mylog
);
loga
->
add
(
mylog
);
loga
->
add
(
ulog
());
loga
->
add
(
ulog
());
...
@@ -146,14 +145,12 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
...
@@ -146,14 +145,12 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
logserv_port
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"logserver-port"
,
it
.
getProp
(
"logserverPort"
),
getId
());
logserv_port
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"logserver-port"
,
it
.
getProp
(
"logserverPort"
),
getId
());
}
}
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
forceOut
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"force-out"
,
it
.
getProp
(
"forceOut"
),
false
);
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
string
heart
=
conf
->
getArgParam
(
"--"
+
argprefix
+
"heartbeat-id"
,
it
.
getProp
(
"heartbeat_id"
));
if
(
!
heart
.
empty
()
)
if
(
!
heart
.
empty
()
)
{
{
idHeartBeat
=
conf
->
getSensorID
(
heart
);
idHeartBeat
=
conf
->
getSensorID
(
heart
);
if
(
idHeartBeat
==
DefaultObjectId
)
if
(
idHeartBeat
==
DefaultObjectId
)
{
{
ostringstream
err
;
ostringstream
err
;
...
@@ -161,14 +158,13 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
...
@@ -161,14 +158,13 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
throw
uniset
::
SystemError
(
err
.
str
());
throw
uniset
::
SystemError
(
err
.
str
());
}
}
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
int
heartbeatTime
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-time"
,
it
.
getProp
(
"heartbeatTime"
),
conf
->
getHeartBeatTime
());
if
(
heartbeatTime
>
0
)
if
(
heartbeatTime
>
0
)
ptHeartBeat
.
setTiming
(
heartbeatTime
);
ptHeartBeat
.
setTiming
(
heartbeatTime
);
else
else
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
ptHeartBeat
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
maxHeartBeat
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"heartbeat-max"
,
it
.
getProp
(
"heartbeat_max"
),
10
);
}
}
// Инициализация значений
// Инициализация значений
...
@@ -177,18 +173,16 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
...
@@ -177,18 +173,16 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
si
.
id
=
uniset
::
DefaultObjectId
;
si
.
id
=
uniset
::
DefaultObjectId
;
si
.
node
=
conf
->
getLocalNode
();
si
.
node
=
conf
->
getLocalNode
();
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
sleep_msec
=
conf
->
getArgPInt
(
"--"
+
argprefix
+
"sleep-msec"
,
"150"
,
150
);
string
s_resetTime
(
""
);
string
s_resetTime
(
""
);
if
(
s_resetTime
.
empty
()
)
if
(
s_resetTime
.
empty
()
)
s_resetTime
=
"500"
;
s_resetTime
=
"500"
;
resetMsgTime
=
uni_atoi
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"resetMsgTime"
),
conf
->
getProp
(
cnode
,
"resetMsgTime"
),
s_resetTime
));
resetMsgTime
=
uni_atoi
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"resetMsgTime"
),
conf
->
getProp
(
cnode
,
"resetMsgTime"
),
s_resetTime
));
ptResetMsg
.
setTiming
(
resetMsgTime
);
ptResetMsg
.
setTiming
(
resetMsgTime
);
int
sm_tout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
int
sm_tout
=
conf
->
getArgInt
(
"--"
+
argprefix
+
"sm-ready-timeout"
,
""
);
if
(
sm_tout
==
0
)
if
(
sm_tout
==
0
)
smReadyTimeout
=
conf
->
getNCReadyTimeout
();
smReadyTimeout
=
conf
->
getNCReadyTimeout
();
else
if
(
sm_tout
<
0
)
else
if
(
sm_tout
<
0
)
...
@@ -196,7 +190,7 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
...
@@ -196,7 +190,7 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
else
else
smReadyTimeout
=
sm_tout
;
smReadyTimeout
=
sm_tout
;
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
smTestID
=
conf
->
getSensorID
(
init3_str
(
conf
->
getArgParam
(
"--"
+
argprefix
+
"sm-test-id"
),
conf
->
getProp
(
cnode
,
"smTestID"
),
""
));
if
(
smTestID
==
DefaultObjectId
)
if
(
smTestID
==
DefaultObjectId
)
...
@@ -223,7 +217,7 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
...
@@ -223,7 +217,7 @@ UObject_SK::UObject_SK( ObjectId id, xmlNode* cnode, const std::string& _argpref
// help надо выводить в конце, когда уже все переменные инициализированы по умолчанию
// help надо выводить в конце, когда уже все переменные инициализированы по умолчанию
if
(
uniset
::
findArgParam
(
"--"
+
argprefix
+
"help"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
if
(
uniset
::
findArgParam
(
"--"
+
argprefix
+
"help"
,
uniset_conf
()
->
getArgc
(),
uniset_conf
()
->
getArgv
())
!=
-
1
)
cout
<<
help
()
<<
endl
;
cout
<<
help
()
<<
endl
;
}
}
...
@@ -275,7 +269,7 @@ bool UObject_SK::setMsg( uniset::ObjectId _code, bool _state ) noexcept
...
@@ -275,7 +269,7 @@ bool UObject_SK::setMsg( uniset::ObjectId _code, bool _state ) noexcept
void
UObject_SK
::
resetMsg
()
void
UObject_SK
::
resetMsg
()
{
{
mylog8
<<
myname
<<
"(resetMsg): reset messages.."
<<
endl
;
mylog8
<<
myname
<<
"(resetMsg): reset messages.."
<<
endl
;
// reset messages
// reset messages
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -304,11 +298,11 @@ Poco::JSON::Object::Ptr UObject_SK::httpDumpIO()
...
@@ -304,11 +298,11 @@ Poco::JSON::Object::Ptr UObject_SK::httpDumpIO()
{
{
Poco
::
JSON
::
Object
::
Ptr
jdata
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Object
::
Ptr
jdata
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Object
::
Ptr
j_in
=
uniset
::
json
::
make_child
(
jdata
,
"in"
);
Poco
::
JSON
::
Object
::
Ptr
j_in
=
uniset
::
json
::
make_child
(
jdata
,
"in"
);
Poco
::
JSON
::
Object
::
Ptr
j_out
=
uniset
::
json
::
make_child
(
jdata
,
"out"
);
Poco
::
JSON
::
Object
::
Ptr
j_out
=
uniset
::
json
::
make_child
(
jdata
,
"out"
);
...
@@ -333,29 +327,32 @@ std::string UObject_SK::dumpIO()
...
@@ -333,29 +327,32 @@ std::string UObject_SK::dumpIO()
s
<<
endl
;
s
<<
endl
;
int
n
=
0
;
int
n
=
0
;
for
(
const
auto
&
e
:
v_in
)
for
(
const
auto
&
e
:
v_in
)
{
{
s
<<
e
;
s
<<
e
;
if
(
(
n
++
)
%
2
)
if
(
(
n
++
)
%
2
)
s
<<
std
::
endl
;
s
<<
std
::
endl
;
}
}
s
<<
endl
;
s
<<
endl
;
n
=
0
;
n
=
0
;
for
(
const
auto
&
e
:
v_out
)
for
(
const
auto
&
e
:
v_out
)
{
{
s
<<
e
;
s
<<
e
;
if
(
(
n
++
)
%
2
)
if
(
(
n
++
)
%
2
)
s
<<
std
::
endl
;
s
<<
std
::
endl
;
}
}
return
s
.
str
();
return
s
.
str
();
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
msgstr
(
uniset
::
ObjectId
id
,
bool
showLinkName
)
const
{
ostringstream
s
;
return
""
;
}
// ----------------------------------------------------------------------------
std
::
string
UObject_SK
::
str
(
uniset
::
ObjectId
id
,
bool
showLinkName
)
const
std
::
string
UObject_SK
::
str
(
uniset
::
ObjectId
id
,
bool
showLinkName
)
const
{
{
ostringstream
s
;
ostringstream
s
;
...
@@ -428,17 +425,14 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
...
@@ -428,17 +425,14 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
{
{
case
SystemMessage
:
:
WatchDog
:
case
SystemMessage
:
:
WatchDog
:
myinfo
<<
myname
<<
"(preSysCommand): WatchDog"
<<
endl
;
myinfo
<<
myname
<<
"(preSysCommand): WatchDog"
<<
endl
;
if
(
!
active
||
!
ptStartUpTimeout
.
checkTime
()
)
if
(
!
active
||
!
ptStartUpTimeout
.
checkTime
()
)
{
{
mywarn
<<
myname
<<
"(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl
;
mywarn
<<
myname
<<
"(preSysCommand): игнорируем WatchDog, потому-что только-что стартанули"
<<
endl
;
break
;
break
;
}
}
case
SystemMessage
:
:
StartUp
:
case
SystemMessage
:
:
StartUp
:
{
{
ostate
=
"StartUp..."
;
ostate
=
"StartUp..."
;
try
try
{
{
if
(
!
logserv_host
.
empty
()
&&
logserv_port
!=
0
&&
!
logserv
->
isRunning
()
)
if
(
!
logserv_host
.
empty
()
&&
logserv_port
!=
0
&&
!
logserv
->
isRunning
()
)
...
@@ -458,12 +452,10 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
...
@@ -458,12 +452,10 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
}
}
ostate
=
"StartUp: wait sm ready.."
;
ostate
=
"StartUp: wait sm ready.."
;
if
(
!
waitSM
(
smReadyTimeout
)
)
if
(
!
waitSM
(
smReadyTimeout
)
)
{
{
if
(
!
cancelled
)
if
(
!
cancelled
)
uterminate
();
uterminate
();
return
;
return
;
}
}
...
@@ -496,10 +488,9 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
...
@@ -496,10 +488,9 @@ void UObject_SK::preSysCommand( const SystemMessage* _sm )
// переоткрываем логи
// переоткрываем логи
mylogany
<<
myname
<<
"(preSysCommand): logRotate"
<<
endl
;
mylogany
<<
myname
<<
"(preSysCommand): logRotate"
<<
endl
;
string
fname
(
log
()
->
getLogFile
()
);
string
fname
(
log
()
->
getLogFile
()
);
if
(
!
fname
.
empty
()
)
if
(
!
fname
.
empty
()
)
{
{
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylog
->
logFile
(
fname
.
c_str
(),
true
);
mylogany
<<
myname
<<
"(preSysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
mylogany
<<
myname
<<
"(preSysCommand): ***************** mylog LOG ROTATE *****************"
<<
endl
;
}
}
...
@@ -554,10 +545,8 @@ uniset::SimpleInfo* UObject_SK::getInfo( const char* userparam )
...
@@ -554,10 +545,8 @@ uniset::SimpleInfo* UObject_SK::getInfo( const char* userparam )
inf
<<
"statistics: "
<<
endl
inf
<<
"statistics: "
<<
endl
<<
" processingMessageCatchCount: "
<<
processingMessageCatchCount
<<
endl
;
<<
" processingMessageCatchCount: "
<<
processingMessageCatchCount
<<
endl
;
inf
<<
" Type of messages: "
<<
endl
;
inf
<<
" Type of messages: "
<<
endl
;
for
(
const
auto
&
s
:
msgTypeStat
)
for
(
const
auto
&
s
:
msgTypeStat
)
inf
<<
" ("
<<
s
.
first
<<
")"
<<
setw
(
10
)
<<
getTypeOfMessage
(
s
.
first
)
<<
": "
<<
setw
(
5
)
<<
s
.
second
<<
endl
;
inf
<<
" ("
<<
s
.
first
<<
")"
<<
setw
(
10
)
<<
getTypeOfMessage
(
s
.
first
)
<<
": "
<<
setw
(
5
)
<<
s
.
second
<<
endl
;
inf
<<
endl
;
inf
<<
endl
;
...
@@ -565,16 +554,14 @@ uniset::SimpleInfo* UObject_SK::getInfo( const char* userparam )
...
@@ -565,16 +554,14 @@ uniset::SimpleInfo* UObject_SK::getInfo( const char* userparam )
inf
<<
endl
;
inf
<<
endl
;
auto
timers
=
getTimersList
();
auto
timers
=
getTimersList
();
inf
<<
"Timers["
<<
timers
.
size
()
<<
"]:"
<<
endl
;
inf
<<
"Timers["
<<
timers
.
size
()
<<
"]:"
<<
endl
;
for
(
const
auto
&
t
:
timers
)
for
(
const
auto
&
t
:
timers
)
{
{
inf
<<
" "
<<
setw
(
15
)
<<
getTimerName
(
t
.
id
)
<<
"["
<<
t
.
id
<<
"]: msec="
inf
<<
" "
<<
setw
(
15
)
<<
getTimerName
(
t
.
id
)
<<
"["
<<
t
.
id
<<
"]: msec="
<<
setw
(
6
)
<<
t
.
tmr
.
getInterval
()
<<
setw
(
6
)
<<
t
.
tmr
.
getInterval
()
<<
" timeleft="
<<
setw
(
6
)
<<
t
.
curTimeMS
<<
" timeleft="
<<
setw
(
6
)
<<
t
.
curTimeMS
<<
" tick="
<<
setw
(
3
)
<<
(
t
.
curTick
>=
0
?
t
.
curTick
:
-
1
)
<<
" tick="
<<
setw
(
3
)
<<
(
t
.
curTick
>=
0
?
t
.
curTick
:
-
1
)
<<
endl
;
<<
endl
;
}
}
inf
<<
endl
;
inf
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
vmon
.
pretty_str
()
<<
endl
;
inf
<<
endl
;
inf
<<
endl
;
...
@@ -592,53 +579,49 @@ Poco::JSON::Object::Ptr UObject_SK::httpGet( const Poco::URI::QueryParameters& p
...
@@ -592,53 +579,49 @@ Poco::JSON::Object::Ptr UObject_SK::httpGet( const Poco::URI::QueryParameters& p
Poco
::
JSON
::
Object
::
Ptr
json
=
UniSetObject
::
httpGet
(
params
);
Poco
::
JSON
::
Object
::
Ptr
json
=
UniSetObject
::
httpGet
(
params
);
Poco
::
JSON
::
Object
::
Ptr
jdata
=
json
->
getObject
(
myname
);
Poco
::
JSON
::
Object
::
Ptr
jdata
=
json
->
getObject
(
myname
);
if
(
!
jdata
)
if
(
!
jdata
)
jdata
=
uniset
::
json
::
make_child
(
json
,
myname
);
jdata
=
uniset
::
json
::
make_child
(
json
,
myname
);
Poco
::
JSON
::
Object
::
Ptr
jserv
=
uniset
::
json
::
make_child
(
jdata
,
"LogServer"
);
Poco
::
JSON
::
Object
::
Ptr
jserv
=
uniset
::
json
::
make_child
(
jdata
,
"LogServer"
);
if
(
logserv
)
if
(
logserv
)
{
{
jserv
->
set
(
"host"
,
logserv_host
);
jserv
->
set
(
"host"
,
logserv_host
);
jserv
->
set
(
"port"
,
logserv_port
);
jserv
->
set
(
"port"
,
logserv_port
);
jserv
->
set
(
"state"
,
(
logserv
->
isRunning
()
?
"RUNNIG"
:
"STOPPED"
));
jserv
->
set
(
"state"
,(
logserv
->
isRunning
()
?
"RUNNIG"
:
"STOPPED"
));
jserv
->
set
(
"info"
,
logserv
->
httpGetShortInfo
());
jserv
->
set
(
"info"
,
logserv
->
httpGetShortInfo
());
}
}
jdata
->
set
(
"io"
,
httpDumpIO
());
jdata
->
set
(
"io"
,
httpDumpIO
());
auto
timers
=
getTimersList
();
auto
timers
=
getTimersList
();
auto
jtm
=
uniset
::
json
::
make_child
(
jdata
,
"Timers"
);
auto
jtm
=
uniset
::
json
::
make_child
(
jdata
,
"Timers"
);
jtm
->
set
(
"count"
,
timers
.
size
());
for
(
const
auto
&
t
:
timers
)
jtm
->
set
(
"count"
,
timers
.
size
());
for
(
const
auto
&
t
:
timers
)
{
{
auto
jt
=
uniset
::
json
::
make_child
(
jtm
,
to_string
(
t
.
id
));
auto
jt
=
uniset
::
json
::
make_child
(
jtm
,
to_string
(
t
.
id
));
jt
->
set
(
"id"
,
t
.
id
);
jt
->
set
(
"id"
,
t
.
id
);
jt
->
set
(
"name"
,
getTimerName
(
t
.
id
));
jt
->
set
(
"name"
,
getTimerName
(
t
.
id
));
jt
->
set
(
"msec"
,
t
.
tmr
.
getInterval
());
jt
->
set
(
"msec"
,
t
.
tmr
.
getInterval
());
jt
->
set
(
"timeleft"
,
t
.
curTimeMS
);
jt
->
set
(
"timeleft"
,
t
.
curTimeMS
);
jt
->
set
(
"tick"
,
(
t
.
curTick
>=
0
?
t
.
curTick
:
-
1
));
jt
->
set
(
"tick"
,
(
t
.
curTick
>=
0
?
t
.
curTick
:
-
1
));
}
}
auto
vlist
=
vmon
.
getList
();
auto
vlist
=
vmon
.
getList
();
auto
jvmon
=
uniset
::
json
::
make_child
(
jdata
,
"Variables"
);
auto
jvmon
=
uniset
::
json
::
make_child
(
jdata
,
"Variables"
);
for
(
const
auto
&
v
:
vlist
)
for
(
const
auto
&
v
:
vlist
)
jvmon
->
set
(
v
.
first
,
v
.
second
);
jvmon
->
set
(
v
.
first
,
v
.
second
);
auto
jstat
=
uniset
::
json
::
make_child
(
jdata
,
"Statistics"
);
auto
jstat
=
uniset
::
json
::
make_child
(
jdata
,
"Statistics"
);
jstat
->
set
(
"processingMessageCatchCount"
,
processingMessageCatchCount
);
jstat
->
set
(
"processingMessageCatchCount"
,
processingMessageCatchCount
);
auto
jsens
=
uniset
::
json
::
make_child
(
jstat
,
"sensors"
);
auto
jsens
=
uniset
::
json
::
make_child
(
jstat
,
"sensors"
);
for
(
const
auto
&
s
:
smStat
)
for
(
const
auto
&
s
:
smStat
)
{
{
std
::
string
sname
(
ORepHelpers
::
getShortName
(
uniset_conf
()
->
oind
->
getMapName
(
s
.
first
)));
std
::
string
sname
(
ORepHelpers
::
getShortName
(
uniset_conf
()
->
oind
->
getMapName
(
s
.
first
)));
auto
js
=
uniset
::
json
::
make_child
(
jsens
,
sname
);
auto
js
=
uniset
::
json
::
make_child
(
jsens
,
sname
);
js
->
set
(
"id"
,
s
.
first
);
js
->
set
(
"id"
,
s
.
first
);
js
->
set
(
"name"
,
sname
);
js
->
set
(
"name"
,
sname
);
js
->
set
(
"count"
,
s
.
second
);
js
->
set
(
"count"
,
s
.
second
);
...
@@ -655,7 +638,7 @@ Poco::JSON::Object::Ptr UObject_SK::httpHelp( const Poco::URI::QueryParameters&
...
@@ -655,7 +638,7 @@ Poco::JSON::Object::Ptr UObject_SK::httpHelp( const Poco::URI::QueryParameters&
uniset
::
json
::
help
::
object
myhelp
(
myname
,
UniSetObject
::
httpGet
(
params
));
uniset
::
json
::
help
::
object
myhelp
(
myname
,
UniSetObject
::
httpGet
(
params
));
// 'log'
// 'log'
uniset
::
json
::
help
::
item
cmd
(
"log"
,
"show log level"
);
uniset
::
json
::
help
::
item
cmd
(
"log"
,
"show log level"
);
myhelp
.
add
(
cmd
);
myhelp
.
add
(
cmd
);
return
myhelp
;
return
myhelp
;
...
@@ -666,13 +649,13 @@ Poco::JSON::Object::Ptr UObject_SK::httpRequest( const std::string& req, const P
...
@@ -666,13 +649,13 @@ Poco::JSON::Object::Ptr UObject_SK::httpRequest( const std::string& req, const P
if
(
req
==
"log"
)
if
(
req
==
"log"
)
return
httpRequestLog
(
p
);
return
httpRequestLog
(
p
);
return
UniSetObject
::
httpRequest
(
req
,
p
);
return
UniSetObject
::
httpRequest
(
req
,
p
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
Poco
::
JSON
::
Object
::
Ptr
UObject_SK
::
httpRequestLog
(
const
Poco
::
URI
::
QueryParameters
&
p
)
Poco
::
JSON
::
Object
::
Ptr
UObject_SK
::
httpRequestLog
(
const
Poco
::
URI
::
QueryParameters
&
p
)
{
{
Poco
::
JSON
::
Object
::
Ptr
jret
=
new
Poco
::
JSON
::
Object
();
Poco
::
JSON
::
Object
::
Ptr
jret
=
new
Poco
::
JSON
::
Object
();
jret
->
set
(
"log"
,
Debug
::
str
(
mylog
->
level
()));
jret
->
set
(
"log"
,
Debug
::
str
(
mylog
->
level
()));
return
jret
;
return
jret
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -721,7 +704,7 @@ bool UObject_SK::waitSM( int wait_msec, ObjectId _testID )
...
@@ -721,7 +704,7 @@ bool UObject_SK::waitSM( int wait_msec, ObjectId _testID )
<<
" testID="
<<
_testID
<<
endl
;
<<
" testID="
<<
_testID
<<
endl
;
// waitReady можно использовать т.к. датчик это по сути IONotifyController
// waitReady можно использовать т.к. датчик это по сути IONotifyController
if
(
!
ui
->
waitReadyWithCancellation
(
_testID
,
wait_msec
,
cancelled
)
)
if
(
!
ui
->
waitReadyWithCancellation
(
_testID
,
wait_msec
,
cancelled
)
)
{
{
ostringstream
err
;
ostringstream
err
;
err
<<
myname
err
<<
myname
...
@@ -732,7 +715,7 @@ bool UObject_SK::waitSM( int wait_msec, ObjectId _testID )
...
@@ -732,7 +715,7 @@ bool UObject_SK::waitSM( int wait_msec, ObjectId _testID )
return
false
;
return
false
;
}
}
if
(
!
ui
->
waitWorking
(
_testID
,
wait_msec
)
)
if
(
!
ui
->
waitWorking
(
_testID
,
wait_msec
)
)
{
{
ostringstream
err
;
ostringstream
err
;
err
<<
myname
err
<<
myname
...
@@ -778,42 +761,39 @@ void UObject_SK::callback() noexcept
...
@@ -778,42 +761,39 @@ void UObject_SK::callback() noexcept
{
{
if
(
!
active
)
if
(
!
active
)
return
;
return
;
try
try
{
{
// проверка таймеров
// проверка таймеров
checkTimers
(
this
);
checkTimers
(
this
);
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
if
(
resetMsgTime
>
0
&&
trResetMsg
.
hi
(
ptResetMsg
.
checkTime
())
)
{
{
// cout << myname << ": ********* reset messages *********" << endl;
// cout << myname << ": ********* reset messages *********" << endl;
resetMsg
();
resetMsg
();
}
}
// обработка сообщений (таймеров и т.п.)
// обработка сообщений (таймеров и т.п.)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
{
{
auto
m
=
receiveMessage
();
auto
m
=
receiveMessage
();
if
(
!
m
)
if
(
!
m
)
break
;
break
;
processingMessage
(
m
.
get
());
processingMessage
(
m
.
get
());
updateOutputs
(
forceOut
);
updateOutputs
(
forceOut
);
// updatePreviousValues();
// updatePreviousValues();
}
}
// Выполнение шага программы
// Выполнение шага программы
step
();
step
();
// "сердцебиение"
// "сердцебиение"
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
if
(
idHeartBeat
!=
DefaultObjectId
&&
ptHeartBeat
.
checkTime
()
)
{
{
try
try
{
{
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
);
ui
->
setValue
(
idHeartBeat
,
maxHeartBeat
);
ptHeartBeat
.
reset
();
ptHeartBeat
.
reset
();
}
}
catch
(
const
uniset
::
Exception
&
ex
)
catch
(
const
uniset
::
Exception
&
ex
)
...
@@ -853,7 +833,7 @@ void UObject_SK::setValue( uniset::ObjectId _sid, long _val )
...
@@ -853,7 +833,7 @@ void UObject_SK::setValue( uniset::ObjectId _sid, long _val )
ui
->
setValue
(
_sid
,
_val
);
ui
->
setValue
(
_sid
,
_val
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UObject_SK
::
updateOutputs
(
bool
_force
)
void
UObject_SK
::
updateOutputs
(
bool
_force
)
...
@@ -875,7 +855,7 @@ void UObject_SK::initFromSM()
...
@@ -875,7 +855,7 @@ void UObject_SK::initFromSM()
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UObject_SK
::
askSensor
(
uniset
::
ObjectId
_sid
,
UniversalIO
::
UIOCommand
_cmd
,
uniset
::
ObjectId
_node
)
void
UObject_SK
::
askSensor
(
uniset
::
ObjectId
_sid
,
UniversalIO
::
UIOCommand
_cmd
,
uniset
::
ObjectId
_node
)
{
{
ui
->
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
ui
->
askRemoteSensor
(
_sid
,
_cmd
,
_node
,
getId
());
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
long
UObject_SK
::
getValue
(
uniset
::
ObjectId
_sid
)
long
UObject_SK
::
getValue
(
uniset
::
ObjectId
_sid
)
...
@@ -897,12 +877,10 @@ long UObject_SK::getValue( uniset::ObjectId _sid )
...
@@ -897,12 +877,10 @@ long UObject_SK::getValue( uniset::ObjectId _sid )
void
UObject_SK
::
preAskSensors
(
UniversalIO
::
UIOCommand
_cmd
)
void
UObject_SK
::
preAskSensors
(
UniversalIO
::
UIOCommand
_cmd
)
{
{
PassiveTimer
ptAct
(
activateTimeout
);
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
{
cout
<<
myname
<<
"(preAskSensors): wait activate..."
<<
endl
;
cout
<<
myname
<<
"(preAskSensors): wait activate..."
<<
endl
;
msleep
(
300
);
msleep
(
300
);
if
(
activated
)
if
(
activated
)
break
;
break
;
}
}
...
@@ -922,7 +900,7 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
...
@@ -922,7 +900,7 @@ void UObject_SK::preAskSensors( UniversalIO::UIOCommand _cmd )
{
{
mycrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
mycrit
<<
myname
<<
"(preAskSensors): "
<<
ex
<<
endl
;
}
}
catch
(
const
std
::
exception
&
ex
)
catch
(
const
std
::
exception
&
ex
)
{
{
mycrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
mycrit
<<
myname
<<
"(execute): catch "
<<
ex
.
what
()
<<
endl
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment