Skip to content
Snippets Groups Projects
Commit 756874c8 authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

VA Launcher: VA Versions now only have the directory as parameter

parent 1078643b
Branches
No related tags found
No related merge requests found
......@@ -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"
}
}
......
......@@ -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" )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment