Getting the Part Property Name

Moderator: Moderators

Getting the Part Property Name

Postby alvin.murphy@navy.mil » Fri May 19, 2017 1:30 pm

I have a model with several part properties that represent a common subsystem block.

Here's a sample picture.
Model.png


I'm able to get the block type using "self" (e.g. NetworkSwitch), but I'd like to get the part property name (i.e. A and B).

I'm using the following Jython code to get and print self:

Code: Select all
name = str(self)[0:str(self).find('@')]
print 'Name: %s' % (name)


Thanks in advance for any help you can provide.
You do not have the required permissions to view the files attached to this post.
alvin.murphy@navy.mil
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:0
Joined: Thu Mar 23, 2017 7:16 am

Re: Getting the Part Property Name

Postby tomas.lukosius@nomagic.com » Tue May 23, 2017 12:48 am

Hello Alvin,

Please provide more information on subject:
1. Is the code fragment you provided full macro or just a part of it? If it is only a part, then how entire macro looks like?
2. In what context you are executing macro? Is it validation rule, table column?

Kind regards,
No Magic, Inc. Customer Support
tomas.lukosius@nomagic.com
Forum Newbie
Forum Newbie
 
Posts: 22
Posts Rating:3
Joined: Tue Aug 30, 2016 12:22 am

Re: Getting the Part Property Name

Postby alvin.murphy@navy.mil » Tue May 23, 2017 8:45 am

Hello.

I've attached my sample model. The context block is "Model." You should be able to run the "Model" IBD as soon as the model opens. You should see the following output in the console:

Code: Select all
00:00:00,000 : **** Block Model is initialized. ****
00:00:00,000 : **** Block Model is started! ****
Name: NetworkSwitch
Name: NetworkSwitch


I'm trying to get the name of the part properties in order to see the following output:

Code: Select all
00:00:00,000 : **** Block Model is initialized. ****
00:00:00,000 : **** Block Model is started! ****
Name: A
Name: B


R,
Alvin
You do not have the required permissions to view the files attached to this post.
alvin.murphy@navy.mil
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:0
Joined: Thu Mar 23, 2017 7:16 am

Re: Getting the Part Property Name

Postby chairat_p » Mon May 29, 2017 10:40 pm

Dear Alvin,

To get the name of the part properties, please do the following steps:
1. Modify Opaque Behavior "GetName" as follows:
name0 = self.getFeatureValues().get(0).feature.getName()
name1 = self.getFeatureValues().get(1).feature.getName()

print 'Name: %s' % (name0)
print 'Name: %s' % (name1)
2. Create a Call Behavior Action (inside an Activity Diagram) with the "GetName" as Behavior
3. Delete "NetworkSwitch" Activity
4. Run the Model simulation, finally you'll get
00:00:00,000 : **** Block Model behavior is started! ****
Name: A
Name: B
00:00:00,116 : **** Block Model execution is terminated. ****

Best Regards,
Chairat
chairat_p
Forum Beginner
Forum Beginner
 
Posts: 31
Posts Rating:3
Joined: Thu Mar 16, 2017 1:35 am

Re: Getting the Part Property Name

Postby alvin.murphy@navy.mil » Wed Jun 07, 2017 1:11 pm

Unfortunately that blew up. I've attached a larger part of my overall model to help explain what I'm building. Here's a more complete image:

Combat System.png


Essentially I'm trying to route data between systems through network switches. Each switch will read a router table to determine how to route data between source and destination systems. I need the switch names (e.g. es1, cs, es2) to determine which switch is processing the packets and determine the port to use to pass the data to the destination system. A typical path (between systems) may be rdr, rcp, ws, rdr for example. Currently the model only passes data from p1 to p2 on the switches (run "Router Simulation" config). I plan to use the MD EXCEL plugin to load the router table into each switch (based upon the switch name).

Thanks in advance for any assitance you can provide.

R,
Alvin
You do not have the required permissions to view the files attached to this post.
alvin.murphy@navy.mil
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:0
Joined: Thu Mar 23, 2017 7:16 am


Return to Cameo Simulation Toolkits

Who is online

Users browsing this forum: No registered users and 1 guest

cron