Files
Jeff Luke 41ef12f954 Add Pac-Man power-on flow and document Odin integration
- Add a four-second arcade-style boot sequence followed by the
  Character / Nickname introduction.
- Separate cabinet power-on from RFID credit and player Start.
- Add operator Power on control and cabinet power-state reporting.
- Prevent repeated power commands from restarting boot or gameplay.
- Ignore RFID scans received before the cabinet is ready.
- Add power-state, RFID, controller, and GPIO feedback regression tests.

- Expand the master walkthrough with export, packaging, file transfer,
  fresh-Pi setup, RFID compilation, and end-to-end testing instructions.
- Correct tester hardware documentation: BCM23/J20 drives an LED;
  physical buttons connect through a separate I2C1 input board.
- Document operator-triggered power-on as the current test workflow
  and retain the temporary 2.4 configuration compatibility notes.
- Record successful physical testing of power-on, RFID credit,
  and player Start.

- Add an Odin integration README describing the proposed Rust/NATS
  bridge, shared messages, Flutter GM interface, autopilot sequencing,
  hardware ownership, and Starfish SSH-management role.
- Define migration milestones and information needed from the
  framework owner; link the integration guide from the root README.

Validation: 69 controller tests, 10 GPIO tests, Pac-Man power/RFID
checks, managed-cabinet lifecycle checks, and visual screen inspection.
2026-10-17 18:47:26 -07:00

95 lines
5.9 KiB
Python

import unittest
import test_fleet
class ObjectiveTests(unittest.TestCase):
setUp = test_fleet.FleetTests.setUp
tearDown = test_fleet.FleetTests.tearDown
def poll(self, cabinet, reports=None, features=True):
return self.fleet.poll(dict(cabinet=cabinet,protocol=2,boot=cabinet,reports=reports or [],features=['assignment_config_v1'] if features else []))
def test_config_reaches_prepare_and_manual_clears_it(self):
self.fleet.operator('prepare_scenario',{'scenario':'three_cabinet_objective_test'})
command=self.poll('cabinet_01')['commands'][0]
self.assertEqual(command['game_config']['test_auto_win_seconds'],5)
self.poll('cabinet_01',[dict(kind='ack',id=command['id'],session=command['session'],ok=True)])
self.fleet.operator('reset',{'cabinet':'cabinet_01'})
command=self.poll('cabinet_01')['commands'][0]
self.poll('cabinet_01',[dict(kind='ack',id=command['id'],session=command['session'],ok=True)])
self.fleet.operator('prepare',{'cabinet':'cabinet_01','game':'pacman'})
self.assertEqual(self.poll('cabinet_01')['commands'][0]['game_config'],{})
def test_old_export_rejected_before_dispatch(self):
self.poll('cabinet_03', features=False)
with self.assertRaisesRegex(ValueError,'Update the game export on cabinet_03'):
self.fleet.operator('prepare_scenario',{'scenario':'three_cabinet_objective_test'})
self.assertFalse(self.poll('cabinet_01')['commands'])
def test_invalid_objective_rejected(self):
assignment=self.catalog['scenarios']['three_cabinet_objective_test']['assignments'][2]
for config in [{'homes_to_win':6},{'homes_to_win':True},{'homes_to_win':.5},{'unknown':1},{'test_auto_win_seconds':float('nan')}]:
assignment['game_config']=config
with self.assertRaises(ValueError):
self.fleet.operator('prepare_scenario',{'scenario':'three_cabinet_objective_test'})
self.assertFalse(self.poll('cabinet_01')['commands'])
def test_never_connected_cabinet_reports_offline_not_old_export(self):
room=self.fleet.rooms['cabinet_03']
room.last_seen=0
room.features=[]
with self.assertRaisesRegex(ValueError,'cabinet_03 is offline'):
self.fleet.operator('prepare_scenario',{'scenario':'three_cabinet_objective_test'})
self.assertFalse(self.poll('cabinet_01')['commands'])
def test_rfid_credit_validation_and_start_gate(self):
room=self.fleet.rooms['cabinet_01']
room.features=['assignment_config_v1','rfid_credit_v1']
room.gpio='real'
self.catalog['cabinets']['cabinet_01']['devices']=[dict(id='reader',kind='rfid')]
item=dict(cabinet='cabinet_01',game='pacman',game_config=dict(rfid_credit_device='reader',rfid_allowed_uids=[]))
self.fleet.validate_assignment(item)
for changes in [dict(rfid_credit_device='missing'),dict(rfid_allowed_uids=['bad']),dict(rfid_allowed_uids=True)]:
invalid=dict(item,game_config=dict(item['game_config'],**changes))
with self.assertRaises(ValueError): self.fleet.validate_assignment(invalid)
room.features=['assignment_config_v1']
with self.assertRaisesRegex(ValueError,'2.3'): self.fleet.validate_assignment(item)
room.features.append('rfid_credit_v1')
room.gpio='simulation'
with self.assertRaisesRegex(ValueError,'real GPIO'): self.fleet.validate_assignment(item)
room.state.update(phase='ready',game_config=item['game_config'],commands=[])
with self.assertRaisesRegex(ValueError,'press Start'): self.fleet.operator('start',dict(cabinet='cabinet_01'))
def test_shipped_rfid_scenario_prepares_without_outputs(self):
# Exercise the actual exported scenario as well as the protocol fixture.
self.tearDown()
self.catalog=test_fleet.json.loads((test_fleet.ROOT/'tools/room_controller/catalog.json').read_text(encoding='utf-8'))
self.fleet=test_fleet.server.Fleet(':memory:',self.catalog,lambda:self.now)
self.poll('cabinet_01')
room=self.fleet.rooms['cabinet_01']
room.features=['assignment_config_v1','rfid_credit_v1','pacman_power_v1']
room.gpio='real'
self.fleet.operator('prepare_scenario', {'scenario':'pacman_rfid_credit_test'})
command=room.poll(dict(cabinet='cabinet_01',protocol=2,boot='cabinet_01',features=room.features,gpio='real',reports=[]))['commands'][0]
self.assertEqual(command['game_config']['rfid_credit_device'],'cab1_rfid1')
self.assertEqual(command['type'],'prepare')
room.ack(dict(id=command['id'],ok=True))
self.assertEqual(room.state['phase'],'powered_off')
room.event(dict(id='power',event='power_booting'))
self.assertEqual(room.state['phase'],'booting')
room.event(dict(id='booted',event='power_ready'))
self.assertEqual(room.state['phase'],'ready')
self.assertFalse(any(c['type'] in ('output','reward','start') for c in room.state['commands']))
self.poll('cabinet_01',[dict(kind='event',id='physical-start',session=command['session'],event='started')])
self.assertEqual(room.state['phase'],'playing')
def test_power_validation(self):
room=self.fleet.rooms['cabinet_01']
room.gpio='real'
self.catalog['cabinets']['cabinet_01']['devices']=[dict(id='button',kind='input')]
item=dict(cabinet='cabinet_01',game='pacman',game_config=dict(power_on_device='button'))
with self.assertRaisesRegex(ValueError,'2.4'): self.fleet.validate_assignment(item)
room.features.append('pacman_power_v1')
self.fleet.validate_assignment(item)
for value in ['missing',True,17]:
with self.assertRaises(ValueError): self.fleet.validate_assignment(dict(item,game_config=dict(power_on_device=value)))
with self.assertRaises(ValueError): self.fleet.validate_assignment(dict(item,activate_after_win='cabinet_02'))