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

Switch bugfixes #641

Merged
merged 2 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
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
23 changes: 0 additions & 23 deletions hardware/switches/switch_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,6 @@ def available_states(self):
"""
return self._switches.copy()

@property
def states(self):
""" The current states the hardware is in as state dictionary with switch names as keys and
state names as values.

@return dict: All the current states of the switches in the form {"switch": "state"}
"""
return self._states.copy()

@states.setter
def states(self, state_dict):
""" The setter for the states of the hardware.

The states of the system can be set by specifying a dict that has the switch names as keys
and the names of the states as values.

@param dict state_dict: state dict of the form {"switch": "state"}
"""
assert isinstance(state_dict, dict), \
f'Property "state" must be dict type. Received: {type(state_dict)}'
for switch, state in state_dict.items():
self.set_state(switch, state)

def get_state(self, switch):
""" Query state of single switch by name

Expand Down
3 changes: 1 addition & 2 deletions interface/switch_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def states(self):
return {switch: self.get_state(switch) for switch in self.available_states}

@states.setter
@interface_method
def states(self, state_dict):
""" The setter for the states of the hardware.

Expand All @@ -110,7 +109,7 @@ def states(self, state_dict):

@param dict state_dict: state dict of the form {"switch": "state"}
"""
assert isinstance(state_dict), 'Parameter "state_dict" must be dict type'
assert isinstance(state_dict, dict), 'Parameter "state_dict" must be dict type'
for switch, state in state_dict.items():
self.set_state(switch, state)

Expand Down
2 changes: 0 additions & 2 deletions logic/switch_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def states(self):
with self._thread_lock:
try:
states = self.switch().states
self._old_states = states
except:
self.log.exception(f'Error during query of all switch states.')
states = dict()
Expand Down Expand Up @@ -139,7 +138,6 @@ def get_state(self, switch):
with self._thread_lock:
try:
state = self.switch().get_state(switch)
self._old_states[switch] = state
except:
self.log.exception(f'Error while trying to query state of switch "{switch}".')
state = None
Expand Down