Commit 4f511f5d authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add SDL handler using Opengeode API to display a statechart

parent 1a2d275e
......@@ -8,7 +8,7 @@ install: compile-all
@for f in ColorFormatter.py TasteMainWindow.py asn1_python.py \
errCode.py mscHandler.py plotmanager.py tasteplot.py \
vn.py Scenario.py __init__.py asn1_value_editor.py gui.py \
mscStreamingScene.py standalone_editor.py \
mscStreamingScene.py standalone_editor.py sdlHandler.py\
udpcontroller.py resources.py; \
do echo Installing $$f && cp $$f asn1_value_editor ; \
done
......
......@@ -56,6 +56,7 @@ except ImportError:
import resources
from mscHandler import mscHandler
from sdlHandler import sdlHandler
from PySide.QtCore import QThread, QFile, Qt, Signal, QObject
from PySide.QtGui import(QApplication, QStatusBar, QLabel, QWidget,
......@@ -277,6 +278,17 @@ def gui():
mscButton.triggered.connect(msc.startStop)
myWidget.mscTrigger.connect(msc.startStop)
# Create a dock to handle the display of SDL diagrams
try:
sdl = sdlHandler(myWidget)
except IOError:
log.info('SDL viewer not available')
pass
else:
sdlButton = toolbar.addAction('SDL')
sdlButton.triggered.connect(sdl.startStop)
# find dockable widgets (containing TM and TC editors)
docks = myWidget.findChildren(QDockWidget)
firstTC = None
......
......@@ -2,7 +2,7 @@
# Resource object code
#
# Created: Fri Nov 21 16:43:11 2014
# Created: Fri Dec 12 21:30:00 2014
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=C0302
"""
TASTE GUI - SDL Statechart handler
Connect to OpenGEODE and display the statechart during the simulation
Copyright (c) 2012-2015 European Space Agency
Designed and implemented by Maxime Perrotin
Contact: maxime.perrotin@esa.int
"""
import os
from PySide.QtGui import QDockWidget
from PySide.QtCore import Slot, Qt
try:
import opengeode
except ImportError:
print 'OpenGEODE module is not available'
class sdlHandler(object):
'''
Class managing SDL models
'''
def __init__(self, parent):
''' Startup: check if there are some SDL files in
the directory and try to parse them and build the widget '''
all_files = os.listdir('.')
pr_files = []
for each in all_files:
if each.endswith('.pr'):
pr_files.append(each)
if not pr_files:
raise IOError('SDL Handler failed to initialize')
self.ast = opengeode.parse(pr_files)
try:
root_ast = self.ast[0]
proc = root_ast.processes[0]
except IndexError:
raise IOError('SDL Handler failed to initialize')
opengeode.Helper.flatten(proc)
graph = opengeode.Statechart.create_dot_graph(proc)
self.sdl_scene = opengeode.SDL_Scene('statechart')
self.sdl_view = opengeode.SDL_View(self.sdl_scene)
opengeode.Statechart.render_statechart(self.sdl_scene, graph)
self.sdl_view.refresh()
self.dock = QDockWidget('SDL/Statechart Viewer', parent)
self.dock.setFloating(True)
self.dock.setObjectName('SDLViewer')
parent.addDockWidget(Qt.RightDockWidgetArea, self.dock)
self.dock.setAllowedAreas(Qt.NoDockWidgetArea)
self.sdl_view.show()
self.dock.setWidget(self.sdl_view)
self.running = False
self.dock.hide()
@Slot()
def startStop(self):
''' Trigger or stop the SDL display '''
self.running = not self.running
if self.running:
self.dock.show()
else:
self.dock.hide()
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