/// <summary> /// Receives data to be processed by the DirectOutput framework.<br/> /// This function has to be called whenever the state of a table element changes in the hosting application. /// </summary> /// <param name="TableElementTypeChar">The table element type char.</param> /// <param name="Number">The number of the table element.</param> /// <param name="Value">The value of the table element.</param> /// <exception cref="System.Exception"> /// Could not extract the first char of the TableElementTypeChar parameter /// or /// You must call Init before passing data to the DirectOutput framework /// or /// A exception occured when passing in data (TableElementTypeChar: {0}, Number: {1}, Value: {2}) /// </exception> public static void UpdateTableElement(string TableElementTypeChar, int Number, int Value) { char C; try { C = TableElementTypeChar[0]; } catch (Exception E) { throw new Exception("Could not extract the first char of the TableElementTypeChar parameter", E); } try { Pinball.ReceiveData(C, Number, Value); } catch (Exception E) { if (Pinball == null) { throw new Exception("You must call Init before passing data to the DirectOutput framework"); } else { throw new Exception("A exception occured when passing in data (TableElementTypeChar: {0}, Number: {1}, Value: {2})".Build(C, Number, Value), E); } } }
public bool LoadConfig() { OpenConfigDialog OCD = new OpenConfigDialog(Settings); if (OCD.ShowDialog() == DialogResult.OK) { if (Pinball != null) { Pinball.Finish(); } Pinball = new Pinball(); Pinball.Init(OCD.GlobalConfigFilename, OCD.TableFilename, OCD.RomName); DisplayTableElements(); return true; } else { return false; } }
/// <summary> /// Finishes the DirectOutput framework.<br/> /// The is the last methods to be called on the framework. /// </summary> public static void Finish() { if (Pinball != null) { Pinball.Finish(); Pinball = null; } }
/// <summary> /// Finishes the DirectOutput framework.<br/> /// The is the last methods to be called on the framework. /// </summary> public static void Finish() { if (Pinball != null) { Pinball.Finish(); Pinball = null; } else { Log.Write("DirectOutput.Finish: Pinball is null, unable to shut down cab!"); } }
/// <summary> /// Receives data for named table elements. /// The received data is put in a queue and the internal thread of the framework is notified about the availability of new data. /// </summary> /// <param name="TableElementName">Name of the table element.</param> /// <param name="Value">The value of the table element.</param> /// <exception cref="System.Exception"> /// You must call Init before passing data to the DirectOutput framework /// or /// A exception occured when passing in data (TableElementName: {0}, Value: {1}).Build(TableElementName, Value) /// </exception> public static void UpdateNamedTableElement(string TableElementName, int Value) { try { Pinball.ReceiveData(TableElementName, Value); } catch (Exception E) { if (Pinball == null) { throw new Exception("You must call Init before passing data to the DirectOutput framework"); } else { throw new Exception("A exception occured when passing in data (TableElementName: {0}, Value: {1})".Build(TableElementName, Value), E); } } }
/// <summary> /// Initializes the Plugin.<br/> /// The IPlugin interface requires the implementation of this method.<br/> /// </summary> /// <param name="HostingApplicationName">Name of the hosting application.</param> /// <param name="TableFilename">The table filename.<br>If no table filename is available, it is best to provide a path and name of a non existing dummy file, since the plugins might use this path to identify the directories where the store logs, load configs from and so on.</br></param> /// <param name="GameName">Name of the game.<br/>If the game is a SS pinball table it is highly recommanded to provide the name of the game rom, otherwise any other name which identifiey to game uniquely will be fine as well.</param> public void PluginInit(string HostingApplicationName, string TableFilename, string GameName) { string HostAppFilename = HostingApplicationName.Replace(".", ""); foreach (char C in Path.GetInvalidFileNameChars() ) { HostAppFilename=HostAppFilename.Replace(""+C,""); } foreach (char C in Path.GetInvalidPathChars()) { HostAppFilename = HostAppFilename.Replace("" + C, ""); } HostAppFilename = "GlobalConfig_{0}".Build(HostAppFilename); //Check config dir for global config file FileInfo F = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", HostAppFilename+".xml")); if (!F.Exists) { //Check if a shortcut to the config dir exists FileInfo LnkFile = new FileInfo(Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, "config", HostAppFilename + ".lnk")); if (LnkFile.Exists) { string ConfigDirPath = ResolveShortcut(LnkFile); if (Directory.Exists(ConfigDirPath)) { F = new FileInfo(Path.Combine(ConfigDirPath, HostAppFilename+".xml")); } } } Pinball = new Pinball(); Pinball.Init(F.FullName,TableFilename,GameName ); }