Browse Source

增加警报播报

zhangliwen 1 year ago
parent
commit
0d1ffd90f0

+ 26 - 0
SCADA_DAQ/Customer/Machines/SampleMachine.cs

@@ -1,14 +1,20 @@
 using DBNames;
 using SCADA;
+using SCADA.Comm;
 using SCADA.CommonLib;
 using SCADA.CommonLib.Data.DIL;
 using SCADA.Drive;
 using SCADA_DAQ.Plugin.Machine;
 using SCADA_DAQ.Plugin.Machine.Device;
 using System;
+using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
 using System.Linq;
+using System.Security.Claims;
+using System.Speech.Synthesis;
+using System.Threading;
+using System.Threading.Tasks;
 using System.Windows;
 
 namespace SCADA_DAQ.Customer.Machines
@@ -36,8 +42,25 @@ namespace SCADA_DAQ.Customer.Machines
             // .Select(t => new Alarm() { AlarmCode = t.AlarmCode_Str, Desc = t.AlarmDesc_Str })?
             // .ToLookup(t => t.AlarmCode).ToDictionary(t => t.Key, t => t.First());
 
+            // 警报播报
+            Task.Run(() =>
+            {
+                while (true)
+                {
+                    if (AlarmCollection.Count > 0)
+                    {
+                        var alarmDesc = AlarmCollection.Select(t => t.Desc).ToList();  // 缓存
+                        var reader = new SpeechSynthesizer();
+                        alarmDesc.ForEach(t =>
+                        {
+                            reader.Speak(BaseDevice.DeviceID.Substring(3, 4) + t);  // 同步播报
+                        });
+                    }
+                }
+            });
         }
 
+
         ///// <summary>
         ///// 
         ///// </summary>
@@ -97,6 +120,7 @@ namespace SCADA_DAQ.Customer.Machines
             {
                 AlarmCollection.Remove(e.Alarm);
             }));
+
             //(GlobalEnv.Instance.AlarmDB as BaseDB).Update("Base_AlarmLog",
             //    $"{T_Col_Name.Base_AlarmLog.AlarmId_Str}='{e.Alarm.Id}'",
             //    new UpdateItem(T_Col_Name.Base_AlarmLog.RecoverTime_Dt, e.Alarm.RecoverTime),
@@ -104,5 +128,7 @@ namespace SCADA_DAQ.Customer.Machines
             //  new UpdateItem(T_Col_Name.Base_AlarmLog.Duration_Int, e.Alarm.DurationTicks),
             //  new UpdateItem(T_Col_Name.Base_AlarmLog.IsClosed_Bit, e.Alarm.IsClosed));
         }
+
+
     }
 }

+ 1 - 2
SCADA_DAQ/Customer/UctFrmCodeScanningGun.xaml.cs

@@ -109,9 +109,8 @@ namespace SCADA_DAQ.Customer
                 });
 
             }
-        }
-
 
+        }
     }
 }
 

+ 1 - 1
SCADA_DAQ/Env.cs

@@ -29,7 +29,7 @@ namespace SCADA_DAQ
         public static LocalDB.DIL.DILDB LocalDAL = null;   // 系统数据库
 
 
-        // SQL Server
+        //SQL Server
         public static SqlSchema.DIL.DILDB SgIDAL = new SqlSchema.DIL.DILDB("127.0.0.1", "TL_DB", "sa", "M+123456");
         //public static SqlSchema.DIL.DILDB SgIDAL = new SqlSchema.DIL.DILDB(@"10.255.254.250", "TL_DB", "sa", "M+123456");
 

File diff suppressed because it is too large
+ 1 - 0
SCADA_DAQ/SCADA_DAQ.csproj


Some files were not shown because too many files changed in this diff