public AlarmHolder(AlarmNodeManager alarmNodeManager, FolderState parent, SourceController trigger, Type controllerType, int interval) { m_alarmNodeManager = alarmNodeManager; m_parent = parent; m_trigger = trigger.Source; m_alarmController = trigger.Controller; m_alarmControllerType = trigger.Controller.GetType(); m_interval = interval; }
public SourceController GetSourceControllerFromNodeState(NodeState nodeState, Dictionary <string, SourceController> map) { SourceController sourceController = null; string name = GetSourceNameFromNodeState(nodeState); if (map.ContainsKey(name)) { sourceController = map[name]; } return(sourceController); }
protected ConditionTypeHolder( AlarmNodeManager alarmNodeManager, FolderState parent, SourceController trigger, string name, SupportedAlarmConditionType alarmConditionType, Type controllerType, int interval, bool optional) : base(alarmNodeManager, parent, trigger, name, alarmConditionType, controllerType, interval, optional) { m_alarmConditionType = alarmConditionType; }
public ServiceResult OnWriteAlarmTrigger( ISystemContext context, NodeState node, NumericRange indexRange, QualifiedName dataEncoding, ref object value, ref StatusCode statusCode, ref DateTime timestamp) { Dictionary <string, SourceController> sourceControllers = GetUnitAlarms(node); if (sourceControllers == null) { return(StatusCodes.BadNodeIdUnknown); } if (sourceControllers != null) { SourceController sourceController = GetSourceControllerFromNodeState(node, sourceControllers); if (sourceController == null) { return(StatusCodes.BadNodeIdUnknown); } Utils.LogInfo("Manual Write {0} to {1}", value, node.NodeId); lock (m_alarms) { sourceController.Source.Value = value; Type valueType = value.GetType(); sourceController.Controller.ManualWrite(value); IList <IReference> references = new List <IReference>(); sourceController.Source.GetReferences(SystemContext, references, ReferenceTypes.HasCondition, false); foreach (IReference reference in references) { string identifier = (string)reference.TargetId.ToString(); if (m_alarms.ContainsKey(identifier)) { AlarmHolder holder = m_alarms[identifier]; holder.Update(true); } } } } return(Opc.Ua.StatusCodes.Good); }
public AcknowledgeableConditionTypeHolder( AlarmNodeManager alarmNodeManager, FolderState parent, SourceController trigger, string name, SupportedAlarmConditionType alarmConditionType, Type controllerType, int interval, bool optional = true, bool create = true) : base(alarmNodeManager, parent, trigger, name, alarmConditionType, controllerType, interval, optional) { if (create) { Initialize(Opc.Ua.ObjectTypes.AcknowledgeableConditionType, name); } }
public AlarmConditionTypeHolder( AlarmNodeManager alarmNodeManager, FolderState parent, SourceController trigger, string name, SupportedAlarmConditionType alarmConditionType, Type controllerType, int interval, bool optional = true, double maxShelveTime = AlarmDefines.NORMAL_MAX_TIME_SHELVED, bool create = true) : base(alarmNodeManager, parent, trigger, name, alarmConditionType, controllerType, interval, optional, false) { if (create) { Initialize(Opc.Ua.ObjectTypes.AlarmConditionType, name, maxShelveTime); } }
public DiscreteHolder( AlarmNodeManager alarmNodeManager, FolderState parent, SourceController trigger, string name, SupportedAlarmConditionType alarmConditionType, Type controllerType, int interval, bool optional = true, double maxShelveTime = AlarmDefines.NORMAL_MAX_TIME_SHELVED, bool create = true) : base(alarmNodeManager, parent, trigger, name, alarmConditionType, controllerType, interval, optional, maxShelveTime, false) { Utils.LogTrace("{0} Discrete Constructor Optional = {1}", name, optional); if (create) { Initialize(ObjectTypes.DiscreteAlarmType, name, maxShelveTime); } }
/// <summary> /// Does any initialization required before the address space can be used. /// </summary> /// <remarks> /// The externalReferences is an out parameter that allows the node manager to link to nodes /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and /// should have a reference to the root folder node(s) exposed by this node manager. /// </remarks> public override void CreateAddressSpace(IDictionary <NodeId, IList <IReference> > externalReferences) { lock (Lock) { #region Setup IList <IReference> references = null; if (!externalReferences.TryGetValue(ObjectIds.ObjectsFolder, out references)) { externalReferences[ObjectIds.ObjectsFolder] = references = new List <IReference>(); } #endregion try { #region Initialize string alarmsName = "Alarms"; string alarmsNodeName = alarmsName; Type alarmControllerType = Type.GetType("Alarms.AlarmController"); int interval = 1000; string intervalString = interval.ToString(); int conditionTypeIndex = 0; #endregion #region Create Alarm Folder FolderState alarmsFolder = CreateFolder(null, alarmsNodeName, alarmsName); alarmsFolder.AddReference(ReferenceTypes.Organizes, true, ObjectIds.ObjectsFolder); references.Add(new NodeStateReference(ReferenceTypes.Organizes, false, alarmsFolder.NodeId)); alarmsFolder.EventNotifier = EventNotifiers.SubscribeToEvents; AddRootNotifier(alarmsFolder); #endregion #region Create Methods string startMethodName = "Start"; string startMethodNodeName = alarmsNodeName + "." + startMethodName; MethodState startMethod = AlarmHelpers.CreateMethod(alarmsFolder, NamespaceIndex, startMethodNodeName, startMethodName); AlarmHelpers.AddStartInputParameters(startMethod, NamespaceIndex); startMethod.OnCallMethod = new GenericMethodCalledEventHandler(OnStart); string startBranchMethodName = "StartBranch"; string startBranchMethodNodeName = alarmsNodeName + "." + startBranchMethodName; MethodState startBranchMethod = AlarmHelpers.CreateMethod(alarmsFolder, NamespaceIndex, startBranchMethodNodeName, startBranchMethodName); AlarmHelpers.AddStartInputParameters(startBranchMethod, NamespaceIndex); startBranchMethod.OnCallMethod = new GenericMethodCalledEventHandler(OnStartBranch); string endMethodName = "End"; string endMethodNodeName = alarmsNodeName + "." + endMethodName; MethodState endMethod = AlarmHelpers.CreateMethod(alarmsFolder, NamespaceIndex, endMethodNodeName, endMethodName); endMethod.OnCallMethod = new GenericMethodCalledEventHandler(OnEnd); #endregion #region Create Variables string analogTriggerName = "AnalogSource"; string analogTriggerNodeName = alarmsNodeName + "." + analogTriggerName; BaseDataVariableState analogTrigger = AlarmHelpers.CreateVariable(alarmsFolder, NamespaceIndex, analogTriggerNodeName, analogTriggerName); analogTrigger.OnWriteValue = OnWriteAlarmTrigger; AlarmController analogAlarmController = (AlarmController)Activator.CreateInstance(alarmControllerType, analogTrigger, interval, false); SourceController analogSourceController = new SourceController(analogTrigger, analogAlarmController); m_triggerMap.Add("Analog", analogSourceController); string booleanTriggerName = "BooleanSource"; string booleanTriggerNodeName = alarmsNodeName + "." + booleanTriggerName; BaseDataVariableState booleanTrigger = AlarmHelpers.CreateVariable(alarmsFolder, NamespaceIndex, booleanTriggerNodeName, booleanTriggerName, boolValue: true); booleanTrigger.OnWriteValue = OnWriteAlarmTrigger; AlarmController booleanAlarmController = (AlarmController)Activator.CreateInstance(alarmControllerType, booleanTrigger, interval, true); SourceController booleanSourceController = new SourceController(booleanTrigger, booleanAlarmController); m_triggerMap.Add("Boolean", booleanSourceController); #endregion #region Create Alarms AlarmHolder mandatoryExclusiveLevel = new ExclusiveLevelHolder( this, alarmsFolder, analogSourceController, intervalString, GetSupportedAlarmConditionType(ref conditionTypeIndex), alarmControllerType, interval, optional: false); m_alarms.Add(mandatoryExclusiveLevel.AlarmNodeName, mandatoryExclusiveLevel); AlarmHolder mandatoryNonExclusiveLevel = new NonExclusiveLevelHolder( this, alarmsFolder, analogSourceController, intervalString, GetSupportedAlarmConditionType(ref conditionTypeIndex), alarmControllerType, interval, optional: false); m_alarms.Add(mandatoryNonExclusiveLevel.AlarmNodeName, mandatoryNonExclusiveLevel); AlarmHolder offNormal = new OffNormalAlarmTypeHolder( this, alarmsFolder, booleanSourceController, intervalString, GetSupportedAlarmConditionType(ref conditionTypeIndex), alarmControllerType, interval, optional: false); m_alarms.Add(offNormal.AlarmNodeName, offNormal); #endregion AddPredefinedNode(SystemContext, alarmsFolder); StartTimer(); m_allowEntry = true; } catch (Exception e) { Utils.LogError(e, "Error creating the AlarmNodeManager address space."); } } }