diff --git a/LaunchScript/VirtualAcousticStarterConfig.json b/LaunchScript/VirtualAcousticStarterConfig.json index 0da0710d8abe8b407285fcb7442ece7aa12234c0..134e6ec2a8bf4907526a31311e86f872d768b1ff 100644 --- a/LaunchScript/VirtualAcousticStarterConfig.json +++ b/LaunchScript/VirtualAcousticStarterConfig.json @@ -5,12 +5,11 @@ "nDefaultSleep": 3, "tReproductionModules": ["TalkthroughHP", "CTC"], - "tVirtualAcousticVersions": { - "2018.a": { "file": "bin/VAServer.exe", "dir": "../v2018.a", "params": "localhost:12340 conf/VACore.ini" }, - "2019.a": { "file": "bin/VAServer.exe", "dir": "../v2019.a", "params": "localhost:12340 conf/VACore.ini" }, - "2020.a": { "file": "bin/VAServer.exe", "dir": "../v2020.a", "params": "localhost:12340 conf/VACore.ini" }, - "2022.a": { "file": "bin/VAServer.exe", "dir": "../v2022.a", "params": "localhost:12340 conf/VACore.ini" }, - "2020.a_AirTraffic": { "file": "bin/VAServer.exe", "dir": "../v2020.a", "params": "localhost:12340 conf/VACore.ATNRenderer.ini" } + "dVAServerDirectories": { + "2018.a": "../v2018.a", + "2019.a": "../v2019.a", + "2020.a": "../v2020.a", + "2022.a": "../v2022.a" } } diff --git a/LaunchScript/VirtualAcousticsStarterServer.py b/LaunchScript/VirtualAcousticsStarterServer.py index 4f60d0cfa70778c52d06e9ed275ae9209d913f0b..46c1524cf8ac41d6519ae41c435b87e7e41c51d7 100644 --- a/LaunchScript/VirtualAcousticsStarterServer.py +++ b/LaunchScript/VirtualAcousticsStarterServer.py @@ -16,7 +16,7 @@ class LauncherConfig: json_config = json.load(json_file) try: - conf.dVirtualAcousticVersions = json_config["tVirtualAcousticVersions"] + conf.dVirtualAcousticDirectories = json_config["dVAServerDirectories"] conf.sLocalIP = json_config["sLocalIP"] conf.nLauncherPort = json_config["nLauncherPort"] conf.nVAServerPort = json_config["nVAServerPort"] @@ -107,11 +107,11 @@ class VirtualAcousticsLauncher: self.oVAProcess.kill() self.oVAProcess = None - dVAServerToStart = self.ReadVAServerIDToStart() - if not dVAServerToStart: + sVAServerDir = self.ReadVAServerIDToStart() + if not sVAServerDir: continue - self.StartRequestedVAServer(dVAServerToStart) + self.StartRequestedVAServer(sVAServerDir) except KeyboardInterrupt: print( "Caught keyboard interrupt, quitting" ) @@ -131,64 +131,55 @@ class VirtualAcousticsLauncher: return None else: try: - dVAServerInstance = self.oConfig.dVirtualAcousticVersions[self.sVAServerID] + sVAServerDir = self.oConfig.dVirtualAcousticDirectories[self.sVAServerID] except KeyError: - dVAServerInstance = None + sVAServerDir = None - if not dVAServerInstance: + if not sVAServerDir: print( 'Requested VA Instance "' + self.sVAServerID + '" not available' ) self.oLauncherConnection.send( b'f' ) #answer 'requested version not available self.oLauncherConnection.close() return None - return dVAServerInstance + return sVAServerDir - def StartRequestedVAServer(self, tInstance): - try: - sWorkingDir = tInstance["dir"] - except KeyError: - sWorkingDir = None + def StartRequestedVAServer(self, sVAServerDir): + # Check for VAServer.exe + sVAExecutableFile = "bin/VAServer.exe" try: - self.sVAExecutableFile = tInstance["file"] - if not os.path.isfile( self.sVAExecutableFile ): - if sWorkingDir and os.path.isfile( sWorkingDir + "/" + self.sVAExecutableFile ): - self.sVAExecutableFile = sWorkingDir + "/" + self.sVAExecutableFile + if not os.path.isfile( sVAExecutableFile ): + if sVAServerDir and os.path.isfile( sVAServerDir + "/" + sVAExecutableFile ): + sVAExecutableFile = sVAServerDir + "/" + sVAExecutableFile else: - print( "ERROR: Invalid config for " + self.sVAServerID + " -- file " + self.sVAExecutableFile + " does not exist" ) + print( "ERROR: Invalid config for " + self.sVAServerID + " -- file " + sVAExecutableFile + " does not exist" ) self.oLauncherConnection.send( b'n' ) #answer 'binary file cannot be found or invalid' return - elif sWorkingDir == None: - sWorkingDir = os.path.dirname( self.sVAExecutableFile ) + elif sVAServerDir == None: + sVAServerDir = os.path.dirname( sVAExecutableFile ) #TODO-PSC: VAServer should always be started from its main directory, not the "bin" folder except KeyError: - self.sVAExecutableFile = None + sVAExecutableFile = None print( "ERROR: config for " + self.sVAServerID + " has no valid \"file\" entry" ) self.oLauncherConnection.send( b'i' ) #answer 'invalid file entry in the config' self.oLauncherConnection.close() return - if not self.sVAExecutableFile: + if not sVAExecutableFile: return - - sCommand = self.sVAExecutableFile - try: - sParams = tInstance["params"] - sCommand = sCommand + ' ' + sParams - except KeyError: - sParams = None - try: - nSleep = tInstance["sleep"] - except KeyError: - nSleep = self.oConfig.nDefaultSleep + # Create start command + sConnectionParam = self.oConfig.sLocalIP + ":" + str( self.oConfig.nVAServerPort ) + sVACoreIniParam = "conf/VACore.ini" + sParams = sConnectionParam + " " + sVACoreIniParam + sCommand = sVAExecutableFile + " " + sParams # start instance print( 'executing "' + sCommand + '"' ) - self.oVAProcess = subprocess.Popen( sCommand, cwd = sWorkingDir, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP ) + self.oVAProcess = subprocess.Popen( sCommand, cwd = sVAServerDir, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP ) # wait for requested duration before sending the go signal - time.sleep( nSleep ) + time.sleep( self.oConfig.nDefaultSleep ) if self.oVAProcess.poll() != None: print( "VA Process died - sending abort token" )