According to the device, the digital I/O information will be displayed. In detail this will be:
Apart from this output of the current state and description of the different input and output signal lines and related properties the user can also interactively change the state of the digital output line and some other properties during the sample execution. How this can be achieved can be seen in the source code of the sample.
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <thread>
#include <vector>
#include <apps/Common/exampleHelper.h>
#include <common/minmax.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#include <mvIMPACT_CPP/mvIMPACT_acquire_GenICam.h>
using namespace std;
string getStringFromCIN( void )
{
cout << endl << ">>> ";
string cmd;
cin >> cmd;
cin.get();
return cmd;
}
int getIntFromCIN( void )
{
return atoi( getStringFromCIN().c_str() );
}
int getHEXFromCIN( void )
{
int result = 0;
#if (defined(_MSC_VER) && (_MSC_VER >= 1400)) || defined (__STDC_LIB_EXT1__)
sscanf_s( getStringFromCIN().c_str(), "%i", &result );
#else
sscanf( getStringFromCIN().c_str(), "%i", &result );
#endif
return result;
}
template<typename _Ty>
void hexToCOUT( const _Ty& param )
{
cout.setf( ios::hex, ios::basefield );
cout << "0x" << param;
cout.unsetf( ios::hex );
}
{
}
{
cout << "This device has" << endl;
cout << " " << inputCount << " digital input(s)" << endl;
for( unsigned int i = 0; i < inputCount; i++ )
{
}
cout << endl;
if( inputCount > 0 )
{
cout << "All input registers can be queried with a single function call: Calling 'readInputRegister' returned ";
cout << endl;
cout << "From the LSB to the MSB a '1' in this result indicates, that this input is currently connected to a signal" << endl
<< "that is interpreted as a logical '1'. E.g. 0x13 indicates that inputs 0, 1 and 4 are currently in 'high' state." << endl;
}
cout << " " << outputCount << " digital output(s)" << endl;
if( outputCount > 0 )
{
unsigned int readOnlyAccessMask = 0;
bool boRun = true;
while( boRun )
{
for( unsigned int j = 0; j < outputCount; j++ )
{
cout <<
" [" << j <<
"]: " << pOutput->
getDescription() <<
"(current state: " << pOutput->
get() <<
", " << ( pOutput->
isWriteable() ?
"" :
"NOT " ) <<
"manually switchable)" << endl;
{
readOnlyAccessMask |= 1 << j;
}
}
cout << endl;
cout << "Enter the number of a digital output followed by [ENTER] to modify its state or 'c' followed by [ENTER] to continue." << endl;
const string cmd( getStringFromCIN() );
if( cmd == "c" )
{
boRun = false;
continue;
}
const unsigned int index = static_cast<unsigned int>( atoi( cmd.c_str() ) );
if( ( index >= outputCount ) || !isdigit( cmd[0] ) )
{
cout << "Invalid selection" << endl;
continue;
}
{
cout << pOutput->
getDescription() <<
" is not manually switchable." << endl;
continue;
}
cout << "Please enter the number in front of the function that shall be called followed by [ENTER]:" << endl;
cout << " [0]: set" << endl
<< " [1]: reset" << endl
<< " [2]: flip" << endl;
const int newMode = getIntFromCIN();
switch( newMode )
{
case 0:
break;
case 1:
break;
case 2:
break;
default:
cout << "Invalid selection." << endl;
break;
}
}
cout << "All output registers can be queried with a single function call." << endl
<< endl
<< "From the LSB to the MSB a '1' in this result indicates, that this output is currently switched to 'high' or 'active' state" << endl
<< endl
<< "E.g. 0x22 indicates that outputs 1 and 5 (zero-based) are currently in 'high' state." << endl;
const unsigned int fullOutputMask = bitMask( outputCount );
boRun = true;
while( boRun )
{
cout << "Calling 'readOutputRegister' returned ";
cout << endl;
cout << "Please enter 'y' followed by [ENTER] to modify all digital outputs with a single function" << endl
<< "call or anything else followed by [ENTER] to continue." << endl;
if( getStringFromCIN() != "y" )
{
boRun = false;
continue;
}
cout << "Please enter the bitmask in hex that contains the new values for the digital outputs followed by [ENTER]: ";
unsigned int value = static_cast<unsigned int>( getHEXFromCIN() );
if( value & ~fullOutputMask )
{
value &= fullOutputMask;
cout << "WARNING: More bits than outputs specified. Bitmask truncated to ";
hexToCOUT( value );
cout << endl;
}
cout << "Please enter the bitmask in hex that contains '1's for outputs that shall be affected by this operation followed by [ENTER]: ";
const unsigned int mask = static_cast<unsigned int>( getHEXFromCIN() );
if( readOnlyAccessMask & mask )
{
cout << "WARNING: At least one selected output is not manually switchable: Mask: ";
hexToCOUT( mask );
cout << ", read-only access mask: ";
hexToCOUT( readOnlyAccessMask );
cout << endl;
cout << "No digital outputs have been modified." << endl
<< endl;
continue;
}
}
}
cout << "This device also has" << endl;
cout <<
" " << ioss.
RTCtrProgramCount() <<
" hardware real-time controller(s)." << endl
<< endl;
{
cout << "How to program the HRTC (Hardware RealTime Controller) is not part of this sample, but the manual will contain a separate chapter on this topic.";
}
<< endl;
}
void mvGenICamIOAccess(
Device* pDev )
{
try
{
const unsigned int IOCount = dioc.lineSelector.dictSize();
bool boRun = true;
while( boRun )
{
cout << endl;
cout << " This device has " << IOCount << " DigitalIOs" << endl;
cout << " ------------------------------------------" << endl;
vector<int64_type> validLineSelectorValues;
dioc.lineSelector.getTranslationDictValues( validLineSelectorValues );
for( const auto& value : validLineSelectorValues )
{
dioc.lineSelector.write( value );
cout << " IO " << value << ": \t Type: " << dioc.lineMode.readS() << " \t Current state: " << ( dioc.lineStatus.read() ? "ON" : "OFF" ) << endl;
}
cout << " ------------------------------------------" << endl;
cout << endl;
cout << "Please enter a valid line number followed by [ENTER]:" << endl;
cout << "- if it is an output its value will be inverted" << endl;
cout << "- if it is an input its value will be polled continuously for 10 seconds" << endl;
cout << "- or enter 'c' followed by [ENTER] to continue:" << endl;
const string cmd( getStringFromCIN() );
if( cmd == "c" )
{
boRun = false;
continue;
}
const unsigned int index = static_cast<unsigned int>( atoi( cmd.c_str() ) );
if( ( index >= IOCount ) || !isdigit( cmd[0] ) )
{
cout << "Invalid selection" << endl;
continue;
}
dioc.lineSelector.write( index );
if( dioc.lineMode.readS() == "Output" )
{
dioc.lineInverter.write( dioc.lineInverter.read() ?
bFalse :
bTrue );
}
else if( dioc.lineMode.readS() == "Input" )
{
cout << endl
<< endl;
cout << " ------------------------------------------" << endl;
cout << " Polling Input '" << dioc.lineSelector.readS() << "'" << endl;
cout << " ------------------------------------------" << endl;
cout << endl;
for( int i = 0; i < 100; i++ )
{
cout << "\r Value:" << ( dioc.lineStatus.read() ? "ON" : "OFF" );
this_thread::sleep_for( chrono::milliseconds( 100 ) );
cout << "\t Remaining Time:"
<< fixed << setprecision( 1 )
<< ( 10. - ( static_cast<double>( i + 1 ) / 10. ) );
cout.flush();
}
cout << endl
<< endl;
}
else
{
cout << "IO " << index << " is a '" << dioc.lineMode.readS() << "'!" << endl;
}
}
}
{
cout << endl;
cout << endl;
}
}
void mvBlueFOXIOAccess(
Device* pDev )
{
displayCommonIOFeatures( ioss );
if( ioss.digitalInputThreshold.isValid() )
{
cout << "This device also supports the '" << ioss.digitalInputThreshold.name() << "' property." << endl;
displayPropertyData( ioss.digitalInputThreshold );
}
cout << "To use a digital output in 'expose active' mode, the property '" << cs.flashMode.name() << "' can be used." << endl
<< "If a delay between switching the output and starting the frame exposure is needed, this can be achieved by " << endl
<< "writing to the property '" << cs.flashToExposeDelay_us.name() << "'." << endl;
}
void frameGrabberIOAccess(
Device* pDev )
{
displayCommonIOFeatures( ioss );
const unsigned int HDOutputCount = ioss.getHDOutputCount();
const unsigned int VDOutputCount = ioss.getVDOutputCount();
if( ( HDOutputCount > 0 ) || ( VDOutputCount > 0 ) )
{
cout << "This device also offers" << endl;
bool boRun = true;
while( boRun )
{
cout << " " << HDOutputCount << " HD output(s)" << endl;
for( unsigned int i = 0; i < HDOutputCount; i++ )
{
}
cout << endl;
cout << " " << VDOutputCount << " VD output(s)" << endl;
for( unsigned int j = 0; j < VDOutputCount; j++ )
{
}
cout << "HD and VD output signals are currently switched to '" << ioss.syncOutputMode.readS() << "' mode." << endl;
cout << "Please enter the number in front of the function that shall be called followed by [ENTER] or 'c' followed by [ENTER] to continue:" << endl;
cout << " [0]: modify the properties a HD output" << endl
<< " [1]: modify the properties a VD output" << endl
<< " [2]: modify the " << ioss.syncOutputMode.name() << " property." << endl;
const string cmd( getStringFromCIN() );
if( cmd == "c" )
{
boRun = false;
continue;
}
const unsigned int cmdIndex = static_cast<unsigned int>( atoi( cmd.c_str() ) );
if( ( cmdIndex > 2 ) || !isdigit( cmd[0] ) )
{
cout << "Invalid selection" << endl;
continue;
}
switch( cmdIndex )
{
case 0:
{
cout << "Please enter the index of the HD-output you want to modify followed by [ENTER]: ";
const string HDOutputString( getStringFromCIN() );
const unsigned int HDOutputIndex = static_cast<unsigned int>( atoi( HDOutputString.c_str() ) );
if( ( HDOutputIndex >= HDOutputCount ) || !isdigit( HDOutputString[0] ) )
{
cout << "Invalid selection" << endl;
continue;
}
modifySyncOutput( ioss.HDOutput( HDOutputIndex ) );
}
break;
case 1:
{
cout << "Please enter the index of the VD-output you want to modify followed by [ENTER]: ";
const string VDOutputString( getStringFromCIN() );
const unsigned int VDOutputIndex = static_cast<unsigned int>( atoi( VDOutputString.c_str() ) );
if( ( VDOutputIndex >= VDOutputCount ) || !isdigit( VDOutputString[0] ) )
{
cout << "Invalid selection" << endl;
continue;
}
modifySyncOutput( ioss.VDOutput( VDOutputIndex ) );
}
break;
case 2:
displayPropertyData( ioss.syncOutputMode );
modifyPropertyValue( ioss.syncOutputMode );
default:
break;
}
}
}
else
{
cout << "HD and VD output signals are not supported by this device." << endl;
}
if( outputCount > 0 )
{
}
}
int main( void )
{
Device* pDev = getDeviceFromUserInput( devMgr );
if( pDev == nullptr )
{
cout << "Unable to continue! Press [ENTER] to end the application" << endl;
cin.get();
return 1;
}
{
mvGenICamIOAccess( pDev );
}
{
mvBlueFOXIOAccess( pDev );
}
{
frameGrabberIOAccess( pDev );
}
else
{
cout <<
"Device " << pDev->
serial.
read() <<
"(" << pDev->
product <<
") is not supported by this sample" << endl;
cout << "Press [ENTER] to end the application" << endl;
cin.get();
return 1;
}
cout << "Press [ENTER] to end the application" << endl;
cin.get();
return 0;
}
mvBlueFOX related camera settings(Device specific interface layout only).
Definition: mvIMPACT_acquire.h:19577
bool isValid(void) const
Checks if the internal component referenced by this object is still valid.
Definition: mvIMPACT_acquire.h:1603
Grants access to devices that can be operated by this software interface.
Definition: mvIMPACT_acquire.h:6964
This class and its functions represent an actual device detected by this interface in the current sys...
Definition: mvIMPACT_acquire.h:5948
PropertyS product
A string property (read-only) containing the product name of this device.
Definition: mvIMPACT_acquire.h:6342
PropertyS serial
A string property (read-only) containing the serial number of this device.
Definition: mvIMPACT_acquire.h:6351
PropertyS family
A string property (read-only) containing the family name of this device.
Definition: mvIMPACT_acquire.h:6340
PropertyIDeviceClass deviceClass
An enumerated integer property (read-only) defining the device class this device belongs to.
Definition: mvIMPACT_acquire.h:6338
PropertyIDeviceInterfaceLayout interfaceLayout
An enumerated integer property which can be used to define which interface layout shall be used when ...
Definition: mvIMPACT_acquire.h:6444
A class to represent a digital output pin(Device specific interface layout only).
Definition: mvIMPACT_acquire.h:15151
bool get(void) const
Returns the current state of this output pin.
Definition: mvIMPACT_acquire.h:15176
void set(void)
Sets the output pin to 'logic 1'.
Definition: mvIMPACT_acquire.h:15199
void reset(void)
Sets the output pin to 'logic 0'.
Definition: mvIMPACT_acquire.h:15204
bool isWriteable(void) const
Checks if the caller has write/modify access to this digital output.
Definition: mvIMPACT_acquire.h:15194
std::string getDescription(void) const
Returns a description for this digital output.
Definition: mvIMPACT_acquire.h:15214
bool flip(void)
Inverts the current state of the digital output and returns the previous state.
Definition: mvIMPACT_acquire.h:15164
ZYX read(int index=0) const
Reads a value from a property.
Definition: mvIMPACT_acquire.h:4170
Category that contains the digital input and output control features.
Definition: mvIMPACT_acquire_GenICam.h:3890
A class to handle the digital inputs and outputs for mvBlueFOX USB cameras(Device specific interface ...
Definition: mvIMPACT_acquire.h:16382
A class to handle the digital inputs and outputs for frame grabber devices(Device specific interface ...
Definition: mvIMPACT_acquire.h:17185
A base class to handle digital inputs and outputs(Device specific interface layout only).
Definition: mvIMPACT_acquire.h:15982
unsigned int getInputCount(void) const
Returns the number of mvIMPACT::acquire::DigitalInput s available for the mvIMPACT::acquire::Device a...
Definition: mvIMPACT_acquire.h:16166
unsigned int getPulseStartConfigurationCount(void) const
Returns the number of mvIMPACT::acquire::PulseStartConfiguration objects available for the mvIMPACT::...
Definition: mvIMPACT_acquire.h:16143
virtual void writeOutputRegister(unsigned int value, unsigned int mask=UINT_MAX)=0
Alters the state of the digital output register.
DigitalOutput * output(unsigned int nr) const
Returns a pointer to a mvIMPACT::acquire::DigitalOutput object.
Definition: mvIMPACT_acquire.h:16212
unsigned int RTCtrProgramCount(void) const
Returns the number of mvIMPACT::acquire::RTCtrProgram s available for the mvIMPACT::acquire::Device a...
Definition: mvIMPACT_acquire.h:16161
const DigitalInput * input(unsigned int nr) const
Returns a const pointer to a mvIMPACT::acquire::DigitalInput object.
Definition: mvIMPACT_acquire.h:16194
unsigned int getOutputCount(void) const
Returns the number of digital outputs available for the mvIMPACT::acquire::Device associated with thi...
Definition: mvIMPACT_acquire.h:16219
virtual unsigned int readOutputRegister(void) const =0
Returns the current state of the digital output register.
virtual unsigned int readInputRegister(void) const =0
Returns the current state of the digital input register.
A base class for exceptions generated by mvIMPACT Acquire.
Definition: mvIMPACT_acquire.h:248
std::string getErrorCodeAsString(void) const
Returns a string representation of the error associated with the exception.
Definition: mvIMPACT_acquire.h:280
A class to create complex digital output signals(Device specific interface layout only).
Definition: mvIMPACT_acquire.h:17581
std::string read(int index=0) const
Reads a value from a property.
Definition: mvIMPACT_acquire.h:5159
A class to represent a sync. output pin(Device specific interface layout only).
Definition: mvIMPACT_acquire.h:15234
PropertyF lowPart_pc
A float property defining the width in percent the sync. signal stays low during one period....
Definition: mvIMPACT_acquire.h:15249
PropertyF frequency_Hz
A float property defining the frequency(in Hertz) for the sync. signal generated by this pin.
Definition: mvIMPACT_acquire.h:15247
std::string getDescription(void) const
Returns a description for this sync. output.
Definition: mvIMPACT_acquire.h:15259
@ bFalse
Off, false or logical low.
Definition: mvDriverBaseEnums.h:551
@ bTrue
On, true or logical high.
Definition: mvDriverBaseEnums.h:553
This namespace contains classes and functions belonging to the GenICam specific part of the image acq...
Definition: mvIMPACT_acquire.h:23307
This namespace contains classes and functions belonging to the image acquisition module of this SDK.
Definition: mvImageBuffer.h:42