public void CreateOpcUAPluginSettingsTemplate() { OpcUAPluginSettings ps = new OpcUAPluginSettings() { SamiKey = "key here", MeasurementObject = "measurement object here if needed", MeasurementTag = "measurement tag here if needed", Password = "******", UserName = "******", NamespaceUri = "S7COM:", OpcUAServiceUrl = "opc.tcp://opc-server-here:4845", OPCUAItemMap = new List <OPCUAItem>() }; ps.OPCUAItemMap.Add(new OPCUAItem() { Identifier = "opc-item-name 1", SamiTag = "sami-tag 1", Scale = new OPCUAPlugin.ValueLinearScale() { Destination = new OPCUAPlugin.LinearScaleLimit() { From = 0m, To = 10m }, Source = new OPCUAPlugin.LinearScaleLimit() { From = 0m, To = 4095m } } }); ps.OPCUAItemMap.Add(new OPCUAItem() { Identifier = "opc-item-name 2", SamiTag = "sami-tag 2", Scale = new OPCUAPlugin.ValueLinearScale() { Destination = new OPCUAPlugin.LinearScaleLimit() { From = 0m, To = 30m }, Source = new OPCUAPlugin.LinearScaleLimit() { From = 0m, To = 10000m } } }); string xml = SerializeHelper.SerializeToStringWithDCS <OpcUAPluginSettings>(ps); Trace.WriteLine(xml); Assert.IsNotNull(xml); OpcUAPluginSettings dps = SerializeHelper.DeserializeWithDCS <OpcUAPluginSettings>(xml); Assert.IsNotNull(dps); Assert.AreEqual(dps.SamiKey, ps.SamiKey); Assert.AreEqual(dps.OPCUAItemMap.Count, ps.OPCUAItemMap.Count); }
public void ReadAndDeserializeOpcUAPluginSettingsFile() { var xml = System.IO.File.ReadAllText(@"Path to settings file"); Trace.WriteLine(xml); Assert.IsNotNull(xml); OpcUAPluginSettings dps = SerializeHelper.DeserializeWithDCS <OpcUAPluginSettings>(xml); Assert.IsNotNull(dps); Assert.AreEqual(dps.SamiKey, "key here"); Assert.AreEqual(dps.OPCUAItemMap.Count, 2); var firstItemMap = dps.OPCUAItemMap.First(); var lastItemMap = dps.OPCUAItemMap.Last(); Assert.IsNotNull(firstItemMap.Scale); Assert.IsNull(lastItemMap.Scale); Assert.AreEqual <double>(firstItemMap.Scale.ScaleValue(1), 0.1); }