/// <summary>
        /// Occurs when a monitored item has changed.
        /// </summary>
        /// <param name="e">The event argument.</param>
        public void OnMonitoredItemChanged(EasyDAItemChangedEventArgs e)
        {
            // This event might come immediately after monitor has been stopped.
            // This must be checked before continuing.
            if (this.RuntimeMeasurements != null)
            {
                // Checks gateway validity.
                if (IsGatewayValid(this.Configuration.Gateway))
                {
                    var references = e.State as References;
                    if (references != null)
                    {
                        foreach (var reference in
                                 references.Where(
                                     reference => 0 <= reference.Index && reference.Index < this.RuntimeMeasurements.Count))
                        {
                            // Sets the value first.
                            this.SetOpcValue(reference, e.Vtq);

                            // Checks value validity and possibly sets reference to the values to be sent to clients.
                            this.ProcessValueChange(reference.Index);
                        }
                    }
                }
            }
        }
            public static void Main1()
            {
                // In order to use event pull, you must set a non-zero queue capacity upfront.
                var easyDAClient = new EasyDAClient {
                    PullItemChangedQueueCapacity = 1000
                };

                Console.WriteLine("Subscribing item changes...");
                easyDAClient.SubscribeItem("", "AutoJet.ACPFileServerDA.1", "Simulation.Random", 1000);

                Console.WriteLine("Processing item changes for 1 minute...");
                int endTick = Environment.TickCount + 60 * 1000;

                do
                {
                    EasyDAItemChangedEventArgs eventArgs = easyDAClient.PullItemChanged(2 * 1000);
                    if (eventArgs != null)
                    {
                        // Handle the notification event
                        Console.WriteLine(eventArgs);
                    }
                } while (Environment.TickCount < endTick);

                Console.WriteLine("Unsubscribing item changes...");
                easyDAClient.UnsubscribeAllItems();

                Console.WriteLine("Finished.");
            }
示例#3
0
 static void client_ItemChanged(object sender, EasyDAItemChangedEventArgs e)
 {
     if (e.Exception != null)
     {
         Console.WriteLine(e.Exception);
     }
     else
     {
         Console.WriteLine(e.Vtq);
     }
 }
        /// <summary>
        /// Occurs when a monitored item has changed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event argument.</param>
        private void OnMonitoredItemChanged(object sender, EasyDAItemChangedEventArgs e)
        {
            // Sets only good values.
            if (IsGood(e))
            {
                // Create message.
                var message = new Message(null, Guid.Empty, MessageTypes.OnMonitoredItemChangedIndication, this);
                message.AddParameter(ParameterTypes.OpcDaItemChangedEventArgs, e);

                // Enqueue message.
                MessageQueue.Instance.Enqueue(message);
            }
        }
 static void client_ItemChanged([NotNull] object sender, [NotNull] EasyDAItemChangedEventArgs e)
 {
     Console.WriteLine();
     Console.WriteLine("ItemDescriptor.Arguments.ItemId: {0}", e.Arguments.ItemDescriptor.ItemId);
     if (e.Exception != null)
     {
         Console.WriteLine("Exception: {0}", e.Exception);
     }
     else
     {
         Debug.Assert(e.Vtq != null);
         Console.WriteLine("Vtq: {0}", e.Vtq);
     }
 }
示例#6
0
 private void ItemChanged(object sender, EasyDAItemChangedEventArgs e)
 {
     try
     {
         if (e.Exception == null)
         {
             if (e.Vtq.Quality.IsGood)
             {
                 this.NewValue = Convert.ToInt32(e.Vtq.Value);
                 //Rise the event, as argument send the tag object.
                 EventHandler <OpcTag> h = OpcItemHasChanged;
                 if (h != null)
                 {
                     h.Invoke(null, this);
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
 // Item changed event handler
 static void easyDAClient_ItemChanged([NotNull] object sender, [NotNull] EasyDAItemChangedEventArgs e)
 {
     Console.WriteLine("{0}: {1}", e.Arguments.ItemDescriptor.ItemId, e.Vtq);
 }
示例#8
0
 // Item changed event handler
 static void easyDAClient_ItemChanged([NotNull] object sender, [NotNull] EasyDAItemChangedEventArgs e)
 {
     Console.WriteLine(e.Vtq);
 }
 /// <summary>
 /// Checks whether the argument represents a good value.
 /// </summary>
 /// <param name="e">The event argument.</param>
 /// <returns><c>true</c> if the value contained in the argument is good; otherwise, <c>false</c>.</returns>
 private static bool IsGood(EasyDAItemChangedEventArgs e)
 {
     return(e.ErrorCode == 0 && e.Exception == null && e.Vtq != null);
 }