Skip to content

Install parameters on instance instead of class#510

Open
MarcusZuber wants to merge 1 commit intomasterfrom
parameters-on-instances
Open

Install parameters on instance instead of class#510
MarcusZuber wants to merge 1 commit intomasterfrom
parameters-on-instances

Conversation

@MarcusZuber
Copy link
Copy Markdown
Member

This should attach the parameters to the single instances and not to the class.

First tests are working:

from concert.devices.motors.dummy import LinearMotor
from concert.base import Quantity

l = await LinearMotor()
l2 = await LinearMotor()
l2.install_parameters({"pos2": Quantity(q.deg)})

l
<concert.devices.motors.dummy.LinearMotor object at 0x7f10a94d39a0>
 Parameter        Value                        
 motion_velocity  200000.0 millimeter / second 
 position         5 millimeter                 
 state            standby  

l2
<concert.devices.motors.dummy.LinearMotor object at 0x7f10a89d6fb0>
 Parameter        Value                        
 motion_velocity  200000.0 millimeter / second 
 pos2             N/A                          
 position         0 millimeter                 
 state            standby  

The actual use-case of this is, when employing different uca-cameras.
With the class-wide implementation, each of the concert.devices.camera.uca.Camera adds all plugin-parameters to the uca.Camera class.

@MarcusZuber MarcusZuber force-pushed the parameters-on-instances branch from 1f70c2d to 5d6c647 Compare January 23, 2023 16:23
@MarcusZuber MarcusZuber requested a review from tfarago January 23, 2023 16:29
@MarcusZuber
Copy link
Copy Markdown
Member Author

@tfarago : Do you see any general problems here? I will also add a few tests for this later.

@tfarago
Copy link
Copy Markdown
Contributor

tfarago commented Feb 1, 2023

What is the difference between setattr(self, 'foo', foo) and self.__dict__['foo'] = foo? You changed it to this kind and I am curious what the benefits are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants