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
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
82 deletions
+89
-82
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
+0
-0
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
373b2172
...
...
@@ -249,6 +249,13 @@
*/
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(); }
// ------------------------------------------------------------
...
...
@@ -1561,6 +1568,20 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
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
{
ostringstream s;
...
...
extensions/include/UObject_SK.h
View file @
373b2172
...
...
@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
// --------------------------------------------------------------------------
// generate timestamp: 201
7-09-01
+03:00
// generate timestamp: 201
8-05-18
+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,23 @@ 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
;
/*! Вывод в строку названия датчика-сообщения: 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
();
}
// ------------------------------------------------------------
std
::
string
help
()
const
noexcept
;
...
...
@@ -161,29 +159,23 @@ 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
bool
activateObject
()
override
;
virtual
bool
deactivateObject
()
override
;
virtual
std
::
string
getMonitInfo
()
const
{
return
""
;
/*!< пользовательская информация выводимая в getInfo() */
}
virtual
std
::
string
getTypeOfMessage
(
int
t
)
const
{
return
uniset
::
strTypeOfMessage
(
t
);
/*!< получение названия типа сообщения. Используется в getInfo() */
}
virtual
std
::
string
getMonitInfo
()
const
{
return
""
;
}
/*!< пользовательская информация выводимая в getInfo() */
virtual
std
::
string
getTypeOfMessage
(
int
t
)
const
{
return
uniset
::
strTypeOfMessage
(
t
);
}
/*!< получение названия типа сообщения. Используется в 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
);
...
...
@@ -212,15 +204,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
=
{
false
};
...
...
@@ -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 */
std
::
unordered_map
<
long
,
size_t
>
msgTypeStat
;
/*!< количество сообщений по типам */
std
::
unordered_map
<
long
,
size_t
>
msgTypeStat
;
/*!< количество сообщений по типам */
std
::
string
ostate
=
{
""
};
/*!< состояние процесса (выводится в getInfo()) */
...
...
extensions/lib/UObject_SK.cc
View file @
373b2172
This diff is collapsed.
Click to expand it.
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