Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

need help with some methods

Hello everyone

 

I am weak in programming and need help with sample methods.

 

my model has two store objects(1-finished WH, 2-sub Assembly WH).

At first if finished Wh has a part 'A'  and when it is less than 3, then it has to call the another method (method of Sub assemblyWH)

In that method, if Sub assembly Wh has a part B and when it is equal to 3 it should move to required successor, when it is less than 3 then it has to reset the respective source so that it can supply parts to it.

 

Could anyone help me how can i write program for this logic and how can i call these methods whenever required

 

Thanks in advance

 

regards

13 REPLIES

Re: need help with some methods

what do you mean with "when it is less than 3" ?

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


Re: need help with some methods

the quantity of that part in that store

 

Thank you

 

 

 

regards

Re: need help with some methods

first, you should add inventory tables to your stores, than you don't need to search the parts, we have already discussed this topic:

https://community.plm.automation.siemens.com/t5/Plant-Simulation-Forum/Updating-Store-parts-in-inven...

Than the programming is much easier. You can start the method in the entrance control (before actions) of the assembly station, there you can analyse the subassembly and call the parts.

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


Re: need help with some methods

Thank you Mr.Steffen

 

I have added Inventory tables to stores.

 

Actually i want start the simulation from backwards. i wrote the logics as a comment in my model attached below.

the source should start when it receives information from Supermarket in the model.

 

my idea is that i want write an INIT method to check PlantWh first then Simulation executes the logics backwards

 

One more question, how can write a method as a Exit control of store. because there is no exit control in store tab 

 

regards

Re: need help with some methods

unfortunately, I cannot read your code (because you use a non-commercial license).

- you cannot write an exit control of the store,but you should have a control for taking out parts from the store; this you can trigger e.g. with the container in the entrance control of the assembly station...

You need to delete the inventory in the init-method.

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


Re: need help with some methods

Thank you very much Mr.steffen

 

I want to write the method in the following way, please correct me.

I have locked all the sources at first with first Init method (source.exitlocked:=true).

the next init method starts as follows

 

Init method :

is
do
if plant_WH.numMU <3 then
ref(S_market).methcall(0);
end;

Then the method (S_Market) is as follows which i don't know how to write exactly.

is
i:integer;
k:integer;
do
for i:=1 to store.xdim loop
for k:=1 to store.ydim loop
if store.pe(i,k).cont /=void and Store.pe(i,k).cont.name="Lower_Hfshell_red" and then
store.pe(i,k).cont.move(Motor_Assembly);

elseif store.pe(i,k).cont.name="lower_hfshell_red" <3 then 

Source .exitlocked:=false

end;

next;

next;

 As i don't know the exact syntax, could you please help me in writing this 

 

Thank you very much

 

Regards

 

Solution
Solution
Accepted by topic author gopi
‎09-19-2016 10:38 AM

Re: need help with some methods

[ Edited ]

if you want to move one Lower_Hfshell_red and reorder, if the inventory is below 3, this may help (I use the inventory):

is
  i:integer;
   k:integer;
 do
    for i:=1 to store.xdim loop
     for k:=1 to store.ydim loop
       if store.pe(i,k).cont /=void and Store.pe(i,k).cont.name="Lower_Hfshell_red" then
         store.pe(i,k).cont.move(Motor_Assembly); 
         --reduce the inventory
         inventory[1,"lower_hfshell_red"]:= inventory[1,"lower_hfshell_red"]-1;
         exitLoop 2;
       end;
     next;
    next;
    --reorder, if inventory is below 3
    if inventory[1,"lower_hfshell_red"] <3 then 
      Source.exitlocked:=false;
    end;

end;

Remark: you cannot move parts directly to the assemblyStation (this is possible from version 13), so you will get a error message

 


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


Re: need help with some methods

Thank you very much Steffen for your valuable time.

 

I will follow your suggestions and try to write a required program.

 

 

Regards

 

 

Re: need help with some methods

Hello Mr. Steffen

 

I am getting an error message " the max depth of Calls was exceeded".

But my Init method only calls other method once. 

 

I have changed Max depth calls (model settings-- simulation), but still it is showing the same message.

Is there any solution for this?

 

Thank you very much

 

Regards