Commit 01a6fca4 authored by Pavel Vainerman's avatar Pavel Vainerman

(codegen): откорректировал шаблоны main и другие мелкие правки

parent 9e2d72de
...@@ -84,7 +84,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -84,7 +84,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
ui->setValue(idHeartBeat,maxHeartBeat); ui->setValue(idHeartBeat,maxHeartBeat);
ptHeartBeat.reset(); ptHeartBeat.reset();
} }
catch( Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl; ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
......
...@@ -83,7 +83,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -83,7 +83,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
ui->setValue(idHeartBeat,maxHeartBeat); ui->setValue(idHeartBeat,maxHeartBeat);
ptHeartBeat.reset(); ptHeartBeat.reset();
} }
catch( Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl; ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
......
...@@ -87,7 +87,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback() ...@@ -87,7 +87,7 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
ui->setValue(idHeartBeat,maxHeartBeat); ui->setValue(idHeartBeat,maxHeartBeat);
ptHeartBeat.reset(); ptHeartBeat.reset();
} }
catch( Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl; ucrit &lt;&lt; myname &lt;&lt; "(execute): " &lt;&lt; ex &lt;&lt; endl;
} }
......
...@@ -40,11 +40,10 @@ using namespace UniSetTypes; ...@@ -40,11 +40,10 @@ using namespace UniSetTypes;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int main( int argc,char* argv[] ) int main( int argc,char* argv[] )
{ {
if( argc>1 &amp;&amp; !strcmp(argv[1],"--help") ) if( argc>1 &amp;&amp; ( strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0 ) )
{ {
cout &lt;&lt; "--name name - ID процесса. По умолчанию IOController1." &lt;&lt; endl; cout &lt;&lt; "--name name - ID процесса. По умолчанию IOController1." &lt;&lt; endl;
cout &lt;&lt; "--confile fname - Конф. файл. по умолчанию configure.xml" &lt;&lt; endl; cout &lt;&lt; "--confile fname - Конф. файл. по умолчанию configure.xml" &lt;&lt; endl;
cout &lt;&lt; "--logfile fname - выводить логи в файл fname. По умолчанию <xsl:value-of select="$CLASSNAME"/>.log" &lt;&lt; endl;
return 0; return 0;
} }
...@@ -53,7 +52,7 @@ int main( int argc,char* argv[] ) ...@@ -53,7 +52,7 @@ int main( int argc,char* argv[] )
auto conf = uniset_init(argc, argv); auto conf = uniset_init(argc, argv);
// определяем ID объекта // определяем ID объекта
ObjectId ID(DefaultObjectId); ObjectId ID = DefaultObjectId;
string name = conf->getArgParam("--name","<xsl:value-of select="normalize-space($OID)"/>"); string name = conf->getArgParam("--name","<xsl:value-of select="normalize-space($OID)"/>");
if( !name.empty() ) if( !name.empty() )
ID = conf->getObjectID(name); ID = conf->getObjectID(name);
...@@ -66,19 +65,15 @@ int main( int argc,char* argv[] ) ...@@ -66,19 +65,15 @@ int main( int argc,char* argv[] )
return 1; return 1;
} }
<xsl:value-of select="$CLASSNAME"/> obj(ID); auto obj = make_shared&lt;<xsl:value-of select="$CLASSNAME"/>&gt;(ID);
string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log");
string logname( conf->getLogDir() + logfilename );
obj.mylog->logFile( logname.c_str() );
auto act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
act-&gt;add(obj.get_ptr()); act-&gt;add(obj);
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act-&gt;broadcast( sm.transport_msg() ); act-&gt;broadcast( sm.transport_msg() );
act-&gt;run(false); act-&gt;run(false);
pause(); // пауза, чтобы дочерние потоки успели завершить работу return 0;
} }
catch( const Exception&amp; ex ) catch( const Exception&amp; ex )
{ {
...@@ -93,7 +88,7 @@ int main( int argc,char* argv[] ) ...@@ -93,7 +88,7 @@ int main( int argc,char* argv[] )
cerr &lt;&lt; "(main): catch ..." &lt;&lt; endl; cerr &lt;&lt; "(main): catch ..." &lt;&lt; endl;
} }
return 0; return 1;
} }
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>
...@@ -42,11 +42,10 @@ using namespace UniSetTypes; ...@@ -42,11 +42,10 @@ using namespace UniSetTypes;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int main( int argc, const char** argv ) int main( int argc, const char** argv )
{ {
if( argc>1 &amp;&amp; strcmp(argv[1],"--help")==0 ) if( argc>1 &amp;&amp; (strcmp(argv[1],"--help")==0 || strcmp(argv[1],"-h")==0) )
{ {
cout &lt;&lt; "--name name - ID процесса. По умолчанию <xsl:value-of select="$CLASSNAME"/>." &lt;&lt; endl; cout &lt;&lt; "--name name - ID процесса. По умолчанию <xsl:value-of select="$CLASSNAME"/>." &lt;&lt; endl;
cout &lt;&lt; "--confile fname - Конф. файл. по умолчанию configure.xml" &lt;&lt; endl; cout &lt;&lt; "--confile fname - Конф. файл. по умолчанию configure.xml" &lt;&lt; endl;
cout &lt;&lt; "--logfile fname - выводить логи в файл fname. По умолчанию <xsl:value-of select="$CLASSNAME"/>.log" &lt;&lt; endl;
return 0; return 0;
} }
...@@ -58,7 +57,7 @@ int main( int argc, const char** argv ) ...@@ -58,7 +57,7 @@ int main( int argc, const char** argv )
</xsl:if> </xsl:if>
<xsl:if test="normalize-space(//@OID)=''"> <xsl:if test="normalize-space(//@OID)=''">
// определяем ID объекта // определяем ID объекта
ObjectId ID(DefaultObjectId); ObjectId ID = DefaultObjectId;
string name = conf->getArgParam("--name","<xsl:value-of select="$CLASSNAME"/>"); string name = conf->getArgParam("--name","<xsl:value-of select="$CLASSNAME"/>");
if( !name.empty() ) if( !name.empty() )
{ {
...@@ -71,11 +70,8 @@ int main( int argc, const char** argv ) ...@@ -71,11 +70,8 @@ int main( int argc, const char** argv )
return 0; return 0;
} }
} }
auto obj = make_shared&lt;<xsl:value-of select="$CLASSNAME"/>&gt;(ID);
string logfilename = conf->getArgParam("--logfile","<xsl:value-of select="$CLASSNAME"/>.log"); auto obj = make_shared&lt;<xsl:value-of select="$CLASSNAME"/>&gt;(ID);
string logname( conf->getLogDir() + logfilename );
obj->mylog->logFile( logname.c_str() );
</xsl:if> </xsl:if>
auto act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
......
#include <sstream> #include <sstream>
#include <memory>
#include <UniSetActivator.h> #include <UniSetActivator.h>
#include "Skel.h" #include "Skel.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -11,30 +12,27 @@ int main( int argc, const char** argv ) ...@@ -11,30 +12,27 @@ int main( int argc, const char** argv )
{ {
auto conf = uniset_init(argc, argv); auto conf = uniset_init(argc, argv);
string logfilename = conf->getArgParam("--logfile", "Skel.log");
string logname( conf->getLogDir() + logfilename );
ulog.logFile( logname.c_str() );
auto act = UniSetActivator::Instance();
xmlNode* cnode = conf->getNode("Skel"); xmlNode* cnode = conf->getNode("Skel");
if( cnode == NULL ) if( cnode == NULL )
{ {
dlog.crit() << "(Skel): not found <Skel> in conffile" << endl; cerr << "(Skel): not found <Skel> in conffile" << endl;
return 1; return 1;
} }
Skel o("Skel", cnode); auto o = make_shared<Skel>("Skel", cnode);
act.add(o.get_ptr());
auto act = UniSetActivator::Instance();
act->add(o);
SystemMessage sm(SystemMessage::StartUp); SystemMessage sm(SystemMessage::StartUp);
act.broadcast( sm.transport_msg() ); act->broadcast( sm.transport_msg() );
ulogany << "\n\n\n"; ulogany << "\n\n\n";
ulogany << "(Skel::main): -------------- Skel START -------------------------\n\n"; ulogany << "(Skel::main): -------------- Skel START -------------------------\n\n";
dlogany << "\n\n\n"; dlogany << "\n\n\n";
dlogany << "(Skel::main): -------------- Skel START -------------------------\n\n"; dlogany << "(Skel::main): -------------- Skel START -------------------------\n\n";
act->run(false); act->run(false);
return 0;
} }
catch( const std::exception& ex ) catch( const std::exception& ex )
{ {
...@@ -45,6 +43,6 @@ int main( int argc, const char** argv ) ...@@ -45,6 +43,6 @@ int main( int argc, const char** argv )
cerr << "(Skel::main): catch(...)" << endl; cerr << "(Skel::main): catch(...)" << endl;
} }
return 0; return 1;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -14,10 +14,10 @@ class Skel: ...@@ -14,10 +14,10 @@ class Skel:
protected: protected:
Skel(); Skel();
virtual void step(); virtual void step() override;
virtual void sensorInfo( UniSetTypes::SensorMessage* sm ); virtual void sensorInfo( const UniSetTypes::SensorMessage* sm ) override;
virtual void timerInfo( UniSetTypes::TimerMessage* tm ); virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ); virtual void askSensors( UniversalIO::UIOCommand cmd ) override;
private: private:
}; };
......
...@@ -27,6 +27,7 @@ void TestGen::step() ...@@ -27,6 +27,7 @@ void TestGen::step()
cout << dumpIO() << endl; cout << dumpIO() << endl;
myinfo << str(input2_s) << endl; myinfo << str(input2_s) << endl;
ulog()->info() << "ulog: " << str(input2_s) << endl;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void TestGen::sensorInfo( const SensorMessage* sm ) void TestGen::sensorInfo( const SensorMessage* sm )
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
ulimit -Sc 1000000 ulimit -Sc 1000000
uniset2-start.sh -f ./test --name TestProc --confile test.xml --ulog-add-levels info,crit,warn,level1,level8 \ uniset2-start.sh -f ./test --name TestProc --confile test.xml --ulog-add-levels warn,crit \
--sm-ready-timeout 5000 --test-run-logserver --test-log-add-levels any --sm-ready-timeout 5000 --test-run-logserver --test-log-add-levels any
#info,warn,crit,system,level9 > 1.log #info,warn,crit,system,level9 > 1.log
#--c-filter-field cfilter --c-filter-value test1 --s-filter-field io --s-filter-value 1 #--c-filter-field cfilter --c-filter-value test1 --s-filter-field io --s-filter-value 1
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
t_check_s="Threshold1_S" t_check_s="Threshold1_S"
log_c="LogLevel_S" log_c="LogLevel_S"
log_s="LogLevel_S" log_s="LogLevel_S"
input1_s="Input5_S"
input2_s="Input6_S"
output2_c="DO2_C"
/> />
<IOControl name="IOControl"/> <IOControl name="IOControl"/>
......
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