EasyManua.ls Logo

Balluff MATRIX VISION mvBlueFOX-200wC - Page 162

Balluff MATRIX VISION mvBlueFOX-200wC
238 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
154
1.18.6.2.3.2 Example 2: Motor does move (return = true)
Status:
Hex: 380086
Dec: 3670150
Binary: 0011 1000 0000 0000 1000 0110
23-20 19-16 15-12 11-08 07-04 03-00 => bit 2 is 1
(status & motorRunning) = 4 => return true
1.18.6.2.3.3 Example 3: Something a little more complex This shows a more complex piece of code of how
the motor focus can be used.
#ifdef _MSC_VER
# include <windows.h>
#else
# include <time.h>
#endif
#include <apps/Common/exampleHelper.h>
#include <iostream>
#include <iomanip>
#include <mvIMPACT_CPP/mvIMPACT_acquire.h>
#include <typeinfo>
using namespace std;
// This whole sample shows the low level access to the focus motor. For some
// of the functions presented here, there are also convenience functions in
// ’mvIMPACT::acquire::MotorFocusControl’
//-----------------------------------------------------------------------------
static void millisleep( long millisec )
//-----------------------------------------------------------------------------
{
#ifdef _MSC_VER
Sleep( millisec );
#else
timespec requested;
requested.tv_sec = millisec / 1000;
requested.tv_nsec = ( millisec % 1000 )
*
1000000L;
nanosleep( &requested, NULL );
#endif
}
//-----------------------------------------------------------------------------
class MotorControl
//-----------------------------------------------------------------------------
{
private:
const MotorFocusControl mfc;
const string version;
// private, so as to hide the command strings from the outside world
TDMR_ERROR write( const string& command ) const
{
mfc.motorFocusSendBuffer.writeS( command );
const TDMR_ERROR retval = static_cast<TDMR_ERROR>( mfc.motorFocusSend.call() );
#if _DEBUG
if( retval != DMR_NO_ERROR )
{
cerr « "Call to command ’" « command « "’ failed with error ’" « DMR_ErrorCodeToString( retval )
« "’" « endl;
}
#endif
return retval;
}
void waitForCommandReceipt( const string& expectedReply ) const
{
const size_t length = expectedReply.length();
string reply;
while( ( ( reply = getReply() ).length() < length ) ||
( reply.length() == length && reply != expectedReply ) ||
( reply.length() > length && reply.substr( 0, length ) != expectedReply ) )
{
cout « "Waiting for confirmation of command " « expectedReply.substr( 1, length - 1 ) « " (" «
reply « ")" « endl;
}
}
TDMR_ERROR writeConfirmed( const string& command ) const
{
const TDMR_ERROR retval = write( command );
if( retval == DMR_NO_ERROR )
{
waitForCommandReceipt( command.substr( 0, 3 ) );
}
return retval;
}
MATRIX VISION GmbH

Table of Contents

Related product manuals