FPGAFXPReadProperty.cs 1018 B

12345678910111213141516171819202122232425262728293031
  1. using FxpConvert.Common;
  2. using NIFPGA.lvbitx;
  3. namespace NIFPGA
  4. {
  5. public sealed class FPGAFXPReadProperty : FPGABaseProperty
  6. {
  7. Interop.NiFpgaDll_ReadU64 Read;
  8. private NiFpga_FxpTypeInfo _TypeInfo;
  9. private object _Lock = new object();
  10. private IFxpConvert _Convert;
  11. internal FPGAFXPReadProperty(FPGASession session, Register indicator, IFxpConvert convert) : base(session, indicator)
  12. {
  13. _TypeInfo = indicator.FxpTypeInfo;
  14. _Convert = convert;
  15. Read = _Session.GetDelegate<Interop.NiFpgaDll_ReadU64>();
  16. }
  17. private double GetValue()
  18. {
  19. lock (_Lock)
  20. {
  21. ulong value = 0;
  22. double temp = 0;
  23. _Session.CheckResult(Read(_Session.Session, Register, ref value));
  24. _Convert.FxpConvertToDouble(ref value, _TypeInfo, ref temp, 1);
  25. return temp;
  26. }
  27. }
  28. public double Value => GetValue();
  29. }
  30. }