public SwitchViewModel(PRSwitch _switch) { this.Name = _switch.Name; this.Number = _switch.Number; this.VpSwitchType = _switch.VpSwitchType; this.Tags = _switch.Tags; this.Label = _switch.Label; if (_switch.BallSearch != null) { var _search = _switch.BallSearch.Split(','); try { if (_search[0].Trim() == "stop") { Stop = true; } if (_search[1].Trim() == "reset") { Reset = true; } } catch { } } }
private void UpdateSwitchesBeforeSaved(MachineConfig mConfig) { //Save switches Log("Adding switches"); foreach (var item in Switches) { var number = item.Number; //TODO: Keep or REMOVE for old column naming //if (MachineConfig.GetMachineType() == MachineType.PDB) // number = item.Number.Split(':')[1]; if (item.Name != "NOT USED") { var sw = new PRSwitch() { Name = item.Name, Number = number, Tags = item.Tags, SwitchType = item.Type, Label = item.Label, VpSwitchType = item.VpSwitchType }; if (item.BallSearch.Any(x => x != null)) { sw.BallSearch = $"{item.BallSearch[0]}, {item.BallSearch[1]}"; } mConfig.PRSwitches.Add(sw); } } }
public KeyboardMapItemViewModel(PRSwitch prSwitch, KeyValuePair <string, string> keySwitch) { Name = prSwitch.Name; Number = prSwitch.Number; Key = keySwitch.Key; GetKeycode(Key.ToString()); }
/// <summary> /// Creates a ball stack script for use in the VBS constructor /// </summary> /// <returns></returns> private string CreateBallStackScript(PRSwitch prSwitch) { string ballStackScript = string.Empty; var vpSwitchNumber = prSwitch.Number.Replace("S", ""); //Add to the Dim variables for top of script var dimName = $"bs{prSwitch.Name}"; _ballStackVariables += $"Dim {dimName}\r\n"; switch (prSwitch.VpSwitchType) { case VpSwitchType.Saucer: ballStackScript += $"Set {dimName}=New cvpmBallStack : With {dimName}" + Environment.NewLine; ballStackScript += $".initKicker sw{vpSwitchNumber}, {vpSwitchNumber}, 80, 5" + Environment.NewLine; //ballStackScript += ".initSounds " + "\"" + "Solenoid" + "\"" + ", " + "\"" + "Solenoid" + "\"" + ", " + "\"" + "Solenoid" + "\"" + Environment.NewLine; ballStackScript += ".CreateEvents " + "\"" + $"{dimName}" + "\"" + $", sw{vpSwitchNumber}" + Environment.NewLine; ballStackScript += "End With" + Environment.NewLine; break; case VpSwitchType.Scoop: ballStackScript += $"Set {dimName}=New cvpmBallStack : With {dimName}" + Environment.NewLine; ballStackScript += $".InitSw 0, {vpSwitchNumber}, 0, 0, 0, 0, 0, 0" + Environment.NewLine; ballStackScript += $".InitKick sw{vpSwitchNumber}, 200, 20" + Environment.NewLine; ballStackScript += $".KickZ = 0.3" + Environment.NewLine; ballStackScript += $".KickForceVar = 1.5" + Environment.NewLine; ballStackScript += ".InitExitSnd " + "\"" + "Solenoid" + "\"" + ", " + "\"" + "Solenoid" + "\"" + Environment.NewLine; ballStackScript += ".CreateEvents " + "\"" + $"{dimName}" + "\"" + $", sw{vpSwitchNumber}" + Environment.NewLine; ballStackScript += "End With" + Environment.NewLine; break; case VpSwitchType.Vuk: ballStackScript += $"Set {dimName}=New cvpmBallStack : With {dimName}" + Environment.NewLine; ballStackScript += $".initKicker sw{vpSwitchNumber}, {vpSwitchNumber}, 80, 5" + Environment.NewLine; ballStackScript += ".initSounds " + "\"" + "Solenoid" + "\"" + ", " + "\"" + "Solenoid" + "\"" + ", " + "\"" + "Solenoid" + "\"" + Environment.NewLine; ballStackScript += ".CreateEvents " + "\"" + $"{dimName}" + "\"" + $", sw{vpSwitchNumber}" + Environment.NewLine; ballStackScript += "End With" + Environment.NewLine; break; default: break; } return(ballStackScript); }
/// <summary> /// Gets a VP scripted switch method. /// </summary> /// <param name="pRSwitch">The Machines switch</param> /// <param name="procMachineType">Type of the PROC Board.</param> /// <returns>String that contains a Hit() and UnHit() method invoking the Controller.Switch(num). If setting VP Switch type the controllers invocation will be different.</returns> private string GetVpSwitchMethod(PRSwitch pRSwitch, MachineType procMachineType) { var exportString = $"' {pRSwitch.Name} hit {Environment.NewLine}"; string swNumber = null; string swName = pRSwitch.Name; //Get switch number with out any chars. Depending on machine type. Different with a PDB if (procMachineType != MachineType.PDB) { swNumber = pRSwitch.Number.Replace("S", string.Empty); } else { swNumber = pRSwitch.Number.Replace("SD", string.Empty); if (swNumber.StartsWith("0")) { swNumber = swNumber.Remove(0, 1); } } // VP Pulse Switches if (pRSwitch.VpSwitchType == VpSwitchType.PulseSwitch) { if (procMachineType != MachineType.PDB) { exportString += $"Sub sw{swNumber}_Hit():vpmTimer.PulseSw {swNumber}:End Sub{Environment.NewLine}"; } } // VP Pulse Spinners else if (pRSwitch.VpSwitchType == VpSwitchType.Spinner) { if (procMachineType != MachineType.PDB) { exportString += $"Sub sw{swNumber}_Spin():vpmTimer.PulseSw {swNumber}:End Sub{Environment.NewLine}"; } } // Anything but BallStacks / Saucers else if (pRSwitch.VpSwitchType != VpSwitchType.Saucer || pRSwitch.VpSwitchType != VpSwitchType.Vuk || pRSwitch.VpSwitchType != VpSwitchType.Scoop) { exportString += $"Sub sw{swNumber}_Hit():Controller.Switch({swNumber}) = 1 :End Sub{Environment.NewLine}"; exportString += $"Sub sw{swNumber}_UnHit():Controller.Switch({swNumber}) = 0 :End Sub{Environment.NewLine}"; } return(exportString); }
private void UpdateDedicatedBeforeSave(MachineConfig mConfig) { Log("Adding Dedicated switches"); foreach (var item in DedicatedSwitches) { if (item.Name != "NOT USED") { var sw = new PRSwitch() { Name = item.Name, Number = item.Number, Tags = item.Tags, SwitchType = item.Type, Label = item.Label }; mConfig.PRSwitches.Add(sw); } } }
private void AddToUnusedSwitch(PRSwitch x) { if (x == null) { return; } char sdlKeyCodeChar = (char)CapturedSdlCode; string charString = sdlKeyCodeChar.ToString(); Dispatcher.CurrentDispatcher.Invoke(() => { SwitchKeys.Add(new KeyboardMapItemViewModel { Keycode = CapturedSdlCode, Name = x.Name, Number = x.Number, Key = sdlKeyCodeChar.ToString() }); }); AvailableSwitches.Remove(x); }