private OPC_Interface.OPC_Interface_Tag[] Tags ( OPCCliConfiguration.ItemsRow[] items, OPC_Interface server, OPC_Interface.OPCGroup oPCGroup ) { OPCClientTag[] tags = new OPCClientTag[ items.Length ]; int idx = 0; #region foreach ( OPCCliConfiguration.ItemsRow row in items ) foreach ( OPCCliConfiguration.ItemsRow row in items ) { OpcDa.Item item = row.Item; double measurement_low = double.NaN; double measurement_hi = double.NaN; double engineer_low = double.NaN; double engineer_hi = double.NaN; OPCCliConfiguration.ConversionsRow[] conversions = row.GetConversionsRows(); if ( conversions.Length > 0 ) { if ( conversions.Length != 1 ) throw new Exception( "Too many ConversionsRows for item " + row.Name ); //musimy konwersje uruchomic measurement_low = conversions[ 0 ].MeasuredValue1; measurement_hi = conversions[ 0 ].MeasuredValue2; engineer_low = conversions[ 0 ].EngineeringValue1; engineer_hi = conversions[ 0 ].EngineeringValue2; } //odczytanie odpowiednich property z pliku opisów global::Opc.Da.ItemPropertyCollection properties = BaseStation.ItemDescriber.ItemDescriber2OpcDA.GetItemPropertiesCollection( row.Name, Main.m_ds_dsc ); if ( properties.Count == 0 ) { //nalezy sprawdzic jeszcze - czy moze nie ma nazewnictwa path/ tagname: properties = BaseStation.ItemDescriber.ItemDescriber2OpcDA.GetItemPropertiesCollection ( server.Name + "/" + oPCGroup.Name + "/" + row.Name, Main.m_ds_dsc ); } OPCTag tagStatistics = new OPCTag( (uint)row.ID, row.Item, measurement_low, measurement_hi, engineer_low, engineer_hi ); string path = server.Name + "/" + oPCGroup.Name + "/"; OPCClientTag tag = new OPCClientTag ( tagStatistics, oPCGroup, null, OpcDa.qualityBits.badNotConnected, properties, path, row.Item ); tag.ClientHandle = idx; tags[ idx++ ] = tag; } #endregion foreach ( OPCCliConfiguration.ItemsRow row in items ) return tags; }
/// <summary> /// Initializes a new instance of the <see cref="OPCClientGroup"/> class. /// </summary> /// <param name="group">The group description from XML configuration file<see cref="OPCCliConfiguration.SubscriptionsRow"/>.</param> /// <param name="items">The table of items <see cref="OPCCliConfiguration.ItemsRow"/>.</param> /// <param name="server">Server that this group should belong to</param> /// <param name="parent">The parent.</param> /// <param name="volumeConstrain">The volume constrain.</param> internal OPCClientGroup ( OPCCliConfiguration.SubscriptionsRow group, OPCCliConfiguration.ItemsRow[] items, OPC_Interface server, OPCDataQueue parent, ref uint? volumeConstrain ) { if ( volumeConstrain.HasValue ) if ( volumeConstrain.Value < items.Length ) throw new LicenseException( typeof( Main ), Main.MainComponent, CAS.Lib.CodeProtect.Properties.Resources.Tx_LicVolumeConstrainErr ); else volumeConstrain = volumeConstrain.Value - Convert.ToUInt32( items.Length ); OpcDa.SubscriptionState state = group.CreateSubscriptionState; m_OPCGroup = server.CreateOPCGroup( (uint)group.ID, (uint)group.ID_server, group.Asynchronous, state ); m_OPCGroup.Tags = Tags( items, server, m_OPCGroup ); m_AllGroups.Add( this ); }
private OPC_Interface.OPC_Interface_Tag[] Tags (OPCCliConfiguration.ItemsRow[] items, OPC_Interface server, OPC_Interface.OPCGroup oPCGroup) { OPC_Interface.OPC_Interface_Tag[] tags = new OPC_Interface.OPC_Interface_Tag[items.Length]; int idx = 0; #region foreach ( OPCCliConfiguration.ItemsRow row in items ) foreach (OPCCliConfiguration.ItemsRow row in items) { Opc.Da.Item item = row.Item; double measurement_low = double.NaN; double measurement_hi = double.NaN; double engineer_low = double.NaN; double engineer_hi = double.NaN; OPCCliConfiguration.ConversionsRow[] conversions = row.GetConversionsRows(); if (conversions.Length > 0) { if (conversions.Length != 1) { throw new Exception("Too many ConversionsRows for item " + row.Name); } //musimy konwersje uruchomic measurement_low = conversions[0].MeasuredValue1; measurement_hi = conversions[0].MeasuredValue2; engineer_low = conversions[0].EngineeringValue1; engineer_hi = conversions[0].EngineeringValue2; } OPCTag tagStatistics = new OPCTag((uint)row.ID, row.Item, measurement_low, measurement_hi, engineer_low, engineer_hi); string path = server.Name + "/" + oPCGroup.Name + "/"; OPC_Interface.OPC_Interface_Tag tag = new OPC_Interface.OPC_Interface_Tag (tagStatistics, oPCGroup, null, Opc.Da.qualityBits.badNotConnected, null, path, row.Item); tag.ClientHandle = idx; tags[idx++] = tag; this.Add(UniqueIdentyfier(server.Name, oPCGroup.Name, row.Name), tag); } #endregion foreach ( OPCCliConfiguration.ItemsRow row in items ) return(tags); }