Is it possible to set dipatcher's central ports in flexscript?

Is it possible to set dipatcher's central ports in flexscript?

danielhsu2014
Contributor Contributor
381 Views
3 Replies
Message 1 of 4

Is it possible to set dipatcher's central ports in flexscript?

danielhsu2014
Contributor
Contributor

Hi everyone,

I’m currently working with a Dispatcher object in FlexSim, and I’d like to programmatically set the Central Ports Type (Source or Sink) using FlexScript.

I’ve tried accessing the variable or attribute through the variables and parameters nodes in the tree, but couldn’t find a node or label corresponding to the central port type. I also attempted using setvarnum() or setnodenum(), but it seems that the central port type is not exposed as a regular node property.

Is there a FlexScript command or method to set the Dispatcher's central ports type at runtime? Or is this only configurable via the GUI?

Thanks in advance for any insights!

0 Likes
Accepted solutions (1)
382 Views
3 Replies
Replies (3)
Message 2 of 4

joerg_vogel_HsH
Mentor
Mentor

Central port is a visual reference by a dawn line between two objects. Whenever you reference an object by centerobject connection, you can replace it directly by FlexScript Class - treenode find method reference. 
Alternatively you can dynamically draw a centerport connection by command contextdragconnection

0 Likes
Message 3 of 4

danielhsu2014
Contributor
Contributor

Thanks a lot. But now I am trying to set dispatcher's Pass To into shortest distance by flexscript like:

Object dispatcher = Model.find(objName);
dispatcher.setProperty("PassTo","Shortest Distance");

 

danielhsu2014_3-1746371502828.png

,but it dosen't work it. How can I make it work? thanks for helping.

 

 

 

 

0 Likes
Message 4 of 4

joerg_vogel_HsH
Mentor
Mentor
Accepted solution

it is not just a string it is a treenode source code that gets evaluated to return directly an output port reference to transfer a tasksequence to attached object. Setproperty has only inserted a string and has not copied the source code into the node. I am not aware of a mechanism to copy a template source code called by phrase like "shortest distance" into the passTo node instantly executable. The picklist source code is in this node VIEW:/picklists/passtopicklist/Shortest Distance. But I wasn't successfull to get this code to work during simulation run. I needed always a reset of this model.

Object dispatcher = Model.find("Dispatcher1"); 
treenode passto = dispatcher.attrs.variables.subnodes["passto"];
passto.value = "";// delete currently active source code
passto.value += "TaskSequence taskSequence = param(1); Dispatcher current = ownerobject(c);";// insert header
passto.value += views.find("/picklists/passtopicklist/Shortest Distance").value;

 

0 Likes