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

📄 checkmarte4cheddar.atl

📁 papyrus插件MARTE例子,uml建模
💻 ATL
📖 第 1 页 / 共 2 页
字号:
				else thisModule.undeferror(e, 'ExecHost of host scheduler') endif;			}		} else {			thisModule.error(e,'<<SchedulableResource>> must be applied.');		}				-- check for duplicate names		if(thisModule.KnownNames->exists(s | s = e.getQName())) {			thisModule.error(e, 'Duplicate name found');		} else {			thisModule.KnownNames <- thisModule.KnownNames->append(e.getQName());			thisModule.TaskNames <- thisModule.TaskNames->append(e.getQName());		}	}}rule resource_user (link:UML!Dependency) {	do {		link.verboseMessage('resource_user ' +link.getClients().first().getQName());				if thisModule.TaskNames->exists(s | s =  link.getClients().first().getQName()) then OclUndefined		else thisModule.unkwarning(link.getSuppliers().first(),link.getClients().first()) endif;				let mc : UML!Constraint = UML!Constraint.allInstances()->select(c | c.getConstrainedElements()->exists(ce | ce=link))->first()		in if not mc.oclIsUndefined() then			if not mc.getSpecification().isIntegral() then				thisModule.error(link.getSuppliers().first(), 'Invalid constraint on resource used by' + link.getClients().first().getQualifiedName())			else OclUndefined endif		else 			thisModule.error(link.getSuppliers().first(), 'No start time constraint on resource used by' + link.getClients().first().getQualifiedName())		endif;					if link.marteHasVSLInteger(link.ResourceUsage(), link.ResourceUsage_execTime(),Sequence{'value'})		then			OclUndefined		else			thisModule.error(link.getSuppliers().first(), 'execTime is required on resource used by' + link.getClients().first().getQualifiedName())		endif;					}}rule resource ( e:UML!Element) {	do {		e.verboseMessage('resource ' + e.getQName());				let cap: String  = e.getStereotypeAttributeValue(e.SwMutualExclusionResource(),e.SwMutualExclusionResource_concurrentAccessProtocol()).toString()		in 	if cap = 'IN!'+e.ConcurrentAccessProtocolKind_PIP() then OclUndefined			else 	if cap = 'IN!'+e.ConcurrentAccessProtocolKind_PCP() then  OclUndefined			else 	if cap = 'IN!'+e.ConcurrentAccessProtocolKind_NoPreemption() then  OclUndefined			else 	if cap = 'IN!'+e.ConcurrentAccessProtocolKind_Other() then					if not e.getOwnedAttributes()->select(e|e.name='cheddar_IPCP').first().oclIsUndefined() then OclUndefined					else thisModule.error(e,'element must have a cheddar_IPCP attribute if the concurrent access protocol is Other') endif			else thisModule.undeferror(e,'concurrentAccessProtocol') endif endif endif endif;						let m : String =  e.getStereotypeAttributeValue(e.SwMutualExclusionResource(),e.SwMutualExclusionResource_mechanism()).toString()		in 		if m = 'IN!'+ e.MutualExclusionResourceKind_BooleanSemaphore() then 0			else		if m = 'IN!'+ e.MutualExclusionResourceKind_Mutex() then 1			else		if m = 'IN!'+ e.MutualExclusionResourceKind_CountSemaphore() then				if 	e.getIntSADVBN(e.SwMutualExclusionResource(), e.SwResource_stateElements(), 'cheddar_state').oclIsUndefined() then					thisModule.warning(e,'cheddar_state is missing, using default value 0 for count semaphore initial state')				else OclUndefined endif			else thisModule.error(e,'mechanism is invalid') endif endif endif;				let mas : String = thisModule.AddressSpaceNames->select(as | e.getSuppliersKindOf(e.MemoryPartition())->exists(a | a.getQName() = as))->first()			in if  mas.oclIsUndefined() then thisModule.undeferror(e,'address space') else OclUndefined 	endif;						for(d in e.getSupplyingDependencies()->select(dep | dep.marteIsKindOf(e.ResourceUsage()))) {			thisModule.resource_user(d);		}				-- check for duplicate names		if(thisModule.KnownNames->exists(s | s = e.getQName())) {			thisModule.error(e, 'Duplicate name found');		} else {			thisModule.KnownNames <- thisModule.KnownNames->append(e.getQName());			thisModule.ResourceNames <- thisModule.ResourceNames->append(e.getQName());		}	}}rule buffer_user (link:UML!Dependency) {	do {		link.verboseMessage('buffer_user ' + link.getClients().first().getQName());				if thisModule.TaskNames->exists(s | s =  link.getClients().first().getQName()) then OclUndefined		else thisModule.unkwarning(link.getSuppliers().first(),link.getClients().first()) endif;				let mc : UML!Constraint = UML!Constraint.allInstances()->select(c | c.getConstrainedElements()->exists(ce | ce=link))->first()		in if not mc.oclIsUndefined() then			if not mc.getSpecification().isIntegral() then				thisModule.error(link.getSuppliers().first(), 'Invalid constraint on buffer used by ' + link.getClients().first().getQualifiedName())			else OclUndefined endif		else 			thisModule.error(link.getSuppliers().first(), 'No time constraint on buffer used by ' + link.getClients().first().getQualifiedName())		endif;			if link.marteHasVSLInteger(link.ResourceUsage(), link.ResourceUsage_msgSize(),Sequence{'value'})		then			OclUndefined		else			thisModule.error(link.getSuppliers().first(), 'msgSize is required on buffer used by' + link.getClients().first().getQualifiedName())		endif;	}}rule buffer (e:UML!Element ) {	do {		e.verboseMessage('buffer ' + e.getQName());				let s: String = e.getDefaultValueAttributeByName('cheddar_qs') in			if s <> 'QS_PP1' and s <> 'QS_MM1' and s <> 'QS_MD1'  and s <> 'QS_MP1'			and s <> 'QS_MG1'  and s <> 'QS_MMS'  and s <> 'QS_MDS' and s <> 'QS_MPS'			and s <> 'QS_MGS' 	and s <> 'QS_MM1N'  and s <> 'QS_MD1N' and s <> 'QS_MP1N' 			and s <> 'QS_MG1N' and s <> 'QS_MMSN' and s <> 'QS_MDSN'  and s <> 'QS_MPSN'  and s <> 'QS_MGSN' 			then thisModule.error(e,'cheddar_qs is invalid') else OclUndefined endif;				if e.marteHasAttributeValue(e.StorageResource(), e.StorageResource_elementSize()) then			if e.marteGetAttributeValue(e.StorageResource(), e.StorageResource_elementSize())='' then				thisModule.error(e,'elementSize is invalid')			else OclUndefined endif			else thisModule.undeferror(e,'elementSize') endif;			let mas : String = thisModule.AddressSpaceNames->select(as | e.getSuppliersKindOf(e.MemoryPartition())->exists(a | a.getQName() = as))->first()		in if  mas.oclIsUndefined() then thisModule.undeferror(e,'address space') else OclUndefined 	endif;				for(d in e.getSupplyingDependencies()->select(dep | dep.marteIsTypeOf(e.ResourceUsage()))) {			thisModule.buffer_user(d);		}				-- check for duplicate names		if(thisModule.KnownNames->exists(s | s = e.getQName())) {			thisModule.error(e, 'Duplicate name found');		} else {			thisModule.KnownNames <- thisModule.KnownNames->append(e.getQName());			thisModule.BufferNames <- thisModule.BufferNames->append(e.getQName());		}	}}rule message ( e:UML!Element) {		do {		e.verboseMessage('message '+e.getQName());				if e.marteHasVSLInteger(e.SaCommStep(), e.GaCommStep_msgSize(),Sequence{'value'}) then			if e.marteGetVSLInteger(e.SaCommStep(), e.GaCommStep_msgSize(),Sequence{'value'}) > 0 then OclUndefined			else  thisModule.error(e,'msgSize must be >0') endif		else thisModule.undeferror(e,'msgSize') endif;					-- check for duplicate names		if(thisModule.KnownNames->exists(s | s = e.getQName())) {			thisModule.error(e, 'Duplicate name found');		} else {			thisModule.KnownNames <- thisModule.KnownNames->append(e.getQName());			thisModule.MessageNames <- thisModule.MessageNames->append(e.getQName());		}	}}rule event_analyzer (e : String) {	do {		e.verboseMessage('event_analyzer '+e);		-- check for duplicate names		if(thisModule.KnownNames->exists(s | s = e)) {			thisModule.error(e, 'Duplicate name found');		} else {			thisModule.KnownNames <- thisModule.KnownNames->append(e);			thisModule.EANames <- thisModule.EANames->append(e);		}	}}rule dependency (link: UML!dependency) {	do {		link.verboseMessage('dependency '+link.getSuppliers()->first().getQName() + ' -> ' + link.getClients()->first().getQName());				if (thisModule.TaskNames->exists(s | s =  link.getClients().first().getQName())			or thisModule.BufferNames->exists(s | s =  link.getClients().first().getQName())			or thisModule.MessageNames->exists(s | s =  link.getClients().first().getQName()))		then OclUndefined		else thisModule.unkerror2(link.getClients().first(), 'dependency') endif;				if (thisModule.TaskNames->exists(s | s =  link.getSuppliers().first().getQName()) 			or thisModule.BufferNames->exists(s | s =  link.getSuppliers().first().getQName()) 			or thisModule.MessageNames->exists(s | s =  link.getSuppliers().first().getQName()))		then OclUndefined		else thisModule.unkerror2(link.getSuppliers().first(),'dependency') endif;	}	}------ Root rule----rule AnalysisContext {	from e:UML!Element ((e.marteIsTypeOf(e.GaAnalysisContext()) or e.marteIsTypeOf(e.SaAnalysisContext()))  and e.isTarget())		do {		e.verboseMessage('Checking for errors ...');				thisModule.AnalysisContextCount <- thisModule.AnalysisContextCount + 1;				if(thisModule.AnalysisContextCount > 1) {			thisModule.info('','Multiple analysis context are defined.');		}				if(thisModule.hasParameter('targetElement')) {			if(e.oclIsKindOf(UML!NamedElement)){				if (thisModule.getParameter('targetElement') = e.getQualifiedName()) {					thisModule.info('', 'Analyzing targeted element : ' + e.getQualifiedName() );				}			}		}				if(e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())->size()=0) {			thisModule.error(e, 'No platform found');		}				-- processors		if(not e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())				->exists(elem|elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.GaExecHost())->size()<>0)) {			thisModule.error(e, 'No processor(s) declared');		}		for( elem in e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())) {			for(elem2 in elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.GaExecHost())){				thisModule.processor(elem2);			}		}				-- address spaces		if(not e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())			->exists(elem|elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.MemoryPartition())->size()<>0)) {			thisModule.error(e, 'No address space(s) declared');		}		for( elem in e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())) {			for(elem2 in elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.MemoryPartition())){				thisModule.address_space(elem2);			}		}				-- tasks		if(not e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())			->exists(elem|elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.SwSchedulableResource())->size()<>0)) {			thisModule.error(e, 'No task(s) declared');		}		for( elem in e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())) {			for(elem2 in elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.SwSchedulableResource())){				thisModule.task( elem2);			}		}				-- resources		for( elem in e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())) {			for(elem2 in elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.SwMutualExclusionResource())){				thisModule.resource(elem2);			}		}				-- buffer		for( elem in e.getStereoElemsKindOfStereoAttrib(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_platform(), e.GaResourcesPlatform())) {						for(elem2 in elem.getStereoElemsKindOfStereoAttrib(e.GaResourcesPlatform(),e.GaResourcesPlatform_resources(), e.StorageResource())){				thisModule.buffer(elem2);			}		}				-- event_analyzers		for( elem in e.marteGetAttributeValueSequence(if e.marteIsTypeOf(e.GaAnalysisContext()) then e.GaAnalysisContext() else e.SaAnalysisContext() endif, e.GaAnalysisContext_contextParams())) {			thisModule.event_analyzer(elem);		}				-- messages		if(e.getStereoElemsKindOfStereoAttrib(e.ACV(), e.GaAnalysisContext_workload(), e.GaWorkloadBehavior())->first().oclIsUndefined()) {			thisModule.warning(e, 'no workload found');		}		for(elem in e.getStereoElemsKindOfStereoAttrib(e.ACV(), e.GaAnalysisContext_workload(), e.GaWorkloadBehavior())) {			if( elem.getStereoElemsKindOfStereoAttrib(e.GaWorkloadBehavior(), e.GaWorkloadBehavior_behavior(), e.GaScenario())->first().oclIsUndefined()) {				thisModule.warning(elem, 'no behavior found');			}						for(elem2 in elem.getStereoElemsKindOfStereoAttrib(e.GaWorkloadBehavior(), e.GaWorkloadBehavior_behavior(), e.GaScenario()) ) {				for(elem3 in elem2.getStereoElemsKindOfStereoAttrib(e.GaScenario(),e.GaScenario_steps(), e.SaCommStep())){					thisModule.message(elem3);				}			}		} 				-- dependencies		for(elem in e.getStereoElemsKindOfStereoAttrib(e.ACV(), e.GaAnalysisContext_workload(), e.GaWorkloadBehavior())) {			for(elem2 in elem.getStereoElemsKindOfStereoAttrib(e.GaWorkloadBehavior(), e.GaWorkloadBehavior_behavior(), e.GaScenario()) ) {				for(step in elem2.getStereotypeAttributeValue(e.GaScenario(), e.GaScenario_steps())) {					if(step.oclType() = UML!Dependency and step.marteIsKindOf(step.GaStep())) {						thisModule.dependency( step);					}				}			}		} 	}}

⌨️ 快捷键说明

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