Cancel
Showing results for 
Search instead for 
Did you mean: 

14= How does SimTalk disconnect an existing connection between objects?

Genius
Genius

Hi,

I want to use SimTalk to update a manually input model by replacing every previously inserted connection with a conveyor (with "normal connections" from upstream object to conveyor, and conveyor to downstream object).

All the SimTalk code for conveyor insertion seems to work OK (for a single test pair of objects), but my naïve expectation that the existing connection would simply be superseded is not being met.

I have looked through help and tutorials for a ".disconnect" method, or for a "see also" with the .connect method, but am only drawing blanks.

There must be a way to do this I suspect, but it is not intuitively obvious - if someone could help with some tips I would be very grateful.

Some context to this problem


Inserting conveyor positioned at the upstream object exit :-

convyr_Left_Right := .MaterialFlow.Conveyor.createObject ( curFrame, x_px, y_px);



Moving conveyor offload point to downstream object entry

segTab :=     convyr_Left_Right.SegmentsTable;
segTab[1,2] := WS_Right.XPos -0.2 *xWd_m /SF;
segTab[2,2] := convyr_Left_Right.YPos;
               convyr_Left_Right.SegmentsTable := segTab;



Feed MUs on and off using normal connections

.materialFlow.connector.connect( WS_Left, convyr_Left_Right          );
.materialFlow.connector.connect(          convyr_Left_Right, WS_Right);


I thought the above .connect code would simply break the existing connections - that would be intuitive to me.

 

What does it actually mean with redundant connections as below ???
14= How does SimTalk disconnect an existing connection between objects QQ.gif

 


Thanks, as always, the case for great help that is provided   Smiley Very Happy

____________________________________________
PlantSim Ver 14.1.0.1294   &  Windows 7 Ent. SP1

~~~~  1st post in thread  ~~~~

18 REPLIES

Re: 14= How does SimTalk disconnect an existing connection between objects?

Phenom
Phenom

As the objects can have multiple incoming and outgoing connectors , why should

 

adding one new connector delete (all) existing connections ?

 

If you want to replace a specific connection

 

use  connector.deleteObject before connecting the (replacing) connector (s. connector.connect)

Betreff: 14= How does SimTalk disconnect an existing connection between objects?

Gears Phenom Gears Phenom
Gears Phenom

As for automatic replacement/deletion of an existing connector, I support @simulators opinion.

 

And to delete a specific connector, you do something like this:

 

-- delete existing connection between SP1 and SP2
for var s := SP1.numSucc downto 1 loop
	if (SP1.succ(s) = SP2) then
		SP1.succConnector(s).deleteObject
	end
next

 

____________________________________________________________
Alex Dilg, Consultant at SimPlan AG (www.SimPlan.de)
This post was good and/or helpful to you? Please provide some Kudos, thank you!

Re: 14= How does SimTalk disconnect an existing connection between objects?

Genius
Genius

Thanks simulator and Alex - will try your responses and respond.

 

> As the objects can have multiple incoming and outgoing connectors , why should adding one new connector delete (all) existing connections ?

 

... because the output of an an object can only be in one place at one time.  If there are alternative destinations, it should be routed by the generating object - not sent everywhere and only accepted by one object.  Isn't that logical?

Well  - I suppose if an artefact could be sent to the next WS or to a holding area, it would need two output paths - so there is a case for multiple outgoing connectors. 

So I acknowledge the point, it was wrong to assume that there can only be one output path, and that output connections would have to be mutually exclusive.

Re: 14= How does SimTalk disconnect an existing connection between objects?

Phenom
Phenom

@Old_Sohol

 

to keep it short.

 

   What if you want to keep the existing connections ?

    Are you going to  acknowledge all the connections you want to keep ?

 

I think your idea makes setting connectors too complicated to handle.

 

 

 

 

 

 

 

Re: 14= How does SimTalk disconnect an existing connection between objects?

Genius
Genius

I've just been thinking about why my intuition expected one-to-one connectivity (which answers your question, I would replace a single connection with another single connection).

My current model is a production line.  True, a WS can feed the downstream WS or a holding area (or QC could reject it and feed it back to an upstream WS, possibly via a holding area), but in essence there is one MU route through the model.

One to one comes from my background, communications and control - if the signal/data path splits then a demultiplexer process is required, normal processes have one output.

But I am sure that I will get the disconnect working fine thanks to your help, that is what is needed now.

Re: 14= How does SimTalk disconnect an existing connection between objects?

Genius
Genius

Thanks @AlexD_SimPlan, your {marked as solution} above works like a charm.

Just one question, is there a reason to run the loop downwards?  

 

for var s := SP1.numSucc downto 1 loop

 

It works fine both ways (with only one connection to remove) - so if no reason for a reverse loop I prefer the normal s++ loop.

Re: 14= How does SimTalk disconnect an existing connection between objects?

Genius
Genius

BTW2 : Would have been hard to find this solution in Help. 

Since deleteObject is inaccurate method name for this action, below is what this was intended for

Syntax:  Path.deleteObject → boolean 

The method deleteObject deletes the object designated by Path.

Had a good laugh at this I did :-

The return value has the data type boolean. Decided not to document what false/true means as it is too complicated to describe. 

It does occur in the right form below but who could find "delete connection" in such a place. It should really be a method "deleteConnection" associated with succConnector :-

2D Reference Help > Material Flow Objects > TwoLaneTrack > Methods of the TwoLaneTrack > succConnector 

Example:   myTwoLaneTrack.B.succConnector.deleteObject 

Re: 14= How does SimTalk disconnect an existing connection between objects?

Gears Phenom Gears Phenom
Gears Phenom

@Old_Sohol  schrieb:

Since deleteObject is inaccurate method name for this action


Well, Connectors are also objects and deleteObject is used for all object-types in PlantSim. But true, the return value could be described better :-D

Sidenote: If you knew the direct path, you could also write .MaterialFlow.Connector1327.deleteObject directly (if Connector1327 would be the one that connects your two stations).

____________________________________________________________
Alex Dilg, Consultant at SimPlan AG (www.SimPlan.de)
This post was good and/or helpful to you? Please provide some Kudos, thank you!

Re: 14= How does SimTalk disconnect an existing connection between objects?

Gears Phenom Gears Phenom
Gears Phenom

@Old_Sohol  schrieb:
Just one question, is there a reason to run the loop downwards?  

It works fine both ways (with only one connection to remove)


That's exactly the point, once there's more than 1 successor at the moment, the direction of the loop would matter (because then you first delete succ#1 and formerly succ#2 becomes succ#1 in its stead, so now for s=2 Station.succconnector(s) would yield VOID), and I prefer to do the loop right for any case.

Judging from your other comments you don't need a loop at all --> SP1.succconnector(1).deleteObject and you're done (provided there always exists exactly one outgoing connector)

____________________________________________________________
Alex Dilg, Consultant at SimPlan AG (www.SimPlan.de)
This post was good and/or helpful to you? Please provide some Kudos, thank you!