コード例 #1
0
        private void AddNotificationToSubscription(ExtendedNotificationModel notification)
        {
            notification.DataType = _uaClientApi.GetBuiltInTypeOfVariableNodeId(notification.NodeId);

            MonitoredItem item;

            var notificationEntity = new NotificationEntity()
            {
                Id        = notification.Id ?? -1,
                Name      = notification.Name,
                NodeId    = notification.NodeId,
                ProjectId = IoC.AppManager.ProjectId,
            };

            if (notification.IsDigital)
            {
                item = _uaClientApi.CreateMonitoredItem(notification.Name, notification.NodeId, 100);

                notificationEntity.IsDigital         = true;
                notificationEntity.IsZeroDescription = notification.IsZeroDescription;
                notificationEntity.IsOneDescription  = notification.IsOneDescription;
            }
            else
            {
                item = _uaClientApi.CreateMonitoredItem(notification.Name,
                                                        notification.NodeId,
                                                        100,
                                                        new DataChangeFilter()
                {
                    DeadbandType  = (uint)notification.DeadbandType,
                    DeadbandValue = notification.FilterValue,
                    Trigger       = DataChangeTrigger.StatusValue
                });

                notificationEntity.FilterValue  = notification.FilterValue;
                notificationEntity.DeadbandType = notification.DeadbandType;
            }

            if (_uaClientApi.AddMonitoredItem(item, _subscription) == false)
            {
                IoC.AppManager.ShowWarningMessage("Notification could not be created!");
            }
            else
            {
                item.Notification += Notification_MonitoredItem;
                if (notification.Id == null)
                {
                    notification.Id = _unitOfWork.Notifications.Add(notificationEntity).Id;
                }
                Notifications.Add(notification);
            }
        }
コード例 #2
0
 public SendNewNotification(ExtendedNotificationModel notification)
 {
     Notification = notification;
 }