FPGAArrayFXPReadProperty.cs 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. using FxpConvert.Common;
  2. namespace NIFPGA
  3. {
  4. public sealed class FPGAArrayFXPReadProperty : FPGABaseProperty
  5. {
  6. Interop.NiFpgaDll_ReadArrayU64 Read;
  7. private NiFpga_FxpTypeInfo _TypeInfo;
  8. private IFxpConvert _Convert;
  9. private ulong[] tempvalue = new ulong[0];
  10. private float[] doubles = new float[0];
  11. internal FPGAArrayFXPReadProperty(FPGASession session, uint indicator, uint count, NiFpga_FxpTypeInfo typeInfo, IFxpConvert convert) : base(session, indicator, true)
  12. {
  13. _Convert = convert;
  14. Count = count;
  15. tempvalue = new ulong[count];
  16. doubles = new float[count];
  17. _TypeInfo = typeInfo;
  18. Read = _Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU64>();
  19. }
  20. private float[] GetData()
  21. {
  22. _Session.CheckResult(Read(_Session.Session, Indicator, ref tempvalue[0], Count));
  23. _Convert.FxpConvertToFloat(ref tempvalue[0], _TypeInfo, ref doubles[0], Count);
  24. return doubles;
  25. }
  26. public uint Count { get; }
  27. public float[] Value { get => GetData(); }
  28. }
  29. }