コード例 #1
0
 public LampViewModel(PRLamp lamp)
 {
     Name   = lamp.Name;
     Number = lamp.Number;
     Tags   = lamp.Tags;
     Label  = lamp.Label;
 }
コード例 #2
0
        private void SaveMachineConfig()
        {
            var mConfig = MachineConfig;

            Log("Saving Machine configuration");

            Log("Adding Flipper switches");
            mConfig.PRSwitches.Clear();
            mConfig.PRSwitches
            .AddRange(FlippersSwitches.Select(x => new PRSwitch()
            {
                Name         = x.Name,
                Number       = x.Number,
                Tags         = x.Tags,
                SwitchType   = x.Type,
                Label        = x.Label,
                VpSwitchType = x.VpSwitchType
            }));

            var allSwitches = Switches;

            if (mConfig.GetMachineType() == MachineType.PDB)
            {
                UpdateSwitchesBeforeSaved(mConfig);
                UpdateDedicatedBeforeSave(mConfig);
            }
            else
            {
                UpdateDedicatedBeforeSave(mConfig);
                UpdateSwitchesBeforeSaved(mConfig);
            }

            //Save Lamps
            Log("Adding Lamps");
            mConfig.PRLamps?.Clear();

            if (mConfig.PRLamps == null)
            {
                Log("No PRLEDs found in config.", Category.Warn);
            }
            else
            {
                foreach (var item in Lamps)
                {
                    if (item.Name != "NOT USED")
                    {
                        var lamp = new PRLamp()
                        {
                            Name   = item.Name,
                            Number = item.Number,
                            Tags   = item.Tags,
                            Label  = item.Label
                        };

                        MachineConfig.PRLamps.Add(lamp);
                    }
                }
            }

            //Save LEds
            Log("Adding LEDs");
            if (mConfig.PRLeds == null)
            {
                Log("No PRLEDs found in config.", Category.Warn);
            }
            else
            {
                mConfig.PRLeds.Clear();
                foreach (var item in PRLeds)
                {
                    if (item.Name != "NOT USED")
                    {
                        var lamp = new PRLed()
                        {
                            Name   = item.Name,
                            Number = item.Number,
                            Tags   = item.Tags,
                            Label  = item.Label
                        };

                        mConfig.PRLeds.Add(lamp);
                    }
                }
            }

            mConfig.PRCoils.Clear();
            mConfig.PRFlippers.Clear();

            Log("Adding Coils");
            foreach (var coil in Coils)
            {
                var number = coil.Number;
                if (MachineConfig.GetMachineType() == MachineType.PDB)
                {
                    number = coil.Number.Split(':')[1];
                }

                if (coil.Name != "NOT USED")
                {
                    var newcoil = new PRCoil()
                    {
                        Name          = coil.Name,
                        Number        = number,
                        Tags          = coil.Tags,
                        PatterOffTime = coil.PatterOffTime,
                        PatterOnTime  = coil.PatterOnTime,
                        BallSearch    = coil.BallSearch,
                        PulseTime     = coil.PulseTime,
                        SolenoidType  = coil.SolenoidType,
                        Label         = coil.Label
                    };

                    mConfig.PRCoils.Add(newcoil);

                    //Add PRFlippers list from the coil name once
                    if (coil.Name.Contains("Main"))
                    {
                        mConfig.PRFlippers.Add(newcoil.Name.Replace("Main", string.Empty));
                    }
                }
            }

            Log("Attempting Save...");
            _skeletonGameProvider.SaveMachineConfig(mConfig);
        }