Skip to content

Commit

Permalink
release 2.1.0
Browse files Browse the repository at this point in the history
- translation fixed
- bugfixes
- telegram cleanup
- gui-appeareance is now better
  • Loading branch information
Sebastian committed Jun 13, 2019
1 parent 0ab59f2 commit b65a86f
Show file tree
Hide file tree
Showing 66 changed files with 6,404 additions and 1,376 deletions.
10 changes: 5 additions & 5 deletions RTOC.egg-info/PKG-INFO
@@ -1,17 +1,17 @@
Metadata-Version: 2.1
Name: RTOC
Version: 2.0.2
Version: 2.1.0
Summary: RealTime OpenControl
Home-page: https://github.com/Haschtl/RealTimeOpenControl
Author: Sebastian Keller
Author-email: sebastiankeller@online.de
License: GNU
Description: # RealTime OpenControl (RTOC)

| [![Documentation Status](https://readthedocs.org/projects/realtimeopencontrol/badge/?version=latest)](https://realtimeopencontrol.readthedocs.io/en/latest/) | [![Builds v2.0](https://img.shields.io/badge/Builds%20version-1.6-brightgreen.svg?style=flat)](https://github.com/Haschtl/RealTimeOpenControl/releases) | [![PyPI pyversions](https://img.shields.io/pypi/pyversions/ansicolortags.svg)](https://pypi.python.org/pypi/RTOC/) | [![PyPI version fury.io](https://badge.fury.io/py/ansicolortags.svg)](https://pypi.python.org/pypi/RTOC/) | [![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/RTOC/) | [![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://github.com/Haschtl/RealTimeOpenControl/releases/) | [![Github all releases](https://img.shields.io/github/downloads/Naereen/StrapDown.js/total.svg)](https://github.com/Haschtl/RealTimeOpenControl/releases/) |
| [![Documentation Status](https://readthedocs.org/projects/realtimeopencontrol/badge/?version=latest)](https://realtimeopencontrol.readthedocs.io/en/latest/) | [![Builds 2.1.0v](https://img.shields.io/badge/Builds%20version-1.6-brightgreen.svg?style=flat)](https://github.com/Haschtl/RealTimeOpenControl/releases) | [![PyPI pyversions](https://img.shields.io/pypi/pyversions/ansicolortags.svg)](https://pypi.python.org/pypi/RTOC/) | [![PyPI version fury.io](https://badge.fury.io/py/ansicolortags.svg)](https://pypi.python.org/pypi/RTOC/) | [![PyPI license](https://img.shields.io/pypi/l/ansicolortags.svg)](https://pypi.python.org/pypi/RTOC/) | [![GitHub release](https://img.shields.io/github/release/Naereen/StrapDown.js.svg)](https://github.com/Haschtl/RealTimeOpenControl/releases/) | [![Github all releases](https://img.shields.io/github/downloads/Naereen/StrapDown.js/total.svg)](https://github.com/Haschtl/RealTimeOpenControl/releases/) |


### Version 2.0
### Version 2.1.0
![Usecase](screenshots/RTOC-schematik.png)
[Documentation](https://realtimeopencontrol.readthedocs.io/en/latest/)

Expand Down Expand Up @@ -159,7 +159,7 @@ Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >=3
Description-Content-Type: text/markdown
Provides-Extra: GUI
Provides-Extra: Webserver
Provides-Extra: Telegram
Provides-Extra: ALL
Provides-Extra: GUI
Provides-Extra: Webserver
11 changes: 6 additions & 5 deletions RTOC.egg-info/SOURCES.txt
Expand Up @@ -55,8 +55,10 @@ RTOC/RTLogger/__pycache__/loggerlib.cpython-36.pyc
RTOC/RTLogger/__pycache__/scriptLibrary.cpython-36.pyc
RTOC/RTLogger/__pycache__/telegramBot.cpython-36.pyc
RTOC/RTLogger/plugins/Generator.py
RTOC/RTLogger/plugins/test.py
RTOC/RTLogger/plugins/Funktionsgenerator/gen_function.ui
RTOC/RTLogger/plugins/__pycache__/Generator.cpython-36.pyc
RTOC/RTLogger/plugins/__pycache__/test.cpython-36.pyc
RTOC/RTOC_GUI/Actions.py
RTOC/RTOC_GUI/PluginDownloader.py
RTOC/RTOC_GUI/RTOC_Import.py
Expand Down Expand Up @@ -118,7 +120,6 @@ RTOC/RTOC_GUI/ui/scriptHelpWidget.ui
RTOC/RTOC_GUI/ui/scriptSubWidget.ui
RTOC/RTOC_GUI/ui/scriptWidget.ui
RTOC/RTOC_GUI/ui/settingsWidget.ui
RTOC/RTOC_GUI/ui/signalWidget.ui
RTOC/RTOC_GUI/ui/signalWidget2.ui
RTOC/RTOC_GUI/ui/stylePlotDialog.ui
RTOC/RTOC_GUI/ui/stylePlotDialog2.ui
Expand Down Expand Up @@ -164,6 +165,7 @@ RTOC/RTOC_GUI/ui/icons/icons8-transfer.png
RTOC/RTOC_GUI/ui/icons/icons8-viele-bearbeiten-filled-100.png
RTOC/RTOC_GUI/ui/icons/internet.png
RTOC/RTOC_GUI/ui/icons/invert.png
RTOC/RTOC_GUI/ui/icons/invisible.png
RTOC/RTOC_GUI/ui/icons/labels.png
RTOC/RTOC_GUI/ui/icons/left_arrow.png
RTOC/RTOC_GUI/ui/icons/left_arrow_disabled.png
Expand Down Expand Up @@ -206,6 +208,7 @@ RTOC/RTOC_GUI/ui/icons/swap.png
RTOC/RTOC_GUI/ui/icons/up_arrow.png
RTOC/RTOC_GUI/ui/icons/up_arrow_disabled.png
RTOC/RTOC_GUI/ui/icons/view.png
RTOC/RTOC_GUI/ui/icons/visible.png
RTOC/RTOC_GUI/ui/icons/x.png
RTOC/RTOC_GUI/ui/icons/xaxislabel.png
RTOC/RTOC_GUI/ui/icons/xtimebase.png
Expand All @@ -227,7 +230,5 @@ RTOC/lib/pyqt_customlib.py
RTOC/lib/__pycache__/__init__.cpython-36.pyc
RTOC/lib/__pycache__/general_lib.cpython-36.pyc
RTOC/lib/__pycache__/pyqt_customlib.cpython-36.pyc
RTOC/locales/en_en _fertig.ts
RTOC/locales/en_en.qm
RTOC/locales/en_en.ts
RTOC/locales/en_en_double.ts
RTOC/locales/de_de.qm
RTOC/locales/de_de.ts
64 changes: 40 additions & 24 deletions RTOC/LoggerPlugin.py
@@ -1,4 +1,4 @@
# LoggerPlugin v2.4
# LoggerPlugin v2.5
import traceback
import time
import sys
Expand Down Expand Up @@ -543,53 +543,69 @@ def __updateT(self, func):


class _perpetualTimer():
thread_counter = 0

def __init__(self, hFunction, samplerate=1, lock=None):
self.thread_counter = 0
self._samplerate = samplerate
self._lock = lock
self._cancel = True
self._hFunction = hFunction
self._thread = None
self._correction = -0.006
self._lastStart = 0

def _handle_function(self):
start = time.time()
self._lastStart = time.perf_counter()
self.thread_counter -= 1
if self.thread_counter != 0:
logging.warning('there should not be a running thread, but unfortunately it is.')
print(self.thread_counter)

with self._lock:
start = time.time()
self._hFunction()
diff = time.time() - start
timedelta = 1/self._samplerate - diff
if timedelta < 0:
timedelta = 0
self._thread = Timer(timedelta, self._handle_function)
self.thread_counter += 1
self._thread.start()
if not self._cancel:
with self._lock:
self._hFunction()
diff = time.time() - start # self._lastStart # - start
diff2 = time.perf_counter()-self._lastStart
timedelta = 1/self._samplerate - diff2
timedelta = timedelta + self._correction
if timedelta < 0:
timedelta = 0
if not self._lock.locked() and not self._cancel:
self._thread = Timer(timedelta, self._handle_function)
self.thread_counter += 1
self._thread.start()

def setSamplerate(self, rate):
if rate != self._samplerate:
if rate != self._samplerate and not self._cancel:
self._samplerate = rate
self.cancel()
if self.thread_counter == 0:
self._thread = Timer(1/self._samplerate, self._handle_function)
self.thread_counter += 1
self._thread.start()
else:
logging.warning('Thread should have stopped before changing samplerate, but it didnt.')
# self.start(1/self._samplerate)
if not self._lock.locked():
self.start(0)
# else:
# print('Samplerate changed, but not restarted')

def getSamplerate(self):
return self._samplerate

def start(self):
def start(self, delayed=0):
logging.info('Starting perpetual timer')
self.cancel()
self._thread = Timer(0, self._handle_function)
self.thread_counter += 1
self._thread.start()
self._cancel = False
with self._lock:
if self.thread_counter <= 0:
self._thread = Timer(delayed, self._handle_function)
self.thread_counter += 1
self._thread.start()
if self.thread_counter<0:
logging.warning('Something is not right...')
else:
logging.warning('You cannot start a second perpetual timer.')
print(self.thread_counter)


def cancel(self):
self._cancel = True
if self._thread is not None:
with self._lock:
self._thread.cancel()
Expand Down
23 changes: 11 additions & 12 deletions RTOC/RTLogger/DeviceFunctions.py
Expand Up @@ -52,14 +52,17 @@ def getDeviceList(self):
# for root, dirs, files in os.walklevel(list(devices.__path__)[0], level=1):
for files in os.listdir(list(devices.__path__)[0]+"/"+folder):
if files.endswith('.py'):
name = devices.__name__+'.'+folder+"."+files.replace('.py', '')
namesplit = name.split('.')
logging.info(name)

devname = namesplit[-1].replace('.', 'Dot').replace(':', 'DDot')
if devname not in ["LoggerPlugin"]:
self.devicenames[devname] = name
self.pluginStatus[devname] = False
file = ''
with open(list(devices.__path__)[0]+"/"+folder+'/'+files, mode='r') as f:
file = f.readlines()
if 'class Plugin(' in ''.join(file):
name = devices.__name__+'.'+folder+"."+files.replace('.py', '')
logging.info(name)

devname = files.replace('.py', '').replace('.', 'Dot').replace(':', 'DDot')
if devname not in ["LoggerPlugin"]:
self.devicenames[devname] = name
self.pluginStatus[devname] = False

# Plugin functions ############################################################

Expand Down Expand Up @@ -90,8 +93,6 @@ def startPlugin(self, name, remote=True):
self.analysePlugin(self.pluginObjects[name], name)
self.pluginStatus[name] = True
logging.info("PLUGIN: " + name+' connected\n')
# self.database.addNewEvent(text=translate('RTLogger', "Plugin gestartet: ") +
# name, sname="", dname="RTOC", priority=0)
if self.startDeviceCallback and remote:
self.startDeviceCallback(name)
return True, ""
Expand Down Expand Up @@ -292,8 +293,6 @@ def stopPlugin(self, name, remote=True):
self.pluginStatus[name] = False
self.pluginObjects[name].close()
logging.info("PLUGIN: " + name+' disconnected\n')
# self.database.addNewEvent(text=translate('RTLogger', "Plugin gestoppt: ") +
# name, sname="", dname="RTOC", priority=0)
# else:
# logging.debug("Plugin "+name+" not loaded")
if self.stopDeviceCallback and remote:
Expand Down
52 changes: 31 additions & 21 deletions RTOC/RTLogger/EventActionFunctions.py
Expand Up @@ -51,7 +51,7 @@ def loadGlobalEvents(self):
"return": " ",
"priority": 0,
"id": "testID",
'rising': True,
'trigger': 'rising',
'sname': '',
'dname': '',
'active': True
Expand All @@ -65,7 +65,7 @@ def loadGlobalEvents(self):
"return": " ",
"priority": 0,
"id": "",
'rising': True,
'trigger': 'rising',
'sname': '',
'dname': '',
'active': False
Expand Down Expand Up @@ -124,15 +124,25 @@ def performGlobalEvents(self, y, unit, devicename, signalname, x=None):
self.activeGlobalEvents[key]['latest'] = None
print('First time for this event')

if cond is True and self.activeGlobalEvents[key]['latest'] is not True:
if event['rising']:
self.database.addNewEvent(
text=event['text'], sname=event['sname'], dname=event['dname'], value=event['return'], priority=event['priority'], id=event['id'])
elif cond is False and self.activeGlobalEvents[key]['latest'] is True:
logging.info('Event-Ende: '+devicename+"."+signalname+': '+event['text'])
if not event['rising']:
self.database.addNewEvent(
text=event['text'], sname=event['sname'], dname=event['dname'], value=event['return'], priority=event['priority'], id=event['id'])
triggered = False
if event['trigger']=='true':
if cond is True:
triggered = True
elif event['trigger'] == 'false':
if cond is False:
triggered = True
else:
if cond is True and self.activeGlobalEvents[key]['latest'] is not True:
if event['trigger']=='rising' or event['trigger']=='both':
triggered = True
elif cond is False and self.activeGlobalEvents[key]['latest'] is True:
logging.info('Event-Ende: '+devicename+"."+signalname+': '+event['text'])
if event['trigger']=='falling' or event['trigger']=='both':
triggered = True

if triggered:
self.database.addNewEvent(
text=event['text'], sname=event['sname'], dname=event['dname'], value=event['return'], priority=event['priority'], id=event['id'])

self.activeGlobalEvents[key]['latest'] = cond
else:
Expand Down Expand Up @@ -218,22 +228,22 @@ def performGlobalActions(self, id, value):
if action['errors'] is False:
for actionId in action['listenID']:
if actionId == id and action['active']:
# Aktion ausf\xfchren
# Execute action
ok, prints = self.executeScript(action['script'])
print('Performing global action for eventID: ' +
str(id)+' with value: '+str(value))
print('Action is: '+str(action)+', Execution: '+str(ok))
print('Returns:' + str(prints))

def addGlobalEvent(self, name='testEvent', cond='', text='TestEvent', priority=0, retur='', id='testID', rising=True, sname='', dname='', active=True):
def addGlobalEvent(self, name='testEvent', cond='', text='TestEvent', priority=0, retur='', id='testID', trigger='rising', sname='', dname='', active=True):
countname = name
i = 2
while countname in self.globalEvents.keys():
countname = name+str(i)
i += 1
name = countname
self.globalEvents[name] = {'cond': cond, 'text': text,
'priority': priority, 'return': retur, 'id': id, 'rising': rising, 'sname': sname, 'dname': dname, 'active': active}
'priority': priority, 'return': retur, 'id': id, 'trigger': trigger, 'sname': sname, 'dname': dname, 'active': active}

def addGlobalAction(self, name='testAction', listenID='testID', script='', parameters='', active=True):
countname = name
Expand Down Expand Up @@ -270,17 +280,17 @@ def printGlobalEvents(self, wo=True):
if event['cond'] != '':
strung.append(name+': '+event['cond'])
else:
strung.append(name+': Ohne Bedingung')
strung.append(name+': '+translate('RTOC', 'No condition'))
return strung

def printGlobalActions(self):
strung = []
for name in self.globalActions.keys():
event = self.globalActions[name]
if event['listenID'] != []:
strung.append(name+' bei '+', '.join(event['listenID']))
strung.append(name+': '+', '.join(event['listenID']))
else:
strung.append(name+': Ohne Zuordnung')
strung.append(name+': '+translate('RTOC', 'No event connected'))
return strung

def triggerGlobalEvent(self, key):
Expand All @@ -289,12 +299,12 @@ def triggerGlobalEvent(self, key):
ok, cond = self.checkCondition(event['cond'])
if ok:
# cond = bool(cond)
text = translate('RTOC', 'Bedingung ist in Ordnung\nAntwort: ')+str(cond)
text = translate('RTOC', 'Condition is valid\nAnswer: ')+str(cond)
self.database.addNewEvent(text=event['text'], sname=event['sname'], dname=event['dname'],
value=event['return'], priority=event['priority'], id=event['id'])
return True, text
else:
text = translate('RTOC', 'Bedingung ist ung\xfcltig\nAntwort: ')+str(cond)
text = translate('RTOC', 'Condition is invalid!\nAnswer: ')+str(cond)
return False, text
return False, None

Expand All @@ -303,9 +313,9 @@ def triggerGlobalAction(self, key):
action = self.globalActions[key]
ok, prints = self.executeScript(action['script'])
if ok:
text = translate('RTOC', 'Aktion ist in Ordnung\nAntwort: ')+str(prints)
text = translate('RTOC', 'Action is valid\nAnswer: ')+str(prints)
return True, text
else:
text = translate('RTOC', 'Aktion ist ung\xfcltig\nAntwort: ')+str(prints)
text = translate('RTOC', 'Action is invalid!\nAnswer: ')+str(prints)
return False, text
return False, None

0 comments on commit b65a86f

Please sign in to comment.