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

Use proper symbols in MSC when using timers

parent 528c1f25
......@@ -126,6 +126,7 @@ inst {fv};'''.format(fv=fv_name)]
self.cnt_id += 1
self.msg.append(msg)
# Draw the message on the MSC Scene
if direction in ('in', 'out'):
if direction == 'out':
start_item = self.gui_instance
end_item = self.taste_instance
......@@ -134,6 +135,14 @@ inst {fv};'''.format(fv=fv_name)]
end_item = self.gui_instance
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:
# comment = self.msc_scene.addComment(msg)
#comment.setCommentText("Hello!")
......
#******************************************************************************
#
# TASTE Msc Diagram Editor
# http://taste.tuxfamily.org/
#
# This file is part of TASTE Msc Editor.
#
# TASTE Msc Diagram Editor is free software: you can redistribute it and/or
# 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
# (at your option) any later version.
#
# TASTE Msc Diagram Editor is distributed in the hope that it will be
# useful,(but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with TASTE Msc Diagram Editor. If not, see
# <http://www.gnu.org/licenses/>.
#
# Author: Angel Esquinas <aesquina@datsi.fi.upm.es>
#
# Copyright (c) 2012 European Space Agency
#
#******************************************************************************
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
TASTE MSC Streaming Scene
http://taste.tuxfamily.org/
This file is part of TASTE MSC Editor.
TASTE Msc Diagram Editor is free software: you can redistribute it and/or
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
(at your option) any later version.
TASTE Msc Diagram Editor is distributed in the hope that it will be
useful,(but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with TASTE Msc Diagram Editor. If not, see
<http://www.gnu.org/licenses/>.
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 QRegExp
......@@ -36,6 +39,7 @@ from collections import deque
from msccore import mscregexp
from msccore import MscMessageDecl
from msccore import MscMessage
from msccore import MscTimer
msgWithValueRegExp = QRegExp('(' + mscregexp.Name + ')' + '\s*' +
'(?:\((.*)\))?')
......@@ -86,12 +90,40 @@ class MscStreamingScene(MscGraphBasicMSCScene):
self.streamingControl(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):
''' Call the remove function depending on the type of the item '''
if isinstance(item, MscGraphMessage):
self.removeMessage(item)
elif isinstance(item, MscGraphCondition):
self.removeCondition(item)
elif isinstance(item, MscGraphTimer):
self.removeTimer(item)
else:
pass
......@@ -101,11 +133,9 @@ class MscStreamingScene(MscGraphBasicMSCScene):
if len(self.visible_items) > self.max_items:
item = self.visible_items.popleft()
firstY = item.pos().y()
#self.removeMessage(item)
self.removeGenericItem(item)
while len(self.visible_items) > self.max_items:
item = self.visible_items.popleft()
#self.removeMessage(item)
self.removeGenericItem(item)
diff = self.visible_items[0].pos().y() - firstY
......
......@@ -219,13 +219,13 @@ class sdlHandler(QObject):
def set_timer(self, name, duration):
''' 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_{}({})"'
.format(name, duration))
def reset_timer(self, name):
''' 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_{}"'
.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