mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-15 12:50:16 +01:00
tidy up the modules a little
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import data_centre.plugin_collection
|
import data_centre.plugin_collection
|
||||||
from data_centre.plugin_collection import ActionsPlugin, DisplayPlugin#, SequencePlugin
|
from data_centre.plugin_collection import ActionsPlugin, DisplayPlugin, ModulationReceiverPlugin#, SequencePlugin
|
||||||
#import math
|
#import math
|
||||||
from math import sin, cos, tan, log, exp, pi
|
from math import sin, cos, tan, log, exp, pi
|
||||||
|
|
||||||
@@ -41,12 +41,13 @@ TODO: >> ?? invert|set_the_shader_param_0_layer_>>print_arguments>>set_variab
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class ManipulatePlugin(ActionsPlugin,DisplayPlugin):
|
class ManipulatePlugin(ActionsPlugin,DisplayPlugin,ModulationReceiverPlugin):
|
||||||
disabled = False
|
disabled = False
|
||||||
|
|
||||||
def __init__(self, plugin_collection):
|
def __init__(self, plugin_collection):
|
||||||
super().__init__(plugin_collection)
|
super().__init__(plugin_collection)
|
||||||
|
|
||||||
|
# ActionsPlugin methods
|
||||||
@property
|
@property
|
||||||
def parserlist(self):
|
def parserlist(self):
|
||||||
return [
|
return [
|
||||||
@@ -58,6 +59,7 @@ class ManipulatePlugin(ActionsPlugin,DisplayPlugin):
|
|||||||
( r"^(.*)>\&(.*)$", self.run_multi ), # pick up piped commands that duplicate a chain of values last
|
( r"^(.*)>\&(.*)$", self.run_multi ), # pick up piped commands that duplicate a chain of values last
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# DisplayPlugin methods
|
||||||
def show_plugin(self, display, display_mode):
|
def show_plugin(self, display, display_mode):
|
||||||
from tkinter import Text, END
|
from tkinter import Text, END
|
||||||
#super(DisplayPlugin).show_plugin(display, display_mode)
|
#super(DisplayPlugin).show_plugin(display, display_mode)
|
||||||
@@ -67,10 +69,10 @@ class ManipulatePlugin(ActionsPlugin,DisplayPlugin):
|
|||||||
for key,value in self.variables.items():
|
for key,value in self.variables.items():
|
||||||
display.display_text.insert(END, "\t" + key + "\t{:03.2f}\n".format(value))
|
display.display_text.insert(END, "\t" + key + "\t{:03.2f}\n".format(value))
|
||||||
|
|
||||||
|
|
||||||
def get_display_modes(self):
|
def get_display_modes(self):
|
||||||
return ["MANIPULA","NAV_MANI"] #"NAV_MANIPULATE"]
|
return ["MANIPULA","NAV_MANI"] #"NAV_MANIPULATE"]
|
||||||
|
|
||||||
|
# Actions
|
||||||
def run_multi(self, action1, action2, value):
|
def run_multi(self, action1, action2, value):
|
||||||
print("ManipulatePlugin>> multi-running '%s' and '%s' with value %s" % (action1, action2, value))
|
print("ManipulatePlugin>> multi-running '%s' and '%s' with value %s" % (action1, action2, value))
|
||||||
self.pc.actions.call_method_name(action1, value)
|
self.pc.actions.call_method_name(action1, value)
|
||||||
@@ -106,25 +108,11 @@ class ManipulatePlugin(ActionsPlugin,DisplayPlugin):
|
|||||||
action, self.variables.get(var_name)# + list(args)
|
action, self.variables.get(var_name)# + list(args)
|
||||||
)
|
)
|
||||||
|
|
||||||
"""def pipe2(self, left, right1, separator, right2, tail, value):
|
|
||||||
self.pc.actions.call_method_name(
|
|
||||||
left + separator + right1, value
|
|
||||||
)
|
|
||||||
self.pc.actions.call_method_name(
|
|
||||||
left + separator + right2, value
|
|
||||||
)
|
|
||||||
self.pc.actions.call_method_name(
|
|
||||||
tail, value
|
|
||||||
)"""
|
|
||||||
|
|
||||||
"""def pipe(self, left, right, value):
|
# ModulationReceiverPlugin methods
|
||||||
# ??
|
# methods for ModulationReceiverPlugin - receives changes to the in-built modulation levels (-1 to +1)
|
||||||
print("ManipulatePlugin>> pipe calling left '%s' and right '%s', both with value '%s'" % (left, right, value))
|
def set_modulation_value(self, param, value):
|
||||||
self.pc.actions.call_method_name(
|
# take modulation value and throw it to local parameter
|
||||||
left, value
|
print("||||| ManipulatePlugin received set_modulation_value for param %s with value %s!" % (param, value))
|
||||||
)
|
self.set_variable("MODVALUE%s" % ('ABCD'[param]), value)
|
||||||
|
|
||||||
self.pc.actions.call_method_name(
|
|
||||||
right, value
|
|
||||||
)"""
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
print ("WJSendPlugin is disabled, not opening serial")
|
print ("WJSendPlugin is disabled, not opening serial")
|
||||||
return
|
return
|
||||||
|
|
||||||
#self.open_serial()
|
|
||||||
#print ("starting refresh?")
|
|
||||||
self.pc.actions.tk.after(500, self.refresh)
|
self.pc.actions.tk.after(500, self.refresh)
|
||||||
#tk.after(500, self.refresh)
|
|
||||||
|
|
||||||
# methods/vars for AutomationSourcePlugin
|
# methods/vars for AutomationSourcePlugin
|
||||||
# a lot of the nitty-gritty handled in parent class, these are for interfacing to the plugin
|
# a lot of the nitty-gritty handled in parent class, these are for interfacing to the plugin
|
||||||
@@ -67,7 +64,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
# experimental & hardcoded !
|
# experimental & hardcoded !
|
||||||
def set_modulation_value(self, param, value):
|
def set_modulation_value(self, param, value):
|
||||||
# take modulation value and throw it to local parameter
|
# take modulation value and throw it to local parameter
|
||||||
print("||||| wjsend received set_modulation_value for param %s with value %s!" % (param, value))
|
print("||||| WJSendPlugin received set_modulation_value for param %s with value %s!" % (param, value))
|
||||||
if param==0:
|
if param==0:
|
||||||
self.set_mix((0.5+value)/2)
|
self.set_mix((0.5+value)/2)
|
||||||
elif param==1:
|
elif param==1:
|
||||||
@@ -77,7 +74,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif param==3:
|
elif param==3:
|
||||||
self.set_back_colour('x', 0.5+value)
|
self.set_back_colour('x', 0.5+value)
|
||||||
else:
|
else:
|
||||||
print("unknown param %s!" % param)
|
print("\tunknown param %s!" % param)
|
||||||
|
|
||||||
#methods for DisplayPlugin
|
#methods for DisplayPlugin
|
||||||
def show_plugin(self, display, display_mode):
|
def show_plugin(self, display, display_mode):
|
||||||
@@ -85,15 +82,15 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
#super(DisplayPlugin).show_plugin(display, display_mode)
|
#super(DisplayPlugin).show_plugin(display, display_mode)
|
||||||
#print("show plugin?")
|
#print("show plugin?")
|
||||||
display.display_text.insert(END, '{} \n'.format(display.body_title))
|
display.display_text.insert(END, '{} \n'.format(display.body_title))
|
||||||
display.display_text.insert(END, "test from WJSendPlugin!\n\n")
|
display.display_text.insert(END, "WJSendPlugin status!\n\n")
|
||||||
|
|
||||||
for queue, last in self.last.items():
|
for queue, last in self.last.items():
|
||||||
display.display_text.insert(END, "last %s:\t%s\n" % (queue,self.last.get(queue)))
|
display.display_text.insert(END, "%s:\t%s\n" % (queue,self.last.get(queue)[1]))
|
||||||
|
|
||||||
def get_display_modes(self):
|
def get_display_modes(self):
|
||||||
return ["WJMXSEND","NAV_WJMX"]
|
return ["WJMXSEND","NAV_WJMX"]
|
||||||
|
|
||||||
# methods for SerialPlugin (todo!)
|
# methods for SerialPlugin (todo!) and serial command queueing
|
||||||
def open_serial(self, port='/dev/ttyUSB0', baudrate=9600):
|
def open_serial(self, port='/dev/ttyUSB0', baudrate=9600):
|
||||||
if self.ser is not None:
|
if self.ser is not None:
|
||||||
self.ser.close()
|
self.ser.close()
|
||||||
@@ -111,25 +108,22 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
timeout=None #timeout
|
timeout=None #timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
print ("starting refresh?")
|
|
||||||
|
|
||||||
#self.pc.midi_input.root.after(500, self.refresh)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print ("open_serial failed: " + str(type(e)))
|
print ("WJSendPlugin>> open_serial failed: " + str(type(e)))
|
||||||
self.disabled = True
|
self.disabled = True
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
def send_serial_string(self, string):
|
def send_serial_string(self, string):
|
||||||
try:
|
try:
|
||||||
print("sending string %s " % string)
|
print("WJSendPlugin>> sending string %s " % string)
|
||||||
output = b'\2' + string.encode('ascii') + b'\3'
|
output = b'\2' + string.encode('ascii') + b'\3'
|
||||||
self.ser.write(output) #.encode())
|
self.ser.write(output) #.encode())
|
||||||
#print("sent string '%s'" % output) #.encode('ascii'))
|
#print("sent string '%s'" % output) #.encode('ascii'))
|
||||||
#if 'S' in string:
|
#if 'S' in string:
|
||||||
# self.get_device_status()
|
# self.get_device_status()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("%s: send_serial_string failed for '%s'" % (e,string)) #.encode()
|
print("\t%s: send_serial_string failed for '%s'" % (e,string)) #.encode()
|
||||||
|
|
||||||
queue = {}
|
queue = {}
|
||||||
def refresh(self):
|
def refresh(self):
|
||||||
@@ -142,7 +136,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
self.send_buffered(queue, command[0], command[1])
|
self.send_buffered(queue, command[0], command[1])
|
||||||
#self.queue.clear()
|
#self.queue.clear()
|
||||||
except Exception:
|
except Exception:
|
||||||
print ("!!! CAUGHT EXCEPTION running queue !!!")
|
print ("WJSendPlugin>>> !!! CAUGHT EXCEPTION running queue %s!!!" % queue)
|
||||||
import traceback
|
import traceback
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
finally:
|
finally:
|
||||||
@@ -157,20 +151,12 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
|
|
||||||
last = {}
|
last = {}
|
||||||
def send_buffered(self, queue, form, args, record = True):
|
def send_buffered(self, queue, form, args, record = True):
|
||||||
"""# TODO: remove this crap when i'm sure the bug has been fixed
|
|
||||||
if output is not None and (type(output) is dict or 'WJSendPlugin' in output):
|
|
||||||
print ("\n\n\ncaught fucker?")
|
|
||||||
import traceback
|
|
||||||
traceback.print_stack()
|
|
||||||
quit()"""
|
|
||||||
|
|
||||||
if self.last.get(queue)!=(form,args):
|
if self.last.get(queue)!=(form,args):
|
||||||
print("send_buffered attempting to parse queue\t%s with form\t'%s' and args\t%s" % (queue, form, args))
|
#print("WJSendPlugin>> send_buffered attempting to parse queue\t%s with form\t'%s' and args\t%s" % (queue, form, args))
|
||||||
output = form.format(*args)
|
output = form.format(*args)
|
||||||
self.send_serial_string(output)
|
self.send_serial_string(output)
|
||||||
self.last[queue] = (form,args) #output
|
self.last[queue] = (form,args) #output
|
||||||
if record:
|
if record:
|
||||||
print("### send_buffered is setting last_record[%s] to %s" % (queue,output))
|
|
||||||
self.last_record[queue] = (form,args)#output
|
self.last_record[queue] = (form,args)#output
|
||||||
|
|
||||||
def send_append(self, command, value):
|
def send_append(self, command, value):
|
||||||
@@ -210,9 +196,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='y':
|
elif dim=='y':
|
||||||
self.colour_y = int(255*value)
|
self.colour_y = int(255*value)
|
||||||
|
|
||||||
#output = "VCC:{}{:02X}{:02X}".format(chan, self.colour_x, self.colour_y)
|
self.send('VCC', "VCC:{}{:02X}{:02X}", [chan, self.colour_x, self.colour_y])
|
||||||
# could store format string + values, then interpolate over those values
|
|
||||||
self.send('VCC', "VCC:{}{:02X}{:02X}", [chan, self.colour_x, self.colour_y]) #output)
|
|
||||||
|
|
||||||
# RGB control of matte colour!
|
# RGB control of matte colour!
|
||||||
back_colour_x = 127
|
back_colour_x = 127
|
||||||
@@ -227,7 +211,6 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='z':
|
elif dim=='z':
|
||||||
self.back_colour_z = int(255*value)
|
self.back_colour_z = int(255*value)
|
||||||
|
|
||||||
#output = "VBM:{:02X}{:02X}{:02X}".format(self.back_colour_x,self.back_colour_y,self.back_colour_z)
|
|
||||||
self.send('VBM', "VBM:{:02X}{:02X}{:02X}", [ self.back_colour_x,self.back_colour_y,self.back_colour_z ])
|
self.send('VBM', "VBM:{:02X}{:02X}{:02X}", [ self.back_colour_x,self.back_colour_y,self.back_colour_z ])
|
||||||
|
|
||||||
# this doesnt seem to work on WJ-MX30 at least, or maybe i dont know how to get it into the right mode?
|
# this doesnt seem to work on WJ-MX30 at least, or maybe i dont know how to get it into the right mode?
|
||||||
@@ -244,7 +227,6 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='z':
|
elif dim=='z':
|
||||||
self.back_wash_colour_z = int(255*value)
|
self.back_wash_colour_z = int(255*value)
|
||||||
|
|
||||||
#output = "VBW:{:02X}{:02X}{:02X}".format(self.back_wash_colour_x,self.back_wash_colour_y,self.back_wash_colour_z)
|
|
||||||
self.send('VBW', "VBW:{:02X}{:02X}{:02X}", [ self.back_wash_colour_x,self.back_wash_colour_y,self.back_wash_colour_z ] )
|
self.send('VBW', "VBW:{:02X}{:02X}{:02X}", [ self.back_wash_colour_x,self.back_wash_colour_y,self.back_wash_colour_z ] )
|
||||||
|
|
||||||
# positioner joystick
|
# positioner joystick
|
||||||
@@ -256,11 +238,9 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
elif dim=='x': # yes, x is really y!
|
elif dim=='x': # yes, x is really y!
|
||||||
self.position_y = int(255*value)
|
self.position_y = int(255*value)
|
||||||
|
|
||||||
#output = "VPS:{}{:02X}{:02X}".format(mode,self.position_x,self.position_y)
|
self.send('VPS:{}'.format(mode), "VPS:{}{:02X}{:02X}", [ mode,self.position_x,self.position_y ])
|
||||||
self.send('VPS:{}'.format(mode), "VPS:{}{:02X}{:02X}", [ mode,self.position_x,self.position_y ])#output)
|
|
||||||
|
|
||||||
# wipe / mix level
|
# wipe / mix level
|
||||||
def set_mix(self, value):
|
def set_mix(self, value):
|
||||||
#output = "VMM:{:04X}".format(int(255*255*value))
|
self.send('VMM', "VMM:{:02X}", [ int(255*value) ])
|
||||||
self.send('VMM', "VMM:{:02X}", [ int(255*value) ])#output)
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user