Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VAServerLauncher
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
VAServerLauncher
Commits
b04fd224
Commit
b04fd224
authored
2 years ago
by
Philipp Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
Launcher: renaming functions/variables and adding minor documentation
parent
e5b2768c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
LaunchScript/VirtualAcousticStarterConfig.json
+1
-1
1 addition, 1 deletion
LaunchScript/VirtualAcousticStarterConfig.json
LaunchScript/VirtualAcousticsStarterServer.py
+22
-17
22 additions, 17 deletions
LaunchScript/VirtualAcousticsStarterServer.py
with
23 additions
and
18 deletions
LaunchScript/VirtualAcousticStarterConfig.json
+
1
−
1
View file @
b04fd224
...
...
@@ -3,7 +3,7 @@
"nLauncherPort"
:
41578
,
"nVAServerPort"
:
12340
,
"nDefaultSleep"
:
3
,
"
t
ReproductionModules"
:
[
"TalkthroughHP"
,
"CTC"
],
"
ls
ReproductionModules"
:
[
"TalkthroughHP"
,
"CTC"
],
"dVAServerDirectories"
:
{
"2018.a"
:
"../v2018.a"
,
...
...
This diff is collapsed.
Click to expand it.
LaunchScript/VirtualAcousticsStarterServer.py
+
22
−
17
View file @
b04fd224
...
...
@@ -25,7 +25,7 @@ class LauncherConfig:
conf
.
nLauncherPort
=
json_config
[
"
nLauncherPort
"
]
conf
.
nVAServerPort
=
json_config
[
"
nVAServerPort
"
]
conf
.
nDefaultSleep
=
json_config
[
"
nDefaultSleep
"
]
conf
.
t
ReproductionModules
=
json_config
[
"
t
ReproductionModules
"
]
conf
.
ls
ReproductionModules
=
json_config
[
"
ls
ReproductionModules
"
]
except
KeyError
as
e
:
print
(
"
ERROR reading the json config. Missing
"
+
str
(
e
.
args
[
0
])
)
sys
.
exit
(
ErrorCodes
.
ERROR_INCOMPLETE_CONFIG
)
...
...
@@ -105,15 +105,16 @@ class VirtualAcousticsLauncher:
self
.
start
()
#Start the launcher
def
start
(
self
):
print
(
"
VirtualAcoustics Starter script - press ctrl+c to quit
"
)
self
.
read
C
onfig
()
self
.
open
LauncherS
erver
S
ocket
()
self
.
run
Launcher
()
self
.
read
_c
onfig
()
self
.
open
_s
erver
_s
ocket
()
self
.
run
()
def
readConfig
(
self
):
#Reads the launcher config and initializes all respective class parameters
def
read_config
(
self
):
sHostConfigurationFile
=
"
VirtualAcousticStarterConfig.
"
+
socket
.
gethostname
()
+
"
.json
"
sGeneralConfigurationFile
=
"
VirtualAcousticStarterConfig.json
"
...
...
@@ -135,7 +136,8 @@ class VirtualAcousticsLauncher:
self
.
oConfig
=
LauncherConfig
(
sUsedConfigFile
)
def
openLauncherServerSocket
(
self
):
#Open network socket used for the communication
def
open_server_socket
(
self
):
print
(
"
Creating server socket at
"
+
self
.
oConfig
.
sLocalIP
+
"
:
"
+
str
(
self
.
oConfig
.
nLauncherPort
)
)
self
.
oLauncherServerSocket
=
socket
.
socket
()
...
...
@@ -149,8 +151,8 @@ class VirtualAcousticsLauncher:
sys
.
exit
(
ErrorCodes
.
ERROR_BINDING_SOCKET
)
self
.
oLauncherServerSocket
.
settimeout
(
1.0
)
def
run
Launcher
(
self
):
#Actually starts the launcher listening for VAServer start requests
def
run
(
self
):
try
:
while
True
:
print
(
"
Waiting for launcher connection...
"
)
...
...
@@ -175,11 +177,11 @@ class VirtualAcousticsLauncher:
self
.
oVAProcess
.
kill
()
self
.
oVAProcess
=
None
sVAServerDir
=
self
.
ReadVAServerIDToStart
()
sVAServerDir
=
self
.
receive_va_server_id
()
if
not
sVAServerDir
:
continue
self
.
S
tart
RequestedVAS
erver
(
sVAServerDir
)
self
.
s
tart
_va_s
erver
(
sVAServerDir
)
except
KeyboardInterrupt
:
print
(
"
Caught keyboard interrupt, quitting
"
)
...
...
@@ -187,7 +189,8 @@ class VirtualAcousticsLauncher:
def
ReadVAServerIDToStart
(
self
):
#Checks for a message containing the ID of the VAServer instance to be started and returns the respective VAServer directory
def
receive_va_server_id
(
self
):
try
:
self
.
sVAServerID
=
self
.
oLauncherConnection
.
recv
(
512
)
if
type
(
self
.
sVAServerID
)
is
bytes
:
...
...
@@ -211,7 +214,8 @@ class VirtualAcousticsLauncher:
return
sVAServerDir
def
StartRequestedVAServer
(
self
,
sVAServerDir
):
#Starts the VAServer from given directory
def
start_va_server
(
self
,
sVAServerDir
):
# Check for VAServer.exe
sVAExecutableFile
=
"
bin/VAServer.exe
"
...
...
@@ -258,7 +262,7 @@ class VirtualAcousticsLauncher:
print
(
"
sending go token
"
)
self
.
oLauncherConnection
.
send
(
b
'
g
'
)
#answer 'go, VAServer is correctly started'
self
.
L
isten
ForR
equests
ByVAServer
()
self
.
l
isten
_for_r
equests
()
#if the above terminates a quit request was received:
# kill VA instance
...
...
@@ -268,7 +272,8 @@ class VirtualAcousticsLauncher:
self
.
oVAProcess
.
kill
()
self
.
oVAProcess
=
None
def
ListenForRequestsByVAServer
(
self
):
#Listens for requests while the VAServer is running
def
listen_for_requests
(
self
):
while
True
:
try
:
sResult
=
self
.
oLauncherConnection
.
recv
(
128
)
...
...
@@ -277,7 +282,7 @@ class VirtualAcousticsLauncher:
#check whether we are about to reveive a file
sMessage
=
sResult
.
decode
(
"
utf-8
"
)
if
sMessage
.
startswith
(
"
file
"
):
self
.
R
eceive
F
ile
(
sMessage
)
self
.
r
eceive
_f
ile
(
sMessage
)
else
:
#NOT sMessage.startswith("file")
print
(
"
Received quit event:
"
+
sMessage
)
break
...
...
@@ -291,7 +296,7 @@ class VirtualAcousticsLauncher:
except
(
KeyboardInterrupt
,
SystemExit
):
raise
#re-raise for higher instance to catch
def
R
eceive
F
ile
(
self
,
sMessage
):
def
r
eceive
_f
ile
(
self
,
sMessage
):
aMessageParts
=
sMessage
.
split
(
"
:
"
)
iBytesToReceive
=
int
(
aMessageParts
[
2
])
Path
,
Filename
=
os
.
path
.
split
(
aMessageParts
[
1
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment