Esempio n. 1
0
        /// <summary>
        /// 初始化参数同时添加订阅
        /// </summary>
        /// <param name="opc"></param>
        public OPCRobotParam(IOpcClient opc)
        {
            var dt = OPCParam.Query($"where Class='{CFG}'");

            if (dt == null || dt.Rows.Count < 1)
            {
                return;
            }
            foreach (DataRow dr in dt.Rows)
            {
                foreach (PropertyInfo property in typeof(OPCRobotParam).GetProperties())
                {
                    if (property.Name == dr["Name"].ToString())
                    {
                        property.SetValue(this,dr["Code"].ToString());
                        opc.AddSubscription(dr["Code"].ToString());
                    }
                }
            }

            PlcSnA = new PlcSignal();
            PlcSnA.LoadSN(ReadSignalA,WriteSignalA);

            PlcSnB = new PlcSignal();
            PlcSnB.LoadSN(ReadSignalB,WriteSignalB);
        }
Esempio n. 2
0
        /// <summary>
        /// 初始化参数同时添加订阅
        /// </summary>
        /// <param name="opc"></param>
        public OPCWeighParam(IOpcClient opc)
        {
            var dt = OPCParam.Query($"where Class='{CFG}'");

            FrmMain.logOpt.Write(JsonConvert.SerializeObject(dt),LogType.NORMAL,LogViewType.OnlyFile);
            if (dt == null || dt.Rows.Count < 1)
            {
                return;
            }
            foreach (DataRow dr in dt.Rows)
            {
                foreach (PropertyInfo property in typeof(OPCWeighParam).GetProperties())
                {
                    if (property.Name == dr["Name"].ToString())
                    {
                        property.SetValue(this,dr["Code"].ToString());
                        opc.AddSubscription(dr["Code"].ToString());
                    }
                }
            }

            PlcSn = new PlcSignal();
            PlcSn.LoadSN(ReadSignal,WriteSignal);
        }