Administrator 2 years ago
parent
commit
57e5842306

BIN
DLL/PLC.Siemens.dll


+ 21 - 2
Projects/永冠/WCS.Service/ProtocolProxy.cs

@@ -95,6 +95,7 @@ namespace WCS.Service
         private static Dictionary<string, Playerback> Clients = new Dictionary<string, Playerback>();
 
         private static RedisClient Redis;
+        private static RedisClient YGRedis;
 
         static ProtocolProxy()
         {
@@ -110,6 +111,18 @@ namespace WCS.Service
                 var obj = MessagePackSerializer.Deserialize(type, bytes);
                 return obj;
             };
+
+            YGRedis = new RedisClient("106.15.78.3,password=Password@123$%^,database=1");
+            YGRedis.Serialize = obj =>
+            {
+                var bytes = MessagePackSerializer.Serialize(obj);
+                return bytes;
+            };
+            YGRedis.DeserializeRaw = (bytes, type) =>
+            {
+                var obj = MessagePackSerializer.Deserialize(type, bytes);
+                return obj;
+            };
         }
 
         //static ConcurrentDictionary<string, DeviceData> Datas = new ConcurrentDictionary<string, DeviceData>();
@@ -196,20 +209,26 @@ namespace WCS.Service
                 var sw = new Stopwatch();
                 sw.Start();
                 Redis.Set(nameof(DeviceDataPack), pack);
+                YGRedis.Set(nameof(DeviceDataPack), pack);
                 sw.Stop();
                 Console.ForegroundColor = ConsoleColor.Blue;
                 Console.WriteLine($"Redis耗时{sw.ElapsedMilliseconds}");
                 Console.ResetColor();
 
                 Redis.RPush("Packs", pack);
-
                 var len = Redis.LLen("Packs");
-
                 if (len > 150000)
                 {
                     Redis.LTrim("Packs", 20000, len);
                 }
 
+                YGRedis.RPush("Packs", pack);
+                var YGlen = YGRedis.LLen("Packs");
+                if (YGlen > 150000)
+                {
+                    YGRedis.LTrim("Packs", 20000, YGlen);
+                }
+
                 foreach (var data in AllDatas)
                 {
                     data.Value.Info = "";

+ 1 - 1
Projects/永冠/WCS.Service/Worker.cs

@@ -158,7 +158,7 @@ namespace WCS.Service
                 }
 
                 LogicHandler.StartAll();
-                //Uploader.Start();
+                
                 _logger.LogInformation("WCSÆô¶¯³É¹¦");
             }
             catch (Exception ex)

+ 7 - 7
WCS.Core/LogicHandler.cs

@@ -57,13 +57,13 @@ namespace WCS.Core
 
         public static void StartAll()
         {
-            //foreach (var h in Handlers)
-            //{
-            //    h.Start();
-            //}
-            //var th = new Thread(new ThreadStart(Loop));
-            //th.IsBackground = true;
-            //th.Start();
+            foreach (var h in Handlers)
+            {
+                h.Start();
+            }
+            var th = new Thread(new ThreadStart(Loop));
+            th.IsBackground = true;
+            th.Start();
         }
 
         private static DateTime last = DateTime.Now;