FPGAFXPReadProperty.cs 970 B

1234567891011121314151617181920212223242526272829
  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 double GetValue()
  16. {
  17. lock (Read)
  18. {
  19. ulong value = 0;
  20. double temp = 0;
  21. _Session.CheckResult(Read(_Session.Session, Indicator, ref value));
  22. _Convert.FxpConvertToDouble(ref value, _TypeInfo, ref temp, 1);
  23. return temp;
  24. }
  25. }
  26. public double Value => GetValue();
  27. }
  28. }