⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coffeemachine_tester.cpp

📁 含有uml的多个实例及实例的java源码。
💻 CPP
字号:
// {{{RME classifier 'Logical View::TestHarnesses::CoffeeMachine_Tester'#if defined( PRAGMA ) && ! defined( PRAGMA_IMPLEMENTED )#pragma implementation "rtg/CoffeeMachine_Tester.h"#endif#include <RTSystem/AutoTestMarkI_x86VisualCpp60.h>#include <rtg/CoffeeMachine_Tester.h>#include <rtg/Boiler.h>#include <rtg/BrewButton.h>#include <rtg/IndicatorLight.h>#include <rtg/ReliefValve.h>#include <rtg/TestCaseDescriptor.h>#include <rtg/Warmer.h>extern const RTActorClass MarkI_Container;extern const RTActorClass MarkI_TestContainer;// {{{RME tool 'OT::Cpp' property 'ImplementationPreface'// {{{USR// }}}USR// }}}RMEstatic RTActor * new_CoffeeMachine_Tester_Actor( RTController * _rts, RTActorRef * _ref ){	return new CoffeeMachine_Tester_Actor( _rts, _ref );}const RTActorClass CoffeeMachine_Tester ={	(const RTActorClass *)0  , "CoffeeMachine_Tester"  , (RTVersionId)0  , 0  , (const RTRelayDescriptor *)0  , new_CoffeeMachine_Tester_Actor};static const char * const rtg_state_names[] ={	"TOP"  , "Testing"  , "Done"  , "Finished_all_tests"};static const RTInterfaceDescriptor rtg_interfaces_testContainers[] ={	{		"reliefValve"	  , 1	}  , {		"boiler"	  , 1	}  , {		"brewButton"	  , 1	}  , {		"warmer"	  , 1	}  , {		"indicatorLight"	  , 1	}  , {		"testResults"	  , 1	}};static const RTBindingDescriptor rtg_bindings_testContainers[] ={	{		0	  , &ReliefValve::Conjugate::rt_class	}  , {		1	  , &Boiler::Conjugate::rt_class	}  , {		2	  , &BrewButton::Conjugate::rt_class	}  , {		3	  , &Warmer::Conjugate::rt_class	}  , {		4	  , &IndicatorLight::Conjugate::rt_class	}  , {		5	  , &TestResults::Conjugate::rt_class	}};static const RTInterfaceDescriptor rtg_interfaces_cuContainer[] ={	{		"reliefValve"	  , 1	}  , {		"indicatorLight"	  , 1	}  , {		"boiler"	  , 1	}  , {		"brewButton"	  , 1	}  , {		"warmer"	  , 1	}};static const RTBindingDescriptor rtg_bindings_cuContainer[] ={	{		0	  , &ReliefValve::Base::rt_class	}  , {		1	  , &IndicatorLight::Base::rt_class	}  , {		2	  , &Boiler::Base::rt_class	}  , {		3	  , &BrewButton::Base::rt_class	}  , {		4	  , &Warmer::Base::rt_class	}};#define SUPER RTActorCoffeeMachine_Tester_Actor::CoffeeMachine_Tester_Actor( RTController * rtg_rts, RTActorRef * rtg_ref )	: RTActor( rtg_rts, rtg_ref )	, current_test( 0 )	, test_cases( (TestCaseDescriptor *) 0 )	, num_tests( 0 ){}CoffeeMachine_Tester_Actor::~CoffeeMachine_Tester_Actor( void ){}// {{{RME operation 'InitializeTests()'void CoffeeMachine_Tester_Actor::InitializeTests( void ){	// {{{USR	// }}}USR}// }}}RMEint CoffeeMachine_Tester_Actor::_followOutV( RTBindingEnd & rtg_end, int rtg_compId, int rtg_portId, int rtg_repIndex ){	switch( rtg_compId )	{	case 1:		// testContainers		switch( rtg_portId )		{		case 0:			// reliefValve			if( rtg_repIndex < 1 )			{				// cuContainer/reliefValve				return cuContainer._followIn( rtg_end, 0, rtg_repIndex );			}			break;		case 1:			// boiler			if( rtg_repIndex < 1 )			{				// cuContainer/boiler				return cuContainer._followIn( rtg_end, 2, rtg_repIndex );			}			break;		case 2:			// brewButton			if( rtg_repIndex < 1 )			{				// cuContainer/brewButton				return cuContainer._followIn( rtg_end, 3, rtg_repIndex );			}			break;		case 3:			// warmer			if( rtg_repIndex < 1 )			{				// cuContainer/warmer				return cuContainer._followIn( rtg_end, 4, rtg_repIndex );			}			break;		case 4:			// indicatorLight			if( rtg_repIndex < 1 )			{				// cuContainer/indicatorLight				return cuContainer._followIn( rtg_end, 1, rtg_repIndex );			}			break;		case 5:			// testResults			if( rtg_repIndex < 1 )			{				// testResults				rtg_end.port = &testResults;				rtg_end.index = rtg_repIndex;				return 1;			}			break;		default:			break;		}	case 2:		// cuContainer		switch( rtg_portId )		{		case 0:			// reliefValve			if( rtg_repIndex < 1 )			{				// testContainers/reliefValve				return testContainers._followIn( rtg_end, 0, rtg_repIndex );			}			break;		case 1:			// indicatorLight			if( rtg_repIndex < 1 )			{				// testContainers/indicatorLight				return testContainers._followIn( rtg_end, 4, rtg_repIndex );			}			break;		case 2:			// boiler			if( rtg_repIndex < 1 )			{				// testContainers/boiler				return testContainers._followIn( rtg_end, 1, rtg_repIndex );			}			break;		case 3:			// brewButton			if( rtg_repIndex < 1 )			{				// testContainers/brewButton				return testContainers._followIn( rtg_end, 2, rtg_repIndex );			}			break;		case 4:			// warmer			if( rtg_repIndex < 1 )			{				// testContainers/warmer				return testContainers._followIn( rtg_end, 3, rtg_repIndex );			}			break;		default:			break;		}	default:		break;	}	return RTActor::_followOutV( rtg_end, rtg_compId, rtg_portId, rtg_repIndex );}// {{{RME enter ':TOP:Testing'INLINE_METHODS void CoffeeMachine_Tester_Actor::enter2_Testing( void ){	// {{{USR	// Display info regarding current test	log.log("\n===========================================================");	log.show("Test #: ");log.log(current_test);	log.show("Test Description: ");	log.log( test_cases[current_test].name );	log.log("\nScenario:");	// incarnate test and start	frame.incarnate( cuContainer );	frame.incarnate( testContainers, *(test_cases[current_test].test) );	testResults.start().send();	// }}}USR}// }}}RMEvoid CoffeeMachine_Tester_Actor::enterStateV( void ){	switch( getCurrentState() )	{	case 2:		enter2_Testing();		break;	default:		RTActor::enterStateV();		break;	}}// {{{RME transition ':TOP:Initial:Initial'INLINE_METHODS void CoffeeMachine_Tester_Actor::transition1_Initial( const void * rtdata, RTProtocol * rtport ){	// {{{USR	InitializeTests();	// }}}USR}// }}}RME// {{{RME transition ':TOP:Testing:Junction2:Failed_Test'INLINE_METHODS void CoffeeMachine_Tester_Actor::transition2_Failed_Test( const void * rtdata, TestResults::Conjugate * rtport ){	// {{{USR	log.log("Test Status: FAILED");	log.log("\n\n=> Tests stopped!");	frame.destroy( testContainers );	frame.destroy( cuContainer );	// }}}USR}// }}}RME// {{{RME transition ':TOP:Testing:Junction4:Passed_Test'INLINE_METHODS void CoffeeMachine_Tester_Actor::transition3_Passed_Test( const void * rtdata, TestResults::Conjugate * rtport ){	// {{{USR	log.log("\nTest Status: PASSED");	log.log("===========================================================");	current_test++;	frame.destroy( testContainers );	frame.destroy( cuContainer );	// }}}USR}// }}}RME// {{{RME transition ':TOP:Finished_all_tests:True'INLINE_METHODS void CoffeeMachine_Tester_Actor::transition5_True( const void * rtdata, TestResults::Conjugate * rtport ){	// {{{USR	log.log("\n\n=> All tests completed successfully!");	// }}}USR}// }}}RMEINLINE_CHAINS void CoffeeMachine_Tester_Actor::chain1_Initial( void ){	// transition ':TOP:Initial:Initial'	rtgChainBegin( 1, "Initial" );	rtgTransitionBegin();	transition1_Initial( msg->data, msg->sap() );	rtgTransitionEnd();	enterState( 2 );}INLINE_CHAINS void CoffeeMachine_Tester_Actor::chain2_Failed_Test( void ){	// transition ':TOP:Testing:Junction2:Failed_Test'	rtgChainBegin( 2, "Failed_Test" );	exitState( rtg_parent_state );	rtgTransitionBegin();	transition2_Failed_Test( msg->data, (TestResults::Conjugate *)msg->sap() );	rtgTransitionEnd();	enterState( 3 );}INLINE_CHAINS void CoffeeMachine_Tester_Actor::chain3_Passed_Test( void ){	// transition ':TOP:Testing:Junction4:Passed_Test'	rtgChainBegin( 2, "Passed_Test" );	exitState( rtg_parent_state );	rtgTransitionBegin();	transition3_Passed_Test( msg->data, (TestResults::Conjugate *)msg->sap() );	rtgTransitionEnd();	if( choicePoint1_Finished_all_tests( msg->data, (TestResults::Conjugate *)msg->sap() ) )		chain5_True();	else		chain4_False();}// {{{RME choicePoint ':TOP:Finished_all_tests'INLINE_METHODS int CoffeeMachine_Tester_Actor::choicePoint1_Finished_all_tests( const void * rtdata, TestResults::Conjugate * rtport ){	// {{{USR	return( current_test == num_tests );	// }}}USR}// }}}RMEINLINE_CHAINS void CoffeeMachine_Tester_Actor::chain5_True( void ){	// transition ':TOP:Finished_all_tests:True'	rtgChainBegin( 4, "True" );	rtgTransitionBegin();	transition5_True( msg->data, (TestResults::Conjugate *)msg->sap() );	rtgTransitionEnd();	enterState( 3 );}INLINE_CHAINS void CoffeeMachine_Tester_Actor::chain4_False( void ){	// transition ':TOP:Finished_all_tests:False'	rtgChainBegin( 4, "False" );	rtgTransitionBegin();	rtgTransitionEnd();	enterState( 2 );}void CoffeeMachine_Tester_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:Testing'			switch( portIndex )			{			case 0:				switch( signalIndex )				{				case 1:					return;				default:					break;				}				break;			case 1:				// {{{RME port 'testResults'				switch( signalIndex )				{				case TestResults::Conjugate::rti_fail:					chain2_Failed_Test();					return;				case TestResults::Conjugate::rti_success:					chain3_Passed_Test();					return;				default:					break;				}				break;				// }}}RME			default:				break;			}			break;			// }}}RME		case 3:			// {{{RME state ':TOP:Done'			switch( portIndex )			{			case 0:				switch( signalIndex )				{				case 1:					return;				default:					break;				}				break;			default:				break;			}			break;			// }}}RME		default:			unexpectedState();			return;		}}const RTActor_class * CoffeeMachine_Tester_Actor::getActorData( void ) const{	return &CoffeeMachine_Tester_Actor::rtg_class;}const RTActor_class CoffeeMachine_Tester_Actor::rtg_class ={	(const RTActor_class *)0  , rtg_state_names  , 3  , CoffeeMachine_Tester_Actor::rtg_parent_state  , &CoffeeMachine_Tester  , 2  , CoffeeMachine_Tester_Actor::rtg_capsule_roles  , 3  , CoffeeMachine_Tester_Actor::rtg_ports  , 0  , (const RTLocalBindingDescriptor *)0  , 2  , CoffeeMachine_Tester_Actor::rtg_CoffeeMachine_Tester_fields};const RTStateId CoffeeMachine_Tester_Actor::rtg_parent_state[] ={	0  , 1  , 1};const RTComponentDescriptor CoffeeMachine_Tester_Actor::rtg_capsule_roles[] ={	{		"testContainers"	  , &MarkI_TestContainer	  , RTOffsetOf( CoffeeMachine_Tester_Actor, testContainers )	  , 1	  , RTComponentDescriptor::Optional	  , 1	  , 1 // cardinality	  , 6	  , rtg_interfaces_testContainers	  , 6	  , rtg_bindings_testContainers	}  , {		"cuContainer"	  , &MarkI_Container	  , RTOffsetOf( CoffeeMachine_Tester_Actor, cuContainer )	  , 2	  , RTComponentDescriptor::Optional	  , 1	  , 1 // cardinality	  , 5	  , rtg_interfaces_cuContainer	  , 5	  , rtg_bindings_cuContainer	}};const RTPortDescriptor CoffeeMachine_Tester_Actor::rtg_ports[] ={	{		"testResults"	  , (const char *)0	  , &TestResults::Conjugate::rt_class	  , RTOffsetOf( CoffeeMachine_Tester_Actor, CoffeeMachine_Tester_Actor::testResults )	  , 1 // cardinality	  , 1	  , RTPortDescriptor::KindWired + RTPortDescriptor::NotificationDisabled + RTPortDescriptor::RegisterNotPermitted + RTPortDescriptor::VisibilityProtected	}  , {		"frame"	  , (const char *)0	  , &Frame::Base::rt_class	  , RTOffsetOf( CoffeeMachine_Tester_Actor, CoffeeMachine_Tester_Actor::frame )	  , 1 // cardinality	  , 2	  , RTPortDescriptor::KindSpecial + RTPortDescriptor::NotificationDisabled + RTPortDescriptor::RegisterNotPermitted + RTPortDescriptor::VisibilityProtected	}  , {		"log"	  , (const char *)0	  , &Log::Base::rt_class	  , RTOffsetOf( CoffeeMachine_Tester_Actor, CoffeeMachine_Tester_Actor::log )	  , 1 // cardinality	  , 3	  , RTPortDescriptor::KindSpecial + RTPortDescriptor::NotificationDisabled + RTPortDescriptor::RegisterNotPermitted + RTPortDescriptor::VisibilityProtected	}};const RTFieldDescriptor CoffeeMachine_Tester_Actor::rtg_CoffeeMachine_Tester_fields[] ={	// {{{RME classAttribute 'current_test'	{		"current_test"	  , RTOffsetOf( CoffeeMachine_Tester_Actor, current_test )		// {{{RME tool 'OT::CppTargetRTS' property 'TypeDescriptor'	  , &RTType_int		// }}}RME		// {{{RME tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'	  , (const RTTypeModifier *)0		// }}}RME	}	// }}}RME	// {{{RME classAttribute 'num_tests'  , {		"num_tests"	  , RTOffsetOf( CoffeeMachine_Tester_Actor, num_tests )		// {{{RME tool 'OT::CppTargetRTS' property 'TypeDescriptor'	  , &RTType_int		// }}}RME		// {{{RME tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'	  , (const RTTypeModifier *)0		// }}}RME	}	// }}}RME};#undef SUPER// {{{RME tool 'OT::Cpp' property 'ImplementationEnding'// {{{USR// }}}USR// }}}RME// }}}RME

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -