| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:PLCModuleLogic.cs
- * 2.功能描述:发送信息到智能设备。
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈晓野 2018/10/18 1.00 新建
- *******************************************************************************/
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Net.Sockets;
- using System.Text;
- using Curtain.Core;
- using Curtain.DataAccess;
- using Curtain.Framework.Json;
- using Curtain.Net.Sockets.PLC;
- using Curtain.Net.Sockets.PLC.Model.Siemens;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.DataAccess;
- using Dongke.IBOSS.PRD.Service.DataModels;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Microsoft.Win32;
- using Newtonsoft.Json.Linq;
- namespace Dongke.IBOSS.PRD.Service.CMNModuleService
- {
- /// <summary>
- /// PLC相关处理
- /// </summary>
- public class PLCModuleLogic
- {
- #region 恒洁三水三车间工位对应PLC操作
- /// <summary>
- /// 恒洁三水三车间工位对应PLC操作 xuwei modify 2020-06-29
- /// </summary>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity DoPLCWorkByUser_HEGII_S3(SUserInfo sUserInfo, string barcode,
- int procedureid, int workStationType = 0, decimal weight = 0)
- {
- using (IDataAccess conn = DataAccess.Create())
- {
- //调用PLC的参数集合
- Hashtable plcPara = new Hashtable();
- try
- {
- //按当前登录用户在工位表中的当前工号查找工位类型
- workStationType = getWorkStationType(conn, sUserInfo.UserCode);
- DataTable dataTable = GetWorkStationInfo(conn, sUserInfo.UserCode);
- if (dataTable == null || dataTable.Rows.Count == 0)
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Message = "当前工号无工位信息" };
- }
- if (dataTable.Columns.Contains("PLC_FLAG"))
- {
- string plc_flag = dataTable.Rows[0]["PLC_FLAG"] + "";
- if (plc_flag != "1")
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- }
- workStationType = 3211;
- //成检交接3211
- if (workStationType == 3211)
- {
- //读取产品型号
- object goodsModel = conn.ExecuteScalar(@"
- SELECT
- g.SEATCOVERCODE
- FROM
- TP_PM_GROUTINGDAILYDETAIL p
- LEFT JOIN TP_MST_GOODS g ON g.GOODSID = p.GOODSID
- WHERE
- p.VALUEFLAG = '1'
- AND p.BARCODE = @BARCODE@
- ",
- new CDAParameter("BARCODE", barcode)
- );
- plcPara.Add("usercode", sUserInfo.UserCode);
- plcPara.Add("barcode", barcode);
- plcPara.Add("procedureid", procedureid);
- plcPara.Add("goodsmodel", goodsModel);
- plcPara.Add("finishflag", 1);
- return plcWrite(conn, sUserInfo.UserCode, workStationType, plcPara);
- }
- // 成检二检3212
- // 读取plc重量 add by fubin 2020-7-20
- if (workStationType == 3212)
- {
- if (weight > 0)
- {
- try
- {
- conn.ExecuteNonQuery(@"
- INSERT INTO tp_pm_goodsweighing
- (barcode
- ,groutingdailydetailid
- ,smartdevicepointcode
- ,procedureid
- ,goodsweight
- ,accountid
- ,createuserid)
- SELECT @barcode@
- ,gd.groutingdailydetailid
- ,'3_2_2'
- ,@procedureid@
- ,@goodsweight@
- ,@accountid@
- ,@userid@
- FROM tp_pm_groutingdailydetail gd
- WHERE gd.barcode = @barcode@",
- new CDAParameter("barcode", barcode),
- new CDAParameter("procedureid", procedureid),
- new CDAParameter("goodsweight", weight),
- new CDAParameter("accountid", sUserInfo.AccountID),
- new CDAParameter("userid", sUserInfo.UserID)
- );
- }
- catch (Exception)
- {
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Other,
- Message = "重量写入失败!"
- };
- }
- plcPara.Add("finishflag", 1);
- return plcWrite(conn, sUserInfo.UserCode, workStationType, plcPara);
- }
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success };
- }
- // 3#上水3320
- if (workStationType == 3320)
- {
- //读取产品型号
- object goodsModel = conn.ExecuteScalar(@"
- SELECT
- g.SEATCOVERCODE
- FROM
- TP_PM_GROUTINGDAILYDETAIL p
- LEFT JOIN TP_MST_GOODS g ON g.GOODSID = p.GOODSID
- WHERE
- p.VALUEFLAG = '1'
- AND p.BARCODE = @BARCODE@
- ",
- new CDAParameter("BARCODE", barcode)
- );
- if (goodsModel.ToInt32() == 0)
- {
- plcPara.Add("goodsmodel", 0);
- plcPara.Add("finishflag", 1);
- plcPara.Add("error", 1);
- }
- else
- {
- plcPara.Add("goodsmodel", goodsModel);
- plcPara.Add("finishflag", 1);
- plcPara.Add("error", 0);
- }
- return plcWrite(conn, sUserInfo.UserCode, workStationType, plcPara);
- }
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Message = "当前工号无工位信息" };
- }
- catch (Exception ex)
- {
- Curtain.Log.Logger.Error(ex);
- string plcParaStr = "";
- foreach (string key in plcPara.Keys) plcParaStr += " " + key + ":" + plcPara[key].ToString() + " ";
- #if DEBUG
- Curtain.Log.Logger.Debug("PLC写入失败!" + plcParaStr);
- #endif
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Other,
- Message = "PLC写入失败!" + plcParaStr
- };
- }
- finally
- {
- conn?.Close();
- }
- }
- }
- /// <summary>
- /// 恒洁三水三车间成检二检获取PLC重量 fubin add 2020-07-20
- /// </summary>
- /// <param name="sUserInfo"></param>
- /// <returns></returns>
- public static ServiceResultEntity ReadPLCWeightByUser_HEGII_S3(SUserInfo sUserInfo)
- {
- using (IDataAccess conn = DataAccess.Create())
- {
- //调用PLC的参数集合
- Hashtable plcPara = new Hashtable();
- try
- {
- //按当前登录用户在工位表中的当前工号查找工位类型
- int workStationType = getWorkStationType(conn, sUserInfo.UserCode);
- // 成检二检3212
- // 读取plc重量 add by fubin 2020-7-20
- if (workStationType == 3212)
- {
- return plcRead(conn, sUserInfo.UserCode, workStationType);
- }
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Result = 0 };
- }
- catch (Exception ex)
- {
- Curtain.Log.Logger.Error(ex);
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Result = 0 };
- }
- finally
- {
- conn?.Close();
- }
- }
- }
- /// <summary>
- /// 获取工位类型ID xuwei add 2020-06-29
- /// </summary>
- /// <param name="conn"></param>
- /// <param name="userCode"></param>
- /// <returns></returns>
- private static int getWorkStationType(IDataAccess conn, string userCode)
- {
- return Convert.ToInt32(conn.ExecuteScalar(@"
- SELECT
- t.WORKSTATIONTYPEID
- FROM
- TP_MST_WORKSTATION w
- LEFT JOIN TP_SYS_WORKSTATIONTYPE t ON w.WORKSTATIONTYPEID = t.WORKSTATIONTYPEID
- WHERE
- w.USERCODE = @USERCODE@
- ",
- new CDAParameter("USERCODE", userCode)
- ));
- }
- private static DataTable GetWorkStationInfo(IDataAccess conn, string userCode)
- {
- DataTable dataTable = conn.ExecuteDatatable(@"
- SELECT
- t.workstationid,
- t.workstationtypeid,
- t.workstationname,
- t.procedureid,
- t.groutinglineid,
- t.usercode,
- t.pccode,
- t.plcip,
- t.plcport,
- t.plcobject,
- t.valueflag,
- t.plcobjectread,
- t.plc_flag
- FROM
- TP_MST_WORKSTATION t
- WHERE
- t.USERCODE =@USERCODE@
- ",
- //new CDAParameter("WORKSTATIONTYPE", workStationType),
- new CDAParameter("USERCODE", userCode)
- );
- return dataTable;
- }
- /// <summary>
- /// 写PLC xuwei add 2020-06-29
- /// </summary>
- /// <param name="conn"></param>
- /// <param name="userCode"></param>
- /// <param name="workStationType"></param>
- /// <param name="plcPara"></param>
- /// <returns></returns>
- private static ServiceResultEntity plcWrite(IDataAccess conn, string userCode, int workStationType, Hashtable plcPara)
- {
- //读取工位配置信息
- DataTable dataTable = conn.ExecuteDatatable(@"
- SELECT --t.*
- t.workstationtypeid,
- t.workstationname,
- t.procedureid,
- t.groutinglineid,
- t.usercode,
- t.pccode,
- t.plcip,
- t.plcport,
- t.plcobject,
- t.valueflag,
- t.plcobjectread,
- t.plc_flag
- FROM
- TP_MST_WORKSTATION t
- WHERE
- t.WORKSTATIONTYPEID = @WORKSTATIONTYPE@
- AND t.USERCODE =@USERCODE@
- ",
- new CDAParameter("WORKSTATIONTYPE", workStationType),
- new CDAParameter("USERCODE", userCode)
- );
- if (dataTable == null || dataTable.Rows.Count == 0)
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Message = "当前工号无工位信息" };
- }
- if (dataTable.Columns.Contains("PLC_FLAG"))
- {
- string plc_flag = dataTable.Rows[0]["PLC_FLAG"] + "";
- if (plc_flag != "1")
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- }
- string ip = dataTable.Rows[0]["PLCIP"] + "";
- if (string.IsNullOrWhiteSpace(ip))
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- int port = Convert.ToInt32(dataTable.Rows[0]["PLCPORT"]);
- JArray plcObj = JArray.Parse(dataTable.Rows[0]["PLCOBJECT"].ToString());
- //写入PLC
- using (SocketClient<SiemensS7_1200Model> plc = new SocketClient<SiemensS7_1200Model>())
- {
- //测试静态数据 测试成功
- //plc.Connect(ip, port);
- //plc.Write<string>("D", "102.2", "2020070101");
- //plc.Write<short>("D", "102.14", Convert.ToInt16(10));
- //手动写
- //plc.Connect(ip, port);
- //plc.Write<string>("D", "102.2", plcPara["barcode"].ToString());
- //plc.Write<short>("D", "102.14", Convert.ToInt16(plcPara["goodsmodel"]));
- //自动按配置写
- plc.Connect(ip, port);
- for (int i = 0; i < plcObj.Count; i++)
- {
- if (plcObj[i]["type"].ToString().ToLower() == "string")
- plc.Write<string>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), plcPara[plcObj[i]["name"].ToString()].ToString());
- else if (plcObj[i]["type"].ToString().ToLower() == "int")
- plc.Write<short>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), Convert.ToInt16(plcPara[plcObj[i]["name"].ToString()]));
- }
- }
- #if DEBUG
- //写入操作成功日志
- string plcParaStr = "";
- foreach (string key in plcPara.Keys) plcParaStr += " " + key + ":" + plcPara[key].ToString() + " ";
- Curtain.Log.Logger.Debug("PLC写入成功!" + plcParaStr);
- #endif
- //PLC操作成功
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Success,
- Message = "" //一定不可以有值,为空时才是提交成功
- };
- }
- /// <summary>
- /// 读取PLC
- /// </summary>
- /// <param name="conn"></param>
- /// <param name="workStationID"></param>
- /// <returns></returns>
- private static ServiceResultEntity plcRead(IDataAccess conn, string userCode, int workStationType)
- {
- try
- {
- //读取工位配置信息
- DataTable dataTable = conn.ExecuteDatatable(@"
- SELECT --t.*
- t.workstationtypeid,
- t.workstationname,
- t.procedureid,
- t.groutinglineid,
- t.usercode,
- t.pccode,
- t.plcip,
- t.plcport,
- t.plcobject,
- t.valueflag,
- t.plcobjectread,
- t.plc_flag
- FROM
- TP_MST_WORKSTATION t
- WHERE
- t.WORKSTATIONTYPEID = @WORKSTATIONTYPE@
- AND t.USERCODE =@USERCODE@
- ",
- new CDAParameter("WORKSTATIONTYPE", workStationType),
- new CDAParameter("USERCODE", userCode)
- );
- if (dataTable == null || dataTable.Rows.Count == 0)
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Message = "当前工号无工位信息" };
- }
- if (dataTable.Columns.Contains("PLC_FLAG"))
- {
- string plc_flag = dataTable.Rows[0]["PLC_FLAG"] + "";
- if (plc_flag != "1")
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- }
- string ip = dataTable.Rows[0]["PLCIP"] + "";
- if (string.IsNullOrWhiteSpace(ip))
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- int port = Convert.ToInt32(dataTable.Rows[0]["PLCPORT"]);
- JArray plcObj = JArray.Parse(dataTable.Rows[0]["PLCOBJECTREAD"].ToString());
- // 读取PLC
- using (SocketClient<SiemensS7_1200Model> plc = new SocketClient<SiemensS7_1200Model>())
- {
- //自动按配置写
- plc.Connect(ip, port);
- for (int i = 0; i < plcObj.Count; i++)
- {
- if (plcObj[i]["type"].ToString().ToLower() == "float")
- {
- PLCResult<float> result = plc.Read<float>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString());
- plcObj[i]["weight"] = result.Data;
- }
- }
- }
- #if DEBUG
- //写入操作成功日志
- Curtain.Log.Logger.Debug("PLC读取成功!" + plcObj.ToJson());
- #endif
- //PLC操作成功
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Success,
- Message = "", //一定不可以有值,为空时才是提交成功
- Result = plcObj
- };
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- /// <summary>
- /// 写PLC2 xuwei modify 2022-09-10 优化代码
- /// </summary>
- /// <param name="workStationType"></param>
- /// <param name="plcPara"></param>
- /// <param name="userCode"></param>
- /// <returns></returns>
- public static ServiceResultEntity PlcWrite2(int workStationType, Hashtable plcPara, string userCode = null)
- {
- using (IDataAccess conn = DataAccess.Create())
- {
- List<CDAParameter> paras = new List<CDAParameter>();
- #region 读取工位配置信息
- string sql = @"
- SELECT
- T.WORKSTATIONTYPEID,
- T.WORKSTATIONNAME,
- T.PROCEDUREID,
- T.GROUTINGLINEID,
- T.USERCODE,
- T.PCCODE,
- T.PLCIP,
- T.PLCPORT,
- T.PLCOBJECT,
- T.VALUEFLAG,
- T.PLCOBJECTREAD,
- T.PLC_FLAG
- FROM
- TP_MST_WORKSTATION T
- WHERE
- T.PLC_FLAG = 1
- AND T.WORKSTATIONTYPEID = @WORKSTATIONTYPE@
- ";
- paras.Add(new CDAParameter("WORKSTATIONTYPE", workStationType));
- if (!string.IsNullOrEmpty(userCode))
- {
- sql += " AND T.USERCODE = @USERCODE@";
- paras.Add(new CDAParameter("USERCODE", userCode));
- }
- DataTable dataTable = conn.ExecuteDatatable(sql, paras.ToArray());
- if (dataTable == null || dataTable.Rows.Count == 0)
- {
- //xuwei modify 2022-02-18
- //return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Message = "无当前工位信息" };
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Success,
- Message = "" //一定不可以有值,为空时才是提交成功
- };
- //xuwei end
- }
- #endregion
- string ip = dataTable.Rows[0]["PLCIP"] + "";
- if (string.IsNullOrWhiteSpace(ip))
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- int port = Convert.ToInt32(dataTable.Rows[0]["PLCPORT"]);
- JArray plcObj = JArray.Parse(dataTable.Rows[0]["PLCOBJECT"].ToString());
- //xuwei modify 2021-11-23 写入PLC增加try catch 获得准确提示===================
- try
- {
- //写入PLC
- using (SocketClient<SiemensS7_1200Model> plc = new SocketClient<SiemensS7_1200Model>())
- {
- //自动按配置写
- plc.Connect(ip, port);
- for (int i = 0; i < plcObj.Count; i++)
- {
- if (plcObj[i]["type"].ToString().ToLower() == "string")
- plc.Write<string>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), plcPara[plcObj[i]["name"].ToString()].ToString());
- else if (plcObj[i]["type"].ToString().ToLower() == "int")
- plc.Write<short>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), Convert.ToInt16(plcPara[plcObj[i]["name"].ToString()]));
- else if (plcObj[i]["type"].ToString().ToLower() == "bool")
- plc.Write<bool>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), Convert.ToBoolean(plcPara[plcObj[i]["name"].ToString()]));
- }
- }
- //PLC操作成功
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Success,
- Message = "" //一定不可以有值,为空时才是提交成功
- };
- }
- catch
- {
- //PLC写入失败!
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Other,
- Message = "PLC(" + ip + ")写入错误!" //一定不可以有值,为空时才是提交成功
- };
- }
- //=======================================================================
- }
- }
-
- /// <summary>
- /// 写PLC 成型线放行
- /// </summary>
- /// <param name="workStationType"></param>
- /// <param name="plcPara"></param>
- /// <param name="userCode"></param>
- /// <returns></returns>
- public static ServiceResultEntity PlcWrite_GL(int workStationType, int gl_id,
- Hashtable plcPara, string userCode = null)
- {
- using (IDataAccess conn = DataAccess.Create())
- {
- List<CDAParameter> paras = new List<CDAParameter>();
- #region 读取工位配置信息
- string sql =
- "SELECT --t.*\n" + @"
- t.workstationtypeid,
- t.workstationname,
- t.procedureid,
- t.groutinglineid,
- t.usercode,
- t.pccode,
- t.plcip,
- t.plcport,
- t.plcobject,
- t.valueflag,
- t.plcobjectread,
- t.plc_flag" +
- " FROM tp_mst_workstation t\n" +
- " WHERE t.workstationtypeid = @workstationtype@\n" +
- " AND t.GROUTINGLINEID = @GROUTINGLINEID@\n"
- ;
- paras.Add(new CDAParameter("workstationtype", workStationType));
- paras.Add(new CDAParameter("GROUTINGLINEID", gl_id));
- if (!string.IsNullOrEmpty(userCode))
- {
- sql += " AND t.usercode = @usercode@";
- paras.Add(new CDAParameter("usercode", userCode));
- }
- DataTable dataTable = conn.ExecuteDatatable(sql, paras.ToArray());
- if (dataTable == null || dataTable.Rows.Count == 0)
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Other, Message = "无当前工位信息" };
- }
- if (dataTable.Columns.Contains("PLC_FLAG"))
- {
- string plc_flag = dataTable.Rows[0]["PLC_FLAG"] + "";
- if (plc_flag != "1")
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- }
- #endregion
- string ip = dataTable.Rows[0]["PLCIP"] + "";
- if (string.IsNullOrWhiteSpace(ip))
- {
- return new ServiceResultEntity() { Status = Constant.ServiceResultStatus.Success, Message = "" /*"PLC对接未启用"*/ };
- }
- int port = Convert.ToInt32(dataTable.Rows[0]["PLCPORT"]);
- JArray plcObj = JArray.Parse(dataTable.Rows[0]["PLCOBJECT"].ToString());
- //写入PLC
- using (SocketClient<SiemensS7_1200Model> plc = new SocketClient<SiemensS7_1200Model>())
- {
- //自动按配置写
- plc.Connect(ip, port);
- for (int i = 0; i < plcObj.Count; i++)
- {
- if (plcObj[i]["type"].ToString().ToLower() == "string")
- plc.Write<string>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), plcPara[plcObj[i]["name"].ToString()].ToString());
- else if (plcObj[i]["type"].ToString().ToLower() == "int")
- plc.Write<short>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), Convert.ToInt16(plcPara[plcObj[i]["name"].ToString()]));
- else if (plcObj[i]["type"].ToString().ToLower() == "bool")
- plc.Write<bool>(plcObj[i]["code"].ToString(), plcObj[i]["number"].ToString(), Convert.ToBoolean(plcPara[plcObj[i]["name"].ToString()]));
- }
- }
- #if DEBUG
- //写入操作成功日志
- string plcParaStr = "";
- foreach (string key in plcPara.Keys)
- {
- plcParaStr += " " + key + ":" + plcPara[key].ToString() + " ";
- }
- Curtain.Log.Logger.Debug($"PLC写入成功!{plcParaStr} {ip} {userCode} {plcObj.ToString()}");
- #endif
- //PLC操作成功
- return new ServiceResultEntity()
- {
- Status = Constant.ServiceResultStatus.Success,
- Message = "" //一定不可以有值,为空时才是提交成功
- };
- }
- }
- }
- }
|