Läuft die Voice Acoustic VA-Remotecontrol (AllDSP AllControl) nativ unter Linux auf echtem wxGTK 3.0 — ohne Wine und ohne dekompilierten App-Code. Ausgeführt wird das unveränderte Python-2.7-Bytecode aus dem macOS-.app; C-Extensions (wxGTK/numpy/ scipy/PortAudio) kommen nativ aus Debian stretch. Enthält: va/ (Original-.pyc + pure-Python-Libs + Assets + launch.py mit den drei Linux-Fixes), Dockerfile/run.sh/entrypoint.sh, reference/ (dekompilierter Quellcode zum Debuggen) und README/STATUS. img.cache (378 MB, regenerierbar) ist per .gitignore ausgeschlossen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1013 lines
47 KiB
Python
1013 lines
47 KiB
Python
# 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_dc.pyc
|
|
# Compiled at: 2025-03-13 16:01:06
|
|
import wx, os, data_model, traceback, one_unit, ConfigParser, protocol, sys, select_keys, select_units, d_protocol, mytime, math
|
|
from definitions import *
|
|
adcTypeChoices = {0: 'Voltage / Potentiometer (Default)', 1: 'Temperature Sensor (Linear Voltage Output)', 2: 'Temperature Sensor (NTC with pull-up)', 3: 'DS18B20 Digital Sensor'}
|
|
from user_config_helpers import *
|
|
FREQUENCY_LOG_CONSTANT = 1.02767
|
|
|
|
class ADC_input(wx.Panel):
|
|
|
|
def __init__(self, parent, frame, uiNumber, panelName):
|
|
self.frame = frame
|
|
self.name = panelName
|
|
self.uiNumber = uiNumber
|
|
self.parent = parent
|
|
self.isTemperature = False
|
|
wx.Panel.__init__(self, parent, size=(964, 500))
|
|
self.initFinished = False
|
|
self.lines = {}
|
|
self.Show(True)
|
|
return
|
|
|
|
def initMe(self, force=False):
|
|
if self.IsShown() == False and force == False:
|
|
return
|
|
if self.initFinished == True:
|
|
return 0
|
|
print mytime.displayTime(), 'ucd.initMe DC In', self.name
|
|
strItem = wx.StaticText(self, -1, 'Item', pos=(100, 138))
|
|
strSubItem = wx.StaticText(self, -1, 'Sub-Item', pos=(210, 138))
|
|
strChannel = wx.StaticText(self, -1, 'Channel', pos=(320, 138))
|
|
strIndex = wx.StaticText(self, -1, 'Index', pos=(430, 138))
|
|
self.strMin = wx.StaticText(self, -1, 'Min / Low', pos=(490, 138))
|
|
self.strCenter = wx.StaticText(self, -1, 'Center', pos=(570, 138))
|
|
self.strMax = wx.StaticText(self, -1, 'Max / High', pos=(650, 138))
|
|
frame = self.frame
|
|
uiNumber = self.uiNumber
|
|
self.stridChoices = [20, 21, 22, 23, 24, 25, 26, 27, 28, 29]
|
|
self.numberOfFactoryItems = 0
|
|
self.membidChoices = {'Disabled': [''], 'Gain': ['Gain'], 'HPF': ['Frequency'], 'LPF': ['Frequency'], 'PEQ': ['Gain', 'Frequency'], 'Mute': ['Mute'], 'Protect': ['Protect'], 'Compressor': ['Threshold'], 'Limiter': ['Threshold'], 'Delay': ['Delay']}
|
|
self.indexChoices = {'Disabled': '1', 'Gain': ['1', '2'], 'HPF': ['1'], 'LPF': ['1'], 'PEQ': [33, 34, 35, 36, 37, 38, 39, 40, 41, 42], 'Mute': ['1'], 'Protect': ['1'], 'Compressor': ['1', '2', '3', '4'], 'Limiter': ['1'], 'Delay': ['1']}
|
|
self.channels = {127: 'All Inputs', 255: 'All Outputs'}
|
|
self.temperatureSensorChannels = {}
|
|
for c in self.frame.frame.parent.unit_channels:
|
|
if c < 128:
|
|
s = 'Input ' + str(c + 1)
|
|
else:
|
|
s = 'Output ' + str(c - 127)
|
|
self.temperatureSensorChannels[c] = s
|
|
self.channels[c] = s
|
|
|
|
self.configKeys = getKeys(frame, uiNumber + 63)
|
|
self.createConfigLine()
|
|
teller = 0
|
|
for uiIndex in self.configKeys:
|
|
(key, val) = self.configKeys[uiIndex]
|
|
if teller > 0:
|
|
self.frame.frame.clear(self.frame, uiNumber + 63, key=key)
|
|
continue
|
|
p = self.lines[0]
|
|
p.adcTypeChoice.SetStringSelection(adcTypeChoices[val[1] & 15])
|
|
if val[1] & 15 != 0:
|
|
self.isTemperature = True
|
|
p.inputRangeMin.SetValue(str(round(float(val[4]) / 50.0, 2)) + ' V')
|
|
p.inputRangeMax.SetValue(str(round(float(val[5]) / 50.0, 2)) + ' V')
|
|
p.outputRangeMin.SetValue(str(round(float(val[6]) / 2)) + ' ' + u'\xb0C')
|
|
p.outputRangeMax.SetValue(str(round(float(val[7]) / 2)) + ' ' + u'\xb0C')
|
|
p.channelChoice.SetStringSelection('Output ' + str(1 + (val[3] & 15)))
|
|
if val[1] & 16 == 0:
|
|
p.aggregate.SetValue(0)
|
|
if val[1] & 32 == 0:
|
|
p.fanControl.SetValue(0)
|
|
p.key = key
|
|
p.checkBox.SetValue(1)
|
|
self.enableConfig()
|
|
teller += 1
|
|
|
|
self.uiKeys = getKeys(frame, uiNumber)
|
|
i = 1
|
|
for uiIndex in self.uiKeys:
|
|
(key, val) = self.uiKeys[uiIndex]
|
|
if key.channel != 1 or key.index < 128:
|
|
continue
|
|
print mytime.displayTime(), 'ucd.factory key', key, val
|
|
self.createLine(i)
|
|
self.lines[i].key = key
|
|
self.lines[i].val = val
|
|
self.lines[i].checkBox.Enable(False)
|
|
self.lines[i].checkBox.SetLabel('Factory ' + str(i + 1))
|
|
self.lines[i].struct_id_choice.Enable(False)
|
|
self.lines[i].member_id_choice.Enable(False)
|
|
self.lines[i].channel_choice.Enable(False)
|
|
self.lines[i].index_choice.Enable(False)
|
|
self.lines[i].min.Enable(False)
|
|
self.lines[i].center.Enable(False)
|
|
self.lines[i].max.Enable(False)
|
|
self.lines[i].checkBox.SetValue(True)
|
|
self.lines[i].struct_id_choice.SetStringSelection(protocol.get_strid_text(val[1] & 127))
|
|
self.numberOfFactoryItems = i + 1
|
|
self.enable(i)
|
|
i += 1
|
|
|
|
for uiIndex in self.uiKeys:
|
|
(key, val) = self.uiKeys[uiIndex]
|
|
if key.channel == 1 and key.index >= 128:
|
|
continue
|
|
print mytime.displayTime(), 'ucd.user key', key, val, protocol.get_strid_text(val[1] & 127)
|
|
self.createLine(i)
|
|
self.lines[i].key = key
|
|
self.lines[i].val = val
|
|
self.lines[i].checkBox.SetValue(True)
|
|
self.lines[i].struct_id_choice.SetStringSelection(protocol.get_strid_text(val[1] & 127))
|
|
self.enable(i, True)
|
|
i += 1
|
|
|
|
if i < 8:
|
|
self.createLine(i)
|
|
self.initFinished = True
|
|
self.Show(True)
|
|
return
|
|
|
|
def limit(self, val):
|
|
if val > 255:
|
|
val = 255
|
|
if val < 0:
|
|
val = 0
|
|
return int(val)
|
|
|
|
def evaluateConfiguration(self):
|
|
p = self.lines[0]
|
|
adcTypeInt = self.getAdcType()
|
|
aggregate = p.aggregate.GetValue()
|
|
fanControl = p.fanControl.GetValue()
|
|
flags = 0
|
|
if aggregate:
|
|
flags |= 16
|
|
if fanControl:
|
|
flags |= 32
|
|
try:
|
|
inputRangeMin = self.limit(round(getFloatFromTextControl(p.inputRangeMin) * 50))
|
|
inputRangeMax = self.limit(round(getFloatFromTextControl(p.inputRangeMax) * 50))
|
|
outputRangeMin = self.limit(round(getFloatFromTextControl(p.outputRangeMin) * 2))
|
|
outputRangeMax = self.limit(round(getFloatFromTextControl(p.outputRangeMax) * 2))
|
|
channel = p.channelChoice.GetStringSelection()
|
|
channel = int(channel.replace('Output ', '')) - 1 & 15
|
|
except:
|
|
inputRangeMin = 0
|
|
inputRangeMax = self.limit(round(247.5))
|
|
outputRangeMin = 0
|
|
outputRangeMax = self.limit(round(250.0))
|
|
channel = 0
|
|
|
|
try:
|
|
sendString = '' + chr(self.uiNumber + 63)
|
|
sendString += chr(adcTypeInt & 15 | flags)
|
|
sendString += chr(0)
|
|
sendString += chr(channel)
|
|
sendString += chr(inputRangeMin)
|
|
sendString += chr(inputRangeMax)
|
|
sendString += chr(outputRangeMin)
|
|
sendString += chr(outputRangeMax)
|
|
return sendString
|
|
except:
|
|
print mytime.displayTime(), 'uc.dcin.eL.failed to build string'
|
|
traceback.print_exc(file=sys.stdout)
|
|
return
|
|
|
|
return
|
|
|
|
def createConfigLine(self):
|
|
p = wx.Panel(self, size=(964, 90))
|
|
p.readingLabel = wx.StaticText(p, -1, 'Voltage reading:', pos=(10, 0))
|
|
p.readingValue = wx.StaticText(p, -1, '', pos=(120, 0))
|
|
p.temperatureLabel = wx.StaticText(p, -1, 'Temperature:', pos=(210, 0))
|
|
p.temperatureValue = wx.StaticText(p, -1, '', pos=(320, 0))
|
|
p.checkBox = wx.CheckBox(p, -1, 'Type:', pos=(10, 33), size=(90, 20))
|
|
p.adcTypeChoice = wx.Choice(p, -1, choices=adcTypeChoices.values(), style=wx.BORDER_NONE, pos=(100,
|
|
31), size=(320,
|
|
26))
|
|
p.adcTypeChoice.SetStringSelection(adcTypeChoices.values()[0])
|
|
p.channelLabel = wx.StaticText(p, -1, 'Channel', pos=(440, 34))
|
|
p.channelChoice = wx.Choice(p, -1, choices=self.temperatureSensorChannels.values(), style=wx.BORDER_NONE, pos=(500,
|
|
31), size=(100,
|
|
26))
|
|
p.aggregate = wx.CheckBox(p, -1, 'Aggregate', pos=(740, 33), size=(90, 20))
|
|
p.aggregate.SetValue(1)
|
|
p.fanControl = wx.CheckBox(p, -1, 'Fan Control', pos=(840, 33), size=(90, 20))
|
|
p.fanControl.SetValue(1)
|
|
p.inputRangeMinLabel = wx.StaticText(p, -1, 'Input Range Min', pos=(100, 70))
|
|
p.inputRangeMin = wx.TextCtrl(p, -1, '0', pos=(220, 69), size=(70, 20))
|
|
p.inputRangeMaxLabel = wx.StaticText(p, -1, 'Input Range Max', pos=(300, 70))
|
|
p.inputRangeMax = wx.TextCtrl(p, -1, '3.3', pos=(410, 69), size=(70, 20))
|
|
p.outputRangeMinLabel = wx.StaticText(p, -1, 'Output Range Min', pos=(530,
|
|
70))
|
|
p.outputRangeMin = wx.TextCtrl(p, -1, '0', pos=(650, 69), size=(70, 20))
|
|
p.outputRangeMaxLabel = wx.StaticText(p, -1, 'Output Range Max', pos=(740,
|
|
70))
|
|
p.outputRangeMax = wx.TextCtrl(p, -1, '100', pos=(860, 69), size=(70, 20))
|
|
self.timer = wx.Timer(self)
|
|
self.counter = 0
|
|
self.Bind(wx.EVT_TIMER, self.onTimer, self.timer)
|
|
self.timer.Start(1000)
|
|
self.Bind(wx.EVT_CHOICE, self.OnChangeAdcType, p.adcTypeChoice)
|
|
p.checkBox.SetValue(0)
|
|
p.SetPosition((0, 20))
|
|
p.key = None
|
|
self.lines[0] = p
|
|
p.lineNumber = 0
|
|
self.enableConfig()
|
|
self.registerAdcType()
|
|
self.Bind(wx.EVT_CHECKBOX, self.OnEnableConfig, p.checkBox)
|
|
return
|
|
|
|
def onTimer(self, e):
|
|
p = self.lines[0]
|
|
self.counter += 1
|
|
try:
|
|
val = round(self.frame.frame.parent.model.get(data_model.Key(protocol.STRUCT_ID_ADC_READING, protocol.MEMBER_ID_ADC_READING, self.uiNumber - 1, 0)), 2)
|
|
except:
|
|
self.timer.Stop()
|
|
p.readingValue.SetLabel('--')
|
|
return
|
|
else:
|
|
p.readingValue.SetLabel(str(val) + ' V')
|
|
try:
|
|
inputRangeMin = getFloatFromTextControl(p.inputRangeMin)
|
|
inputRangeMax = getFloatFromTextControl(p.inputRangeMax)
|
|
outputRangeMin = getFloatFromTextControl(p.outputRangeMin)
|
|
outputRangeMax = getFloatFromTextControl(p.outputRangeMax)
|
|
except:
|
|
inputRangeMin = 0
|
|
inputRangeMax = 3.3
|
|
outputRangeMin = 0
|
|
outputRangeMax = 100
|
|
|
|
adcTypeInt = self.getAdcType()
|
|
if adcTypeInt == 0:
|
|
p.temperatureLabel.SetLabel(' ')
|
|
p.temperatureValue.SetLabel(' ')
|
|
elif adcTypeInt in (1, 3):
|
|
inputRange = inputRangeMax - inputRangeMin
|
|
percent = (val - inputRangeMin) / inputRange
|
|
outputRange = outputRangeMax - outputRangeMin
|
|
temperature = int(outputRangeMin + outputRange * percent)
|
|
if temperature > outputRangeMax:
|
|
temperature = outputRangeMax
|
|
if temperature < outputRangeMin:
|
|
temperature = outputRangeMin
|
|
p.temperatureLabel.SetLabel('Temperature: ')
|
|
p.temperatureValue.SetLabel(str(temperature) + ' ' + u'\xb0C')
|
|
elif adcTypeInt == 2:
|
|
p.temperatureLabel.SetLabel('Temperature: ')
|
|
try:
|
|
inputRange = inputRangeMax - inputRangeMin
|
|
percent = 1 - (val - inputRangeMin) / inputRange
|
|
outputRange = outputRangeMax - outputRangeMin
|
|
if outputRangeMin < 0.001:
|
|
outputRangeMin = 0.001
|
|
logRange = math.log10(outputRangeMax / outputRangeMin)
|
|
factor = outputRange / logRange
|
|
resLin = percent * outputRange + outputRangeMin
|
|
resLog = math.log10(resLin / outputRangeMin)
|
|
temperature = int(resLog * factor + outputRangeMin)
|
|
if temperature > outputRangeMax:
|
|
temperature = outputRangeMax
|
|
if temperature < outputRangeMin:
|
|
temperature = outputRangeMin
|
|
p.temperatureValue.SetLabel(str(temperature) + ' ' + u'\xb0C')
|
|
except:
|
|
p.temperatureValue.SetLabel('-- C')
|
|
|
|
return
|
|
|
|
def OnChangeAdcType(self, e):
|
|
self.registerAdcType()
|
|
return
|
|
|
|
def getAdcType(self):
|
|
p = self.lines[0]
|
|
adcType = p.adcTypeChoice.GetStringSelection()
|
|
adcTypeInt = 0
|
|
for i in adcTypeChoices.keys():
|
|
if adcTypeChoices[i] == adcType:
|
|
adcTypeInt = i
|
|
break
|
|
|
|
return adcTypeInt
|
|
|
|
def registerAdcType(self):
|
|
p = self.lines[0]
|
|
adcTypeInt = self.getAdcType()
|
|
if adcTypeInt == 0:
|
|
self.isTemperature = False
|
|
p.inputRangeMinLabel.Enable(False)
|
|
p.inputRangeMin.Show(False)
|
|
p.inputRangeMaxLabel.Enable(False)
|
|
p.inputRangeMax.Show(False)
|
|
p.outputRangeMinLabel.Enable(False)
|
|
p.outputRangeMin.Show(False)
|
|
p.outputRangeMaxLabel.Enable(False)
|
|
p.outputRangeMax.Show(False)
|
|
p.aggregate.Enable(False)
|
|
p.fanControl.Enable(False)
|
|
p.channelChoice.Enable(False)
|
|
p.channelLabel.Enable(False)
|
|
self.strMin.SetLabel('Min / Low')
|
|
self.strCenter.SetLabel('Center')
|
|
self.strMax.SetLabel('Max / High')
|
|
else:
|
|
self.isTemperature = True
|
|
p.inputRangeMinLabel.Enable(True)
|
|
p.inputRangeMin.Show(True)
|
|
p.inputRangeMaxLabel.Enable(True)
|
|
p.inputRangeMax.Show(True)
|
|
p.outputRangeMinLabel.Enable(True)
|
|
p.outputRangeMin.Show(True)
|
|
p.outputRangeMaxLabel.Enable(True)
|
|
p.outputRangeMax.Show(True)
|
|
p.aggregate.Enable(True)
|
|
p.fanControl.Enable(True)
|
|
p.channelChoice.Enable(True)
|
|
p.channelLabel.Enable(True)
|
|
self.strMin.SetLabel('Threshold')
|
|
self.strCenter.SetLabel('Slope')
|
|
self.strMax.SetLabel('')
|
|
for i in range(1, len(self.lines)):
|
|
self.setupFieldsForStrid(i)
|
|
|
|
return
|
|
|
|
def createLine(self, i):
|
|
p = wx.Panel(self, size=(964, 30))
|
|
p.checkBox = wx.CheckBox(p, 100 + i, ' User ' + str(i - self.numberOfFactoryItems), pos=(10,
|
|
2), size=(90,
|
|
20))
|
|
p.struct_id_choice = wx.Choice(p, 40 + i, choices=self.stridChoices, style=wx.BORDER_NONE, pos=(100,
|
|
0), size=(100,
|
|
26))
|
|
self.Bind(wx.EVT_CHOICE, self.OnChangeStrid, p.struct_id_choice)
|
|
p.struct_id_choice.SetStringSelection('Disabled')
|
|
p.member_id_choice = wx.Choice(p, 50 + i, choices=self.membidChoices['Disabled'], style=wx.BORDER_NONE, pos=(210,
|
|
0), size=(100,
|
|
26))
|
|
p.channel_choice = wx.Choice(p, 60 + i, choices=self.channels.values(), style=wx.BORDER_NONE, pos=(320,
|
|
0), size=(100,
|
|
26))
|
|
p.index_choice = wx.Choice(p, 70 + i, choices=[_[1] for j in range(2)], style=wx.BORDER_NONE, pos=(430,
|
|
0), size=(50,
|
|
26))
|
|
p.min = wx.TextCtrl(p, 80 + i, '', pos=(490, 1), size=(70, 20))
|
|
p.center = wx.TextCtrl(p, 90 + i, '', pos=(570, 1), size=(70, 20))
|
|
p.max = wx.TextCtrl(p, 30 + i, '', pos=(650, 1), size=(70, 20))
|
|
p.LockWithKeyLock = wx.CheckBox(p, -1, 'Lock when front panel keys are locked', pos=(730,
|
|
2))
|
|
p.LockWithKeyLock.SetValue(0)
|
|
p.SetPosition((0, 130 + 28 * i))
|
|
p.checkBox.SetValue(0)
|
|
p.key = None
|
|
p.lineNumber = i
|
|
p.val = [14, 14, 14, 14, 14, 14, 14, 14]
|
|
self.lines[i] = p
|
|
self.setupFieldsForStrid(i)
|
|
self.enable(i)
|
|
self.Bind(wx.EVT_CHECKBOX, self.OnEnabled, p.checkBox)
|
|
return
|
|
|
|
def getStringValue(self, val, membid, slope=False):
|
|
if membid == protocol.MEMBER_ID_GAIN:
|
|
if self.isTemperature:
|
|
return str(float(val) / 2) + ' ' + u'\xb0C'
|
|
else:
|
|
return str(val - 128) + ' dB'
|
|
if membid == protocol.MEMBER_ID_DELAY:
|
|
return str(val - 128) + ' m'
|
|
if membid == protocol.MEMBER_ID_FREQ:
|
|
if self.isTemperature:
|
|
return str(float(val) / 2) + ' ' + u'\xb0C'
|
|
else:
|
|
return str(self.frequencyFromInt(val)) + ' Hz'
|
|
if membid in (protocol.MEMBER_ID_MUTE, protocol.MEMBER_ID_PROTECT):
|
|
if self.isTemperature:
|
|
return str(float(val) / 2) + ' ' + u'\xb0C'
|
|
else:
|
|
return str(float(val) / 50.0) + ' V'
|
|
if membid == protocol.MEMBER_ID_THRESHOLD:
|
|
if slope:
|
|
if self.isTemperature:
|
|
return '-' + str(float(val) / 10) + ' dB/' + u'\xb0C'
|
|
else:
|
|
return str(float(val) / 50.0) + ' V'
|
|
else:
|
|
if self.isTemperature:
|
|
return str(float(val) / 2) + ' ' + u'\xb0C'
|
|
else:
|
|
return str(float(val) / 50.0) + ' V'
|
|
return str(val)
|
|
|
|
def OnChangeStrid(self, e):
|
|
i = e.GetId() - 40
|
|
print mytime.displayTime(), 'ucd.2', i
|
|
wx.CallAfter(self.enable, i)
|
|
return
|
|
|
|
def setupFieldsForStrid(self, i, first=False):
|
|
strid = self.lines[i].struct_id_choice.GetStringSelection().strip()
|
|
val = self.lines[i].val
|
|
self.lines[i].member_id_choice.Destroy()
|
|
self.lines[i].member_id_choice = wx.Choice(self.lines[i], 50 + i, choices=self.membidChoices[strid], style=wx.BORDER_NONE, pos=(210,
|
|
0), size=(100,
|
|
26))
|
|
self.lines[i].index_choice.Destroy()
|
|
self.lines[i].index_choice = wx.Choice(self.lines[i], 70 + i, choices=self.indexChoices[strid], style=wx.BORDER_NONE, pos=(430,
|
|
0), size=(50,
|
|
26))
|
|
try:
|
|
self.lines[i].member_id_choice.SetStringSelection(self.membidChoices[strid][val[2]])
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.lines[i].index_choice.SetStringSelection(str(val[4] + 1))
|
|
except:
|
|
pass
|
|
|
|
if first:
|
|
print 'ucd.val:', val
|
|
membid = val[2]
|
|
self.lines[i].member_id_choice.SetStringSelection(protocol.get_member_text(membid))
|
|
channel = val[3]
|
|
if channel == 255:
|
|
channel = 'All Outputs'
|
|
elif channel == 127:
|
|
channel = 'All Inputs'
|
|
elif channel < 128:
|
|
channel = 'Input ' + str(channel + 1)
|
|
else:
|
|
channel = 'Output ' + str(channel - 128 + 1)
|
|
self.lines[i].channel_choice.SetStringSelection(channel)
|
|
self.lines[i].index_choice.SetStringSelection(str(val[4] + 1))
|
|
if strid in strid_fixed_membid.keys():
|
|
self.lines[i].member_id_choice.Enable(False)
|
|
self.lines[i].member_id_choice.SetStringSelection(strid_fixed_membid[strid])
|
|
elif strid in ('Compressor', 'Limiter'):
|
|
self.lines[i].member_id_choice.Enable(False)
|
|
self.lines[i].member_id_choice.SetStringSelection(self.membidChoices[strid][0])
|
|
else:
|
|
self.lines[i].member_id_choice.Enable(True)
|
|
membid = protocol.get_membid_by_text(self.lines[i].member_id_choice.GetStringSelection())
|
|
if strid in ('Compressor', 'Limiter'):
|
|
self.lines[i].min.SetValue(self.getStringValue(val[5], membid))
|
|
self.lines[i].center.Show(True)
|
|
self.lines[i].center.SetValue(self.getStringValue(val[6], membid, True))
|
|
self.lines[i].max.Show(False)
|
|
else:
|
|
self.lines[i].min.SetValue(self.getStringValue(val[5], membid))
|
|
self.lines[i].center.Show(True)
|
|
self.lines[i].center.SetValue(self.getStringValue(val[6], membid))
|
|
self.lines[i].max.Show(True)
|
|
self.lines[i].max.SetValue(self.getStringValue(val[7], membid))
|
|
if val[1] & 128 == 0:
|
|
self.lines[i].LockWithKeyLock.SetValue(0)
|
|
else:
|
|
self.lines[i].LockWithKeyLock.SetValue(1)
|
|
return
|
|
|
|
def enable(self, i, first=False):
|
|
self.registerAdcType()
|
|
val = self.lines[i].checkBox.GetValue()
|
|
if i < self.numberOfFactoryItems:
|
|
val = False
|
|
self.lines[i].struct_id_choice.Enable(val)
|
|
strID = self.lines[i].struct_id_choice.GetStringSelection().strip()
|
|
print mytime.displayTime(), 'ucd.e.1', strID
|
|
if strID == 'Disabled':
|
|
val = False
|
|
if strID in strid_fixed_membid:
|
|
self.lines[i].member_id_choice.Enable(False)
|
|
else:
|
|
self.lines[i].member_id_choice.Enable(val)
|
|
self.lines[i].channel_choice.Enable(val)
|
|
if len(self.indexChoices[strID]) == 1:
|
|
self.lines[i].index_choice.Enable(False)
|
|
else:
|
|
self.lines[i].index_choice.Enable(val)
|
|
self.lines[i].min.Enable(val)
|
|
self.lines[i].center.Enable(val)
|
|
self.lines[i].max.Enable(val)
|
|
self.setupFieldsForStrid(i, first)
|
|
return
|
|
|
|
def OnEnabled(self, e):
|
|
i = e.GetId() - 100
|
|
self.enable(i)
|
|
if i == len(self.lines) - 1 and self.lines[i].checkBox.GetValue() == True and i < 8:
|
|
self.createLine(i + 1)
|
|
return
|
|
|
|
def enableConfig(self):
|
|
p = self.lines[0]
|
|
val = p.checkBox.GetValue()
|
|
p.inputRangeMinLabel.Enable(val)
|
|
p.inputRangeMin.Enable(val)
|
|
p.inputRangeMaxLabel.Enable(val)
|
|
p.inputRangeMax.Enable(val)
|
|
p.outputRangeMinLabel.Enable(val)
|
|
p.outputRangeMin.Enable(val)
|
|
p.outputRangeMaxLabel.Enable(val)
|
|
p.outputRangeMax.Enable(val)
|
|
p.adcTypeChoice.Enable(val)
|
|
p.aggregate.Enable(val)
|
|
p.fanControl.Enable(val)
|
|
p.channelChoice.Enable(val)
|
|
p.channelLabel.Enable(val)
|
|
self.registerAdcType()
|
|
return
|
|
|
|
def OnEnableConfig(self, e):
|
|
self.enableConfig()
|
|
return
|
|
|
|
def intFromFrequency(self, frequency):
|
|
try:
|
|
frequency = int(frequency)
|
|
if frequency > 20001:
|
|
return 255
|
|
lastDelta = 100000000
|
|
res = 0
|
|
print mytime.displayTime(), 'ucd.Get value for frequency', frequency
|
|
for i in range(256):
|
|
f = int(19 * pow(FREQUENCY_LOG_CONSTANT, i))
|
|
delta = math.fabs(frequency - f)
|
|
if delta <= lastDelta:
|
|
res = i
|
|
else:
|
|
print mytime.displayTime(), 'ucd.returning', res, int(19 * pow(FREQUENCY_LOG_CONSTANT, res))
|
|
return res
|
|
lastDelta = delta
|
|
|
|
print mytime.displayTime(), 'ucd.loop ended', res, int(19 * pow(FREQUENCY_LOG_CONSTANT, res))
|
|
return res
|
|
except:
|
|
raise 'ucd.Get value for frequency', frequency, 'failed, returning None'
|
|
return
|
|
|
|
return
|
|
|
|
def frequencyFromInt(self, res):
|
|
return int(19 * pow(FREQUENCY_LOG_CONSTANT, res))
|
|
|
|
def evaluateLine(self, line):
|
|
if line.checkBox.GetValue() == False:
|
|
return
|
|
else:
|
|
if line.lineNumber == 0:
|
|
return self.evaluateConfiguration()
|
|
membID = protocol.get_membid_by_text(line.member_id_choice.GetStringSelection())
|
|
if membID in (protocol.MEMBER_ID_MUTE, protocol.MEMBER_ID_PROTECT, protocol.MEMBER_ID_THRESHOLD):
|
|
if self.isTemperature:
|
|
try:
|
|
min = self.limit(getFloatFromTextControl(line.min) * 2)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
min = 0
|
|
else:
|
|
line.min.SetValue(str(round(min / 2.0, 1)) + ' ' + u'\xb0C')
|
|
if membID == protocol.MEMBER_ID_THRESHOLD:
|
|
try:
|
|
center = self.limit(math.fabs(getFloatFromTextControl(line.center)) * 10)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
center = 255
|
|
else:
|
|
line.center.SetValue('-' + str(round(center / 10.0, 1)) + ' dB/' + u'\xb0C')
|
|
else:
|
|
try:
|
|
center = self.limit(getFloatFromTextControl(line.center) * 2)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
center = 255
|
|
|
|
line.center.SetValue(str(round(center / 2.0, 1)) + ' ' + u'\xb0C')
|
|
try:
|
|
max = self.limit(getFloatFromTextControl(line.max) * 2)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
max = 255
|
|
else:
|
|
line.max.SetValue(str(round(max / 2.0, 1)) + ' ' + u'\xb0C')
|
|
else:
|
|
try:
|
|
min = self.limit(getFloatFromTextControl(line.min) * 50)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
min = 0
|
|
else:
|
|
line.min.SetValue(str(round(min / 50.0, 2)) + ' V')
|
|
if membID == protocol.MEMBER_ID_THRESHOLD:
|
|
try:
|
|
center = self.limit(getFloatFromTextControl(line.center) * 10)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
center = 255
|
|
else:
|
|
line.center.SetValue(str(round(center / 10.0, 1)) + ' dB/V')
|
|
else:
|
|
try:
|
|
center = self.limit(getFloatFromTextControl(line.center) * 50)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
center = 255
|
|
|
|
line.center.SetValue(str(round(center / 50.0, 2)) + ' V')
|
|
try:
|
|
max = self.limit(getFloatFromTextControl(line.max) * 50)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
max = 255
|
|
else:
|
|
line.max.SetValue(str(round(max / 50.0, 2)) + ' V')
|
|
if membID == protocol.MEMBER_ID_GAIN:
|
|
try:
|
|
min = int(getFloatFromTextControl(line.min)) + 128
|
|
if min < 0:
|
|
min = 0
|
|
line.min.SetValue('-128 dB')
|
|
if min > 255:
|
|
min = 255
|
|
line.min.SetValue('127 dB')
|
|
line.min.SetValue(str(min - 128) + ' dB')
|
|
except:
|
|
min = 128
|
|
line.min.SetValue('0 dB')
|
|
else:
|
|
try:
|
|
max = int(getFloatFromTextControl(line.max)) + 128
|
|
if max < 0:
|
|
max = 0
|
|
line.max.SetValue('-128 dB')
|
|
if max > 255:
|
|
max = 255
|
|
line.max.SetValue('127 dB')
|
|
line.max.SetValue(str(max - 128) + ' dB')
|
|
except:
|
|
max = 128
|
|
line.max.SetValue('0 dB')
|
|
else:
|
|
try:
|
|
center = int(getFloatFromTextControl(line.center)) + 128
|
|
if center < 0:
|
|
center = 0
|
|
line.center.SetValue('-128')
|
|
if center > 255:
|
|
center = 255
|
|
line.center.SetValue('127')
|
|
line.center.SetValue(str(center - 128) + ' dB')
|
|
except:
|
|
center = (min + max) / 2
|
|
line.center.SetValue(str(center - 128) + ' dB')
|
|
|
|
if membID == protocol.MEMBER_ID_DELAY:
|
|
try:
|
|
min = int(getFloatFromTextControl(line.min)) + 128
|
|
if min < 0:
|
|
min = 0
|
|
line.min.SetValue('-128 m')
|
|
if min > 255:
|
|
min = 255
|
|
line.min.SetValue('127 m')
|
|
line.min.SetValue(str(min - 128) + ' m')
|
|
except:
|
|
min = 128
|
|
line.min.SetValue('0 m')
|
|
else:
|
|
try:
|
|
max = int(getFloatFromTextControl(line.max)) + 128
|
|
if max < 0:
|
|
max = 0
|
|
line.max.SetValue('-128 m')
|
|
if max > 255:
|
|
max = 255
|
|
line.max.SetValue('127 m')
|
|
line.max.SetValue(str(max - 128) + ' m')
|
|
except:
|
|
max = 128
|
|
line.max.SetValue('0 m')
|
|
else:
|
|
try:
|
|
center = int(getFloatFromTextControl(line.center)) + 128
|
|
if center < 0:
|
|
center = 0
|
|
line.center.SetValue('-128 m')
|
|
if center > 255:
|
|
center = 255
|
|
line.center.SetValue('127 m')
|
|
line.center.SetValue(str(center - 128) + ' m')
|
|
except:
|
|
center = (min + max) / 2
|
|
line.center.SetValue(str(center - 128) + ' m')
|
|
|
|
if membID == protocol.MEMBER_ID_FREQ:
|
|
try:
|
|
min = self.intFromFrequency(getFloatFromTextControl(line.min))
|
|
if min < 0:
|
|
min = 0
|
|
line.min.SetValue('Off')
|
|
if min > 255:
|
|
min = 255
|
|
line.min.SetValue('Off')
|
|
line.min.SetValue(str(self.frequencyFromInt(min)) + ' Hz')
|
|
except:
|
|
min = self.intFromFrequency(1000)
|
|
line.min.SetValue('1000')
|
|
else:
|
|
try:
|
|
max = self.intFromFrequency(getFloatFromTextControl(line.max))
|
|
if max < 0:
|
|
max = 0
|
|
line.max.SetValue('Off')
|
|
if max > 255:
|
|
max = 255
|
|
line.max.SetValue('Off')
|
|
line.max.SetValue(str(self.frequencyFromInt(max)) + ' Hz')
|
|
except:
|
|
max = self.intFromFrequency(1000)
|
|
line.max.SetValue('1000')
|
|
else:
|
|
try:
|
|
center = self.intFromFrequency(getFloatFromTextControl(line.center))
|
|
if center < 0:
|
|
center = 0
|
|
line.center.SetValue('Off')
|
|
if center > 255:
|
|
center = 255
|
|
line.center.SetValue('Off')
|
|
line.center.SetValue(str(self.frequencyFromInt(center)) + ' Hz')
|
|
except:
|
|
center = (min + max) / 2
|
|
line.center.SetValue(str(self.frequencyFromInt(center)) + ' Hz')
|
|
|
|
strID = protocol.get_strid_by_text(line.struct_id_choice.GetStringSelection())
|
|
if line.LockWithKeyLock.GetValue():
|
|
strID |= 128
|
|
channel = line.channel_choice.GetStringSelection()
|
|
if channel == 'All Inputs':
|
|
channel = 127
|
|
elif channel == 'All Outputs':
|
|
channel = 255
|
|
elif channel.find('Input ') >= 0:
|
|
channel = int(channel.replace('Input ', '')) - 1
|
|
elif channel.find('Output ') >= 0:
|
|
channel = int(channel.replace('Output ', '')) - 1 + 128
|
|
index = int(line.index_choice.GetStringSelection()) - 1
|
|
if strID == None:
|
|
strID = 10
|
|
membID = 0
|
|
channel = 0
|
|
index = 0
|
|
min = 0
|
|
max = 0
|
|
center = 0
|
|
line.val = [
|
|
self.uiNumber, strID, membID, channel, index, min, center, max]
|
|
try:
|
|
sendString = '' + chr(self.uiNumber)
|
|
sendString += chr(strID)
|
|
sendString += chr(membID)
|
|
sendString += chr(channel)
|
|
sendString += chr(index)
|
|
sendString += chr(min)
|
|
sendString += chr(center)
|
|
sendString += chr(max)
|
|
return sendString
|
|
except:
|
|
print mytime.displayTime(), 'uc.dcin.eL.failed to build string'
|
|
traceback.print_exc(file=sys.stdout)
|
|
return
|
|
|
|
return
|
|
|
|
|
|
class DAC_output(wx.Panel):
|
|
|
|
def __init__(self, parent, frame, index):
|
|
self.frame = frame
|
|
self.name = str(index)
|
|
self.index = index
|
|
self.parent = parent
|
|
wx.Panel.__init__(self, parent, size=(964, 600))
|
|
self.nameLabel = wx.StaticText(self, -1, 'DC out ' + str(index + 1) + ' drives a ', pos=(13,
|
|
12), size=(100,
|
|
26))
|
|
self.select_type = wx.Choice(self, 3, choices=['Fan', 'Level indicator'], style=wx.BORDER_NONE, pos=(130,
|
|
10), size=(150,
|
|
26))
|
|
try:
|
|
self.select_type.SetStringSelection('Fan')
|
|
except:
|
|
print mytime.displayTime() + ' Unsupported Input Type'
|
|
|
|
self.Bind(wx.EVT_CHOICE, self.OnChangeType, id=3)
|
|
self.Show(True)
|
|
return
|
|
|
|
def OnChangeType(self, e):
|
|
print mytime.displayTime() + ' Change type', self.select_type.GetStringSelection()
|
|
return
|
|
|
|
|
|
class Digital_input(wx.Panel):
|
|
|
|
def __init__(self, parent, frame, index):
|
|
self.frame = frame
|
|
self.name = str(index)
|
|
self.index = index
|
|
self.parent = parent
|
|
wx.Panel.__init__(self, parent, size=(964, 600))
|
|
self.nameLabel = wx.StaticText(self, -1, 'Digital in ' + str(index + 1) + ' is ', pos=(13,
|
|
12), size=(80,
|
|
26))
|
|
self.select_nc = wx.Choice(self, 3, choices=['Normally Open', 'Normally Closed'], style=wx.BORDER_NONE, pos=(100,
|
|
10), size=(150,
|
|
26))
|
|
try:
|
|
self.select_nc.SetStringSelection('Normally Open')
|
|
except:
|
|
print mytime.displayTime() + ' Unsupported Input Type'
|
|
|
|
self.select_type = wx.Choice(self, 3, choices=['Active High', 'Active Low', 'Contact'], style=wx.BORDER_NONE, pos=(260,
|
|
10), size=(120,
|
|
26))
|
|
try:
|
|
self.select_type.SetStringSelection('Active High')
|
|
except:
|
|
print mytime.displayTime() + ' Unsupported Input Type'
|
|
|
|
self.kLabel = wx.StaticText(self, 2, 'and controls', pos=(390, 12), size=(200,
|
|
26))
|
|
self.lines = {}
|
|
self.channels = {127: 'All Inputs', 255: 'All Outputs'}
|
|
self.temperatureSensorChannels = {}
|
|
for c in self.frame.frame.parent.unit_channels:
|
|
if c < 128:
|
|
s = 'Input ' + str(c + 1)
|
|
else:
|
|
s = 'Output ' + str(c - 127)
|
|
self.temperatureSensorChannels[c] = s
|
|
self.channels[c] = s
|
|
|
|
strItem = wx.StaticText(self, -1, 'Item', pos=(100, 40))
|
|
strSubItem = wx.StaticText(self, -1, 'Sub-Item', pos=(210, 40))
|
|
strChannel = wx.StaticText(self, -1, 'Channel', pos=(320, 40))
|
|
strIndex = wx.StaticText(self, -1, 'Index', pos=(430, 40))
|
|
for i in range(1):
|
|
self.createLine(i)
|
|
|
|
self.Show(True)
|
|
return
|
|
|
|
def createLine(self, i):
|
|
p = wx.Panel(self, size=(964, 30))
|
|
p.checkBox = wx.CheckBox(p, 100 + i, ' Target ' + str(i + 1), pos=(10, 2))
|
|
p.struct_id_choice = wx.Choice(p, 40 + i, choices=protocol.STRUCT_ID_TEXT, style=wx.BORDER_NONE, pos=(100,
|
|
0), size=(100,
|
|
26))
|
|
p.member_id_choice = wx.Choice(p, 50 + i, choices=protocol.MEMB_ID_TEXT.values(), style=wx.BORDER_NONE, pos=(210,
|
|
0), size=(100,
|
|
26))
|
|
p.channel_choice = wx.Choice(p, 60 + i, choices=self.channels.values(), style=wx.BORDER_NONE, pos=(320,
|
|
0), size=(100,
|
|
26))
|
|
p.index_choice = wx.Choice(p, 70 + i, choices=[_[1] for j in range(10)], style=wx.BORDER_NONE, pos=(430,
|
|
0), size=(50,
|
|
26))
|
|
p.SetPosition((0, 60 + 28 * i))
|
|
p.checkBox.SetValue(0)
|
|
self.lines[i] = p
|
|
self.enable(i)
|
|
self.Bind(wx.EVT_CHECKBOX, self.OnEnabled, p.checkBox)
|
|
p.key = None
|
|
return
|
|
|
|
def enable(self, i):
|
|
val = self.lines[i].checkBox.GetValue()
|
|
self.lines[i].struct_id_choice.Enable(val)
|
|
self.lines[i].member_id_choice.Enable(val)
|
|
self.lines[i].channel_choice.Enable(val)
|
|
self.lines[i].index_choice.Enable(val)
|
|
return
|
|
|
|
def OnEnabled(self, e):
|
|
i = e.GetId() - 100
|
|
self.enable(i)
|
|
if i == len(self.lines) - 1 and self.lines[i].checkBox.GetValue() == True and i < 7:
|
|
self.createLine(i + 1)
|
|
return
|
|
|
|
|
|
class Digital_output(wx.Panel):
|
|
|
|
def __init__(self, parent, frame, index):
|
|
self.frame = frame
|
|
self.name = str(index)
|
|
self.index = index
|
|
self.parent = parent
|
|
wx.Panel.__init__(self, parent, size=(964, 600))
|
|
self.nameLabel = wx.StaticText(self, -1, 'Digital out ' + str(index + 1) + ' is a ', pos=(13,
|
|
12), size=(100,
|
|
26))
|
|
self.select_type = wx.Choice(self, 3, choices=[15, 16, 17, 18, 19], style=wx.BORDER_NONE, pos=(130,
|
|
10), size=(250,
|
|
26))
|
|
try:
|
|
self.select_type.SetStringSelection('Protect Output')
|
|
except:
|
|
print mytime.displayTime() + ' Unsupported Input Type'
|
|
|
|
self.select_level = wx.Choice(self, 5, choices=['Active High', 'Active Low'], style=wx.BORDER_NONE, pos=(390,
|
|
10), size=(120,
|
|
26))
|
|
try:
|
|
self.select_level.SetStringSelection('Active High')
|
|
except:
|
|
print mytime.displayTime() + ' Unsupported Input Type'
|
|
|
|
self.addLabel1 = wx.StaticText(self, -1, 'for channel', pos=(13, 42))
|
|
self.channels = {127: 'All Inputs', 255: 'All Outputs'}
|
|
for c in self.frame.frame.parent.unit_channels:
|
|
if c < 128:
|
|
s = 'Input ' + str(c + 1)
|
|
else:
|
|
s = 'Output ' + str(c - 127)
|
|
self.channels[c] = s
|
|
|
|
self.channelChoice = wx.Choice(self, 4, choices=self.channels.values(), style=wx.BORDER_NONE, pos=(100,
|
|
40), size=(100,
|
|
26))
|
|
try:
|
|
self.channelChoice.SetStringSelection('Input 1')
|
|
except:
|
|
print mytime.displayTime() + ' Unsupported Channel Type'
|
|
|
|
self.addLabel2 = wx.StaticText(self, -1, 'at signal level', pos=(210, 42))
|
|
self.levelText = wx.TextCtrl(self, 5, '-48', pos=(320, 41), size=(50, 20))
|
|
self.addLabel3 = wx.StaticText(self, -1, 'dBu', pos=(380, 42))
|
|
self.Bind(wx.EVT_CHOICE, self.OnChangeType, id=3)
|
|
self.Bind(wx.EVT_CHOICE, self.OnChangeChannel, id=4)
|
|
self.setLabelsForType()
|
|
self.Show(True)
|
|
return
|
|
|
|
def OnChangeType(self, e):
|
|
self.setLabelsForType()
|
|
return
|
|
|
|
def setLabelsForType(self):
|
|
type = self.select_type.GetStringSelection()
|
|
print mytime.displayTime() + ' Change type', type
|
|
if type == 'Protect Output':
|
|
self.addLabel1.Show(False)
|
|
self.addLabel2.Show(False)
|
|
self.addLabel3.Show(False)
|
|
self.channelChoice.Show(False)
|
|
self.levelText.Show(False)
|
|
if type == 'Signal Level Indicator':
|
|
self.addLabel1.Show(True)
|
|
self.addLabel2.Show(True)
|
|
self.addLabel3.Show(True)
|
|
self.channelChoice.Show(True)
|
|
self.levelText.Show(True)
|
|
self.addLabel2.SetLabel('at signal level')
|
|
self.levelText.SetValue('-48')
|
|
self.addLabel3.SetLabel('dBu')
|
|
if type == 'Gain Reduction Indicator':
|
|
self.addLabel1.Show(True)
|
|
self.addLabel2.Show(True)
|
|
self.addLabel3.Show(True)
|
|
self.channelChoice.Show(True)
|
|
self.levelText.Show(True)
|
|
self.addLabel2.SetLabel('at gain reduction')
|
|
self.levelText.SetValue('3')
|
|
self.addLabel3.SetLabel('dB')
|
|
if type == 'Power Indicator':
|
|
self.addLabel1.Show(True)
|
|
self.addLabel2.Show(True)
|
|
self.addLabel3.Show(True)
|
|
self.channelChoice.Show(True)
|
|
self.levelText.Show(True)
|
|
self.addLabel2.SetLabel('at power level')
|
|
self.levelText.SetValue('100')
|
|
self.addLabel3.SetLabel('W(rms)')
|
|
if type == 'Impedance Indicator':
|
|
self.addLabel1.Show(True)
|
|
self.addLabel2.Show(True)
|
|
self.addLabel3.Show(True)
|
|
self.channelChoice.Show(True)
|
|
self.levelText.Show(True)
|
|
self.addLabel2.SetLabel('at impedance')
|
|
self.levelText.SetValue('20')
|
|
self.addLabel3.SetLabel('Ohms')
|
|
return
|
|
|
|
def OnChangeChannel(self, e):
|
|
print mytime.displayTime() + ' Change channel', self.channelChoice.GetStringSelection()
|
|
return
|
|
|
|
|
|
|
|
# okay decompiling pycode/user_config_dc.pyc
|