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
ce4fa6e8
Commit
ce4fa6e8
authored
Nov 05, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(codegen): добавил учёи статистики по количеству SensorMessage,
сделал её вывод в httpGet).
parent
7dd5cf85
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
6 deletions
+49
-6
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+41
-5
uniset2-codegen.in
Utilities/codegen/uniset2-codegen.in
+8
-1
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
ce4fa6e8
...
...
@@ -389,10 +389,24 @@
}
};
std::unordered_map
<
const UniSetTypes::ObjectId,const long*,VMapHashFn
>
vmap;
std::unordered_map
<
const UniSetTypes::ObjectId,long*,VMapHashFn
>
outvmap;
std::unordered_map
<
const long*,const UniSetTypes::ObjectId*,PtrMapHashFn,PtrMapEqualFn
>
ptrmap;
std::unordered_map
<
long*,const UniSetTypes::ObjectId*,PtrMapHashFn,PtrMapEqualFn
>
outptrmap;
std::unordered_map
<
const UniSetTypes::ObjectId, const long*,VMapHashFn
>
vmap;
std::unordered_map
<
const UniSetTypes::ObjectId, long*, VMapHashFn
>
outvmap;
std::unordered_map
<
const long*, const UniSetTypes::ObjectId*, PtrMapHashFn, PtrMapEqualFn
>
ptrmap;
std::unordered_map
<
long*,const UniSetTypes::ObjectId*, PtrMapHashFn,PtrMapEqualFn
>
outptrmap;
</xsl:if>
<xsl:if
test=
"normalize-space($STAT)='1'"
>
class StatHashFn
{
public:
size_t operator() (const UniSetTypes::ObjectId
&
key) const
{
return std::hash
<
long
>
()(key);
}
};
std::unordered_map
<
const UniSetTypes::ObjectId,size_t, StatHashFn
>
smStat; /*!
<
количество сообщений по датчикам */
size_t processingMessageCatchCount = { 0 }; /*!
<
количество исключений пойманных в processingMessage */
</xsl:if>
</xsl:template>
...
...
@@ -410,7 +424,13 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( const UniSetType
switch( _msg->type )
{
case Message::SensorInfo:
preSensorInfo( reinterpret_cast
<
const SensorMessage*
>
(_msg) );
{
const SensorMessage* sm = reinterpret_cast
<
const SensorMessage*
>
(_msg);
<xsl:if
test=
"normalize-space($STAT)='1'"
>
smStat[sm->id] += 1;
</xsl:if>
preSensorInfo(sm);
}
break;
case Message::Timer:
...
...
@@ -427,6 +447,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( const UniSetType
}
catch( const std::exception
&
ex )
{
<xsl:if
test=
"normalize-space($STAT)='1'"
>
processingMessageCatchCount++;
</xsl:if>
mycrit
<<
myname
<<
"(processingMessage): "
<<
ex.what()
<<
endl;
}
}
...
...
@@ -579,6 +602,19 @@ nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpGet( const Poco::URI:
for( const auto
&
v: vlist )
jvmon[v.first] = v.second;
<xsl:if
test=
"normalize-space($STAT)='1'"
>
auto
&
jstat = jdata["Statistics"];
jstat["processingMessageCatchCount"] = processingMessageCatchCount;
auto
&
jsens = jstat["sensors"];
for( const auto
&
s: smStat )
{
auto
&
js = jsens[str(s.first,false)];
js["id"] = s.first;
js["name"] = ORepHelpers::getShortName( uniset_conf()->oind->getMapName(s.first) );
js["count"] = s.second;
}
</xsl:if>
httpGetUserData(jdata);
return std::move(json);
}
...
...
Utilities/codegen/uniset2-codegen.in
View file @
ce4fa6e8
...
...
@@ -28,6 +28,7 @@ Valid options are:
-n, --name - filename for *_SK files (base class implementation). Default: xmlfilename_SK
--ask - Use 'ask' templates. See the documentation.
--gen-varmap - generate variable map. For function: long* valptr(ObjectId)
--no-gen-statistics - disable generate code for the account of statistics
--alone - Use 'alone' templates. See the documentation.
--no-main - Don't generate main.cc
...
...
@@ -40,7 +41,7 @@ EOF
}
#parse command line options
TEMP
=
`
getopt
-n
$PROG
-o
h,n:,m:,a,l:,z
-l
help
,name:,main:,no-main,topdir:,path:,alone,ask,no-ask,local:,local-include,add-cc-include,add-hh-include,make-skel:,no-makefile,gen-varmap
--
"
$@
"
`
||
exit
1
TEMP
=
`
getopt
-n
$PROG
-o
h,n:,m:,a,l:,z
-l
help
,name:,main:,no-main,topdir:,path:,alone,ask,no-ask,local:,local-include,add-cc-include,add-hh-include,make-skel:,no-makefile,gen-varmap
,no-gen-statistics
--
"
$@
"
`
||
exit
1
eval set
--
"
$TEMP
"
name
=
...
...
@@ -70,6 +71,7 @@ skel_xml="skel.src.xml"
skel_make
=
"skel-Makefile.am"
varmap
=
0
genstat
=
1
while
:
;
do
case
"
$1
"
in
...
...
@@ -120,6 +122,10 @@ while :; do
varmap
=
1
;;
--no-gen-statistics
)
genstat
=
1
;;
-l
|
--local
)
shift
xsltdir
=
$1
...
...
@@ -199,6 +205,7 @@ PARAMS=$( echo \
--stringparam
CNAME
"
${
name
}
"
\
--stringparam
LOCALINC
"
${
localinc
}
"
\
--stringparam
VARMAP
"
${
varmap
}
"
\
--stringparam
STAT
"
${
genstat
}
"
\
$xsltpath
\
)
# --stringparam ADD_CC_INC "${add_cc_inc}" \
...
...
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