|
@@ -6,6 +6,7 @@ namespace NIFPGA
|
|
where T : unmanaged
|
|
where T : unmanaged
|
|
{
|
|
{
|
|
private T[] tempvalue = new T[0];
|
|
private T[] tempvalue = new T[0];
|
|
|
|
+ private object lockObject = new object();
|
|
internal FPGAArrayWriteProperty(FPGASession session, uint indicator, uint count) : base(session, indicator, false)
|
|
internal FPGAArrayWriteProperty(FPGASession session, uint indicator, uint count) : base(session, indicator, false)
|
|
{
|
|
{
|
|
Count = count;
|
|
Count = count;
|
|
@@ -13,84 +14,90 @@ namespace NIFPGA
|
|
}
|
|
}
|
|
private void SetValue(T[] values)
|
|
private void SetValue(T[] values)
|
|
{
|
|
{
|
|
- if (values.Length != Count) return;
|
|
|
|
- switch (values[0])
|
|
|
|
|
|
+ lock (lockObject)
|
|
{
|
|
{
|
|
- case (bool):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayBool>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (byte):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU8>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (sbyte):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI8>()(_Session.Session, Indicator, ref Unsafe.As<T, sbyte>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (short):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI16>()(_Session.Session, Indicator, ref Unsafe.As<T, short>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (ushort):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU16>()(_Session.Session, Indicator, ref Unsafe.As<T, ushort>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (int):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI32>()(_Session.Session, Indicator, ref Unsafe.As<T, int>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (uint):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU32>()(_Session.Session, Indicator, ref Unsafe.As<T, uint>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (long):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI64>()(_Session.Session, Indicator, ref Unsafe.As<T, long>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (ulong):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU64>()(_Session.Session, Indicator, ref Unsafe.As<T, ulong>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (float):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArraySgl>()(_Session.Session, Indicator, ref Unsafe.As<T, float>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (double):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayDbl>()(_Session.Session, Indicator, ref Unsafe.As<T, double>(ref values[0]), Count));
|
|
|
|
- break;
|
|
|
|
|
|
+ if (values.Length != Count) return;
|
|
|
|
+ switch (values[0])
|
|
|
|
+ {
|
|
|
|
+ case (bool):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayBool>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (byte):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU8>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (sbyte):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI8>()(_Session.Session, Indicator, ref Unsafe.As<T, sbyte>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (short):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI16>()(_Session.Session, Indicator, ref Unsafe.As<T, short>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (ushort):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU16>()(_Session.Session, Indicator, ref Unsafe.As<T, ushort>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (int):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI32>()(_Session.Session, Indicator, ref Unsafe.As<T, int>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (uint):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU32>()(_Session.Session, Indicator, ref Unsafe.As<T, uint>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (long):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayI64>()(_Session.Session, Indicator, ref Unsafe.As<T, long>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (ulong):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayU64>()(_Session.Session, Indicator, ref Unsafe.As<T, ulong>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (float):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArraySgl>()(_Session.Session, Indicator, ref Unsafe.As<T, float>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (double):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_WriteArrayDbl>()(_Session.Session, Indicator, ref Unsafe.As<T, double>(ref values[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
private T[] GetValues()
|
|
private T[] GetValues()
|
|
{
|
|
{
|
|
- if (Count == 0) return tempvalue;
|
|
|
|
- switch (tempvalue[0])
|
|
|
|
|
|
+ lock (lockObject)
|
|
{
|
|
{
|
|
- case (bool):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayBool>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (byte):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU8>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (sbyte):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI8>()(_Session.Session, Indicator, ref Unsafe.As<T, sbyte>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case short:
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI16>()(_Session.Session, Indicator, ref Unsafe.As<T, short>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (ushort):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU16>()(_Session.Session, Indicator, ref Unsafe.As<T, ushort>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (int):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI32>()(_Session.Session, Indicator, ref Unsafe.As<T, int>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (uint):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU32>()(_Session.Session, Indicator, ref Unsafe.As<T, uint>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (long):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI64>()(_Session.Session, Indicator, ref Unsafe.As<T, long>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (ulong):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU64>()(_Session.Session, Indicator, ref Unsafe.As<T, ulong>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (float):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArraySgl>()(_Session.Session, Indicator, ref Unsafe.As<T, float>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
- case (double):
|
|
|
|
- _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayDbl>()(_Session.Session, Indicator, ref Unsafe.As<T, double>(ref tempvalue[0]), Count));
|
|
|
|
- break;
|
|
|
|
|
|
+ if (Count == 0) return tempvalue;
|
|
|
|
+ switch (tempvalue[0])
|
|
|
|
+ {
|
|
|
|
+ case (bool):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayBool>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (byte):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU8>()(_Session.Session, Indicator, ref Unsafe.As<T, byte>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (sbyte):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI8>()(_Session.Session, Indicator, ref Unsafe.As<T, sbyte>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case short:
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI16>()(_Session.Session, Indicator, ref Unsafe.As<T, short>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (ushort):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU16>()(_Session.Session, Indicator, ref Unsafe.As<T, ushort>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (int):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI32>()(_Session.Session, Indicator, ref Unsafe.As<T, int>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (uint):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU32>()(_Session.Session, Indicator, ref Unsafe.As<T, uint>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (long):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayI64>()(_Session.Session, Indicator, ref Unsafe.As<T, long>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (ulong):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayU64>()(_Session.Session, Indicator, ref Unsafe.As<T, ulong>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (float):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArraySgl>()(_Session.Session, Indicator, ref Unsafe.As<T, float>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ case (double):
|
|
|
|
+ _Session.CheckResult(_Session.GetDelegate<Interop.NiFpgaDll_ReadArrayDbl>()(_Session.Session, Indicator, ref Unsafe.As<T, double>(ref tempvalue[0]), Count));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return tempvalue;
|
|
}
|
|
}
|
|
- return tempvalue;
|
|
|
|
}
|
|
}
|
|
public uint Count { get; }
|
|
public uint Count { get; }
|
|
public T[] Values { get => GetValues(); set => SetValue(value); }
|
|
public T[] Values { get => GetValues(); set => SetValue(value); }
|