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>
3264 lines
162 KiB
Python
3264 lines
162 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: control_panel.pyc
|
|
# Compiled at: 2025-05-23 10:32:32
|
|
if __name__ == '__main__':
|
|
import main
|
|
main.run()
|
|
import mytime, os.path, ConfigParser, one_unit, math, wx, sys, svg_panel, diagram, data_model, protocol, copy, dialog, traceback, threading, future, string, server, inspect
|
|
|
|
def getString(strID):
|
|
return one_unit.getString(strID)
|
|
|
|
|
|
def rreplace(s, old, new, occurrence=1):
|
|
li = s.rsplit(old, occurrence)
|
|
return new.join(li)
|
|
|
|
|
|
fixed_vars_list = {'ip_address': 'self.parent.active_unit.IP',
|
|
'mac_address': 'self.parent.active_unit.MAC',
|
|
'serial_number': 'self.parent.active_unit.Serial',
|
|
'firmware_version': 'self.parent.active_unit.FWVersion',
|
|
'software_version': 'one_unit.app.Version'}
|
|
constant_vars_list = {'confTwoWay': (protocol.confTwoWay),
|
|
'confAllModes': (protocol.confAllModes),
|
|
'confAESBackup': (protocol.confAESBackup),
|
|
'confStandby': (protocol.confStandby)}
|
|
illegal_chars = ('/', '\\')
|
|
|
|
class Control_panel(svg_panel.SVG_Panel):
|
|
|
|
def __init__(self, parent, id=-1, pos=(-1, -1), size=(-1, -1), style=0, name='svg_panel', config=None):
|
|
self.parent = parent
|
|
self.current_channel = None
|
|
self.selected_channel = None
|
|
self.config = config
|
|
self.pos = pos
|
|
self.last_panel = None
|
|
self.timerExecuting = False
|
|
self.style = style
|
|
self.font_size = 14
|
|
self.size = size
|
|
self.needRefreshAfterSync = True
|
|
self.update_key = None
|
|
self.peq_type_changed = False
|
|
self.full_screen_diagram = False
|
|
self.remote_link = parent.remote_link
|
|
self.name = name
|
|
svg_doc_name = config.get(name, 'svg_file')
|
|
self.image_replace_list = one_unit.app.image_replace_list
|
|
try:
|
|
self.image_replace_list = eval(config.get('DEFAULT', 'image_replace_list'))
|
|
except:
|
|
pass
|
|
|
|
svg_doc_name = os.path.join(parent.next_skin_path, svg_doc_name)
|
|
svg_panel.SVG_Panel.__init__(self, parent, id, pos, size, style, name, svg_doc_name)
|
|
self.svg_doc_name = svg_doc_name
|
|
self.thread = threading.Thread(name='AllDSP Unit Panel', target=self.process)
|
|
self.lock = threading.Lock()
|
|
self.start()
|
|
return
|
|
|
|
def OnGetFocus(self, e):
|
|
print mytime.displayTime(), 'cp.Got focus'
|
|
self.clickTime = mytime.clock()
|
|
return
|
|
|
|
def start(self):
|
|
self.thread.start()
|
|
return
|
|
|
|
def process(self):
|
|
self.SetBackgroundColour((0, 0, 0))
|
|
style = self.style
|
|
parent = self.parent
|
|
pos = self.pos
|
|
self.updates = 0
|
|
size = self.size
|
|
name = self.name
|
|
config = self.config
|
|
self.GL = parent.GL
|
|
self.editing_diagram = False
|
|
self.config = config
|
|
self.name = name
|
|
cursor = wx.StockCursor(wx.CURSOR_ARROW)
|
|
self.cursor_type = 'arrow'
|
|
self.SetCursor(cursor)
|
|
self.last_cursor = cursor
|
|
self.index = 0
|
|
return
|
|
|
|
def init_1(self):
|
|
config = self.config
|
|
parent = self.parent
|
|
name = self.name
|
|
self.csbutton = name
|
|
self.last_loaded_preset_no = None
|
|
self.last_loaded_preset_time = mytime.clock() - 5
|
|
self.controls = {}
|
|
self.skipping_timer = 0
|
|
self.control_types = {}
|
|
self.supported_units = parent.supported_units
|
|
try:
|
|
controls = config.get(name, 'controls')
|
|
controls = [_[1] for s in controls.split(',')]
|
|
except:
|
|
controls = []
|
|
print mytime.clock(), 'No controls found in config, trying to resolve...'
|
|
for id in self.svg_doc.active_elements:
|
|
if id[:4] not in ('imag', 'rect', 'name', 'meta', 'defs', 'svg1', 'svg2',
|
|
'svg3', 'svg4', 'text', 'path', 'logo'):
|
|
tmpid = id
|
|
if self.svg_doc.get_bb(id) == None:
|
|
continue
|
|
if tmpid[-3:] in ('max', 'min', '_bg'):
|
|
continue
|
|
for appendix in ('_off', '_on', '_over'):
|
|
tmpid2 = rreplace(tmpid, appendix, '')
|
|
if tmpid2 != tmpid:
|
|
tmpid = tmpid2
|
|
break
|
|
|
|
if tmpid not in controls:
|
|
controls.append(tmpid)
|
|
|
|
controls.append('cs_button')
|
|
|
|
self.wink_time = 0
|
|
self.gr_style = 'continuous'
|
|
self.vu_style = 'continuous'
|
|
self.vu_led_shape = 'square'
|
|
self.vu_led_size = 3
|
|
self.vu_led_spacing = 5
|
|
self.gr_led_size = 3
|
|
self.gr_led_spacing = 5
|
|
self.vu_bg_colour = 'BLACK'
|
|
self.waitToCreateProgressBarTime = 0
|
|
self.vu_in_led_values = None
|
|
self.vu_out_led_values = None
|
|
self.gr_led_values = None
|
|
self.preset_names = {}
|
|
self.vu_in_yellow = 0
|
|
self.vu_in_red = 6
|
|
self.block_once = False
|
|
self.block_once_time = 0
|
|
self.vu_out_yellow = 0
|
|
self.vu_pwr_yellow = 10
|
|
self.vu_pwr_red = 20
|
|
self.vu_out_red = 6
|
|
self.gr_yellow = 0
|
|
self.noProgressWindow = False
|
|
self.custom_write_protected_dialog = None
|
|
self.gr_red = 6
|
|
self.vu_grey_on_mute = 'yes'
|
|
self.gauges = {}
|
|
self.string_support = False
|
|
self.ctrl_keys = {}
|
|
self.fixed_render = {}
|
|
self.blink_timer = 0
|
|
self.update_all_controls_counter = 8
|
|
self.blink_value = 0
|
|
self.delay_unit = 'ms'
|
|
self.autoScaleDelay = False
|
|
self.fir_taps_from_file = None
|
|
self.have_lpf = False
|
|
self.have_hpf = False
|
|
self.run_test = False
|
|
self.repaint = False
|
|
self.repaint_time = 0
|
|
self.last_repaint_time = 0
|
|
self.test_counter = 0
|
|
self.show_sync = False
|
|
self.progress = None
|
|
self.skin_approved = False
|
|
self.select_rendering_by_channel = {}
|
|
self.cursor_type = 'arrow'
|
|
self.mouse_down = False
|
|
self.bitmapdir = os.path.normpath(one_unit.app.cwd + '/bitmaps/')
|
|
self.test_phase = 0
|
|
self.model_number_string = ''
|
|
self.custom_access_key = {}
|
|
self.invert_custom_access_key = {}
|
|
self.visibility_key = {}
|
|
self.visibility_mask = {}
|
|
self.visibility_value = {}
|
|
self.visibility_invert = {}
|
|
self.customElementKeys = {}
|
|
self.channelFlagMask = {}
|
|
self.channelFlagShow = {}
|
|
self.readChannelFlagMask()
|
|
self.readCustomElementKeys()
|
|
try:
|
|
self.font_size = float(config.get(self.name, 'font_size'))
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.auto_type_choice = eval(config.get(self.name, 'auto_type_choice'))
|
|
except:
|
|
self.auto_type_choice = False
|
|
|
|
try:
|
|
values = config.get('DEFAULT', 'vu_in_led_values')
|
|
try:
|
|
values = [_[2] for s in values.split(',')]
|
|
except:
|
|
dial = wx.MessageDialog(None, 'VU IN LED values list syntax error', 'Error', wx.OK | wx.ICON_ERROR)
|
|
dial.ShowModal()
|
|
|
|
self.vu_in_led_values = []
|
|
for i in range(len(values)):
|
|
self.vu_in_led_values.append(values[i])
|
|
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
values = config.get('DEFAULT', 'vu_out_led_values')
|
|
try:
|
|
values = [_[3] for s in values.split(',')]
|
|
except:
|
|
dial = wx.MessageDialog(None, 'VU OUT LED values list syntax error', 'Error', wx.OK | wx.ICON_ERROR)
|
|
dial.ShowModal()
|
|
|
|
self.vu_out_led_values = []
|
|
for i in range(len(values)):
|
|
self.vu_out_led_values.append(values[i])
|
|
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
values = config.get('DEFAULT', 'gr_led_values')
|
|
try:
|
|
values = [_[4] for s in values.split(',')]
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
dial = wx.MessageDialog(None, 'GR LED values list syntax error', 'Error', wx.OK | wx.ICON_ERROR)
|
|
dial.ShowModal()
|
|
|
|
self.gr_led_values = []
|
|
for i in range(len(values)):
|
|
self.gr_led_values.append(values[i])
|
|
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.peq_max_freq = float(config.get(self.name, 'peq_max_freq'))
|
|
except:
|
|
self.peq_max_freq = 20000.0
|
|
|
|
print self.peq_max_freq
|
|
self.enableContextMenu = self.parent.getFromConfig('enableContextMenu', True)
|
|
try:
|
|
self.vu_style = config.get('DEFAULT', 'vu_style')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_in_yellow = config.get('DEFAULT', 'vu_in_yellow')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_in_red = config.get('DEFAULT', 'vu_in_red')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_out_yellow = config.get('DEFAULT', 'vu_out_yellow')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_out_red = config.get('DEFAULT', 'vu_out_red')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_pwr_yellow = config.get('DEFAULT', 'vu_pwr_yellow')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_pwr_red = config.get('DEFAULT', 'vu_pwr_red')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.gr_yellow = config.get('DEFAULT', 'gr_yellow')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.gr_red = config.get('DEFAULT', 'gr_red')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_led_shape = config.get('DEFAULT', 'vu_led_shape')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.gr_led_shape = config.get('DEFAULT', 'gr_led_shape')
|
|
except:
|
|
self.gr_led_shape = 'square'
|
|
|
|
try:
|
|
self.vu_led_size = config.get('DEFAULT', 'vu_led_size')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.vu_led_spacing = config.get('DEFAULT', 'vu_led_spacing')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.gr_led_size = config.get('DEFAULT', 'gr_led_size')
|
|
except:
|
|
self.gr_led_size = self.vu_led_size
|
|
|
|
try:
|
|
self.gr_led_spacing = config.get('DEFAULT', 'gr_led_spacing')
|
|
except:
|
|
self.gr_led_spacing = self.vu_led_spacing
|
|
|
|
try:
|
|
self.vu_bg_colour = eval(config.get('DEFAULT', 'vu_bg_colour'))
|
|
except:
|
|
pass
|
|
|
|
self.custom_colours = True
|
|
self.default_text_colour = (80, 80, 80)
|
|
try:
|
|
self.default_text_colour = eval(config.get('DEFAULT', 'default_text_colour'))
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.custom_write_protected_dialog = self.parent.main_config.get('ROOT', 'custom_write_protected_dialog')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.default_text_colour = eval(config.get(self.name, 'default_text_colour'))
|
|
except:
|
|
pass
|
|
|
|
self.font_sizes = {}
|
|
self.font_colours = {}
|
|
self.show_Q_unit = False
|
|
try:
|
|
if config.get(name, 'show_Q_unit') == 'True':
|
|
self.show_Q_unit = True
|
|
except:
|
|
pass
|
|
|
|
self.suppress_knob_updates = True
|
|
try:
|
|
if config.get('DEFAULT', 'suppress_knob_updates') == 'False':
|
|
self.suppress_knob_updates = False
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.keepUserPresetName = eval(config.get('DEFAULT', 'keep_user_preset_name'))
|
|
except:
|
|
self.keepUserPresetName = False
|
|
|
|
try:
|
|
self.include_delay_unit = eval(config.get(name, 'include_delay_unit'))
|
|
except:
|
|
self.include_delay_unit = False
|
|
|
|
self.svg_doc.compute_bb(controls)
|
|
for ctrl_name in controls:
|
|
if ctrl_name == '':
|
|
continue
|
|
if ctrl_name == 'cs_button':
|
|
try:
|
|
self.csbutton = config.get(name, ctrl_name + '_value')
|
|
except:
|
|
pass
|
|
else:
|
|
continue
|
|
try:
|
|
self.font_colours[ctrl_name] = config.get(name, ctrl_name + '_colour')
|
|
except:
|
|
try:
|
|
self.font_colours[ctrl_name] = config.get(name, ctrl_name + '_text_colour')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.font_sizes[ctrl_name] = config.get(name, ctrl_name + '_font_size')
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
var_name = config.get(name, ctrl_name + '_value')
|
|
except ConfigParser.NoOptionError:
|
|
try:
|
|
var_name = config.get(name, ctrl_name + '_values')
|
|
except ConfigParser.NoOptionError:
|
|
var_name = ctrl_name.replace('_text', '')
|
|
var_name = var_name.replace('_slider', '')
|
|
var_name = var_name.replace('_knob', '')
|
|
var_name = var_name.replace('_choice', '')
|
|
var_name = var_name.replace('_label', '')
|
|
if self.auto_type_choice:
|
|
var_name = var_name.replace('_type', '')
|
|
try:
|
|
struct_id = config.getint(var_name, 'struct_id')
|
|
config.set(name, ctrl_name + '_value', var_name)
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
struct_id = config.getint(var_name, 'struct_id')
|
|
if struct_id == protocol.STRUCT_ID_MIXER:
|
|
num = config.getint(var_name, 'num')
|
|
if num not in self.parent.unit_channels:
|
|
print mytime.displayTime() + ' cp.init: skipping var for unused index', var_name
|
|
continue
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
channel = int(config.get(var_name, 'channel'), 0)
|
|
if channel not in self.parent.unit_channels and struct_id >= 0:
|
|
print mytime.displayTime() + ' cp.init: skipping var for unused channel', var_name, channel, self.parent.unit_channels
|
|
continue
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
ctrl = self.control_factory(name, ctrl_name)
|
|
except:
|
|
ctrl = None
|
|
|
|
if ctrl is not None:
|
|
try:
|
|
var = config.get(name, ctrl_name + '_visibility_var')
|
|
struct_id = config.getint(var, 'struct_id')
|
|
member_id = config.getint(var, 'member_id')
|
|
num = config.getint(var, 'num')
|
|
try:
|
|
channel = int(config.get(var, 'channel'), 0)
|
|
except ConfigParser.NoOptionError:
|
|
try:
|
|
channel = self.current_channel
|
|
except:
|
|
channel = -1
|
|
|
|
key = data_model.Key(struct_id, member_id, channel, num)
|
|
self.visibility_mask[ctrl_name] = config.get(name, ctrl_name + '_visibility_mask')
|
|
try:
|
|
self.visibility_mask[ctrl_name] = eval(self.visibility_mask[ctrl_name])
|
|
except:
|
|
try:
|
|
self.visibility_mask[ctrl_name] = eval('protocol.' + self.visibility_mask[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.visibility_invert[ctrl_name] = eval(config.get(name, ctrl_name + '_visibility_invert'))
|
|
except:
|
|
self.visibility_invert[ctrl_name] = False
|
|
|
|
self.visibility_value[ctrl_name] = config.get(name, ctrl_name + '_visibility_value')
|
|
try:
|
|
self.visibility_value[ctrl_name] = eval(self.visibility_value[ctrl_name])
|
|
except:
|
|
try:
|
|
self.visibility_value[ctrl_name] = eval('protocol.' + self.visibility_value[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
self.visibility_key[ctrl_name] = key
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
self.custom_access_key[ctrl_name] = int(config.get(name, ctrl_name + '_custom_access_key'), 0)
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
self.invert_custom_access_key[ctrl_name] = eval(config.get(name, ctrl_name + '_invert_custom_access_key'))
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
var_name = config.get(name, ctrl_name + '_value')
|
|
except ConfigParser.NoOptionError:
|
|
try:
|
|
var_name = config.get(name, ctrl_name + '_values')
|
|
except ConfigParser.NoOptionError:
|
|
self.controls[ctrl_name] = (
|
|
ctrl, None, None)
|
|
if ctrl_name.startswith('cs_') == False and ctrl_name not in ('link_status',
|
|
'delay_unit',
|
|
'preset_load',
|
|
'preset_store',
|
|
'available_units'):
|
|
print mytime.displayTime() + ' cp.No variable specified for', ctrl_name
|
|
|
|
else:
|
|
try:
|
|
var_name = config.get(name, ctrl_name + '_value')
|
|
except ConfigParser.NoOptionError:
|
|
try:
|
|
var_name = config.get(name, ctrl_name + '_values')
|
|
except ConfigParser.NoOptionError:
|
|
self.controls[ctrl_name] = (
|
|
ctrl, None, None)
|
|
continue
|
|
else:
|
|
var_names = [_[5] for s in var_name.split(',')]
|
|
keys = {}
|
|
for var in var_names[:]:
|
|
struct_id = config.getint(var, 'struct_id')
|
|
member_id = config.getint(var, 'member_id')
|
|
try:
|
|
default_val = config.getint(var, 'default')
|
|
except:
|
|
default_val = None
|
|
|
|
num = config.getint(var, 'num')
|
|
try:
|
|
channel = int(config.get(var, 'channel'), 0)
|
|
if channel not in self.parent.unit_channels:
|
|
var_names.remove(var)
|
|
continue
|
|
except ConfigParser.NoOptionError:
|
|
try:
|
|
channel = self.current_channel
|
|
except:
|
|
channel = -1
|
|
|
|
key = data_model.Key(struct_id, member_id, channel, num)
|
|
if channel > 0:
|
|
self.parent.model.set_default(key, default_val)
|
|
try:
|
|
self.ctrl_keys[key].append(ctrl_name)
|
|
except KeyError:
|
|
self.ctrl_keys[key] = []
|
|
self.ctrl_keys[key].append(ctrl_name)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
self.controls[ctrl_name] = (
|
|
ctrl, key, var_names)
|
|
continue
|
|
else:
|
|
struct_id = 0
|
|
member_id = 0
|
|
num = 0
|
|
channel = None
|
|
try:
|
|
struct_id = config.getint(var_name, 'struct_id')
|
|
member_id = config.getint(var_name, 'member_id')
|
|
num = config.getint(var_name, 'num')
|
|
try:
|
|
ctrl.variable_num = eval(config.get(var_name, 'variable_num'))
|
|
print ctrl.name, 'set to variable indexing'
|
|
except:
|
|
ctrl.variable_num = False
|
|
|
|
except:
|
|
if var_name in fixed_vars_list.keys():
|
|
struct_id = protocol.STRUCT_ID_INTERNAL
|
|
else:
|
|
try:
|
|
varNumber = int(var_name)
|
|
except:
|
|
varNumber = None
|
|
else:
|
|
if var_name in constant_vars_list.keys() or str(varNumber) == var_name:
|
|
lookupkey = config.get(name, ctrl_name + '_key')
|
|
struct_id = config.getint(lookupkey, 'struct_id')
|
|
member_id = config.getint(lookupkey, 'member_id')
|
|
num = config.getint(lookupkey, 'num')
|
|
channel = config.getint(lookupkey, 'channel')
|
|
try:
|
|
mask = config.get(name, ctrl_name + '_mask')
|
|
try:
|
|
mask = int(mask)
|
|
except:
|
|
mask = constant_vars_list[mask]
|
|
|
|
ctrl.mask = int(mask)
|
|
try:
|
|
mask = int(var_name)
|
|
except:
|
|
mask = constant_vars_list[var_name]
|
|
|
|
ctrl.mask_val = int(mask)
|
|
try:
|
|
ctrl.radio = eval(config.get(name, ctrl_name + '_radio_button'))
|
|
except:
|
|
ctrl.radio = False
|
|
|
|
except:
|
|
print mytime.displayTime(), 'cp.i.Failed to convert mask for', ctrl_name
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
else:
|
|
print mytime.displayTime() + ' var_name:', var_name, 'struct_ID:', struct_id, 'member_id: ', member_id, 'num:', num, 'not found or corrupted'
|
|
else:
|
|
if channel == None:
|
|
try:
|
|
channel = int(config.get(var_name, 'channel'), 0)
|
|
if channel not in self.parent.unit_channels and struct_id >= 0:
|
|
print mytime.displayTime(), 'cp.i1.Skipping', ctrl_name, ' for unused channel'
|
|
continue
|
|
except ConfigParser.NoOptionError:
|
|
channel = -1
|
|
except:
|
|
if var_name in fixed_vars_list.keys():
|
|
channel = 0
|
|
channel = 0
|
|
|
|
key = data_model.Key(struct_id, member_id, channel, num)
|
|
if key.struct_id == protocol.STRUCT_ID_HPF:
|
|
self.have_hpf = True
|
|
if key.struct_id == protocol.STRUCT_ID_LPF:
|
|
self.have_lpf = True
|
|
self.controls[ctrl_name] = (
|
|
ctrl, key, var_name)
|
|
try:
|
|
self.fixed_render[ctrl_name] = eval(config.get(name, ctrl_name + '_fixed_render'))
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
self.ctrl_keys[key].append(ctrl_name)
|
|
except KeyError:
|
|
self.ctrl_keys[key] = []
|
|
self.ctrl_keys[key].append(ctrl_name)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
else:
|
|
if hasattr(ctrl, 'set_off_value') and callable(ctrl.set_off_value):
|
|
ctrl.key = key
|
|
if hasattr(ctrl, 'set_limits') and callable(ctrl.set_limits):
|
|
try:
|
|
min_val = config.getfloat(var_name, 'min_value')
|
|
max_val = config.getfloat(var_name, 'max_value')
|
|
ctrl.set_limits(min_val, max_val)
|
|
except:
|
|
pass
|
|
|
|
if hasattr(ctrl, 'set_default') and callable(ctrl.set_default):
|
|
try:
|
|
default = config.getfloat(var_name, 'default_value')
|
|
except:
|
|
default = None
|
|
else:
|
|
ctrl.set_default(default)
|
|
if hasattr(ctrl, 'set_off_value') and callable(ctrl.set_off_value):
|
|
try:
|
|
off_value = config.getfloat(var_name, 'off_value')
|
|
ctrl.set_off_value(off_value)
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
off_text = config.get(var_name, 'off_text')
|
|
ctrl.set_off_text(off_text)
|
|
except:
|
|
pass
|
|
|
|
if hasattr(ctrl, 'set_max_value') and callable(ctrl.set_max_value):
|
|
try:
|
|
max_text = config.get(var_name, 'max_text')
|
|
ctrl.set_max_text(max_text)
|
|
max_value = config.getfloat(var_name, 'max_value')
|
|
ctrl.set_max_value(max_value)
|
|
print mytime.displayTime(), 'set max for', var_name
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
render_channels = config.get(var_name, 'render_channels')
|
|
self.select_rendering_by_channel[key] = eval(render_channels)
|
|
print mytime.displayTime() + ' Selective rendering:', self.select_rendering_by_channel[key], key
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
max_current = config.getfloat(name, ctrl_name + '_max_current')
|
|
ctrl.max_current = max_current
|
|
print mytime.displayTime(), 'cp.i.Set max current for', ctrl_name, 'to', max_current
|
|
except:
|
|
ctrl.max_current = 10000
|
|
else:
|
|
try:
|
|
self.custom_access_key[key] = int(config.get(var_name, 'custom_access_key'), 0)
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
self.invert_custom_access_key[key] = eval(config.get(var_name, 'invert_custom_access_key'))
|
|
print mytime.displayTime() + ' Inverted custom access key', key
|
|
except:
|
|
self.invert_custom_access_key[key] = False
|
|
else:
|
|
try:
|
|
self.custom_access_key[key] = int(config.get(name, ctrl_name + '_custom_access_key'), 0)
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
self.invert_custom_access_key[key] = eval(config.get(name, ctrl_name + '_invert_custom_access_key'))
|
|
except:
|
|
pass
|
|
|
|
names = []
|
|
for (ctrl, key, var_name) in self.controls.values():
|
|
names.extend(ctrl.get_svg_labels())
|
|
|
|
self.svg_doc.compute_bb(names)
|
|
for (ctrl, key, var_name) in self.controls.values():
|
|
labels = ctrl.get_svg_labels()
|
|
for label in labels:
|
|
if not self.svg_doc.bb_cache.has_key(label):
|
|
self.svg_doc.bb_cache[label] = None
|
|
|
|
names = []
|
|
for (ctrl, key, var_name) in self.controls.values():
|
|
labels = ctrl.get_svg_labels()
|
|
for label in labels:
|
|
if not self.svg_doc.bb_cache.has_key(label):
|
|
names.extend(label)
|
|
|
|
self.svg_doc.compute_bb(names)
|
|
self.timer = wx.Timer(self)
|
|
self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
|
|
self.mousetimer = wx.Timer(self)
|
|
self.Bind(wx.EVT_TIMER, self.on_mousetimer, self.mousetimer)
|
|
self.test_timer = wx.Timer(self)
|
|
self.Bind(wx.EVT_TIMER, self.on_test_timer, self.test_timer)
|
|
self.load_time = mytime.clock()
|
|
self.total_vars = 10000
|
|
try:
|
|
self.redirect = self.parent.config.get(self.name, 'redirect')
|
|
self.redirect_var = self.parent.config.get(self.name, 'redirect_var')
|
|
self.redirect_mask = int(self.parent.config.get(self.name, 'redirect_mask'), 16)
|
|
self.redirect_val = int(self.parent.config.get(self.name, 'redirect_val'), 16)
|
|
except:
|
|
self.redirect = None
|
|
|
|
self.active_cs_button = None
|
|
self.active_index_button = None
|
|
self.updateControlLimits()
|
|
return
|
|
|
|
def refreshUnits(self):
|
|
for ctrl_name in self.controls:
|
|
(ctrl, key, var_name) = self.controls[ctrl_name]
|
|
if key == None:
|
|
continue
|
|
if key.member_id == protocol.MEMBER_ID_THRESHOLD:
|
|
ctrl.set_value(ctrl.get_value())
|
|
|
|
return
|
|
|
|
def readCustomElementKeys(self):
|
|
self.elementConfig = ConfigParser.ConfigParser()
|
|
self.defaultElementConfigFile = os.path.join(self.parent.next_skin_path, 'elementKeys.cfg')
|
|
if os.path.exists(self.defaultElementConfigFile):
|
|
try:
|
|
self.elementConfig.read(self.defaultElementConfigFile)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
self.userElementConfigFile = os.path.join(one_unit.app.asys_config_path, self.parent.GL.loaded_skin + '_elementKeys.cfg')
|
|
if os.path.exists(self.userElementConfigFile):
|
|
try:
|
|
self.elementConfig.read(self.userElementConfigFile)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
print mytime.displayTime(), 'cp.element config sections:', self.elementConfig.sections()
|
|
for section in self.elementConfig.sections():
|
|
try:
|
|
view = section[:section.find('|')]
|
|
print mytime.displayTime(), 'cu.ek.view:', view
|
|
if view != self.name:
|
|
continue
|
|
rest = section[section.find('|') + 1:]
|
|
channel = eval(rest[:rest.find('|')])
|
|
sectionRef = section
|
|
if channel == -1:
|
|
channel = None
|
|
sectionRef = section.replace('-1', 'None')
|
|
print mytime.displayTime(), 'cu.ek.channel', channel, self.current_channel
|
|
if channel != self.current_channel:
|
|
continue
|
|
controlName = rest[rest.find('|') + 1:]
|
|
print mytime.displayTime(), 'cu.ek.control name:', controlName
|
|
Key = data_model.Key
|
|
self.customElementKeys[sectionRef] = eval(self.elementConfig.get(section, 'customElementKeys'))
|
|
print mytime.displayTime(), 'Found custom customElementKeys for', sectionRef, self.customElementKeys[sectionRef]
|
|
except ConfigParser.NoOptionError:
|
|
pass
|
|
except:
|
|
print mytime.displayTime(), 'cp.Error decoding custom element key for section', section
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
print mytime.displayTime(), 'cp.customElementKeys:', self.customElementKeys
|
|
return
|
|
|
|
def readChannelFlagMask(self):
|
|
self.channelFlagMaskConfig = ConfigParser.ConfigParser()
|
|
self.defaultChannelFlagMaskConfigFile = os.path.join(self.parent.next_skin_path, 'channelFlagMask.cfg')
|
|
if os.path.exists(self.defaultChannelFlagMaskConfigFile):
|
|
try:
|
|
self.channelFlagMaskConfig.read(self.defaultChannelFlagMaskConfigFile)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
self.userChannelFlagMaskConfigFile = os.path.join(one_unit.app.asys_config_path, self.parent.GL.loaded_skin + '_channelFlagMask.cfg')
|
|
if os.path.exists(self.userChannelFlagMaskConfigFile):
|
|
try:
|
|
self.channelFlagMaskConfig.read(self.userChannelFlagMaskConfigFile)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
for section in self.channelFlagMaskConfig.sections():
|
|
try:
|
|
view = section[:section.find('|')]
|
|
if view.lower() == 'any':
|
|
view = self.name
|
|
if view != self.name:
|
|
continue
|
|
rest = section[section.find('|') + 1:]
|
|
channel = eval(rest[:rest.find('|')])
|
|
if channel == -1:
|
|
channel = None
|
|
if self.current_channel != None and self.current_channel >= 0 and channel == None:
|
|
channel = self.current_channel
|
|
if channel != self.current_channel:
|
|
continue
|
|
controlName = rest[rest.find('|') + 1:]
|
|
except:
|
|
print mytime.displayTime(), 'cp.Error building channelflag controlName for section', section
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
try:
|
|
mask = eval(self.channelFlagMaskConfig.get(section, 'channelFlagMask'))
|
|
for s in ('_off', '_on', '_over', '_bg', '_max', '_min', '', '_slider',
|
|
'_knob'):
|
|
self.channelFlagMask[controlName + s] = mask
|
|
|
|
except ConfigParser.NoOptionError:
|
|
pass
|
|
except:
|
|
print mytime.displayTime(), 'cp.Error decoding channelflag mask for section', section
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
try:
|
|
show = self.channelFlagMaskConfig.get(section, 'channelFlagShow')
|
|
try:
|
|
show = eval(show)
|
|
except:
|
|
pass
|
|
|
|
for s in ('_off', '_on', '_over', '_bg', '_max', '_min', '', '_slider',
|
|
'_knob'):
|
|
self.channelFlagShow[controlName + s] = show
|
|
|
|
except ConfigParser.NoOptionError:
|
|
pass
|
|
except:
|
|
print mytime.displayTime(), 'cp.Error decoding channelflag show for section', section
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
return
|
|
|
|
def Refresh(self):
|
|
svg_panel.SVG_Panel.Refresh(self)
|
|
return
|
|
|
|
def has_lpf(self):
|
|
return self.have_lpf
|
|
|
|
def has_hpf(self):
|
|
return self.have_hpf
|
|
|
|
def updateControlLimits(self, channel=None):
|
|
if channel != None and self.current_channel != -1 and self.current_channel != channel:
|
|
return
|
|
else:
|
|
for ctrl_name in self.controls:
|
|
(ctrl, key, var_name) = self.controls[ctrl_name]
|
|
if key == None:
|
|
continue
|
|
if hasattr(ctrl, 'set_limits') and callable(ctrl.set_limits):
|
|
try:
|
|
key = self.key_with_current_channel(key)
|
|
if key.member_id == protocol.MEMBER_ID_THRESHOLD and key.channel in self.parent.thresholdCorrection:
|
|
min_val = self.parent.model.get_min(key)
|
|
max_val = self.parent.model.get_max(key)
|
|
if min_val != None and max_val != None and (min_val != ctrl.lower_limit or max_val != ctrl.higher_limit):
|
|
ctrl.set_limits(min_val, max_val)
|
|
if self.parent.model.completion() == 100:
|
|
try:
|
|
val = self.parent.model.get(key)
|
|
if val == None:
|
|
print mytime.displayTime(), 'cp.ucl.got None val for key', key, val, min_val, max_val
|
|
elif val > max_val:
|
|
print mytime.displayTime(), 'cp.ucl.clipping max val for key', key, val, min_val, max_val
|
|
val = max_val
|
|
self.set_value(key, val)
|
|
if val < min_val:
|
|
print mytime.displayTime(), 'cp.ucl.clipping min for key', key, val, min_val, max_val
|
|
val = min_val
|
|
self.set_value(key, val)
|
|
except:
|
|
print mytime.displayTime(), 'cp.ucl.failed to clip val for key', key, val, min_val, max_val
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
self.update_control(ctrl_name, force=True)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
return
|
|
|
|
def saveElementConfig(self):
|
|
f = open(self.userElementConfigFile, 'wb')
|
|
self.elementConfig.write(f)
|
|
f.close()
|
|
return
|
|
|
|
def saveChannelFlagMaskConfig(self):
|
|
f = open(self.userChannelFlagMaskConfigFile, 'wb')
|
|
self.channelFlagMaskConfig.write(f)
|
|
f.close()
|
|
return
|
|
|
|
def switch_skin(self, skin=None):
|
|
if skin is not None and self.parent.switching_skin is False:
|
|
print mytime.displayTime() + ' cp.sw_sk', skin
|
|
self.parent.switch_skin(skin)
|
|
return
|
|
|
|
def select_skin_to_current_user(self):
|
|
if self.parent.checkRedirect(self.name):
|
|
return
|
|
else:
|
|
if self.parent.updatingFirmware == True:
|
|
return
|
|
if self.parent.restartingAfterFirmwareUpdate == True or self.parent.updatingFirmware == True or self.parent.loading_library == True or self.parent.loading_preset == True or self.parent.switching_skin == True or self.parent.init_done == False or self.parent.changing_view == True or one_unit.app.application_stopping == True:
|
|
return
|
|
if self.parent.mv_panel == True:
|
|
return
|
|
if self.parent.accessGrantedToView(self.name) == False:
|
|
self.parent.call_set_view = self.parent.views[0]
|
|
return
|
|
if self.parent.GL.current_skin == self.parent.default_skin and self.parent.GL.current_skin.lower().find('default') >= 0:
|
|
return
|
|
if self.parent.MAC[:4] not in ('DEMO', 'GRPdeactivated', 'VN::'):
|
|
try:
|
|
model_number = one_unit.app.server.peers.units[self.parent.MAC].process.conn.model_number
|
|
if model_number == None:
|
|
self.model_number_string = self.parent.model_number_string
|
|
else:
|
|
self.model_number_string = '_' + str(model_number)
|
|
except:
|
|
return
|
|
else:
|
|
if self.model_number_string in ('', '_'):
|
|
return
|
|
else:
|
|
self.model_number_string = ''
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
if current_user == protocol.uAllDSP and self.parent.MAC[:4] not in ('DEMO',
|
|
'GRPdeactivated'):
|
|
return False
|
|
if current_user == protocol.uFactory:
|
|
if self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_d':
|
|
self.parent.switch_skin(self.parent.active_unit.type + self.model_number_string + '_d')
|
|
return True
|
|
else:
|
|
return False
|
|
if current_user == protocol.uDeveloper or one_unit.app.demo_developer_password[:8] == one_unit.app.check_password and self.parent.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated'):
|
|
if self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_d':
|
|
self.parent.switch_skin(self.parent.active_unit.type + self.model_number_string + '_d')
|
|
return True
|
|
else:
|
|
return False
|
|
if current_user == protocol.uAdmin or one_unit.app.demo_admin_password[:8] == one_unit.app.check_password and self.parent.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated'):
|
|
if self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_a' and (accessrights & protocol.arShowFullSkin == 0 or self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_d' or self.parent.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated') or self.parent.ignore_arShowFullSkin == True):
|
|
self.parent.switch_skin(self.parent.active_unit.type + self.model_number_string + '_a')
|
|
return True
|
|
else:
|
|
return False
|
|
if current_user == protocol.uUser or one_unit.app.demo_user_password[:8] == one_unit.app.check_password and self.parent.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated'):
|
|
if self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_u' and (accessrights & protocol.arShowFullSkin == 0 or self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_d' or self.parent.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated') or self.parent.ignore_arShowFullSkin == True):
|
|
self.parent.switch_skin(self.parent.active_unit.type + self.model_number_string + '_u')
|
|
return True
|
|
else:
|
|
return False
|
|
if current_user == protocol.uLocked or one_unit.app.demo_locked_password[:8] == one_unit.app.check_password and self.parent.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated'):
|
|
if self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_l' and (accessrights & protocol.arShowFullSkin == 0 or self.parent.GL.last_tested_skin != self.parent.active_unit.type + self.model_number_string + '_d' or self.parent.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated') or self.parent.ignore_arShowFullSkin == True):
|
|
self.parent.switch_skin(self.parent.active_unit.type + self.model_number_string + '_l')
|
|
return True
|
|
else:
|
|
return False
|
|
if current_user != 0 and (self.parent.GL.last_tested_skin == self.parent.active_unit.type + self.model_number_string + '_f' or self.parent.GL.last_tested_skin == self.parent.active_unit.type + self.model_number_string + '_a' or self.parent.GL.last_tested_skin == self.parent.active_unit.type + self.model_number_string + '_d' or self.parent.GL.last_tested_skin == self.parent.active_unit.type + self.model_number_string + '_u'):
|
|
self.parent.switch_skin(self.parent.active_unit.type + self.model_number_string)
|
|
return True
|
|
return False
|
|
|
|
def SetMinSize(self, size):
|
|
svg_panel.SVG_Panel.SetMinSize(self, size)
|
|
for ctrl_name in self.controls.keys():
|
|
(ctrl, key, var_name) = self.controls[ctrl_name]
|
|
rc = self.add_control(ctrl)
|
|
if rc == -1:
|
|
del self.controls[ctrl_name]
|
|
|
|
self.update_controls()
|
|
self.svg_doc.set_element_render_all()
|
|
try:
|
|
if self.timer.IsRunning() == False:
|
|
self.timer.Start(500)
|
|
if self.mousetimer.IsRunning() == False:
|
|
self.mousetimer.Start(500)
|
|
except:
|
|
return
|
|
|
|
self.virgin = True
|
|
return
|
|
|
|
def CheckSkin(self):
|
|
if self.parent.active_unit is not None:
|
|
current_skin = self.parent.GL.current_skin
|
|
if current_skin.count('_') > 2:
|
|
current_skin = current_skin[:-2]
|
|
if self.parent.active_unit.type + self.model_number_string != current_skin and self.parent.remote_link.Connected == True and self.parent.auto_unit_switch == True:
|
|
self.switch_skin(self.parent.active_unit.type + self.model_number_string)
|
|
try:
|
|
self.Destroy()
|
|
except:
|
|
pass
|
|
|
|
return True
|
|
if self.parent.active_unit.MAC[:4] not in ('DEMO', 'GRPdeactivated') and self.skin_approved == False:
|
|
self.skin_approved = True
|
|
elif self.parent.active_unit.MAC[:4] not in ('DEMO', 'GRPdeactivated') and self.skin_approved == False:
|
|
self.skin_approved = True
|
|
return False
|
|
|
|
def on_mousetimer(self, evt):
|
|
if one_unit.app.application_stopping == True:
|
|
return
|
|
if self.parent.model.synced() == True and self.parent.model.completion() == 100:
|
|
if self.cursor_type == 'wait':
|
|
cursor = wx.StockCursor(wx.CURSOR_ARROW)
|
|
self.cursor_type = 'arrow'
|
|
self.SetCursor(cursor)
|
|
return
|
|
|
|
def check_redirect(self, key):
|
|
if one_unit.app.application_stopping == True:
|
|
return
|
|
else:
|
|
name = self.parent.model.get_var_name(key)
|
|
if self.redirect != None and self.redirect_var == name:
|
|
redirect = self.redirect
|
|
redirect_mask = self.redirect_mask
|
|
redirect_val = self.redirect_val
|
|
try:
|
|
if int(self.parent.model.get_by_name(self.redirect_var)) & redirect_mask == redirect_val:
|
|
print mytime.displayTime() + ' cp.Redirect to', redirect
|
|
self.parent.prepare_set_view(self.redirect)
|
|
return True
|
|
except:
|
|
pass
|
|
|
|
return False
|
|
|
|
def showSynchronizingBar(self):
|
|
if self.parent.program_title.find('(Locked)') > 0:
|
|
return
|
|
else:
|
|
try:
|
|
completion = self.parent.model.completion()
|
|
if completion < 100:
|
|
self.parent.SetTitle(self.parent.program_title + ' (' + str(completion) + '%)')
|
|
self.parent.menubar.SetTitle(self.parent.program_title + ' (' + str(completion) + '%)')
|
|
else:
|
|
self.parent.SetTitle(self.parent.program_title + ' (synced)')
|
|
self.parent.menubar.SetTitle(self.parent.program_title + ' (synced)')
|
|
except:
|
|
pass
|
|
|
|
return
|
|
try:
|
|
if self.IsShownOnScreen() == False:
|
|
self.waitToCreateProgressBarTime = 0
|
|
if self.parent.restartingAfterFirmwareUpdate == False and self.IsShownOnScreen() == True and self.parent.model.completion() < 100 and one_unit.app.bootloader_progress[self.parent.MAC] == None and self.noProgressWindow == False:
|
|
if self.parent.active_unit is not None and self.remote_link.ResetValues == False and self.parent.changing_view == False and self.parent.auto_progress_disabled == False and self.parent.stopping == False and one_unit.app.application_stopping == False:
|
|
if self.parent.remote_link.SyncIndicateActive == True and self.show_sync == False and self.skin_approved == True:
|
|
if self.progress == None:
|
|
if self.parent.model.completion() < 95:
|
|
if self.waitToCreateProgressBarTime != 0:
|
|
if mytime.clock() - self.waitToCreateProgressBarTime > 1:
|
|
self.progress = one_unit.ProgressScreen(self, -1, 'Progress', 'Synchronizing (' + str(self.parent.model.completion()) + '%)')
|
|
else:
|
|
return
|
|
else:
|
|
self.waitToCreateProgressBarTime = mytime.clock()
|
|
if self.progress != None:
|
|
self.show_sync = True
|
|
self.progress.Show(True)
|
|
if self.show_sync == True:
|
|
completion = self.parent.model.completion()
|
|
if completion >= 100 or self.parent.remote_link.Connected == False:
|
|
if self.progress != None:
|
|
self.progress.Destroy()
|
|
self.progress = None
|
|
self.show_sync = False
|
|
self.parent.remote_link.SyncIndicateActive = False
|
|
elif self.IsShownOnScreen() == True:
|
|
if self.progress == None:
|
|
self.progress = one_unit.ProgressScreen(self, -1, 'Progress', 'Synchronizing (' + str(self.parent.model.completion()) + '%)')
|
|
if self.progress.IsShown() == False:
|
|
self.progress.Show(True)
|
|
if self.progress != None:
|
|
self.progress.Update(completion)
|
|
self.progress.SetText('Synchronizing (' + str(completion) + '%)')
|
|
self.update_all_controls_counter = 15
|
|
self.updates = 0
|
|
elif self.progress != None:
|
|
self.progress.Destroy()
|
|
self.progress = None
|
|
self.show_sync = False
|
|
self.progress = None
|
|
elif self.progress != None:
|
|
self.progress.Destroy()
|
|
self.progress = None
|
|
self.show_sync = False
|
|
except:
|
|
pass
|
|
|
|
return
|
|
|
|
def on_timer(self, evt):
|
|
if self.timerExecuting:
|
|
return
|
|
self.timerExecuting = True
|
|
self.executeTimer()
|
|
self.timerExecuting = False
|
|
return
|
|
|
|
def executeTimer(self):
|
|
if self.full_screen_diagram == True:
|
|
self.update_controls()
|
|
return
|
|
self.showSynchronizingBar()
|
|
if self.IsShownOnScreen() == False:
|
|
self.timer.Stop()
|
|
self.timer.Start(2500)
|
|
self.skipping_timer = 10
|
|
self.refreshAfterSync = True
|
|
self.repaint = True
|
|
self.repaint_time = mytime.clock()
|
|
return
|
|
if self.ctrl_with_focus == None and mytime.clock() - self.repaint_time < 3 and mytime.clock() - self.last_repaint_time > 1:
|
|
self.svg_doc.set_element_render_all()
|
|
self.Refresh()
|
|
self.last_repaint_time = mytime.clock()
|
|
if self.skipping_timer > 0:
|
|
self.skipping_timer -= 1
|
|
repeat_time = 1000
|
|
else:
|
|
repeat_time = 250
|
|
if self.parent.stopping == True:
|
|
if self.progress != None:
|
|
self.progress.Destroy()
|
|
self.progress = None
|
|
self.show_sync = False
|
|
self.timer.Stop()
|
|
return
|
|
if self.IsShownOnScreen() == False:
|
|
if self.progress != None:
|
|
self.progress.Destroy()
|
|
self.progress = None
|
|
self.show_sync = False
|
|
if self == self.parent.current_view and self.parent.active_unit.MAC[:4] not in ('DEMO', 'GRPd') and self.parent.updatingFirmware == False:
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
if self.csbutton == None:
|
|
if self.current_channel < 128 and self.current_channel >= 0 and accessrights & protocol.arInChannel == 0 and self.parent.active_unit.MAC[:4] not in ('DEMO', 'GRP_') or self.current_channel >= 128 and accessrights & protocol.arOutChannel == 0 and self.parent.GL.last_tested_skin.endswith('_a') == False and self.parent.current_view != self.parent.views[0]:
|
|
print mytime.displayTime() + ' cp.Access to this panel has been denied (1), switching to main panel.', self.name, self.current_channel, self, self.parent.current_view, self.parent.views[0]
|
|
self.parent.prepare_set_view(self.parent.views[0], force=True)
|
|
return
|
|
elif self.parent.GL.current_skin.endswith('_eq') and self.current_channel == None:
|
|
self.current_channel = 0
|
|
if (self.current_channel < 128 and self.current_channel >= 0 and accessrights & protocol.arInChannel == 0 and self.parent.active_unit.MAC[:4] not in ('DEMO', 'GRP_') or self.current_channel >= 128 and accessrights & protocol.arOutChannel == 0 and self.parent.GL.last_tested_skin.endswith('_a') == False and self.parent.alwaysGrantAccessToOutPanel == False or self.current_channel < 0 and (self.csbutton[:5] == 'cs_in' or self.csbutton[:6] == 'cs_out' or self.csbutton == 'cs_auto_io') and self.parent.current_view != self.parent.views[0]) and self.name[:10] != 'Main_panel':
|
|
print mytime.displayTime() + ' cp.Access to this panel has been denied (2), switching to main panel.', '|' + self.name[:10] + '|', self.current_channel, self, self.parent.current_view, self.parent.views[0]
|
|
self.parent.prepare_set_view(self.parent.views[0], force=True)
|
|
return
|
|
try:
|
|
view_accessrights = self.parent.config.getint(self.name, 'required_access_rights')
|
|
if view_accessrights & accessrights == 0 and self.parent.current_view != self.parent.views[0]:
|
|
print mytime.displayTime() + ' cp.Access to this panel has been denied (3), switching to main panel.', self.name, self.current_channel, self, self.parent.current_view, self.parent.views[0]
|
|
self.parent.prepare_set_view(self.parent.views[0], force=True)
|
|
return
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
if self.virgin == True:
|
|
if self.parent.mv_panel == True:
|
|
group = self.parent.group
|
|
members = one_unit.app.groups[group]
|
|
for mac in members:
|
|
try:
|
|
one_unit.app.server.peers.units[mac].process.conn.enable_vu = True
|
|
except:
|
|
pass
|
|
|
|
for key in self.gauges.keys():
|
|
if key.channel == -1 and self.current_channel is not None:
|
|
member_id = key.member_id
|
|
if self.current_channel < 128:
|
|
if key.member_id == protocol.MEMBER_ID_VU_OUT:
|
|
member_id = protocol.MEMBER_ID_VU_IN
|
|
if key.member_id == protocol.MEMBER_ID_GR_OUT:
|
|
member_id = protocol.MEMBER_ID_GR_IN
|
|
elif key.member_id == protocol.MEMBER_ID_VU_IN:
|
|
member_id = protocol.MEMBER_ID_VU_OUT
|
|
if key.member_id == protocol.MEMBER_ID_GR_IN:
|
|
member_id = protocol.MEMBER_ID_GR_OUT
|
|
new_key = data_model.Key(key.struct_id, member_id, -1, key.num)
|
|
if key != new_key:
|
|
if new_key not in self.gauges.keys():
|
|
self.gauges[new_key] = []
|
|
for client in self.gauges[key]:
|
|
self.gauges[new_key].append(client)
|
|
|
|
del self.gauges[key]
|
|
print mytime.displayTime() + ' Changed gauge key from ', key, 'to', new_key
|
|
|
|
self.index = 0
|
|
self.virgin = False
|
|
if self == self.parent.current_view:
|
|
if self.CheckSkin() == True:
|
|
return
|
|
if self.parent.model.changed == True or self.update_all_controls_counter > 20 or self.skipping_timer > 0 or self.needRefreshAfterSync == True:
|
|
if self.parent.model.synced() == True and self.parent.model.completion() == 100:
|
|
self.needRefreshAfterSync = False
|
|
self.update_all_controls_counter = 0
|
|
self.update_controls()
|
|
self.parent.model.changed = False
|
|
for gauges in self.gauges.values():
|
|
for gauge in gauges:
|
|
gauge.verifyRender()
|
|
gauge.Refresh()
|
|
|
|
self.svg_doc.set_element_render_all()
|
|
self.update_all_controls_counter += 1
|
|
if self.updates > 2:
|
|
self.timer.Stop()
|
|
if self.show_sync == True:
|
|
self.timer.Start(250)
|
|
else:
|
|
self.timer.Start(repeat_time)
|
|
else:
|
|
self.updates += 1
|
|
else:
|
|
self.virgin = True
|
|
self.timer.Stop()
|
|
if self.show_sync == True:
|
|
self.timer.Start(250)
|
|
else:
|
|
self.timer.Start(repeat_time)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
if self.parent.mv_panel == True:
|
|
try:
|
|
group = self.parent.group
|
|
members = one_unit.app.groups[group]
|
|
vu_max_in = -100
|
|
vu_max_out = -100
|
|
gr_max = -100
|
|
vu_min_in = 100
|
|
vu_min_out = 100
|
|
gr_min = 100
|
|
for mac in members:
|
|
try:
|
|
(invu, outvu) = server.unit_data.vu[mac]
|
|
except:
|
|
invu = -100
|
|
outvu = -100
|
|
|
|
if outvu > vu_max_out:
|
|
vu_max_out = outvu
|
|
if invu > vu_max_in:
|
|
vu_max_in = invu
|
|
if outvu < vu_min_out:
|
|
vu_min_out = outvu
|
|
if invu < vu_min_in:
|
|
vu_min_in = invu
|
|
try:
|
|
gr = server.unit_data.gr[mac]
|
|
except:
|
|
gr = -100
|
|
|
|
if gr > gr_max:
|
|
gr_max = gr
|
|
if gr < gr_min:
|
|
gr_min = gr
|
|
|
|
for key in self.gauges.keys():
|
|
if key.member_id == protocol.MEMBER_ID_VU_IN:
|
|
for gauge in self.gauges[key]:
|
|
if gauge.name.find('min') > 0:
|
|
gauge.update(vu_min_in)
|
|
else:
|
|
gauge.update(vu_max_in)
|
|
|
|
continue
|
|
if key.member_id == protocol.MEMBER_ID_VU_OUT:
|
|
for gauge in self.gauges[key]:
|
|
if gauge.name.find('min') > 0:
|
|
gauge.update(vu_min_out)
|
|
else:
|
|
gauge.update(vu_max_out)
|
|
|
|
continue
|
|
if key.member_id in (protocol.MEMBER_ID_GR_IN, protocol.MEMBER_ID_GR_OUT):
|
|
for gauge in self.gauges[key]:
|
|
if gauge.name.find('min') > 0:
|
|
gauge.update(gr_min)
|
|
else:
|
|
gauge.update(gr_max)
|
|
|
|
self.timer.Stop()
|
|
self.timer.Start(100)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
return
|
|
|
|
def unsavedChanges(self):
|
|
try:
|
|
key = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_HARDWARE_STATUS_FLAGS, 0, 0)
|
|
val = self.parent.model.get(key)
|
|
if val != None:
|
|
val = int(val)
|
|
if val & protocol.confUserConfig > 0:
|
|
print mytime.displayTime(), 'cp.Jaja wel user changes'
|
|
return True
|
|
print mytime.displayTime(), 'cp.Nene geen user changes'
|
|
return False
|
|
return True
|
|
except:
|
|
return True
|
|
|
|
return
|
|
|
|
def set_index(self, index):
|
|
if self.active_index_button != None:
|
|
self.active_index_button.set_state('off')
|
|
if int(self.index) != int(index):
|
|
self.index = index
|
|
self.block_once = True
|
|
self.block_once_time = mytime.clock()
|
|
return
|
|
|
|
def on_test_timer(self, evt):
|
|
if self.run_test == True:
|
|
if self.test_phase == 1:
|
|
self.parent.load_vars_from_file('pr1.preset', None)
|
|
key = data_model.Key(protocol.STRUCT_ID_COMMAND, protocol.MEMBER_ID_COMMAND, 0, 2)
|
|
self.parent.model.set_to_unit(key, 0)
|
|
self.test_phase = 0
|
|
else:
|
|
self.parent.load_vars_from_file('pr2.preset', None)
|
|
key = data_model.Key(protocol.STRUCT_ID_COMMAND, protocol.MEMBER_ID_COMMAND, 0, 2)
|
|
self.parent.model.set_to_unit(key, 1)
|
|
self.test_phase = 1
|
|
self.update_controls()
|
|
return
|
|
|
|
def set_channel(self, chan_no):
|
|
if self.active_cs_button != None:
|
|
self.active_cs_button.set_state('off')
|
|
self.current_channel = chan_no
|
|
self.selected_channel = chan_no
|
|
self.updateControlLimits()
|
|
self.channelFlagMask = {}
|
|
self.channelFlagShow = {}
|
|
self.readChannelFlagMask()
|
|
self.readCustomElementKeys()
|
|
self.update_controls()
|
|
return
|
|
|
|
def control_factory(self, section, ctrl_name):
|
|
handlers = {'slider': (self.create_slider),
|
|
'knob': (self.create_knob),
|
|
'text': (self.create_text),
|
|
'gauge': (self.create_gauge),
|
|
'toggle-button': (self.create_toggle_button),
|
|
'button': (self.create_button),
|
|
'PEQ_diagram': (self.create_PEQ_diagram),
|
|
'XV_diagram': (self.create_XV_diagram),
|
|
'choice': (self.create_choice),
|
|
'available_units': (self.create_available_units),
|
|
'delay_unit': (self.create_delay_unit),
|
|
'indicator': (self.create_indicator),
|
|
'label': (self.create_label),
|
|
'memberList': (self.createItemList),
|
|
'groupList': (self.createItemList)}
|
|
try:
|
|
ctrl_type = self.config.get(section, ctrl_name + '_type')
|
|
except:
|
|
if ctrl_name.find('_text') > 0:
|
|
ctrl_type = 'text'
|
|
elif ctrl_name.find('_slider') > 0:
|
|
ctrl_type = 'slider'
|
|
elif ctrl_name.find('_label') > 0:
|
|
ctrl_type = 'label'
|
|
elif ctrl_name.find('_button') > 0:
|
|
ctrl_type = 'button'
|
|
elif ctrl_name.find('_knob') > 0:
|
|
ctrl_type = 'knob'
|
|
elif ctrl_name.find('_gauge') > 0:
|
|
ctrl_type = 'gauge'
|
|
elif ctrl_name.find('_type') > 0 and self.auto_type_choice:
|
|
ctrl_type = 'choice'
|
|
elif ctrl_name.find('_choice') > 0:
|
|
ctrl_type = 'choice'
|
|
elif ctrl_name.find('vu_') == 0:
|
|
ctrl_type = 'gauge'
|
|
elif ctrl_name.find('level_') == 0:
|
|
ctrl_type = 'gauge'
|
|
elif ctrl_name.find('gr_') == 0:
|
|
ctrl_type = 'gauge'
|
|
elif ctrl_name.find('memberList') >= 0:
|
|
print mytime.displayTime(), 'cp.got member list'
|
|
ctrl_type = 'memberList'
|
|
elif ctrl_name.find('groupList') >= 0:
|
|
print mytime.displayTime(), 'cp.got group list', ctrl_name
|
|
ctrl_type = 'groupList'
|
|
else:
|
|
ctrl_type = 'toggle-button'
|
|
|
|
self.control_types[ctrl_name] = ctrl_type
|
|
try:
|
|
handler = handlers[ctrl_type]
|
|
except KeyError:
|
|
dial = wx.MessageDialog(None, os.path.join('Unsupported Control Type:', ctrl_type, ctrl_name), 'Error', wx.OK | wx.ICON_ERROR)
|
|
dial.ShowModal()
|
|
return
|
|
else:
|
|
res = handler(self.config, section, ctrl_name)
|
|
res.set_change_handler(self.on_value_change)
|
|
if ctrl_type == 'groupList':
|
|
res.switchGroup = True
|
|
if ctrl_type == 'memberList':
|
|
res.switchToUnit = True
|
|
|
|
return res
|
|
return
|
|
|
|
def is_locked_slave(self, channel):
|
|
if channel > 0 and channel - 1 in self.parent.unit_channels:
|
|
if self.number_of_slaves(channel - 1) > 0:
|
|
return True
|
|
else:
|
|
return False
|
|
return
|
|
|
|
def number_of_slaves(self, channel):
|
|
key = data_model.Key(protocol.STRUCT_ID_LINK, protocol.MEMBER_ID_LINK, channel, 2)
|
|
val = self.parent.model.get(key)
|
|
if val == None:
|
|
return 0
|
|
else:
|
|
if int(val) == 1 and channel + 1 in self.parent.unit_channels:
|
|
if 130 in self.parent.unit_channels and 131 not in self.parent.unit_channels:
|
|
if channel in (0, 129):
|
|
return 1
|
|
else:
|
|
return 0
|
|
else:
|
|
if channel & 1 == 0:
|
|
return 1
|
|
else:
|
|
return 0
|
|
return 0
|
|
|
|
def set_value(self, key, val):
|
|
self.parent.set_value(key, val)
|
|
self.update_all_controls_counter = 20000
|
|
return
|
|
|
|
def Q_to_Bw(self, Q, peq_type):
|
|
if peq_type == protocol.fLowShelf or peq_type == protocol.fHighShelf:
|
|
if Q == 0:
|
|
return 10
|
|
return 30 / Q
|
|
if Q == 0:
|
|
return 80
|
|
return 2.88539 * math.asinh(1 / (2 * Q))
|
|
|
|
def show_q_or_bw(self, Q, ctrl, key):
|
|
peq_type = self.parent.model.get(data_model.Key(protocol.STRUCT_ID_PEQ, protocol.MEMBER_ID_TYPE, key.channel, key.num))
|
|
if peq_type == protocol.fNOTCH:
|
|
max_val = 80.0
|
|
min_val = 10.0
|
|
Q *= 10.0
|
|
elif peq_type == protocol.fLowPass or peq_type == protocol.fHighPass:
|
|
max_val = 2.0
|
|
min_val = 0.5
|
|
Q /= 10.0
|
|
elif peq_type == protocol.fLowShelf or peq_type == protocol.fHighShelf:
|
|
max_val = 25.0
|
|
min_val = 3.0
|
|
else:
|
|
max_val = 25.0
|
|
min_val = 0.1
|
|
if self.parent.model.get(data_model.Key(protocol.STRUCT_ID_INTERNAL, protocol.MEMBER_ID_Q_BW, 0, 0)) == 1:
|
|
ctrl.set_limits(self.Q_to_Bw(max_val, peq_type), self.Q_to_Bw(min_val, peq_type))
|
|
if self.show_Q_unit == True:
|
|
if peq_type == protocol.fLowShelf or peq_type == protocol.fHighShelf:
|
|
ctrl.set_unit('dB/Oct')
|
|
else:
|
|
ctrl.set_unit(' Oc')
|
|
return self.Q_to_Bw(Q, peq_type)
|
|
else:
|
|
ctrl.set_limits(min_val, max_val)
|
|
if self.show_Q_unit == True:
|
|
try:
|
|
if peq_type == protocol.fLowShelf or peq_type == protocol.fHighShelf:
|
|
ctrl.set_unit('dB/Oct')
|
|
else:
|
|
ctrl.set_unit(' Q')
|
|
except:
|
|
pass
|
|
|
|
return round(Q, 1)
|
|
return
|
|
|
|
def get_q_or_bw(self, val, key):
|
|
peq_type = self.parent.model.get(data_model.Key(protocol.STRUCT_ID_PEQ, protocol.MEMBER_ID_TYPE, key.channel, key.num))
|
|
test_key = data_model.Key(protocol.STRUCT_ID_INTERNAL, protocol.MEMBER_ID_Q_BW, 0, 0)
|
|
if self.parent.model.get(test_key) == 1:
|
|
if val == 0:
|
|
return 25
|
|
else:
|
|
if peq_type == protocol.fLowShelf or peq_type == protocol.fHighShelf:
|
|
val = 30.0 / val
|
|
else:
|
|
val = math.sqrt(math.pow(2, val)) / (pow(2, val) - 1.0)
|
|
if peq_type == protocol.fNOTCH:
|
|
val /= 10.0
|
|
if val > 8:
|
|
val = 8
|
|
if val < 1:
|
|
return 1
|
|
return val
|
|
if peq_type == protocol.fHighPass or peq_type == protocol.fLowPass:
|
|
val *= 10.0
|
|
if val > 20:
|
|
val = 20
|
|
if val < 5:
|
|
return 5
|
|
return val
|
|
if val > 25:
|
|
val = 25
|
|
if val < 0.1:
|
|
return 0.1
|
|
return val
|
|
else:
|
|
if peq_type == protocol.fNOTCH:
|
|
val /= 10
|
|
elif peq_type == protocol.fHighPass or peq_type == protocol.fLowPass:
|
|
val *= 10
|
|
return val
|
|
return
|
|
|
|
def access_granted(self, key, message=True):
|
|
try:
|
|
if self.parent.active_unit.IP == 'Offline':
|
|
if message == True:
|
|
dial = dialog.Dialog(self, -1, 'Warning', 'It is not allowed to change settings while the unit is offline.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return False
|
|
except:
|
|
return False
|
|
else:
|
|
if self.parent.full_access == True or self.parent.active_unit.MAC[:4] in ('DEMO',
|
|
'GRPdeactivated'):
|
|
return True
|
|
access_granted = True
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
if key.struct_id == protocol.STRUCT_ID_GLOBAL:
|
|
if key.member_id == protocol.MEMBER_ID_CHECK_PASSWORD:
|
|
return True
|
|
if key.member_id == protocol.MEMBER_ID_SHORT_NAME:
|
|
if accessrights & protocol.arUnitName == 0:
|
|
access_granted = False
|
|
elif key.member_id == protocol.MEMBER_ID_STANDBY_DELAY:
|
|
if accessrights & protocol.arUnitConfiguration == 0:
|
|
access_granted = False
|
|
else:
|
|
return True
|
|
elif key.struct_id == protocol.STRUCT_ID_PRESET_GLOBAL:
|
|
if key.member_id == protocol.MEMBER_ID_CONFIGURATION:
|
|
if accessrights & protocol.arOutChannel == 0:
|
|
access_granted = False
|
|
else:
|
|
return True
|
|
else:
|
|
return True
|
|
elif key.struct_id == protocol.STRUCT_ID_COMMAND:
|
|
return True
|
|
confkey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_CONFIGURATION, 0, 0)
|
|
confval = self.parent.model.get(confkey)
|
|
try:
|
|
confval = int(confval)
|
|
except:
|
|
confval = 0
|
|
|
|
try:
|
|
gain_always_allowed = eval(self.parent.main_config.get('ROOT', 'gain_always_allowed'))
|
|
except:
|
|
gain_always_allowed = True
|
|
|
|
if gain_always_allowed:
|
|
if key.channel >= 128 and accessrights & protocol.arOutChannel == 0 and key.struct_id != protocol.STRUCT_ID_MUTE and key.struct_id != protocol.STRUCT_ID_MIXER and (key.struct_id != protocol.STRUCT_ID_GAIN or confval & protocol.confAllModes != 0):
|
|
access_granted = False
|
|
if key.channel < 128 and accessrights & protocol.arInChannel == 0 and key.struct_id != protocol.STRUCT_ID_MUTE and (key.struct_id != protocol.STRUCT_ID_GAIN or confval & protocol.confAllModes != 0):
|
|
access_granted = False
|
|
elif key.channel >= 128 and accessrights & protocol.arOutChannel == 0 and key.struct_id != protocol.STRUCT_ID_MUTE and key.struct_id != protocol.STRUCT_ID_MIXER:
|
|
access_granted = False
|
|
if key.channel < 128 and accessrights & protocol.arInChannel == 0 and key.struct_id != protocol.STRUCT_ID_MUTE:
|
|
access_granted = False
|
|
|
|
if access_granted == False:
|
|
if message == True:
|
|
dial = dialog.Dialog(self, -1, 'Warning', 'Sorry, you do not have sufficient access rights to change this value.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return False
|
|
return True
|
|
|
|
def switchActiveUnitTo(self, mac, switchSkin=False):
|
|
try:
|
|
val = self.parent.peers.units[mac].type
|
|
except:
|
|
print mytime.displayTime() + ' value', val, 'not in peers'
|
|
return
|
|
else:
|
|
try:
|
|
key = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_MODEL_NUMBER, 0, 0)
|
|
model_number = one_unit.app.server.peers.get(key, mac)
|
|
if model_number < 0:
|
|
key = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_MODEL_FIRMWARE, 0, 0)
|
|
model_number = one_unit.app.server.peers.get(key, mac)
|
|
val = val + '_' + str(model_number)
|
|
skin_path = os.path.join(one_unit.app.cwd, one_unit.app.skin_path, val)
|
|
if os.path.exists(skin_path):
|
|
print mytime.displayTime() + ' cp.ovc.Skin', skin_path, ' found'
|
|
elif os.path.exists(skin_path + '_u'):
|
|
print mytime.displayTime() + ' cp.ovc.Skin +_u found'
|
|
val += '_u'
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
try:
|
|
val = val.replace('_None', '')
|
|
except:
|
|
pass
|
|
|
|
if mac[:4] not in ('DEMO', 'GRPdeactivated', 'VN::'):
|
|
if mac not in one_unit.app.pin_verified:
|
|
dial = dialog.Dialog(self, -1, 'Error', 'The unit you have selected is not available yet. Please try again later.')
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
if one_unit.app.pin_verified[mac] == False:
|
|
dial = dialog.Dialog(self, -1, 'Error', 'The unit you have selected is protected by a PIN code. Please close this panel and enter the correct PIN when re-opening it.')
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
if self.parent.peers.units[mac].link_status != 'available':
|
|
dial = dialog.Dialog(self, -1, 'Error', 'The unit you have selected is no longer available. Please check the connection.')
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
if self.parent.support_wrong_skin != True and self.parent.remote_link.Connected == True and self.parent.peers.units[mac].MAC[:4] in ('DEMO',
|
|
'GRPdeactivated'):
|
|
if self.parent.peers.units[mac].type + self.model_number_string != self.parent.active_unit.type + self.model_number_string:
|
|
print mytime.displayTime() + ' Wrong skin, not supported'
|
|
return
|
|
launchKey = one_unit.getLaunchKey(mac)
|
|
print mytime.displayTime(), 'cp.saut', self.parent.launchKey, launchKey
|
|
if launchKey == None:
|
|
print mytime.displayTime(), 'cp.saut. None Launch Key, aborting'
|
|
if self.parent.launchKey != None:
|
|
if launchKey[launchKey.find('|'):] != self.parent.launchKey[self.parent.launchKey.find('|'):]:
|
|
print mytime.displayTime(), 'cp.saut.restoring other closed window'
|
|
wx.CallAfter(one_unit.executeLaunch, mac)
|
|
wx.CallAfter(self.parent.close)
|
|
return
|
|
|
|
if True:
|
|
print mytime.displayTime() + ' cp.ovc.auto switching to', val
|
|
self.parent.active_unit = self.parent.peers.units[mac]
|
|
if mac not in one_unit.app.bootloader_progress:
|
|
one_unit.app.bootloader_progress[mac] = None
|
|
one_unit.app.auto_load_dff[mac] = False
|
|
self.parent.parent.network_window.children[self.parent.MAC] = None
|
|
self.parent.MAC = mac
|
|
if switchSkin == True:
|
|
self.switch_skin(val)
|
|
self.parent.refreshAll()
|
|
return
|
|
else:
|
|
print mytime.displayTime() + 'cu.saut.Nothing to do!'
|
|
return
|
|
|
|
def on_value_change(self, ctrl):
|
|
timestamp = mytime.clock()
|
|
try:
|
|
if self.parent.changing_view == True or self.parent.init_done == False or self.parent.switching_skin == True:
|
|
return
|
|
except:
|
|
return
|
|
else:
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
ctrl_name = ctrl.name
|
|
showMessage = True
|
|
if True:
|
|
(c, key, var_name) = self.controls[ctrl_name]
|
|
if c is not ctrl or key is None and ctrl_name != 'available_units' and ctrl_name != 'delay_unit' and ctrl.name.startswith('cs_') == False:
|
|
print mytime.displayTime(), 'cp.ovc. No key', c, ctrl, key, var_name, ctrl.name
|
|
return
|
|
section = self.name + '|' + str(self.current_channel) + '|' + ctrl_name
|
|
if section in self.customElementKeys:
|
|
keysToApply = self.customElementKeys[section]
|
|
else:
|
|
keysToApply = [
|
|
key]
|
|
keysToApplyIndex = -1
|
|
for key in keysToApply:
|
|
keysToApplyIndex += 1
|
|
value_set = False
|
|
if self.block_once == True and mytime.clock() - self.block_once_time < 1:
|
|
self.block_once = False
|
|
try:
|
|
val = self.parent.model.get(self.key_with_current_channel(key))
|
|
self.update_control(ctrl_name)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
return
|
|
try:
|
|
if ctrl_name.find('output_select') >= 0 and self.parent.autoBridgeSelect:
|
|
print mytime.displayTime(), 'cp. output select changed', ctrl_name, ctrl.text
|
|
bridgeKey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_CONFIGURATION, 0, 0)
|
|
bridgeVal = self.parent.model.get(bridgeKey)
|
|
if bridgeVal == None:
|
|
bridgeVal = 0
|
|
bridgeVal = int(bridgeVal)
|
|
bridgeChannel = self.key_with_current_channel(key).channel
|
|
if bridgeChannel < 8:
|
|
bridgeMask = protocol.confBridge << bridgeChannel / 2
|
|
if ctrl.text.lower().find('bridge') >= 0:
|
|
bridgeVal |= bridgeMask
|
|
else:
|
|
bridgeVal &= ~bridgeMask
|
|
self.parent.model.set_to_unit(bridgeKey, bridgeVal)
|
|
self.simulateMouseClick(1)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
if ctrl_name == 'sleep' or ctrl_name == 'standby':
|
|
num = protocol.cmdExitStandby
|
|
try:
|
|
testkey = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_HARDWARE_STATUS_FLAGS, 0, 0)
|
|
val = self.parent.model.get(testkey)
|
|
if val != None:
|
|
val = int(val)
|
|
if val & protocol.confStandby > 0:
|
|
num = protocol.cmdExitStandby
|
|
else:
|
|
num = protocol.cmdGotoStandby
|
|
except:
|
|
pass
|
|
else:
|
|
key = data_model.Key(key.struct_id, key.member_id, 0, num)
|
|
if ctrl_name == 'power':
|
|
try:
|
|
testkey = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_HARDWARE_STATUS_FLAGS, 0, 0)
|
|
val = self.parent.model.get(testkey)
|
|
if val != None:
|
|
val = int(val)
|
|
if val & protocol.confStandby == 0:
|
|
dial = dialog.Dialog(self, -1, 'Power Off', 'Are you sure to power off?', Wrap=300)
|
|
dial.ShowModal()
|
|
response = dial.response
|
|
dial.Destroy()
|
|
if response != 'OK':
|
|
return
|
|
cmdkey = data_model.Key(protocol.STRUCT_ID_COMMAND, protocol.MEMBER_ID_COMMAND, 0, protocol.cmdGotoStandby)
|
|
self.parent.set_value(cmdkey, 1)
|
|
future.Future(1, self.parent.set_value, cmdkey, 0)
|
|
else:
|
|
cmdkey = data_model.Key(protocol.STRUCT_ID_COMMAND, protocol.MEMBER_ID_COMMAND, 0, protocol.cmdExitStandby)
|
|
self.parent.set_value(cmdkey, 1)
|
|
future.Future(1, self.parent.set_value, cmdkey, 0)
|
|
except:
|
|
pass
|
|
|
|
if ctrl_name == 'check_password':
|
|
print mytime.displayTime(), 'User entered password:', ctrl.get_value(), key
|
|
one_unit.app.check_password = ctrl.get_value()
|
|
pwok = False
|
|
for i in range(0, 6):
|
|
preset_pwkey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_SET_PASSWORD, i, 0)
|
|
presetPassword = self.parent.model.get(preset_pwkey)
|
|
try:
|
|
if presetPassword != None and presetPassword.strip() != '' and presetPassword.strip() == ctrl.get_value().strip():
|
|
userkey = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_CURRENT_USER, 0, 0)
|
|
self.set_value(key, ctrl.get_value())
|
|
self.parent.progress = one_unit.ProgressScreen(self.parent, -1, 'Progress', 'Applying...')
|
|
self.parent.progress.Show(True)
|
|
self.parent.progress.Update(1)
|
|
pr = 1
|
|
try:
|
|
while self.parent.model.synced(key) == False:
|
|
mytime.sleep(0.1)
|
|
if pr < 99:
|
|
pr += 1
|
|
self.parent.progress.Update(pr)
|
|
|
|
self.parent.model.set_to_unit(userkey, i)
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.parent.progress.Destroy()
|
|
except:
|
|
pass
|
|
|
|
return
|
|
if presetPassword != None and presetPassword.strip() != '':
|
|
continue
|
|
except:
|
|
pass
|
|
|
|
pwkey = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_SET_PASSWORD, i, 0)
|
|
globalPassword = self.parent.model.get(pwkey)
|
|
try:
|
|
if globalPassword != None and globalPassword.strip() == ctrl.get_value().strip():
|
|
userkey = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_CURRENT_USER, 0, 0)
|
|
self.set_value(key, ctrl.get_value())
|
|
self.parent.progress = one_unit.ProgressScreen(self.parent, -1, 'Progress', 'Applying...')
|
|
self.parent.progress.Show(True)
|
|
self.parent.progress.Update(1)
|
|
pr = 1
|
|
try:
|
|
while self.parent.model.synced(key) == False:
|
|
mytime.sleep(0.1)
|
|
if pr < 99:
|
|
pr += 1
|
|
self.parent.progress.Update(pr)
|
|
|
|
self.parent.model.set_to_unit(userkey, i)
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
self.parent.progress.Destroy()
|
|
except:
|
|
pass
|
|
|
|
return
|
|
except:
|
|
pass
|
|
|
|
self.parent.set_value(key, one_unit.app.check_password)
|
|
wx.MessageBox('Invalid Password.', 'Error', wx.OK | wx.ICON_ERROR)
|
|
return
|
|
if ctrl_name == 'delay_unit':
|
|
self.delay_unit = ctrl.get_value()
|
|
for ctrl_name in self.controls:
|
|
(c, key, var_name) = self.controls[ctrl_name]
|
|
if key == None:
|
|
continue
|
|
if key.struct_id == protocol.STRUCT_ID_DELAY:
|
|
c.set_value(0)
|
|
|
|
self.update_all_controls_counter = 20000
|
|
return
|
|
if ctrl_name == 'available_units':
|
|
mac = ctrl.get_value()
|
|
self.switchActiveUnitTo(mac)
|
|
return
|
|
if hasattr(ctrl, 'get_values') and callable(ctrl.get_values):
|
|
vals = ctrl.get_values(changed_only=True)
|
|
for (key, val) in vals.items():
|
|
channel_key = self.key_with_current_channel(key)
|
|
if self.is_locked_slave(channel_key.channel):
|
|
channel_key = data_model.Key(channel_key.struct_id, channel_key.member_id, channel_key.channel - 1, channel_key.num)
|
|
if self.access_granted(key, showMessage) == False:
|
|
return
|
|
if key.struct_id == protocol.STRUCT_ID_PEQ and key.member_id == protocol.MEMBER_ID_GAIN and val != self.parent.model.get(channel_key):
|
|
temp_key = data_model.Key(key.struct_id, protocol.MEMBER_ID_ON, channel_key.channel, key.num)
|
|
if math.fabs(val) > 0.05:
|
|
on_val = 1
|
|
else:
|
|
on_val = 0
|
|
try:
|
|
self.set_value(temp_key, on_val)
|
|
except:
|
|
pass
|
|
|
|
if (key.struct_id == protocol.STRUCT_ID_LPF or key.struct_id == protocol.STRUCT_ID_HPF) and key.member_id == protocol.MEMBER_ID_FREQ:
|
|
temp_key = data_model.Key(key.struct_id, protocol.MEMBER_ID_ON, key.channel, key.num)
|
|
if self.parent.model.get(temp_key) != None and val != self.parent.model.get(key):
|
|
self.parent.model.changed = True
|
|
if val > ctrl.lower_limit and val < ctrl.higher_limit:
|
|
self.set_value(temp_key, 1)
|
|
else:
|
|
self.set_value(temp_key, 0)
|
|
self.set_value(channel_key, val)
|
|
|
|
else:
|
|
val = ctrl.get_value()
|
|
key = self.key_with_current_channel(key)
|
|
try:
|
|
if ctrl.variable_num == True:
|
|
key = self.key_with_current_index(key)
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
if ctrl.radio == True:
|
|
self.update_all_controls_counter = 20000
|
|
if val == 'on':
|
|
return
|
|
mask = ctrl.mask
|
|
old_val = int(self.parent.model.get(key))
|
|
old_val &= 4294967295L ^ mask
|
|
if val == 'off':
|
|
if ctrl.mask_val != 0:
|
|
old_val |= ctrl.mask_val
|
|
if val == 'on':
|
|
if ctrl.mask_val == 0:
|
|
old_val |= ctrl.mask
|
|
val = old_val
|
|
except:
|
|
pass
|
|
|
|
if key == None or self.access_granted(key, showMessage) == False:
|
|
return
|
|
if key.struct_id == protocol.STRUCT_ID_CHANNEL and key.member_id == protocol.MEMBER_ID_SHORT_NAME:
|
|
if self.parent.channel_name_split > 0:
|
|
val = (val + ' ')[:16 - self.parent.channel_name_split]
|
|
try:
|
|
val += self.parent.model.get(key)[16 - self.parent.channel_name_split:]
|
|
except:
|
|
print mytime.displayTime() + ' cp.ovc.no value found for channel name'
|
|
return
|
|
else:
|
|
val += ' '
|
|
val = val[:16]
|
|
if key.struct_id == protocol.STRUCT_ID_COMMAND and key.member_id == protocol.MEMBER_ID_COMMAND:
|
|
if self.parent.active_unit.MAC[:4] in ('DEMO', 'GRPdeactivated'):
|
|
return
|
|
loop = 0
|
|
while self.parent.model.synced(key) == False and loop < 100:
|
|
mytime.sleep(0.1)
|
|
one_unit.tryYield()
|
|
loop += 1
|
|
|
|
try:
|
|
if key.struct_id == protocol.STRUCT_ID_PRESET_GLOBAL and key.member_id == protocol.MEMBER_ID_CONFIGURATION:
|
|
if val & protocol.confTwoWay == protocol.confTwoWay:
|
|
for linkkey in self.parent.model.vars:
|
|
if linkkey.struct_id == protocol.STRUCT_ID_LINK and linkkey.member_id == protocol.MEMBER_ID_LINK and linkkey.channel >= 128:
|
|
self.set_value(linkkey, 0)
|
|
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
if key.struct_id == protocol.STRUCT_ID_PEQ and key.member_id == protocol.MEMBER_ID_TYPE:
|
|
self.peq_type_changed = True
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
if self.control_types[ctrl_name] == 'text':
|
|
if isinstance(val, basestring):
|
|
try:
|
|
if ctrl_name.find('long_name') >= 0:
|
|
maxLen = 64
|
|
else:
|
|
maxLen = 16
|
|
new_val = data_model.getValidName(val)[:maxLen]
|
|
if val.strip() != new_val.strip():
|
|
msg = 'The text "' + val.strip() + '" contains illegal characters, and will be changed to "' + new_val + '".'
|
|
dial = dialog.Dialog(self, -1, 'Warning', msg)
|
|
dial.ShowModal()
|
|
response = dial.response
|
|
dial.Destroy()
|
|
if response != 'OK':
|
|
self.update_controls()
|
|
return
|
|
val = new_val
|
|
val = val.strip()
|
|
if len(val) > maxLen:
|
|
msg = 'The text "' + val.strip() + '" is too long, and will be reset to "' + val[:maxLen] + '".'
|
|
dial = dialog.Dialog(self, -1, 'Warning', msg)
|
|
dial.ShowModal()
|
|
response = dial.response
|
|
dial.Destroy()
|
|
if response != 'OK':
|
|
self.update_controls()
|
|
return
|
|
val = val[:maxLen]
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
print mytime.displayTime() + ' ControlPanel.on_value_change: Failed to set unit name:', val
|
|
return
|
|
|
|
if ctrl_name == 'preset_name_text':
|
|
if val != None and val.strip().lower() == 'default':
|
|
dial = dialog.Dialog(self, -1, 'Preset Name', 'The name ' + val.strip() + ' is not allowed. Please choose a different name.')
|
|
dial.ShowModal()
|
|
return
|
|
if val.startswith(self.parent.spk_lib_id):
|
|
if self.current_user == protocol.uDeveloper:
|
|
dial = dialog.Dialog(self, -1, 'Speaker Library', 'The name starting with "' + self.parent.spk_lib_id + '" identifies this preset as a loudspeaker library. Continue?')
|
|
dial.ShowModal()
|
|
res = dial.response
|
|
dial.Destroy()
|
|
if res != 'OK':
|
|
return
|
|
else:
|
|
dial = dialog.Dialog(self, -1, 'Speaker Library', 'The name starting with "' + self.parent.spk_lib_id + '" is protected and can not be used. Please choose another name.')
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
if val.strip().lower() == 'empty':
|
|
val = 'Empty'
|
|
if ctrl_name == 'unit_name_text':
|
|
if val[:3] == 'GRP' and val.strip() != self.parent.active_unit.name.strip():
|
|
dial = dialog.Dialog(self, -1, 'Grouping', 'Grouping via unit name is no longer supported. Please open the network window (Tools - Network Window) and select a group there.')
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
if val == 'start test':
|
|
print mytime.displayTime() + ' Starting Test.....'
|
|
self.run_test = True
|
|
self.test_timer.Start(200)
|
|
self.test_counter = 0
|
|
key = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_SHORT_NAME, 0, 0)
|
|
self.parent.model.set_to_unit(key, 'Test Running')
|
|
return
|
|
if val == 'stop test':
|
|
print mytime.displayTime() + ' Stopped Test'
|
|
self.run_test = False
|
|
self.test_timer.Stop()
|
|
return
|
|
if val == 'ssstart tetrisss':
|
|
one_unit.start_tetris()
|
|
return
|
|
if val == 'list USB':
|
|
one_unit.ListUSBDevices()
|
|
return
|
|
if ctrl_name == 'recall_preset_list' and self.parent.auto_load_preset == True:
|
|
if self.unsavedChanges() == True and one_unit.areYouSure(getString('aslp')) == False:
|
|
self.update_control('recall_preset_list')
|
|
self.needRefreshAfterSync = True
|
|
return
|
|
print mytime.displayTime() + ' cp.auto recall preset .2'
|
|
namekey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_SHORT_NAME, val, 0)
|
|
name = self.parent.model.get(namekey)
|
|
if name == None:
|
|
print mytime.displayTime(), 'cp.None name for preset', val
|
|
return
|
|
if name.strip().lower() in ('empty preset', 'empty'):
|
|
return
|
|
loadKey = data_model.Key(protocol.STRUCT_ID_COMMAND, protocol.MEMBER_ID_COMMAND, 0, protocol.cmdLoadPreset)
|
|
selectKey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_PRESET_NUMBER, 0, 0)
|
|
for groupID in one_unit.app.groups:
|
|
if self.parent.MAC not in one_unit.app.groups[groupID]:
|
|
continue
|
|
print mytime.displayTime() + ' cp.Lid van group', one_unit.app.group_names[groupID]
|
|
modelFWkey = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_MODEL_FIRMWARE, 0, 0)
|
|
modelFW = one_unit.app.server.peers.get(modelFWkey, self.parent.MAC)
|
|
unitType = one_unit.app.server.peers.units[self.parent.MAC].type
|
|
allIdentical = True
|
|
print mytime.displayTime() + ' cp.Mijn unit type:', unitType + '_' + str(modelFW)
|
|
for testMAC in one_unit.app.groups[groupID]:
|
|
try:
|
|
if one_unit.app.server.peers.get(modelFWkey, testMAC) != modelFW or one_unit.app.server.peers.units[testMAC].type != unitType:
|
|
allIdentical = False
|
|
print mytime.displayTime() + ' cp.Gevonden:', one_unit.app.server.peers.units[testMAC].type + '_' + str(one_unit.app.server.peers.get(modelFWkey, testMAC))
|
|
except:
|
|
allIdentical = False
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
if allIdentical:
|
|
continue
|
|
print mytime.displayTime() + ' Verschillende typen in group -> verder controleren'
|
|
if one_unit.app.group_type[groupID] == 'Carbon Copy':
|
|
if loadKey in one_unit.app.group_exceptions[groupID] or selectKey in one_unit.app.group_exceptions[groupID]:
|
|
print mytime.displayTime() + ' Exception in carbon copy group -> OK'
|
|
continue
|
|
print mytime.displayTime() + ' Geen exception in carbon copy group -> niet OK!'
|
|
elif one_unit.app.group_type[groupID] == 'Advanced':
|
|
if loadKey not in one_unit.app.group_links[groupID] and selectKey not in one_unit.app.group_links[groupID]:
|
|
print mytime.displayTime() + ' Geen link in advanced group -> OK'
|
|
continue
|
|
print mytime.displayTime() + ' Link in advanced group -> Niet OK!'
|
|
dial = dialog.Dialog(None, -1, 'Load Preset', 'It is not allowed to load a preset or configuration in groups of mixed unit types.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
self.update_control('recall_preset_list')
|
|
self.needRefreshAfterSync = True
|
|
return
|
|
|
|
if ctrl_name == 'recall_preset_list':
|
|
if val == 0:
|
|
self.update_controls()
|
|
return
|
|
if self.parent.auto_load_preset == True:
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
if accessrights & protocol.arLoadPreset == 0:
|
|
dial = dialog.Dialog(None, -1, 'Access Rights', 'You do not have sufficient access rights to open presets.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
if key.struct_id == protocol.STRUCT_ID_LINK:
|
|
if val == 1:
|
|
channel = key.channel
|
|
if channel >= 128:
|
|
channel = 'output ' + str(channel - 127)
|
|
else:
|
|
channel = 'input ' + str(channel + 1)
|
|
msg = 'Warning! Setting channel links will copy settings of channel ' + channel
|
|
channel = key.channel + key.num
|
|
if channel >= 128:
|
|
channel = 'output ' + str(channel - 128)
|
|
else:
|
|
channel = 'input ' + str(channel)
|
|
msg += ' to channel ' + channel + '. Continue?'
|
|
dlgMessage = msg
|
|
dlgTitle = 'Warning'
|
|
res = wx.MessageBox(dlgMessage, dlgTitle, wx.OK | wx.CANCEL)
|
|
if res != wx.OK:
|
|
self.update_controls()
|
|
return
|
|
start_channel = key.channel
|
|
end_channel = key.channel + key.num
|
|
for sub_key in self.parent.model.vars.keys():
|
|
if sub_key.struct_id == protocol.STRUCT_ID_LINK and sub_key != key and (sub_key.channel >= key.channel and sub_key.channel < key.channel + key.num or key.channel >= sub_key.channel and key.channel < sub_key.channel + sub_key.num):
|
|
self.set_value(sub_key, 0)
|
|
if val == 1 and sub_key.channel > key.channel and sub_key.channel < key.channel + key.num:
|
|
if sub_key.struct_id in (protocol.STRUCT_ID_UI_CONTROL, protocol.STRUCT_ID_GLOBAL, protocol.STRUCT_ID_PRESET_GLOBAL, protocol.STRUCT_ID_MIXER, protocol.STRUCT_ID_LINK) or sub_key.struct_id < 0:
|
|
continue
|
|
if sub_key.struct_id == protocol.STRUCT_ID_MUTE and self.parent.link_mute == False:
|
|
continue
|
|
if sub_key.member_id in (protocol.MEMBER_ID_SHORT_NAME, protocol.MEMBER_ID_INPUT_SELECT, protocol.MEMBER_ID_CONFIGURATION, protocol.MEMBER_ID_COMMAND):
|
|
continue
|
|
master_key = data_model.Key(sub_key.struct_id, sub_key.member_id, start_channel, sub_key.num)
|
|
master_val = self.parent.model.get(master_key)
|
|
sub_val = self.parent.model.get(sub_key)
|
|
if master_val == sub_val:
|
|
continue
|
|
self.set_value(sub_key, master_val)
|
|
|
|
if key.struct_id not in (protocol.STRUCT_ID_MIXER, protocol.STRUCT_ID_MUTE, protocol.STRUCT_ID_LINK) and key.member_id not in (protocol.MEMBER_ID_CONNECTOR_NAME, protocol.MEMBER_ID_SHORT_NAME, protocol.MEMBER_ID_INPUT_SELECT) and (key.struct_id not in (protocol.STRUCT_ID_LPF, protocol.STRUCT_ID_HPF) or key.member_id not in (protocol.MEMBER_ID_GAIN, protocol.MEMBER_ID_Q)) and (key.struct_id != protocol.STRUCT_ID_PRESET_GLOBAL or key.member_id != protocol.MEMBER_ID_DELAY) and self.is_locked_slave(key.channel) and key.struct_id != protocol.STRUCT_ID_GLOBAL:
|
|
key = data_model.Key(key.struct_id, key.member_id, key.channel - 1, key.num)
|
|
elif key.struct_id == protocol.STRUCT_ID_MUTE and self.parent.link_mute == True and self.is_locked_slave(key.channel):
|
|
key = data_model.Key(key.struct_id, key.member_id, key.channel - 1, key.num)
|
|
if key.member_id == protocol.MEMBER_ID_Q:
|
|
val = self.get_q_or_bw(val, key)
|
|
if ctrl_name[:12] == 'xv_knob_freq' and self.remote_link.last_xover_key is not None:
|
|
key = data_model.Key(self.remote_link.last_xover_key.struct_id, key.member_id, key.channel, key.num)
|
|
if ctrl_name[:8] == 'peq_knob' and self.remote_link.last_peq_key is not None:
|
|
key = data_model.Key(key.struct_id, key.member_id, key.channel, self.remote_link.last_peq_key.num)
|
|
if key.struct_id == protocol.STRUCT_ID_PEQ and key.member_id == protocol.MEMBER_ID_GAIN:
|
|
peq_type = self.parent.model.get(data_model.Key(key.struct_id, protocol.MEMBER_ID_TYPE, key.channel, key.num))
|
|
if peq_type in (protocol.fNOTCH, protocol.fAllpass, protocol.fLowPass, protocol.fHighPass):
|
|
return
|
|
if key.struct_id == protocol.STRUCT_ID_PEQ and key.member_id == protocol.MEMBER_ID_GAIN:
|
|
temp_key = data_model.Key(key.struct_id, protocol.MEMBER_ID_ON, key.channel, key.num)
|
|
on_val = 1
|
|
try:
|
|
if val == 0:
|
|
on_val = 0
|
|
else:
|
|
on_val = 1
|
|
except:
|
|
pass
|
|
else:
|
|
try:
|
|
self.set_value(temp_key, on_val)
|
|
except:
|
|
pass
|
|
|
|
if (key.struct_id == protocol.STRUCT_ID_LPF or key.struct_id == protocol.STRUCT_ID_HPF) and key.member_id == protocol.MEMBER_ID_FREQ:
|
|
temp_key = data_model.Key(key.struct_id, protocol.MEMBER_ID_ON, key.channel, key.num)
|
|
if self.parent.model.get(temp_key) != None and val != self.parent.model.get(key):
|
|
if val > ctrl.lower_limit and val < ctrl.higher_limit:
|
|
self.set_value(temp_key, 1)
|
|
else:
|
|
self.set_value(temp_key, 0)
|
|
if key.struct_id == protocol.STRUCT_ID_COMMAND and key.member_id == protocol.MEMBER_ID_COMMAND:
|
|
if self.parent.active_unit.MAC[:4] in ('DEMO', 'GRPdeactivated'):
|
|
return
|
|
if key.num == protocol.cmdLoadPreset:
|
|
if self.unsavedChanges() == True and one_unit.areYouSure(getString('aslp')) == False:
|
|
self.update_control('recall_preset_list')
|
|
self.needRefreshAfterSync = True
|
|
return
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
presetnumkey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_PRESET_NUMBER, 0, 0)
|
|
presetnum = self.parent.model.get(presetnumkey)
|
|
if presetnum in self.preset_names and self.preset_names[presetnum].strip() in ('Empty',
|
|
'Empty Preset'):
|
|
if accessrights & protocol.arLoadEmptyPreset == 0:
|
|
dial = dialog.Dialog(None, -1, 'Access Rights', 'You do not have sufficient access rights to load empty presets.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
elif accessrights & protocol.arLoadPreset == 0:
|
|
dial = dialog.Dialog(None, -1, 'Access Rights', 'You do not have sufficient access rights to load presets.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
self.needRefreshAfterSync = True
|
|
if key.num == protocol.cmdSavePreset:
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
if accessrights & protocol.arSavePreset == 0:
|
|
dial = dialog.Dialog(None, -1, 'Access Rights', 'You do not have sufficient access rights to save presets.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
try:
|
|
tmpkey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_PRESET_NUMBER, 0, 0)
|
|
pres_num = int(self.parent.model.get(tmpkey))
|
|
except:
|
|
pres_num = 100
|
|
|
|
namekey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_SHORT_NAME, pres_num, 0)
|
|
current_name = self.parent.model.get(namekey)
|
|
try:
|
|
tmpkey = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_STARTUP_PRESET, 0, 0)
|
|
read_only_preset_range = (int(self.parent.model.get(tmpkey)) & 65280) / 256
|
|
except:
|
|
read_only_preset_range = 0
|
|
|
|
print mytime.displayTime() + ' cp.ovc.Saving Preset to unit, selected preset number:', pres_num, '(read only range:', read_only_preset_range, '), user level:', protocol.get_user_text(current_user)
|
|
print mytime.displayTime() + ' Current name of selected preset number:', current_name
|
|
if pres_num <= read_only_preset_range and current_user > protocol.uDeveloper:
|
|
print mytime.displayTime() + ' Read-only preset! Aborting'
|
|
if self.custom_write_protected_dialog != None:
|
|
dial = dialog.Dialog(None, -1, 'Read-Only', self.custom_write_protected_dialog, OK_Only=True)
|
|
else:
|
|
dial = dialog.Dialog(None, -1, 'Read-Only', 'Presets 1 to ' + str(read_only_preset_range) + ' are protected. Please save to location ' + str(read_only_preset_range + 1) + ' or above.', OK_Only=True)
|
|
dial.ShowModal()
|
|
dial.Destroy()
|
|
return
|
|
if current_name != None and current_name.strip() != 'Empty':
|
|
dial = wx.MessageBox('Warning: This preset is not empty. Continue?', 'Overwrite Preset', wx.OK | wx.CANCEL)
|
|
if dial != wx.OK:
|
|
return
|
|
if self.keepUserPresetName == True and pres_num > read_only_preset_range:
|
|
userNameKey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_SHORT_NAME, 0, 0)
|
|
self.set_value(userNameKey, current_name)
|
|
mytime.sleep(0.1)
|
|
counter = 100
|
|
while counter > 0 and self.parent.stopping == False:
|
|
if self.parent.model.synced(userNameKey) == True:
|
|
break
|
|
mytime.sleep(0.1)
|
|
counter -= 1
|
|
|
|
self.set_value(key, 1)
|
|
self.parent.waitForSync('saving preset (1)', key=key)
|
|
future.Future(0.5, self.set_value, key, 0)
|
|
self.parent.remote_link.set_get_key(namekey)
|
|
return
|
|
if ctrl_name == 'sleep' or ctrl_name == 'standby':
|
|
val = 1
|
|
if key.struct_id == protocol.STRUCT_ID_COMMAND:
|
|
self.set_value(key, 0)
|
|
self.parent.waitForSync('cp.cdb.command -> 0', key=key)
|
|
self.set_value(key, 1)
|
|
else:
|
|
self.set_value(key, val)
|
|
value_set = True
|
|
if key.struct_id == protocol.STRUCT_ID_PEQ:
|
|
peq_type = self.parent.model.get(data_model.Key(key.struct_id, protocol.MEMBER_ID_TYPE, key.channel, key.num))
|
|
if (peq_type == protocol.fHighShelf or peq_type == protocol.fLowShelf) and self.parent.model.get(data_model.Key(key.struct_id, protocol.MEMBER_ID_Q, key.channel, key.num)) < 3:
|
|
self.set_value(data_model.Key(key.struct_id, protocol.MEMBER_ID_Q, key.channel, key.num), 3)
|
|
showMessage = False
|
|
|
|
try:
|
|
if value_set == True and key.struct_id == protocol.STRUCT_ID_COMMAND:
|
|
if key.num == protocol.cmdLoadPreset:
|
|
self.parent.blockSwitchViewWhenNotSynced = True
|
|
self.cursor_type = 'wait'
|
|
ctrl.set_state('on')
|
|
cursor = wx.StockCursor(wx.CURSOR_WAIT)
|
|
self.SetCursor(cursor)
|
|
future.Future(1, self.SetCursor, wx.StockCursor(wx.CURSOR_ARROW))
|
|
print mytime.displayTime(), 'cp.cdb.l.1'
|
|
if self.parent.waitForSync('cp.cdb.load preset', key=key) == False:
|
|
self.parent.blockSwitchViewWhenNotSynced = False
|
|
return
|
|
print mytime.displayTime(), 'cp.cdb.l.2'
|
|
self.set_value(key, 0)
|
|
print mytime.displayTime(), 'cp.cdb.l.3'
|
|
self.parent.remote_link.LinkStatus = False
|
|
self.parent.remote_link.ClearDataBuffer()
|
|
for testkey in self.parent.remote_link.values.keys():
|
|
if testkey.struct_id != protocol.STRUCT_ID_COMMAND and testkey.member_id not in protocol.unit_global_items:
|
|
if testkey.struct_id == protocol.STRUCT_ID_PRESET_GLOBAL and testkey.member_id == protocol.MEMBER_ID_SHORT_NAME and testkey.channel > 0:
|
|
continue
|
|
del self.parent.remote_link.values[testkey]
|
|
break
|
|
|
|
one_unit.tryYield()
|
|
mytime.sleep(0.5)
|
|
one_unit.tryYield()
|
|
self.parent.refreshAccess()
|
|
print mytime.displayTime(), 'cp.cdb.l.4'
|
|
one_unit.tryYield()
|
|
mytime.sleep(0.5)
|
|
one_unit.tryYield()
|
|
self.parent.model.reset_get_list()
|
|
elif key.num == protocol.cmdLocate:
|
|
future.Future(10, self.set_value, key, 0)
|
|
else:
|
|
future.Future(1, self.set_value, key, 0)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
else:
|
|
if ctrl_name == 'recall_preset_list' and self.parent.auto_load_preset == True:
|
|
loadKey = data_model.Key(protocol.STRUCT_ID_COMMAND, protocol.MEMBER_ID_COMMAND, 0, protocol.cmdLoadPreset)
|
|
if self.last_loaded_preset_no == val and mytime.clock() - self.last_loaded_preset_time < 10:
|
|
print mytime.displayTime() + ' Skipping reload of same preset', val, 'last loaded', mytime.clock() - self.last_loaded_preset_time, 'seconds ago'
|
|
else:
|
|
self.last_loaded_preset_no = val
|
|
self.last_loaded_preset_time = mytime.clock()
|
|
print mytime.displayTime() + ' Auto loading preset', val
|
|
counter = 100
|
|
while counter > 0 and self.parent.stopping == False:
|
|
if self.parent.model.synced(key) == True:
|
|
break
|
|
mytime.sleep(0.1)
|
|
counter -= 1
|
|
|
|
mytime.sleep(1)
|
|
self.set_value(loadKey, 1)
|
|
future.Future(1, self.set_value, loadKey, 0)
|
|
counter = 100
|
|
while counter > 0 and self.parent.stopping == False:
|
|
if self.parent.model.synced(loadKey) == True:
|
|
break
|
|
mytime.sleep(0.1)
|
|
counter -= 1
|
|
|
|
mytime.sleep(1)
|
|
self.parent.remote_link.LinkStatus = False
|
|
self.parent.remote_link.ClearDataBuffer()
|
|
for testkey in self.parent.remote_link.values.keys():
|
|
if testkey.struct_id != protocol.STRUCT_ID_COMMAND:
|
|
del self.parent.remote_link.values[testkey]
|
|
break
|
|
|
|
self.parent.model.reset_get_list()
|
|
self.check_redirect(key)
|
|
|
|
self.updates = 0
|
|
return
|
|
|
|
def update_controls(self, in_ctrl_name=None):
|
|
self.update_control('link_status')
|
|
if self.parent.loading_preset == True or self.parent.switching_skin == True or self.parent.init_done == False or self.parent.changing_view == True or one_unit.app.application_stopping == True or self.remote_link.Connected == False and self.parent.MAC[:4] not in ('DEMO',
|
|
'GRPdeactivated',
|
|
'VN::'):
|
|
return
|
|
else:
|
|
if self.select_skin_to_current_user() == True:
|
|
return
|
|
if self.IsShownOnScreen() == False:
|
|
return
|
|
if self.full_screen_diagram == True:
|
|
for ctrl_name in self.controls.keys():
|
|
if ctrl_name[-3:] == '_fs':
|
|
self.update_control(ctrl_name)
|
|
|
|
return
|
|
if self.parent.MK2 == True:
|
|
self.parent.refreshUIControls()
|
|
self.parent.getAllUserBits()
|
|
(accessrights, current_user) = self.parent.get_access()
|
|
self.accessrights = accessrights
|
|
self.current_user = current_user
|
|
if in_ctrl_name == None:
|
|
self.showSynchronizingBar()
|
|
if len(self.controls) == 0:
|
|
return
|
|
for ctrl_name in self.controls:
|
|
self.update_control(ctrl_name)
|
|
|
|
self.peq_type_changed = False
|
|
else:
|
|
self.update_control(in_ctrl_name)
|
|
return
|
|
|
|
def register_gauge(self, client, key):
|
|
if key == None:
|
|
print mytime.displayTime() + ' None Key not registered!!'
|
|
channel = self.key_with_current_channel(key).channel
|
|
if channel not in self.parent.unit_channels and channel >= 0 and key.struct_id >= 0:
|
|
print mytime.displayTime() + ' cp.rg.Unused channel:', key.channel
|
|
return
|
|
else:
|
|
if key not in self.gauges.keys():
|
|
self.gauges[key] = []
|
|
self.gauges[key].append(client)
|
|
return
|
|
|
|
def update_gauge(self, key, val):
|
|
if self.parent.mv_panel == True:
|
|
return
|
|
if self.IsShownOnScreen() == False:
|
|
return
|
|
if self.full_screen_diagram == True:
|
|
return
|
|
ignoreRender = int(mytime.clock() * 10) % 10
|
|
try:
|
|
for gauge in self.gauges[key]:
|
|
gauge.update(val, ignoreRender=ignoreRender)
|
|
|
|
except:
|
|
try:
|
|
if key.channel == self.current_channel:
|
|
mykey = data_model.Key(key.struct_id, key.member_id, -1, key.num)
|
|
if mykey in self.gauges:
|
|
for gauge in self.gauges[mykey]:
|
|
gauge.update(val)
|
|
|
|
else:
|
|
if key.member_id > protocol.MEMBER_ID_GR_OUT:
|
|
return
|
|
mykey2 = data_model.Key(key.struct_id, key.member_id ^ 1, -1, key.num)
|
|
if mykey2 in self.gauges:
|
|
self.gauges[mykey] = self.gauges[mykey2]
|
|
del self.gauges[mykey2]
|
|
print mytime.displayTime() + ' Reset gauge', mykey2, 'to', mykey
|
|
except:
|
|
pass
|
|
|
|
return
|
|
|
|
def update_control_by_key(self, key):
|
|
try:
|
|
for ctrl_name in self.ctrl_keys[key]:
|
|
if self.control_types[ctrl_name][-7:] != 'diagram':
|
|
self.update_control(ctrl_name)
|
|
|
|
if key.struct_id == protocol.STRUCT_ID_MUTE:
|
|
for ctrl_name in self.controls:
|
|
if self.control_types[ctrl_name] == 'gauge':
|
|
self.update_control(ctrl_name)
|
|
|
|
except:
|
|
pass
|
|
|
|
return
|
|
|
|
def update_control(self, ctrl_name, force=False):
|
|
try:
|
|
(ctrl, key, var_name) = self.controls[ctrl_name]
|
|
except:
|
|
return
|
|
|
|
if self.check_redirect(key) or self.parent.loading_preset == True:
|
|
return
|
|
else:
|
|
if self.full_screen_diagram == True:
|
|
if ctrl_name == 'diagram':
|
|
print 'cp.refresh diagram'
|
|
ctrl.Refresh()
|
|
return
|
|
section = self.name + '|' + str(self.current_channel) + '|' + ctrl_name
|
|
if section in self.customElementKeys:
|
|
if len(self.customElementKeys[section]) == 0:
|
|
return
|
|
key = self.customElementKeys[section][0]
|
|
if self.control_types[ctrl_name] == 'gauge':
|
|
if key.struct_id in (protocol.STRUCT_ID_VU, protocol.STRUCT_ID_GR):
|
|
key = self.key_with_current_channel(data_model.Key(protocol.STRUCT_ID_MUTE, protocol.MEMBER_ID_MUTE, key.channel, 0))
|
|
val = self.parent.model.get(key)
|
|
if val is None:
|
|
return
|
|
old_val = ctrl.is_muted()
|
|
if old_val != val:
|
|
ctrl.set_mute(val)
|
|
ctrl.Refresh()
|
|
return
|
|
if ctrl_name.startswith('select_preset_'):
|
|
key = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_PRESET_NUMBER, 0, 0)
|
|
val = self.parent.model.get(key)
|
|
try:
|
|
preset_number = int(ctrl_name.replace('select_preset_', '')) + 1
|
|
if preset_number == val:
|
|
ctrl.set_state('on')
|
|
else:
|
|
ctrl.set_state('off')
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
return
|
|
if ctrl_name == 'about_text':
|
|
val = self.parent.CreateAboutText(log=True)
|
|
if val != ctrl.get_value():
|
|
ctrl.set_value(val)
|
|
return
|
|
if ctrl_name == 'check_password':
|
|
val = ' '
|
|
if val != ctrl.get_value():
|
|
ctrl.set_value(val)
|
|
return
|
|
if self.control_types[ctrl_name] == 'memberList':
|
|
try:
|
|
val = {}
|
|
for member in one_unit.app.groups[self.parent.group]:
|
|
val[member] = one_unit.app.groups[self.parent.group][member][0]
|
|
|
|
if val != ctrl.get_value():
|
|
ctrl.set_value(val)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
return
|
|
if self.control_types[ctrl_name] == 'groupList':
|
|
try:
|
|
activeItemName = str(one_unit.app.group_names[self.parent.group])
|
|
except:
|
|
activeItemName = None
|
|
|
|
try:
|
|
val = {}
|
|
for group in one_unit.app.groups:
|
|
if ctrl.filter != None:
|
|
if one_unit.app.group_type[group] not in ctrl.filter:
|
|
continue
|
|
val[group] = one_unit.app.group_names[group]
|
|
|
|
if val != ctrl.get_value() or activeItemName != ctrl.activeItemName:
|
|
ctrl.activeItemName = activeItemName
|
|
ctrl.set_value(val)
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
return
|
|
if ctrl_name == 'sleep' or ctrl_name == 'standby':
|
|
try:
|
|
key = data_model.Key(protocol.STRUCT_ID_GLOBAL, protocol.MEMBER_ID_HARDWARE_STATUS_FLAGS, 0, 0)
|
|
val = self.parent.model.get(key)
|
|
if val != None:
|
|
val = int(val)
|
|
if val & protocol.confStandby > 0:
|
|
ctrl.set_state('on')
|
|
else:
|
|
ctrl.set_state('off')
|
|
return
|
|
except:
|
|
pass
|
|
|
|
if ctrl_name == 'link_status':
|
|
old_state = ctrl.get_state()
|
|
if self.remote_link.Connected == True:
|
|
if self.parent.model.synced() == True and self.parent.model.completion() == 100:
|
|
state = 'on'
|
|
else:
|
|
state = 'sync'
|
|
else:
|
|
state = 'off'
|
|
if old_state != state:
|
|
ctrl.set_state(state)
|
|
self.svg_doc.set_element_render(ctrl.name)
|
|
self.Refresh()
|
|
return
|
|
if ctrl_name == 'cs_button':
|
|
return
|
|
if ctrl_name == 'available_units':
|
|
choices = {}
|
|
for mac in self.parent.peers.units.keys():
|
|
if self.parent.peers.units[mac].type.count('_') > 2:
|
|
continue
|
|
name = self.parent.peers.units[mac].name
|
|
if mac[:4] == 'DEMO':
|
|
display_mac = 'Demo'
|
|
else:
|
|
display_mac = mac
|
|
if mac == 'Startup...':
|
|
continue
|
|
name = name.strip()
|
|
if name[-11:] == 'Development':
|
|
choices[mac] = name
|
|
elif name[-7:] == 'Factory':
|
|
choices[mac] = name
|
|
else:
|
|
choices[mac] = name + ' (' + display_mac + ')'
|
|
|
|
if choices != ctrl.get_choices():
|
|
ctrl.set_choices(choices)
|
|
if ctrl.get_value() != self.parent.active_unit.MAC:
|
|
ctrl.set_value(self.parent.active_unit.MAC)
|
|
return
|
|
if ctrl_name == 'recall_preset_list':
|
|
ctrl_choices = ctrl.get_choices()
|
|
choices = {}
|
|
self.preset_names = {}
|
|
for i in ctrl.sort_list:
|
|
namekey = data_model.Key(protocol.STRUCT_ID_PRESET_GLOBAL, protocol.MEMBER_ID_SHORT_NAME, i, 0)
|
|
name = self.parent.model.get(namekey)
|
|
if name == None:
|
|
name = 'None'
|
|
if name.lower().strip() == 'empty preset':
|
|
name = 'Empty'
|
|
if name.find(self.parent.spk_lib_id) < 4 and name.find(self.parent.spk_lib_id) >= 0 and self.current_user > protocol.uDeveloper:
|
|
continue
|
|
self.preset_names[i] = name
|
|
if self.parent.list_empty_presets == False and name.lower().find('empty') >= 0:
|
|
continue
|
|
if self.accessrights & protocol.arLoadEmptyPreset == 0 and self.accessrights & protocol.arSavePreset == 0 and name.lower().strip() in ('empty',
|
|
'empty preset'):
|
|
continue
|
|
if self.parent.show_preset_numbers == True:
|
|
name = str(i) + ': ' + name
|
|
if i == 0:
|
|
name = ' '
|
|
choices[i] = name
|
|
|
|
if choices != ctrl_choices:
|
|
value = ctrl.get_value()
|
|
if value == None:
|
|
value = 0
|
|
ctrl.set_choices(choices)
|
|
ctrl.set_value(value)
|
|
if key == None:
|
|
return
|
|
val = self.parent.model.get(key)
|
|
if val == None:
|
|
return
|
|
if val != ctrl.get_value():
|
|
ctrl.set_value(val)
|
|
return
|
|
if key is not None and key.struct_id in (protocol.STRUCT_ID_LPF, protocol.STRUCT_ID_HPF) and key.member_id == protocol.MEMBER_ID_TYPE and (key.channel >= 0 and key.channel < 128 or key.channel == -1 and self.current_channel >= 0 and self.current_channel < 128):
|
|
try:
|
|
if 39 in ctrl.choices:
|
|
print mytime.displayTime(), 'cp.Removing 48dB filter option for input', key, var_name
|
|
del ctrl.choices[39]
|
|
except:
|
|
pass
|
|
|
|
if ctrl_name[:3] == 'cs_':
|
|
if ctrl_name == self.csbutton:
|
|
state = 'on'
|
|
else:
|
|
state = 'off'
|
|
if self.csbutton in ('cs_auto_io', 'cs_in', 'cs_out'):
|
|
if self.current_channel < 128:
|
|
self.csbutton = 'cs_in'
|
|
else:
|
|
self.csbutton = 'cs_out'
|
|
if self.csbutton[-11:] == '%outchannel' and ctrl_name[:self.csbutton.find('%')] == self.csbutton[:self.csbutton.find('%')] and int(ctrl_name[-1:]) + 127 == self.current_channel:
|
|
state = 'on'
|
|
elif self.csbutton[-10:] == '%inchannel' and ctrl_name[:self.csbutton.find('%')] == self.csbutton[:self.csbutton.find('%')] and int(ctrl_name[-1:]) - 1 == self.current_channel:
|
|
state = 'on'
|
|
elif self.csbutton.find('%') < 0:
|
|
while ctrl_name[:5] == self.csbutton[:5]:
|
|
if ctrl_name[3:5] == 'in' and len(self.csbutton) == 5:
|
|
if self.current_channel == None:
|
|
break
|
|
testval = ord(ctrl_name[5]) - ord('a') - self.current_channel
|
|
if testval == 0:
|
|
state = 'on'
|
|
break
|
|
testval = ord(ctrl_name[5]) - ord('A') - self.current_channel
|
|
if testval == 0:
|
|
state = 'on'
|
|
break
|
|
testval = ord(ctrl_name[5]) - ord('1') - self.current_channel
|
|
if testval == 0:
|
|
state = 'on'
|
|
break
|
|
break
|
|
if ctrl_name[3:6] == 'out' and len(self.csbutton) == 6:
|
|
if self.current_channel == None:
|
|
break
|
|
testval = ord(ctrl_name[6]) - ord('A') - (self.current_channel - 128)
|
|
if testval == 0:
|
|
state = 'on'
|
|
break
|
|
testval = ord(ctrl_name[6]) - ord('a') - (self.current_channel - 128)
|
|
if testval == 0:
|
|
state = 'on'
|
|
break
|
|
testval = ord(ctrl_name[6]) - ord('1') - (self.current_channel - 128)
|
|
if testval == 0:
|
|
state = 'on'
|
|
break
|
|
break
|
|
break
|
|
|
|
if state == 'on':
|
|
self.active_cs_button = ctrl
|
|
if ctrl.get_state() != state or self.render_me(ctrl_name) == ctrl.hidden:
|
|
ctrl.set_state(state, force=True)
|
|
self.svg_doc.set_element_render(ctrl.name)
|
|
return
|
|
if hasattr(ctrl, 'set_values') and callable(ctrl.set_values):
|
|
vals = ctrl.get_values()
|
|
new_vals = {}
|
|
for key in vals:
|
|
new_key = self.key_with_current_channel(key)
|
|
if new_key.channel not in self.parent.unit_channels:
|
|
continue
|
|
val = self.parent.model.get(new_key)
|
|
if val != vals[key]:
|
|
self.svg_doc.set_element_render(ctrl.name)
|
|
new_vals[key] = val
|
|
self.index = key.num
|
|
|
|
if len(new_vals) > 0:
|
|
ctrl.set_values(new_vals)
|
|
ctrl.Refresh()
|
|
return
|
|
if key is None:
|
|
return
|
|
try:
|
|
if self.peq_type_changed == True and key.struct_id == protocol.STRUCT_ID_PEQ and key.member_id == protocol.MEMBER_ID_Q:
|
|
if ctrl.variable_num == True:
|
|
key = self.key_with_current_index(key)
|
|
key = self.key_with_current_channel(key)
|
|
self.show_q_or_bw(1, ctrl, key)
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
if ctrl.variable_num == True:
|
|
key = self.key_with_current_index(key)
|
|
for ctrl_name in self.controls:
|
|
if ctrl_name.find('edit') == 0:
|
|
num = int(ctrl_name[5:])
|
|
(edit_ctrl, edit_key, edit_var) = self.controls[ctrl_name]
|
|
if num == self.index:
|
|
self.active_index_button = edit_ctrl
|
|
if edit_ctrl.get_state() != 'on':
|
|
edit_ctrl.set_state('on')
|
|
elif edit_ctrl.get_state() != 'off':
|
|
edit_ctrl.set_state('off')
|
|
|
|
except:
|
|
pass
|
|
|
|
if ctrl_name[:12] == 'xv_knob_freq' and self.remote_link.last_xover_key is not None:
|
|
key = data_model.Key(self.remote_link.last_xover_key.struct_id, key.member_id, key.channel, key.num)
|
|
if ctrl_name[:8] == 'peq_knob' and self.remote_link.last_peq_key is not None:
|
|
key = data_model.Key(key.struct_id, key.member_id, key.channel, self.remote_link.last_peq_key.num)
|
|
key = self.key_with_current_channel(key)
|
|
if key.channel is None or key.channel < 0:
|
|
return
|
|
if key.struct_id == protocol.STRUCT_ID_INTERNAL:
|
|
val = self.parent.model.get_internal(key)
|
|
else:
|
|
val = self.parent.model.get(key)
|
|
if ctrl_name in fixed_vars_list.keys():
|
|
val = eval(fixed_vars_list[ctrl_name])
|
|
if key.struct_id == protocol.STRUCT_ID_CHANNEL and key.member_id == protocol.MEMBER_ID_SHORT_NAME:
|
|
try:
|
|
val = val[:16 - self.parent.channel_name_split]
|
|
except:
|
|
val = None
|
|
|
|
if val is None and var_name is not None:
|
|
try:
|
|
val = self.config.get(var_name, 'default_value')
|
|
except:
|
|
val = 0
|
|
else:
|
|
try:
|
|
val = float(val)
|
|
except:
|
|
pass
|
|
else:
|
|
self.parent.model.set_default(key, val)
|
|
if val is not None:
|
|
if key.member_id == protocol.MEMBER_ID_Q:
|
|
val = self.show_q_or_bw(val, ctrl, key)
|
|
peq_type = self.parent.model.get(data_model.Key(protocol.STRUCT_ID_PEQ, protocol.MEMBER_ID_TYPE, key.channel, key.num))
|
|
if peq_type == protocol.fNOTCH:
|
|
if self.parent.model.get(data_model.Key(protocol.STRUCT_ID_INTERNAL, protocol.MEMBER_ID_Q_BW, 0, 0)) == 1:
|
|
if val < 0.01:
|
|
val = 0.01
|
|
if val > 1.0:
|
|
val = 1.0
|
|
else:
|
|
if val > 80.0:
|
|
val = 80.0
|
|
if val < 10.0:
|
|
val = 10.0
|
|
if peq_type in (protocol.fLowPass, protocol.fHighPass):
|
|
if self.parent.model.get(data_model.Key(protocol.STRUCT_ID_INTERNAL, protocol.MEMBER_ID_Q_BW, 0, 0)) == 1:
|
|
if val < 0.71:
|
|
val = 0.71
|
|
if val > 2.54:
|
|
val = 2.54
|
|
else:
|
|
if val > 2.0:
|
|
val = 2.0
|
|
if val < 0.5:
|
|
val = 0.5
|
|
if key.struct_id == protocol.STRUCT_ID_PEQ and key.member_id == protocol.MEMBER_ID_GAIN:
|
|
peq_type = self.parent.model.get(data_model.Key(protocol.STRUCT_ID_PEQ, protocol.MEMBER_ID_TYPE, key.channel, key.num))
|
|
if peq_type in (protocol.fNOTCH, protocol.fAllpass, protocol.fHighPass, protocol.fLowPass, protocol.fBandPass):
|
|
try:
|
|
if val != 0:
|
|
self.set_value(key, 0)
|
|
val = '--'
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
old_val = ctrl.get_value()
|
|
try:
|
|
mask_val = ctrl.mask_val
|
|
val = int(val)
|
|
if mask_val == 0:
|
|
if val == 0:
|
|
val = 'on'
|
|
else:
|
|
val = 'off'
|
|
elif val & ctrl.mask == mask_val:
|
|
val = 'on'
|
|
else:
|
|
val = 'off'
|
|
except:
|
|
pass
|
|
else:
|
|
if old_val != val or force == True:
|
|
ctrl.set_value(val)
|
|
self.svg_doc.set_element_render(ctrl.name)
|
|
return
|
|
|
|
def key_with_current_channel(self, key):
|
|
if key == None:
|
|
return
|
|
else:
|
|
try:
|
|
if key.channel < 0:
|
|
key = data_model.Key(key.struct_id, key.member_id, self.current_channel, key.num)
|
|
return key
|
|
except:
|
|
calframe = inspect.getouterframes(inspect.currentframe(), 2)
|
|
print mytime.displayTime(), 'cp.kwcc.Failed to get key with current channel for panel', self.name, 'key', key, 'called from', calframe[2][3], calframe[1][3], calframe[0][3]
|
|
return
|
|
|
|
return
|
|
|
|
def key_with_current_index(self, key):
|
|
key = data_model.Key(key.struct_id, key.member_id, key.channel, self.index)
|
|
return key
|
|
|
|
def key_with_prototype_channel(self, key):
|
|
key = data_model.Key(key.struct_id, key.member_id, -1, key.num)
|
|
return key
|
|
|
|
def update_from_remote_link(self, ctrl):
|
|
try:
|
|
val = self.parent.model.get(self.key_with_current_channel(ctrl.key))
|
|
return val
|
|
except:
|
|
return -1000
|
|
|
|
return
|
|
|
|
def create_slider(self, config, section, ctrl_name):
|
|
try:
|
|
max_name = config.get(section, ctrl_name + '_max_label')
|
|
except:
|
|
max_name = ctrl_name + '_max'
|
|
|
|
try:
|
|
min_name = config.get(section, ctrl_name + '_min_label')
|
|
except:
|
|
min_name = ctrl_name + '_min'
|
|
|
|
res = svg_panel.Slider(self, ctrl_name, max_name, min_name)
|
|
return res
|
|
|
|
def create_knob(self, config, section, ctrl_name):
|
|
res = svg_panel.Knob(ctrl_name)
|
|
return res
|
|
|
|
def create_label(self, config, section, ctrl_name):
|
|
return self.create_text(config, section, ctrl_name, write_protect=True)
|
|
|
|
def create_text(self, config, section, ctrl_name, write_protect=False):
|
|
units = ''
|
|
try:
|
|
var_name = config.get(section, ctrl_name + '_value')
|
|
units = config.get(var_name, 'units').lower()
|
|
if units == 'ppm' and var_name.find('delay') >= 0:
|
|
self.delay_unit = 'ppm'
|
|
print mytime.displayTime(), 'Set self.delay_unit to ppm'
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
my_unit = config.get(section, ctrl_name + '_unit')
|
|
my_unit = my_unit.replace('"', '')
|
|
my_unit = my_unit.replace("'", '')
|
|
except:
|
|
my_unit = ''
|
|
|
|
try:
|
|
member_id = int(config.get(var_name, 'member_id'))
|
|
if protocol.get_member_format(member_id)[-1:] == 's':
|
|
my_unit = 'string'
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
struct_id = int(config.get(var_name, 'struct_id'))
|
|
if struct_id in (protocol.STRUCT_ID_COMPRESSOR, protocol.STRUCT_ID_LIMITER) and member_id in (protocol.MEMBER_ID_ATTACK, protocol.MEMBER_ID_RELEASE, protocol.MEMBER_ID_HOLD):
|
|
units = 'comp_ms'
|
|
except:
|
|
pass
|
|
|
|
try:
|
|
align = config.get(section, ctrl_name + '_align')
|
|
except:
|
|
align = 'centre'
|
|
|
|
try:
|
|
multiline = eval(config.get(section, ctrl_name + '_multiline'))
|
|
except:
|
|
multiline = False
|
|
|
|
my_style = wx.BORDER_NONE | wx.TE_PROCESS_ENTER
|
|
if align == 'left':
|
|
my_style |= wx.TE_LEFT
|
|
if align == 'right':
|
|
my_style |= wx.TE_RIGHT
|
|
if align == 'centre':
|
|
my_style |= wx.TE_CENTRE
|
|
if multiline == True:
|
|
autoresize = False
|
|
my_style |= wx.TE_MULTILINE | wx.TE_NO_VSCROLL
|
|
else:
|
|
autoresize = True
|
|
font_size = self.font_size
|
|
try:
|
|
font_size = int(self.font_sizes[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
text_colour = self.default_text_colour
|
|
try:
|
|
text_colour = eval(self.font_colours[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
val_type = svg_panel.TextValueCtrl.VAL_ANY
|
|
if units in ('db', 'dB', 'dBu', 'dBV'):
|
|
val_type = svg_panel.TextValueCtrl.VAL_DB
|
|
elif units == 'comp_ms':
|
|
val_type = svg_panel.TextValueCtrl.VAL_COMP_MS
|
|
my_unit = 'ms'
|
|
elif units == 'ms':
|
|
val_type = svg_panel.TextValueCtrl.VAL_DELAY
|
|
elif units in ('hz', 'Hz'):
|
|
val_type = svg_panel.TextValueCtrl.VAL_FREQ
|
|
elif units == 'float':
|
|
val_type = svg_panel.TextValueCtrl.VAL_FLOAT
|
|
res = svg_panel.TextValueCtrl(parent=self, name=ctrl_name, value_type=val_type, style=my_style, visible_unit=my_unit, custom_colours=self.custom_colours, default_text_colour=text_colour, write_protect=write_protect, pix=font_size, autoresize=autoresize)
|
|
return res
|
|
|
|
def create_gauge(self, config, section, ctrl_name):
|
|
var_name = 'var for ' + ctrl_name
|
|
try:
|
|
var_name = config.get(section, ctrl_name + '_value')
|
|
try:
|
|
text_location = eval(config.get(section, ctrl_name + '_text_location'))
|
|
except:
|
|
text_location = (10, 4)
|
|
|
|
struct_id = config.getint(var_name, 'struct_id')
|
|
member_id = config.getint(var_name, 'member_id')
|
|
except:
|
|
try:
|
|
for s in var_name.split('_'):
|
|
v = int(s)
|
|
|
|
except:
|
|
print mytime.displayTime(), 'Data member definition ', var_name, ' not found or corrupted'
|
|
traceback.print_exc(file=sys.stdout)
|
|
|
|
try:
|
|
channel = int(config.get(var_name, 'channel'), 0)
|
|
except ConfigParser.NoOptionError:
|
|
channel = -1
|
|
|
|
num = config.getint(var_name, 'num')
|
|
key = data_model.Key(struct_id, member_id, channel, num)
|
|
res = svg_panel.Color_gauge(parent=self, update_func=self.update_from_remote_link, name=ctrl_name)
|
|
res.key = key
|
|
led_spacing = self.vu_led_spacing
|
|
led_size = self.vu_led_size
|
|
led_shape = self.vu_led_shape
|
|
if ctrl_name[:5] in ('gr_in', 'gr_ou'):
|
|
values = self.gr_led_values
|
|
yellow = self.gr_yellow
|
|
red = self.gr_red
|
|
led_spacing = self.gr_led_spacing
|
|
led_size = self.gr_led_size
|
|
led_shape = self.gr_led_shape
|
|
elif ctrl_name[:5] == 'vu_in':
|
|
values = self.vu_in_led_values
|
|
yellow = self.vu_in_yellow
|
|
red = self.vu_in_red
|
|
elif ctrl_name == 'level_vu':
|
|
values = None
|
|
yellow = self.vu_out_yellow
|
|
red = self.vu_out_red
|
|
elif ctrl_name == 'level_gr':
|
|
values = None
|
|
yellow = 0
|
|
red = self.vu_out_red
|
|
elif ctrl_name == 'level_pwr':
|
|
values = None
|
|
yellow = self.vu_pwr_yellow
|
|
red = self.vu_pwr_red
|
|
else:
|
|
values = self.vu_out_led_values
|
|
yellow = self.vu_out_yellow
|
|
red = self.vu_out_red
|
|
res.set_style(style='leds', led_shape=led_shape, led_spacing=led_spacing, led_size=led_size, yellow=yellow, red=red, grey_on_mute=self.vu_grey_on_mute, led_values=values, text_location=text_location, bg_colour=self.vu_bg_colour, default_text_colour=(0,
|
|
0,
|
|
0))
|
|
return res
|
|
|
|
def create_toggle_button(self, config, section, ctrl_name):
|
|
res = svg_panel.ToggleButton(self, ctrl_name)
|
|
return res
|
|
|
|
def create_button(self, config, section, ctrl_name):
|
|
res = svg_panel.Button(self, ctrl_name)
|
|
return res
|
|
|
|
def create_PEQ_diagram(self, config, section, ctrl_name):
|
|
try:
|
|
res = diagram.PEQ_diagram(parent=self, config=config, section=section, name=ctrl_name, max_freq=self.peq_max_freq)
|
|
return res
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
return
|
|
|
|
return
|
|
|
|
def create_XV_diagram(self, config, section, ctrl_name):
|
|
res = diagram.XV_diagram(parent=self, config=config, section=section, name=ctrl_name)
|
|
return res
|
|
|
|
def create_choice(self, config, section, ctrl_name):
|
|
var_name = config.get(section, ctrl_name + '_value')
|
|
choices = {}
|
|
if var_name == 'recall_preset':
|
|
try:
|
|
min_value = int(config.get(var_name, 'min_value'))
|
|
except:
|
|
min_value = 0
|
|
else:
|
|
try:
|
|
max_value = int(config.get(var_name, 'max_value'))
|
|
except:
|
|
max_value = 1
|
|
else:
|
|
choices = {}
|
|
sort_list = []
|
|
for i in range(min_value, max_value + 1):
|
|
sort_list.append(i)
|
|
|
|
else:
|
|
values = config.get(var_name, 'values')
|
|
values = [_[1] for s in values.split(',')]
|
|
labels = config.get(var_name, 'labels')
|
|
labels = [_[2] for s in labels.split(',')]
|
|
try:
|
|
sort_list = config.get(var_name, 'sort_list')
|
|
sort_list = [_[3] for s in sort_list.split(',')]
|
|
except:
|
|
sort_list = values
|
|
|
|
for i in range(len(values)):
|
|
choices[values[i]] = labels[i]
|
|
|
|
font_size = self.font_size
|
|
try:
|
|
font_size = int(self.font_sizes[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
text_colour = self.default_text_colour
|
|
try:
|
|
text_colour = eval(self.font_colours[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
res = svg_panel.Choice(parent=self, choices=choices, name=ctrl_name, sort_list=sort_list, pix=font_size, default_text_colour=text_colour, custom_colours=self.custom_colours)
|
|
return res
|
|
|
|
def create_available_units(self, config, section, ctrl_name):
|
|
my_choices = {}
|
|
font_size = self.font_size
|
|
try:
|
|
font_size = int(self.font_sizes[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
text_colour = self.default_text_colour
|
|
try:
|
|
text_colour = eval(self.font_colours[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
for mac in self.parent.peers.units.keys():
|
|
my_choices[mac] = self.parent.peers.units[mac].name
|
|
|
|
res = svg_panel.Choice(parent=self, choices=my_choices, name=ctrl_name, pix=font_size, default_text_colour=text_colour, custom_colours=self.custom_colours)
|
|
return res
|
|
|
|
def create_delay_unit(self, config, section, ctrl_name):
|
|
try:
|
|
choices = eval(self.config.get(self.name, 'delay_unit_choices'))
|
|
except:
|
|
choices = {'ms': 'ms', 's': 's', 'mm': 'mm', 'm': 'm', 'mil': 'mil', 'inch': 'inch', 'feet': 'feet'}
|
|
|
|
font_size = self.font_size
|
|
try:
|
|
font_size = int(self.font_sizes[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
text_colour = self.default_text_colour
|
|
try:
|
|
text_colour = eval(self.font_colours[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
res = svg_panel.Choice(parent=self, choices=choices, name=ctrl_name, pix=font_size, default_text_colour=text_colour, custom_colours=self.custom_colours)
|
|
res.set_value('ms')
|
|
return res
|
|
|
|
def create_indicator(self, config, section, ctrl_name):
|
|
condition = config.get(section, ctrl_name + '_condition')
|
|
res = svg_panel.Indicator(ctrl_name, condition, config, section)
|
|
return res
|
|
|
|
def createItemList(self, config, section, ctrl_name):
|
|
try:
|
|
settings = eval(config.get(section, ctrl_name + '_settings'))
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
settings = {}
|
|
|
|
try:
|
|
scroll = settings['scroll']
|
|
except:
|
|
scroll = True
|
|
|
|
my_style = wx.BORDER_NONE | wx.TE_PROCESS_ENTER
|
|
try:
|
|
align = settings['align']
|
|
except:
|
|
align = 'left'
|
|
|
|
if align == 'left':
|
|
my_style |= wx.TE_LEFT
|
|
if align == 'right':
|
|
my_style |= wx.TE_RIGHT
|
|
if align in ('centre', 'center'):
|
|
my_style |= wx.TE_CENTRE
|
|
if scroll == True:
|
|
autoresize = False
|
|
my_style |= wx.TE_MULTILINE | wx.TE_NO_VSCROLL
|
|
else:
|
|
autoresize = True
|
|
my_style |= wx.TE_MULTILINE | wx.TE_NO_VSCROLL
|
|
font_size = self.font_size
|
|
try:
|
|
font_size = int(self.font_sizes[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
text_colour = self.default_text_colour
|
|
try:
|
|
text_colour = eval(self.font_colours[ctrl_name])
|
|
except:
|
|
pass
|
|
|
|
val_type = svg_panel.TextValueCtrl.VAL_ANY
|
|
try:
|
|
res = svg_panel.itemList(parent=self, name=ctrl_name, value_type=val_type, style=my_style, visible_unit='', custom_colours=self.custom_colours, default_text_colour=text_colour, write_protect=True, pix=font_size, autoresize=autoresize, itemList={}, settings=settings)
|
|
print mytime.displayTime() + ' Created member list:', ctrl_name
|
|
except:
|
|
traceback.print_exc(file=sys.stdout)
|
|
res = None
|
|
|
|
return res
|
|
|
|
def reset_peq(self, num):
|
|
struct_id = protocol.STRUCT_ID_PEQ
|
|
member_id = protocol.MEMBER_ID_GAIN
|
|
channel = self.current_channel
|
|
key = data_model.Key(struct_id, member_id, channel, num)
|
|
self.set_value(key, 0)
|
|
struct_id = protocol.STRUCT_ID_PEQ
|
|
member_id = protocol.MEMBER_ID_ON
|
|
channel = self.current_channel
|
|
key = data_model.Key(struct_id, member_id, channel, num)
|
|
self.set_value(key, 0)
|
|
return
|
|
|
|
|
|
|
|
# okay decompiling pycode/control_panel.pyc
|