Commit 0a95a46d authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Prepare placeholders for the SQL widgets

parent ffa3e240
......@@ -19,41 +19,116 @@
import sys
from PySide.QtCore import (QObject, Signal, Slot, Qt, QRectF, QPointF, QPoint)
from PySide.QtGui import QWidget
from PySide.QtGui import QDockWidget
__author__ = "Maxime Perrotin"
__license__ = "LGPL"
__version__ = "1.0"
__url__ = "http://taste.tuxfamily.org"
#__all__ = ['']
class TM(QWidget):
# User must list explicitly the classes he wants to expose to the GUI:
__all__ = ['SQLTelecommands', 'SQLTelemetries']
class TM(QDockWidget, QObject):
''' Subclasses of TM will receive ASN.1 data from the GUI whenever a
value is updated (through a Qt slot)
'''
# specify a name for the combo button
name = 'Generic TM'
def __init__(self, asn1_type=None, parent=None):
''' Initialisation of the Widget '''
pass
super(TM, self).__init__(parent)
@Slot
@staticmethod
def applicable():
'''' Return true is the widget is active '''
return True
@Slot()
def update(self, value):
''' Receive ASN.1 value - Specify actual type in subclasses (Slot)'''
''' Receive ASN.1 value '''
pass
class TC(QWidget):
class TC(QDockWidget, QObject):
''' Subclasses of TC can be used to provide ASN.1 data to the main GUI
and to automatically send it to the application.
Example of uses: Buttons, SQL interface...
Define your widget and send signals at will.
'''
send = Signal()
update = Signal() # User to specify type
update = Signal()
# specify a name for the combo button
name = 'Generic TM'
def __init__(self, asn1_type=None, parent=None):
''' Initialisation of the Widget '''
super(TC, self).__init__(parent)
class SQLTelecommands(TC):
''' Handle Postgresql databases for telecommands '''
name = 'Get from db'
def __init__(self, parent=None):
''' Initialise the widget '''
# to do here = create a table widget, and place all the entries
# of the given ASN.1 type
# Thanassis: please specify what data you need as parameters
# (I can provide the data type name, the database name...)
@staticmethod
def applicable():
'''' check if there is a sql_db directory, return False otherwise '''
return True
def sql2asn1(self, lineNb):
''' Thanassis: please retrieve the db entry for index "lineNb"
and convert it to an ASN.1 native type '''
pass
def onUpdateButtonClick(self, lineNb):
''' When user clicks on Update, the content of the selected TC will
be used to feed the main GUI TC editor '''
as_asn1 = self.sql2asn1(lineNb)
self.update.emit(as_asn1) # use signal to send data to the GUI
def onSendButtonClick(self, lineNb):
''' When user clicks on Send, the selected TC will be sent to the
running application '''
as_asn1 = self.sql2asn1(lineNb)
self.send.emit(as_asn1) # use signal to send data to the GUI
class SQLTelemetries(TM):
''' Handle Postgresql databases for telecommands '''
name = 'Store in db'
def __init__(self, parent=None):
''' Initialise the widget '''
super(SQLTelemetries, self).__init__(parent)
# to do here = display a window with two buttons:
# "start storing in DB", "stop storing in DB"
# Thanassis: please specify what data you need as parameters
# (I can provide the data type name, the database name...)
self.mode = 'recording'
@Slot()
def update(self, value):
''' Receive ASN.1 value '''
pass
# value should be in native ASN.1 format
if self.mode == 'recording':
# Convert value to SQL entry and store in DB
pass
else:
pass
@staticmethod
def applicable():
'''' check if there is a sql_db directory, return False otherwise '''
return True
if __name__ == '__main__':
print 'This module can only be imported from the main TASTE guis'
sys.exit(-1)
......
......@@ -40,7 +40,7 @@ log.addHandler(handler_console)
from ColorFormatter import ColorFormatter
from asn1_value_editor import asn1Editor, asn1Viewer, __version__
from asn1_value_editor import asn1Editor, asn1Viewer, __version__, UserWidgets
from plotmanager import PlotManager
import vn
......@@ -394,6 +394,16 @@ def gui():
editor.log = log
dockWidget = editor.parent()
myButtons = dockWidget.findChildren(QPushButton)
customBtn = dockWidget.findChild(QComboBox, "customCombo")
# retrieve user widgets for TM and TC
customTC, customTM = [], []
for each in UserWidgets.__all__:
widget = getattr(UserWidget, each)
if widget.__base__ == UserWidget.TC:
customTC.append(widget)
elif widget.__base__ == UserWidget.TM:
customTM.append(widget)
if isinstance(editor, asn1Viewer): # TM Viewer
hasTM = True
......
Markdown is supported
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