User`s manual

Writing Custom Applications
Module.Input().Info().Channels().DisableAll();
for (int i = 0; i < Channels(); ++i)
{
bool active = Settings.ActiveChannels[i] ? true : false;
if (active==true)
Module.Input().Info().Channels().Enabled(i, true);
}
X5_400M::IIClockSource src[] = { X5_400M::csExternal, X5_400M::csInternal };
Module.ClockSource(src[Settings.SampleClockSource]);
int ActiveChannels = Module.Input().Info().Channels().ActiveChannels();
if (!ActiveChannels)
{
UI->Log("Error: Must enable at least one channel");
UI->AfterStreamAutoStop();
return;
}
The module supports up to 2 channels of simultaneous data. The previous call to GetSettings populated the Settings object
with the number of channels to be enabled on this run. That information is used to enable the required channels via the
Channels object within the Module.Input().Info() object. The clock source is also programmed using its property.
// Packets scaled in units of events (samples per each enabled channel)
int SamplesPerWord = 1;
Module.ReturnPacketSize(Settings.PacketSize*ActiveChannels/SamplesPerWord + 2);
The size of the data packets sent from the module to the Host during streaming is programmable. This is helpful during
framed acquisition, since the packet size can be tailored to match a multiple of the frame size, providing application
notification on each acquired frame. In other applications, such as when an FFT is embedded within the FPGA, the packet
size can be programmed to match the processing block size from the algorithm within the FPGA.
//
// Start Loggers on active channels
if (Settings.PlotEnable)
Graph.Quit();
if (Settings.LoggerEnable || Settings.PlotEnable)
Logger.Start();
BlocksToLog = Settings.SamplesToLog/Settings.PacketSize
+ ((Settings.SamplesToLog%Settings.PacketSize) ? 1 : 0);
Stopped = false;
The example illustrates logging data to a disk file, with post-viewing of the acquired data using BinView. The code fragment
above closes any pending instance of BinView and logger data files.
Module.Dio().DioPortConfig(Settings.DioConfig);
The module supports programmable bit I/O, available on connector JP16. The code fragment above programs the direction
of these DIO bits in accordance with the settings from the GUI.
X5-GSPS User's Manual 53