Commits (6)
......@@ -34,6 +34,7 @@ LICENSE: LGPL - see LICENSE file
CHANGELOG:
1.6.0 - Fix autoscrolling in MSC streaming scenes
1.5.8 - Fix in Scenario.py used in MSCtoPython handlers
1.5.7 - No change - 1st version in TASTEv4
1.5.6 - Add support for taste-msc-editor
......
......@@ -16,7 +16,7 @@
__author__ = "Maxime Perrotin"
__license__ = "LGPLv3"
__version__ = "1.5.8"
__version__ = "1.6.0"
__url__ = "http://taste.tuxfamily.org"
import sys
......
......@@ -5,7 +5,7 @@
Tool main entry point (when used standalone)
Copyright (c) 2012-2015 European Space Agency
Copyright (c) 2012-2018 European Space Agency
Designed and implemented by Maxime Perrotin
......@@ -29,6 +29,7 @@ import time
from functools import partial
from ctypes import CDLL, create_string_buffer
logging.basicConfig()
log = logging.getLogger(__name__)
terminal_formatter = logging.Formatter(
fmt="%(levelname)s - %(name)s: %(message)s")
......
......@@ -106,6 +106,7 @@ class AddToMsc(QUndoCommand):
self.handler.cnt_id += 1
self.handler.msg.append(self.txt)
self.handler.next_y += self.increase_factor
if self.handler.msc_scene.visible_items[-1] != self.item:
self.handler.msc_scene.visible_items.append(self.item)
self.item.show()
......
......@@ -69,7 +69,10 @@ class MscStreamingScene(MscGraphBasicMSCScene):
y=y - self.globalDiff, data=coreMsg)
rst = super(MscStreamingScene, self).addMessage2(graphMsg)
self.visible_items.append (rst)
rst.show()
self.streamingControl(rst)
rst.ensureVisible()
return rst
......@@ -79,6 +82,7 @@ class MscStreamingScene(MscGraphBasicMSCScene):
y = y - self.globalDiff
rst = super(MscStreamingScene, self).addCondition(instance, y, label)
self.streamingControl(rst)
rst.ensureVisible()
return rst
......@@ -88,6 +92,7 @@ class MscStreamingScene(MscGraphBasicMSCScene):
pos = instance.mapFromScene(0, y)
rst = super(MscStreamingScene, self).addTimer(instance, pos, label)
self.streamingControl(rst)
rst.ensureVisible()
return rst
......@@ -118,6 +123,7 @@ class MscStreamingScene(MscGraphBasicMSCScene):
y = y - self.globalDiff
rst = super(MscStreamingScene, self).addProcedure(instance, y, label)
self.streamingControl(rst)
rst.ensureVisible()
return rst
......@@ -136,16 +142,21 @@ class MscStreamingScene(MscGraphBasicMSCScene):
def streamingControl(self, element):
''' Scroll up in streaming mode '''
#self.visible_items.append(element)
_ = element
if len(self.visible_items) > self.max_items:
item = self.visible_items.popleft()
firstY = item.pos().y()
self.removeGenericItem(item)
firstY = item.y()
item.hide()
# Can't call removeGenericItem because it is not associated to
# the bMSC, as it was created with addMessage2. This flow should
# be clarified. This is a memory leak...
#self.removeGenericItem(item)
while len(self.visible_items) > self.max_items:
item = self.visible_items.popleft()
self.removeGenericItem(item)
#self.removeGenericItem(item)
item.hide()
diff = self.visible_items[0].pos().y() - firstY
diff = self.visible_items[0].y() - firstY
self.globalDiff = self.globalDiff + diff
map(lambda msg: msg.setPos(msg.pos().x(), msg.pos().y() - diff),
map(lambda msg: msg.setPos(msg.x(), msg.y() - diff),
self.visible_items)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
TASTE ASN.1 Value Editor
Testing module for the MSC Streaming function
Copyright (c) 2012-2018 European Space Agency
Contact: maxime.perrotin@esa.int
License is LGPLv3 - Check the LICENSE file
"""
import sys
import signal
import time
import logging
from PySide.QtGui import QGraphicsView, QApplication
from PySide.QtCore import Qt, QTimer
from mscStreamingScene import MscStreamingScene
def test_msc():
''' Create an MSC Scene and add items to check if streaming is ok '''
global next_y, counter
app = QApplication(sys.argv)
msc_scene = MscStreamingScene()
msc_view = QGraphicsView(msc_scene)
# Create two MSC instances on the diagram
env_x = 80.0
taste_x = 600.0
gui_instance = msc_scene.addInstance(env_x, 0, label="GUI")
taste_instance = msc_scene.addInstance(taste_x, 0, label="SYSTEM")
next_y = 130.0
increase_factor = 30
counter = 1
msc_view.show()
def add_item(item):
''' Add item to the scene and update next y position '''
global next_y, counter
counter += 1
next_y += increase_factor
def click(_):
''' Called when user clicks on the scene '''
item = msc_scene.addMessage(gui_instance,
taste_instance,
next_y,
"Ping({})".format(counter))
add_item(item)
item = msc_scene.addMessage(taste_instance,
gui_instance,
next_y,
"Pong({})".format(counter))
add_item(item)
msc_scene.mousePressEvent = click
msc_scene.setLimit(15)
app.exec_()
if __name__ == '__main__':
# Exit app on Ctrl-C
logging.basicConfig()
signal.signal(signal.SIGINT, signal.SIG_DFL)
sys.exit(test_msc())