Ejemplo n.º 1
0
        public void switch_update_rule(ushort number, EventType event_type, SwitchRule rule, DriverState[] linked_drivers, bool drive_outputs_now)
        {
            int numDrivers = 0;

            if (linked_drivers != null)
            {
                numDrivers = linked_drivers.Length;
            }

            bool use_column_8 = g_machineType == MachineType.WPC;

            if (firstTime)
            {
                firstTime = false;
                SwitchConfig switchConfig = new SwitchConfig();
                switchConfig.Clear                    = false;
                switchConfig.UseColumn8               = use_column_8;
                switchConfig.UseColumn9               = false; // No WPC machines actually use this
                switchConfig.HostEventsEnable         = true;
                switchConfig.DirectMatrixScanLoopTime = 2;     // Milliseconds
                switchConfig.PulsesBeforeCheckingRX   = 10;
                switchConfig.InactivePulsesAfterBurst = 12;
                switchConfig.PulsesPerBurst           = 6;
                switchConfig.PulseHalfPeriodTime      = 13; // Milliseconds
                lock (procSyncObject)
                {
                    PinProc.PRSwitchUpdateConfig(ProcHandle, ref switchConfig);
                }
            }
            Result r;

            lock (procSyncObject)
            {
                r = PinProc.PRSwitchUpdateRule(ProcHandle, (byte)number, event_type, ref rule, linked_drivers, numDrivers, drive_outputs_now);
            }
            if (r == Result.Success)
            {
                // Possibly we should flush the write data here
            }
            else
            {
                Logger.Log(String.Format("SwitchUpdateRule FAILED for #{0} event_type={1} numDrivers={2} drive_outputs_now={3}",
                                         number, event_type.ToString(), numDrivers, drive_outputs_now));
            }
        }