# AConvertPreTrigData()

For products with pretrigger implemented in hardware (most products), this function converts the raw data collected by APretrig(). The APretrig() method can return either raw A/D data or converted data, depending on whether or not the ConvertData option was used. The raw data is not in the correct order as it is collected. After the data collection is completed, it must be rearranged into the correct order. This method also orders the data, starting with the first pretrigger data point and ending with the last post-trigger point.

Member of the MccBoard class.

## Function Prototype

VB .NET

Public Function AConvertPreTrigData(ByVal preTrigCount As Integer, ByVal totalCount As Integer, ByVal adData As Short(), ByVal chanTags As Short()) As MccDaq.ErrorInfo

Public Function AConvertPretrigData(ByVal preTrigCount As Integer, ByVal totalCount As Integer, ByVal adData As System.UInt16(), ByVal chanTags As System.UInt16()) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo AConvertPreTrigData(int preTrigCount, int totalCount, short[] adData, short[] chanTags)

public MccDaq.ErrorInfo AConvertPretrigData(int preTrigCount, int totalCount, ushort[] adData, ushort[] chanTags)

##### Deprecated methods

The following methods are deprecated, and should only be used for legacy applications. The methods above are preferred, and must be used for 64-bit application development.

VB .NET

Public Function AConvertPreTrigData(ByVal preTrigCount As Integer, ByVal totalCount As Integer, ByRef adData As Short, ByRef chanTags As Short) As MccDaq.ErrorInfo

Public Function AConvertPretrigData(ByVal preTrigCount As Integer, ByVal totalCount As Integer, ByRef adData As System.UInt16, ByRef chanTags As System.UInt16) As MccDaq.ErrorInfo

C# .NET

public MccDaq.ErrorInfo AConvertPreTrigData(int preTrigCount, int totalCount, ref ushort adData, out ushort chanTags)

public AConvertPretrigData(int preTrigCount, int totalCount, ref short adData, out short chanTags)

## Parameters

preTrigCount

Number of pre-trigger samples (this value must match the value returned by the PretrigCount parameter in the APretrig() method).

totalCount

Total number of samples that were collected.

adData

Reference to data array (must match array name used in APretrig() method).

chanTags

A pointer to the start of the channel tag array (if available). Returns NULL if using a 16-bit board or if channel tags are not available. Refer to the note regarding 16-bit A/D boards below.

## Returns

- An ErrorInfo object that indicates the status of the operation.
- adData - converted data

## Notes

- When you collect data with APretrig() and you don't use the ConvertData option, you must use this method to convert the data after it is collected. There are cases where the ConvertData option is not allowed: for example, if you use the Background option with APretrig() on some devices, the ConvertData option is not allowed. In those cases this method should be used to convert the data after the data collection is complete.
- 12-Bit A/D boards: On some 12-bit boards, each raw data point consists of a 12-bit A/D value with a 4-bit channel number. This method pulls each data point apart and puts the A/D value into the adData and the channel number into the chanTags array.
- Upon returning from AConvertPretrigData(), adData array contains only 12-bit A/D data.
- 16-Bit A/D boards: This method is for use with 16-bit A/D boards only insofar as ordering the data. No channel tags are returned.
- The name of the ADData array must match that used in AInScan() or WinBufToArray().

- VB .Net Programmers: After the data is collected with APretrig(), it must be copied to a BASIC array with WinBufToArray().
- Important: The entire array must be copied, which includes the extra 512 samples needed by APretrig(). Example code is provided here:

SampleCount& = 10000
Dim A_D_Data%(SampleCount& + 512)
Dim Chan_Tags%(SampleCount& + 512)

APretrig%(LowChan, HighChan, PretrigCount&, SampleCount&...)

WinBufToArray%(MemHandle%, A_D_Data%, SampleCount& + 512)
AConvertPretrigData%(Pretrig_Count&, SampleCount&, A_D_Data%, Chan_Tags%)