Repository navigation
Feature switch element - #526
Conversation
| def _fill_tool(self, tool: TuningTool | MeasurementTool) -> None: | ||
| self.add_tool(tool.attach(self)) | ||
|
|
||
| def _fill_switch_element(self, element: SwitchElement) -> None: |
There was a problem hiding this comment.
It's a shame that we need to keep adding new "_fill" functions every time we need to define a new element. Maybe we could categorize this as a "tool" and use _fill_tool?
There was a problem hiding this comment.
I don't like it so much because it does not share a type with TuningTool or MeasurementTool, and the functionality is closer to an element. But maybe typing it as TuningTool is ok. But I agree that these fill* methods need to be revised somehow.
There was a problem hiding this comment.
Then maybe it could use _fill_unbound_element if it is left uncategorized?
There was a problem hiding this comment.
I don't like it either... It reduces the number of functions, but the lines of code are roughly the same. In fact, I don't like this unbound element so much.
…olean channel in control system (simulator only).
|
@kparasch Do you mind merging with ugly _fill_switch_element()? |
| return self.enabled.get() | ||
|
|
||
| def _fill_device(self, holder: "ElementHolder") -> None: | ||
| holder._fill_switch_element(self) |
There was a problem hiding this comment.
How about an if statement here that does the _fill_switch_element itself based on the type of the element holder?
There was a problem hiding this comment.
It's what would've needed to be done in _fill_unbound_element. I don't see much difference between another def() and another if(). Same number of lines of code. But it could be done.
kparasch
left a comment
There was a problem hiding this comment.
I wouldn't mind merging now, but I think this is the perfect PR to experiment with trying to do the _fill_device better, as this element is quite simple and contained. If you disagree though, we can merge without any hard feelings.
|
@kparasch We can make an issue about fill*. I need this PR to continue working on IDs. |
This PR should allow to have a simple "switch" element, such as boolean flag of various feedbacks being on or off. This is useful for many measurements to set the feedbacks to OFF before the measurement and ON after the measurement.
Resolves #413. Related to #509, which requires a switch element.