Skip to content
Permalink
Browse files

fix polarity issues with WPC in P-Roc

  • Loading branch information...
jabdoa2 committed Aug 30, 2019
1 parent a5689cb commit 2aafe828656d09921e959f4c2f0208ac70f6a23e
@@ -218,7 +218,7 @@ def configure_driver(self, config: DriverConfig, number: str, platform_settings:
raise AssertionError("Cannot use PD-16 with ID 0 or 1 when DIP 1 is on the P3-Roc. Turn DIP 1 off or "
"renumber PD-16s. Driver: {}".format(number))

proc_driver_object = PROCDriver(proc_num, config, self, number)
proc_driver_object = PROCDriver(proc_num, config, self, number, True)

return proc_driver_object

@@ -110,10 +110,12 @@ def configure_driver(self, config: DriverConfig, number: str, platform_settings:
proc_num = self.pdbconfig.get_proc_coil_number(str(number))
if proc_num == -1:
raise AssertionError("Driver {} cannot be controlled by the P-ROC. ".format(str(number)))
polarity = True
else:
proc_num = self.pinproc.decode(self.machine_type, str(number))
polarity = self.machine_type in (self.pinproc.MachineTypeSternWhitestar, self.pinproc.MachineTypeSternSAM)

return PROCDriver(proc_num, config, self, number)
return PROCDriver(proc_num, config, self, number, polarity)

def configure_switch(self, number: str, config: SwitchConfig, platform_config: dict):
"""Configure a P-ROC switch.
@@ -55,17 +55,19 @@ class PROCDriver(DriverPlatformInterface):
"""

__slots__ = ["log", "proc", "string_number", "pdbconfig", "__dict__"]
__slots__ = ["log", "proc", "string_number", "pdbconfig", "polarity", "__dict__"]

def __init__(self, number, config, platform, string_number):
def __init__(self, number, config, platform, string_number, polarity):
"""Initialise driver."""
self.log = logging.getLogger('PROCDriver')
super().__init__(config, number)
self.platform = platform
self.polarity = polarity
self.string_number = string_number
self.pdbconfig = getattr(platform, "pdbconfig", None)

self.log.debug("Driver Settings for %s", self.number)
self.platform.run_proc_cmd_no_wait("driver_update_state", self.state())

def get_board_name(self):
"""Return board of the driver."""
@@ -120,7 +122,7 @@ def state(self):
return {
'driverNum': self.number,
'outputDriveTime': 0,
'polarity': True,
'polarity': self.polarity,
'state': False,
'waitForFirstTimeSlot': False,
'timeslots': 0,
@@ -11,6 +11,8 @@ switches:
number: sd1
s_test_matrix:
number: s26
s_slingshot_test:
number: s20

coils:
c_test_direct:
@@ -22,11 +24,17 @@ coils:
test_gi:
number: g01
default_pulse_ms: 0

c_slingshot_test:
number: c02
lights:
test_light:
number: l11
subtype: matrix
test_gi:
platform: drivers
number: test_gi
number: test_gi

autofire_coils:
ac_slingshot_test:
coil: c_slingshot_test
switch: s_slingshot_test
@@ -72,6 +72,8 @@ def decode(self, machine_type, device_str):
return 0
elif device_str == "s26":
return 53
elif device_str == "s20":
return 47
elif device_str == "l11":
return 80
elif device_str == "g01":
@@ -232,6 +234,13 @@ def test_platform(self):
self.assertEqual(info_str, self.machine.default_platform.get_info_string())

def _test_pulse_and_hold(self):
# make sure polarity is right
number = self.machine.coils["c_test"].hw_driver.number
self.pinproc.driver_update_state.assert_has_calls([
call({'driverNum': number, 'outputDriveTime': 0, 'polarity': True, 'state': False, 'waitForFirstTimeSlot': False, 'timeslots': 0, 'patterOnTime': 0, 'patterOffTime': 0, 'patterEnable': False, 'futureEnable': False})],
False
)

self.assertEqual("PD-16 Board 1 Bank 1", self.machine.coils["c_test"].hw_driver.get_board_name())
# pulse coil A1-B1-2
self.machine.coils["c_test"].pulse()
@@ -502,7 +511,29 @@ def _test_pdb_gi_light(self):
@test_config("wpc.yaml")
def test_load_wpc(self):
# make sure p-roc properly initialises with WPC config
pass

# make sure polarity is right
number = self.machine.coils["c_test_direct"].hw_driver.number
self.pinproc.driver_update_state.assert_has_calls([
call({'driverNum': number, 'outputDriveTime': 0, 'polarity': False, 'state': False, 'waitForFirstTimeSlot': False, 'timeslots': 0, 'patterOnTime': 0, 'patterOffTime': 0, 'patterEnable': False, 'futureEnable': False})],
False
)

# test polarity in rule
self.pinproc.switch_update_rule = MagicMock()
self.machine.autofires["ac_slingshot_test"].enable()
self.wait_for_platform()
coil_number = self.machine.coils["c_slingshot_test"].hw_driver.number
self.pinproc.switch_update_rule.assert_has_calls([
call(47, 'open_nondebounced', {'notifyHost': False, 'reloadActive': True}, [], False),
call(47, 'closed_nondebounced', {'notifyHost': False, 'reloadActive': True},
[{'futureEnable': False, 'patterOffTime': 0, 'polarity': False, 'waitForFirstTimeSlot': False,
'timeslots': 0, 'patterOnTime': 0, 'outputDriveTime': 10, 'patterEnable': False, 'state': 1,
'driverNum': coil_number}], False),
call(47, 'open_debounced', {'notifyHost': True, 'reloadActive': True}, [], False),
call(47, 'closed_debounced', {'notifyHost': True, 'reloadActive': True}, [], False),
], any_order=True)
self.machine.autofires["ac_slingshot_test"].disable()

@test_config("snux.yaml")
def test_load_snux(self):

0 comments on commit 2aafe82

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