Fixing problems

parent 52075425
......@@ -26,7 +26,7 @@ CVAMatlabConnection::CVAMatlabConnection()
CVAMatlabConnection::~CVAMatlabConnection()
{
if( pVAMatlabTracker->GetConnected() )
if( pVAMatlabTracker->IsConnected() )
pVAMatlabTracker->Uninitialize();
delete pVAMatlabTracker;
......
......@@ -16,7 +16,7 @@
#include "VAMatlabConnection.h"
#include "VAMatlabTracking.h"
// Matlab includes
// Matlab includes
#include <mex.h>
#include <matrix.h>
......@@ -61,7 +61,7 @@ int g_iVerboseLevel = VERBOSE_LEVEL_NORMAL; // Verbosity level
| |
+------------------------------------------------------+ */
// Verbose functions
// Verbose functions
void INFO( const char * format, ... )
{
......@@ -96,8 +96,7 @@ ConnectionHandle GenerateConnectionHandle()
g_iLastConnectionHandle = i;
return i;
}
}
while( hHandle == -1 );
} while( hHandle == -1 );
// Should not reach this line!
VA_EXCEPT1( "An internal error occured - Please contact the developer" );
......@@ -118,7 +117,6 @@ ConnectionHandle GetConnectionHandle( const mxArray *pArray, bool bAllowNullHand
}
VA_EXCEPT1( "Invalid connection handle" );
return NULL;
}
// Checks if the correct excat number of arguments is provided
......@@ -227,8 +225,8 @@ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
| |
+------------------------------------------------------+ */
// Reflexion function. Returns cell-array of structs with information on the command functions.
// Used for code generation of the Matlab MEX facade class [private]
// Reflexion function. Returns cell-array of structs with information on the command functions.
// Used for code generation of the Matlab MEX facade class [private]
REGISTER_PRIVATE_FUNCTION( enumerateFunctions );
......@@ -311,11 +309,11 @@ REGISTER_PRIVATE_FUNCTION( get_connected );
#if VAMATLAB_INTEGRATED == 1
void get_connected(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
void get_connected( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
REQUIRE_INPUT_ARGS(1);
REQUIRE_INPUT_ARGS( 1 );
plhs[0] = mxCreateLogicalScalar(true);
plhs[ 0 ] = mxCreateLogicalScalar( true );
};
#else // VAMATLAB_INTEGRATED
......@@ -331,7 +329,7 @@ void get_connected( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
}
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
bool bConnected = pConnection->pClient->GetConnected();
bool bConnected = pConnection->pClient->IsConnected();
plhs[ 0 ] = mxCreateLogicalScalar( bConnected );
};
......@@ -343,45 +341,47 @@ REGISTER_PRIVATE_FUNCTION( connect );
#if VAMATLAB_INTEGRATED == 1
void connect(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
void connect( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
REQUIRE_INPUT_ARGS(1);
REQUIRE_INPUT_ARGS( 1 );
// Always connection ID 1
ConnectionHandle hHandle = 1;
if (g_iConnectionsEstablished==0) {
if( g_iConnectionsEstablished == 0 ) {
try {
std::string sPath = getDirectoryFromPath( VACore::GetCoreLibFilename() );
std::string sConfigFile = combinePath( sPath, VA_DEFAULT_CONFIGFILE );
g_pOwnCore = VACore::CreateCoreInstance(sConfigFile);
g_pOwnCore = VACore::CreateCoreInstance( sConfigFile );
g_pOwnCore->Initialize();
} catch (CVAException& e) {
}
catch( CVAException& e ) {
delete g_pOwnCore;
g_pOwnCore = NULL;
char buf[4096];
sprintf_s(buf, 4096, "Failed to initialize VACore. %s.", e.GetErrorMessage().c_str());
mexErrMsgTxt(buf);
} catch (...) {
char buf[ 4096 ];
sprintf_s( buf, 4096, "Failed to initialize VACore. %s.", e.GetErrorMessage().c_str() );
mexErrMsgTxt( buf );
}
catch( ... ) {
delete g_pOwnCore;
g_pOwnCore = NULL;
mexErrMsgTxt("Failed to initialize VACore");
mexErrMsgTxt( "Failed to initialize VACore" );
}
mexPrintf("VACore initialized\n");
mexPrintf( "VACore initialized\n" );
// First connection = Dummy connection to internal core
g_oDummyConnection.pClient = NULL;
g_oDummyConnection.pCoreInterface = g_pOwnCore;
g_vpConnections[hHandle] = &g_oDummyConnection;
g_vpConnections[ hHandle ] = &g_oDummyConnection;
}
++g_iConnectionsEstablished;
// Return the handle
plhs[0] = matlabCreateID(hHandle);
plhs[ 0 ] = matlabCreateID( hHandle );
}
#else // VAMATLAB_INTEGRATED
......@@ -409,7 +409,7 @@ void connect( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
{
pConnection->pClient->Initialize( sAddress, iPort, IVANetClient::EXC_CLIENT_THROW, false );
if( !pConnection->pClient->GetConnected() )
if( !pConnection->pClient->IsConnected() )
{
// TODO: Delete object. Here were some error with double destruction. Exception in destr?
std::stringstream ss;
......@@ -452,41 +452,43 @@ REGISTER_PRIVATE_FUNCTION( disconnect );
#if VAMATLAB_INTEGRATED == 1
void disconnect(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
void disconnect( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
REQUIRE_INPUT_ARGS(1);
REQUIRE_INPUT_ARGS( 1 );
// Nothing to do ... Dummy function ...
if (g_iConnectionsEstablished < 1) {
VA_EXCEPT1("No connections established");
if( g_iConnectionsEstablished < 1 ) {
VA_EXCEPT1( "No connections established" );
return;
}
--g_iConnectionsEstablished;
g_vpConnections[1] = NULL;
g_vpConnections[ 1 ] = NULL;
if (g_iConnectionsEstablished == 0) {
if( g_iConnectionsEstablished == 0 ) {
// Aufrumen
try {
g_pOwnCore->Finalize();
delete g_pOwnCore;
g_pOwnCore = NULL;
} catch (CVAException& e) {
}
catch( CVAException& e ) {
delete g_pOwnCore;
g_pOwnCore = NULL;
char buf[4096];
sprintf_s(buf, 4096, "Failed to finalize VACore. %s.", e.GetErrorMessage().c_str());
mexErrMsgTxt(buf);
char buf[ 4096 ];
sprintf_s( buf, 4096, "Failed to finalize VACore. %s.", e.GetErrorMessage().c_str() );
mexErrMsgTxt( buf );
} catch (...) {
}
catch( ... ) {
delete g_pOwnCore;
g_pOwnCore = NULL;
mexErrMsgTxt("Failed to finalize VACore. An unknown error occured.");
mexErrMsgTxt( "Failed to finalize VACore. An unknown error occured." );
}
mexPrintf("VACore finalized\n");
mexPrintf( "VACore finalized\n" );
}
}
......@@ -520,12 +522,12 @@ DECLARE_FUNCTION_OUTARG( get_server_address, addr, "string", "Server address" );
#if VAMATLAB_INTEGRATED == 1
void get_server_address(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
void get_server_address( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
REQUIRE_INPUT_ARGS(1);
REQUIRE_INPUT_ARGS( 1 );
// We not really have a connection. But definitely the core is on this machine... :-)
prhs[0] = mxCreateString("localhost");
prhs[ 0 ] = mxCreateString( "localhost" );
}
......@@ -568,11 +570,11 @@ void connect_tracker( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]
if( pTracker->Initialize( sServerAdress, sLocalAdress ) == false )
VA_EXCEPT2( INVALID_PARAMETER, "Could not initialize connection to tracker with remote adress '" + sServerAdress
+ "' and local adress '" + sLocalAdress + "'" );
+ "' and local adress '" + sLocalAdress + "'" );
}
REGISTER_PRIVATE_FUNCTION( disconnect_tracker );
void disconnect_tracker( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void disconnect_tracker( int , mxArray *[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 1 );
......@@ -595,7 +597,7 @@ void get_tracker_connected( int nlhs, mxArray *plhs[], int nrhs, const mxArray *
CVAMatlabConnection* pConnection = g_vpConnections[ hHandle ];
CVAMatlabTracker* pTracker = pConnection->pVAMatlabTracker;
bool bIsConnected = pTracker->GetConnected();
bool bIsConnected = pTracker->IsConnected();
if( nlhs != 1 )
{
if( bIsConnected )
......@@ -654,7 +656,7 @@ void set_tracked_sound_receiver_rigid_body_translation( int nlhs, mxArray *plhs[
VAVec3 v3Pos;
matlabGetRealVector3( prhs[ 1 ], "offset", v3Pos );
pConnection->pVAMatlabTracker->vTrackedSoundReceiverTranslation = VistaVector3D( v3Pos.x, v3Pos.y, v3Pos.z );
pConnection->pVAMatlabTracker->vTrackedSoundReceiverTranslation = VistaVector3D( float( v3Pos.x ), float( v3Pos.y ), float( v3Pos.z ) );
}
REGISTER_PRIVATE_FUNCTION( set_tracked_sound_receiver_rigid_body_rotation );
......@@ -669,7 +671,7 @@ void set_tracked_sound_receiver_rigid_body_rotation( int nlhs, mxArray *plhs[],
VAQuat qOrient;
matlabGetQuaternion( prhs[ 1 ], "rotation", qOrient );
pConnection->pVAMatlabTracker->qTrackedSoundReceiverRotation = VistaQuaternion( qOrient.x, qOrient.y, qOrient.z, qOrient.w );
pConnection->pVAMatlabTracker->qTrackedSoundReceiverRotation = VistaQuaternion( float( qOrient.x ), float( qOrient.y ), float( qOrient.z ), float( qOrient.w ) );
}
// Tracked real-world sound receiver
......@@ -714,7 +716,7 @@ void set_tracked_real_world_sound_receiver_rigid_body_translation( int nlhs, mxA
VAVec3 v3Pos;
matlabGetRealVector3( prhs[ 1 ], "offset", v3Pos );
pConnection->pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation = VistaVector3D( v3Pos.x, v3Pos.y, v3Pos.z );
pConnection->pVAMatlabTracker->vTrackedRealWorldSoundReceiverTranslation = VistaVector3D( float( v3Pos.x ), float( v3Pos.y ), float( v3Pos.z ) );
}
REGISTER_PRIVATE_FUNCTION( set_tracked_real_world_sound_receiver_rigid_body_rotation );
......@@ -729,7 +731,7 @@ void set_tracked_real_world_sound_receiver_rigid_body_rotation( int nlhs, mxArra
VAQuat qOrient;
matlabGetQuaternion( prhs[ 1 ], "rotation", qOrient );
pConnection->pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation = VistaQuaternion( qOrient.x, qOrient.y, qOrient.z, qOrient.w );
pConnection->pVAMatlabTracker->qTrackedRealWorldSoundReceiverRotation = VistaQuaternion( float( qOrient.x ), float( qOrient.y ), float( qOrient.z ), float( qOrient.w ) );
}
// Tracked source
......@@ -817,11 +819,11 @@ REGISTER_PUBLIC_FUNCTION( reset, "Resets the VA server", "" );
#if VAMATLAB_INTEGRATED == 1
void reset(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
void reset( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {
REQUIRE_INPUT_ARGS(1);
REQUIRE_INPUT_ARGS( 1 );
INFO("Resetting VA core\n");
INFO( "Resetting VA core\n" );
g_pOwnCore->Reset();
}
......@@ -1060,7 +1062,7 @@ void create_signal_source_text_to_speech( int nlhs, mxArray *plhs[], int nrhs, c
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( create_signal_source_buffer_from_parameters, "Creates an buffer signal source", "" );
DECLARE_FUNCTION_REQUIRED_INARG( create_signal_source_buffer_from_parameters, params, "struct", "Parameters", "''" );
DECLARE_FUNCTION_REQUIRED_INARG( create_signal_source_buffer_from_parameters, params, "struct", "Parameters" );
DECLARE_FUNCTION_OPTIONAL_INARG( create_signal_source_buffer_from_parameters, name, "string", "Displayed name", "''" );
DECLARE_FUNCTION_OUTARG( create_signal_source_buffer_from_parameters, signalSourceID, "string", "Signal source ID" );
......@@ -1081,7 +1083,7 @@ void create_signal_source_buffer_from_parameters( int nlhs, mxArray *plhs[], int
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( create_signal_source_engine, "Creates an engine signal source", "" );
DECLARE_FUNCTION_REQUIRED_INARG( create_signal_source_engine, params, "struct", "Parameters", "''" );
DECLARE_FUNCTION_REQUIRED_INARG( create_signal_source_engine, params, "struct", "Parameters" );
DECLARE_FUNCTION_OPTIONAL_INARG( create_signal_source_engine, name, "string", "Displayed name", "''" );
DECLARE_FUNCTION_OUTARG( create_signal_source_engine, signalSourceID, "string", "Signal source ID" );
......@@ -2259,7 +2261,7 @@ REGISTER_PUBLIC_FUNCTION( set_sound_receiver_pose, "Sets the position and orient
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_pose, soundreceiverID, "integer-1x1", "Sound receiver ID" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_pose, pos, "double-3", "Position vector [x, y, z] (unit: meters)" );
DECLARE_FUNCTION_REQUIRED_INARG( set_sound_receiver_pose, ypr, "double-4", "Rotation angles [w,x,y,z]" );
void set_sound_receiver_pose( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void set_sound_receiver_pose( int , mxArray *[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 4 );
......@@ -2623,7 +2625,7 @@ void set_core_clock( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]
* | | *
* +----------------------------------------------------------+ */
// Rendering
// Rendering
REGISTER_PUBLIC_FUNCTION( set_rendering_module_gain, "Sets the output gain of a reproduction module", "" );
DECLARE_FUNCTION_REQUIRED_INARG( set_rendering_module_gain, sModuleID, "string", "Module identifier" );
......@@ -2800,7 +2802,7 @@ void get_reproduction_module_gain( int nlhs, mxArray *plhs[], int nrhs, const mx
REGISTER_PUBLIC_FUNCTION( get_reproduction_modules, "Get list of rendering modules", "" );
DECLARE_FUNCTION_OPTIONAL_INARG( get_reproduction_modules, bFilterEnabled, "boolean-1x1", "Filter activated (true)", "1" );
DECLARE_FUNCTION_OUTARG( get_reproduction_modules, reproductionmodules, "cell-array of struct-1x1", "Reproduction module infos (names, descriptions, etc.)" );
void get_reproduction_modules( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void get_reproduction_modules( int , mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
bool bFilterEnabled = true;
if( nrhs > 1 )
......@@ -2834,8 +2836,8 @@ void get_reproduction_modules( int nlhs, mxArray *plhs[], int nrhs, const mxArra
* | | *
* +----------------------------------------------------------+ */
// Timer momentan nur unter Windows verfgbar
// TODO: Weitere Platform-Implementierungen
// Timer momentan nur unter Windows verfgbar
// TODO: Weitere Platform-Implementierungen
#ifdef WIN32
// Wchter, der automatisch das Kernel-Handle freigibt, wenn die DLL entladen wird
......@@ -2869,7 +2871,7 @@ static HandleGuard g_oTimerHandle;
REGISTER_PUBLIC_FUNCTION( set_timer, "Sets up the high-precision timer", "" );
DECLARE_FUNCTION_REQUIRED_INARG( set_timer, period, "double-1x1", "Timer period (unit: seconds)" );
void set_timer( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void set_timer( int , mxArray *[], int nrhs, const mxArray *prhs[] )
{
REQUIRE_INPUT_ARGS( 2 );
......@@ -2906,7 +2908,7 @@ void set_timer( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
// ------------------------------------------------------------
REGISTER_PUBLIC_FUNCTION( wait_for_timer, "Wait for a signal of the high-precision timer", "" );
void wait_for_timer( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
void wait_for_timer( int , mxArray *[], int nrhs, const mxArray *[] )
{
REQUIRE_INPUT_ARGS( 1 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment