Commit f30f6903 authored by Pavel Vaynerman's avatar Pavel Vaynerman

add heartbeat logic to uniset-codegen

parent 13e883c4
......@@ -71,9 +71,16 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
//
step();
// ""
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.saveValue(idHeartBeat,maxHeartBeat,UniversalIO::AnalogInput);
ptHeartBeat.reset();
}
//
updateOutputs(false);
updatePreviousValues();
updatePreviousValues();
}
catch( Exception&amp; ex )
{
......
......@@ -73,6 +73,13 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
//
step();
// ""
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.saveValue(idHeartBeat,maxHeartBeat,UniversalIO::AnalogInput);
ptHeartBeat.reset();
}
//
updateOutputs(false);
......
......@@ -70,6 +70,13 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
//
step();
// ""
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.saveValue(idHeartBeat,maxHeartBeat,UniversalIO::AnalogInput);
ptHeartBeat.reset();
}
//
updateOutputs(false);
updatePreviousValues();
......
......@@ -57,7 +57,6 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
//
checkTimers(this);
if( resetMsgTime&gt;0 &amp;&amp; trResetMsg.hi(ptResetMsg.checkTime()) )
{
// cout &lt;&lt; myname &lt;&lt; ": ********* reset messages *********" &lt;&lt; endl;
......@@ -74,7 +73,14 @@ void <xsl:value-of select="$CLASSNAME"/>_SK::callback()
//
step();
// ""
if( idHeartBeat!=DefaultObjectId &amp;&amp; ptHeartBeat.checkTime() )
{
ui.saveValue(idHeartBeat,maxHeartBeat,UniversalIO::AnalogInput);
ptHeartBeat.reset();
}
//
updateOutputs(false);
......
......@@ -203,6 +203,11 @@
UniSetTypes::ObjectId idLocalTestMode_S; /*!&lt; ( ) */
bool in_TestMode_S;
bool in_LocalTestMode_S;
// ""
PassiveTimer ptHeartBeat; /*! &lt; "" */
UniSetTypes::ObjectId idHeartBeat; /*! &lt; (AI) "" */
int maxHeartBeat; /*! &lt; */
xmlNode* confnode;
/*! . confnode */
......@@ -445,6 +450,8 @@ active(false),
isTestMode(false),
idTestMode_S(DefaultObjectId),
idLocalTestMode_S(DefaultObjectId),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(0),
smReadyTimeout(0),
activated(false)
......@@ -472,6 +479,8 @@ idTestMode_S(conf->getSensorID("TestMode_S")),
idLocalTestMode_S(conf->getSensorID(conf->getProp(cnode,"LocalTestMode_S"))),
in_TestMode_S(false),
in_LocalTestMode_S(false),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(cnode),
smReadyTimeout(0),
activated(false)
......@@ -498,6 +507,27 @@ activated(false)
}
</xsl:for-each>
UniXML_iterator it(cnode);
string heart = conf->getArgParam("--heartbeat-id",it.getProp("heartbeat_id"));
if( !heart.empty() )
{
idHeartBeat = conf->getSensorID(heart);
if( idHeartBeat == DefaultObjectId )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; ": 'HeartBeat' " &lt;&lt; heart;
throw SystemError(err.str());
}
int heartbeatTime = conf->getArgPInt("--heartbeat-time",it.getProp("heartbeatTime"), 5000);
if( heartbeatTime>0 )
ptHeartBeat.setTiming(heartbeatTime);
else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime);
maxHeartBeat = conf->getArgPInt("--heartbeat-max",it.getProp("heartbeat_max"), 10);
}
//
<xsl:for-each select="//smap/item">
<xsl:if test="normalize-space(@default)=''">
......@@ -666,6 +696,8 @@ active(false),
isTestMode(false),
idTestMode_S(DefaultObjectId),
idLocalTestMode_S(DefaultObjectId),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(0),
activated(false)
{
......@@ -695,6 +727,8 @@ idTestMode_S(conf->getSensorID("TestMode_S")),
idLocalTestMode_S(conf->getSensorID(conf->getProp(cnode,"LocalTestMode_S"))),
in_TestMode_S(false),
in_LocalTestMode_S(false),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
confnode(cnode),
activated(false)
{
......@@ -706,6 +740,29 @@ activated(false)
</xsl:call-template>
</xsl:for-each>
UniXML_iterator it(cnode);
string heart = conf->getArgParam("--heartbeat-id",it.getProp("heartbeat_id"));
if( !heart.empty() )
{
idHeartBeat = conf->getSensorID(heart);
if( idHeartBeat == DefaultObjectId )
{
ostringstream err;
err &lt;&lt; myname &lt;&lt; ": 'HeartBeat' " &lt;&lt; heart;
throw SystemError(err.str());
}
int heartbeatTime = conf->getArgPInt("--heartbeat-time",it.getProp("heartbeatTime"), 5000);
if( heartbeatTime>0 )
ptHeartBeat.setTiming(heartbeatTime);
else
ptHeartBeat.setTiming(UniSetTimer::WaitUpTime);
maxHeartBeat = conf->getArgPInt("--heartbeat-max",it.getProp("heartbeat_max"), 10);
}
sleep_msec = conf->getArgPInt("--sleep-msec","<xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>", <xsl:call-template name="settings-alone"><xsl:with-param name="varname" select="'sleep-msec'"/></xsl:call-template>);
resetMsgTime = conf->getPIntProp(cnode,"resetMsgTime", 0);
......
noinst_PROGRAMS = test
noinst_PROGRAMS = test
#test2
test_LDADD = $(top_builddir)/lib/libUniSet.la
test_CXXFLAGS = -I$(top_builddir)/include
test_SOURCES = TestGen_SK.cc TestGen.cc TestGen-main.cc
GENERATED=TestGen_SK.h TestGen_SK.cc TestGen-main.cc
test2_LDADD = $(top_builddir)/lib/libUniSet.la
test2_CXXFLAGS = -I$(top_builddir)/include
test2_SOURCES = TestGenAlone_SK.cc TestGenAlone.cc TestGenAlone-main.cc
GENERATED=TestGen_SK.h TestGen_SK.cc TestGen-main.cc
GENERATED2=TestGenAlone_SK.h TestGenAlone_SK.cc TestGenAlone-main.cc
$(GENERATED): ../@PACKAGE@-codegen testgen.src.xml ../*.xsl
@UNISET_CODEGEN@ --local-include -l --ask -n TestGen testgen.src.xml
$(GENERATED2): ../@PACKAGE@-codegen testgen-alone.src.xml ../*.xsl
@UNISET_CODEGEN@ --local-include -l --ask --alone -n TestGenAlone testgen-alone.src.xml
clean-local:
rm -rf $(GENERATED)
rm -rf $(GENERATED) $(GENERATED2)
#all-local: $(GENERATED)
#
// $Id$
#include "Exceptions.h"
#include "TestGenAlone.h"
// -----------------------------------------------------------------------------
using namespace std;
using namespace UniSetTypes;
// -----------------------------------------------------------------------------
TestGenAlone::TestGenAlone( UniSetTypes::ObjectId id, xmlNode* confnode ):
TestGenAlone_SK( id, confnode )
{
}
// -----------------------------------------------------------------------------
TestGenAlone::~TestGenAlone()
{
}
// -----------------------------------------------------------------------------
TestGenAlone::TestGenAlone()
{
cerr << ": init failed!!!!!!!!!!!!!!!"<< endl;
throw Exception();
}
// -----------------------------------------------------------------------------
void TestGenAlone::step()
{
cout << "input2 state=" << in_input2_s << endl;
}
// -----------------------------------------------------------------------------
void TestGenAlone::sensorInfo( SensorMessage *sm )
{
if( sm->id == input1_s )
out_output1_c = in_input1_s; // sm->state
}
// -----------------------------------------------------------------------------
void TestGenAlone::timerInfo( TimerMessage *tm )
{
}
// -----------------------------------------------------------------------------
void TestGenAlone::sigterm( int signo )
{
TestGenAlone_SK::sigterm(signo);
}
// -----------------------------------------------------------------------------
// $Id$
// -----------------------------------------------------------------------------
#ifndef TestGenAlone_H_
#define TestGenAlone_H_
// -----------------------------------------------------------------------------
#include "TestGenAlone_SK.h"
// -----------------------------------------------------------------------------
class TestGenAlone:
public TestGenAlone_SK
{
public:
TestGenAlone( UniSetTypes::ObjectId id, xmlNode* confnode = UniSetTypes::conf->getNode("TestGenAlone") );
virtual ~TestGenAlone();
protected:
TestGenAlone();
virtual void step();
void sensorInfo( UniSetTypes::SensorMessage *sm );
void timerInfo( UniSetTypes::TimerMessage *tm );
virtual void sigterm( int signo );
private:
};
// -----------------------------------------------------------------------------
#endif // TestGenAlone_H_
// -----------------------------------------------------------------------------
<?xml version="1.0" encoding="koi8-r"?>
<!--
name -
msgcount -
sleep_msec -
type
====
in - ( )
out - ()
io -
-->
<GlobalConfigure>
<settings>
<TestGenAlone>
<set name="ID" val="TestGenAlone"/>
<set name="class-name" val="TestGenAlone"/>
<set name="msg-count" val="20"/>
<set name="sleep-msec" val="150"/>
</TestGenAlone>
</settings>
<ObjectsMap idfromfile="1" no_dep="0">
<sensors>
<item id="1" name="input1_s" iotype="DI" textname="xxx">
<consumers>
<consumer name="TestGenAlone" vartype="in" type="objects"/>
</consumers>
</item>
<item id="23" name="input2_s" iotype="DI" textname="xxx">
<consumers>
<consumer name="TestGenAlone" vartype="in" type="objects"/>
</consumers>
</item>
<item id="31" name="output1_c" iotype="DO" textname="xxx">
<consumers>
<consumer name="TestGenAlone" vartype="out" type="objects"/>
</consumers>
</item>
</sensors>
<messages>
</messages>
<objects>
<item id="2000" name="TestGenAlone" />
</objects>
</ObjectsMap>
</GlobalConfigure>
\ No newline at end of file
......@@ -10,7 +10,7 @@
out - ()
io -
-->
<QG>
<Test>
<settings>
<set name="class-name" val="TestGen"/>
<set name="msg-count" val="20"/>
......@@ -27,4 +27,4 @@
<!-- name - . -->
<item name="mid_Message1" comment="comment for Message 1" />
</msgmap>
</QG>
</Test>
......@@ -3,7 +3,7 @@
Name: libuniset
Version: 0.97
Release: eter12
Release: eter13
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
......@@ -178,6 +178,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Sat Sep 26 2009 Pavel Vainerman <pv@etersoft.ru> 0.97-eter12
- minor fixes in IONotifyController
* Fri Sep 25 2009 Pavel Vainerman <pv@altlinux.ru> 0.97-eter11
- return old mutex
......
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