#define MIL1553
#define A429
#define CSDB
#define ASYNC
#define DISCRETE
#define HDLC
#define LOOPBACK
using System;
using static MAXT.MXFoundation.mxf;
using System.Runtime.InteropServices;
using System.Text;
namespace multi_example
{
class multi
{
const int ADDRESS = 5;
const int SUBADDRESS = 3;
const int ALMOST_FULL = 10;
const int ALMOST_EMPTY = 5;
const int MIL1553_IDX = 0;
const int A429_IDX = 1;
const int CSDB_IDX = 2;
const int ASYNC_IDX = 3;
const int DISCRETE_IDX = 4;
const int HDLC_IDX = 5;
const int BUFFER_SIZE = 1 * 1024 * 1024;
const int RATE = 250 * 1000 * 1000;
public static UInt64 discreteTimer = 0;
public struct EVENT_INFO_CHANNEL
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public UInt64[] txChannel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public UInt64[] rxChannel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public UInt64[] txBuffer;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
public UInt64[] rxBuffer;
public UInt64 sched;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
}
public struct EVENT_INFO
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public EVENT_INFO_CHANNEL[] channel;
public IntPtr hostBuffer;
}
public static EVENT_INFO eventInfo = new EVENT_INFO();
static void Main(string[] args)
{
UInt32 rc;
UInt64 deviceCount = 0;
UInt64 server;
var device = new UInt64[1];
UInt64 asyncEvent = 0;
eventInfo.channel = new EVENT_INFO_CHANNEL[6];
for (int i = 0; i < 6; i++)
{
eventInfo.channel[i].rxBuffer = new UInt64[1];
eventInfo.channel[i].rxChannel = new UInt64[1];
eventInfo.channel[i].txBuffer = new UInt64[1];
eventInfo.channel[i].txChannel = new UInt64[1];
}
#if LOCAL
#else
#endif
if (rc != MAXT_SUCCESS)
{
Console.Write("Failed to connect; rc=0x{0:x8}", rc);
Console.Write("\nPress a key to terminate\n");
Console.ReadKey();
return;
}
Console.Write("\nStarting\n");
if (rc == MAXT_SUCCESS)
{
if (rc == MAXT_SUCCESS && (deviceCount == 0))
rc = MAXT_ERROR_DEVICE_NOT_DETECTED;
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
try
{
eventInfo.hostBuffer = Marshal.AllocHGlobal(BUFFER_SIZE);
}
catch (OutOfMemoryException)
{
rc = MAXT_ERROR_MEM;
}
}
if (rc == MAXT_SUCCESS)
#if MIL1553
if (rc == MAXT_SUCCESS)
{
rc = startMil1553(device[0], asyncEvent, ref eventInfo.channel[MIL1553_IDX]);
}
#endif
#if A429
if (rc == MAXT_SUCCESS)
rc = startA429(device[0], asyncEvent, ref eventInfo.channel[A429_IDX]);
#endif
#if CSDB
if (rc == MAXT_SUCCESS)
rc = startCSDB(device[0], asyncEvent, ref eventInfo.channel[CSDB_IDX]);
#endif
#if ASYNC
if (rc == MAXT_SUCCESS)
rc = startASYNC(device[0], asyncEvent, ref eventInfo.channel[ASYNC_IDX]);
#endif
#if DISCRETE
if (rc == MAXT_SUCCESS)
rc = startDiscrete(device[0], asyncEvent, ref eventInfo.channel[DISCRETE_IDX]);
#endif
#if HDLC
if (rc == MAXT_SUCCESS)
rc = startHDLC(device[0], asyncEvent, ref eventInfo.channel[HDLC_IDX]);
#endif
if (rc == MAXT_SUCCESS)
#if MIL1553
if (rc == MAXT_SUCCESS)
rc = stopMil1553(asyncEvent, eventInfo.channel[MIL1553_IDX]);
#endif
#if A429
if (rc == MAXT_SUCCESS)
rc = stopA429(asyncEvent, eventInfo.channel[A429_IDX]);
#endif
#if CSDB
if (rc == MAXT_SUCCESS)
rc = stopCSDB(asyncEvent, eventInfo.channel[CSDB_IDX]);
#endif
#if ASYNC
if (rc == MAXT_SUCCESS)
rc = stopASYNC(asyncEvent, eventInfo.channel[ASYNC_IDX]);
#endif
#if DISCRETE
if (rc == MAXT_SUCCESS)
rc = stopDiscrete(asyncEvent, eventInfo.channel[DISCRETE_IDX]);
#endif
#if HDLC
if (rc == MAXT_SUCCESS)
rc = stopHDLC(asyncEvent, eventInfo.channel[HDLC_IDX]);
#endif
if (asyncEvent > 0)
if (rc != MAXT_SUCCESS)
{
StringBuilder buffer = new StringBuilder(256);
Console.WriteLine(buffer + "\n");
}
if (eventInfo.hostBuffer != IntPtr.Zero)
Marshal.FreeHGlobal(eventInfo.hostBuffer);
Console.Write("\n\rPress a key to terminate\n\r");
Console.ReadKey();
return;
}
private static UInt32 initHandler(UInt64 server, UInt64 deviceIndex, UInt64 moduleIndex, UInt64 channelIndex, UInt64 attrib, ref UInt64 value)
{
UInt64 device;
UInt32 rc;
if (attrib == KMXF_CHANNEL_CLASS)
{
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS && (deviceInfo.modules[moduleIndex].type == MXF_MODULE_ASYNC_EH))
{
if ((channelIndex == 0) || (channelIndex == deviceInfo.modules[moduleIndex].txCount))
{
value = MXF_CLASS_CSDB;
return 1;
}
}
else
{
if ((channelIndex == 0) || (channelIndex == 8))
{
value = MXF_CLASS_HDLC;
return 1;
}
else if ((channelIndex == 4) || (channelIndex == 12))
{
value = MXF_CLASS_CLOCK;
return 1;
}
}
}
return 0;
}
private static UInt32 startMil1553(UInt64 device, UInt64 asyncEvent, ref EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
var module = new UInt64[1];
UInt64 count;
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
# if LOOPBACK
if (rc == MAXT_SUCCESS)
#endif
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqBufferAlloc(eventInfoChn.rxChannel[0], BUFFER_SIZE, out eventInfoChn.rxBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
{
minorFrame[0].
buffer = eventInfoChn.txBuffer[0];
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
Console.Write("Starting MIL1553\n\r");
}
if (rc == MAXT_SUCCESS)
{
eventInfoChn.txCondition[0].
condID = MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.channel = eventInfoChn.txChannel[0];
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
eventInfoChn.rxCondition[0].
condID = MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.buffer = eventInfoChn.rxBuffer[0];
}
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqStart(eventInfoChn.rxBuffer[0], MXF_RXACQ_FLAG_DEFAULT, 0, 0);
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 startA429(UInt64 device, UInt64 asyncEvent, ref EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
var module = new UInt64[1];
UInt64 msgSched = 0;
UInt64 count;
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
rc =
mxfModuleChannelAllGet(module[0], MXF_CLASS_A429, MXF_SCLASS_RX_CHANNEL, 1, out count, eventInfoChn.rxChannel);
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
}
# if LOOPBACK
if (rc == MAXT_SUCCESS)
#endif
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqBufferAlloc(eventInfoChn.rxChannel[0], BUFFER_SIZE, out eventInfoChn.rxBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
{
Console.Write("Starting A429\n\r");
}
if (rc == MAXT_SUCCESS)
{
eventInfoChn.txCondition[0].condID = MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.channel = eventInfoChn.txChannel[0];
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
eventInfoChn.rxCondition[0].condID = MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.buffer = eventInfoChn.rxBuffer[0];
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqStart(eventInfoChn.rxBuffer[0], MXF_RXACQ_FLAG_DEFAULT, 0, 0);
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 startCSDB(UInt64 device, UInt64 asyncEvent, ref EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
var module = new UInt64[1];
UInt64 msgSched = 0;
recTXCsdb[0].
data =
new byte[12];
UInt64 txSyncBuffer = 0;
var txBuffer = new UInt64[2];
UInt64 count;
IntPtr recPtr = IntPtr.Zero;
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
rc =
mxfModuleChannelAllGet(module[0], MXF_CLASS_CSDB, MXF_SCLASS_RX_CHANNEL, 1, out count, eventInfoChn.rxChannel);
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
}
# if LOOPBACK
if (rc == MAXT_SUCCESS)
#endif
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqBufferAlloc(eventInfoChn.rxChannel[0], BUFFER_SIZE, out eventInfoChn.rxBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
{
Console.Write("Starting CSDB\n\r");
}
if (rc == MAXT_SUCCESS)
{
eventInfoChn.txCondition[0].condID = MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.txCondition[0].condition.txPeriodicUpdateMsgBufferThreshold.channel = eventInfoChn.txChannel[0];
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
eventInfoChn.rxCondition[0].condID = MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.buffer = eventInfoChn.rxBuffer[0];
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
txBuffer[0] = txSyncBuffer;
txBuffer[1] = eventInfoChn.txBuffer[0];
}
try
{
}
catch(OutOfMemoryException)
{
rc = MAXT_ERROR_MEM;
}
if (rc == MAXT_SUCCESS)
{
recTXCsdb[0].timeTag = 0;
recTXCsdb[0].control = 0;
recTXCsdb[0].repeatCount = 1;
recTXCsdb[0].reserved = 0;
recTXCsdb[0].data[0] = 0xA5;
recTXCsdb[0].data[1] = 0xA5;
recTXCsdb[0].data[2] = 0xA5;
recTXCsdb[0].data[3] = 0xA5;
recTXCsdb[0].data[4] = 0xA5;
recTXCsdb[0].data[5] = 0xA5;
}
Marshal.StructureToPtr(recTXCsdb[0], recPtr, true);
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqStart(eventInfoChn.rxBuffer[0], MXF_RXACQ_FLAG_DEFAULT, 0, 0);
if (rc == MAXT_SUCCESS)
Marshal.FreeHGlobal(recPtr);
return rc;
}
private static UInt32 startASYNC(UInt64 device, UInt64 asyncEvent, ref EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
var module = new UInt64[1];
UInt64 count;
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
rc =
mxfModuleChannelAllGet(module[0], MXF_CLASS_ASYNC_ENHANCED, MXF_SCLASS_RX_CHANNEL, 1, out count, eventInfoChn.rxChannel);
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
}
# if LOOPBACK
if (rc == MAXT_SUCCESS)
#endif
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
rc =
mxfTxAperiodicBufferAlloc(eventInfoChn.txChannel[0], MXF_TXAPERIODIC_PRIORITY_NORMAL, BUFFER_SIZE, out eventInfoChn.txBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqBufferAlloc(eventInfoChn.rxChannel[0], BUFFER_SIZE, out eventInfoChn.rxBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
{
eventInfoChn.rxCondition[0].condID = MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.buffer = eventInfoChn.rxBuffer[0];
}
if (rc == MAXT_SUCCESS)
{
Console.Write("Starting ASYNC\n\r");
rc =
mxfRxAcqStart(eventInfoChn.rxBuffer[0], MXF_RXACQ_FLAG_DEFAULT, 0, 0);
}
if (rc == MAXT_SUCCESS)
{
eventInfoChn.txCondition[0].condID = MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.buffer = eventInfoChn.txBuffer[0];
}
return rc;
}
private static UInt32 startDiscrete(UInt64 device, UInt64 asyncEvent, ref EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
var module = new UInt64[1];
UInt64 moduleCount;
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
# if LOOPBACK
if (rc == MAXT_SUCCESS)
#endif
if (rc == MAXT_SUCCESS)
rc =
mxfTxAperiodicBufferAlloc(eventInfoChn.txChannel[0], MXF_TXAPERIODIC_PRIORITY_NORMAL, BUFFER_SIZE, out eventInfoChn.txBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqBufferAlloc(eventInfoChn.rxChannel[0], BUFFER_SIZE, out eventInfoChn.rxBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
{
eventInfoChn.rxCondition[0].condID = MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.buffer = eventInfoChn.rxBuffer[0];
}
if (rc == MAXT_SUCCESS)
{
Console.Write("Starting Discrete\n\r");
rc =
mxfRxAcqStart(eventInfoChn.rxBuffer[0], MXF_RXACQ_FLAG_DEFAULT, 0, 0);
}
if (rc == MAXT_SUCCESS)
{
eventInfoChn.txCondition[0].condID = MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.buffer = eventInfoChn.txBuffer[0];
}
return rc;
}
private static UInt32 startHDLC(UInt64 device, UInt64 asyncEvent, ref EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
var module = new UInt64[1];
UInt64 count;
if (rc == MAXT_SUCCESS && count > 0)
rc =
mxfModuleChannelAllGet(module[0], MXF_CLASS_HDLC, MXF_SCLASS_TX_CHANNEL, 1, out count, eventInfoChn.txChannel);
if (rc == MAXT_SUCCESS && count > 0)
rc =
mxfModuleChannelAllGet(module[0], MXF_CLASS_HDLC, MXF_SCLASS_RX_CHANNEL, 1, out count, eventInfoChn.rxChannel);
if (rc == MAXT_SUCCESS && count == 0)
rc = MAXT_ERROR_NOT_FOUND;
# if LOOPBACK
if (rc == MAXT_SUCCESS)
#endif
if (rc == MAXT_SUCCESS)
rc =
mxfTxAperiodicBufferAlloc(eventInfoChn.txChannel[0], MXF_TXAPERIODIC_PRIORITY_NORMAL, BUFFER_SIZE, out eventInfoChn.txBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
rc =
mxfRxAcqBufferAlloc(eventInfoChn.rxChannel[0], BUFFER_SIZE, out eventInfoChn.rxBuffer[0], IntPtr.Zero);
if (rc == MAXT_SUCCESS)
{
eventInfoChn.rxCondition[0].condID = MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.rxCondition[0].condition.rxAcqBufferThreshold.buffer = eventInfoChn.rxBuffer[0];
}
if (rc == MAXT_SUCCESS)
{
Console.Write("Starting HDLC\n\r");
rc =
mxfRxAcqStart(eventInfoChn.rxBuffer[0], MXF_RXACQ_FLAG_DEFAULT, 0, 0);
}
if (rc == MAXT_SUCCESS)
{
eventInfoChn.txCondition[0].condID = MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.almostEmpty = ALMOST_EMPTY;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.almostFull = ALMOST_FULL;
eventInfoChn.txCondition[0].condition.txAperiodicBufferThreshold.buffer = eventInfoChn.txBuffer[0];
}
return rc;
}
private static UInt32 stopMil1553(UInt64 asyncEvent, EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
Console.Write("Stopping MIL1553\n\r");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 stopA429(UInt64 asyncEvent, EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
Console.Write("Stopping A429\n\r");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 stopCSDB(UInt64 asyncEvent, EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
Console.Write("Stopping CSDB\n\r");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 stopASYNC(UInt64 asyncEvent, EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
Console.Write("Stopping ASYNC\n\r");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 stopDiscrete(UInt64 asyncEvent, EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
Console.Write("Stopping Discrete\n\r");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 stopHDLC(UInt64 asyncEvent, EVENT_INFO_CHANNEL eventInfoChn)
{
UInt32 rc;
Console.Write("Stopping HDLC\n\r");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
return rc;
}
private static UInt32 eventHandler(UInt64 asyncEvent, IntPtr pParam)
{
UInt32 rc = 0;
UInt64 eventCount;
UInt64 rec;
IntPtr recPtr = IntPtr.Zero;
if (rc == MAXT_SUCCESS)
{
switch (pendingList[0].condID)
{
case MXF_ASYNCEVENT_COND_TXPERIODIC_UPDATEMSG_BUFFER_THRESHOLD:
{
if (pendingList[0].condition.txPeriodicUpdateMsgBufferThreshold.buffer == eventInfo.channel[MIL1553_IDX].txBuffer[0])
{
txRec.
data =
new UInt16[36];
recPtr = eventInfo.hostBuffer;
{
txRec.
data[1] = (UInt16)rec;
txRec.
data[2] = (UInt16)rec;
txRec.
data[3] = (UInt16)rec;
txRec.
data[4] = (UInt16)rec;
Marshal.StructureToPtr(txRec, recPtr, true);
}
}
else if (pendingList[0].condition.txPeriodicUpdateMsgBufferThreshold.buffer == eventInfo.channel[A429_IDX].txBuffer[0])
{
recPtr = eventInfo.hostBuffer;
{
Marshal.StructureToPtr(txRec, recPtr, true);
}
}
else if (pendingList[0].condition.txPeriodicUpdateMsgBufferThreshold.buffer == eventInfo.channel[CSDB_IDX].txBuffer[0])
{
txRec.
data =
new byte[12];
recPtr = eventInfo.hostBuffer;
{
txRec.
data[0] = (byte)rec;
txRec.
data[1] = (byte)rec;
txRec.
data[2] = (byte)rec;
txRec.
data[3] = (byte)rec;
txRec.
data[4] = (byte)rec;
txRec.
data[5] = (byte)rec;
Marshal.StructureToPtr(txRec, recPtr, true);
}
}
break;
}
case MXF_ASYNCEVENT_COND_TXAPERIODIC_BUFFER_THRESHOLD:
{
if (pendingList[0].condition.txAperiodicBufferThreshold.buffer == eventInfo.channel[ASYNC_IDX].txBuffer[0])
{
txRec.
data =
new byte[256];
recPtr = eventInfo.hostBuffer;
int i;
{
for (i = 0; i < 10; i++)
txRec.
data[i] = (byte)rec;
Marshal.StructureToPtr(txRec, recPtr, true);
}
rc =
mxfTxAperiodicWrite(pendingList[0].condition.txAperiodicBufferThreshold.buffer, MXF_TXAPERIODIC_FLAG_DEFAULT, RATE * rec, rec, eventInfo.hostBuffer);
}
else if (pendingList[0].condition.txPeriodicUpdateMsgBufferThreshold.buffer == eventInfo.channel[DISCRETE_IDX].txBuffer[0])
{
recPtr = eventInfo.hostBuffer;
if (discreteTimer == 0)
{
UInt64 device;
rc =
mxfChannelInfoGet(eventInfo.channel[DISCRETE_IDX].txChannel[0], out device, IntPtr.Zero);
if (rc == MAXT_SUCCESS)
if (rc != MAXT_SUCCESS)
break;
}
{
Marshal.StructureToPtr(txRec, recPtr, true);
discreteTimer += RATE;
}
rc =
mxfTxAperiodicWrite(pendingList[0].condition.txAperiodicBufferThreshold.buffer, MXF_TXAPERIODIC_FLAG_USE_RECORD_ABSOLUTE_TIME, 0, rec, eventInfo.hostBuffer);
}
else if (pendingList[0].condition.txPeriodicUpdateMsgBufferThreshold.buffer == eventInfo.channel[HDLC_IDX].txBuffer[0])
{
txRec.
data =
new UInt16[2048];
recPtr = eventInfo.hostBuffer;
UInt64 i;
{
for (i = 0; i < txRec.
dataSize / 2; i++)
txRec.
data[i] = (UInt16)rec;
Marshal.StructureToPtr(txRec, recPtr, true);
}
rc =
mxfTxAperiodicWrite(pendingList[0].condition.txAperiodicBufferThreshold.buffer, MXF_TXAPERIODIC_FLAG_DEFAULT, RATE * rec, rec, eventInfo.hostBuffer);
}
break;
}
case MXF_ASYNCEVENT_COND_RXACQ_BUFFER_THRESHOLD:
{
UInt64 rxAcqStatus, msgCount, byteCount;
rc =
mxfASYNCEHRxAcqRead(pendingList[0].condition.rxAcqBufferThreshold.buffer, 0, BUFFER_SIZE, out rxAcqStatus, out msgCount, out byteCount, eventInfo.hostBuffer);
if (rc != MAXT_SUCCESS)
break;
if (pendingList[0].condition.rxAcqBufferThreshold.buffer == eventInfo.channel[MIL1553_IDX].rxBuffer[0])
{
UInt64 data;
recPtr = eventInfo.hostBuffer;
for (rec = 0; rc == MAXT_SUCCESS && rec < msgCount; rec++)
{
Console.Write("MIL1553 --> {0} ", rxRec[rec].timeTag);
Console.Write("{0:x8} ", rxRec[rec].control);
Console.Write("{0:0000} ", (rxRec[rec].dataSize / 2) - 1);
for (data = 0; data < Math.Min(8, rxRec[rec].dataSize / 2); data++)
{
Console.Write("{0:X4} ", rxRec[rec].data[data]);
}
Console.Write("\n\r");
}
}
else if (pendingList[0].condition.rxAcqBufferThreshold.buffer == eventInfo.channel[A429_IDX].rxBuffer[0])
{
recPtr = eventInfo.hostBuffer;
for (rec = 0; rc == MAXT_SUCCESS && rec < msgCount; rec++)
{
Console.Write("A429 --> {0} ", rxRec[rec].timeTag);
Console.Write("{0:x8} ", rxRec[rec].control);
Console.Write("{0:x8} \n\r", rxRec[rec].data);
}
}
else if (pendingList[0].condition.rxAcqBufferThreshold.buffer == eventInfo.channel[CSDB_IDX].rxBuffer[0])
{
UInt64 data;
recPtr = eventInfo.hostBuffer;
for (rec = 0; rc == MAXT_SUCCESS && rec < msgCount; rec++)
{
Console.Write("CSDB --> {0} ", rxRec[rec].timeTag);
Console.Write("{0:x8} ", rxRec[rec].control);
for (data = 0; data < 6; data++)
{
Console.Write("{0:X2} ", rxRec[rec].data[data]);
}
Console.Write("\n\r");
}
}
else if (pendingList[0].condition.rxAcqBufferThreshold.buffer == eventInfo.channel[ASYNC_IDX].rxBuffer[0])
{
UInt64 data;
recPtr = eventInfo.hostBuffer;
for (rec = 0; rc == MAXT_SUCCESS && rec < msgCount; rec++)
{
Console.Write("ASYNC --> {0} ", rxRec[rec].timeTag);
Console.Write("{0:x8} ", rxRec[rec].control);
Console.Write("{0:0000} ", rxRec[rec].dataSize);
for (data = 0; data < rxRec[rec].dataSize; data++)
{
Console.Write("{0:X2} ", rxRec[rec].data[data]);
}
Console.Write("\n\r");
}
}
else if (pendingList[0].condition.rxAcqBufferThreshold.buffer == eventInfo.channel[DISCRETE_IDX].rxBuffer[0])
{
recPtr = eventInfo.hostBuffer;
for (rec = 0; rc == MAXT_SUCCESS && rec < msgCount; rec++)
{
Console.Write("DISCRETE --> {0} ", rxRec[rec].timeTag);
Console.Write("{0:X2} ", (byte)rxRec[rec].edge);
Console.Write("{0:X2} \n\r", (byte)rxRec[rec].data);
}
}
else if (pendingList[0].condition.txPeriodicUpdateMsgBufferThreshold.buffer == eventInfo.channel[HDLC_IDX].rxBuffer[0])
{
UInt64 data;
recPtr = eventInfo.hostBuffer;
for (rec = 0; rc == MAXT_SUCCESS && rec < msgCount; rec++)
{
Console.Write("HDLC --> {0} ", rxRec[rec].timeTag);
Console.Write("{0:x8} ", rxRec[rec].control);
Console.Write("{0:0000} ", rxRec[rec].dataSize / 2);
for (data = 0; data < Math.Min(8, rxRec[rec].dataSize / 2); data++)
{
Console.Write("{0:X4} ", rxRec[rec].data[data]);
}
Console.Write("\n\r");
}
}
break;
}
}
}
if (rc != MAXT_SUCCESS)
Console.Write("event handler rc=0x{0:x8}\n\r", rc);
return rc;
}
}
}