public NumTagValueConverter(num_tags numericTag) { _type = numericTag.TagType; if (numericTag.raw_min == null || numericTag.raw_max == null || numericTag.eng_min == null || numericTag.eng_max == null || numericTag.raw_max - numericTag.raw_min == 0) return; _needCalculation = true; _mul = (double) numericTag.eng_max - (double) numericTag.eng_min; _add = (double) numericTag.eng_min*(double) numericTag.raw_max - (double) numericTag.eng_max*(double) numericTag.raw_min; _div = (double) numericTag.raw_max - (double) numericTag.raw_min; }
protected override void EstablishContext() { base.EstablishContext(); NumTag = new num_tags { num_tag_types = new num_tag_types { name = "Int32" }, raw_min = 0, raw_max = 100, eng_min = 0, eng_max = 10 }; Converter = new NumTagValueConverter(NumTag); }
protected override void EstablishContext() { base.EstablishContext(); IoDeviceWrapper = new Mock<IIoDeviceWrapper>(); IoDeviceWrapperFactory = new Mock<IIoDeviceWrapperFactory>(); IoDeviceWrapperFactory.Setup(f => f.Create()).Returns(IoDeviceWrapper.Object); IoDevice = new io_devices { name = "IoDeviceRunTargetName", options = IoDeviceOptions, type = string.Format("{0}{1}{2}", IoDeviceFolder, PHmiConstants.PHmiIoDeviceSeparator, IoDeviceFile) }; DigitalTag = new dig_tags { id = 1, device = "M0", can_read = true }; IoDevice.dig_tags.Add(DigitalTag); WriteOnlyDigitalTag = new dig_tags { id = 2, device = "M1", can_read = false }; IoDevice.dig_tags.Add(WriteOnlyDigitalTag); NumericTag = new num_tags { id = 1, device = "D0", num_tag_types = new num_tag_types {name = "Int32"}, can_read = true }; IoDevice.num_tags.Add(NumericTag); WriteOnlyNumericTag = new num_tags { id = 2, device = "D1", num_tag_types = new num_tag_types {name = "Int16"}, can_read = false }; IoDevice.num_tags.Add(WriteOnlyNumericTag); Reporter = new Mock<INotificationReporter>(); IoDeviceRunTarget = new IoDeviceRunTarget(IoDevice, IoDeviceWrapperFactory.Object, Reporter.Object); DigitalTagValue = true; NumericTagValue = new Random().Next(); IoDeviceWrapper .Setup(w => w.Read(It.IsAny<ReadParameter[]>())) .Returns(new object[] { DigitalTagValue, NumericTagValue }); }
/// <summary> /// Deprecated Method for adding a new object to the num_tags EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTonum_tags(num_tags num_tags) { base.AddObject("num_tags", num_tags); }
/// <summary> /// Create a new num_tags object. /// </summary> /// <param name="id">Initial value of the id property.</param> /// <param name="name">Initial value of the name property.</param> /// <param name="ref_io_devices">Initial value of the ref_io_devices property.</param> /// <param name="ref_tag_types">Initial value of the ref_tag_types property.</param> /// <param name="device">Initial value of the device property.</param> /// <param name="can_read">Initial value of the can_read property.</param> public static num_tags Createnum_tags(global::System.Int32 id, global::System.String name, global::System.Int32 ref_io_devices, global::System.Int32 ref_tag_types, global::System.String device, global::System.Boolean can_read) { num_tags num_tags = new num_tags(); num_tags.id = id; num_tags.name = name; num_tags.ref_io_devices = ref_io_devices; num_tags.ref_tag_types = ref_tag_types; num_tags.device = device; num_tags.can_read = can_read; return num_tags; }