Tutorial X: …
This Tutorial demonstrates …
SIR 3S Installation
[ ]:
SIR3S_SIRGRAF_DIR = r"C:\3S Consult\Sir3S-90 Entwicklerversionen\SirGraf-90-15-00-12_Quebec_x64" #change to local path
Imports
Note: The SIR 3S Toolkit requires the Sir3S_Toolkit.dll included in SIR 3S installations (version Quebec and higher).
[7]:
import sir3stoolkit
The core of sir3stoolkit is a Python wrapper around basic functionality of SIR 3S, offering a low-level access to the creation, modification and simulation of SIR 3S models. In the future pure python subpackages may be added.
[9]:
from sir3stoolkit.core import wrapper
[11]:
sir3stoolkit
[11]:
<module 'sir3stoolkit' from 'C:\\Users\\aUsername.3S.000\\AppData\\Local\\anaconda3\\Lib\\site-packages\\sir3stoolkit\\__init__.py'>
The wrapper package has to be initialized with reference to a SIR 3S (SirGraf) installation.
[13]:
wrapper.Initialize_Toolkit(SIR3S_SIRGRAF_DIR)
Initialization
The SIR 3S Toolkit contains two classes: SIR3S_Model (model and data) and SIR3S_View (depiction in SIR Graf). All SIR 3S Toolkit functionality is accessed via the methods of these classes.
[16]:
s3s = wrapper.SIR3S_Model()
Initialization complete
[17]:
s3s_view = wrapper.SIR3S_View()
Initialization complete
Create New Model
We are using the NewModel() function of SIR3S_Model() to create a new db3 file.
[23]:
dbFilePath=r"Toolkit_TutorialX_Model.db3"
[25]:
s3s.NewModel(dbName=dbFilePath,
providerType=s3s.ProviderTypes.SQLite,
namedInstance="",
netType=s3s.NetworkType.Undefined,
modelDescription="Tutorial X Model",
userID="",
password="")
New model is created with the model identifier: M-2-0-1
Now the model has been created and is opened. All SIR 3S Toolkit operations now apply to this model until another one is opened. If there already existed a model file with this path and name, a new model with the same name but incremented model identifier is created.
[30]:
print(s3s.GetNetworkType()) # to check that the model is responsive
NetworkType.Undefined
Open Model
[32]:
dbFilePath=r"Toolkit_TutorialX_Model.db3"
[33]:
s3s.OpenModel(dbName=dbFilePath,
providerType=s3s.ProviderTypes.SQLite,
Mid="M-1-0-1",
saveCurrentlyOpenModel=False,
namedInstance="",
userID="",
password="")
Model is open for further operation
Now the model has been opened and the previous one has been closed without saving it. All SIR 3S Toolkit commands now apply to this model until another one is opened.
[35]:
print(s3s.GetNetworkType()) # to check that the correct model is responsive, model we are trying to open was created with type Undefined
NetworkType.Undefined
…