Exemplo n.º 1
0
        public void SyncRead(object sender, EventArgs e)
        {
            tTimer.Stop();

            try
            {
                object ItemValues; object Quantities; object TimeStamps;//同步读取临时变量 值 质量 时间戳

                for (int i = 0; i < ModelList.Count; i++)
                {
                    opcItem[i].Read(1, out ItemValues, out Quantities, out TimeStamps);

                    if (Quantities.ToString() == "192")
                    {
                        Address            = ModelList[i].KepAddress;
                        myDcValue[Address] = ItemValues.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                tTimer.Start();
            }
            tTimer.Start();
        }
Exemplo n.º 2
0
        public void SyncRead(object sender, EventArgs e)
        {
            tTimer.Stop();
            string LabelName = string.Empty;

            try
            {
                object ItemValues; object Quantities; object TimeStamps;//同步读取临时变量 值 质量 时间戳

                for (int i = 0; i < paramClass.ParamList.Count; i++)
                {
                    opcItem[i].Read(1, out ItemValues, out Quantities, out TimeStamps);
                    if (Quantities.ToString() == "192")
                    {
                        LabelName = paramClass.ParamList[i].LabelName;

                        Type type = paramClass.GetType();                                          //获取类型
                        System.Reflection.PropertyInfo propertyInfo = type.GetProperty(LabelName); //获取指定名称的属性
                        //int value_Old = (int)propertyInfo.GetValue(paramClass, null); //获取属性值
                        if (propertyInfo != null)
                        {
                            propertyInfo.SetValue(paramClass, ItemValues.ToString(), null);                       //给对应属性赋值
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tTimer.Start();
            }
            tTimer.Start();
        }