96 lines
2.5 KiB
C#
96 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Matomat.Output;
|
|
using Matomat.Input;
|
|
using Matomat.Database;
|
|
|
|
namespace Matomat.Helper
|
|
{
|
|
class Factory
|
|
{
|
|
private static LCDDisplay lcd_i = null;
|
|
private static TInput inp_i = null;
|
|
private static Config con_i = null;
|
|
private static TDatabase dbo_i;
|
|
|
|
public static LCDDisplay getLCD()
|
|
{
|
|
if (lcd_i == null)
|
|
lcd_i = Factory._createLCDDisplay();
|
|
return lcd_i;
|
|
}
|
|
public static void rmLCD()
|
|
{
|
|
if (lcd_i != null)
|
|
{
|
|
lcd_i.RequestStop();
|
|
lcd_i = null;
|
|
}
|
|
}
|
|
private static LCDDisplay _createLCDDisplay()
|
|
{
|
|
return LCDDisplay.getInstance(Factory.getConfig().com_display);
|
|
}
|
|
|
|
public static TInput getInput()
|
|
{
|
|
if (inp_i == null)
|
|
inp_i = Factory._createInput();
|
|
return inp_i;
|
|
}
|
|
private static TInput _createInput()
|
|
{
|
|
return TInput.getInstance(Factory.getConfig().com_rfid);
|
|
}
|
|
public static void rmInput()
|
|
{
|
|
if (inp_i != null)
|
|
{
|
|
inp_i.RequestStop();
|
|
inp_i = null;
|
|
}
|
|
}
|
|
|
|
public static Config getConfig()
|
|
{
|
|
if (con_i == null)
|
|
con_i = Factory._createConfig("App.config");
|
|
return con_i;
|
|
}
|
|
private static Config _createConfig(string file)
|
|
{
|
|
return Config.getInstance(file);
|
|
}
|
|
public static void rmConfig()
|
|
{
|
|
if (con_i != null)
|
|
{
|
|
con_i.RequestStop();
|
|
con_i = null;
|
|
}
|
|
}
|
|
|
|
public static TDatabase getDBO()
|
|
{
|
|
if (dbo_i == null)
|
|
dbo_i = Factory._createDBO();
|
|
return dbo_i;
|
|
}
|
|
private static TDatabase _createDBO()
|
|
{
|
|
Config c = Factory.getConfig();
|
|
return TDatabase.getInstance(c.mysql_server, c.mysql_db, c.mysql_user, c.mysql_pw, c.mysql_port, c.mysql_driver);
|
|
}
|
|
public static void rmDBO()
|
|
{
|
|
if (dbo_i != null)
|
|
{
|
|
dbo_i.RequestStop();
|
|
dbo_i = null;
|
|
}
|
|
}
|
|
}
|
|
}
|