【问题标题】:Unable to get Requirement in Acceleo无法在 Acceleo 中获得需求
【发布时间】:2018-02-01 00:28:51
【问题描述】:

无法从模型中获取需求。我试过 getAppliedStereotypes() 但它仍然不起作用。代码如下:

 [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 ,我可以通过 generate(re : Requirements::Requirement) 获得需求,但它不能满足需求,因为我必须将模型中的一些节点值放到文档中,但是这个模板无法获取模型信息。或者也许有任何关于在模型中获取节点信息的解决方案,这些信息只得到需求?

【问题讨论】:

    标签: acceleo papyrus sysml


    【解决方案1】:

    我有一个非常相似的问题,为了解决这个问题,我在这里提出了这个问题,我现在相信已经找到了答案。我运行了我的 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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-04
      • 2013-12-08
      • 2020-01-09
      • 2015-03-25
      • 1970-01-01
      相关资源
      最近更新 更多