Function |
def schedule (self, model, commands, variables, blockDatacomm=False, jobData=None)
|
Description |
Schedules a new simulation. Simulations will not run immediately, they use defined callbacks to communicate.
|
Arguments |
model | Path to the model .dll file extracted from Sumo (sumoproject.dll in the .sumo file) |
commands | List of commands to the simulation engine. Consult the SumoCore command documentation for availabe commands. |
variables | List of variables to listen to. Variable names can be copied from Sumo's Advanced -> Core Window. |
blockDatacomm | Should the simulation wait while python decides what to do? Set this to true, if you wish to control the simulation, but keep it false otherwise for faster results. |
jobData | Extra information (dictionary) stored with the job, you might access later. You may set the sumo.persistent flag to keep the data once the simulation is finished. |
returns | This function returns the JobID that you can reference to identify the simulation. |
|
Example |
job1 = ds.sumo.schedule(
"sumoproject.dll"
commands = [
f"load state.xml",
f"set Sumo__StopTime {10*ds.sumo.dur.day};",
f"set Sumo__DataComm {1*ds.sumo.dur.hour};",
f"set Sumo__Plant__Influent__param__frSNHx_TKN 2;",
"mode dynamic;",
"start;"],
variables = ["Sumo__Time",
"Sumo__Plant__Effluent__SNOx",
"Sumo__Plant__Effluent__SPO4"],
jobData = {
ds.sumo.persistent: True,
"results" : { }
},
);
|
|
|
Function |
def sendCommand(self, job, command)
|
Description |
Sends a command to a job. If you send commands to a simulation that hasn't started yet, it'll get executed when it starts.
|
Arguments |
|
Example |
ds.sumo.sendCommand(job1, "pause")
|
|
|
Function |
def sendCommands(self, job, commands)
|
Description |
Sends a list of commands to a job. If you send commands to a simulation that hasn't started yet, it'll get executed when it starts.
|
Arguments |
job | Id of the target job |
commands | A list of commands to the simulation engine. Consult the SumoCore command documentation for availabe commands. |
returns | - |
|
Example |
ds.sumo.sendCommands(job1, ["set Sumo__StopTime 86400000", "set Sumo__DataComm 3600000", "start"])
|
Notes |
No need for closing semicolon character.
|
|
|
Function |
def getJobData(self, jobId):
|
Description |
Gets the data you assigned to the job when you scheduled it. You may modify it and it will keep the changes.
|
Arguments |
jobId | Id of the target job |
returns | The dictionary you defined when you called schedule function. If you didn't define any job data there, this function returns null |
|
Example |
jobData = ds.sumo.getJobData(job)
|
|
|
Function |
def finish(self, job)
|
Description |
Finish the job with the given job id, so other jobs may run. You may only finish jobs that have started running. You may not finish jobs that were scheduled but not ran yet.
Often you'll want to finish a job when its simulation is finished. When a job is finished, its jobData is cleared unless sumo.persistent flag was set.
|
Note |
Usually it's better to only do one simulation per job. The scheduler optimizes jobs to run in the some process if possible to reduce overhead,
but if you overuse a single job, it can cause slowdown on that job. You may impact other jobs as well, if they never get to run.
|
Arguments |
job | the id of the job that you want to finish |
returns | - |
|
Example |
def msg_callback(job, msg):
if (ds.sumo.isSimFinishedMsg(msg)):
ds.sumo.finish(job)
|
|
|