Ejemplo n.º 1
0
        /// <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>
        private void OPCClientGroup
        (
            OPCCliConfiguration.SubscriptionsRow group,
            OPCCliConfiguration.ItemsRow[] items,
            OPC_Interface server,
            ref uint?volumeConstrain
        )
        {
            if (volumeConstrain.HasValue)
            {
                if (volumeConstrain.Value < items.Length)
                {
                    throw new LicenseException(typeof(DataBindingsManager), this, CAS.Lib.CodeProtect.Properties.Resources.Tx_LicVolumeConstrainErr);
                }
                else
                {
                    volumeConstrain = volumeConstrain.Value - Convert.ToUInt32(items.Length);
                }
            }
            SubscriptionState state = group.CreateSubscriptionState;

            OPC_Interface.OPCGroup m_OPCGroup;
            m_OPCGroup      = server.CreateOPCGroup((uint)group.ID, (uint)group.ID_server, group.Asynchronous, state);
            m_OPCGroup.Tags = Tags(items, server, m_OPCGroup);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates new instance of an OPC client and
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="volumeConstrain">The  volume constrain.</param>
        private void CrateServer(OPCCliConfiguration.ServersRow server, ref uint?volumeConstrain)
        {
            OPC_Interface m_Server = new OPC_Interface(server.PreferedSpecification, server.URL, server.Name);

            foreach (OPCCliConfiguration.SubscriptionsRow group in server.GetSubscriptionsRows())
            {
                OPCClientGroup(group, group.GetItemsRows(), m_Server, ref volumeConstrain);
            }
        }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 /// <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 );
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Connects all serves and starts pumping the datat .
 /// </summary>
 public void Start()
 {
     OPC_Interface.SwitchOnAllServers();
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Stops all data sources and disconnect all servers.
 /// </summary>
 public void Stop()
 {
     OPC_Interface.DisconnectAllServers();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// finalize all server interfaces
 /// </summary>
 internal static void DisconnectAllServers()
 {
   OPC_Interface.DisconnectAllServers();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Switch on Scanning of thr all goups and complet initiaition
 /// </summary>
 internal static void SwitchOnScanning()
 {
   OPC_Interface.SwitchOnAllServers();
   OPCClientTransaction.SwitchOnAll();
 }