# uncompyle6 version 3.9.3 # Python bytecode version base 2.6 (62161) # Decompiled from: Python 3.9.25 (main, Oct 31 2025, 23:16:49) # [GCC 14.2.0] # Embedded file name: user_config_timer.pyc # Compiled at: 2022-05-31 09:29:42 import wx, os, data_model, traceback, one_unit, ConfigParser, protocol, sys, select_keys, select_units, d_protocol, mytime from user_config_helpers import * hourChoices = [_[1] for c in range(2, 23, 1)] minuteChoices = [_[2] for c in range(0, 60, 5)] import string print string.ascii_lowercase days = (getString('monday'), getString('tuesday'), getString('wednesday'), getString('thursday'), getString('friday'), getString('saturday'), getString('sunday')) numberOfLines = 10 pageOffset = {'a': 0, 'b': numberOfLines, 'c': (numberOfLines * 2)} class setTimer(wx.Panel): def __init__(self, parent, frame, uiNumber, panelName): self.frame = frame self.name = panelName self.uiNumber = int(uiNumber[:-1]) page = uiNumber[-1] self.pageOffset = pageOffset[page] self.parent = parent self.lines = {} wx.Panel.__init__(self, parent, size=(934, 500)) self.Show(True) self.initFinished = False return def initMe(self, force=False): if self.IsShown() == False and force == False: return else: if self.initFinished == True: return 0 print mytime.displayTime(), 'uct.initMe setTimer', self.name frame = self.frame uiNumber = self.uiNumber self.checkBoxes = {} self.uiKeys = getKeys(frame, self.uiNumber) self.preset_names = {} for i in range(255): namekey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_SHORT_NAME, i, 0) name = self.frame.frame.parent.model.get(namekey) if name == None: continue if name.lower().strip() in ('empty preset', 'empty'): continue self.preset_names[name] = i self.lines = {} wx.StaticText(self, -1, 'Preset', pos=(220, 14)) wx.StaticText(self, -1, 'M', pos=(330, 14)) wx.StaticText(self, -1, 'T', pos=(346, 14)) wx.StaticText(self, -1, 'W', pos=(362, 14)) wx.StaticText(self, -1, 'T', pos=(378, 14)) wx.StaticText(self, -1, 'F', pos=(394, 14)) wx.StaticText(self, -1, 'S', pos=(410, 14)) wx.StaticText(self, -1, 'S', pos=(426, 14)) wx.StaticText(self, -1, 'Preset', pos=(670, 14)) wx.StaticText(self, -1, 'M', pos=(780, 14)) wx.StaticText(self, -1, 'T', pos=(796, 14)) wx.StaticText(self, -1, 'W', pos=(812, 14)) wx.StaticText(self, -1, 'T', pos=(828, 14)) wx.StaticText(self, -1, 'F', pos=(844, 14)) wx.StaticText(self, -1, 'S', pos=(860, 14)) wx.StaticText(self, -1, 'S', pos=(876, 14)) for i in range(numberOfLines): self.createLine(i) if self.pageOffset == 0: self.createLine(numberOfLines) for uiIndex in self.uiKeys: (key, val) = self.uiKeys[uiIndex] print mytime.displayTime(), 'uct.key:', key, val lineNumber = (val[1] & 31) - self.pageOffset if lineNumber >= 0 and lineNumber < numberOfLines: self.lines[lineNumber].key = key if lineNumber == 0 and self.pageOffset == 0: if val[1] & 32 == 32: self.lines[numberOfLines - 1].enable.SetValue(1) self.enable() p = self.lines[lineNumber] time = val[2] preset = val[3] for presetString in self.preset_names.keys(): if self.preset_names[presetString] == preset: preset = presetString break days = val[4] hours = time / 12 minutes = (time - hours * 12) * 5 hours += 2 p.hour1.SetStringSelection(('0' + str(hours))[-2:]) p.minute1.SetStringSelection(('0' + str(minutes))[-2:]) try: p.preset1.SetStringSelection(preset) except: pass else: p.enable1.SetValue(days & 128) p.mon1.SetValue(days & 64) p.tue1.SetValue(days & 32) p.wed1.SetValue(days & 16) p.thu1.SetValue(days & 8) p.fri1.SetValue(days & 4) p.sat1.SetValue(days & 2) p.sun1.SetValue(days & 1) time = val[5] preset = val[6] for presetString in self.preset_names.keys(): if self.preset_names[presetString] == preset: preset = presetString break days = val[7] hours = time / 12 minutes = (time - hours * 12) * 5 hours += 2 p.hour2.SetStringSelection(('0' + str(hours))[-2:]) p.minute2.SetStringSelection(('0' + str(minutes))[-2:]) try: p.preset2.SetStringSelection(preset) except: pass else: p.enable2.SetValue(days & 128) p.mon2.SetValue(days & 64) p.tue2.SetValue(days & 32) p.wed2.SetValue(days & 16) p.thu2.SetValue(days & 8) p.fri2.SetValue(days & 4) p.sat2.SetValue(days & 2) p.sun2.SetValue(days & 1) self.enableLine(lineNumber) self.enableLine(lineNumber | 128) if val[1] & 31 == 31 and self.pageOffset == 0: self.rtc = str(val[2]) + '-' + str(val[3]) + '-' + str(val[4]) + ' ' + str(val[5]) + ':' + str(val[6]) + ':' + str(val[7]) print mytime.displayTime(), 'uct.RTC', self.rtc self.lines[numberOfLines].currentTime.SetLabel(self.rtc) self.lines[numberOfLines].key = key self.initFinished = True self.Show(True) return def createLine(self, lineNumber): if lineNumber >= numberOfLines - 1: h = 100 else: h = 26 p = wx.Panel(self, size=(934, h)) p.lineNumber = lineNumber p.Show(False) if lineNumber < numberOfLines: p.hour1 = wx.Choice(p, -1, choices=hourChoices, style=wx.BORDER_NONE, pos=(100, 0), size=(50, 26)) p.hour1.SetStringSelection(hourChoices[0]) p.l2 = wx.StaticText(p, -1, ':', pos=(151, 3)) p.minute1 = wx.Choice(p, -1, choices=minuteChoices, style=wx.BORDER_NONE, pos=(160, 0), size=(50, 26)) p.minute1.SetStringSelection(minuteChoices[0]) p.preset1 = wx.Choice(p, -1, choices=self.preset_names.keys(), style=wx.BORDER_NONE, pos=(220, 0), size=(100, 26)) p.preset1.SetStringSelection(self.preset_names.keys()[0]) p.enable1 = wx.CheckBox(p, lineNumber, 'Enable', pos=(30, 3)) self.Bind(wx.EVT_CHECKBOX, self.OnEnableLine, p.enable1) p.mon1 = wx.CheckBox(p, -1, '', pos=(330, 5), size=(15, 15)) p.tue1 = wx.CheckBox(p, -1, '', pos=(346, 5), size=(15, 15)) p.wed1 = wx.CheckBox(p, -1, '', pos=(362, 5), size=(15, 15)) p.thu1 = wx.CheckBox(p, -1, '', pos=(378, 5), size=(15, 15)) p.fri1 = wx.CheckBox(p, -1, '', pos=(394, 5), size=(15, 15)) p.sat1 = wx.CheckBox(p, -1, '', pos=(410, 5), size=(15, 15)) p.sun1 = wx.CheckBox(p, -1, '', pos=(426, 5), size=(15, 15)) p.hour2 = wx.Choice(p, -1, choices=hourChoices, style=wx.BORDER_NONE, pos=(550, 0), size=(50, 26)) p.hour2.SetStringSelection(hourChoices[0]) p.l3 = wx.StaticText(p, -1, ':', pos=(601, 3)) p.minute2 = wx.Choice(p, -1, choices=minuteChoices, style=wx.BORDER_NONE, pos=(610, 0), size=(50, 26)) p.minute2.SetStringSelection(minuteChoices[0]) p.preset2 = wx.Choice(p, -1, choices=self.preset_names.keys(), style=wx.BORDER_NONE, pos=(670, 0), size=(100, 26)) p.preset2.SetStringSelection(self.preset_names.keys()[0]) p.enable2 = wx.CheckBox(p, lineNumber | 128, 'Enable', pos=(480, 3)) self.Bind(wx.EVT_CHECKBOX, self.OnEnableLine, p.enable2) p.mon2 = wx.CheckBox(p, -1, '', pos=(780, 5), size=(15, 15)) p.tue2 = wx.CheckBox(p, -1, '', pos=(796, 5), size=(15, 15)) p.wed2 = wx.CheckBox(p, -1, '', pos=(812, 5), size=(15, 15)) p.thu2 = wx.CheckBox(p, -1, '', pos=(828, 5), size=(15, 15)) p.fri2 = wx.CheckBox(p, -1, '', pos=(844, 5), size=(15, 15)) p.sat2 = wx.CheckBox(p, -1, '', pos=(860, 5), size=(15, 15)) p.sun2 = wx.CheckBox(p, -1, '', pos=(876, 5), size=(15, 15)) if lineNumber == numberOfLines - 1 and self.pageOffset == 0: p.enable = wx.CheckBox(p, -1, getString('ent'), pos=(30, 70), size=(100, 15)) p.enable.SetValue(0) self.Bind(wx.EVT_CHECKBOX, self.OnEnable, p.enable) p.SetPosition((0, 30 + 26 * lineNumber)) else: p.timeLabel = wx.StaticText(p, -1, 'Current time in unit:', pos=(30, 0), size=(150, 22)) p.currentTime = wx.StaticText(p, -1, 'Not set', pos=(208, 0), size=(70, 22)) p.timeLabel2 = wx.StaticText(p, -1, 'The unit time will be automatically aligned with the actual time when settings are applied.', pos=(30, 16), size=(750, 22)) p.SetPosition((0, 100 + 26 * lineNumber)) p.key = None self.lines[lineNumber] = p p.Show(True) if lineNumber == numberOfLines - 1: self.enable() if lineNumber < numberOfLines: self.enableLine(lineNumber) self.enableLine(lineNumber | 128) return p def OnEnableLine(self, e): self.enableLine(e.GetId()) return def enableLine(self, id): lineNumber = id & 31 p = self.lines[lineNumber] if id & 128 == 0: val = p.enable1.GetValue() p.hour1.Enable(val) p.minute1.Enable(val) p.preset1.Enable(val) p.mon1.Enable(val) p.tue1.Enable(val) p.wed1.Enable(val) p.thu1.Enable(val) p.fri1.Enable(val) p.sat1.Enable(val) p.sun1.Enable(val) if lineNumber > 0 and val and p.mon1.GetValue() == 0 and p.tue1.GetValue() == 0 and p.wed1.GetValue() == 0 and p.thu1.GetValue() == 0 and p.fri1.GetValue() == 0 and p.sat1.GetValue() == 0 and p.sun1.GetValue() == 0: p2 = self.lines[lineNumber - 1] if p.hour1.GetStringSelection() != '02': return if p.minute1.GetStringSelection() != '00': return p.hour1.SetStringSelection(p2.hour2.GetStringSelection()) p.minute1.SetStringSelection(p2.minute2.GetStringSelection()) p.mon1.SetValue(p2.mon2.GetValue()) p.tue1.SetValue(p2.tue2.GetValue()) p.wed1.SetValue(p2.wed2.GetValue()) p.thu1.SetValue(p2.thu2.GetValue()) p.fri1.SetValue(p2.fri2.GetValue()) p.sat1.SetValue(p2.sat2.GetValue()) p.sun1.SetValue(p2.sun2.GetValue()) p.preset1.SetStringSelection(p2.preset2.GetStringSelection()) else: val = p.enable2.GetValue() p.hour2.Enable(val) p.minute2.Enable(val) p.preset2.Enable(val) p.mon2.Enable(val) p.tue2.Enable(val) p.wed2.Enable(val) p.thu2.Enable(val) p.fri2.Enable(val) p.sat2.Enable(val) p.sun2.Enable(val) if lineNumber >= 0 and val and p.mon2.GetValue() == 0 and p.tue2.GetValue() == 0 and p.wed2.GetValue() == 0 and p.thu2.GetValue() == 0 and p.fri2.GetValue() == 0 and p.sat2.GetValue() == 0 and p.sun2.GetValue() == 0: if p.hour2.GetStringSelection() != '02': return if p.minute2.GetStringSelection() != '00': return p.hour2.SetStringSelection(p.hour1.GetStringSelection()) p.minute2.SetStringSelection(p.minute1.GetStringSelection()) p.mon2.SetValue(p.mon1.GetValue()) p.tue2.SetValue(p.tue1.GetValue()) p.wed2.SetValue(p.wed1.GetValue()) p.thu2.SetValue(p.thu1.GetValue()) p.fri2.SetValue(p.fri1.GetValue()) p.sat2.SetValue(p.sat1.GetValue()) p.sun2.SetValue(p.sun1.GetValue()) p.preset2.SetStringSelection(p.preset1.GetStringSelection()) return def OnEnable(self, e): self.enable() return def enable(self): return def OnCopy(self, e): lineNumber = e.GetId() - 20 for i in range(48): self.lines[lineNumber].timeSlot[i].SetValue(self.lines[lineNumber - 1].timeSlot[i].GetValue()) return def OnClear(self, e): lineNumber = e.GetId() - 30 for i in range(48): self.lines[lineNumber].timeSlot[i].SetValue(0) return def evaluateLine(self, line): try: if line.lineNumber < numberOfLines: val = {} hour = (int(line.hour1.GetStringSelection()) - 2) * 12 minute = int(line.minute1.GetStringSelection()) / 5 time = hour + minute enable = line.enable1.GetValue() << 7 mon = line.mon1.GetValue() << 6 tue = line.tue1.GetValue() << 5 wed = line.wed1.GetValue() << 4 thu = line.thu1.GetValue() << 3 fri = line.fri1.GetValue() << 2 sat = line.sat1.GetValue() << 1 sun = line.sun1.GetValue() << 0 try: preset = self.preset_names[line.preset1.GetStringSelection()] except: preset = 1 else: if preset > 255: preset = 255 if time > 255: time = 255 val[0] = time val[1] = preset val[2] = enable | mon | tue | wed | thu | fri | sat | sun hour = (int(line.hour2.GetStringSelection()) - 2) * 12 minute = int(line.minute2.GetStringSelection()) / 5 time = hour + minute enable = line.enable2.GetValue() << 7 mon = line.mon2.GetValue() << 6 tue = line.tue2.GetValue() << 5 wed = line.wed2.GetValue() << 4 thu = line.thu2.GetValue() << 3 fri = line.fri2.GetValue() << 2 sat = line.sat2.GetValue() << 1 sun = line.sun2.GetValue() << 0 try: preset = self.preset_names[line.preset2.GetStringSelection()] except: preset = 0 else: if preset > 255: preset = 255 if time > 255: time = 255 val[3] = time val[4] = preset val[5] = enable | mon | tue | wed | thu | fri | sat | sun flags = 0 if line.lineNumber == 0 and self.pageOffset == 0: if self.lines[numberOfLines - 1].enable.GetValue(): flags |= 32 structID = line.lineNumber + self.pageOffset | flags else: import datetime nowString = datetime.datetime.now().strftime('%y-%m-%d-%H-%M-%S') print mytime.displayTime(), 'uct.tijd zetten op', nowString val = [_[1] for c in nowString.split('-')] structID = 31 val[1] |= 128 try: sendString = '' + chr(self.uiNumber) sendString += chr(structID) sendString += chr(val[0]) sendString += chr(val[1]) sendString += chr(val[2]) sendString += chr(val[3]) sendString += chr(val[4]) sendString += chr(val[5]) mys = 'uct.String: ' for c in sendString: mys += hex(ord(c)) + ':' print mys return sendString except: print mytime.displayTime(), 'uct.eL.failed to build string' traceback.print_exc(file=sys.stdout) except: traceback.print_exc(file=sys.stdout) return # okay decompiling pycode/user_config_timer.pyc