Commit dfe6ea79 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Use proper symbols in MSC when using timers

parent 528c1f25
...@@ -126,14 +126,23 @@ inst {fv};'''.format(fv=fv_name)] ...@@ -126,14 +126,23 @@ inst {fv};'''.format(fv=fv_name)]
self.cnt_id += 1 self.cnt_id += 1
self.msg.append(msg) self.msg.append(msg)
# Draw the message on the MSC Scene # Draw the message on the MSC Scene
if direction == 'out': if direction in ('in', 'out'):
start_item = self.gui_instance if direction == 'out':
end_item = self.taste_instance start_item = self.gui_instance
elif direction == 'in': end_item = self.taste_instance
start_item = self.taste_instance elif direction == 'in':
end_item = self.gui_instance start_item = self.taste_instance
msg = self.msc_scene.addMessage( end_item = self.gui_instance
start_item, end_item, self.next_y, label=message) msg = self.msc_scene.addMessage(
start_item, end_item, self.next_y, label=message)
elif direction == 'set':
self.msc_scene.addSetTimer(self.taste_instance,
self.next_y,
message)
elif direction == 'reset':
self.msc_scene.addResetTimer(self.taste_instance,
self.next_y,
message)
# This is how to add a comment on the graph: # This is how to add a comment on the graph:
# comment = self.msc_scene.addComment(msg) # comment = self.msc_scene.addComment(msg)
#comment.setCommentText("Hello!") #comment.setCommentText("Hello!")
......
#****************************************************************************** #!/usr/bin/env python
# # -*- coding: utf-8 -*-
# TASTE Msc Diagram Editor
# http://taste.tuxfamily.org/ '''
# TASTE MSC Streaming Scene
# This file is part of TASTE Msc Editor. http://taste.tuxfamily.org/
#
# TASTE Msc Diagram Editor is free software: you can redistribute it and/or This file is part of TASTE MSC Editor.
# modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or TASTE Msc Diagram Editor is free software: you can redistribute it and/or
# (at your option) any later version. modify it under the terms of the GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# TASTE Msc Diagram Editor is distributed in the hope that it will be (at your option) any later version.
# useful,(but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the TASTE Msc Diagram Editor is distributed in the hope that it will be
# GNU General Public License for more details. useful,(but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# You should have received a copy of the GNU General Public License GNU General Public License for more details.
# along with TASTE Msc Diagram Editor. If not, see
# <http://www.gnu.org/licenses/>. You should have received a copy of the GNU General Public License
# along with TASTE Msc Diagram Editor. If not, see
# Author: Angel Esquinas <aesquina@datsi.fi.upm.es> <http://www.gnu.org/licenses/>.
#
# Copyright (c) 2012 European Space Agency Author: Angel Esquinas <aesquina@datsi.fi.upm.es>
# Maintained by: Maxime Perrotin <maxime.perrotin@esa.int>
#******************************************************************************
Copyright (c) 2012-2015 European Space Agency
'''
from PySide.QtCore import Slot from PySide.QtCore import Slot
from PySide.QtCore import QRegExp from PySide.QtCore import QRegExp
...@@ -36,6 +39,7 @@ from collections import deque ...@@ -36,6 +39,7 @@ from collections import deque
from msccore import mscregexp from msccore import mscregexp
from msccore import MscMessageDecl from msccore import MscMessageDecl
from msccore import MscMessage from msccore import MscMessage
from msccore import MscTimer
msgWithValueRegExp = QRegExp('(' + mscregexp.Name + ')' + '\s*' + msgWithValueRegExp = QRegExp('(' + mscregexp.Name + ')' + '\s*' +
'(?:\((.*)\))?') '(?:\((.*)\))?')
...@@ -86,12 +90,40 @@ class MscStreamingScene(MscGraphBasicMSCScene): ...@@ -86,12 +90,40 @@ class MscStreamingScene(MscGraphBasicMSCScene):
self.streamingControl(rst) self.streamingControl(rst)
return rst return rst
def addTimer(self, instance, y, label=''):
''' Add timer (set, reset, timeout) '''
y = y - self.globalDiff
pos = instance.mapFromScene(0, y)
rst = super(MscStreamingScene, self).addTimer(instance, pos, label)
self.streamingControl(rst)
return rst
@Slot(MscGraphInstance, float, str)
def addSetTimer(self, instance, y=None, label=''):
''' Add a new SET TIMER symbol in streaming mode '''
self.setItemType(MscTimer.StartTimer)
return self.addTimer(instance, y, label)
@Slot(MscGraphInstance, float, str)
def addTimeout(self, instance, y=None, label=''):
''' Add a new TIMEOUT symbol in streaming mode '''
self.setItemType(MscTimer.TimeOut)
return self.addTimer(instance, y, label)
@Slot(MscGraphInstance, float, str)
def addResetTimer(self, instance, y=None, label=''):
''' Add a new RESET TIMER symbol in streaming mode '''
self.setItemType(MscTimer.StopTimer)
return self.addTimer(instance, y, label)
def removeGenericItem(self, item): def removeGenericItem(self, item):
''' Call the remove function depending on the type of the item ''' ''' Call the remove function depending on the type of the item '''
if isinstance(item, MscGraphMessage): if isinstance(item, MscGraphMessage):
self.removeMessage(item) self.removeMessage(item)
elif isinstance(item, MscGraphCondition): elif isinstance(item, MscGraphCondition):
self.removeCondition(item) self.removeCondition(item)
elif isinstance(item, MscGraphTimer):
self.removeTimer(item)
else: else:
pass pass
...@@ -101,11 +133,9 @@ class MscStreamingScene(MscGraphBasicMSCScene): ...@@ -101,11 +133,9 @@ class MscStreamingScene(MscGraphBasicMSCScene):
if len(self.visible_items) > self.max_items: if len(self.visible_items) > self.max_items:
item = self.visible_items.popleft() item = self.visible_items.popleft()
firstY = item.pos().y() firstY = item.pos().y()
#self.removeMessage(item)
self.removeGenericItem(item) self.removeGenericItem(item)
while len(self.visible_items) > self.max_items: while len(self.visible_items) > self.max_items:
item = self.visible_items.popleft() item = self.visible_items.popleft()
#self.removeMessage(item)
self.removeGenericItem(item) self.removeGenericItem(item)
diff = self.visible_items[0].pos().y() - firstY diff = self.visible_items[0].pos().y() - firstY
......
...@@ -219,13 +219,13 @@ class sdlHandler(QObject): ...@@ -219,13 +219,13 @@ class sdlHandler(QObject):
def set_timer(self, name, duration): def set_timer(self, name, duration):
''' Callback function when the SDL model sets a timer ''' ''' Callback function when the SDL model sets a timer '''
self.msc.emit('in', 'SET_{}({})'.format(name, duration)) self.msc.emit('set', 'SET_{}({})'.format(name, duration))
self.log_area.addItem('Received event "SET_{}({})"' self.log_area.addItem('Received event "SET_{}({})"'
.format(name, duration)) .format(name, duration))
def reset_timer(self, name): def reset_timer(self, name):
''' Callback function when the SDL model resets a timer ''' ''' Callback function when the SDL model resets a timer '''
self.msc.emit('in', 'RESET_{}'.format(name)) self.msc.emit('reset', 'RESET_{}'.format(name))
self.log_area.addItem('Received event "RESET_{}"' self.log_area.addItem('Received event "RESET_{}"'
.format(name)) .format(name))
......
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