mirror of
https://github.com/cyberboy666/r_e_c_u_r.git
synced 2025-12-12 19:30:11 +01:00
moved handling of data frame diffs etc to AutomationSourcePlugin base class
This commit is contained in:
@@ -247,9 +247,54 @@ class AutomationSourcePlugin(Plugin):
|
|||||||
def recall_frame_data(self, data):
|
def recall_frame_data(self, data):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
# these frame stubs deal with the simplest case of a frame being a dict of values
|
||||||
|
# if its anything more complicated than that (like lists) then that will need to be
|
||||||
|
# handled in the plugin by overriding these methods
|
||||||
def get_frame_diff(self, last_frame, current_frame):
|
def get_frame_diff(self, last_frame, current_frame):
|
||||||
raise NotImplementedError
|
lf = last_frame.get(self.frame_key)
|
||||||
|
cf = current_frame.get(self.frame_key)
|
||||||
|
|
||||||
|
if cf is None or not cf:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
if lf is None or not lf:
|
||||||
|
return cf.copy()
|
||||||
|
|
||||||
|
diff = {}
|
||||||
|
for queue,message in cf.items():
|
||||||
|
if lf.get(queue) is None or lf.get(queue)!=message:
|
||||||
|
diff[queue] = message
|
||||||
|
|
||||||
|
#print (">>>>>> returning diff\n%s\n<<<<<" % diff)
|
||||||
|
return diff
|
||||||
|
|
||||||
|
def merge_data(self, data1, data2):
|
||||||
|
#print (">>>merge_data passed\n\t%s\nand\n\t%s" % (data1,data2))
|
||||||
|
output = {}
|
||||||
|
if data1 is None:
|
||||||
|
output = data2.copy()
|
||||||
|
else:
|
||||||
|
output = data1.copy()
|
||||||
|
output.update(data2)
|
||||||
|
#print("merge_data returning\n\t%s" % output)
|
||||||
|
#print("<<<<<<")
|
||||||
|
return output
|
||||||
|
|
||||||
|
def get_ignored_data(self, data, ignored):
|
||||||
|
#frame = self.f
|
||||||
|
f = data.copy() #frame.get(self.frame_key,{})
|
||||||
|
for queue,item in f.items(): #frame.get(self.frame_key,{}).items():
|
||||||
|
if ignored.get(queue) is not None:
|
||||||
|
#print ("\tfound that should ignore %s (%s) ?" % (queue, item))
|
||||||
|
f[queue] = None
|
||||||
|
return f
|
||||||
|
|
||||||
|
def is_frame_data_empty(self, data):
|
||||||
|
if len(data)>0:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
### end plugin base classes
|
||||||
|
|
||||||
# adapted from https://github.com/gdiepen/python_plugin_example
|
# adapted from https://github.com/gdiepen/python_plugin_example
|
||||||
class PluginCollection(object):
|
class PluginCollection(object):
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
#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
|
||||||
last_record = {}
|
last_record = {}
|
||||||
def get_frame_data(self):
|
def get_frame_data(self):
|
||||||
diff = self.last_record.copy()
|
diff = self.last_record.copy()
|
||||||
@@ -53,50 +54,6 @@ class WJSendPlugin(ActionsPlugin, SequencePlugin, DisplayPlugin, ModulationRecei
|
|||||||
"""def clear_recorded_frame(self):
|
"""def clear_recorded_frame(self):
|
||||||
self.last_record = {}"""
|
self.last_record = {}"""
|
||||||
|
|
||||||
def get_frame_diff(self, last_frame, current_frame):
|
|
||||||
lf = last_frame.get(self.frame_key)
|
|
||||||
cf = current_frame.get(self.frame_key)
|
|
||||||
|
|
||||||
if cf is None or not cf:
|
|
||||||
return {}
|
|
||||||
|
|
||||||
if lf is None or not lf:
|
|
||||||
return cf.copy()
|
|
||||||
|
|
||||||
diff = {}
|
|
||||||
for queue,message in cf.items():
|
|
||||||
if lf.get(queue) is None or lf.get(queue)!=message:
|
|
||||||
diff[queue] = message
|
|
||||||
|
|
||||||
#print (">>>>>> returning diff\n%s\n<<<<<" % diff)
|
|
||||||
return diff
|
|
||||||
|
|
||||||
def merge_data(self, data1, data2):
|
|
||||||
#print (">>>merge_data passed\n\t%s\nand\n\t%s" % (data1,data2))
|
|
||||||
output = {}
|
|
||||||
if data1 is None:
|
|
||||||
output = data2.copy()
|
|
||||||
else:
|
|
||||||
output = data1.copy()
|
|
||||||
output.update(data2)
|
|
||||||
#print("merge_data returning\n\t%s" % output)
|
|
||||||
#print("<<<<<<")
|
|
||||||
return output
|
|
||||||
|
|
||||||
def get_ignored_data(self, data, ignored):
|
|
||||||
#frame = self.f
|
|
||||||
f = data.copy() #frame.get(self.frame_key,{})
|
|
||||||
for queue,item in f.items(): #frame.get(self.frame_key,{}).items():
|
|
||||||
if ignored.get(queue) is not None:
|
|
||||||
#print ("\tfound that should ignore %s (%s) ?" % (queue, item))
|
|
||||||
f[queue] = None
|
|
||||||
return f
|
|
||||||
|
|
||||||
def is_frame_data_empty(self, data):
|
|
||||||
if len(data)>0:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def recall_frame_data(self, data):
|
def recall_frame_data(self, data):
|
||||||
if data is None:
|
if data is None:
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user