<ProgramFilesX86>\OPC Labs\QuickOPC 5.3\Assemblies\OpcLabs.BaseLib.dll <ProgramFilesX86>\OPC Labs\QuickOPC 5.3\Assemblies\OpcLabs.BaseLibExtensions.dll <ProgramFilesX86>\OPC Labs\QuickOPC 5.3\Assemblies\OpcLabs.EasyOpc.dll <ProgramFilesX86>\OPC Labs\QuickOPC 5.3\Assemblies\OpcLabs.EasyOpcClassic.dll <ProgramFilesX86>\OPC Labs\QuickOPC 5.3\Assemblies\OpcLabs.EasyOpcClassicExtensions.dll <ProgramFilesX86>\OPC Labs\QuickOPC 5.3\Assemblies\OpcLabs.EasyOpcClassicInternal.dll OpcLabs.BaseLib OpcLabs.BaseLib.LiveMapping OpcLabs.EasyOpc OpcLabs.EasyOpc.DataAccess OpcLabs.EasyOpc.DataAccess.Generic OpcLabs.EasyOpc.DataAccess.LiveMapping OpcLabs.EasyOpc.DataAccess.LiveMapping.Extensions System.Threading void Main() { var root = "/common2OpcModel"; TestData td = new TestData(); var mp = new DAClientMapper(); var d = new DAMappingContext() { ServerDescriptor = Test.cServer, // local OPC server NodeDescriptor = new DANodeDescriptor { BrowsePath = root + "/msarna/L1/Z1/ZonesCtx"}, GroupParameters = 300, }; mp.Map(td, d); mp.Client.SubscribeItem(Test.cServer, new DAItemDescriptor() { BrowsePath= root + "/msarna/L1/Z1/ZonesCtx/LoadZonePosition"}, 300,(e1,e2)=> { Console.WriteLine("[Subscribed event] LoadZonePositio : " + e1.ToString() + e2.ToString()); },null); //------------------------------------------- td.LoadZonePosition.RwTestData.Value = 9001; mp.WriteTarget(td.LoadZonePosition.RwTestData,true); Thread.Sleep(1000); td.LoadZonePosition.RwTestData.Value = 0; mp.ReadTarget(td.LoadZonePosition.RwTestData,true); //------------------------------------------- mp.Subscribe(true); uint val = 0; var t1 = new Thread(()=>{ while(true) { Test.TestReadWrite(root +"/msarna/L1/Z1/ZonesCtx", "LoadZonePosition", val, true); // or writing by rw mapping //td.LoadZonePosition.RwTestData.Value = val; //mp.WriteTarget(td.LoadZonePosition.RwTestData,false); Thread.Sleep(1500); val++; if(val >40) { val =0; } } }); var t2 = new Thread(()=> { Thread.Sleep(1000); Console.WriteLine("[Mapped thread] NodeDescriptor.BrowsePath=" + td.LoadZonePosition.CvTestData.NodeDescriptor.BrowsePath.ToString() ); Console.WriteLine("*************************************************"); while(true) { Console.WriteLine("[Mapped thread] LoadZonePositio : " + td.LoadZonePosition.CvTestData.Value ); if (td.LoadZonePosition.CvTestData.Exception != null) { Console.WriteLine("[Mapped thread] Exception=" + td.LoadZonePosition.CvTestData.Exception.Message); } else { Console.WriteLine("[Mapped thread] Exception=null"); } Thread.Sleep(1500); } }); t1.Start(); t2.Start(); t1.Join(); t2.Join(); } [DAType] public class TestData { public TestData() { LoadZonePosition = new CvRwBoxTestData(); } [DANode()] public CvRwBoxTestData LoadZonePosition {get;set;} } [DAType] public class CvRwBoxTestData { public CvRwBoxTestData() { //I have commented RW value mapping RwTestData = new RwTestData(); CvTestData = new CvTestData(); } [DANode(BrowsePath = "")] public RwTestData RwTestData {get;set;} [DANode(BrowsePath = "")] public CvTestData CvTestData {get;set;} } [DAType] public class RwTestData { [DANode(BrowsePath = "")] [DAItem(Operations = DAItemMappingOperations.Subscribe)] [DARead(DataSource = DADataSource.Device)] public Int64 Value {get;set;} [DANode(BrowsePath = "")] [DAItem(Kind = DAItemMappingKind.Exception, Operations=DAItemMappingOperations.ReadAndSubscribe)] [DARead(DataSource = DADataSource.Device)] public Exception Exception {get;set;} [MetaMember("NodeDescriptor")] public NodeDescriptor NodeDescriptor { get; set; } } [DAType] public class CvTestData { [DANode(BrowsePath = "")] [DAItem(Operations = DAItemMappingOperations.ReadAndWrite)] public Int64 Value {get;set;} [DANode(BrowsePath = "")] [DAItem(Kind = DAItemMappingKind.Exception, Operations=DAItemMappingOperations.ReadAndWrite)] public Exception Exception {get;set;} [MetaMember("NodeDescriptor")] public NodeDescriptor NodeDescriptor { get; set; } } class Test { public const string cServer = "Kepware.KEPServerEX.V5"; public static void TestReadWrite(string rootPath, string valName, object value, bool isolated) { string path = rootPath + "/" + valName; Console.WriteLine("[TestReadWrite] Test for: " + path + ", isolated: " + isolated.ToString() + ", value: " + value.ToString()); EasyDAClient c1 = new EasyDAClient(); EasyDAClient c2 = new EasyDAClient(); c1.Isolated = isolated; c2.Isolated = isolated; c1.WriteItemValue(new ServerDescriptor (){ ServerClass = cServer}, new DAItemDescriptor() { BrowsePath= path},value); Thread.Sleep(1000); var ds = new DAItemDescriptor() { BrowsePath= path}; if (value is bool) ds.RequestedDataType = VarType.Bool; var valB = c2.ReadItem( new ServerDescriptor (){ ServerClass = cServer}, ds , new DAReadParameters(){ DataSource= DADataSource.Device, } ); Console.WriteLine("[TestReadWrite] ValueAfterRead=" + valB.ToString()); } }