2017-07-25 40 views
0

無法從模型中獲取要求。我嘗試過getAppliedStereotypes(),但它仍然不起作用。其代碼如下:無法獲得Acceleo的要求

[comment encoding = UTF-8 /] 
[module maintest('http://www.eclipse.org/papyrus/sysml/1.4/SysML', 
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Activities', 
'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Requirements', 
'http://www.eclipse.org/uml2/5.0.0/UML')/] 

[template public maintestClass(aPackage : Package)] 
[comment @main /] 
[file ((aPackage.name+'.m'), false, 'UTF-8')] 
0000 
[for (r : Requirements::Requirement| aPackage.packagedElement->filter(Requirements::Requirement))] 
11111 
[/for] 
[/file] 
[/template] 

此外,從http://techqa.info/programming/question/35093700/cannot-access-sysml-stereotypes-and-their-properties-in-acceleo這個頁面,我可以要求只是生成(重:要求::要求),但它不能滿足需要,因爲我已經把一些節點模型中的值到文檔中,但此模板無法獲取模型信息。或者,也許有關獲取節點信息的解決方案只能滿足要求?

回答

0

我有一個非常類似的問題,並解決這個問題,我在這裏交叉這個問題,我現在相信找到了答案。我運行了我的SysML模型的類,並決定它們是否爲塊或需求。根據我稱之爲不同的進口模板:

[comment encoding = UTF-8 /] 
[module main('http://www.eclipse.org/papyrus/sysml/1.4/SysML', 'http://www.eclipse.org/uml2/5.0.0/UML')] 

[import MULTIC_TOOLING_GenSystemC::files::modRequirement /] 
[import MULTIC_TOOLING_GenSystemC::files::modBlock /] 

[template public mainTemplate(aClass : Class)] 

    [comment @main/] 
    [if (aClass.getAppliedStereotype('SysML::Blocks::Block')->notEmpty())] 
     [let aBlock : Block = aClass.getStereotypeApplication(aClass.getAppliedStereotype('SysML::Blocks::Block'))] 
     [tempBlock(aBlock)/] 
     [/let] 
    [/if] 
    [if (aClass.getAppliedStereotype('SysML::Requirements::Requirement')->notEmpty())] 
     [let aRequirement : Requirement = aClass.getStereotypeApplication(aClass.getAppliedStereotype('SysML::Requirements::Requirement'))] 
      [tempRequirement(aRequirement)/] 
     [/let] 
    [/if] 

[/template]