Cancel
Showing results for 
Search instead for 
Did you mean: 

18=Is there a way to perform indirect addressing in an object's formula ?

Genius
Genius

Hi there,

Is it possible to use indirect addressing in the formula to fetch an object's parameters?

The following worked fine to get the two times

<Object>.Times.Processing Time.Formula :=
        .Models.PillDispenser.L_Data["Proc Time/MU",9]

<Object>.Times.Setup Time.Formula :=
        .Models.PillDispenser.L_Data["Setup Time/MU",9]


However I don't like the idea of distributing hard-coded row indices (the index 9 above) throughout each and every object's formulae in the model.
I know that the model parameter table (which is imported from Excel into tableFile:L_data) will change often.

I'd rather use an intervening indexing layer (tableFile "par") with the intention of freezing the locations in this table and so allowing L_data to be flexible (Excel can construct & maintain the par table without too much user intervention).
So I wanted to use the following two formulae in place of the two in the previous code box, but get the error as shown :

<Object>.Times.Processing Time.Formula := root.L_Data[ .root.par("Col label",61), .root.par("Row number",61) ] -- processing time
<Object>.Times.Setup Time.Formula      := root.L_Data[ .root.par("Col label",62), .root.par("Row number",62) ] -- setup      time
-> error: Unknown Identifier root   (( where root is   .Models.PillDispenser  ))


So I tried the expanded form of this, this time the error suggests that the indices into the L_Data table (an object) cannot be objects but must be methods :-

<Object>.Times.Processing Time.Formula := .Models.PillDispenser.L_Data[ .Models.PillDispenser.par("Col label",61), .Models.PillDispenser.par("Row number",61) ] -- processing time
<Object>.Times.Setup Time.Formula      := .Models.PillDispenser.L_Data[ .Models.PillDispenser.par("Col label",62), .Models.PillDispenser.par("Row number",62) ] -- setup      time

-> error: An object which is not a method was used with an argument list


Is there a (simple) way to achieve something like that of the second code box (addressed using .root.par - not absolute addressing)?

This is such a pity - that all objects are not objectified - are not treated equally as objects (an old axe I like grinding).

The following image does not warrant a forum post on its own, but demonstrates that Connector (objects - !??) cannot be selected by a box dragged through them as other objects can.  


I wanted to delete all the selected Connectors so I could get the predecessor sequence right, but had to manually select each connector before doing a bulk delete - a single box drag would have been so much handier.

18=Connection not selectable by drag and drop 01.Gif


 

 

12 REPLIES 12

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi Old_Sohol,

 

If .root.par is a table where you want to access a cell you should write ".root.par["Col label",61]",  instead of ".root.par("Col label",61)".

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Genius
Genius

Thanks Ralf - that is such a stupid mistake of me to make Smiley Embarassed

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Genius
Genius

Can a method change the .ProcTime and .SetupTime input type to "formula" and also insert a formula for each.

I can generate the text for such a method in Excel from all the parameter data for the model, it seems a pity to have to manually edit every process object in the model now.

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
yes, have a look at the method setSubAttribute; in your case:

singleProc.setSubAttribute("ProcTime","type","formula")
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Genius
Genius

That's just the sort of thing I hoped for, thanks Steffen.  I'll get the exact syntax from PlantSim.Help.

I assume that one doesn't use the literal   singleProc  identifier, and also that it may turn out to be something like this - but that is tomorrow's work ....

<processObject>.setSubAttribute ( "ProcTime", "formula", <actual formula>)

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Siemens Phenom Siemens Phenom
Siemens Phenom

For built-in time distribution attributes like "ProcTime" and "SetupTime", you can use the method setParam to set the distribution type and parameters at once. For example:

 

YourStationName.ProcTime.setParam("Formula", "1+2")

 

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Genius
Genius

Thanks Michael - appreciate that input too.

 

Long reply here (again) - but this is the important part, repeated here for emphasis

If the Excel master file generates SimTalk code comprising all the setAttribute's 
for the model, can this code in the spreadsheet be loaded (using another method)
into a method in the model?

 

 

> For built-in time distribution attributes like "ProcTime" and "SetupTime"

Would that be for most of the properties you can set manually via dialogs?

Don't worry - this will be answered by this Help entry

 Path.putAttributeNamesIntoTable(Table:table [,IncludeUserDefinedAttribute:boolean, IncludeMethods:boolean, Language:integer]) 

Example:  MyStation.putAttributeNamesIntoTable(MyTable) 

I'll make sure I use a mix of both, to keep future options open.  Might find out some interesting pros and cons of each with use.

 

However reading further in Help when I came across this basic command

 Path.setAttribute(AttributeName:string, Value:any) 
 
Example:   MyStation.setAttribute("ProcTime",5) 

I wondered if it might be simpler to avoid entering formulae in every object using a method, by simply having a method load the literal values using setAttribute instead (Excel could generate all these commands instead of all the formulae which have to access two tablefiles).

The huge advantage of this is that actual numerical value is displayed directly in the model (F8 query or via the object dialogs) -- and it's pretty neat that the value setting can be annotated - that is awesome :-

 

18=Value set by setAttribtue can be annotated.Gif

 

[edit: small correction: Not applicable to setAttribute 
          must use setParam  or  setSubAttribute as this must be entered as a formula18=Value set by setAttribtue can be annotated 02.Gif          ]


So that leads to the question :-

 

If the Excel master file generates SimTalk code comprising all the setAttribute's for the model, can this code in the spreadsheet be loaded (using another method) into a method in the model? 

(Since I have recently read that a method can load an Excel spreadsheet directly into a table avoiding manual copy and paste).

--- and if a method can load ExcelSmiley FrustratedimTalk code, it can just as well invoke it too --

 

For now I will just copy and paste the Excel->SimTalk code manually into the method and execute that, see how that works for me - simpler than the formulae method which required double indexing into two tablefiles

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Phenom
Phenom

you can import ascii data from a txt file into a method

 

through e.g.  &method.load("xxx.txt").

 

If you want to load excel data into a method

 

 you then first have to load the excel data into a string

 

and then hand over the data (string)  to the method

 

e.g. &method.program ( := datastring)

 

For more details s. help for method

 

Betreff: 18=Is there a way to perform indirect addressing in an object's formula ?

Genius
Genius

Thanks simulator - now that looks really powerful, will experiment a bit and post back with some concrete examples