question

chao.g avatar image
1 Like"
chao.g asked michael.smith commented

Data Import into simulation

If I have 100 processors in a model, I need to setup process time information, I can certainly read those from excel into a global table, but still I have to go into each individual processor to setup link to right location of table, that's really time consuming, can I do this in a central location, say on model reset trigger, where I finish all the data read process, that way, I can update them in just one location instead of 100 locations, same question applies for MTTR/MTBF for these 100 stations, I don't want to define them individually and then assign value and logic to them. Can someone provide a sample model, maybe with 3 or 5 processors of how this can be done?

FlexSim 16.1.0
global tableexcel importprocess timeuser commandreset trigger
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Brandon Peterson avatar image
3 Likes"
Brandon Peterson answered Brandon Peterson edited

Chao,

Here is a sample model that uses a global table to supply processors with their names and process times. The model demonstrates four methods for automatically updating the row value for each processor. In all cases the names of the processors are updated on reset and a label called "PRow" is set on the processor with the global table row it needs to use for processing. The process time data in the global table is stored as a string that is executed by the process trigger.

The first two methods (Top two model flows) use center port connections to define the processor's row in the global table. In the flow on the left side the reset trigger of each processor is responsible for obtaining the center port connection rank and updating the name and PRow label on the processor. In the flow on the right side the reset trigger of object "ProcessorCPConnection2" updates the names and sets the PRow label for all of the processors connected to it.

The last two methods (Bottom two model flows) use a container rank to define the processor's row in the global table. In both flows the processors are contained in the 2x2 green visual plane object at the top left of the flow. In the flow on the left side the reset trigger of each processor is responsible for obtaining the processor's rank in the visual plane and updating the name and PRow label accordingly. In the flow on the right side the reset trigger of the visual plane updates the names and sets the PRow label for all of the processors contained inside of it.

In all four methods:

  • You can very easily update the processor names and process times by changing the values in the global table.
  • You can easily remove processors from the model by:
    • deleting the processor and updating the global table accordingly (deleting the corresponding row)
  • You can easily add processors to the model by:
    • Top Models (center port connection)
      • Create a copy of an existing processor
      • Create the center port connection
      • Add a row to the global table and fill in the appropriate data
  • Bottom Models (Container)
    • Create a copy of an existing processor (make sure it is placed in the visual plane with the other processors)
    • Add a row to the global table and fill in the appropriate data

I hope this gives a good starting point,

Brandon


· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Steven Hamoen avatar image
3 Likes"
Steven Hamoen answered michael.smith commented

Hi Chao,

What if you would make a usercommand (for instance for the reset trigger), write the call to this user command on the resettrigger of 1 of your processors. Then select all other processors and copy the onreset trigger from this 1 processor to all other processors by using the "edit selected objects".

That way there is only 1 place where there is code that you have to change and that is your usercommand. The copying has to be done only once and is very easy. You could also put all processors in a group so you can easily select them again later on if you need to copy another piece of code on all processors.

Steven

· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Will Bishop avatar image
0 Likes"
Will Bishop answered

@chao.gao,

I think I understand what you are going for. I want the same thing -- centrally managing model inputs (like processor cycle times and MTBF/MTTR downtime) and deploying updates quickly and programmatically. I followed your suggestion to use custom flexscript code in a Model Trigger "OnModelReset" to update Processor cycle times.

The code below (run on model reset) programmatically updates Process cycle times for Processors listed in a pair of Global Tables (imported from an Excel file "data/inputs.xlsx"). I broke the input data into two tables: a "cycle_time" table that gives cycle time expressions for each manufacturing "Step", and an "equipment" table that maps individual equipment (i.e. Processors) to the appropriate manufacturing "Step". The code does the following:

  1. Query cycle time expressions (defined by Step) for each equipment Processor.
  2. Loop through each query record to [A] load the matching named Processor node (if it exists), and [B] updated the "cycletime" variable node.
  1. /**Custom Code*/
  2. treenode processor; // processor node
  3. treenode ct; // processor cycletime node
  4.  
  5. // query equipment cycle times
  6. query("SELECT s.STEP AS STEP, \
  7. e.EQUIPMENT AS EQUIPMENT, \
  8. s.CT_DIST AS CT_DIST \
  9. FROM gt_equipment e, gt_cycle_time s \
  10. WHERE e.STEP = s.STEP");
  11. // loop through each equipment record and update cycletime
  12. int n_rows = getquerymatchcount();
  13. for (int i = 1; i <= n_rows; i++) {
  14. // get the processor node that matches the current equipment record
  15. processor = node(getqueryvalue(i, "EQUIPMENT"), model());
  16. // load and update the 'cycletime' variable for the current processor
  17. ct = getvarnode(processor, "cycletime");
  18. setnodestr(ct, concat("treenode current = ownerobject(c); \n",
  19. "treenode item = param(1); \n",
  20. "return /**/", getqueryvalue(i, "CT_DIST"), "/**direct*/;"));
  21. }

This seems to work with one big caveat. When you make an update to the Excel file, you need to click "Reset" twice -- the first time imports the excel changes (after enabling the "Import table on Model Reset" feature), and the second time runs the script above with the new Global Table data. It seems like the Excel import happens after the "OnModelReset" script is run. Maybe this can be changed, or maybe the Excel import can be triggered from within the flexscript code to avoid this.

It seems like this method can hopefully be used to update any variable in a Processor node (or any node)model-inputs.zip.

See the attached .zip file for the example model and Excel data file.


model-inputs.zip (33.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.