Skip to content

Commit

Permalink
Release 1.8.7.5
Browse files Browse the repository at this point in the history
Added button to show/hide signal-list
Added legend to signal-list
Added clear cache button 

fixed plugin-stream bug
fixed plotline-styling
  • Loading branch information
Sebastian committed Dec 29, 2018
1 parent 9d3e4bf commit 334cc8a
Show file tree
Hide file tree
Showing 25 changed files with 2,936 additions and 744 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# RealTime OpenControl (RTOC)

### Version 1.8.2
### Version 1.8.7.5

[**This README is available in GERMAN here.**](misc/README_german.md)

Expand Down
2 changes: 1 addition & 1 deletion RTOC.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: RTOC
Version: 1.8.6
Version: 1.8.7.5
Summary: RealTime OpenControl
Home-page: https://github.com/Haschtl/RealTimeOpenControl
Author: Sebastian Keller
Expand Down
3 changes: 3 additions & 0 deletions RTOC.egg-info/SOURCES.txt
Expand Up @@ -97,6 +97,8 @@ RTOC/data/ui/icons/icons8-stornieren-480.png
RTOC/data/ui/icons/invert.png
RTOC/data/ui/icons/labels.png
RTOC/data/ui/icons/legend.png
RTOC/data/ui/icons/list.png
RTOC/data/ui/icons/list_dark.png
RTOC/data/ui/icons/measure.png
RTOC/data/ui/icons/mittlere_prioritaet.png
RTOC/data/ui/icons/mittlere_prioritaet_grey.png
Expand Down Expand Up @@ -179,6 +181,7 @@ RTOC/data/ui/icons/dark/up_arrow.png
RTOC/data/ui/icons/dark/up_arrow_disabled.png
RTOC/lang/en_en.qm
RTOC/lang/en_en.ts
RTOC/lang/en_en_old.ts
RTOC/plugins/Generator.py
RTOC/plugins/NetWoRTOC.py
RTOC/plugins/Funktionsgenerator/gen_function.ui
Expand Down
7 changes: 6 additions & 1 deletion RTOC/LoggerPlugin.py
Expand Up @@ -48,8 +48,13 @@ def stream(self, *args, **kwargs):
for idx, arg in enumerate(args):
if idx == 0:
y = arg
kwargs['x'] = [time.time()]*len(y)
if type(y) == list:
kwargs['x'] = [time.time()]*len(y)
else:
kwargs['x'] = [time.time()]
self.__cb(*args, **kwargs)
else:
print('ERROR: cannot stream signals. No callback connected')

def plot(self, x=[], y=[], *args, **kwargs):
dataname = kwargs.get('sname', "noName")
Expand Down
30 changes: 22 additions & 8 deletions RTOC/RTLogger.py
Expand Up @@ -383,7 +383,9 @@ def handleTcpLogger(self, loggerDict):
loggerDict[call]['starttime'] = self.starttime
loggerDict[call]['telegram_token'] = self.config['telegram_token']
loggerDict[call]['telegram_bot'] = self.config['telegram_bot']
loggerDict[call]['signal_memory'] = self.logger.getSignalSize()
size, maxsize = self.getSignalSize()
loggerDict[call]['signal_memory'] = size
loggerDict[call]['signal_memory_limit'] = maxsize
return loggerDict

def getPluginDict(self):
Expand All @@ -410,12 +412,12 @@ def startPlugin(self, name, callback=None, remote=True):
try:
if name in self.devicenames.keys():
fullname = self.devicenames[name]
if callback is None:
self.pluginObjects[name] = importlib.import_module(
fullname).Plugin(self.addDataCallback, self.plot, self.addNewEvent)
else:
self.pluginObjects[name] = importlib.import_module(
fullname).Plugin(callback, self.addNewEvent)
# if callback is None:
self.pluginObjects[name] = importlib.import_module(
fullname).Plugin(self.addDataCallback, self.plot, self.addNewEvent)
# else:
# self.pluginObjects[name] = importlib.import_module(
# fullname).Plugin(callback, self.addNewEvent)
self.analysePlugin(self.pluginObjects[name], name)
self.pluginStatus[name] = True
print("PLUGIN: " + name+' connected\n')
Expand Down Expand Up @@ -779,6 +781,10 @@ def addDataCallback(self, datasY=[], *args, **kwargs):
if idx == 4:
createCallback = arg

if type(datasY) == float or type(datasY) == int:
datasY = [datasY]
print('Warning: You should stream a list of signals, not a single signal')

if type(datasY) == list:
if datasX == [None]:
datasX = [None]*len(datasY)
Expand Down Expand Up @@ -1058,6 +1064,13 @@ def load_config(self):
# with open(self.config['documentfolder']+"/config.json", 'w', encoding="utf-8") as fp:
# json.dump(conf, fp, sort_keys=False, indent=4, separators=(',', ': '))

def clearCache(self):
self.config = defaultconfig
self.save_config()
filename = self.config['documentfolder']+"/plotStyles.json"
if os.path.exists(filename):
os.remove(filename)

def save_config(self):
self.config["deviceWidget"] = True
self.config["pluginsWidget"] = False
Expand Down Expand Up @@ -1110,14 +1123,15 @@ def getSignalNames(self, id):
return [[''], ['']]

def getSignalSize(self):
maxsize = len(self.signals)*(2*(self.maxLength*8+64)+16)
outerlayer = sys.getsizeof(self.signals)
innerlayer = 0
for sig in self.signals:
innerlayer += sys.getsizeof(sig)
innerlayer += sys.getsizeof(sig[0])*2
innerlayer += sys.getsizeof(list(sig[0]))*2
size = outerlayer + innerlayer
return size
return size, maxsize

def check_for_updates(self):
import xmlrpc.client
Expand Down
2 changes: 1 addition & 1 deletion RTOC/__init__.py
@@ -1,4 +1,4 @@
from .data import *

name = "RTOC"
__version__ = "1.8.6"
__version__ = "1.8.7.5"
2 changes: 1 addition & 1 deletion RTOC/__main__.py
Expand Up @@ -32,7 +32,7 @@ def main():
'RTOC.py [-h, -s] [-r <Remoteadress>]\n -h: Hilfe\n-s: TCP-Server ohne GUI\n-r <Remoteadresse>: TCP-Client zu RTOC-Server\n-p: Starte TCP-Server auf anderem Port (Standart: 5050)')
sys.exit()
elif opt == '-s':
logger = RTLogger.RTLogger(True, port)
logger = RTLogger(True, port)
#runInBackground()
while logger.run:
time.sleep(1)
Expand Down
8 changes: 8 additions & 0 deletions RTOC/data/Actions.py
Expand Up @@ -45,6 +45,8 @@ def connectButtons(self):
self.aboutAction.triggered.connect(self.showAboutMessage)
self.checkUpdatesAction.triggered.connect(self.checkUpdates)

self.clearCacheAction.triggered.connect(self.clearCache)

self.searchEdit.textChanged.connect(self.filterDevices)

def toggleTcpServer(self):
Expand Down Expand Up @@ -279,3 +281,9 @@ def checkUpdates(self):
info = self.tr('Um die Version zu überprüfen, installiere RTOC mit "pip3 install RTOC"')

pyqtlib.info_message(self.tr('Version'), text, info)

def clearCache(self):
ok = pyqtlib.alert_message(self.tr('Cache leeren'), self.tr('Wollen Sie wirklich den Cache leeren?'), self.tr('Dadurch gehen gespeicherte Ploteinstellungen sowie Einstellungen verloren.'))
if ok:
self.plotStyles = {}
self.logger.clearCache()
10 changes: 9 additions & 1 deletion RTOC/data/RTPlotActions.py
Expand Up @@ -44,6 +44,8 @@ def initPlotWidget(self):
200, 200, 200), fill=(200, 200, 200, 50), html=None) # ,
self.plot.addItem(self.plotMouseLabel, ignoreBounds = True)

self.hideSignalsButton.clicked.connect(self.hideSignalList)

def initPlotViewWidget(self):
self.plotViewWidget = QtWidgets.QWidget()
uic.loadUi(packagedir+"/ui/plotViewWidget.ui", self.plotViewWidget)
Expand Down Expand Up @@ -84,6 +86,12 @@ def initPlotViewWidget(self):
self.gridViewWidget.yCheckbox.clicked.connect(self.gridYAction)
self.gridViewWidget.alphaSlider.valueChanged.connect(self.gridAlphaAction)

def hideSignalList(self):
if self.hideSignalsButton.isChecked():
self.widget_2.show()
else:
self.widget_2.hide()

def gridXAction(self):
value = self.gridViewWidget.xCheckbox.isChecked()
self.grid[0] = value
Expand Down Expand Up @@ -361,7 +369,7 @@ def filterDevices(self, tex):
tex = tex+';'
tex = tex.replace('; ', ';')
for item in self.signalTreeWidgetItems:
sig = self.treeWidget.itemWidget(item, 0)
sig = self.treeWidget.itemWidget(item, 1)
found = False
for text in tex.split(';'):
# print(text)
Expand Down
8 changes: 7 additions & 1 deletion RTOC/data/RTPlotWidget.py
Expand Up @@ -165,6 +165,8 @@ def addSignalRAW(self, signalObject):
self.treeWidget.setItemWidget(self.signalTreeWidgetItems[idx], 0, self.signalObjects[idx])
self.treeWidget.setItemWidget(
self.signalTreeWidgetItems[idx], 1, self.signalObjects[idx].label)
#self.treeWidget.resizeColumnToContents(0)
#self.treeWidget.resizeColumnToContents(1)
self.deviceTreeWidgetItems[self.devices.index(devicename)].setExpanded(True)
self.updateCountLabel()

Expand Down Expand Up @@ -212,11 +214,15 @@ def addSignal(self, devicename, signalname, id, unit):
self.treeWidget.setItemWidget(self.signalTreeWidgetItems[idx], 0, self.signalObjects[idx])
self.treeWidget.setItemWidget(
self.signalTreeWidgetItems[idx], 1, self.signalObjects[idx].label)

#self.treeWidget.resizeColumnToContents(0)
#self.treeWidget.resizeColumnToContents(1)
self.deviceTreeWidgetItems[self.devices.index(devicename)].setExpanded(True)
self.updateCountLabel()

def updateCountLabel(self):
self.countLabel.setText(self.tr("Signale: ")+str(len(self.signalObjects))+' ('+lib.bytes_to_str(self.logger.getSignalSize())+')')
size, maxsize = self.logger.getSignalSize()
self.countLabel.setText(self.tr("Signale: ")+str(len(self.signalObjects))+' ('+lib.bytes_to_str(size)+'/'+lib.bytes_to_str(maxsize)+')')

def startDragTreeWidget(self, actions):
self.self._drag_info = {"oldWidget": "", "newWidget": "", "signalObjects": []}
Expand Down
1 change: 1 addition & 0 deletions RTOC/data/signalEditWidget.py
Expand Up @@ -100,6 +100,7 @@ def editPlotStyle(self):
"."+str(self.self.signalname)]["brush"] = brush

self.self.labelItem.setColor(symbol["color"])
self.self.updateLegend()

def deleteSignal(self):
self.self.remove()
Expand Down
104 changes: 98 additions & 6 deletions RTOC/data/signalWidget.py
Expand Up @@ -10,6 +10,7 @@
from .signalEditWidget import SignalEditWidget
from . import define as define
from .stylePlotGUI import setStyle as setPlotStyle
from .stylePlotGUI import getStyle as getPlotStyle


def mouseClickEventPlotCurveItem(self, ev):
Expand Down Expand Up @@ -78,14 +79,29 @@ def setBackColor(self, color):
backColor = QtCore.pyqtProperty(QtGui.QColor, getBackColor, setBackColor)


class SignalWidget(QtWidgets.QToolButton):
#class SignalWidget(QtWidgets.QToolButton):
class SignalWidget(QtWidgets.QWidget):
def __init__(self, plotWidget, logger, devicename, signalname, id, unit):
super(SignalWidget, self).__init__()
sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
self.layout = QtWidgets.QHBoxLayout()
self.setLayout(self.layout)
self.legend = QtWidgets.QLabel('-')
self.legend.setSizePolicy(sizePolicy)
self.button = QtWidgets.QToolButton()
self.layout.addWidget(self.legend)
self.layout.addWidget(self.button)
self.clicked=self.button.clicked

sizePolicy = QtGui.QSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
self.setSizePolicy(sizePolicy)
self.button.setSizePolicy(sizePolicy)
self.setCheckable(True)

self.setText(signalname)
Expand Down Expand Up @@ -146,6 +162,81 @@ def __init__(self, plotWidget, logger, devicename, signalname, id, unit):

self.signalModifications = [0, 0, 1, 1]

self.updateLegend()

def setCheckable(self, value):
self.button.setCheckable(value)

def setText(self, signalname):
self.button.setText(signalname)

def setChecked(self, value):
self.button.setChecked(value)

def isChecked(self):
return self.button.isChecked()
#def setSizePolicy(self, policy):
# self.button.setSizePolicy(policy)

def menu(self):
return self.button.menu()

def setStyleSheet(self, stylesheet):
self.button.setStyleSheet(stylesheet)

def setMinimumHeight(self, height):
self.button.setMinimumHeight(height)

def setMaximumHeight(self, height):
self.button.setMaximumHeight(height)

def updateLegend(self):
symbol, brush = getPlotStyle(self.plot)
self.setLegendType(symbol['style'],brush['style'])
self.setLegendColor(symbol['color'])
self.legend.setFont(QtGui.QFont('SansSerif', 6+symbol['width']*3))

def setLegendType(self, line='-', symbol=''):
if line == 1 or line == 0:
line = '_'
elif line == 2:
line = '-'
elif line == 3:
line = '.'
elif line == 4:
line = '-.'
elif line == 5:
line = '-..'
else:
line =''

# if symbol == 0:
# symbol = "d"
# elif symbol == 1:
# symbol = "o"
# elif symbol == 2:
# symbol = "x"
# elif symbol == 3:
# symbol = "s"
# elif symbol == 4:
# symbol = "t"
# elif symbol == 5:
# symbol = "+"
# else:
# symbol = ''
if symbol is None:
symbol = ""
#else:
# symbol = ''
self.legend.setText(line+symbol+line)

def setLegendColor(self, color, bgcolor=None):
if bgcolor == None:
self.legend.setStyleSheet("QLabel { color : "+str(color)+"; }");
else:
self.legend.setStyleSheet("QLabel { background-color : red; color : blue; }");


def onMove(self, pos):
act_pos = self.plot.mapFromScene(pos)
p1 = self.plot.scatter.pointsAt(act_pos)
Expand Down Expand Up @@ -174,12 +265,12 @@ def r(): return random.randint(0, 255)
return symbol, brush

def initMenu(self):
self.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)
self.setMenu(QtWidgets.QMenu(self))
self.button.setPopupMode(QtWidgets.QToolButton.MenuButtonPopup)
self.button.setMenu(QtWidgets.QMenu(self.button))
action = QtWidgets.QWidgetAction(self)
self.editWidget = SignalEditWidget(self, self.id, self.plotWidget)
action.setDefaultWidget(self.editWidget)
self.menu().addAction(action)
self.button.menu().addAction(action)

def newDataIncoming(self):
if self.plotWidget.plotViewWidget.blinkingButton.isChecked():
Expand Down Expand Up @@ -310,7 +401,8 @@ def updatePlot(self):
self.eventItems[idx].vLine.setPos(pos)

def toggleSignal(self):

print(self.isChecked())
print(self.hidden)
if self.isChecked() and not self.hidden:
self.active = True
self.plotWidget.legend.addItem(
Expand All @@ -336,7 +428,7 @@ def remove(self, cb=True, total=True):
if total:
idx = self.logger.removeSignal(self.id)
self.labelItem.hide()
self.menu().hide()
self.button.menu().hide()
self.hide()
self.close()

Expand Down

0 comments on commit 334cc8a

Please sign in to comment.