1 Star 0 Fork 0

evan_xia_mew/RTSystem-alarm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Door.cpp 10.74 KB
一键复制 编辑 原始数据 按行查看 历史
evan_xia_mew 提交于 2022-01-02 14:33 . 4805
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
// {{{RME classifier 'Logical View::Door'
#if defined( PRAGMA ) && ! defined( PRAGMA_IMPLEMENTED )
#pragma implementation "Door.h"
#endif
#include <RTSystem/TestComponent.h>
#include <Door.h>
#include <DeviceInfo.h>
// {{{RME tool 'OT::Cpp' property 'ImplementationPreface'
// {{{USR
// }}}USR
// }}}RME
static const RTRelayDescriptor rtg_relays[] =
{
{
"DoorPort"
, &DoorProtocol::Conjugate::rt_class
, 1 // cardinality
}
, {
"DoorTestPort"
, &DoorTest::Base::rt_class
, 1 // cardinality
}
};
static RTActor * new_Door_Actor( RTController * _rts, RTActorRef * _ref )
{
return new Door_Actor( _rts, _ref );
}
const RTActorClass Door =
{
(const RTActorClass *)0
, "Door"
, (RTVersionId)0
, 2
, rtg_relays
, new_Door_Actor
};
static const char * const rtg_state_names[] =
{
"TOP"
, "doorLocked"
, "doorUnlocked"
, "doorOpen"
, "doorHeld"
};
#define SUPER RTActor
Door_Actor::Door_Actor( RTController * rtg_rts, RTActorRef * rtg_ref )
: RTActor( rtg_rts, rtg_ref )
{
}
Door_Actor::~Door_Actor( void )
{
}
int Door_Actor::_followInV( RTBindingEnd & rtg_end, int rtg_portId, int rtg_repIndex )
{
switch( rtg_portId )
{
case 0:
// DoorPort
if( rtg_repIndex < 1 )
{
rtg_end.port = &DoorPort;
rtg_end.index = rtg_repIndex;
return 1;
}
break;
case 1:
// DoorTestPort
if( rtg_repIndex < 1 )
{
rtg_end.port = &DoorTestPort;
rtg_end.index = rtg_repIndex;
return 1;
}
break;
default:
break;
}
return RTActor::_followInV( rtg_end, rtg_portId, rtg_repIndex );
}
// {{{RME transition ':TOP:doorLocked:J58B88C4101A6:unlock'
INLINE_METHODS void Door_Actor::transition2_unlock( const void * rtdata, DoorProtocol::Conjugate * rtport )
{
// {{{USR
log.log("Door unlocked");
RTTimespec thirtySeconds (10, 0);
DoorTimer = timer.informIn(thirtySeconds);
// }}}USR
}
// }}}RME
// {{{RME transition ':TOP:doorUnlocked:J58B88C470239:timeout'
INLINE_METHODS void Door_Actor::transition3_timeout( const void * rtdata, Timing::Base * rtport )
{
// {{{USR
log.log("Door locked due to timeout");
DoorPort.doorClosed().send();
// }}}USR
}
// }}}RME
// {{{RME transition ':TOP:doorUnlocked:J58B9B9F7025C:open'
INLINE_METHODS void Door_Actor::transition4_open( const void * rtdata, DoorTest::Base * rtport )
{
// {{{USR
timer.cancelTimer(DoorTimer);
RTTimespec oneMinute (10, 0);
DoorTimer = timer.informIn(oneMinute);
DoorPort.doorOpen().send();
// }}}USR
}
// }}}RME
// {{{RME transition ':TOP:doorOpen:J58B9B9FE0202:close'
INLINE_METHODS void Door_Actor::transition5_close( const void * rtdata, DoorTest::Base * rtport )
{
// {{{USR
timer.cancelTimer(DoorTimer);
DoorPort.doorClosed().send();
// }}}USR
}
// }}}RME
// {{{RME transition ':TOP:doorOpen:J58D9860D00C2:doorHeld1min'
INLINE_METHODS void Door_Actor::transition6_doorHeld1min( const void * rtdata, Timing::Base * rtport )
{
// {{{USR
RTTimespec fourMinutes (10, 0);
DoorTimer = timer.informIn(fourMinutes);
DoorPort.doorHeld1().send();
// }}}USR
}
// }}}RME
// {{{RME transition ':TOP:doorHeld:J58D9865302AC:doorHeld5min'
INLINE_METHODS void Door_Actor::transition7_doorHeld5min( const void * rtdata, Timing::Base * rtport )
{
// {{{USR
DoorPort.doorHeld5().send();
// }}}USR
}
// }}}RME
// {{{RME transition ':TOP:doorHeld:J58D98688021D:close'
INLINE_METHODS void Door_Actor::transition8_close( const void * rtdata, DoorTest::Base * rtport )
{
// {{{USR
timer.cancelTimer(DoorTimer);
DoorPort.doorClosed().send();
// }}}USR
}
// }}}RME
INLINE_CHAINS void Door_Actor::chain1_Initial( void )
{
// transition ':TOP:Initial:Initial'
rtgChainBegin( 1, "Initial" );
rtgTransitionBegin();
rtgTransitionEnd();
enterState( 2 );
}
INLINE_CHAINS void Door_Actor::chain2_unlock( void )
{
// transition ':TOP:doorLocked:J58B88C4101A6:unlock'
rtgChainBegin( 2, "unlock" );
exitState( rtg_parent_state );
rtgTransitionBegin();
transition2_unlock( msg->data, (DoorProtocol::Conjugate *)msg->sap() );
rtgTransitionEnd();
enterState( 3 );
}
INLINE_CHAINS void Door_Actor::chain3_timeout( void )
{
// transition ':TOP:doorUnlocked:J58B88C470239:timeout'
rtgChainBegin( 3, "timeout" );
exitState( rtg_parent_state );
rtgTransitionBegin();
transition3_timeout( msg->data, (Timing::Base *)msg->sap() );
rtgTransitionEnd();
enterState( 2 );
}
INLINE_CHAINS void Door_Actor::chain4_open( void )
{
// transition ':TOP:doorUnlocked:J58B9B9F7025C:open'
rtgChainBegin( 3, "open" );
exitState( rtg_parent_state );
rtgTransitionBegin();
transition4_open( msg->data, (DoorTest::Base *)msg->sap() );
rtgTransitionEnd();
enterState( 4 );
}
INLINE_CHAINS void Door_Actor::chain6_doorHeld1min( void )
{
// transition ':TOP:doorOpen:J58D9860D00C2:doorHeld1min'
rtgChainBegin( 4, "doorHeld1min" );
exitState( rtg_parent_state );
rtgTransitionBegin();
transition6_doorHeld1min( msg->data, (Timing::Base *)msg->sap() );
rtgTransitionEnd();
enterState( 5 );
}
INLINE_CHAINS void Door_Actor::chain5_close( void )
{
// transition ':TOP:doorOpen:J58B9B9FE0202:close'
rtgChainBegin( 4, "close" );
exitState( rtg_parent_state );
rtgTransitionBegin();
transition5_close( msg->data, (DoorTest::Base *)msg->sap() );
rtgTransitionEnd();
enterState( 2 );
}
INLINE_CHAINS void Door_Actor::chain7_doorHeld5min( void )
{
// transition ':TOP:doorHeld:J58D9865302AC:doorHeld5min'
rtgChainBegin( 5, "doorHeld5min" );
exitState( rtg_parent_state );
rtgTransitionBegin();
transition7_doorHeld5min( msg->data, (Timing::Base *)msg->sap() );
rtgTransitionEnd();
enterState( 2 );
}
INLINE_CHAINS void Door_Actor::chain8_close( void )
{
// transition ':TOP:doorHeld:J58D98688021D:close'
rtgChainBegin( 5, "close" );
exitState( rtg_parent_state );
rtgTransitionBegin();
transition8_close( msg->data, (DoorTest::Base *)msg->sap() );
rtgTransitionEnd();
enterState( 2 );
}
void Door_Actor::rtsBehavior( int signalIndex, int portIndex )
{
for( int stateIndex = getCurrentState(); ; stateIndex = rtg_parent_state[ stateIndex - 1 ] )
switch( stateIndex )
{
case 1:
// {{{RME state ':TOP'
switch( portIndex )
{
case 0:
switch( signalIndex )
{
case 1:
chain1_Initial();
return;
default:
break;
}
break;
default:
break;
}
unexpectedMessage();
return;
// }}}RME
case 2:
// {{{RME state ':TOP:doorLocked'
switch( portIndex )
{
case 0:
switch( signalIndex )
{
case 1:
return;
default:
break;
}
break;
case 1:
// {{{RME port 'DoorPort'
switch( signalIndex )
{
case DoorProtocol::Conjugate::rti_doorUnlock:
chain2_unlock();
return;
default:
break;
}
break;
// }}}RME
default:
break;
}
break;
// }}}RME
case 3:
// {{{RME state ':TOP:doorUnlocked'
switch( portIndex )
{
case 0:
switch( signalIndex )
{
case 1:
return;
default:
break;
}
break;
case 3:
// {{{RME port 'timer'
switch( signalIndex )
{
case Timing::Base::rti_timeout:
chain3_timeout();
return;
default:
break;
}
break;
// }}}RME
case 4:
// {{{RME port 'DoorTestPort'
switch( signalIndex )
{
case DoorTest::Base::rti_doorOpen:
chain4_open();
return;
default:
break;
}
break;
// }}}RME
default:
break;
}
break;
// }}}RME
case 4:
// {{{RME state ':TOP:doorOpen'
switch( portIndex )
{
case 0:
switch( signalIndex )
{
case 1:
return;
default:
break;
}
break;
case 3:
// {{{RME port 'timer'
switch( signalIndex )
{
case Timing::Base::rti_timeout:
chain6_doorHeld1min();
return;
default:
break;
}
break;
// }}}RME
case 4:
// {{{RME port 'DoorTestPort'
switch( signalIndex )
{
case DoorTest::Base::rti_doorClose:
chain5_close();
return;
default:
break;
}
break;
// }}}RME
default:
break;
}
break;
// }}}RME
case 5:
// {{{RME state ':TOP:doorHeld'
switch( portIndex )
{
case 0:
switch( signalIndex )
{
case 1:
return;
default:
break;
}
break;
case 3:
// {{{RME port 'timer'
switch( signalIndex )
{
case Timing::Base::rti_timeout:
chain7_doorHeld5min();
return;
default:
break;
}
break;
// }}}RME
case 4:
// {{{RME port 'DoorTestPort'
switch( signalIndex )
{
case DoorTest::Base::rti_doorClose:
chain8_close();
return;
default:
break;
}
break;
// }}}RME
default:
break;
}
break;
// }}}RME
default:
unexpectedState();
return;
}
}
const RTActor_class * Door_Actor::getActorData( void ) const
{
return &Door_Actor::rtg_class;
}
const RTActor_class Door_Actor::rtg_class =
{
(const RTActor_class *)0
, rtg_state_names
, 5
, Door_Actor::rtg_parent_state
, &Door
, 0
, (const RTComponentDescriptor *)0
, 4
, Door_Actor::rtg_ports
, 0
, (const RTLocalBindingDescriptor *)0
, 1
, Door_Actor::rtg_Door_fields
};
const RTStateId Door_Actor::rtg_parent_state[] =
{
0
, 1
, 1
, 1
, 1
};
const RTPortDescriptor Door_Actor::rtg_ports[] =
{
{
"DoorPort"
, (const char *)0
, &DoorProtocol::Conjugate::rt_class
, RTOffsetOf( Door_Actor, Door_Actor::DoorPort )
, 1 // cardinality
, 1
, RTPortDescriptor::KindWired + RTPortDescriptor::NotificationDisabled + RTPortDescriptor::RegisterNotPermitted + RTPortDescriptor::VisibilityPublic
}
, {
"log"
, (const char *)0
, &Log::Base::rt_class
, RTOffsetOf( Door_Actor, Door_Actor::log )
, 1 // cardinality
, 2
, RTPortDescriptor::KindSpecial + RTPortDescriptor::NotificationDisabled + RTPortDescriptor::RegisterNotPermitted + RTPortDescriptor::VisibilityProtected
}
, {
"timer"
, (const char *)0
, &Timing::Base::rt_class
, RTOffsetOf( Door_Actor, Door_Actor::timer )
, 1 // cardinality
, 3
, RTPortDescriptor::KindSpecial + RTPortDescriptor::NotificationDisabled + RTPortDescriptor::RegisterNotPermitted + RTPortDescriptor::VisibilityProtected
}
, {
"DoorTestPort"
, (const char *)0
, &DoorTest::Base::rt_class
, RTOffsetOf( Door_Actor, Door_Actor::DoorTestPort )
, 1 // cardinality
, 4
, RTPortDescriptor::KindWired + RTPortDescriptor::NotificationDisabled + RTPortDescriptor::RegisterNotPermitted + RTPortDescriptor::VisibilityPublic
}
};
const RTFieldDescriptor Door_Actor::rtg_Door_fields[] =
{
// {{{RME classAttribute 'DoorTimer'
{
"DoorTimer"
, RTOffsetOf( Door_Actor, DoorTimer )
// {{{RME tool 'OT::CppTargetRTS' property 'TypeDescriptor'
, (const RTObject_class *)0
// }}}RME
// {{{RME tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'
, (const RTTypeModifier *)0
// }}}RME
}
// }}}RME
};
#undef SUPER
// {{{RME tool 'OT::Cpp' property 'ImplementationEnding'
// {{{USR
// }}}USR
// }}}RME
// }}}RME
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/evan-xia-mew/rtsystem-alarm.git
git@gitee.com:evan-xia-mew/rtsystem-alarm.git
evan-xia-mew
rtsystem-alarm
RTSystem-alarm
master

搜索帮助