mirror of
https://github.com/naruxde/revpipycontrol.git
synced 2025-11-08 23:53:52 +01:00
RevPiCheckClient Fehler z?hlen und ggf. Fenster verwerfen
RevPiCheckControl baut RevPiCheckClient nach max Fehler neu auf
This commit is contained in:
@@ -225,6 +225,11 @@ Arbeit nur für dieses Dict()
|
|||||||
<dd>
|
<dd>
|
||||||
Änderungen auf RevPi schreiben
|
Änderungen auf RevPi schreiben
|
||||||
</dd>
|
</dd>
|
||||||
|
</dl><dl>
|
||||||
|
<dt>Returns:</dt>
|
||||||
|
<dd>
|
||||||
|
None
|
||||||
|
</dd>
|
||||||
</dl><a NAME="RevPiCheckClient.hideallwindows" ID="RevPiCheckClient.hideallwindows"></a>
|
</dl><a NAME="RevPiCheckClient.hideallwindows" ID="RevPiCheckClient.hideallwindows"></a>
|
||||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
RevPiCheckClient.hideallwindows</h3>
|
RevPiCheckClient.hideallwindows</h3>
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ class RevPiCheckClient(tkinter.Frame):
|
|||||||
self.lst_devices = [d[0] for d in self.lst_devices]
|
self.lst_devices = [d[0] for d in self.lst_devices]
|
||||||
self.dict_inps = pickle.loads(self.cli.ps_inps().data)
|
self.dict_inps = pickle.loads(self.cli.ps_inps().data)
|
||||||
self.dict_outs = pickle.loads(self.cli.ps_outs().data)
|
self.dict_outs = pickle.loads(self.cli.ps_outs().data)
|
||||||
|
self.err_workvalues = 0
|
||||||
|
self.max_errors = 25
|
||||||
|
|
||||||
self.lk = Lock()
|
self.lk = Lock()
|
||||||
self.dict_wins = {}
|
self.dict_wins = {}
|
||||||
@@ -94,7 +96,7 @@ class RevPiCheckClient(tkinter.Frame):
|
|||||||
try:
|
try:
|
||||||
newvalue = io[5].get()
|
newvalue = io[5].get()
|
||||||
# Wertebereich prüfen
|
# Wertebereich prüfen
|
||||||
if newvalue < 0 or newvalue > 255 * io[1]:
|
if newvalue < 0 or newvalue > 256 ** io[1] - 1:
|
||||||
raise ValueError("too big")
|
raise ValueError("too big")
|
||||||
|
|
||||||
self.__chval(device, io)
|
self.__chval(device, io)
|
||||||
@@ -175,7 +177,7 @@ class RevPiCheckClient(tkinter.Frame):
|
|||||||
check.grid(column=1, row=rowcount)
|
check.grid(column=1, row=rowcount)
|
||||||
else:
|
else:
|
||||||
var = tkinter.IntVar()
|
var = tkinter.IntVar()
|
||||||
txt = tkinter.Spinbox(s_frame, to=255 * io[1])
|
txt = tkinter.Spinbox(s_frame, to=256 ** io[1] - 1)
|
||||||
txt.bind(
|
txt.bind(
|
||||||
"<Key>",
|
"<Key>",
|
||||||
lambda event, tkvar=var: self.__saveoldvalue(event, tkvar)
|
lambda event, tkvar=var: self.__saveoldvalue(event, tkvar)
|
||||||
@@ -188,7 +190,7 @@ class RevPiCheckClient(tkinter.Frame):
|
|||||||
txt["command"] = \
|
txt["command"] = \
|
||||||
lambda device=device, io=io: self.__chval(device, io)
|
lambda device=device, io=io: self.__chval(device, io)
|
||||||
txt["state"] = "disabled" if iotype == "inp" else "normal"
|
txt["state"] = "disabled" if iotype == "inp" else "normal"
|
||||||
txt["width"] = 4
|
txt["width"] = 5
|
||||||
txt["textvariable"] = var
|
txt["textvariable"] = var
|
||||||
txt.grid(column=1, row=rowcount)
|
txt.grid(column=1, row=rowcount)
|
||||||
|
|
||||||
@@ -290,16 +292,32 @@ class RevPiCheckClient(tkinter.Frame):
|
|||||||
|
|
||||||
def _workvalues(self, io_dicts=None, writeout=False):
|
def _workvalues(self, io_dicts=None, writeout=False):
|
||||||
u"""Alle Werte der Inputs und Outputs abrufen.
|
u"""Alle Werte der Inputs und Outputs abrufen.
|
||||||
@param io_dicts Arbeit nur für dieses Dict()
|
|
||||||
@param writeout Änderungen auf RevPi schreiben"""
|
|
||||||
|
|
||||||
|
@param io_dicts Arbeit nur für dieses Dict()
|
||||||
|
@param writeout Änderungen auf RevPi schreiben
|
||||||
|
@return None
|
||||||
|
|
||||||
|
"""
|
||||||
# Abfragelisten vorbereiten
|
# Abfragelisten vorbereiten
|
||||||
if io_dicts is None:
|
if io_dicts is None:
|
||||||
io_dicts = [self.dict_inps, self.dict_outs]
|
io_dicts = [self.dict_inps, self.dict_outs]
|
||||||
|
|
||||||
# Werte abrufen
|
# Werte abrufen
|
||||||
with self.lk:
|
with self.lk:
|
||||||
|
try:
|
||||||
ba_values = bytearray(self.cli.ps_values().data)
|
ba_values = bytearray(self.cli.ps_values().data)
|
||||||
|
self.err_workvalues = 0
|
||||||
|
except:
|
||||||
|
if self.autorw.get():
|
||||||
|
self.err_workvalues += 1
|
||||||
|
else:
|
||||||
|
self.err_workvalues = self.max_errors
|
||||||
|
|
||||||
|
if self.err_workvalues >= self.max_errors:
|
||||||
|
self.hideallwindows()
|
||||||
|
self.pack_forget()
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
# Multicall zum Schreiben vorbereiten
|
# Multicall zum Schreiben vorbereiten
|
||||||
if writeout:
|
if writeout:
|
||||||
@@ -362,11 +380,12 @@ class RevPiCheckClient(tkinter.Frame):
|
|||||||
if not self.autorw.get():
|
if not self.autorw.get():
|
||||||
try:
|
try:
|
||||||
self.chk_auto["state"] = "normal"
|
self.chk_auto["state"] = "normal"
|
||||||
self._workvalues()
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
self._workvalues()
|
||||||
|
|
||||||
self.master.after(200, self.tmr_workvalues)
|
self.master.after(200, self.tmr_workvalues)
|
||||||
|
|
||||||
def toggleauto(self):
|
def toggleauto(self):
|
||||||
|
|||||||
@@ -240,7 +240,9 @@ class RevPiPyControl(tkinter.Frame):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Debugfenster laden
|
# Debugfenster laden
|
||||||
if self.debugframe is None:
|
if self.debugframe is None \
|
||||||
|
or self.debugframe.err_workvalues >= \
|
||||||
|
self.debugframe.max_errors:
|
||||||
self.debugframe = revpicheckclient.RevPiCheckClient(
|
self.debugframe = revpicheckclient.RevPiCheckClient(
|
||||||
self, self.cli, self.xmlmode
|
self, self.cli, self.xmlmode
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user