Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic TAU (steve huntington)
Decrease font size
Increase font size
Topic Title: About extracting property of stererotype
Topic Summary:
Created On: 3-Apr-2007 14:10
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Ian Barnard, on Thursday, April 5, 2007 7:56 AM

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
 3-Apr-2007 14:10
User is offline View Users Profile Print this message


James Chan

Posts: 11
Joined: 20-Sep-2006

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"]
            }
Report this to a Moderator Report this to a Moderator
 3-Apr-2007 14:49
User is offline View Users Profile Print this message


Ian Barnard

Posts: 91
Joined: 4-Jul-2002

Answer 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

-------------------------
=============
Ian Barnard
Principal Consultant
Telelogic UK, an IBM company


Edited: 3-Apr-2007 at 14:50 by Ian Barnard
Report this to a Moderator Report this to a Moderator
 3-Apr-2007 15:13
User is offline View Users Profile Print this message


Greg Gorman

Posts: 75
Joined: 4-Oct-2002

Thanks Ian, you have the advantage of GMT over PDT -- maybe a curse.

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
Report this to a Moderator Report this to a Moderator
 3-Apr-2007 15:28
User is offline View Users Profile Print this message


Ian Barnard

Posts: 91
Joined: 4-Jul-2002

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
Report this to a Moderator Report this to a Moderator
 4-Apr-2007 04:41
User is offline View Users Profile Print this message


James Chan

Posts: 11
Joined: 20-Sep-2006

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"?
Report this to a Moderator Report this to a Moderator
 4-Apr-2007 04:42
User is offline View Users Profile Print this message


James Chan

Posts: 11
Joined: 20-Sep-2006

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"?
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic TAU forum.
There are currently 1 users logged in.
The most users ever online was 15 on 31-Mar-2008 at 16:22.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.