FPGAFXPReadProperty.cs 1016 B

123456789101112131415161718192021222324252627282930
  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 object _Lock = new object();
  9. private IFxpConvert _Convert;
  10. internal FPGAFXPReadProperty(FPGASession session, uint indicator, NiFpga_FxpTypeInfo typeInfo, IFxpConvert convert) : base(session, indicator, true)
  11. {
  12. _TypeInfo = typeInfo;
  13. _Convert = convert;
  14. Read = _Session.GetDelegate<Interop.NiFpgaDll_ReadU64>();
  15. }
  16. private double GetValue()
  17. {
  18. lock (_Lock)
  19. {
  20. ulong value = 0;
  21. double temp = 0;
  22. _Session.CheckResult(Read(_Session.Session, Indicator, ref value));
  23. _Convert.FxpConvertToDouble(ref value, _TypeInfo, ref temp, 1);
  24. return temp;
  25. }
  26. }
  27. public double Value => GetValue();
  28. }
  29. }