1
0
mirror of https://github.com/naruxde/revpipycontrol.git synced 2025-11-08 23:53:52 +01:00

Maximale Bytel?nge f?r int() berechnung festgelegt 32Bit Systeme

This commit is contained in:
2017-07-03 12:59:55 +02:00
parent 03773ff4b0
commit 5488107c42
3 changed files with 31 additions and 4 deletions

View File

@@ -82,6 +82,9 @@ Methods</h3>
<td><a style="color:#0000FF" href="#RevPiCheckClient.hideallwindows">hideallwindows</a></td> <td><a style="color:#0000FF" href="#RevPiCheckClient.hideallwindows">hideallwindows</a></td>
<td>Versteckt alle Fenster.</td> <td>Versteckt alle Fenster.</td>
</tr><tr> </tr><tr>
<td><a style="color:#0000FF" href="#RevPiCheckClient.maxint">maxint</a></td>
<td>Errechnet maximalen int() Wert f&#252;r Bytes max 22.</td>
</tr><tr>
<td><a style="color:#0000FF" href="#RevPiCheckClient.readvalues">readvalues</a></td> <td><a style="color:#0000FF" href="#RevPiCheckClient.readvalues">readvalues</a></td>
<td>Ruft nur Input Werte von RevPi ab und aktualisiert Fenster.</td> <td>Ruft nur Input Werte von RevPi ab und aktualisiert Fenster.</td>
</tr><tr> </tr><tr>
@@ -236,7 +239,23 @@ RevPiCheckClient.hideallwindows</h3>
<b>hideallwindows</b>(<i></i>) <b>hideallwindows</b>(<i></i>)
<p> <p>
Versteckt alle Fenster. Versteckt alle Fenster.
</p><a NAME="RevPiCheckClient.readvalues" ID="RevPiCheckClient.readvalues"></a> </p><a NAME="RevPiCheckClient.maxint" ID="RevPiCheckClient.maxint"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000">
RevPiCheckClient.maxint</h3>
<b>maxint</b>(<i>bytelen</i>)
<p>
Errechnet maximalen int() Wert f&#252;r Bytes max 22.
</p><dl>
<dt><i>bytelen</i></dt>
<dd>
Anzahl Bytes
</dd>
</dl><dl>
<dt>Returns:</dt>
<dd>
int() max oder 0 bei &#220;berschreitung
</dd>
</dl><a NAME="RevPiCheckClient.readvalues" ID="RevPiCheckClient.readvalues"></a>
<h3 style="background-color:#FFFFFF;color:#FF0000"> <h3 style="background-color:#FFFFFF;color:#FF0000">
RevPiCheckClient.readvalues</h3> RevPiCheckClient.readvalues</h3>
<b>readvalues</b>(<i></i>) <b>readvalues</b>(<i></i>)

View File

@@ -11,6 +11,7 @@ revpicheckclient.RevPiCheckClient._onfrmconf?5(canvas)
revpicheckclient.RevPiCheckClient._warnwrite?5() revpicheckclient.RevPiCheckClient._warnwrite?5()
revpicheckclient.RevPiCheckClient._workvalues?5(io_dicts=None, writeout=False) revpicheckclient.RevPiCheckClient._workvalues?5(io_dicts=None, writeout=False)
revpicheckclient.RevPiCheckClient.hideallwindows?4() revpicheckclient.RevPiCheckClient.hideallwindows?4()
revpicheckclient.RevPiCheckClient.maxint?4(bytelen)
revpicheckclient.RevPiCheckClient.readvalues?4() revpicheckclient.RevPiCheckClient.readvalues?4()
revpicheckclient.RevPiCheckClient.refreshvalues?4() revpicheckclient.RevPiCheckClient.refreshvalues?4()
revpicheckclient.RevPiCheckClient.tmr_workvalues?4() revpicheckclient.RevPiCheckClient.tmr_workvalues?4()

View File

@@ -96,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 > 256 ** io[1] - 1: if newvalue < 0 or newvalue > self.maxint(io[1]):
raise ValueError("too big") raise ValueError("too big")
self.__chval(device, io) self.__chval(device, io)
@@ -177,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=256 ** io[1] - 1) txt = tkinter.Spinbox(s_frame, to=self.maxint(io[1]))
txt.bind( txt.bind(
"<Key>", "<Key>",
lambda event, tkvar=var: self.__saveoldvalue(event, tkvar) lambda event, tkvar=var: self.__saveoldvalue(event, tkvar)
@@ -189,7 +189,8 @@ 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" or \
self.maxint(io[1]) == 0 else "normal"
txt["width"] = 5 txt["width"] = 5
txt["textvariable"] = var txt["textvariable"] = var
txt.grid(column=1, row=rowcount) txt.grid(column=1, row=rowcount)
@@ -363,6 +364,12 @@ class RevPiCheckClient(tkinter.Frame):
for win in self.dict_wins: for win in self.dict_wins:
self.dict_wins[win].withdraw() self.dict_wins[win].withdraw()
def maxint(self, bytelen):
u"""Errechnet maximalen int() Wert für Bytes max 22.
@param bytelen Anzahl Bytes
@return int() max oder 0 bei Überschreitung"""
return 0 if bytelen > 22 else 256 ** bytelen - 1
def readvalues(self): def readvalues(self):
u"""Ruft nur Input Werte von RevPi ab und aktualisiert Fenster.""" u"""Ruft nur Input Werte von RevPi ab und aktualisiert Fenster."""
if not self.autorw.get(): if not self.autorw.get():