From 12e46d4fbff26ebe994c1978ed78478fabe871c8 Mon Sep 17 00:00:00 2001 From: EricPei20 Date: Wed, 22 Apr 2026 10:23:20 -0700 Subject: [PATCH 1/2] Fixed invalid property errors in set_binning. --- deapi/client.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/deapi/client.py b/deapi/client.py index 78430d5b..ecdfd5af 100644 --- a/deapi/client.py +++ b/deapi/client.py @@ -231,6 +231,7 @@ def connect(self, host: str = "127.0.0.1", port: int = 13240, read_only=False): self._initialize_attributes() self.update_scan_size() self.update_image_size() + self.update_feature_hw_binning() self.virtual_masks = [] for i in range(4): self.virtual_masks.append(VirtualMask(client=self, index=i)) @@ -249,6 +250,9 @@ def update_image_size(self): self.image_sizex = self["Image Size X (pixels)"] self.image_sizey = self["Image Size Y (pixels)"] + def update_feature_hw_binning(self): + self.feature_hw_binning = self["Feature - Hardware Binning"] + def disconnect(self): """ Disconnects from the server. @@ -1002,12 +1006,13 @@ def set_binning(self, bin_x, bin_y, use_hw=True): if commandVersion >= 13: retval = self.SetProperty("Server Normalize Properties", "Off") - retval &= self.SetProperty( - "Hardware Binning X", 2 if bin_x >= 2 and use_hw else 1 - ) - retval &= self.SetProperty( - "Hardware Binning Y", 2 if bin_y >= 2 and use_hw else 1 - ) + if self.feature_hw_binning == "On": + retval &= self.SetProperty( + "Hardware Binning X", 2 if bin_x >= 2 and use_hw else 1 + ) + retval &= self.SetProperty( + "Hardware Binning Y", 2 if bin_y >= 2 and use_hw else 1 + ) prop_hw_bin_x = self.GetProperty("Hardware Binning X") prop_hw_bin_y = self.GetProperty("Hardware Binning Y") From 7b58bf914ce3becb1d91cef01c5ab0c804cbdbce Mon Sep 17 00:00:00 2001 From: EricPei20 Date: Tue, 28 Apr 2026 10:21:11 -0700 Subject: [PATCH 2/2] Do not get HW Binning in set_binning if camera does not support it. --- deapi/client.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/deapi/client.py b/deapi/client.py index ecdfd5af..fcd9ba35 100644 --- a/deapi/client.py +++ b/deapi/client.py @@ -1006,6 +1006,9 @@ def set_binning(self, bin_x, bin_y, use_hw=True): if commandVersion >= 13: retval = self.SetProperty("Server Normalize Properties", "Off") + hw_bin_x = 1 + hw_bin_y = 1 + if self.feature_hw_binning == "On": retval &= self.SetProperty( "Hardware Binning X", 2 if bin_x >= 2 and use_hw else 1 @@ -1014,15 +1017,14 @@ def set_binning(self, bin_x, bin_y, use_hw=True): "Hardware Binning Y", 2 if bin_y >= 2 and use_hw else 1 ) - prop_hw_bin_x = self.GetProperty("Hardware Binning X") - prop_hw_bin_y = self.GetProperty("Hardware Binning Y") - hw_bin_x = 1 - hw_bin_y = 1 - if prop_hw_bin_x is not False: - hw_bin_x = int(prop_hw_bin_x) + prop_hw_bin_x = self.GetProperty("Hardware Binning X") + prop_hw_bin_y = self.GetProperty("Hardware Binning Y") + + if prop_hw_bin_x is not False: + hw_bin_x = int(prop_hw_bin_x) - if prop_hw_bin_y is not False: - hw_bin_y = int(prop_hw_bin_y) + if prop_hw_bin_y is not False: + hw_bin_y = int(prop_hw_bin_y) retval &= self.SetProperty("Binning X", bin_x / hw_bin_x) retval &= self.SetProperty("Binning Y", bin_y / hw_bin_y)