Skip to content

Commit b65a86f

Browse files
author
Sebastian
committed
release 2.1.0
- translation fixed - bugfixes - telegram cleanup - gui-appeareance is now better
1 parent 0ab59f2 commit b65a86f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+6404
-1376
lines changed

RTOC.egg-info/PKG-INFO

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
Metadata-Version: 2.1
22
Name: RTOC
3-
Version: 2.0.2
3+
Version: 2.1.0
44
Summary: RealTime OpenControl
55
Home-page: https://github.com/Haschtl/RealTimeOpenControl
66
Author: Sebastian Keller
77
Author-email: [email protected]
88
License: GNU
99
Description: # RealTime OpenControl (RTOC)
1010

11-
| [![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/) |
11+
| [![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/) |
1212

1313

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

@@ -159,7 +159,7 @@ Classifier: Topic :: Scientific/Engineering :: Visualization
159159
Classifier: Topic :: Software Development :: User Interfaces
160160
Requires-Python: >=3
161161
Description-Content-Type: text/markdown
162-
Provides-Extra: GUI
163-
Provides-Extra: Webserver
164162
Provides-Extra: Telegram
165163
Provides-Extra: ALL
164+
Provides-Extra: GUI
165+
Provides-Extra: Webserver

RTOC.egg-info/SOURCES.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ RTOC/RTLogger/__pycache__/loggerlib.cpython-36.pyc
5555
RTOC/RTLogger/__pycache__/scriptLibrary.cpython-36.pyc
5656
RTOC/RTLogger/__pycache__/telegramBot.cpython-36.pyc
5757
RTOC/RTLogger/plugins/Generator.py
58+
RTOC/RTLogger/plugins/test.py
5859
RTOC/RTLogger/plugins/Funktionsgenerator/gen_function.ui
5960
RTOC/RTLogger/plugins/__pycache__/Generator.cpython-36.pyc
61+
RTOC/RTLogger/plugins/__pycache__/test.cpython-36.pyc
6062
RTOC/RTOC_GUI/Actions.py
6163
RTOC/RTOC_GUI/PluginDownloader.py
6264
RTOC/RTOC_GUI/RTOC_Import.py
@@ -118,7 +120,6 @@ RTOC/RTOC_GUI/ui/scriptHelpWidget.ui
118120
RTOC/RTOC_GUI/ui/scriptSubWidget.ui
119121
RTOC/RTOC_GUI/ui/scriptWidget.ui
120122
RTOC/RTOC_GUI/ui/settingsWidget.ui
121-
RTOC/RTOC_GUI/ui/signalWidget.ui
122123
RTOC/RTOC_GUI/ui/signalWidget2.ui
123124
RTOC/RTOC_GUI/ui/stylePlotDialog.ui
124125
RTOC/RTOC_GUI/ui/stylePlotDialog2.ui
@@ -164,6 +165,7 @@ RTOC/RTOC_GUI/ui/icons/icons8-transfer.png
164165
RTOC/RTOC_GUI/ui/icons/icons8-viele-bearbeiten-filled-100.png
165166
RTOC/RTOC_GUI/ui/icons/internet.png
166167
RTOC/RTOC_GUI/ui/icons/invert.png
168+
RTOC/RTOC_GUI/ui/icons/invisible.png
167169
RTOC/RTOC_GUI/ui/icons/labels.png
168170
RTOC/RTOC_GUI/ui/icons/left_arrow.png
169171
RTOC/RTOC_GUI/ui/icons/left_arrow_disabled.png
@@ -206,6 +208,7 @@ RTOC/RTOC_GUI/ui/icons/swap.png
206208
RTOC/RTOC_GUI/ui/icons/up_arrow.png
207209
RTOC/RTOC_GUI/ui/icons/up_arrow_disabled.png
208210
RTOC/RTOC_GUI/ui/icons/view.png
211+
RTOC/RTOC_GUI/ui/icons/visible.png
209212
RTOC/RTOC_GUI/ui/icons/x.png
210213
RTOC/RTOC_GUI/ui/icons/xaxislabel.png
211214
RTOC/RTOC_GUI/ui/icons/xtimebase.png
@@ -227,7 +230,5 @@ RTOC/lib/pyqt_customlib.py
227230
RTOC/lib/__pycache__/__init__.cpython-36.pyc
228231
RTOC/lib/__pycache__/general_lib.cpython-36.pyc
229232
RTOC/lib/__pycache__/pyqt_customlib.cpython-36.pyc
230-
RTOC/locales/en_en _fertig.ts
231-
RTOC/locales/en_en.qm
232-
RTOC/locales/en_en.ts
233-
RTOC/locales/en_en_double.ts
233+
RTOC/locales/de_de.qm
234+
RTOC/locales/de_de.ts

RTOC/LoggerPlugin.py

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# LoggerPlugin v2.4
1+
# LoggerPlugin v2.5
22
import traceback
33
import time
44
import sys
@@ -543,53 +543,69 @@ def __updateT(self, func):
543543

544544

545545
class _perpetualTimer():
546-
thread_counter = 0
547546

548547
def __init__(self, hFunction, samplerate=1, lock=None):
548+
self.thread_counter = 0
549549
self._samplerate = samplerate
550550
self._lock = lock
551+
self._cancel = True
551552
self._hFunction = hFunction
552553
self._thread = None
554+
self._correction = -0.006
555+
self._lastStart = 0
553556

554557
def _handle_function(self):
558+
start = time.time()
559+
self._lastStart = time.perf_counter()
555560
self.thread_counter -= 1
556561
if self.thread_counter != 0:
557562
logging.warning('there should not be a running thread, but unfortunately it is.')
558563
print(self.thread_counter)
559564

560-
with self._lock:
561-
start = time.time()
562-
self._hFunction()
563-
diff = time.time() - start
564-
timedelta = 1/self._samplerate - diff
565-
if timedelta < 0:
566-
timedelta = 0
567-
self._thread = Timer(timedelta, self._handle_function)
568-
self.thread_counter += 1
569-
self._thread.start()
565+
if not self._cancel:
566+
with self._lock:
567+
self._hFunction()
568+
diff = time.time() - start # self._lastStart # - start
569+
diff2 = time.perf_counter()-self._lastStart
570+
timedelta = 1/self._samplerate - diff2
571+
timedelta = timedelta + self._correction
572+
if timedelta < 0:
573+
timedelta = 0
574+
if not self._lock.locked() and not self._cancel:
575+
self._thread = Timer(timedelta, self._handle_function)
576+
self.thread_counter += 1
577+
self._thread.start()
570578

571579
def setSamplerate(self, rate):
572-
if rate != self._samplerate:
580+
if rate != self._samplerate and not self._cancel:
573581
self._samplerate = rate
574-
self.cancel()
575-
if self.thread_counter == 0:
576-
self._thread = Timer(1/self._samplerate, self._handle_function)
577-
self.thread_counter += 1
578-
self._thread.start()
579-
else:
580-
logging.warning('Thread should have stopped before changing samplerate, but it didnt.')
582+
# self.start(1/self._samplerate)
583+
if not self._lock.locked():
584+
self.start(0)
585+
# else:
586+
# print('Samplerate changed, but not restarted')
581587

582588
def getSamplerate(self):
583589
return self._samplerate
584590

585-
def start(self):
591+
def start(self, delayed=0):
586592
logging.info('Starting perpetual timer')
587593
self.cancel()
588-
self._thread = Timer(0, self._handle_function)
589-
self.thread_counter += 1
590-
self._thread.start()
594+
self._cancel = False
595+
with self._lock:
596+
if self.thread_counter <= 0:
597+
self._thread = Timer(delayed, self._handle_function)
598+
self.thread_counter += 1
599+
self._thread.start()
600+
if self.thread_counter<0:
601+
logging.warning('Something is not right...')
602+
else:
603+
logging.warning('You cannot start a second perpetual timer.')
604+
print(self.thread_counter)
605+
591606

592607
def cancel(self):
608+
self._cancel = True
593609
if self._thread is not None:
594610
with self._lock:
595611
self._thread.cancel()

RTOC/RTLogger/DeviceFunctions.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ def getDeviceList(self):
5252
# for root, dirs, files in os.walklevel(list(devices.__path__)[0], level=1):
5353
for files in os.listdir(list(devices.__path__)[0]+"/"+folder):
5454
if files.endswith('.py'):
55-
name = devices.__name__+'.'+folder+"."+files.replace('.py', '')
56-
namesplit = name.split('.')
57-
logging.info(name)
58-
59-
devname = namesplit[-1].replace('.', 'Dot').replace(':', 'DDot')
60-
if devname not in ["LoggerPlugin"]:
61-
self.devicenames[devname] = name
62-
self.pluginStatus[devname] = False
55+
file = ''
56+
with open(list(devices.__path__)[0]+"/"+folder+'/'+files, mode='r') as f:
57+
file = f.readlines()
58+
if 'class Plugin(' in ''.join(file):
59+
name = devices.__name__+'.'+folder+"."+files.replace('.py', '')
60+
logging.info(name)
61+
62+
devname = files.replace('.py', '').replace('.', 'Dot').replace(':', 'DDot')
63+
if devname not in ["LoggerPlugin"]:
64+
self.devicenames[devname] = name
65+
self.pluginStatus[devname] = False
6366

6467
# Plugin functions ############################################################
6568

@@ -90,8 +93,6 @@ def startPlugin(self, name, remote=True):
9093
self.analysePlugin(self.pluginObjects[name], name)
9194
self.pluginStatus[name] = True
9295
logging.info("PLUGIN: " + name+' connected\n')
93-
# self.database.addNewEvent(text=translate('RTLogger', "Plugin gestartet: ") +
94-
# name, sname="", dname="RTOC", priority=0)
9596
if self.startDeviceCallback and remote:
9697
self.startDeviceCallback(name)
9798
return True, ""
@@ -292,8 +293,6 @@ def stopPlugin(self, name, remote=True):
292293
self.pluginStatus[name] = False
293294
self.pluginObjects[name].close()
294295
logging.info("PLUGIN: " + name+' disconnected\n')
295-
# self.database.addNewEvent(text=translate('RTLogger', "Plugin gestoppt: ") +
296-
# name, sname="", dname="RTOC", priority=0)
297296
# else:
298297
# logging.debug("Plugin "+name+" not loaded")
299298
if self.stopDeviceCallback and remote:

RTOC/RTLogger/EventActionFunctions.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def loadGlobalEvents(self):
5151
"return": " ",
5252
"priority": 0,
5353
"id": "testID",
54-
'rising': True,
54+
'trigger': 'rising',
5555
'sname': '',
5656
'dname': '',
5757
'active': True
@@ -65,7 +65,7 @@ def loadGlobalEvents(self):
6565
"return": " ",
6666
"priority": 0,
6767
"id": "",
68-
'rising': True,
68+
'trigger': 'rising',
6969
'sname': '',
7070
'dname': '',
7171
'active': False
@@ -124,15 +124,25 @@ def performGlobalEvents(self, y, unit, devicename, signalname, x=None):
124124
self.activeGlobalEvents[key]['latest'] = None
125125
print('First time for this event')
126126

127-
if cond is True and self.activeGlobalEvents[key]['latest'] is not True:
128-
if event['rising']:
129-
self.database.addNewEvent(
130-
text=event['text'], sname=event['sname'], dname=event['dname'], value=event['return'], priority=event['priority'], id=event['id'])
131-
elif cond is False and self.activeGlobalEvents[key]['latest'] is True:
132-
logging.info('Event-Ende: '+devicename+"."+signalname+': '+event['text'])
133-
if not event['rising']:
134-
self.database.addNewEvent(
135-
text=event['text'], sname=event['sname'], dname=event['dname'], value=event['return'], priority=event['priority'], id=event['id'])
127+
triggered = False
128+
if event['trigger']=='true':
129+
if cond is True:
130+
triggered = True
131+
elif event['trigger'] == 'false':
132+
if cond is False:
133+
triggered = True
134+
else:
135+
if cond is True and self.activeGlobalEvents[key]['latest'] is not True:
136+
if event['trigger']=='rising' or event['trigger']=='both':
137+
triggered = True
138+
elif cond is False and self.activeGlobalEvents[key]['latest'] is True:
139+
logging.info('Event-Ende: '+devicename+"."+signalname+': '+event['text'])
140+
if event['trigger']=='falling' or event['trigger']=='both':
141+
triggered = True
142+
143+
if triggered:
144+
self.database.addNewEvent(
145+
text=event['text'], sname=event['sname'], dname=event['dname'], value=event['return'], priority=event['priority'], id=event['id'])
136146

137147
self.activeGlobalEvents[key]['latest'] = cond
138148
else:
@@ -218,22 +228,22 @@ def performGlobalActions(self, id, value):
218228
if action['errors'] is False:
219229
for actionId in action['listenID']:
220230
if actionId == id and action['active']:
221-
# Aktion ausf\xfchren
231+
# Execute action
222232
ok, prints = self.executeScript(action['script'])
223233
print('Performing global action for eventID: ' +
224234
str(id)+' with value: '+str(value))
225235
print('Action is: '+str(action)+', Execution: '+str(ok))
226236
print('Returns:' + str(prints))
227237

228-
def addGlobalEvent(self, name='testEvent', cond='', text='TestEvent', priority=0, retur='', id='testID', rising=True, sname='', dname='', active=True):
238+
def addGlobalEvent(self, name='testEvent', cond='', text='TestEvent', priority=0, retur='', id='testID', trigger='rising', sname='', dname='', active=True):
229239
countname = name
230240
i = 2
231241
while countname in self.globalEvents.keys():
232242
countname = name+str(i)
233243
i += 1
234244
name = countname
235245
self.globalEvents[name] = {'cond': cond, 'text': text,
236-
'priority': priority, 'return': retur, 'id': id, 'rising': rising, 'sname': sname, 'dname': dname, 'active': active}
246+
'priority': priority, 'return': retur, 'id': id, 'trigger': trigger, 'sname': sname, 'dname': dname, 'active': active}
237247

238248
def addGlobalAction(self, name='testAction', listenID='testID', script='', parameters='', active=True):
239249
countname = name
@@ -270,17 +280,17 @@ def printGlobalEvents(self, wo=True):
270280
if event['cond'] != '':
271281
strung.append(name+': '+event['cond'])
272282
else:
273-
strung.append(name+': Ohne Bedingung')
283+
strung.append(name+': '+translate('RTOC', 'No condition'))
274284
return strung
275285

276286
def printGlobalActions(self):
277287
strung = []
278288
for name in self.globalActions.keys():
279289
event = self.globalActions[name]
280290
if event['listenID'] != []:
281-
strung.append(name+' bei '+', '.join(event['listenID']))
291+
strung.append(name+': '+', '.join(event['listenID']))
282292
else:
283-
strung.append(name+': Ohne Zuordnung')
293+
strung.append(name+': '+translate('RTOC', 'No event connected'))
284294
return strung
285295

286296
def triggerGlobalEvent(self, key):
@@ -289,12 +299,12 @@ def triggerGlobalEvent(self, key):
289299
ok, cond = self.checkCondition(event['cond'])
290300
if ok:
291301
# cond = bool(cond)
292-
text = translate('RTOC', 'Bedingung ist in Ordnung\nAntwort: ')+str(cond)
302+
text = translate('RTOC', 'Condition is valid\nAnswer: ')+str(cond)
293303
self.database.addNewEvent(text=event['text'], sname=event['sname'], dname=event['dname'],
294304
value=event['return'], priority=event['priority'], id=event['id'])
295305
return True, text
296306
else:
297-
text = translate('RTOC', 'Bedingung ist ung\xfcltig\nAntwort: ')+str(cond)
307+
text = translate('RTOC', 'Condition is invalid!\nAnswer: ')+str(cond)
298308
return False, text
299309
return False, None
300310

@@ -303,9 +313,9 @@ def triggerGlobalAction(self, key):
303313
action = self.globalActions[key]
304314
ok, prints = self.executeScript(action['script'])
305315
if ok:
306-
text = translate('RTOC', 'Aktion ist in Ordnung\nAntwort: ')+str(prints)
316+
text = translate('RTOC', 'Action is valid\nAnswer: ')+str(prints)
307317
return True, text
308318
else:
309-
text = translate('RTOC', 'Aktion ist ung\xfcltig\nAntwort: ')+str(prints)
319+
text = translate('RTOC', 'Action is invalid!\nAnswer: ')+str(prints)
310320
return False, text
311321
return False, None

0 commit comments

Comments
 (0)