(self,
dataBase: str,
dataBase2: str = None,
startFrame: int = None,
simNote: str = ''
)
| 18 | |
| 19 | class InterReplayModel: |
| 20 | def __init__(self, |
| 21 | dataBase: str, |
| 22 | dataBase2: str = None, |
| 23 | startFrame: int = None, |
| 24 | simNote: str = '' |
| 25 | ) -> None: |
| 26 | print('[green bold]Model initialized at {}.[/green bold]'.format( |
| 27 | datetime.now().strftime('%H:%M:%S.%f')[:-3] |
| 28 | )) |
| 29 | |
| 30 | self.sim_mode: str = 'InterReplay' |
| 31 | self.dataBase = dataBase |
| 32 | conn = sqlite3.connect(self.dataBase) |
| 33 | cur = conn.cursor() |
| 34 | |
| 35 | # minTimeStep |
| 36 | cur.execute("""SELECT MAX(frame) FROM frameINFO;""") |
| 37 | maxTimeStep = cur.fetchone()[0] - 200 |
| 38 | if maxTimeStep < 0: |
| 39 | maxTimeStep = 0 |
| 40 | cur.execute("""SELECT MIN(frame) FROM frameINFO;""") |
| 41 | minTimeStep = cur.fetchone()[0] |
| 42 | if startFrame: |
| 43 | if startFrame > maxTimeStep: |
| 44 | print( |
| 45 | '[yellow]The start frame is too large, and is reassigned to[/yellow] %i.' % maxTimeStep) |
| 46 | self.timeStep = maxTimeStep |
| 47 | elif startFrame < minTimeStep: |
| 48 | print( |
| 49 | '[yellow]The start frame is too small, and is reassigned to[/yellow] %i.' % minTimeStep) |
| 50 | self.timeStep = minTimeStep |
| 51 | else: |
| 52 | self.timeStep = startFrame |
| 53 | else: |
| 54 | self.timeStep = minTimeStep |
| 55 | |
| 56 | self.startFrame = self.timeStep |
| 57 | |
| 58 | self.tpEnd = 0 |
| 59 | |
| 60 | self.rb = Rebuild(dataBase) |
| 61 | self.rb.getData() |
| 62 | self.rb.buildTopology() |
| 63 | |
| 64 | # get initialized ego car with origin position |
| 65 | cur.execute("""SELECT * FROM simINFO;""") |
| 66 | simINFO = cur.fetchone() |
| 67 | _, localPosx, localPosy, radius, egoID, _, _, _ = simINFO |
| 68 | if radius: |
| 69 | self.dv = DummyVehicle(localPosx, localPosy, radius) |
| 70 | else: |
| 71 | raise TypeError('Please select the appropriate database file.') |
| 72 | |
| 73 | cur.close() |
| 74 | conn.close() |
| 75 | |
| 76 | if dataBase2: |
| 77 | self.dataBase2 = dataBase2 |
nothing calls this directly
no test coverage detected