def _write_hw_rule(self, switch_obj, driver_obj, use_hold):
if switch_obj.invert:
raise AssertionError("Cannot handle inverted switches")
self._verify_coil_and_switch_fit(switch_obj, driver_obj)
self.log.debug("Setting HW Rule. Driver: %s, Driver settings: %s",
driver_obj.hw_driver.number, driver_obj.config)
driver_obj.hw_driver.use_switch = True
driver_obj.hw_driver.switches.append(switch_obj.hw_switch.number)
_, _, switch_num = switch_obj.hw_switch.number.split("-")
switch_num = int(switch_num)
self._add_switch_coil_mapping(switch_num, driver_obj.hw_driver)
# Technically not necessary unless the solenoid parameters are
# changing. MPF may not know when initial kick and hold values
# are changed, so this might need to be called each time.
self.reconfigure_driver(driver_obj, use_hold)
def reconfigure_driver(self, driver, use_hold: bool):
"""Reconfigure a driver.
Args:
driver: Driver object.
use_hold: Whether this driver stays enabled after a trigger or not.
"""
# If hold is 0, set the auto clear bit
if not use_hold:
cmd = ord(OppRs232Intf.CFG_SOL_AUTO_CLR)
driver.hw_driver.can_be_pulsed = True
hold = 0
else:
cmd = 0
driver.hw_driver.can_be_pulsed = False
hold = self.get_hold_value(driver)
if not hold:
raise AssertionError("Hold may not be 0")
if hold >= 16:
if self.minVersion >= 0x00020000:
# set flag for full power, hold is not used
cmd += ord(OppRs232Intf.CFG_SOL_ON_OFF)
hold = 0
else:
hold = 15
minimum_off = self.get_minimum_off_time(driver)
# Before version 0.2.0.0 set solenoid input wasn't available.
# CFG_SOL_USE_SWITCH was used to enable/disable a solenoid. This
# will work as long as switches are added using _add_switch_coil_mapping
if (self.minVersion < 0x00020000) and driver.hw_driver.use_switch:
cmd += ord(OppRs232Intf.CFG_SOL_USE_SWITCH)
_, solenoid = driver.config['number'].split('-')
pulse_len = self._get_pulse_ms_value(driver)
msg = bytearray()
msg.append(driver.hw_driver.solCard.addr)
msg.extend(OppRs232Intf.CFG_IND_SOL_CMD)
msg.append(int(solenoid))
msg.append(cmd)
msg.append(pulse_len)
msg.append(hold + (minimum_off << 4))
msg.extend(OppRs232Intf.calc_crc8_whole_msg(msg))
msg.extend(OppRs232Intf.EOM_CMD)
final_cmd = bytes(msg)
self.log.debug("Writing individual config: %s", "".join(" 0x%02x" % b for b in final_cmd))
self.send_to_processor(driver.hw_driver.solCard.chain_serial, final_cmd)
Jan
2017-12-01 13:35:10,317 : autofire.bumper_1 : Enabling2017-12-01 13:35:10,317 : OPP : Setting HW Rule. Driver: COM4-4-8, Driver settings: {'debug': True, 'hold_power': None, 'recycle_factor': None, 'pulse_events': {}, 'console_log': 'full', 'tags': [], 'hold_power16': None, 'pulse_ms': 32, 'platform': None, 'label': '%', 'number': '4-8', 'enable_events': {}, 'file_log': 'full', 'disable_events': {}, 'recycle': True, 'allow_enable': False, 'pulse_power': None}2017-12-01 13:35:10,317 : OPP : Mapping input 16 and coil 82017-12-01 13:35:10,318 : OPP : Writing individual config: 0x24 0x14 0x08 0x02 0x20 0x20 0xa5 0xffOPP : Writing individual config: 0x24 0x14 0x08 0x02 0x20 0x20 0xa5 0xff.I would normally expect that command to be 0x24 0x14 0x08 0x02 0x20 0x00 ?? 0xff. One interesting thing to try would be to remove those pulse_power statements in the yaml for the autofire solenoids.Received Version Response: 0x20 0x02 0x00 0x02 0x00 0x05 0x9d
2017-12-01 13:34:59,723 : OPP : Config driver COM4-4-8, 32, None
2017-12-01 13:34:59,723 : OPP : Writing individual config: 0x24 0x14 0x08 0x02 0x20 0x00 0x45 0xff
2017-12-01 13:34:59,739 : autofire.bumper_1 : Platform Driver: None
and later it says:
2017-12-01 13:35:10,317 : autofire.bumper_1 : Enabling
2017-12-01 13:35:10,317 : OPP : Setting HW Rule. Driver: COM4-4-8, Driver settings: {'debug': True, 'hold_power': None, 'recycle_factor': None,
'pulse_events': {}, 'console_log': 'full', 'tags': [], 'hold_power16': None, 'pulse_ms': 32, 'platform': None, 'label': '%', 'number': '4-8',
'enable_events': {}, 'file_log': 'full', 'disable_events': {}, 'recycle': True, 'allow_enable': False, 'pulse_power': None}
2017-12-01 13:35:10,317 : OPP : Mapping input 16 and coil 8
2017-12-01 13:35:10,318 : OPP : Writing individual config: 0x24 0x14 0x08 0x02 0x20 0x20 0xa5 0xff
Somehow the command gets changed as you mentioned above instead of actually "mapping input 16 and coil 8".The pulse_power statement doesn't change anything and has been added for testing(in the log above it was not included)And do you know what the line:autofire.bumper_1 : Platform Driver: Nonemeans?
Jan
I guess that I don't understand that question.autofire.bumper_1 : Platform Driver: None
Jan