zhuhao 1 year ago
parent
commit
c9461b1277

+ 2 - 0
IMCS_CCS/Entitys/CcsActionAddress.cs

@@ -42,6 +42,8 @@ namespace IMCS.CCS.Entitys
     {
         [EnumDescription("写入")] 
         WRITE,
+        [EnumDescription("二次写入")]
+        WRITE_SECOND,
         [EnumDescription("写入校验下一个是否条件写入")]
         WRITE_CHECK,
         [EnumDescription("校验")]

+ 24 - 1
IMCS_CCS/Service/Impl/HttpRequestService.cs

@@ -9,7 +9,6 @@ using IMCS.CCS.DeviceProtocol;
 using System;
 using S7.Net;
 using IMCS_CCS.Utils;
-using Newtonsoft.Json;
 using IMCS_CCS.Utils.DeviceProtocol;
 using HslCommunication.Profinet.Siemens;
 using Microsoft.Extensions.Configuration;
@@ -20,6 +19,7 @@ using HslCommunication;
 using System.Text.RegularExpressions;
 using System.IO;
 using System.Reflection;
+using Newtonsoft.Json;
 
 namespace IMCS.CCS.Services
 {
@@ -224,6 +224,29 @@ namespace IMCS.CCS.Services
                         }
                     }
                 }
+                //二次写入地址列表
+                List<CcsActionAddress> CcsActionAddressWriteSeconds = CcsActionAddresses.Where(o => o.Type == ActionAddressTypeEnum.WRITE_SECOND.ToString()).ToList();
+                foreach (CcsActionAddress actionAddress in CcsActionAddressWriteSeconds)
+                {
+                    if (!string.IsNullOrEmpty(actionAddress.Address))
+                    {
+                        if (string.IsNullOrEmpty(actionAddress.Value))
+                        {
+                            //取参数传参值
+                            string dataValue = getProperties(req.data, actionAddress.Description);
+                            if (!string.IsNullOrEmpty(dataValue))
+                            {
+                                s7.Write(actionAddress.Address, Convert.ToInt16(dataValue));
+                            }
+                        }
+                        else
+                        {
+                            s7.Write(actionAddress.Address, Convert.ToInt16(actionAddress.Value));
+                        }
+
+                        Thread.Sleep(SLEEP_TIME);
+                    }
+                }
                 s7.ConnectClose();
 
                 //插入回调

+ 8 - 1
IMCS_CCS/Service/Impl/TaskJobService.cs

@@ -387,7 +387,14 @@ namespace IMCS.CCS.Service.Impl
                             }
                            
                         }
-
+                        //执行位清零
+                        SiemensS7Net s7 = DevicePlcS7.SiemensS7(task.IP);
+                        HslCommunication.OperateResult ConnectionResult = s7.ConnectServer();
+                        if (ConnectionResult.IsSuccess)
+                        {
+                            s7.Write("DB2.10", Convert.ToInt16("0")); 
+                        }
+                        s7.ConnectClose();
                     }
                     //回调检测到失败,回调通知ecs
                     if (!string.IsNullOrEmpty(task.FailAddress) || !string.IsNullOrEmpty(task.FailAddress2) || !string.IsNullOrEmpty(task.FailAddress3))