/// <summary>
        /// Creates an instance of an event.
        /// </summary>
        public BaseEventState CreateInstance(ServerSystemContext context, AeEventTypeState eventType)
        {
            BaseEventState instance = null;

            switch (eventType.EventType.EventTypeMapping)
            {
            case EventTypeMapping.AlarmConditionType: { instance = new AlarmConditionState(null); break; }

            case EventTypeMapping.AuditEventType: { instance = new AuditEventState(null); break; }

            case EventTypeMapping.BaseEventType: { instance = new BaseEventState(null); break; }

            case EventTypeMapping.DeviceFailureEventType: { instance = new DeviceFailureEventState(null); break; }

            case EventTypeMapping.DiscreteAlarmType: { instance = new DiscreteAlarmState(null); break; }

            case EventTypeMapping.NonExclusiveDeviationAlarmType: { instance = new NonExclusiveDeviationAlarmState(null); break; }

            case EventTypeMapping.ExclusiveLevelAlarmType: { instance = new ExclusiveLevelAlarmState(null); break; }

            case EventTypeMapping.LimitAlarmType: { instance = new LimitAlarmState(null); break; }

            case EventTypeMapping.NonExclusiveLevelAlarmType: { instance = new NonExclusiveLevelAlarmState(null); break; }

            case EventTypeMapping.OffNormalAlarmType: { instance = new OffNormalAlarmState(null); break; }

            case EventTypeMapping.SystemEventType: { instance = new SystemEventState(null); break; }

            case EventTypeMapping.TripAlarmType: { instance = new TripAlarmState(null); break; }
            }

            return(instance);
        }
Example #2
0
        /// <summary>
        /// Creates an instance of an event.
        /// </summary>
        public BaseEventState CreateInstance(ServerSystemContext context, AeEventTypeState eventType)
        {
            BaseEventState instance = null;

            switch (eventType.EventType.EventTypeMapping)
            {
                case EventTypeMapping.AlarmConditionType: { instance = new AlarmConditionState(null); break; }
                case EventTypeMapping.AuditEventType: { instance = new AuditEventState(null); break; }
                case EventTypeMapping.BaseEventType: { instance = new BaseEventState(null); break; }
                case EventTypeMapping.DeviceFailureEventType: { instance = new DeviceFailureEventState(null); break; }
                case EventTypeMapping.DiscreteAlarmType: { instance = new DiscreteAlarmState(null); break; }
                case EventTypeMapping.NonExclusiveDeviationAlarmType: { instance = new NonExclusiveDeviationAlarmState(null); break; }
                case EventTypeMapping.ExclusiveLevelAlarmType: { instance = new ExclusiveLevelAlarmState(null); break; }
                case EventTypeMapping.LimitAlarmType: { instance = new LimitAlarmState(null); break; }
                case EventTypeMapping.NonExclusiveLevelAlarmType: { instance = new NonExclusiveLevelAlarmState(null); break; }
                case EventTypeMapping.OffNormalAlarmType: { instance = new OffNormalAlarmState(null); break; }
                case EventTypeMapping.SystemEventType: { instance = new SystemEventState(null); break; }
                case EventTypeMapping.TripAlarmType: { instance = new TripAlarmState(null); break; }
            }

            return instance;
        }
        private ConditionState CreateAlarmOrCondition(SimAlarmStateBackend alarm, NodeId branchId)
        {
            ISystemContext context = _nodeManager.SystemContext;

            ConditionState node;

            // Condition
            if (alarm.AlarmType == AlarmObjectStates.ConditionType)
            {
                node = new ConditionState(this);
            }
            // All alarms inherent from AlarmConditionState
            else
            {
                switch (alarm.AlarmType)
                {
                case AlarmObjectStates.TripAlarmType:
                    node = new TripAlarmState(this);
                    break;

                case AlarmObjectStates.LimitAlarmType:
                    node = new LimitAlarmState(this);
                    break;

                case AlarmObjectStates.OffNormalAlarmType:
                    node = new OffNormalAlarmState(this);
                    break;

                default:
                    node = new AlarmConditionState(this);
                    break;
                }

                // create elements that conditiontype doesn't have
                CreateAlarmSpecificElements(context, (AlarmConditionState)node, branchId);
            }

            CreateCommonFieldsForAlarmAndCondition(context, node, alarm, branchId);

            // This call initializes the condition from the type model (i.e. creates all of the objects
            // and variables requried to store its state). The information about the type model was
            // incorporated into the class when the class was created.
            //
            // This method also assigns new NodeIds to all of the components by calling the INodeIdFactory.New
            // method on the INodeIdFactory object which is part of the system context. The NodeManager provides
            // the INodeIdFactory implementation used here.
            node.Create(
                context,
                null,
                new QualifiedName(alarm.Name, this.BrowseName.NamespaceIndex),
                null,
                true);

            // initialize event information.node
            node.EventType.Value     = node.TypeDefinitionId;
            node.SourceNode.Value    = this.NodeId;
            node.SourceName.Value    = this.SymbolicName;
            node.ConditionName.Value = node.SymbolicName;
            node.Time.Value          = DateTime.UtcNow;
            node.ReceiveTime.Value   = node.Time.Value;
            node.BranchId.Value      = branchId;

            // don't add branches to the address space.
            if (NodeId.IsNull(branchId))
            {
                this.AddChild(node);
            }

            return(node);
        }
        /// <summary>
        /// Creates a new alarm for the source.
        /// </summary>
        /// <param name="alarm">The alarm.</param>
        /// <param name="branchId">The branch id.</param>
        /// <returns>The new alarm.</returns>
        private AlarmConditionState CreateAlarm(UnderlyingSystemAlarm alarm, NodeId branchId)
        {
            ISystemContext context = m_nodeManager.SystemContext;

            AlarmConditionState node = null;

            // need to map the alarm type to a UA defined alarm type.
            switch (alarm.AlarmType)
            {
            case "HighAlarm":
            {
                ExclusiveDeviationAlarmState node2 = new ExclusiveDeviationAlarmState(this);
                node            = node2;
                node2.HighLimit = new PropertyState <double>(node2);
                break;
            }

            case "HighLowAlarm":
            {
                NonExclusiveLevelAlarmState node2 = new NonExclusiveLevelAlarmState(this);
                node = node2;

                node2.HighHighLimit = new PropertyState <double>(node2);
                node2.HighLimit     = new PropertyState <double>(node2);
                node2.LowLimit      = new PropertyState <double>(node2);
                node2.LowLowLimit   = new PropertyState <double>(node2);

                node2.HighHighState = new TwoStateVariableState(node2);
                node2.HighState     = new TwoStateVariableState(node2);
                node2.LowState      = new TwoStateVariableState(node2);
                node2.LowLowState   = new TwoStateVariableState(node2);

                break;
            }

            case "TripAlarm":
            {
                node = new TripAlarmState(this);
                break;
            }

            default:
            {
                node = new AlarmConditionState(this);
                break;
            }
            }

            node.SymbolicName = alarm.Name;

            // add optional components.
            node.Comment        = new ConditionVariableState <LocalizedText>(node);
            node.ClientUserId   = new PropertyState <string>(node);
            node.AddComment     = new AddCommentMethodState(node);
            node.ConfirmedState = new TwoStateVariableState(node);
            node.Confirm        = new AddCommentMethodState(node);

            if (NodeId.IsNull(branchId))
            {
                node.SuppressedState = new TwoStateVariableState(node);
                node.ShelvingState   = new ShelvedStateMachineState(node);
            }

            // adding optional components to children is a little more complicated since the
            // necessary initilization strings defined by the class that represents the child.
            // in this case we pre-create the child, add the optional components
            // and call create without assigning NodeIds. The NodeIds will be assigned when the
            // parent object is created.
            node.EnabledState = new TwoStateVariableState(node);
            node.EnabledState.TransitionTime       = new PropertyState <DateTime>(node.EnabledState);
            node.EnabledState.EffectiveDisplayName = new PropertyState <LocalizedText>(node.EnabledState);
            node.EnabledState.Create(context, null, BrowseNames.EnabledState, null, false);

            // same procedure add optional components to the ActiveState component.
            node.ActiveState = new TwoStateVariableState(node);
            node.ActiveState.TransitionTime       = new PropertyState <DateTime>(node.ActiveState);
            node.ActiveState.EffectiveDisplayName = new PropertyState <LocalizedText>(node.ActiveState);
            node.ActiveState.Create(context, null, BrowseNames.ActiveState, null, false);

            // specify reference type between the source and the alarm.
            node.ReferenceTypeId = ReferenceTypeIds.HasComponent;

            // This call initializes the condition from the type model (i.e. creates all of the objects
            // and variables requried to store its state). The information about the type model was
            // incorporated into the class when the class was created.
            //
            // This method also assigns new NodeIds to all of the components by calling the INodeIdFactory.New
            // method on the INodeIdFactory object which is part of the system context. The NodeManager provides
            // the INodeIdFactory implementation used here.
            node.Create(
                context,
                null,
                new QualifiedName(alarm.Name, this.BrowseName.NamespaceIndex),
                null,
                true);

            // don't add branches to the address space.
            if (NodeId.IsNull(branchId))
            {
                this.AddChild(node);
            }

            // initialize event information.node
            node.EventType.Value     = node.TypeDefinitionId;
            node.SourceNode.Value    = this.NodeId;
            node.SourceName.Value    = this.SymbolicName;
            node.ConditionName.Value = node.SymbolicName;
            node.Time.Value          = DateTime.UtcNow;
            node.ReceiveTime.Value   = node.Time.Value;
            node.BranchId.Value      = branchId;

            // set up method handlers.
            node.OnEnableDisable = OnEnableDisableAlarm;
            node.OnAcknowledge   = OnAcknowledge;
            node.OnAddComment    = OnAddComment;
            node.OnConfirm       = OnConfirm;
            node.OnShelve        = OnShelve;
            node.OnTimedUnshelve = OnTimedUnshelve;

            // return the new node.
            return(node);
        }
Example #5
0
        /// <summary>
        /// Creates a new alarm for the source.
        /// </summary>
        /// <param name="alarm">The alarm.</param>
        /// <param name="branchId">The branch id.</param>
        /// <returns>The new alarm.</returns>
        private AlarmConditionState CreateAlarm(UnderlyingSystemAlarm alarm, NodeId branchId)
        {
            ISystemContext context = m_nodeManager.SystemContext;

            AlarmConditionState node = null;

            // need to map the alarm type to a UA defined alarm type.
            switch (alarm.AlarmType)
            {
                case "HighAlarm":
                {
                    ExclusiveDeviationAlarmState node2 = new ExclusiveDeviationAlarmState(this);
                    node = node2;
                    node2.HighLimit = new PropertyState<double>(node2);
                    break;
                }

                case "HighLowAlarm":
                {
                    NonExclusiveLevelAlarmState node2 = new NonExclusiveLevelAlarmState(this);
                    node = node2;

                    node2.HighHighLimit = new PropertyState<double>(node2);
                    node2.HighLimit = new PropertyState<double>(node2);
                    node2.LowLimit = new PropertyState<double>(node2);
                    node2.LowLowLimit = new PropertyState<double>(node2);

                    node2.HighHighState = new TwoStateVariableState(node2);
                    node2.HighState = new TwoStateVariableState(node2);
                    node2.LowState = new TwoStateVariableState(node2);
                    node2.LowLowState = new TwoStateVariableState(node2);

                    break;
                }
                    
                case "TripAlarm":
                {
                    node = new TripAlarmState(this);
                    break;
                }

                default:
                {
                    node = new AlarmConditionState(this);
                    break;
                }
            }

            node.SymbolicName = alarm.Name;

            // add optional components.
            node.Comment = new ConditionVariableState<LocalizedText>(node);
            node.ClientUserId = new PropertyState<string>(node);
            node.AddComment = new AddCommentMethodState(node);
            node.ConfirmedState = new TwoStateVariableState(node);
            node.Confirm = new AddCommentMethodState(node);

            if (NodeId.IsNull(branchId))
            {
                node.SuppressedState = new TwoStateVariableState(node);
                node.ShelvingState = new ShelvedStateMachineState(node);
            }

            // adding optional components to children is a little more complicated since the 
            // necessary initilization strings defined by the class that represents the child.
            // in this case we pre-create the child, add the optional components
            // and call create without assigning NodeIds. The NodeIds will be assigned when the
            // parent object is created.
            node.EnabledState = new TwoStateVariableState(node);
            node.EnabledState.TransitionTime = new PropertyState<DateTime>(node.EnabledState);
            node.EnabledState.EffectiveDisplayName = new PropertyState<LocalizedText>(node.EnabledState);
            node.EnabledState.Create(context, null, BrowseNames.EnabledState, null, false);

            // same procedure add optional components to the ActiveState component.
            node.ActiveState = new TwoStateVariableState(node);
            node.ActiveState.TransitionTime = new PropertyState<DateTime>(node.ActiveState);
            node.ActiveState.EffectiveDisplayName = new PropertyState<LocalizedText>(node.ActiveState);
            node.ActiveState.Create(context, null, BrowseNames.ActiveState, null, false);

            // specify reference type between the source and the alarm.
            node.ReferenceTypeId = ReferenceTypeIds.HasComponent;

            // This call initializes the condition from the type model (i.e. creates all of the objects
            // and variables requried to store its state). The information about the type model was 
            // incorporated into the class when the class was created.
            //
            // This method also assigns new NodeIds to all of the components by calling the INodeIdFactory.New
            // method on the INodeIdFactory object which is part of the system context. The NodeManager provides
            // the INodeIdFactory implementation used here.
            node.Create(
                context,
                null,
                new QualifiedName(alarm.Name, this.BrowseName.NamespaceIndex),
                null,
                true);

            // don't add branches to the address space.
            if (NodeId.IsNull(branchId))
            {
                this.AddChild(node);
            }

            // initialize event information.node
            node.EventType.Value = node.TypeDefinitionId;
            node.SourceNode.Value = this.NodeId;
            node.SourceName.Value = this.SymbolicName;
            node.ConditionName.Value = node.SymbolicName;
            node.Time.Value = DateTime.UtcNow;
            node.ReceiveTime.Value = node.Time.Value;
            node.LocalTime.Value = Utils.GetTimeZoneInfo();
            node.BranchId.Value = branchId;
            
            // set up method handlers.
            node.OnEnableDisable = OnEnableDisableAlarm;
            node.OnAcknowledge = OnAcknowledge;
            node.OnAddComment = OnAddComment;
            node.OnConfirm = OnConfirm;
            node.OnShelve = OnShelve;
            node.OnTimedUnshelve = OnTimedUnshelve;

            // return the new node.
            return node;
        }