Beispiel #1
0
        private void ItemChanged(MonitoredItem monitoreditem, MonitoredItemNotificationEventArgs e)
        {
            MonitoredItemNotification notification = e.NotificationValue as MonitoredItemNotification;

            if (notification != null)
            {
                string nodeid = monitoreditem.StartNodeId.Identifier.ToString();
                if (!_SubscriptionTags.ContainsKey(nodeid))
                {
                    throw (new Exception(string.Format("订阅回调触发,但是_SubscriptionTags不包含键;key:{0}", nodeid)));
                }
                TagItem item = _SubscriptionTags[nodeid];
                if (item == null)
                {
                    throw (new Exception(string.Format("订阅回调触发,但是未找到键对应TagItem对象;key:{0},value:null", nodeid)));
                }
                if (item.CallBack == null)
                {
                    return;
                }
                item.CBType    = TagItem.CallBackType.Subscription;
                item.Value     = notification.Value.Value;
                item.Timestamp = notification.Value.SourceTimestamp;
                item.Quality   = notification.Value.StatusCode.ToString();
                item.CallBack(item);
            }
        }
Beispiel #2
0
        private void _OpcDaGroup_AsyncReadCompleteEvent(Item item)
        {
            TagItem tag = _TagItems[item.Name];

            if (tag == null)
            {
                return;
            }
            if (tag.CallBack == null)
            {
                return;
            }
            tag.Value     = item.Value;
            tag.Quality   = item.Quality.ToString();
            tag.Timestamp = DateTime.Parse(item.Timesnamp.ToString());
            tag.CBType    = TagItem.CallBackType.AsyncRead;
            tag.CallBack(tag);
        }
Beispiel #3
0
        private void _OpcDaGroup_DataChangeEvent(Item item)
        {
            TagItem tag = _TagItems[item.Name];

            if (tag == null)
            {
                return;
            }
            if (tag.CallBack == null)
            {
                return;
            }
            tag.Value     = item.Value;
            tag.Quality   = item.Quality.ToString();
            tag.Timestamp = DateTime.Parse(item.Timesnamp.ToString());
            tag.CBType    = TagItem.CallBackType.Subscription;
            tag.CallBack(tag);
        }