/
simulation_build.py
108 lines (89 loc) · 2.54 KB
/
simulation_build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import pyhelios
from threading import Condition as CondVar
PYHELIOS_SIMULATION_BUILD_CONDITION_VARIABLE = CondVar()
class SimulationBuild:
"""SimulationBuild represents a PyHelios simulation built through a
SimulationBuilder.
Attributes:
sim -- The PyHeliosSimulation instance
"""
# --- CONSTRUCTOR --- #
# --------------------- #
def __init__(
self,
surveyPath,
assetsDir,
outputDir,
numThreads,
lasOutput,
las10,
zipOutput,
copy=False,
fixedGpsTimeStart="",
kdtFactory=4,
kdtJobs=0,
kdtSAHLossNodes=32,
parallelizationStrategy=1,
chunkSize=32,
warehouseFactor=4
):
if copy:
return
self.sim = pyhelios.Simulation(
surveyPath,
assetsDir,
outputDir,
numThreads,
lasOutput,
las10,
zipOutput,
kdtFactory,
kdtJobs,
kdtSAHLossNodes,
parallelizationStrategy,
chunkSize,
warehouseFactor
)
self.sim.fixedGpsTimeStart = fixedGpsTimeStart
# --- CONTROL METHODS --- #
# ------------------------- #
def start(self):
self.sim.start()
def pause(self):
self.sim.pause()
def stop(self):
self.sim.stop()
def resume(self):
self.sim.resume()
def join(self):
# Conditional variable necessary for callback mode
with PYHELIOS_SIMULATION_BUILD_CONDITION_VARIABLE:
output = self.sim.join()
while not output.finished:
PYHELIOS_SIMULATION_BUILD_CONDITION_VARIABLE.wait()
output = self.sim.join()
return output
# --- C O P Y --- #
# ----------------- #
def copy(self):
"""Do a copy of this SimulationBuild.
Return:
SimulationBuild which is a copy of current one
"""
copySim = SimulationBuild(None, None, None, None, None, None, True)
copySim.sim = self.sim.copy()
return copySim
# --- GETTERS and SETTERS --- #
# ----------------------------- #
def isStarted(self):
return self.sim.isStarted()
def isPaused(self):
return self.sim.isPaused()
def isStopped(self):
return self.sim.isStopped()
def isFinished(self):
return self.sim.isFinished()
def isRunning(self):
return self.sim.isRunning()
def getScanner(self):
return self.sim.getScanner()