Cancel
Showing results for 
Search instead for 
Did you mean: 

Getting a MU attribute value

Experimenter
Experimenter

Hi everyone, 

 

I´m working with a MU which has 3 different attributes defined by me (e.g. Quality, Mass, Volume, neverthless they could be 5-6 different attributes or more, it doesn´t matter). Every time a MU activate the method I have to get the value of 1 of these 3 attributes; the point is that the one I need to get changes time by time, according to what is written in a variable(called "Attribute", type string) belonging to the same frame.

 

If I write @.Attribute it does not recognize anything, I neither cannot write @.Quality, otherwise I would always look for the same attribute. 

 

Thanks for helping.

Lorenzo 

 

12 REPLIES 12

Re: Getting a MU attribute value

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
try

@.getAttributeValue("yourAttributeName")
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Getting a MU attribute value

Experimenter
Experimenter

thanks a lot, actually the one that works was @.getAttribute( ), thanks for helping!!

Re: Getting a MU attribute value

Experimenter
Experimenter

Hi, 

 

In the method i use, a certain attribute of the MU determines the default exit of a CC, therefor i tried to work with the @.getAttribute("Type") method you suggested with Type being the assigned attribute to the MU. But i get an error saying a void can't use this method. What exactly does this mean?

 

Thanks in advance,

 

Guillaume Mille

Re: Getting a MU attribute value

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

you cannot call a method by yourself, if you use @; Plant Simulation will set @, if a MU calls a sensor or control;

if you execute the method, @ is void

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Getting a MU attribute value

Experimenter
Experimenter

Hi,

 

Thank you for replying. I don't fully understand what you mean. In the following link there is the code of the method that i use. The method isnt directly linked to the CC (Cross Conveyor), it only changes the attribute of the CC afterwards. There is no mention of Method in a controller tab. In the attatched picture you can find the layout. Thanks in advance.

 

http://pastiebin.com/embed/5cace9d582db4

Re: Getting a MU attribute value

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

what do you mean with @ in your program?

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Getting a MU attribute value

Experimenter
Experimenter

i try to refer to the MU that is passing, i gave it a User-Defined attribute called Type which is a string. If it is "V60" is moves on, if now it moves down. I had seen a method where @ was used to move the object to or to change the icon of it.

Re: Getting a MU attribute value

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

@ is a anonymous identifier, it will be replaced by Plant Simulation before executing the command. This only happens, if you call the method by a sensor (exit-, entrance, sensor-control...).

In your case, @ will not replaced and keeps nothing (void). You need to find another way to adress the MU.

 

Where is the MU, when you call the method?

Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Re: Getting a MU attribute value

Experimenter
Experimenter

The method is called when the program is initiated (in the init method). All method's in the model are constantly active and keep getting called every 10 or 5 seconds. This was the way i was shown how to set up the model. I want to retrieve the value in the user defined attribute of the Mu the moment it enters the CC or exits the previous station.

 

If preferred, i can send you a direct message to provide all the information you need so the thread doesn't get saturated.