Skip to content
Permalink
Browse files

add APC to LISY platform. fix #1345

  • Loading branch information...
jabdoa2 committed May 11, 2019
1 parent b552349 commit 0021aa4c80c3f5c4db02c7ed0e797f0f2419340e
Showing with 10 additions and 10 deletions.
  1. +10 −10 mpf/platforms/lisy/lisy.py
@@ -156,7 +156,7 @@ class LisyHardwarePlatform(SwitchPlatform, LightsPlatform, DriverPlatform,
"""LISY platform."""

__slots__ = ["config", "_writer", "_reader", "_poll_task", "_watchdog_task", "_number_of_lamps",
"_number_of_solenoids", "_number_of_displays", "_inputs", "_system_type",
"_number_of_solenoids", "_number_of_displays", "_inputs", "_coils_start_at_zero",
"_bus_lock"] # type: List[str]

def __init__(self, machine) -> None:
@@ -172,7 +172,7 @@ def __init__(self, machine) -> None:
self._number_of_solenoids = None # type: Optional[int]
self._number_of_displays = None # type: Optional[int]
self._inputs = dict() # type: Dict[str, bool]
self._system_type = None # type: Optional[str]
self._coils_start_at_zero = None # type: Optional[str]
self.features['max_pulse'] = 255

@asyncio.coroutine
@@ -206,12 +206,10 @@ def initialize(self):
self.send_byte(LisyDefines.InfoGetConnectedLisyHardware)
type_str = yield from self.read_string()

if type_str == b'LISY1':
self._system_type = 1
elif type_str == b'LISY35':
self._system_type = 35
if type_str in (b'LISY1', b'LISY35', b'APC'):
self._coils_start_at_zero = False
elif type_str == b'LISY80':
self._system_type = 80
self._coils_start_at_zero = True
else:
raise AssertionError("Invalid LISY hardware version {}".format(type_str))

@@ -261,7 +259,9 @@ def initialize(self):
number = row * 10 + col
self.send_byte(LisyDefines.SwitchesGetStatusOfSwitch, bytes([number]))
state = yield from self.read_byte()
if state > 1:
if state == 2:
self.warning_log("Switch %s does not exist in platform.", number)
elif state > 2:
raise AssertionError("Invalid switch {}. Got response: {}".format(number, state))

self._inputs[str(number)] = state == 1
@@ -361,7 +361,7 @@ def configure_light(self, number: str, subtype: str, platform_settings: dict) ->
del platform_settings, subtype
assert self._number_of_lamps is not None

if self._system_type == 80:
if self._coils_start_at_zero:
if 0 < int(number) >= self._number_of_lamps:
raise AssertionError("LISY only has {} lamps. Cannot configure lamp {} (zero indexed).".
format(self._number_of_lamps, number))
@@ -400,7 +400,7 @@ def configure_driver(self, config: DriverConfig, number: str, platform_settings:
if 1 < int(number) > self._number_of_solenoids and int(number) < 100:
raise AssertionError("LISY only has {} drivers. Cannot configure driver {} (zero indexed).".
format(self._number_of_solenoids, number))
elif self._system_type == 80:
elif self._coils_start_at_zero:
if 100 < int(number) >= self._number_of_lamps + 100:
raise AssertionError("LISY only has {} lamps. Cannot configure lamp driver {} (zero indexed).".
format(self._number_of_lamps, number))

0 comments on commit 0021aa4

Please sign in to comment.
You can’t perform that action at this time.