Function |
def convert_to_data(s: str):
|
Description |
Converts a string into the proper type of data based on Sumo standards
|
Arguments |
s | the string that contains the data |
returns | integer, float, string or array with the converted data |
|
Example |
print(dtool.convert_to_data("4.0;3.2;8.0"))
# prints [4.0, 3.2, 8.0]
print(dtool.convert_to_data("5.1"))
# prints 5.1
|
|
|
Function |
def read_sumocore_xml(file_name: str) -> dict:
|
Description |
Reads an xml state produced by the SumoCore's "save" command
|
Arguments |
file_name | full path to the file to be loaded |
returns | string -> VariableEntry dictionary, where the key is variable name |
|
|
|
Function |
def write_sumocore_xml(file_name: str, data: dict):
|
Description |
Writes a xml state that can be read to the SumoCore by the "load" command. When using this function you should read an existing state with read_sumocore_xml,
modify it and write it back, to ensure that all variables exist that is present in the model.
|
Arguments |
file_name | full path to the file to be saved |
data | string -> VariableEntry dictionary, where the key is variable name |
returns | - |
|
|
|
Function |
write_sumocore_script(file_name: str, data: dict):
|
Description |
Writes a SumoCore Script (.*scs) that can be used in the SumoCore with the "execute" command.
|
Arguments |
file_name | full path to the file to be saved |
data | string -> value dictionary, where the key is variable name |
returns | - |
|
|
|
Function |
def create_array(begin, end = None, step = None, count = None, includeEnd = True)
|
Description |
Generates an array based on the arguments given. You must define begin, and two out of the three other controlling arguments (end, step, count).
|
Arguments |
begin | the first element of the array |
end | the ending value of the array. If includeEnd is true, this value is included, otherwise its excluded. |
step | the difference between two consecutive elements |
count | the number of elements in the array |
includeEnd | decide if end should be part of the array or not. If end is not defined, this argument has no meaning |
returns | generated array |
|
Example |
dtool.create_array(begin = 1, end = 3, step = 1, includeEnd = True)
[1,2,3]
dtool.create_array(begin = 1, end = 3, count = 2, includeEnd = False)
[1,2]
dtool.create_array(begin = 1, end = 3, count = 2, includeEnd = True)
[1,3]
dtool.create_array(begin = 1, step = 2, count = 3, includeEnd = False)
[1,3,5]
|
|
|
Function |
extract_dll_from_project(project : str, path_to : str):
|
Description |
Extracts the dll file from a .sumo project that can be loaded into SumoCore in order to run simulations
|
Arguments |
project | path to the .sumo file (including filename and extension) |
path_to | path to the output .dll file (including filename and extension) |
returns | - |
|
|
|
Function |
def extract_misc_from_project(project : str, what : str, path_to : str):
|
Description |
Extract any file from the .sumo project. You can use this function to extract saved state.xml files from the project
|
Arguments |
project | path to the .sumo file (including filename and extension) |
what | name of the file that needs to be extracted |
path_to | path to the output file (including filename and extension) |
returns | - |
|
|
|
Function |
def extract_parameters_from_project(project : str, tsvdir : str, script_to : str, scenario : str = "") -> bool:
|
Description |
Extract a script from the project that sets up the parameters as you would see in the Sumo GUI. It also includes dynamic tables.
You can use the "execute" command to run this script in the SumoCore.
|
Arguments |
project | path to the .sumo file (including filename and extension) |
tsvdir | path to a folder that the module can use to save additional files |
script_to | path to the output script file (including filename and extension) |
scenario | scenario to be loaded. If omitted or incorrect, the module will only consider input setup values |
returns | - |
|
|
|
Function |
def create_temp_folder(base : str):
|
Description |
Creates a random, 8 character long folder. Can be used to save extracted Sumo project artifacts, like project dll, initialization scripts etc. These folders can be safely deleted to clean up the Python application folder.
|
Arguments |
base | The random name folder will be created in this folder. Usually it is "." which means the current folder. |
returns | The folder name. |
|
|
|