using System; using System.Collections.Generic; using System.Text; using System.Data; using ICommLayer; using DBFactory; namespace FINSTCPIP { /// /// 20210405 FINS 协议通讯接口派生类 /// 获取设备状态类 /// 创建者:zcy /// public class CGetDeviceState : IGetDeviceState { static StringBuilder sql = new StringBuilder(); static DataView dv = new DataView(); //public static DBOperator dbo = new DBOperator();//20130926 string _commLayerError; public string CommLayerError { get { return _commLayerError; } set { _commLayerError = value; } } public static DBOperator dbo = CommonClassLib.AppSettings.dbo; //20130510 public DBOperator dboM = CommonClassLib.AppSettings.dboM; //20130510 public static Dictionary SendCounts = new Dictionary(); public CGetDeviceState() { dbo.Open(); } //~CGetDeviceState() //{ // dbo.Close(); //} /// /// 向 PLC 发送读请求 /// public int[] GetDeviceState(int DeviceIndex, int TaskIndex) { try { sql.Clear(); sql.Append("select f_remoteip from V_RGVINFO where F_DeviceIndex = ").Append(DeviceIndex); dv = dbo.ExceSQL(sql.ToString()).Tables[0].DefaultView; if (dv.Count > 0) { string ip = dv[0]["f_remoteip"].ToString(); { //byte[] data = ClientCommunication.clientFinss[ip].GetInfo_DMRead(2100, 30); ClientCommunication.socketFinss[ip].Send(ClientCommunication.SC_RGV_READ_DATA[ip], null); if (SendCounts.ContainsKey(ip) == true) { if (SendCounts[ip] < 3600 * 24 * 7) { SendCounts[ip]++; } else { SendCounts[ip] = 1; } } else { SendCounts.Add(ip, 0); } } } return null; } catch (Exception ex) { _commLayerError = this.ToString() + ":GetDeviceState---" + ex.Message; return null; } finally { dv.Dispose(); } } public string GetStringData(int DeviceIndex, int TaskIndex) { return ""; } } }