|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
class HostLifetime(
|
|
|
HardwareFileLoader hardwareFileLoader,
|
|
|
+ HardwareDBLoader hardwareDBLoader,
|
|
|
ConfigFileLoader configFileLoader,
|
|
|
AddressFileLoader addressFileLoader,
|
|
|
HardWareMonitor hardWareMonitor,
|
|
|
@@ -23,7 +24,21 @@ class HostLifetime(
|
|
|
{
|
|
|
log.Initialize("General");
|
|
|
|
|
|
- hardwareFileLoader.Load();
|
|
|
+ //Connect to DataBase Server
|
|
|
+ ormCollections.MainORM = new SqlSugarCustom();
|
|
|
+ if (string.IsNullOrEmpty(basicInfo.DBConnectionString) ||
|
|
|
+ !ormCollections.MainORM.Initialize() ||
|
|
|
+ !ormCollections.MainORM.Open(basicInfo.DBConnectionString, DbType.PostgreSQL))
|
|
|
+ {
|
|
|
+ log.Fatal($"Connect DB Failed");
|
|
|
+ Environment.Exit(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!hardwareDBLoader.Load())
|
|
|
+ {
|
|
|
+ hardwareFileLoader.Load();
|
|
|
+ hardwareDBLoader.Save();
|
|
|
+ }
|
|
|
configFileLoader.Load();
|
|
|
addressFileLoader.Load();
|
|
|
addressFileLoader.LoadPLC();
|
|
|
@@ -36,6 +51,7 @@ class HostLifetime(
|
|
|
}
|
|
|
dataDispatcher.TryAddNotifier("PLC", plcNotifier);
|
|
|
dataDispatcher.TryAddNotifier("UI", uiNotifier);
|
|
|
+
|
|
|
//Start RT Server
|
|
|
if (string.IsNullOrEmpty(basicInfo.RTServerAddress) ||
|
|
|
!rtNotifer.Initialize(tlvProvider) ||
|
|
|
@@ -44,20 +60,10 @@ class HostLifetime(
|
|
|
log.Fatal($"Open RT Server {basicInfo.RTServerAddress}:{basicInfo.RTServerPort} Failed");
|
|
|
Environment.Exit(0);
|
|
|
}
|
|
|
+
|
|
|
dataDispatcher.TryAddNotifier("RT", rtNotifer);
|
|
|
dataDispatcher.TryAddNotifier("Kanban", kanbanNotifier);
|
|
|
|
|
|
- //Connect to DataBase Server
|
|
|
- ormCollections.MainORM = new SqlSugarCustom();
|
|
|
- if (string.IsNullOrEmpty(basicInfo.DBConnectionString) ||
|
|
|
- !ormCollections.MainORM.Initialize() ||
|
|
|
- !ormCollections.MainORM.Open(basicInfo.DBConnectionString, DbType.PostgreSQL))
|
|
|
- {
|
|
|
- log.Fatal($"Connect DB Failed");
|
|
|
- Environment.Exit(0);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
log.Info($"Start RT Server {basicInfo.RTServerAddress}:{basicInfo.RTServerPort} success");
|
|
|
|
|
|
//Connect to Mini8s
|
|
|
@@ -71,6 +77,7 @@ class HostLifetime(
|
|
|
//Start Collecting Mini8s Realtime Data
|
|
|
hardWareMonitor.ParallelStartDataCollecion();
|
|
|
|
|
|
+ //Start Daily Routine Work
|
|
|
dailyRoutinHelper.AddorUpdateRoutinWork("CleanDataBase", dataBaseCleaner.CleanDB);
|
|
|
dailyRoutinHelper.AddorUpdateRoutinWork("CleanLogFile", ((LogSender)log).CleanLog);
|
|
|
dailyRoutinHelper.StartService(TimeSpan.FromDays(1));
|