/// <summary> /// Creates a new dialog condition /// </summary> private DialogConditionState CreateDialog(string dialogName) { ISystemContext context = m_nodeManager.SystemContext; DialogConditionState node = new DialogConditionState(this); node.SymbolicName = dialogName; // specify optional fields. 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); // 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. node.Create( context, null, new QualifiedName(dialogName, this.BrowseName.NamespaceIndex), null, true); this.AddChild(node); // initialize event information. node.EventId.Value = Guid.NewGuid().ToByteArray(); 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.Message.Value = "The dialog was activated"; node.Retain.Value = true; node.SetEnableState(context, true); node.SetSeverity(context, EventSeverity.Low); // initialize the dialog information. node.Prompt.Value = "Please specify a new state for the source."; node.ResponseOptionSet.Value = s_ResponseOptions; node.DefaultResponse.Value = 2; node.CancelResponse.Value = 2; node.OkResponse.Value = 0; // set up method handlers. node.OnRespond = OnRespond; // this flag needs to be set because the underlying system does not produce these events. node.AutoReportStateChanges = true; // activate the dialog. node.Activate(context); // return the new node. return node; }