P3-SDK 0.9
P3 Software Development Kit
Loading...
Searching...
No Matches
Multimorphic.P3.P3Controller Class Reference

Subclass of NetProcMachine's MachineController, enhanced with P3-related functionality. More...

Inheritance diagram for Multimorphic.P3.P3Controller:
Multimorphic.NetProcMachine.Machine.MachineController

Public Member Functions

 P3Controller (NetProc.Tools.ILogger logger, bool fakePROC)
 Initializes a new instance of the Multimorphic.P3.P3Controller class.
void SetDefaultSimSwitchStates (Dictionary< string, bool > defaultSwitchStates)
override bool LoadConfig (string PathToFile)
 Create a new machine configuration representation in memory from a file on disk.
override bool LoadConfigs (List< string > FilePaths)
bool LoadP3ConfigPlusConfigs (List< string > FilePaths)
override void Reset ()
 Reset the machine controller.
Re-add wallScoopMode and playfield modes.
void Init ()
override void end_run_loop ()
 Set the exit condition for the run loop causing P3Controller to terminate.
override void enable_flippers (bool enable)
 Enable flippers with default pulse lengths.
override void enable_flippers (bool enable, int pulse_width)
 Enable flippers with the specified pulse length.
override void enable_bumpers (bool enabled)
 Enable bumpers (all items in the PRBumpers section of the machine config file)
void ClearGrid ()
 Force clear of balltracking grid lines.
P3HardwareInfo GetP3HardwareInfo ()
void initMachineController (NetProc.MachineType machineType, NetProc.Tools.ILogger logger, bool Simulated)
void parseSwitchConfig (MachineConfiguration config)
 Parse only the switch config. Use this if switch states can affect what configuration should be loaded later.
void parseConfig (MachineConfiguration config)
 Parse full config (including switches)
void parseConfig (MachineConfiguration config, bool parseSwitches)
 Either parse the full config including Switches or everything except switches Don't include switches if they were already configured.
void ParseEverythingExceptSwitches (MachineConfiguration config)
void ConfigureSwitches (List< SwitchConfigFileEntry > switchConfigEntries, List< BurstSwitchConfigFileEntry > burstSwitchConfigEntries)
void ConfigureCoils (List< CoilConfigFileEntry > coilConfigEntries)
void ConfigureLEDs (List< LEDConfigFileEntry > ledConfigEntries)
void ConfigureLEDStrings (List< LEDStringConfigFileEntry > ledStringConfigEntries)
void ConfigureServos (List< ServoConfigFileEntry > servoConfigEntries)
void ConfigureSteppers (List< StepperConfigFileEntry > stepperConfigEntries)
void ConfigureBallPaths (List< BallPathDefinition > ballPathConfigEntries)
void ConfigureLamps (List< LampConfigFileEntry > lampConfigEntries)
void ConfigureGI (List< GIConfigFileEntry > giConfigEntries)
void link_flipper_switch (string switch_name, string[] linked_coils)
virtual void process_accelerometer_event (NetProc.Event evt)
void update_lamps ()
virtual void burst_event (NetProc.Event evt)
virtual Event[] get_events ()
 Retrieve all events from the PROC interface board.
void tick_virtual_drivers ()
 Propagate Tick events to all lamps and coils.
virtual void tick ()
virtual void dmd_event ()
 Called by the MachineController when a DMD event has been received.
void run_loop ()
 Main run loop of the program. Performs the following logic until the loop ends:
void process_events (Event[] events)
void AddUserSwitchEvent (string swName, EventType evtType, UInt32 time)
void AddUserSwitchEvent (Event evt)
void SetSwitchState (string swName, bool swActive)
void AddMode (Mode mode)
void RemoveMode (Mode mode)
bool IsModeInQueue (Mode mode)
void RecordSwitchesStart (string fileName)
void RecordSwitchesStop ()
bool IsRecordingSwitches ()
void PlaybackSwitchesStart (string filename, float playbackRate)
void PlaybackSwitchesStart (string filename)
List< DriverGetCoilsWithTag (string tag)
List< DriverGetCoilsWithoutTag (string tag)
List< LEDGetLEDsWithTag (string tag)
List< LEDGetLEDsWithoutTag (string tag)
List< SwitchGetSwitchesWithTag (string tag)
List< SwitchGetSwitchesWithoutTag (string tag)
List< FlipperEntryGetFlippers ()
List< BumperEntryGetBumpers ()
void LogModeClass (string modeClass, bool debug)

Public Attributes

BallTracker ballTracker
 Ball Tracking Logic.
Underkeeper underkeeper
 Under-playfield ball management (trough, drain, etc)
WallsScoops wallScoopMode
 Wall/Scoop assembly control.
PowerRelay powerRelay
 Power control for enabling / disabling high voltage.
Accelerometer accelerometer
 Accelerometer logic for sensing machine level, nudging, and tilting.
Playfield playfield
 object that queries upper playfield module IDs
SafeEventManager GUIToModesEventManager
 Event queue for events from GUI to Game.
SafeEventManager ModesToGUIEventManager
 Event queue for events from Game to GUI.
SafeEventManager BallTrackingToGUIEventManager
 Event queue for events from BallTracker to GUI.
LEDControllerMode LEDController
bool active = false
 Game in progress status.
byte[] testFrame
PDBConfig pdb_config

Protected Member Functions

override void run_loop_iteration ()
override void process_event (Event evt)
 Process the retrieved event from the PROC interface board (switch/dmd events)
void recordSwitchSnapshot ()
void RecordSwitchEvent (Event evt)
void ParsePlaybackFile ()
List< Event > GetPlaybackEvents ()
double GetPlaybackTime ()

Protected Attributes

NetProc.MachineType _machineType
 Machine type used to configure the proc device.
ProcController _proc
 The _proc controller which manages that hardware interface.
ModeQueue _modes
 TODO: Implement mode queue logic.
AttrCollection< ushort, string, Driver_coils
 TODO: implement coil driver object list.
AttrCollection< ushort, string, Driver_lamps
 TODO: implement lamp driver object list.
AttrCollection< ushort, string, LED_leds
 TODO: implement LED driver object list.
AttrCollection< ushort, string, LED_specialLEDFeatures
AttrCollection< ushort, string, Servo_servos
AttrCollection< ushort, string, Stepper_steppers
AttrCollection< ushort, string, BallPathDefinition_ballPaths
AttrCollection< ushort, string, Driver_gi
 List of GI drivers.
AttrCollection< ushort, string, Switch_switches
 TODO: implement switch object lists.
MachineConfiguration _config
 The configuration object loaded by load_config() TODO: implement config handling.
double _bootTime = 0
 The date/time when the framework was started (machine powered up)
object _machine_data
 Contains information specific to the particular location installation (high scores, audits, etc).
bool _flippers_enabled = false
 Are the flippers and bumpers currently enabled?
bool _done = false
 Run loop exit condition. This continues until true.
object _user_event_lock_object = new object()
 Thread synchronization object for coils.
List< SafeCoilDrive_safe_coil_drive_queue = new List<SafeCoilDrive>()
 List of coils to drive that is manipulated from outside/UI threads TODO: This is set to be removed in favor of the UI process communication model.
List< LEDConfigFileEntry_named_serial_LEDs = new List<LEDConfigFileEntry>()
 Create a list to hold LED configs that map to subsets of serial Strings. For instance, there might be a serial string with serial leds 0-31. Each LED would get mapped to an individual LED. The named_serial_LEDs would be to create a name for a subset of those, such as a building window that might use serial leds 5-11, or some such. The named serial LEDs shouldn't result in new LEDs being added.
StreamWriter switchRecordFile
StreamReader switchPlaybackFile
bool switchRecordingActive = false
bool playbackEventsActive = false
float playbackEventsRate = 1f
Dictionary< double, Event > playbackEvents
List< double > playbackTimestamps

Properties

bool simulated [get]
LampController LampController [get, set]
MachineConfiguration Config [get]
 Current machine configuration representation.
NetProc.ProcController PROC [get]
 PROC device driver wrapper.
AttrCollection< ushort, string, DriverCoils [get, set]
 All coils/solenoids.
AttrCollection< ushort, string, LEDLEDs [get, set]
AttrCollection< ushort, string, LEDSpecialLEDFeatures [get, set]
AttrCollection< ushort, string, ServoServos [get, set]
AttrCollection< ushort, string, StepperSteppers [get, set]
AttrCollection< ushort, string, BallPathDefinitionBallPaths [get, set]
AttrCollection< ushort, string, DriverLamps [get, set]
 All lamps.
AttrCollection< ushort, string, DriverGI [get, set]
 All GI drivers.
AttrCollection< ushort, string, SwitchSwitches [get, set]
 All switches and optos.

Detailed Description

Subclass of NetProcMachine's MachineController, enhanced with P3-related functionality.

Constructor & Destructor Documentation

◆ P3Controller()

Multimorphic.P3.P3Controller.P3Controller ( NetProc.Tools.ILogger logger,
bool fakePROC )

Initializes a new instance of the Multimorphic.P3.P3Controller class.

Parameters
loggerLogger
fakePROCIf set to true P3-ROC functionality is simulated
forcePFExistsIf set to true an upper p/f is assumed to exist

Member Function Documentation

◆ enable_bumpers()

override void Multimorphic.P3.P3Controller.enable_bumpers ( bool enabled)
virtual

Enable bumpers (all items in the PRBumpers section of the machine config file)

Parameters
enabledIf set to true enable bumpers. Otherwise, disable them.

Reimplemented from Multimorphic.NetProcMachine.Machine.MachineController.

◆ enable_flippers() [1/2]

override void Multimorphic.P3.P3Controller.enable_flippers ( bool enable)
virtual

Enable flippers with default pulse lengths.

Parameters
enableIf set to true enable flippers. Otherwise, disable flippers.

Reimplemented from Multimorphic.NetProcMachine.Machine.MachineController.

◆ enable_flippers() [2/2]

override void Multimorphic.P3.P3Controller.enable_flippers ( bool enable,
int pulse_width )
virtual

Enable flippers with the specified pulse length.

Parameters
enableIf set to true enable flippers. Otherwise, disable flippers.
pulse_widthFlipper pulse length.

Reimplemented from Multimorphic.NetProcMachine.Machine.MachineController.

◆ end_run_loop()

override void Multimorphic.P3.P3Controller.end_run_loop ( )
virtual

Set the exit condition for the run loop causing P3Controller to terminate.

Reimplemented from Multimorphic.NetProcMachine.Machine.MachineController.

◆ get_events()

virtual Event[] Multimorphic.NetProcMachine.Machine.MachineController.get_events ( )
virtualinherited

Retrieve all events from the PROC interface board.

Returns
A list of events from the PROC

◆ LoadConfig()

override bool Multimorphic.P3.P3Controller.LoadConfig ( string PathToFile)
virtual

Create a new machine configuration representation in memory from a file on disk.

Parameters
PathToFileThe path to the configuration XML file

Reimplemented from Multimorphic.NetProcMachine.Machine.MachineController.

◆ LoadConfigs()

override bool Multimorphic.P3.P3Controller.LoadConfigs ( List< string > FilePaths)
virtual

◆ parseConfig() [1/2]

void Multimorphic.NetProcMachine.Machine.MachineController.parseConfig ( MachineConfiguration config)
inherited

Parse full config (including switches)

Parameters
config

◆ parseConfig() [2/2]

void Multimorphic.NetProcMachine.Machine.MachineController.parseConfig ( MachineConfiguration config,
bool parseSwitches )
inherited

Either parse the full config including Switches or everything except switches Don't include switches if they were already configured.

Parameters
config
parseSwitchConfigFirst

◆ parseSwitchConfig()

void Multimorphic.NetProcMachine.Machine.MachineController.parseSwitchConfig ( MachineConfiguration config)
inherited

Parse only the switch config. Use this if switch states can affect what configuration should be loaded later.

Parameters
config

◆ process_event()

override void Multimorphic.P3.P3Controller.process_event ( Event evt)
protectedvirtual

Process the retrieved event from the PROC interface board (switch/dmd events)

Parameters
evtThe event to process

Reimplemented from Multimorphic.NetProcMachine.Machine.MachineController.

◆ Reset()

override void Multimorphic.P3.P3Controller.Reset ( )
virtual

Reset the machine controller.
Re-add wallScoopMode and playfield modes.

Reimplemented from Multimorphic.NetProcMachine.Machine.MachineController.

◆ run_loop()

void Multimorphic.NetProcMachine.Machine.MachineController.run_loop ( )
inherited

Main run loop of the program. Performs the following logic until the loop ends:

  • Get events from PROC
  • Process this list of events across all modes
  • 'Tick' modes
  • Tickle watchdog

◆ run_loop_iteration()

override void Multimorphic.P3.P3Controller.run_loop_iteration ( )
protectedvirtual