/// <summary> /// Initializes the node manager. /// </summary> public ComHdaClientNodeManager(IServerInternal server, string namespaceUri, ComHdaClientConfiguration configuration, bool ownsTypeModel) : base(server, namespaceUri, ownsTypeModel) { SystemContext.SystemHandle = m_system = new ComHdaClientManager(); SystemContext.NodeIdFactory = this; // save the configuration for the node manager. m_configuration = configuration; // set the alias root. AliasRoot = m_configuration.ServerName; if (String.IsNullOrEmpty(AliasRoot)) { AliasRoot = "HDA"; } // set the default parser if none provided. if (configuration.ItemIdParser == null) { configuration.ItemIdParser = new ComItemIdParser(); } // set default parameters. if (m_configuration.AttributeSamplingInterval == 0) { m_configuration.AttributeSamplingInterval = 1000; } // create the list of subscriptions. m_subscriptionManagers = new Dictionary<int, HdaSubscribeRequestManager>(); m_subscriptionManagers[ComUtils.LOCALE_SYSTEM_DEFAULT] = new HdaSubscribeRequestManager(SystemContext, ComUtils.LOCALE_SYSTEM_DEFAULT, m_configuration); m_monitoredItems = new Dictionary<uint, HdaSubscribeRequestManager>(); }
/// <summary> /// Initializes a new instance of the <see cref="HdaSubscribeRequestManager"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="localeId">The locale to use.</param> /// <param name="configuration">The configuration.</param> public HdaSubscribeRequestManager(ServerSystemContext context, int localeId, ComHdaClientConfiguration configuration) { m_context = context; m_localeId = localeId; m_configuration = configuration; m_requests = new Dictionary <string, HdaSubscribeAttributeRequest>(); m_monitoredItems = new Dictionary <uint, IMonitoredItem>(); }
/// <summary> /// Initializes a new instance of the <see cref="ComHdaClient"/> class. /// </summary> /// <param name="configuration"></param> public ComHdaClient(ComHdaClientConfiguration configuration) : base(configuration) { m_configuration = configuration; }
/// <summary> /// Initializes a new instance of the <see cref="DaItemState"/> class. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="itemId">The item id.</param> /// <param name="attribute">The attribute.</param> /// <param name="namespaceIndex">Index of the namespace.</param> public HdaAttributeState( ComHdaClientConfiguration configuration, string itemId, HdaAttribute attribute, ushort namespaceIndex) : base(null) { m_itemId = itemId; m_attribute = attribute; this.NodeId = HdaModelUtils.ConstructIdForHdaItemAttribute(itemId, attribute.Id, namespaceIndex); this.SymbolicName = attribute.Id.ToString(); this.Description = attribute.Description; this.AccessLevel = AccessLevels.CurrentRead; this.UserAccessLevel = AccessLevels.CurrentRead; this.MinimumSamplingInterval = MinimumSamplingIntervals.Indeterminate; this.Historizing = false; this.ReferenceTypeId = Opc.Ua.ReferenceTypeIds.HasProperty; this.TypeDefinitionId = Opc.Ua.VariableTypeIds.PropertyType; this.Value = null; this.StatusCode = StatusCodes.BadWaitingForInitialData; bool isConfigItem = false; // handle built-in properties. switch (attribute.Id) { default: { bool isArray = false; this.BrowseName = new QualifiedName(this.SymbolicName, namespaceIndex); this.DisplayName = attribute.Name; this.DataType = ComUtils.GetDataTypeId(attribute.DataType, out isArray); this.ValueRank = (isArray)?ValueRanks.OneDimension:ValueRanks.Scalar; break; } case Constants.OPCHDA_ENG_UNITS: { this.BrowseName = Opc.Ua.BrowseNames.EngineeringUnits; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.EUInformation; this.ValueRank = ValueRanks.Scalar; break; } case Constants.OPCHDA_NORMAL_MAXIMUM: { this.BrowseName = Opc.Ua.BrowseNames.EURange; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.Range; this.ValueRank = ValueRanks.Scalar; break; } case Constants.OPCHDA_HIGH_ENTRY_LIMIT: { this.BrowseName = Opc.Ua.BrowseNames.InstrumentRange; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.Range; this.ValueRank = ValueRanks.Scalar; break; } case Constants.OPCHDA_STEPPED: { this.BrowseName = Opc.Ua.BrowseNames.Stepped; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.Boolean; this.ValueRank = ValueRanks.Scalar; isConfigItem = true; break; } case Constants.OPCHDA_DERIVE_EQUATION: { this.BrowseName = Opc.Ua.BrowseNames.Definition; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.String; this.ValueRank = ValueRanks.Scalar; isConfigItem = true; break; } case Constants.OPCHDA_MIN_TIME_INT: { this.BrowseName = Opc.Ua.BrowseNames.MinTimeInterval; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.Duration; this.ValueRank = ValueRanks.Scalar; isConfigItem = true; break; } case Constants.OPCHDA_MAX_TIME_INT: { this.BrowseName = Opc.Ua.BrowseNames.MaxTimeInterval; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.Duration; this.ValueRank = ValueRanks.Scalar; isConfigItem = true; break; } case Constants.OPCHDA_EXCEPTION_DEV: { this.BrowseName = Opc.Ua.BrowseNames.ExceptionDeviation; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.Double; this.ValueRank = ValueRanks.Scalar; isConfigItem = true; break; } case Constants.OPCHDA_EXCEPTION_DEV_TYPE: { this.BrowseName = Opc.Ua.BrowseNames.ExceptionDeviationFormat; this.DisplayName = this.BrowseName.Name; this.DataType = Opc.Ua.DataTypeIds.ExceptionDeviationFormat; this.ValueRank = ValueRanks.Scalar; isConfigItem = true; break; } } // set the parent id. NodeId parentId = null; if (isConfigItem) { parentId = HdaParsedNodeId.Construct(HdaModelUtils.HdaItemConfiguration, itemId, null, namespaceIndex); } else { parentId = HdaModelUtils.ConstructIdForHdaItem(itemId, namespaceIndex); } this.AddReference(ReferenceTypeIds.HasProperty, true, parentId); }
/// <summary> /// Initializes a new instance of the <see cref="HdaSubscribeRequestManager"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="localeId">The locale to use.</param> /// <param name="configuration">The configuration.</param> public HdaSubscribeRequestManager(ServerSystemContext context, int localeId, ComHdaClientConfiguration configuration) { m_context = context; m_localeId = localeId; m_configuration = configuration; m_requests = new Dictionary<string, HdaSubscribeAttributeRequest>(); m_monitoredItems = new Dictionary<uint, IMonitoredItem>(); }
/// <summary> /// Handles the Click event of the OkBTN control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OkBTN_Click(object sender, EventArgs e) { try { if (ServersLV.SelectedItems.Count != 1) { return; } // extract the wrapper configuration from the application configuration. ComWrapperServerConfiguration wrapperConfig = m_configuration.ParseExtension<ComWrapperServerConfiguration>(); if (wrapperConfig == null) { wrapperConfig = new ComWrapperServerConfiguration(); } if (wrapperConfig.WrappedServers == null) { wrapperConfig.WrappedServers = new ComClientConfigurationCollection(); } // get the selected server. Item item = (Item)ServersLV.SelectedItems[0].Tag; // create a new new COM client entry for the selected server. ComClientConfiguration clientConfig = null; if (item.Specification == Specification.Da20 || item.Specification == Specification.Da30) { clientConfig = new ComDaClientConfiguration(); } else if (item.Specification == Specification.Ae10) { clientConfig = new ComAeClientConfiguration(); } else if (item.Specification == Specification.Hda10) { clientConfig = new ComHdaClientConfiguration(); } clientConfig.ServerUrl = item.Server.Url; clientConfig.ServerName = item.Server.VersionIndependentProgId; clientConfig.MaxReconnectWait = 100000; wrapperConfig.WrappedServers.Add(clientConfig); // update the configuration. m_configuration.UpdateExtension<ComWrapperServerConfiguration>(null, wrapperConfig); // close the dialog. DialogResult = DialogResult.OK; } catch (Exception exception) { MessageBox.Show(exception.Message); } }