Exemplo n.º 1
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     NumTag = new NumTag {
         NumTagType = new NumTagType {
             Name = "Int32"
         }
     };
     Converter = new NumTagValueConverter(NumTag);
 }
Exemplo n.º 2
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     IoDeviceWrapper        = new Mock <IIoDeviceWrapper>();
     IoDeviceWrapperFactory = new Mock <IIoDeviceWrapperFactory>();
     IoDeviceWrapperFactory.Setup(f => f.Create()).Returns(IoDeviceWrapper.Object);
     IoDevice = new PHmiModel.Entities.IoDevice
     {
         Name    = "IoDeviceRunTargetName",
         Options = IoDeviceOptions,
         Type    = string.Format("{0}{1}{2}", IoDeviceFolder, PHmiConstants.PHmiIoDeviceSeparator, IoDeviceFile)
     };
     DigitalTag = new DigTag
     {
         Id      = 1,
         Device  = "M0",
         CanRead = true
     };
     IoDevice.DigTags.Add(DigitalTag);
     WriteOnlyDigitalTag = new DigTag
     {
         Id      = 2,
         Device  = "M1",
         CanRead = false
     };
     IoDevice.DigTags.Add(WriteOnlyDigitalTag);
     NumericTag = new NumTag
     {
         Id         = 1,
         Device     = "D0",
         NumTagType = new NumTagType {
             Name = "Int32"
         },
         CanRead = true
     };
     IoDevice.NumTags.Add(NumericTag);
     WriteOnlyNumericTag = new NumTag
     {
         Id         = 2,
         Device     = "D1",
         NumTagType = new NumTagType {
             Name = "Int16"
         },
         CanRead = false
     };
     IoDevice.NumTags.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 });
 }
Exemplo n.º 3
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     NumTag = new NumTag {
         NumTagType = new NumTagType {
             Name = "Int32"
         },
         RawMinDb = 0,
         RawMaxDb = 100,
         EngMinDb = 0,
         EngMaxDb = 10
     };
     Converter = new NumTagValueConverter(NumTag);
 }
Exemplo n.º 4
0
 public NumTagValueConverter(NumTag numericTag)
 {
     _type = numericTag.TagType;
     if (numericTag.RawMinDb == null || numericTag.RawMaxDb == null || numericTag.EngMinDb == null ||
         numericTag.EngMaxDb == null || numericTag.RawMaxDb - numericTag.RawMinDb == 0)
     {
         return;
     }
     _needCalculation = true;
     _mul             = (double)numericTag.EngMaxDb - (double)numericTag.EngMinDb;
     _add             = (double)numericTag.EngMinDb * (double)numericTag.RawMaxDb -
                        (double)numericTag.EngMaxDb * (double)numericTag.RawMinDb;
     _div = (double)numericTag.RawMaxDb - (double)numericTag.RawMinDb;
 }
Exemplo n.º 5
0
 public NumTagValueHolder(NumTag tag)
 {
     _converter = new NumTagValueConverter(tag);
     _address   = tag.Device;
 }