![]() |
Telelogic TAU (steve huntington) | ![]() |
Topic Title: About extracting property of stererotype Topic Summary: Created On: 3-Apr-2007 14:10 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: James First point is that Stereotype1 must extend a metaclass, probably with multiplicity 0..1, something like this: stereotype Stereotype1 extends TTDMetamodel::Class [0 .. 1] { Charstring aa; part ClassA a; } class ClassA { Charstring a; Integer b; //part ClassB bb; } And then here is a textual version of a class Class1 with <<Stereotype1>> applied, with some values: <<Stereotype1(.a = ClassA (.b = 23,a = "hi".),aa = "lo".)>> class Class1 { } Which gives a hint that the correct syntax for retrieving b is: set expRequired [u2::GetTaggedValue $sel "'Stereotype1' (. a=ClassA (. b .) .)"] Here is the script I got to work: set sel [std::GetSelection] Output "Selection=$sel [u2::GetValue $sel Name] [u2::GetMetaClassName $sel]\n" set expRequired [u2::GetTaggedValue $sel "'Stereotype1' (. a=ClassA (. b .) .)"] if { $expRequired == 0 } { set expRequired_txt "" } else { Output "value=$expRequired [u2::GetMetaClassName $expRequired]\n" set expRequired_txt [u2::GetValue $expRequired "Value"] } Output "text value=$expRequired_txt\n" HTH Ian | |
![]() |
|
How can i extract the property of stereotype in the following example:
stereotype Stereotype1 { Charstring aa; part ClassA a; } class ClassA { Charstring a; Integer b; part ClassB bb; } Is that correct as followed? set expRequired [u2::GetTaggedValue $s "'$sname' (. a (. b .) .)"] if { $expRequired == 0 } { set expRequired_txt "" } else { set expRequired_txt [u2::GetValue $expRequired "Value"] } |
|
![]() |
|
![]() |
|
James
First point is that Stereotype1 must extend a metaclass, probably with multiplicity 0..1, something like this: stereotype Stereotype1 extends TTDMetamodel::Class [0 .. 1] { Charstring aa; part ClassA a; } class ClassA { Charstring a; Integer b; //part ClassB bb; } And then here is a textual version of a class Class1 with <<Stereotype1>> applied, with some values: <<Stereotype1(.a = ClassA (.b = 23,a = "hi".),aa = "lo".)>> class Class1 { } Which gives a hint that the correct syntax for retrieving b is: set expRequired [u2::GetTaggedValue $sel "'Stereotype1' (. a=ClassA (. b .) .)"] Here is the script I got to work: set sel [std::GetSelection] Output "Selection=$sel [u2::GetValue $sel Name] [u2::GetMetaClassName $sel]\n" set expRequired [u2::GetTaggedValue $sel "'Stereotype1' (. a=ClassA (. b .) .)"] if { $expRequired == 0 } { set expRequired_txt "" } else { Output "value=$expRequired [u2::GetMetaClassName $expRequired]\n" set expRequired_txt [u2::GetValue $expRequired "Value"] } Output "text value=$expRequired_txt\n" HTH Ian ------------------------- ============= Ian Barnard Principal Consultant Telelogic UK, an IBM company Edited: 3-Apr-2007 at 14:50 by Ian Barnard |
|
![]() |
|
![]() |
|
Thanks Ian, you have the advantage of GMT over PDT
![]() Here's a function I use regularly that gets any tagged value, or at least attempts to: # return the text of a tagged value proc getTagValue { el tag } { set tv [u2::GetTaggedValue $el $tag] if { $tv == 0 } { set infotext "" } else { if { [u2::IsKindOf $tv Ident] } { set infotext [u2::GetValue $tv Name] } elseif { [u2::IsKindOf $tv ListExpr] } { # combine the list values with \n set infotext [list] foreach e [u2::GetEntities $tv Expression] { lappend infotext "[u2::GetValue $e ValueString]" } } elseif { [u2::IsKindOf $tv CharstringValue] } { set infotext [u2::GetValue $tv Value] } else { set infotext [u2::GetValue $tv ValueString] } } return $infotext } ------------------------- Greg Gorman Vice President, Product Management Modeling and Test Products Telelogic AB |
|
![]() |
|
![]() |
|
And here's the UK entry for GetTagValue:
proc GetTagValue { el tag } { set tv [u2::GetTaggedValue $el $tag] if { $tv == 0 } { set infotext "" } else { if { [u2::IsKindOf $tv Ident] } { set infotext [u2::GetValue $tv Name] } elseif { [u2::IsKindOf $tv ListExpr] } { # combine the list values with \n set infotext [list] foreach e [u2::GetEntities $tv Expression] { lappend infotext "[u2::GetValue $e ValueString]" } } elseif { [u2::IsKindOf $tv CharstringValue] } { set infotext [u2::GetValue $tv Value] } elseif {[u2::IsKindOf $tvStr UnaryExpr]} { set infotext "[u2::GetValue $tv Operator][u2::GetValue $tv Operand]" } else { set infotext [u2::GetValue $tv ValueString] } } DebugOutput "tag value for [rep $el] $tag is $infotext\n" return $infotext } This adds handling of UnaryExpr (e.g. the value -1) which caught me out once :~| Regards Ian I wish I could get code quoting to work! ------------------------- ============= Ian Barnard Principal Consultant Telelogic UK, an IBM company |
|
![]() |
|
![]() |
|
Thank IAN and Greg, I got it.
But it seems that variable expresssed with unicode is not supported. i.e is as follow: <<::'MSB-IPD'::'Architectural Profile'::Signal::sigDM(.'Signal Property信号属性' = CSignalProperty (.Remark = "kuyuy".), HistoryInfo历史信息 = CHistoryInfo (..).)>> signal Signal1; Could you confirm the variable 'Signal Property信号属性' must be replaced with "SigProerty"? |
|
![]() |
|
![]() |
|
Thank IAN and Greg, I got it.
But it seems that variable expresssed with unicode is not supported. i.e is as follow: <<::'MSB-IPD'::'Architectural Profile'::Signal::sigDM(.'Signal Property信号属性' = CSignalProperty (.Remark = "kuyuy".), HistoryInfo历史信息 = CHistoryInfo (..).)>> signal Signal1; Could you confirm the variable 'Signal Property信号属性' must be replaced with "SigProerty"? |
|
![]() |
Telelogic TAU
» TAU/Developer
»
About extracting property of stererotype
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.