FPGAFXPReadProperty.cs 894 B

1234567891011121314151617181920212223242526
  1. using FxpConvert.Common;
  2. namespace NIFPGA
  3. {
  4. public sealed class FPGAFXPReadProperty : FPGABaseProperty
  5. {
  6. Interop.NiFpgaDll_ReadU64 Read;
  7. private NiFpga_FxpTypeInfo _TypeInfo;
  8. private IFxpConvert _Convert;
  9. internal FPGAFXPReadProperty(FPGASession session, uint indicator, NiFpga_FxpTypeInfo typeInfo, IFxpConvert convert) : base(session, indicator, true)
  10. {
  11. _TypeInfo = typeInfo;
  12. _Convert = convert;
  13. Read = _Session.GetDelegate<Interop.NiFpgaDll_ReadU64>();
  14. }
  15. private float GetValue()
  16. {
  17. ulong value = 0;
  18. float temp = 0;
  19. _Session.CheckResult(Read(_Session.Session, Indicator, ref value));
  20. _Convert.FxpConvertToFloat(ref value, _TypeInfo, ref temp, 1);
  21. return temp;
  22. }
  23. public float Value => GetValue();
  24. }
  25. }