MCPcopy Create free account
hub / github.com/PJLab-ADG/OASim / updateScene

Method updateScene

limsim/simModel/fixedScene/localScene.py:213–243  ·  view source on GitHub ↗
(self, dataBase: str, timeStep: int)

Source from the content-addressed store, hash-verified

211 return edges, juncs
212
213 def updateScene(self, dataBase: str, timeStep: int):
214 NowTLs = {}
215 conn = sqlite3.connect(dataBase)
216 cur = conn.cursor()
217 cur.execute(
218 """SELECT * FROM trafficLightStates WHERE frame=%i;""" % timeStep
219 )
220 tlsINFO = cur.fetchall()
221 if tlsINFO:
222 for tls in tlsINFO:
223 frame, tlid, currPhase, nextPhase, switchTime = tls
224 NowTLs[tlid] = (currPhase, nextPhase, switchTime)
225
226 cur.close()
227 conn.close()
228
229 if NowTLs:
230 for jid in self.junctions:
231 junc = self.netInfo.getJunction(jid)
232 if junc:
233 for jlid in junc.JunctionLanes:
234 jl = self.netInfo.getJunctionLane(jlid)
235 tlid = jl.tlLogic
236 if tlid:
237 try:
238 currPhase, nextPhase, switchTime = NowTLs[tlid]
239 except KeyError:
240 continue
241 jl.currTlState = currPhase[jl.tlsIndex]
242 jl.nexttTlState = nextPhase[jl.tlsIndex]
243 jl.switchTime = switchTime
244
245 def updateSurroundVeh(self):
246 for vid in self.outOfRange:

Callers

nothing calls this directly

Calls 2

getJunctionMethod · 0.80
getJunctionLaneMethod · 0.80

Tested by

no test coverage detected