Assembler B.O.M. list

All topics on coding 4Dscript in Enterprise Dynamics.
Post Reply
Taid
Posts: 7
Joined: Wednesday 22 April, 2015 - 16:20

Assembler B.O.M. list

Post by Taid »

Hello,

Currently I'm trying to include dynamic B.O.M with my assembler, in short what i'm trying to do is:

I have a fixed size container to which I pack many different sized product, I do the calculation of how many of each product can fit into 1 container.
At the moment I do 2 checks,
1. If there is an atom inside of the container in the assembler,
2. If the name of atom that entered queue before assembler has the same name as the last atom in the container

Depending on the result I modify the B.O.M list. for example if product 1 can fit 200 atoms into the container but only 50 arrive before another product comes along, I want to update B.O.M and ship the container with 50 atoms and open up slot for another product.

From my understanding the below code should work just fine, but afaik there might be problem with when Events occur in simulation and the B.O.M table sometimes doesn't update correctly, especially after reset and often the assembler becomes "stuck" and doesn't send a ready product with container forward.

Any help would be appreciated.

Code: Select all

 Do(
  CloseOutput(c),
 Case (
  WhichIsTrue(
                         AtomExists(First(First(AtomByName([Assembler9],Model)))) = false,
                         CompareText(Name(i),Name(First(First(AtomByName([Assembler9],Model))))) = true,
                         CompareText(Name(i),Name(First(First(AtomByName([Assembler9],Model))))) = false),
            Do(
                  SetCell(2,2,Label([Pak], i), AtomByName([Assembler9],Model)),
                  OpenOutput(c)
                 ),
            Do(
                  SetCell(2,2,Label([Pak], i), AtomByName([Assembler9],Model)),
                  OpenOutput(c)
                 ),
            Do(
                  {ClearRow(2,AtomByName([Assembler9],Model)),   } 
                  SetCell(2,2,Content(First(AtomByName([Assembler9],Model))), AtomByName([Assembler9],Model)),
                  SetCell(2,2,Label([Pak], i), AtomByName([Assembler9],Model)),
                  ExecEvent(OnEvent,AtomByName([Assembler9],Model)),
                  
                  OpenOutput(c)
                  )   
           )
          )   
Taid
Posts: 7
Joined: Wednesday 22 April, 2015 - 16:20

Re: Assembler B.O.M. list

Post by Taid »

Hello!

I think I found out why the assembler behaved like it did. From my point of view the process looks like this:
1. Assembler opens channel for container(s),
2. triggers onEntered Event and stores the value from B.O.M inside an attribute #7 called finishquant.
This is done only when container(s) enter the assembler, so if there is a change to B.O.M after that event the attribute value won't change and finishquant will have old value.
My walk around is to set the value in B.O.M but also assign that same ( + any number of containers, since finishquant is products + containers) to the attribute without triggering the event of a container entering assembler. So far everything seems to be working just fine.

Below the changed code, I know some of the lines probably don't need to be there but I kept them just to be sure :D

Code: Select all

 Do(
  CloseOutput(c),
 Case (
  WhichIsTrue(
                         AtomExists(First(First(AtomByName([Assembler199],Model)))) = false,
                         CompareText(Name(First(c)),Name(First(First(AtomByName([Assembler199],Model))))) = true,
                         CompareText(Name(First(c)),Name(First(First(AtomByName([Assembler199],Model))))) = false),
            Do(
                   SetCell(2,1,(Round(1 / Label([Szerokosc_profilu],i)))* (Round(0.540 / 
                   Label([Wysokosc_profilu],i))),AtomByName([Assembler199],Model)),
                   Att(7,AtomByName([Assembler199],Model)):= (Round(1 / Label([Szerokosc_profilu],i)))*
                   (Round(0.540 / Label([Wysokosc_profilu],i))) + 1,                  
                   OpenOutput(c)
                 ),
            Do(
                  SetCell(2,1,(Round(1 / Label([Szerokosc_profilu],First(First(AtomByName([Assembler199],Model))))))* 
                  (Round(0.540 / Label([Wysokosc_profilu],First(First(AtomByName([Assembler199],Model)))))),
                  AtomByName([Assembler199],Model)),
                  Att(7,AtomByName([Assembler199],Model)):=(Round(1 / Label([Szerokosc_profilu],i)))*(Round(0.540 / 
                  Label([Wysokosc_profilu],i))) + 1,
                  OpenOutput(c)
                  
                 ),
            Do(
                  SetCell(2,1,Content(First(AtomByName([Assembler199],Model))), AtomByName([Assembler199],Model)),
                  Att(7,AtomByName([Assembler199],Model)):= Content(First(AtomByName([Assembler199],Model))) + 1,
                  OpenOc(1,AtomByName([Assembler199],Model)),
                  SetCell(2,1,(Round(1 / Label([Szerokosc_profilu],i)))*(Round(0.540 / 
                  Label([Wysokosc_profilu],i))),AtomByName([Assembler199],Model)),
                  Att(7,AtomByName([Assembler199],Model)):=(Round(1 / Label([Szerokosc_profilu],i)))*(Round(0.540 / 
                  Label([Wysokosc_profilu],i))) + 1,                  
                  OpenOutput(c)
                  )   
           )
          )   
Post Reply