-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpipe_external.txt
40 lines (31 loc) · 1.07 KB
/
pipe_external.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from X4_Python_Pipe_Server import Pipe_Server
# TODO: Test if this works and makes sense on Windows
# Probably needs adjustments 🤷
# This file is Windows only. The Linux variant does not use
# this so I have no test or use case. -- beko
#
# development options
# enable it to write received data to a file
isDevelopment = False
dataOutputFilename = "x4_simpit.json"
# pipe names
pipeInName = 'x4simpit'
pipeOutName = 'x4simpit_out'
def main(args):
print('###: Starting X4 Simulated_Cockpit module')
# start pipe to X4 game
pipeIn = Pipe_Server(pipeInName)
pipeIn.Connect()
print('###: Created '+ pipeInName +' pipe.')
# start pipe to Node.js
pipeOut = Pipe_Server(pipeOutName)
pipeOut.Connect()
print('###: Created '+ pipeOutName +' pipe.')
while 1:
message = pipeIn.Read()
# development purpose - save to file
if isDevelopment:
f = open(dataOutputFilename, "w", encoding='utf-8')
f.write(message)
f.close()
pipeOut.Write(message)