Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions deapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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.
Expand Down Expand Up @@ -1002,22 +1006,25 @@ 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
)

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)

if prop_hw_bin_y is not False:
hw_bin_y = int(prop_hw_bin_y)
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")

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)

retval &= self.SetProperty("Binning X", bin_x / hw_bin_x)
retval &= self.SetProperty("Binning Y", bin_y / hw_bin_y)
Expand Down
Loading