肖奇伟 17 saat önce
ebeveyn
işleme
ded8cfab80

BIN
Lib/SCADA.CommonCtrl.dll


BIN
Lib/SCADA.CommonLib.dll


+ 5 - 0
Lib/SCADA.CommonLib.xml

@@ -1078,6 +1078,11 @@
             下限
             </summary>
         </member>
+        <member name="P:SCADA.CommonLib.CommonModel.DetectionItem`1.SetupValue">
+            <summary>
+            设定值
+            </summary>
+        </member>
         <member name="T:SCADA.CommonLib.CommonModel.DetectionStatus">
             <summary>
             

BIN
Lib/SCADA.dll


+ 1 - 1
Lib/SCADA.xml

@@ -99,7 +99,7 @@
             低位在前
             </summary>
         </member>
-        <member name="F:SCADA.OCTByteSeq.EFGJABCD">
+        <member name="F:SCADA.OCTByteSeq.EFGHABCD">
             <summary>
             高低位在前(默认)
             </summary>

BIN
Lib/SCADA_DAQ.Plugin.Core.dll


BIN
Lib/SCADA_DAQ.Plugin.CoreUI.dll


BIN
Lib/SCADA_DAQ.Plugin.Machine.dll


BIN
Lib/SCADA_DAQ.Plugin.MachineUI.dll


BIN
Lib/SCADA_DAQ.Plugin.RESTful.dll


BIN
SCADA_DAQ.Service/Data/Alarmdb.zip


BIN
SCADA_DAQ.Service/Data/LocalApp.zip


BIN
SCADA_DAQ.Service/Data/Platform.zip


+ 18 - 83
SCADA_DAQ.Service/Env.cs

@@ -2,6 +2,7 @@
 using SCADA.CommonLib;
 using SCADA.CommonLib.Data.DIL;
 using SCADA.CommonLib.Helper;
+using SCADA.Instrument.AIP;
 using SysManage.User;
 using System;
 using System.Collections.ObjectModel;
@@ -19,34 +20,8 @@ namespace SCADA_DAQ
 
         public static Schedual Schedual { get; internal set; } = Schedual.Instance;
 
-        //public static readonly ConcurrentDictionary<string, BaseComm> CommResource = new ConcurrentDictionary<string, BaseComm>();
-
-        public static DateTime StartTime { get; set; }
-
-        public static int StartTick { get; internal set; }
-
-        public static AutoSaveParameterItem<string> ProductName;
-
-        public static AutoSaveParameterItem<string> CompanyName;
-
-        public static AutoSaveParameterItem<string> MainDllName;
-
-        public static AutoSaveParameterItem<string> DefaultUserName;
-
-        public static AutoSaveParameterItem<string> WebServerAddress = AutoSaveParameterItem.Create("App.WebServer", "www.skdscada.com");
-
         public static AutoSaveParameterItem<bool> DataBaseNeedRest { get; set; } = AutoSaveParameterItem.Create("App.DatabaseNeedRest", false);
 
-        public static AutoSaveParameterItem<string> ComputerTag;
-
-        public static AutoSaveParameterItem<int> RESTfulPort;
-
-        public static AutoSaveParameterItem<int> RPCPort;
-
-        public static AutoSaveParameterItem<bool> SingleModel;
-
-        public static AutoSaveParameterItem<SCADA.CommonLib.LoggerHelper.LogLevel> LogLevel;
-
         public static DataBaseConfig CurrentDbConfig { get; set; }
 
         public static AutoSaveParameterItem<DatabaseSelector> CurrentDataBase { get; set; }
@@ -66,46 +41,8 @@ namespace SCADA_DAQ
         /// </summary>
         public static AutoSaveParameterItem<string> DeviceConfigFilePath;
 
-        public static void ParameterInit()
+        public static void ParameterInit(IApp app)
         {
-            ProductName = AutoSaveParameterItem.Create("App.ProductName", "", true);
-            ProductName.DisplayName = "产品名称";
-
-
-            CompanyName = AutoSaveParameterItem.Create("App.ProductName", "", true);
-            CompanyName.DisplayName = "公司名称";
-
-
-            MainDllName = AutoSaveParameterItem.Create("App.MainDllname", "", true);
-            {
-                MainDllName.DisplayName = "主dll名称";
-            };
-
-            DefaultUserName = AutoSaveParameterItem.Create("App.DefualtUserName", "", true);
-            DefaultUserName.DisplayName = "默认用户";
-
-
-            ComputerTag = AutoSaveParameterItem.Create("App.ComputerTag", "", true);
-            ComputerTag.DisplayName = "电脑标签";
-            ComputerTag.IsReadOnly = true;
-
-
-            RESTfulPort = AutoSaveParameterItem.Create("App.RESTfulPort", 7888);
-            RESTfulPort.DisplayName = "网页端口";
-
-            RPCPort = AutoSaveParameterItem.Create("App.RPCPort", 7880);
-            RPCPort.DisplayName = "本地RPC端口";
-
-
-            SingleModel = AutoSaveParameterItem.Create("App.SingleModel", true);
-            SingleModel.DisplayName = "单例模式";
-
-            LogLevel = AutoSaveParameterItem.Create("App.LogLevel", SCADA.CommonLib.LoggerHelper.LogLevel.All);
-            LogLevel.DisplayName = "日志级别";
-
-            DeviceConfigFilePath = AutoSaveParameterItem.Create("DeviceConfigFilePath", "DeviceCfg.Json");
-            DeviceConfigFilePath.DisplayName = "设备配置文件";
-
             CurrentDataBase = AutoSaveParameterItem.Create("App.DataBaseConfig", new DatabaseSelector()
             { CurrentDataBaseConfig = "Default" });
 
@@ -161,7 +98,6 @@ namespace SCADA_DAQ
                 if (dataBaseConfig.DBType == DatabaseType.Sqlite)   //如果是sqlite数据库就检查数据库的状态
                 {
                     string dbInfo = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dataBaseConfig.FilePath);
-                    //string dbInfo = Path.GetFullPath(dataBaseConfig.FilePath);
                     dilDb = (BaseDB)Activator.CreateInstance(dbType, Path.GetDirectoryName(dbInfo), Path.GetFileName(dataBaseConfig.FilePath),
                         dataBaseConfig.UserName,
                         dataBaseConfig.Password);
@@ -178,9 +114,9 @@ namespace SCADA_DAQ
             dbInit(AlarmDBConfig, typeof(DILDB), out BaseDB alarmDB);
 
             DAL = (DILDB)currentDB;
-            GlobalEnv.Instance.GlobalDB = currentDB;
-            GlobalEnv.Instance.AlarmDB = alarmDB;
-            GlobalEnv.Instance.LocalAppDB = sysDB;
+            app.RuntimeInfo.GlobalDB = currentDB;
+            app.RuntimeInfo.AlarmDB = alarmDB;
+            app.RuntimeInfo.LocalAppDB = sysDB;
             NewUser = new User(DAL)
             {
                 UserName = "Admin",
@@ -188,8 +124,7 @@ namespace SCADA_DAQ
         }
         static Env()
         {
-            //XmlUserConfig.Create();
-            //ParameterInit();
+
         }
 
         private static void CheckDataBase(BaseDB db, string databasepath, bool dataBaseNeedRest)
@@ -206,16 +141,16 @@ namespace SCADA_DAQ
             {
                 if (File.Exists(databasepath))
                 {
-                    object dt = db.ExecuteScalar("PRAGMA integrity_check");
-                    if ($"{dt}".ToUpper() == "OK")
-                    {
-                        System.Diagnostics.Debug.WriteLine($"{databasepath} 数据库检测正常");
-                    }
-                    else
-                    {
-                        System.Diagnostics.Trace.TraceWarning($"检测到本地数据库已损坏,开始重置数据库");
-                        _ = ReleseDatabase();
-                    }
+                    //object dt = db.ExecuteScalar("PRAGMA integrity_check");
+                    //if ($"{dt}".ToUpper() == "OK")
+                    //{
+                    //    System.Diagnostics.Debug.WriteLine($"{databasepath} 数据库检测正常");
+                    //}
+                    //else
+                    //{
+                    //    System.Diagnostics.Trace.TraceWarning($"检测到本地数据库已损坏,开始重置数据库");
+                    //    _ = ReleseDatabase();
+                    //}
                 }
                 else
                 {
@@ -238,9 +173,9 @@ namespace SCADA_DAQ
                     {
                         res = new MemoryStream(LocalResource.LocalApp);
                     }
-                    else if (Path.GetFileName(databasepath).ToUpper() == "QWPLATFORM.DB")
+                    else if (Path.GetFileName(databasepath).ToUpper() == "PLATFORM.DB")
                     {
-                        res = new MemoryStream(LocalResource.QwPlatform);
+                        res = new MemoryStream(LocalResource.Platform);
                     }
                     if (res == null) return true;
                     using (res)

+ 12 - 2
SCADA_DAQ.Service/LocalResource.Designer.cs

@@ -60,6 +60,16 @@ namespace SCADA_DAQ {
             }
         }
         
+        /// <summary>
+        ///   查找 System.Byte[] 类型的本地化资源。
+        /// </summary>
+        internal static byte[] Alarmdb {
+            get {
+                object obj = ResourceManager.GetObject("Alarmdb", resourceCulture);
+                return ((byte[])(obj));
+            }
+        }
+        
         /// <summary>
         ///   查找 System.Byte[] 类型的本地化资源。
         /// </summary>
@@ -73,9 +83,9 @@ namespace SCADA_DAQ {
         /// <summary>
         ///   查找 System.Byte[] 类型的本地化资源。
         /// </summary>
-        internal static byte[] QwPlatform {
+        internal static byte[] Platform {
             get {
-                object obj = ResourceManager.GetObject("QwPlatform", resourceCulture);
+                object obj = ResourceManager.GetObject("Platform", resourceCulture);
                 return ((byte[])(obj));
             }
         }

+ 6 - 3
SCADA_DAQ.Service/LocalResource.resx

@@ -119,9 +119,12 @@
   </resheader>
   <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
   <data name="LocalApp" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>data\localapp.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>Data\localapp.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </data>
-  <data name="QwPlatform" type="System.Resources.ResXFileRef, System.Windows.Forms">
-    <value>data\qwplatform.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  <data name="Platform" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>Data\Platform.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </data>
+    <data name="Alarmdb" type="System.Resources.ResXFileRef, System.Windows.Forms">
+    <value>Data\Alarmdb.zip;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </data>
 </root>

+ 103 - 7
SCADA_DAQ.Service/Program.cs

@@ -1,6 +1,8 @@
 
 using log4net;
+using SCADA.CommonLib;
 using SCADA.CommonLib.Helper;
+using SCADA.CommonLib.Service;
 using System;
 using System.Runtime.InteropServices;
 using System.Threading;
@@ -12,27 +14,24 @@ namespace SCADA_DAQ.Service
     {
         static void Main(string[] args)
         {
-            ILog log = SCADA.CommonLib.LoggerHelper.Logger.CreatLogger(typeof(ProgramMain));
+            ILog log = SCADA.CommonLib.LoggerHelper.Logger.CreateLogger(typeof(ProgramMain));
 
             AppDomain.CurrentDomain.UnhandledException += (s, e) =>
             {
                 log.Error(e);
             };
             DisableConsoleCloseAction();
-            Env.StartTick = Environment.TickCount;
-            Env.ParameterInit();
+            Env.ParameterInit(Runtime.Instance);
             HostFactory.Run(x =>
             {
-                var cfg = x.Service<ServiceHost>(
+                var cfg = x.Service<Runtime>(
                      s =>
                      {
-                         s.ConstructUsing(name => ServiceHost.Instance);
+                         s.ConstructUsing(name => Runtime.Instance);
                          s.WhenStarted(t => t.Start());
                          s.WhenPaused(t => t.Paused());
                          s.WhenContinued(t => t.Resume());
                          s.WhenStopped(t => t.Stop());
-
-
                      });
                 //x.UseLog4Net("log4net.config");
                 x.SetDescription("SCADA 采集");
@@ -93,4 +92,101 @@ namespace SCADA_DAQ.Service
         private const string _ConsoleTitle = "采集服务正在运行,请不要关闭此窗口!(PLEASE Don't Close This Window!)";
 
     }
+
+
+    public class Runtime : IApp
+    {
+        private string _sessionid;
+
+        private Runtime()
+        {
+
+        }
+
+        private static Runtime _instance;
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public static Runtime Instance { get => _instance ?? (_instance = new Runtime()); private set { _instance = value; } }
+
+        public ThemeConfig ThemeConfig { get; }
+
+        public SystemConfig SystemConfig { get; }
+
+        public RuntimeInfo RuntimeInfo { get; set; }
+        public IServiceHost ServiceHost { get; set; }
+
+        public void Start()
+        {
+            RuntimeInfo.ProductId = "";
+            RuntimeInfo.SessionId = _sessionid ?? (_sessionid = Guid.NewGuid().ToString());
+            Console.WriteLine($"App Start  {DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}");
+            if (string.IsNullOrEmpty(SystemConfig.WebServer))
+            {
+                SystemConfig.WebServer = "www.imaodou.com.cn";
+            }
+            if (string.IsNullOrEmpty(SystemConfig.ProductTitle))
+            {
+                SystemConfig.ProductTitle = RuntimeInfo.ProductId;
+            }
+            if (string.IsNullOrEmpty(SystemConfig.AuthorInfo))
+            {
+                SystemConfig.AuthorInfo = "";
+            }
+            if (string.IsNullOrEmpty(SystemConfig.DefaultUser))
+            {
+                SystemConfig.DefaultUser = "Operator";
+            }
+
+            var host = SCADA_DAQ.ServiceHost.Instance;
+            host.Start(this);
+            ServiceHost = host;
+        }
+
+        public void Stop()
+        {
+            ServiceHost.Stop();
+        }
+
+        public void Paused()
+        {
+
+        }
+
+        public void ReLoadLicense()
+        {
+
+        }
+
+        public void Resume()
+        {
+
+        }
+
+        public void Restart(bool runAsAdmin)
+        {
+
+        }
+
+        public void Restart()
+        {
+
+        }
+
+        public void ShowLongToast(object message, ControlStyle toastType = ControlStyle.Default)
+        {
+
+        }
+
+        public void ShowShortToast(object message, ControlStyle toastType = ControlStyle.Default)
+        {
+
+        }
+
+        public void ShowToast(object message, ControlStyle toastType = ControlStyle.Default, int showTime = 2000)
+        {
+
+        }
+    }
 }

+ 1 - 1
SCADA_DAQ/Env.cs

@@ -84,7 +84,7 @@ namespace SCADA_DAQ
                             {
                                 ResourceName="AlarmDB",
                                 DBType = DatabaseType.Sqlite,
-                                FilePath = @"Data\Aalarmdb.db"
+                                FilePath = @"Data\Alarmdb.db"
                             },
                             new DataBaseConfig()
                             {