Commit f252f537 authored by Pavel Vainerman's avatar Pavel Vainerman

(VMonitor): сделал вывод переменных "в два столбца" (вместо одного)

parent d534a6f8
...@@ -14,8 +14,9 @@ print_usage() ...@@ -14,8 +14,9 @@ print_usage()
{ {
[ "$1" = 0 ] || exec >&2 [ "$1" = 0 ] || exec >&2
echo "Usage: ${0##*/} [-s watch_sec | -d] ObjectID1[@node],ObjectID2,.." echo "Usage: ${0##*/} [-s watch_sec | -d | -c confile.xml ] ObjectID1[@node],ObjectID2,.."
echo " -d - dump state. Print state and exit" echo " -d - dump state. Print state and exit"
echo " -c confile - Set confile."
# echo "" # echo ""
# uniset2-admin --help # uniset2-admin --help
...@@ -27,14 +28,19 @@ print_usage() ...@@ -27,14 +28,19 @@ print_usage()
#parse command line options #parse command line options
dump= dump=
confile=
case "$1" in case "$1" in
-h|--help) print_usage 0;; -h|--help) print_usage 0;;
-s|--sec) shift; WATCH_SEC=$1; shift;; -s|--sec) shift; WATCH_SEC=$1; shift;;
-d|--dump) dump=1; shift;; -d|--dump) dump=1; shift;;
-c|--confile) shift; confile=$1; shift;;
esac esac
OID=$1 OID=$1
shift shift
[ -z "$dump" ] && $WATCH -n $WATCH_SEC uniset2-admin --oinfo ${OID} $* [ -n "$confile" ] && confile="--confile $confile"
[ -n "$dump" ] && uniset2-admin --oinfo ${OID} $*
[ -z "$dump" ] && $WATCH -n $WATCH_SEC uniset2-admin $confile --oinfo ${OID} $*
[ -n "$dump" ] && uniset2-admin $confile --oinfo ${OID} $*
...@@ -434,7 +434,9 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo() ...@@ -434,7 +434,9 @@ UniSetTypes::SimpleInfo* <xsl:value-of select="$CLASSNAME"/>_SK::getInfo()
inf &lt;&lt; i->info &lt;&lt; endl; inf &lt;&lt; i->info &lt;&lt; endl;
inf &lt;&lt; "LogServer: " &lt;&lt; logserv_host &lt;&lt; ":" &lt;&lt; logserv_port &lt;&lt; endl; inf &lt;&lt; "LogServer: " &lt;&lt; logserv_host &lt;&lt; ":" &lt;&lt; logserv_port &lt;&lt; endl;
inf &lt;&lt; dumpIO() &lt;&lt; endl; inf &lt;&lt; dumpIO() &lt;&lt; endl;
inf &lt;&lt; endl;
inf &lt;&lt; vmon.pretty_str() &lt;&lt; endl; inf &lt;&lt; vmon.pretty_str() &lt;&lt; endl;
inf &lt;&lt; endl;
inf &lt;&lt; getMonitInfo() &lt;&lt; endl; inf &lt;&lt; getMonitInfo() &lt;&lt; endl;
i->info = inf.str().c_str(); i->info = inf.str().c_str();
...@@ -1020,14 +1022,26 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO() ...@@ -1020,14 +1022,26 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
{ {
ostringstream s; ostringstream s;
s &lt;&lt; myname &lt;&lt; ": " &lt;&lt; endl; s &lt;&lt; myname &lt;&lt; ": " &lt;&lt; endl;
std::vector&lt;std::string&gt; v;
ostringstream s1;
<xsl:for-each select="//smap/item"> <xsl:for-each select="//smap/item">
s &lt;&lt; " " &lt;&lt; setw(30) &lt;&lt; std::right &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>" s1.str("");
s1 &lt;&lt; " " &lt;&lt; setw(30) &lt;&lt; std::right &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>"
&lt;&lt; "(" &lt;&lt; setw(30) &lt;&lt; std::left &lt;&lt; ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)) &lt;&lt; ")" &lt;&lt; "(" &lt;&lt; setw(30) &lt;&lt; std::left &lt;&lt; ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)) &lt;&lt; ")"
&lt;&lt; std::right &lt;&lt; " = " &lt;&lt; setw(6) &lt;&lt; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/> &lt;&lt; std::right &lt;&lt; " = " &lt;&lt; setw(6) &lt;&lt; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
&lt;&lt; endl; v.push_back(s1.str());
</xsl:for-each> </xsl:for-each>
return s.str(); int n = 0;
for( const auto&amp; e: v )
{
s &lt;&lt; e;
if( (n++)%2 )
s &lt;&lt; std::endl;
}
return std::move(s.str());
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName ) std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName )
...@@ -1038,7 +1052,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId ...@@ -1038,7 +1052,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId
{ {
s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>"; s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>";
if( showLinkName ) s &lt;&lt; "(" &lt;&lt; ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)) &lt;&lt; ")"; if( showLinkName ) s &lt;&lt; "(" &lt;&lt; ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)) &lt;&lt; ")";
return s.str(); return std::move(s.str());
} }
</xsl:for-each> </xsl:for-each>
return ""; return "";
...@@ -1054,7 +1068,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::Object ...@@ -1054,7 +1068,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::Object
s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>"; s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>";
if( showLinkName ) s &lt;&lt; "(" &lt;&lt; ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)) &lt;&lt; ")"; if( showLinkName ) s &lt;&lt; "(" &lt;&lt; ORepHelpers::getShortName( uniset_conf()->oind->getMapName(<xsl:value-of select="@name"/>)) &lt;&lt; ")";
s &lt;&lt; "=" &lt;&lt; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>; s &lt;&lt; "=" &lt;&lt; <xsl:call-template name="setprefix"/><xsl:value-of select="@name"/>;
return s.str(); return std::move(s.str());
} }
</xsl:for-each> </xsl:for-each>
return ""; return "";
...@@ -1319,14 +1333,28 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO() ...@@ -1319,14 +1333,28 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::dumpIO()
ostringstream s; ostringstream s;
s &lt;&lt; myname &lt;&lt; ": " &lt;&lt; endl; s &lt;&lt; myname &lt;&lt; ": " &lt;&lt; endl;
ostringstream s1;
vector&lt;std::string&gt; v;
<xsl:for-each select="//sensors/item/consumers/consumer"> <xsl:for-each select="//sensors/item/consumers/consumer">
<xsl:if test="normalize-space(../../@msg)!='1'"> <xsl:if test="normalize-space(../../@msg)!='1'">
<xsl:if test="normalize-space(@name)=$OID"> <xsl:if test="normalize-space(@name)=$OID">
s &lt;&lt; " " &lt;&lt; strval(<xsl:value-of select="../../@name"/>) &lt;&lt; endl; s1.str("");
s1 &lt;&lt; " " &lt;&lt; strval(<xsl:value-of select="../../@name"/>);
v.push_back(s1.str());
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
return s.str();
int n=0;
for( const auto&amp; e: v )
{
s &lt;&lt; e;
if( (++n)%2 )
s &lt;&lt; endl;
}
return std::move(s.str());
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName ) std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId id, bool showLinkName )
...@@ -1339,7 +1367,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId ...@@ -1339,7 +1367,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::str( UniSetTypes::ObjectId
{ {
s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>"; s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>";
if( showLinkName ) s &lt;&lt; "(<xsl:value-of select="../../@name"/>)"; if( showLinkName ) s &lt;&lt; "(<xsl:value-of select="../../@name"/>)";
return s.str(); return std::move(s.str());
} }
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
...@@ -1358,7 +1386,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::Object ...@@ -1358,7 +1386,7 @@ std::string <xsl:value-of select="$CLASSNAME"/>_SK::strval( UniSetTypes::Object
s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>"; s &lt;&lt; "<xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>";
if( showLinkName ) s &lt;&lt; "(<xsl:value-of select="../../@name"/>)"; if( showLinkName ) s &lt;&lt; "(<xsl:value-of select="../../@name"/>)";
s &lt;&lt; "=" &lt;&lt; <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>; s &lt;&lt; "=" &lt;&lt; <xsl:call-template name="setprefix"/><xsl:value-of select="../../@name"/>;
return s.str(); return std::move(s.str());
} }
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.1 Version: 2.1
Release: alt8 Release: alt8.1
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -456,6 +456,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# .. # ..
%changelog %changelog
* Sun Jun 28 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt8.1
- VMonitor: added output information in the form of two columns
* Sat Jun 20 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt8 * Sat Jun 20 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt8
- release - release
......
...@@ -19,6 +19,7 @@ TestProc::TestProc( UniSetTypes::ObjectId id, xmlNode* confnode ): ...@@ -19,6 +19,7 @@ TestProc::TestProc( UniSetTypes::ObjectId id, xmlNode* confnode ):
lit = loglevels.begin(); lit = loglevels.begin();
out_log_c = (*lit); out_log_c = (*lit);
vmonit(undef);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TestProc::~TestProc() TestProc::~TestProc()
...@@ -34,7 +35,6 @@ TestProc::TestProc(): ...@@ -34,7 +35,6 @@ TestProc::TestProc():
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void TestProc::step() void TestProc::step()
{ {
snap(undef);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void TestProc::sysCommand( const UniSetTypes::SystemMessage* sm ) void TestProc::sysCommand( const UniSetTypes::SystemMessage* sm )
......
...@@ -85,7 +85,7 @@ struct Debug ...@@ -85,7 +85,7 @@ struct Debug
/** A function to convert symbolic string names on debug levels /** A function to convert symbolic string names on debug levels
to their numerical value. to their numerical value.
*/ */
static Debug::type value(string const& val); static Debug::type value(std::string const& val);
/** Display the tags and descriptions of the current debug level /** Display the tags and descriptions of the current debug level
of ds of ds
......
...@@ -118,6 +118,7 @@ class VMonitor ...@@ -118,6 +118,7 @@ class VMonitor
friend std::ostream& operator<<(std::ostream& os, VMonitor& m ); friend std::ostream& operator<<(std::ostream& os, VMonitor& m );
static const int NameWidth = { 30 }; static const int NameWidth = { 30 };
static const int ColCount = { 2 };
std::string str(); std::string str();
std::string pretty_str(); std::string pretty_str();
......
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <vector>
#include <iomanip> #include <iomanip>
#include "VMonitor.h" #include "VMonitor.h"
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -91,26 +92,76 @@ ...@@ -91,26 +92,76 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRET(T) \ #define VMON_IMPL_PRET(T) \
{\ {\
std::vector<std::string> v(m_char.size()+m_unsigned_char.size());\
std::ostringstream s;\
for( const auto& e: m_##T ) \ for( const auto& e: m_##T ) \
os << pretty_str(e.second,e.first) << std::endl;\ {\
s.str("");\
s << pretty_str(e.second,e.first);\
v.push_back(s.str()); \
}\
\
int n = 0;\
for( const auto& e: v ) \
{\
os << e; \
if( (n++)%ColCount ) \
os << std::endl; \
} \
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRET2(T) \ #define VMON_IMPL_PRET2(T) \
{\ {\
std::vector<std::string> v(m_char.size()+m_unsigned_char.size());\
std::ostringstream s;\
for( const auto& e: m_##T ) \ for( const auto& e: m_##T ) \
os << pretty_str(e.second,e.first) << std::endl;\ {\
s.str("");\
s << pretty_str(e.second,e.first);\
v.push_back(s.str());\
}\
\ \
for( const auto& e: m_unsigned_##T ) \ for( const auto& e: m_unsigned_##T ) \
os << pretty_str(e.second,e.first) << std::endl;\ {\
s.str("");\
s << pretty_str(e.second,e.first);\
v.push_back(s.str());\
}\
\
int n = 0;\
for( const auto& e: v ) \
{\
os << e; \
if( (n++)%ColCount ) \
os << std::endl; \
} \
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#define VMON_IMPL_PRET_CHAR \ #define VMON_IMPL_PRET_CHAR \
{\ {\
std::vector<std::string> v(m_char.size()+m_unsigned_char.size());\
std::ostringstream s;\
for( const auto& e: m_char ) \ for( const auto& e: m_char ) \
os << std::right << std::setw(NameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\ {\
s.str("");\
s << std::right << std::setw(NameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first));\
v.push_back(s.str());\
}\
\ \
for( const auto& e: m_unsigned_char ) \ for( const auto& e: m_unsigned_char ) \
os << std::right << std::setw(NameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first)) << std::endl;\ {\
s.str("");\
s << std::right << std::setw(NameWidth) << e.second << std::left << " = " << std::right << std::setw(6) << (int)(*(e.first));\
v.push_back(s.str()); \
}\
\
int n = 0;\
for( const auto& e: v ) \
{\
os << e; \
if( (n++)%ColCount ) \
os << std::endl; \
} \
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
VMON_IMPL_ADD2(int) VMON_IMPL_ADD2(int)
......
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