![](dotnetdiagramimages/OpcLabs_EasyOpcClassic_OpcLabs_EasyOpc_DataAccess_Reactive_DAWriteItemValueObserver`1.png)
'Declaration
<ComVisibleAttribute(False)> <TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)> <CLSCompliantAttribute(True)> <ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=False, Export=True, PageId=10001)> <SerializableAttribute()> Public NotInheritable Class DAWriteItemValueObserver(Of TValue) Inherits DAReactive Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, System.ICloneable, System.IObserver(Of TValue), System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
'Usage
Dim instance As DAWriteItemValueObserver(Of TValue)
[ComVisible(false)] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [CLSCompliant(true)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] public sealed class DAWriteItemValueObserver<TValue> : DAReactive, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, System.ICloneable, System.IObserver<TValue>, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
[ComVisible(false)] [TypeConverter(System.ComponentModel.ExpandableObjectConverter)] [CLSCompliant(true)] [ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.81.455.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", DefaultReadWrite=false, Export=true, PageId=10001)] [Serializable()] generic<typename TValue> public ref class DAWriteItemValueObserver sealed : public DAReactive, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, System.ICloneable, System.IObserver<TValue>, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable
// Shows how to create an observer that writes values to OPC-DA item, and subscribe it to a generated sequence of values. // Requires Microsoft Reactive Extensions (Rx). // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Reactive.Linq; using System.Threading; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.Reactive; namespace ReactiveDocExamples { namespace _DAWriteItemValueObserver { class OnNext { public static void Main1() { Console.WriteLine("Creating source observable, 0..9 in 1 second intervals..."); IObservable<int> source = Observable.Generate(0, i => i < 10, i => i + 1, i => i, i => TimeSpan.FromSeconds(1)); Console.WriteLine("Creating observer to write values into OPC item..."); DAWriteItemValueObserver<int> observer = DAWriteItemValueObserver.Create<int>("", "OPCLabs.KitServer.2", "Simulation.Register_I4"); Console.WriteLine("Monitoring changes of the target OPC item using traditional means..."); int handle = EasyDAClient.SharedInstance.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 100, (_, e) => Console.WriteLine(e.Vtq)); Console.WriteLine("Subscribing the observer to source observable..."); source.Subscribe(observer); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Finalizing monitoring..."); EasyDAClient.SharedInstance.UnsubscribeItem(handle); Console.WriteLine("Waiting for 2 seconds..."); Thread.Sleep(2 * 1000); } } } }
// Shows how to continuously transform values of OPC-DA item, and write the results into a second item. // Requires Microsoft Reactive Extensions (Rx). // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Reactive.Linq; using System.Threading; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.Reactive; namespace ReactiveDocExamples { namespace _DAReactive { class Composition { public static void Pipeline() { Console.WriteLine("Creating source observable..."); DAItemChangedObservable<int> source = DAItemChangedObservable.Create<int>("", "OPCLabs.KitServer.2", "Simulation.Incrementing (1 s)", 100); Console.WriteLine("Creating processed observable (takes valid input values and multiplies them by 1000)..."); IObservable<int> processed = source .Where(e => e.Exception is null) .Select(e => e.TypedVtq.TypedValue * 1000); Console.WriteLine("Creating observer to write values into OPC item..."); DAWriteItemValueObserver<int> observer = DAWriteItemValueObserver.Create<int>("", "OPCLabs.KitServer.2", "Simulation.Register_I4"); Console.WriteLine("Monitoring changes of the target OPC item using traditional means..."); int handle = EasyDAClient.SharedInstance.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Register_I4", 100, (_, e) => Console.WriteLine(e.Vtq)); Console.WriteLine("Subscribing the observer to the processed observable..."); using (processed.Subscribe(observer)) { Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Unsubscribing the observer from the processed observable..."); } Console.WriteLine("Finalizing monitoring..."); EasyDAClient.SharedInstance.UnsubscribeItem(handle); Console.WriteLine("Waiting for 2 seconds..."); Thread.Sleep(2 * 1000); } } } }
System.Object
OpcLabs.BaseLib.Object2
OpcLabs.BaseLib.Info
OpcLabs.EasyOpc.DataAccess.Reactive.DAReactive
OpcLabs.EasyOpc.DataAccess.Reactive.DAWriteItemValueObserver<TValue>