Compare commits

..

7 Commits

3 changed files with 34 additions and 5 deletions

View File

@@ -32,7 +32,9 @@ data = {
"x": None,
"y": [1,2,3],
"aaa": "aaa",
"c": "cccccc"
"c": "cccccc",
"image_background_enable": "passive",
"function": "spectrometer.py"
},
"ignored": {}
@@ -51,6 +53,8 @@ class PipelineClient:
return server_info
def get_instance_config(self, name):
return data[name]
def set_instance_config(self, name, config):
pass
def get_pipelines(self):
return data.keys()

View File

@@ -42,7 +42,7 @@ class MathEntry(wx.TextCtrl):
def SetValue(self, val):
self.value_type = type(val)
val = str(val)
super().SetValue(val)
super().ChangeValue(val) #TODO
def on_enter(self, event):
@@ -94,7 +94,7 @@ class MathEntry(wx.TextCtrl):
def clear(self):
super().SetValue("")
super().ChangeValue("") #TODO

29
scam.py
View File

@@ -81,6 +81,9 @@ class MainPanel(wx.Panel):
self.instance = None
self.camera = None
self.orig_cfg = None
self.pipeline_cfg = None
self.pls = pls = Pipelines()
pl_names = [GOOD + n for n in pls.active]
@@ -104,6 +107,8 @@ class MainPanel(wx.Panel):
self.entries = entries = SettingsList(self)
self.Bind(wx.EVT_TEXT, self.on_change)
self.btn_print = btn_print = wx.Button(self, label="Print")
self.btn_save = btn_save = wx.Button(self, label="Save")
@@ -156,6 +161,8 @@ class MainPanel(wx.Panel):
cfg = pipeline.get()
print("current config:", cfg)
self.pipeline_cfg = cfg
# use contents of KNOWN_TYPES to pre-fill cfg
#TODO use setdefault instead?
cfg_o = cfg
@@ -221,7 +228,7 @@ class MainPanel(wx.Panel):
def on_screenpanel(self, event):
cam = self.camera
cmd = f"screen_panel -persist -cam={cam}"
cmd = f"screen_panel -persist -cam {cam}"
print(cmd)
subprocess.Popen(cmd.split(), start_new_session=True)
@@ -290,6 +297,24 @@ class MainPanel(wx.Panel):
pipeline = self.pls[self.instance]
res = pipeline.set(new_cfg)
print("result config:", res)
self.on_select(None) # get the server-side config again
self.btn_save.SetBackgroundColour(wx.NullColour)
def on_change(self, event):
old_cfg = self.pipeline_cfg or {}
new_cfg = self.make_cfg()
new = {}
old = {}
for i in sorted(set(old_cfg) & set(new_cfg)):
old[i] = old_cfg.get(i)
new[i] = new_cfg.get(i)
old_cfg = old
new_cfg = new
color = wx.Colour(164, 36, 23) if new_cfg != old_cfg else wx.NullColour
self.btn_save.SetBackgroundColour(color)
@@ -315,7 +340,7 @@ def check_incoming_cfg(cfg):
def check_outgoing_cfg(cfg):
bkg = cfg["image_background"]
bkg = cfg.get("image_background", None)
cfg["image_background_enable"] = "passive" if bkg else None
cfg["image_threshold"] = None