Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt3piezo app -- set read channels to None #10

Open
gadamc opened this issue Mar 13, 2023 · 4 comments
Open

qt3piezo app -- set read channels to None #10

gadamc opened this issue Mar 13, 2023 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@gadamc
Copy link
Collaborator

gadamc commented Mar 13, 2023

The underlying library supports setting read channels to None, but the GUI application fails to handle this scenario.
As a user, I want to be able to control the actuator even if I don't have analog read channels from the actuator controller connected to NIDAQ analog inputs.

Should be an easy fix.

@gadamc gadamc added bug Something isn't working good first issue Good for newcomers labels Mar 13, 2023
@gadamc
Copy link
Collaborator Author

gadamc commented Mar 13, 2023

suggested change to tkcontrollerapp.py

def build_controller():
    if args.test:
        controller = nipiezojenapy.BaseControl()
    else:
        if args.piezo_read_channels != 'None':
            read_channels = args.piezo_read_channels.split(',')
        else:
            read_channels = None
        controller = nipiezojenapy.PiezoControl(device_name = args.daq_name,
                                  write_channels = args.piezo_write_channels.split(','),
                                  read_channels = read_channels,
                                  move_settle_time = args.settle_time)
    return controller

@gadamc
Copy link
Collaborator Author

gadamc commented Mar 13, 2023

Or better yet, could run a check for valid values! If values do not appear to be allowed (can one call nidaqmx to ask the device???), then raise exception or do something else smart.

@gadamc
Copy link
Collaborator Author

gadamc commented Mar 14, 2023

def build_controller():
    if args.test:
        controller = nipiezojenapy.BaseControl()
    else:
        if args.piezo_read_channels == 'None':
            read_channels = None
        else:
            read_channels = args.piezo_read_channels.split(',')
            if len(read_channels) != 3:
                raise ValueError(f'{args.piezo_read_channels} should be a comma-separated list of three analog channel names') 
        controller = nipiezojenapy.PiezoControl(device_name = args.daq_name,
                                  write_channels = args.piezo_write_channels.split(','),
                                  read_channels = read_channels,
                                  move_settle_time = args.settle_time)
    return controller

@gadamc
Copy link
Collaborator Author

gadamc commented Mar 16, 2023

Maybe this is better

def build_controller():
    if args.test:
        controller = nipiezojenapy.BaseControl()
    else:
       
         if args.piezo_read_channels == 'None':
            read_channels = None
        else:
            read_channels = args.piezo_read_channels.split(',')
          
        controller = nipiezojenapy.PiezoControl(device_name = args.daq_name,
                                  write_channels = args.piezo_write_channels.split(','),
                                  read_channels = read_channels,
                                  move_settle_time = args.settle_time)
    return controller

then put the checks for name values inside the PiezoControl class.

class PiezoControl(BaseControl):

    def __init__(self, device_name: str,
                       write_channels: List[str] = ['ao0','ao1','ao2'],
                       read_channels: Optional[List[str]] = None,
                       scale_microns_per_volt: float = 8,
                       move_settle_time: float = 0.001,
                       min_position: float = 0.0,
                       max_position: float = 80.0) -> None:
        super().__init__()

        self.device_name = device_name

         if len(write_channels) != 3:
                raise ValueError(f'{write_channels} should be a list of three analog output channel names')
        self.write_channels = write_channels

        if len(read_channels) != 3:
                raise ValueError(f'{read_channels} should be a list of three analog input channel names')
        self.read_channels = read_channels

        self.scale_microns_per_volt = scale_microns_per_volt
        self.minimum_allowed_position = min_position
        self.maximum_allowed_position = max_position
        self.settling_time_in_seconds = move_settle_time #10 millisecond settle time
        self.last_write_values = [None, None, None]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant