Windows example: This example shows the usage of the pif interface.
Windows example: This example shows the usage of the pif interface. Consists of 2 files.
IRImagerHandler.cpp: This is the client and shows how to access the events and the digital/analog values.
../platform/windows/examples/pif/IRImagerHandler.cpp IRPifExample.cpp: This shows the pif initialization and configuration
#include <cstdio>
#include <iostream>
#include <Windows.h>
#include "IRDevice.h"
#include "IRImager.h"
#include "IRLogger.h"
#include "IRImagerHandler.h"
IRImagerHandler* _handler;
BOOL _ctrlHandler(DWORD fdwCtrlType)
{
delete _handler;
return true;
}
int main(int argc, char *argv[])
{
SetConsoleCtrlHandler((PHANDLER_ROUTINE)_ctrlHandler, TRUE);
if (argc < 2)
{
std::cout << "usage: " << argv[0] << " <path to xml file>" << std::endl;
return -1;
}
char *args = argv[1];
size_t argSize = strlen(args) + 1, converted;
wchar_t *argPath = new wchar_t[argSize];
mbstowcs_s(&converted, argPath, argSize, args, argSize);
return -1;
delete[] argPath;
evo::IRDevice *device = IRDevice::IRCreateDevice(_params);
if (device)
{
if (_imager.
init(&_params, device->getFrequency(), device->getWidth(), device->getHeight(),
true))
{
{
IRPifConfig pifConfig;
pifConfig = _imager.
setPifType(IRPifType::Intern, 1);
if (fwRevision >= 3000 && fwRevision < 3200 && pifType != IRPifType::Stackable)
{
pifConfig = _imager.
setPifType(IRPifType::Stackable, 1);
}
else
{
}
if (pifConfig.ChannelsDI.size() > 0)
{
pifConfig.ChannelsDI[0].Mode = IRChannelInputMode::Snapshot;
}
if (pifConfig.ChannelsAI.size() > 0)
{
pifConfig.ChannelsAI[0].IsLowActive = false;
pifConfig.ChannelsAI[0].Mode = IRChannelInputMode::Snapshot;
pifConfig.ChannelsAI[0].Threshold = 5;
}
if (pifConfig.ChannelsAO.size() > 0)
{
pifConfig.ChannelsAO[0].AnalogMode = IRChannelAnalogOutputMode::Range_0V_10V;
pifConfig.FlagOpenOutput.Channel = pifConfig.ChannelsAO[0];
pifConfig.FlagOpenOutput.AnalogValueClosed = 10;
pifConfig.FlagOpenOutput.AnalogValueMoving = 5;
pifConfig.FlagOpenOutput.AnalogValueOpen = 0;
}
if (pifConfig.ChannelsAO.size() > 1)
{
pifConfig.FrameSyncOutput.Channel = pifConfig.ChannelsAO[1];
pifConfig.FrameSyncOutput.AnalogValue = 3;
pifConfig.ChannelsAO[1].AnalogMode = IRChannelAnalogOutputMode::Range_0V_10V;
}
if (pifConfig.ChannelsAO.size() > 2)
{
pifConfig.ChannelsAO[2].Mode = IRChannelOutputMode::Manual;
pifConfig.ChannelsAO[2].AnalogMode = IRChannelAnalogOutputMode::Range_0V_10V;
}
if (pifConfig.ChannelsAO.size() > 3)
{
pifConfig.ChannelsAO[3].Mode = IRChannelOutputMode::Manual;
pifConfig.ChannelsAO[3].AnalogMode = IRChannelAnalogOutputMode::Range_0mA_20mA;
}
if (pifConfig.ChannelsDO.size() > 0)
if (pifConfig.ChannelsAO.size() > 2)
if (pifConfig.ChannelsAO.size() > 3)
}
else
{
std::cout << "No pif connected" << std::endl;
}
_handler = new IRImagerHandler(&_imager);
device->setClient(_handler);
device->startStreaming();
_handler->run(device);
device->stopStreaming();
}
}
else
{
std::cout << "IR Imager device could not be found" << std::endl;
}
return 0;
}
static bool readXML(const Tchar *xmlFile, IRDeviceParams ¶ms)
Static xml parsing method.
Wrapper for PI driver and image processing library.
Definition: IRImager.h:141
void setPifDO(unsigned char channel, bool value)
Set the Pif Digital Output.
bool init(IRDeviceParams *params, unsigned int frequency, unsigned int width, unsigned int height, bool useHID, unsigned short hwRev=0, unsigned short fwRev=0)
Initializing routine, to be called after instantiation.
unsigned char getPifDeviceCount(bool actual) const
Get the Pif Device Count.
IRPifConfig getPifConfig() const
Get the Pif Config object.
IRPifType::Value getPifType() const
Returns the current pif type.
void setPifAO(unsigned char channel, float value)
Set the Pif Analog Output.
void setPifConfig(IRPifConfig config)
Set the Pif Config.
unsigned int getFWRevision() const
Get firmware revision.
IRPifConfig setPifType(IRPifType::Value pifType, unsigned char pifDeviceCount)
Currently only for Xi80.
static void setVerbosity(IRLoggerVerbosityLevel levelStdout, IRLoggerVerbosityLevel levelFile, const char *filename=NULL)
Change verbosity level.
Structure containing device parameters.
Definition: IRDeviceParams.h:125
IRArray< IRChannelConfigDI > ChannelsDI
Channel config of digital input channel's.
Definition: IRPifConfig.h:154