Bläddra i källkod

东洋设备驱动

mengshunguo 1 månad sedan
förälder
incheckning
69345289f9
2 ändrade filer med 93 tillägg och 20 borttagningar
  1. 1 1
      SCADA_DAQ/App.config
  2. 92 19
      SCADA_DAQ/Customer/Machines/TOYOSampleMachine.cs

+ 1 - 1
SCADA_DAQ/App.config

@@ -69,7 +69,7 @@
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
-        <bindingRedirect oldVersion="0.0.0.0-8.0.1.1" newVersion="4.0.1.1" />
+        <bindingRedirect oldVersion="0.0.0.0-8.0.1.1" newVersion="4.0.1.2" />
       </dependentAssembly>
     </assemblyBinding>
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

+ 92 - 19
SCADA_DAQ/Customer/Machines/TOYOSampleMachine.cs

@@ -22,33 +22,106 @@ namespace SCADA_DAQ.Customer.Machines
         }
         public TOYOSampleMachine(IComm comm, int address)
         {
-            ListenReg.Add("报警触发时间", new RegInfo
-            { RegName = "报警触发时间",Protocol=this, RegKind = RegKind.IO,
-                Comment = new RegAnnotation { Variable = "报警触发时间", Annotation = "扫描周期(ms)", IsReadOnly = true } });
-            ListenReg.Add("报警代码", new RegInfo() { RegName = "报警代码", Comment = new RegAnnotation { } });
-            ListenReg.Add("报警信息", new RegInfo() { RegName = "报警信息", Comment = new RegAnnotation { } });
-            ListenReg.Add("报警DATA1", new RegInfo() { RegName = "报警DATA1", Comment = new RegAnnotation { } });
-            ListenReg.Add("报警DATA2", new RegInfo() { RegName = "报警DATA2", Comment = new RegAnnotation { } });
-            ListenReg.Add("模式触发时间", new RegInfo() { RegName = "模式触发时间", Comment = new RegAnnotation { } });
-            ListenReg.Add("模式代码", new RegInfo() { RegName = "模式代码", Comment = new RegAnnotation { } });
-            ListenReg.Add("模式信息", new RegInfo() { RegName = "模式信息", Comment = new RegAnnotation { } });
-            ListenReg.Add("产量推送时间", new RegInfo() { RegName = "产量推送时间", Comment = new RegAnnotation { } });
-            ListenReg.Add("产量信息", new RegInfo() { RegName = "产量信息", Comment = new RegAnnotation { } });
+            ListenReg.Add("报警时间", new RegInfo
+            {
+                RegName = "AlarmTime",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "AlarmTime", Annotation = "报警时间", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("报警代码", new RegInfo
+            {
+                RegName = "AlarmCode",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "AlarmCode", Annotation = "报警代码", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("报警信息", new RegInfo
+            {
+                RegName = "AlarmInfo",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "AlarmInfo", Annotation = "报警信息", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("报警DATA1", new RegInfo
+            {
+                RegName = "AlarmDATA1",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "AlarmDATA1", Annotation = "报警DATA1", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("报警DATA2", new RegInfo
+            {
+                RegName = "AlarmDATA2",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "AlarmDATA2", Annotation = "报警DATA2", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("模式切换时间", new RegInfo
+            {
+                RegName = "ModeTime",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "ModeTime", Annotation = "模式切换时间", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("模式代码", new RegInfo
+            {
+                RegName = "ModeCode",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "ModeCode", Annotation = "模式代码", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("模式信息", new RegInfo
+            {
+                RegName = "ModeInfo",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "ModeInfo", Annotation = "模式信息", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("产量推送时间", new RegInfo
+            {
+                RegName = "OutPutTime",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "OutPutTime", Annotation = "产量推送时间", IsReadOnly = true, ViewType = RegViewType.String }
+            });
+            ListenReg.Add("产量", new RegInfo
+            {
+                RegName = "OutPutQty",
+                Protocol = this,
+                RegKind = RegKind.IO,
+                StringValue = null,
+                Comment = new RegAnnotation { Variable = "OutPutQty", Annotation = "产量", IsReadOnly = true, ViewType = RegViewType.String }
+            });
             //comm.ResponseInfos = 
-            comm.ResponseInfos = new List<ResponseInfo>() { new ResponseInfo() { ResponseType = ResponseType.UnKnown } };
-            comm.DataReceived += Comm_DataReceived;
-            Comm = comm;
+            if (comm != null)
+            {
+                comm.ResponseInfos = new List<ResponseInfo>() { new ResponseInfo() { ResponseType = ResponseType.UnKnown } };
+                comm.DataReceived += Comm_DataReceived;
+                Comm = comm;
+            }
+
         }
         public TOYOSampleMachine(IComm comm, string address) : this(comm, 0)
         {
 
         }
 
-
-
         public override void Dispose()
         {
-            Comm.DataReceived -= Comm_DataReceived;
+            if (Comm != null)
+            {
+                Comm.DataReceived -= Comm_DataReceived;
+            }
             base.Dispose();
         }
         private void Comm_DataReceived(object sender, DataReceivedEventArg e)
@@ -70,7 +143,7 @@ namespace SCADA_DAQ.Customer.Machines
                     triggerTime = $"{receiveMSGArray[2]}/{receiveMSGArray[3]}";
                     schemaCode = receiveMSGArray[4];
                     patternCharacters = receiveMSGArray[5];
-                    ListenReg["模式触发时间"].StringValue = triggerTime;
+                    ListenReg["模式时间"].StringValue = triggerTime;
                     ListenReg["模式代码"].StringValue = schemaCode;
                     ListenReg["模式信息"].StringValue = patternCharacters;
                     //log($"收到设备模式数据,设备名{MachieID},触发时间{triggerTime},模式代码{schemaCode},模式字符{patternCharacters}");