Skip to content

Accessing complex types via control server #248

@MikeHart85

Description

@MikeHart85

This is from a question asked by Tom Willemsen.

If a device is defined like this:

class MyDevice(StateMachineDevice):
    def initialize_data(self):
        self.channels = {1 : Channel(), 2 : Channel(), 3 : Channel()}
        ...

Where Channel is defined like this:

class Channel(object):
    def __init__(self):
        self.waveform_type = 0
        self.step_time = 0
        ...

Would it be possible to access via control server using this sort of syntax (or similar):

$ lewis-control device channels[1].waveform_type 1

For now I suggested creating set_channel_param(self, index, param, value) and get_channel_param(self, index, param) methods on the MyDevice object. But it would be nicer if we could avoid the need for creating such boilerplate methods.

There are two difficulties with implementing something like this:

  • Syntax / shell interaction ([1] might mean something special in some shells)
  • Trying to json-rpc Channel objects throws a "not serializable" exception

The method workaround works fine, so this issue is mainly to see if we can come up with ideas on how to improve this.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions