Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ table = Table(plantsim, 'TableName')
print(table)
```

An example, together with a simple simulation model, can be found in [example](example/).

## Setup

Expand Down
28 changes: 28 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Example

![](network.png)

This directory provides an example of a simple simulation to show how variables could be set,
the simulation could be controlled and results in variables and tables could be fetched.

The simulation model was created in PlantSimulation 16.1.6.

## Simulation model
This is a simple example of simulation model.
It's a simple source - processing - sink process,
where you can adapt the processingTime of the
station by updating the variable procTime.
On every item reaching the sink, an entry
is added to the ResultTable and ResultTable1.
Additionally, the totalSinks are counted, even
though they are equal to Senke.StatAnzahlEin.
But this is just a simple example to see how this
value can be accessed by the script.

The variable procTimeT is currently unsued, only
for showing how to set a time value by using a
simtalk lambda function in the script.

## Usage
Ensure you've installed the ``plantsim``-package before executing the examples, e.g. using pip.
Afterwards just run the example.py.
39 changes: 39 additions & 0 deletions example/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
import time

from plantsim.plantsim import Plantsim
from plantsim.table import Table


plantsim = Plantsim(version='16.1', license_type='Research')#, visible=False)
plantsim.load_model(os.getcwd() + '\model.spp')

plantsim.set_path_context('.Modelle.Modell')

plantsim.set_value('procTime', '30:00.00000')
# if you want to set the time as a real time you can do this by executing a
# simtalk lambda function
#plantsim.execute_simtalk("procTimeT := str_to_time(\"45:00.0\")")

# do the simulation run
plantsim.set_event_controller()
plantsim.reset_simulation()
plantsim.start_simulation()

# wait until the simulation has finished
while plantsim.is_simulation_running():
time.sleep(0.1)

# get main kpi
print("Counted sinks in totalSinks:", plantsim.get_value('totalSinks'))
print("Statistic value (parts in) of sink:", plantsim.get_value('Senke.StatAnzahlEin'))

# print table with indexes
table = Table(plantsim, 'ResultTable')
print(table)

# print table without index
table1 = Table(plantsim, 'ResultTable1')
print(table1)

plantsim.quit()
Binary file added example/model.spp
Binary file not shown.
Binary file added example/network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.