DDC.DataStorage.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using TDMS.Common;
  4. namespace TDMS.Externals
  5. {
  6. internal partial class DDC : DIAdemConnectivity
  7. {
  8. /// <summary>
  9. /// 覆盖所有现有的数据值
  10. /// </summary>
  11. /// <param name="channel">通道句柄</param>
  12. /// <param name="values">
  13. /// 数据值的数组<br />
  14. /// 此数组的类型必须与指定通道的数据类型匹配。可以调用<see cref="DDC.GetDataType" />来获取通道的数据类型。
  15. /// </param>
  16. /// <param name="numValues">数组中值的个数</param>
  17. [DllImport(DLL, CallingConvention = CallingConvention.StdCall, EntryPoint = "DDC_SetDataValues")]
  18. public static extern Error SetDataValues(IntPtr channel, ref byte values, uint numValues);
  19. /// <summary>
  20. /// 函数用于为指定的通道设置时间戳数据值。该函数通过传递每个时间戳组件的单独数组来指定时间戳值。通过组合每个单独数组中的相应条目来构造每个完整的时间戳值。<br /><br />
  21. /// 参数说明<br />
  22. /// • channel(DDCChannelHandle) : 包含新数据值的通道的句柄。指定通道的数据类型必须是 DDC_Timestamp。<br />
  23. /// • year(unsigned int[]) : 包含时间戳值的年份组件的数组。该函数将每个年份值与其他时间戳组件数组中的相应值组合以构造单个时间戳值。年份表示本地日历时间。<br />
  24. /// • month(unsigned int[]) : 包含时间戳值的月份组件的数组。有效值为 1(1 月)到 12(12 月)。<br />
  25. /// • day(unsigned int[]) : 包含时间戳值的日期组件的数组。有效值为 1 到 31。<br />
  26. /// • hour(unsigned int[]) : 包含时间戳值的小时组件的数组。有效值为 0 到 23。<br />
  27. /// • minute(unsigned int[]) : 包含时间戳值的分钟组件的数组。有效值为 0 到 59。<br />
  28. /// • second(unsigned int[]) : 包含时间戳值的秒组件的数组。有效值为 0 到 59。<br />
  29. /// • millisecond(double[]) : 包含时间戳值的毫秒组件的数组。只能指定非负值。<br />
  30. /// • numberOfValues(size_t) : 每个时间戳组件数组中的值的数量。<br /><br />
  31. /// 返回值<br />
  32. /// • status(integer) : 返回值指示函数是否成功执行。零表示成功执行,负数表示错误代码。
  33. /// </summary>
  34. [DllImport(DLL, CallingConvention = CallingConvention.StdCall, EntryPoint = "DDC_SetDataValuesTimestampComponents")]
  35. public static extern Error SetDataValuesTimestampComponents(IntPtr channel,
  36. uint[] year,
  37. uint[] month,
  38. uint[] day,
  39. uint[] hour,
  40. uint[] minute,
  41. uint[] second,
  42. double[] milliSecond,
  43. uint numValues);
  44. /// <summary>
  45. /// 在现有数据值之后追加新的数据值。
  46. /// </summary>
  47. /// <param name="channel">通道句柄</param>
  48. /// <param name="values">
  49. /// 数据值的数组<br />
  50. /// 此数组的类型必须与指定通道的数据类型匹配。可以调用<see cref="DDC.GetDataType" />来获取通道的数据类型。
  51. /// </param>
  52. /// <param name="numValues">数组中值的个数</param>
  53. [DllImport(DLL, CallingConvention = CallingConvention.StdCall, EntryPoint = "DDC_AppendDataValues")]
  54. public static extern Error AppendDataValues(IntPtr channel, ref byte values, uint numValues);
  55. [DllImport(DLL, CallingConvention = CallingConvention.StdCall, EntryPoint = "DDC_AppendDataValuesTimestampComponents")]
  56. public static extern Error AppendDataValuesTimestampComponents(IntPtr channel,
  57. uint[] year,
  58. uint[] month,
  59. uint[] day,
  60. uint[] hour,
  61. uint[] minute,
  62. uint[] second,
  63. double[] milliSecond,
  64. uint numValues);
  65. /// <summary>
  66. /// 替换指定通道的数据值。新的数据值覆盖从指定索引处开始的现有数据值。
  67. /// </summary>
  68. /// <param name="channel">通道句柄</param>
  69. /// <param name="indexOfFirstValueToReplace">
  70. /// 要替换的通道中第一个数据值的从零开始的索引。从该索引开始的数据值将被values参数指定的值所替换。
  71. /// </param>
  72. /// <param name="values">
  73. /// 数据值的数组<br />
  74. /// 此数组的类型必须与指定通道的数据类型匹配。可以调用<see cref="DDC.GetDataType" />来获取通道的数据类型。
  75. /// </param>
  76. /// <param name="numValues">数组中值的个数</param>
  77. [DllImport(DLL, CallingConvention = CallingConvention.StdCall, EntryPoint = "DDC_ReplaceDataValues")]
  78. public static extern Error ReplaceDataValues(IntPtr channel,
  79. uint indexOfFirstValueToReplace,
  80. ref byte values,
  81. uint numValues);
  82. [DllImport(DLL, CallingConvention = CallingConvention.StdCall, EntryPoint = "DDC_ReplaceDataValuesTimestampComponents")]
  83. public static extern Error ReplaceDataValuesTimestampComponents(IntPtr channel,
  84. uint indexOfFirstValueToReplace,
  85. uint[] year,
  86. uint[] month,
  87. uint[] day,
  88. uint[] hour,
  89. uint[] minute,
  90. uint[] second,
  91. double[] milliSecond,
  92. uint numValues);
  93. }
  94. }