Commit 2d11d7ff authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Prepare support for shared libraries

parent c31afeb6
......@@ -17,6 +17,7 @@ import re
import logging
import optparse
import time
from ctypes import CDLL
log = logging.getLogger(__name__)
terminal_formatter = logging.Formatter(
......@@ -131,6 +132,8 @@ def gui():
help='Display debug information')
parser.add_option('--udp', dest='udp', metavar='RemoteIP:inPort:outPort',
help='Use UDP sockets instead of message queues')
parser.add_option('-l', '--shared_lib', action='store_true', default=False,
help='Use a shared library instead of msgQ or UDP')
parser.add_option('-r', '--reset', action='store_true', default=False,
help='Do not try to restore windows layout')
parser.add_option('-i', '--ivpath', dest='ivpath',
......@@ -151,10 +154,18 @@ def gui():
log.error('You entered ' + options.udp)
sys.exit(-1)
try:
import datamodel
except ImportError:
log.error('Could not import project data')
return -1
msgQ = True
udp = None
dll = None
hasTM = False
if options.udp is None:
if options.udp is None and options.shared_lib is None:
# Default: use message queue
try:
from PythonController import(OpenMsgQueueForReading,
GetMsgQueueBufferSize, DV, RetrieveMessageFromQueue)
......@@ -162,7 +173,7 @@ def gui():
except ImportError:
log.error('Python module "PythonController" is missing')
return -1
else:
elif options.udp:
msgQ = False
udpConfig = options.udp.split(':')
log.debug('UDP with IP={cfg[0]} inPort={cfg[1]} outPort={cfg[2]}'
......@@ -175,12 +186,16 @@ def gui():
except ImportError:
log.error('Python module "udpcontroller" is missing')
return -1
try:
import datamodel
except ImportError:
log.error('Could not import user-defined datamodel')
return -1
elif options.options.shared_lib:
# Load and run the startup transition of the shared library (Ada only?)
try:
dll = CDLL('./{}.so'.format(datamodel.FVname))
dll_init = getattr(dll, 'lib{}init'.format(datamodel.FVname))
dll_init()
except OSError:
log.error('Shared library ./{}.so not found'
.format(datamodel.FVname))
return -1
# Define a Qt application (mandatory)
app = QApplication(sys.argv)
......@@ -295,8 +310,10 @@ def gui():
editor.msc.connect(msc.addToMsc)
if msgQ:
encoder_backend.setMsgQ()
else:
elif udp:
encoder_backend.setUDP()
elif dll:
encoder_backend.setSharedLib(dll)
editor.backend = encoder_backend
editor.log = log
dockWidget = editor.parent()
......@@ -340,10 +357,13 @@ def gui():
if isinstance(editor, asn1Viewer):
pollingThread.tm.connect(editor.receivedTM)
pollingThread.start()
else: # use UDP
elif udp:
if hasTM:
udp.tmPool = g_tmPool
udp.start(hasTM)
elif dll:
# TODO Should register the TMs callbacks
pass
# Associate the plotter manager to the main app
myWidget.plotter = plotter
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment