5 using System.Xml.Serialization;
24 Log.
Write(
"Cabinet auto configuration started");
26 General.TypeList Types =
new General.TypeList(AppDomain.CurrentDomain.GetAssemblies().ToList().SelectMany(s => s.GetTypes()).Where(p => typeof(
IAutoConfigOutputController).IsAssignableFrom(p) && !p.IsAbstract));
27 foreach (Type T
in Types)
38 Log.
Exception(
"A exception occured during auto configuration for output controller(s) of type {0}.".Build(T.Name), E);
44 Log.
Write(
"Cabinet auto configuration finished");
81 get {
return Owner.Alarms; }
89 public string Name {
get; set; }
98 public string CabinetConfigurationFilename {
get; set; }
100 private Toys.ToyList _Toys;
108 get {
return _Toys; }
109 set { _Toys = value; }
126 get {
return _Colors; }
127 set { _Colors = value; }
138 get {
return _Curves; }
139 set { _Curves = value; }
142 private bool _AutoConfigEnabled=
true;
151 public bool AutoConfigEnabled
153 get {
return _AutoConfigEnabled; }
154 set { _AutoConfigEnabled = value; }
172 private Out.OutputControllerList _OutputControllers;
178 public Out.OutputControllerList OutputControllers
180 get {
return _OutputControllers; }
181 set { _OutputControllers = value; }
185 #region Serialization
194 using (MemoryStream ms =
new MemoryStream())
196 new XmlSerializer(typeof(
Cabinet)).Serialize(ms,
this);
198 using (StreamReader sr =
new StreamReader(ms, Encoding.Default))
200 Xml = sr.ReadToEnd();
215 GetConfigXml().WriteToFile(FileName);
229 Xml = General.FileReader.ReadFileToString(FileName);
233 Log.
Exception(
"Could not load cabinet config from {0}.".Build(FileName), E);
234 throw new Exception(
"Could not read cabinet config file {0}.".Build(FileName), E);
237 return GetCabinetFromConfigXml(Xml);
251 C = GetCabinetFromConfigXmlFile(FileName);
268 return GetCabinetFromConfigXmlFile(CabinetConfigFile.FullName);
278 byte[] xmlBytes = Encoding.Default.GetBytes(ConfigXml);
279 using (MemoryStream ms =
new MemoryStream(xmlBytes))
283 return (
Cabinet)
new XmlSerializer(typeof(
Cabinet)).Deserialize(ms);
288 Exception Ex =
new Exception(
"Could not deserialize the cabinet config from XML data.", E);
289 Ex.Data.Add(
"XML Data", ConfigXml);
290 Log.
Exception(
"Could not load cabinet config from XML data.", Ex);
305 this.Owner = CabinetOwner;
306 OutputControllers.Init(
this);
318 Toys.UpdateOutputs();
319 OutputControllers.Update();
332 OutputControllers.Finish();
344 _OutputControllers =
new Out.OutputControllerList();
346 _Toys =
new Toys.ToyList();
The AlarmHandler classed is used to execute scheduled events (e.g. regular updates on a effect) in th...
The Cabinet object describes the parts of a pinball cabinet (toys, outputcontrollers, outputs and more).
Interface for classes used to automatically detect and configure output controllers ...
The namespace DirectOutput.Cab.Toys contains all toy related classes.
static Cabinet GetCabinetFromConfigXmlFile(string FileName)
Instanciates a Cabinet object from a cabinet configuration in a XML file.
static bool TestCabinetConfigXmlFile(string FileName)
Tests a cabinet config in a XML file.
void SaveConfigXmlFile(string FileName)
Serializes the cabinet configuration to a XML file.
void Update()
Calls the update method for toys and output controllers in the cabinet
Readonly list containing all IOutput objects of all IOutputController objects in a cabinet...
static void Write(string Message)
Writes the specified message to the logfile.
A simple logger used to record important events and exceptions.
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
void Finish()
Finishes the cabinet
DirectOutput.Cab.Out is the namespace for all output controller related classes like different output...
static Cabinet GetCabinetFromConfigXmlFile(FileInfo CabinetConfigFile)
Instanciates a Cabinet object from a cabinet configuration in a XML file.
static Cabinet GetCabinetFromConfigXml(string ConfigXml)
Instanciates a Cabinet object from a cabinet configuration in a XML string.
void Init(ICabinetOwner CabinetOwner)
Initializes the cabinet.
void AutoConfig()
This method finds all classes implementing the IAutoConfigOutputController interface and uses the mem...
void AutoConfig(Cabinet Cabinet)
This method has to detect configure IOutputController object automatically.
The namespace DirectOutput.General contains classes for general use.
Support classes used by the Pinball object.
static void Exception(string Message, Exception E=null)
Writes a exception message to the log.
string GetConfigXml()
Returns a serialized XML representation of the cabinet configuration.