Commit ce4fa6e8 authored by Pavel Vainerman's avatar Pavel Vainerman

(codegen): добавил учёи статистики по количеству SensorMessage,

сделал её вывод в httpGet).
parent 7dd5cf85
...@@ -389,10 +389,24 @@ ...@@ -389,10 +389,24 @@
} }
}; };
std::unordered_map<const UniSetTypes::ObjectId,const long*,VMapHashFn> vmap; std::unordered_map<const UniSetTypes::ObjectId, const long*,VMapHashFn> vmap;
std::unordered_map<const UniSetTypes::ObjectId,long*,VMapHashFn> outvmap; std::unordered_map<const UniSetTypes::ObjectId, long*, VMapHashFn> outvmap;
std::unordered_map<const long*,const UniSetTypes::ObjectId*,PtrMapHashFn,PtrMapEqualFn> ptrmap; std::unordered_map<const long*, const UniSetTypes::ObjectId*, PtrMapHashFn, PtrMapEqualFn> ptrmap;
std::unordered_map<long*,const UniSetTypes::ObjectId*,PtrMapHashFn,PtrMapEqualFn> outptrmap; 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&amp; key) const
{
return std::hash&lt;long&gt;()(key);
}
};
std::unordered_map&lt;const UniSetTypes::ObjectId,size_t, StatHashFn&gt; smStat; /*!&lt; количество сообщений по датчикам */
size_t processingMessageCatchCount = { 0 }; /*!&lt; количество исключений пойманных в processingMessage */
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
...@@ -410,7 +424,13 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( const UniSetType ...@@ -410,7 +424,13 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( const UniSetType
switch( _msg->type ) switch( _msg->type )
{ {
case Message::SensorInfo: case Message::SensorInfo:
preSensorInfo( reinterpret_cast&lt;const SensorMessage*&gt;(_msg) ); {
const SensorMessage* sm = reinterpret_cast&lt;const SensorMessage*&gt;(_msg);
<xsl:if test="normalize-space($STAT)='1'">
smStat[sm->id] += 1;
</xsl:if>
preSensorInfo(sm);
}
break; break;
case Message::Timer: case Message::Timer:
...@@ -427,6 +447,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( const UniSetType ...@@ -427,6 +447,9 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::processingMessage( const UniSetType
} }
catch( const std::exception&amp; ex ) catch( const std::exception&amp; ex )
{ {
<xsl:if test="normalize-space($STAT)='1'">
processingMessageCatchCount++;
</xsl:if>
mycrit &lt;&lt; myname &lt;&lt; "(processingMessage): " &lt;&lt; ex.what() &lt;&lt; endl; mycrit &lt;&lt; myname &lt;&lt; "(processingMessage): " &lt;&lt; ex.what() &lt;&lt; endl;
} }
} }
...@@ -579,6 +602,19 @@ nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpGet( const Poco::URI: ...@@ -579,6 +602,19 @@ nlohmann::json <xsl:value-of select="$CLASSNAME"/>_SK::httpGet( const Poco::URI:
for( const auto&amp; v: vlist ) for( const auto&amp; v: vlist )
jvmon[v.first] = v.second; jvmon[v.first] = v.second;
<xsl:if test="normalize-space($STAT)='1'">
auto&amp; jstat = jdata["Statistics"];
jstat["processingMessageCatchCount"] = processingMessageCatchCount;
auto&amp; jsens = jstat["sensors"];
for( const auto&amp; s: smStat )
{
auto&amp; 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); httpGetUserData(jdata);
return std::move(json); return std::move(json);
} }
......
...@@ -28,6 +28,7 @@ Valid options are: ...@@ -28,6 +28,7 @@ Valid options are:
-n, --name - filename for *_SK files (base class implementation). Default: xmlfilename_SK -n, --name - filename for *_SK files (base class implementation). Default: xmlfilename_SK
--ask - Use 'ask' templates. See the documentation. --ask - Use 'ask' templates. See the documentation.
--gen-varmap - generate variable map. For function: long* valptr(ObjectId) --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. --alone - Use 'alone' templates. See the documentation.
--no-main - Don't generate main.cc --no-main - Don't generate main.cc
...@@ -40,7 +41,7 @@ EOF ...@@ -40,7 +41,7 @@ EOF
} }
#parse command line options #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" eval set -- "$TEMP"
name= name=
...@@ -70,6 +71,7 @@ skel_xml="skel.src.xml" ...@@ -70,6 +71,7 @@ skel_xml="skel.src.xml"
skel_make="skel-Makefile.am" skel_make="skel-Makefile.am"
varmap=0 varmap=0
genstat=1
while :; do while :; do
case "$1" in case "$1" in
...@@ -120,6 +122,10 @@ while :; do ...@@ -120,6 +122,10 @@ while :; do
varmap=1 varmap=1
;; ;;
--no-gen-statistics)
genstat=1
;;
-l|--local) -l|--local)
shift shift
xsltdir=$1 xsltdir=$1
...@@ -199,6 +205,7 @@ PARAMS=$( echo \ ...@@ -199,6 +205,7 @@ PARAMS=$( echo \
--stringparam CNAME "${name}" \ --stringparam CNAME "${name}" \
--stringparam LOCALINC "${localinc}" \ --stringparam LOCALINC "${localinc}" \
--stringparam VARMAP "${varmap}" \ --stringparam VARMAP "${varmap}" \
--stringparam STAT "${genstat}" \
$xsltpath \ $xsltpath \
) )
# --stringparam ADD_CC_INC "${add_cc_inc}" \ # --stringparam ADD_CC_INC "${add_cc_inc}" \
......
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