How to import data from global table to empirical distribution table

How to import data from global table to empirical distribution table

hhnaing2
Not applicable
12 Views
5 Replies
Message 1 of 6

How to import data from global table to empirical distribution table

hhnaing2
Not applicable

[ FlexSim 23.2.0 ]

Hi,

I would like to connect to SQL server from the production line to pull the past one month uptime and downtime data of the machine. Upon accessing SQL server, it looks like data will be imported to global table. Then, how to import the data from global table to Empirical table automatically. That means once the model starts running, model connect to SQL sever and retrieve data then data will be imported to global table then empirical table. Would that be possible? if yes, appreciate if you could help to make a simple example model. Thanks a lot.

1692319220099.png


0 Likes
Accepted solutions (1)
13 Views
5 Replies
Replies (5)
Message 2 of 6

moehlmann_fe
Observer
Observer
Accepted solution

You can use the code below to copy the table into the distribution. Just replace the distribution and table names so they match your model.

treenode distributionTable = Model.find("/Tools/EmpiricalDistributions/TestName>variables/data");
Table("TestTable").cloneTo(distributionTable.as(Table));
0 Likes
Message 3 of 6

hhnaing2
Not applicable

Where should this code be written? Global table>>on reset>> script edit? Thanks.

1692346707859.png

0 Likes
Message 4 of 6

jason_lightfootVL7B4
Autodesk
Autodesk

How often do you need it updated? If it's once then just put it in the script console and run it from there.

0 Likes
Message 5 of 6

hhnaing2
Not applicable
I want to update every time the model runs.
0 Likes
Message 6 of 6

jason_lightfootVL7B4
Autodesk
Autodesk

If you have other things that might sample the distribution at reset then you should do it either on reset (you may not be able to control the timing of this - it's based on which object you place the code), or you can use a parameter table entry OnSet trigger to run the code which then happens before all reset triggers fire.