baseref.getClass().getSimpleName() );
System.out.println( "---------------------------------------" );
for ( final EdsPropertyID id : EdsPropertyID.values() ) {
final long size = CanonUtils.getPropertySize( baseref, id );
final EdsDataType type = CanonUtils.getPropertyType( baseref, id );
if ( size > -1 || !hideNegativeSizeProperties ) {
System.out.println( id.name() );
System.out.println( " Size: " + size );
System.out.println( " Type: " + type.description() );
if ( size == -1 &&
type.equals( EdsDataType.kEdsDataType_Unknown ) ) {
System.out.println( id.name() +
" - VALUE NOT AVAILABLE ON THIS CAMERA AND/OR WITH CURRENT SETTINGS" );
} else {
final Object value;
switch ( type ) {
case kEdsDataType_String: {
final String data = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = data;
break;
}
case kEdsDataType_Rational: {
final EdsRational struct = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = struct;
break;
}
case kEdsDataType_Point: {
final EdsPoint struct = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = struct;
break;
}
case kEdsDataType_Rect: {
final EdsRect struct = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = struct;
break;
}
case kEdsDataType_Time: {
final EdsTime struct = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = struct;
break;
}
case kEdsDataType_FocusInfo: {
final EdsFocusInfo struct = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = struct;
break;
}
case kEdsDataType_PictureStyleDesc: {
final EdsPictureStyleDesc struct = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = struct;
break;
}
case kEdsDataType_ByteBlock:
case kEdsDataType_Int8_Array:
case kEdsDataType_UInt8_Array:
case kEdsDataType_Int16_Array:
case kEdsDataType_UInt16_Array:
case kEdsDataType_Int32_Array:
case kEdsDataType_UInt32_Array: {
final int[] array = CanonUtils.getPropertyDataAdvanced( baseref, id );
value = array;
break;
}
default:
value = Long.valueOf( CanonUtils.getPropertyData( baseref, id ) );
}
System.out.println( " Value: " +
Test.toString( value ) );
}
}
}
System.out.println( "\n" );
}
//TEST READING CUSTOM FUNCTIONS
System.out.println( "Custom Functions" );
System.out.println( "---------------------------------------" );
for ( int i = -10000; i < 10000; i++ ) {
final long size = CanonUtils.getPropertySize( camera.getEdsCamera(), EdsPropertyID.kEdsPropID_CFn, i );
final EdsDataType type = CanonUtils.getPropertyType( camera.getEdsCamera(), EdsPropertyID.kEdsPropID_CFn, i );
if ( size > -1 || !hideNegativeSizeCustomFunctions ) {
System.out.println( "Number: " + i + " (0x" +
Integer.toHexString( i ) + ")" );
System.out.println( " Type: " + type.description() );
System.out.println( " Size: " + size );
if ( size == -1 &&
type.equals( EdsDataType.kEdsDataType_Unknown ) ) {
System.out.println( " VALUE NOT AVAILABLE ON THIS CAMERA AND/OR WITH CURRENT SETTINGS" );
} else {
final Long value = CanonUtils.getPropertyData( camera.getEdsCamera(), EdsPropertyID.kEdsPropID_CFn, i );
System.out.println( " Value: " + value );
final EdsCustomFunction e = EdsCustomFunction.enumOfValue( i );
if ( e != null ) {
System.out.println( " Known: Yes, " + e.name() +
" (" + e.description() + ")" );
} else {
System.out.println( " Known: NO" );
}
}
}
}
System.out.println( "\n" );
if ( liverefs != null ) {
CanonUtils.release( liverefs );
}
//TEST GETTERS FROM CanonCamera
System.out.println( "Property Getters in CanonCamera" );
System.out.println( "---------------------------------------" );
final Method[] methods = camera.getClass().getMethods();
for ( final Method method : methods ) {
if ( method.getName().startsWith( "get" ) &&
method.getParameterTypes().length == 0 ) {
System.out.println( "Trying " + method.getName() );
try {
final Object o = method.invoke( camera, (Object[]) null );
System.out.println( " Result: " + Test.toString( o ) );
}
catch ( final IllegalAccessException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch ( final IllegalArgumentException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch ( final InvocationTargetException e ) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
System.out.println( "\n\n" );
//TEST CUSTOM FUNCTION FROM CanonCamera
System.out.println( "EdsCustomFunction with CanonCamera.getCustomFunction" );
System.out.println( "----------------------------------------------------" );
for ( final EdsCustomFunction e : EdsCustomFunction.values() ) {
System.out.println( "\nTrying " + e.description() + " (" +
e.name() + ")" );
final Long result = camera.getCustomFunction( e );
System.out.println( " Value: " + Test.toString( result ) );
}
System.out.println( "\n" );
//TEST FOR MISSING EdsPropID CONSTANTS
System.out.println( "Testing if its possible to get values from the camera for undefined property IDs from 0x0 to 0xFFFF" );
System.out.println( "----------------------------------------------------" );
for ( int i = 0; i < 0xFFFF; i++ ) {
if ( null == EdsPropertyID.enumOfValue( i ) ) {
final int bufferSize = 1;
final IntBuffer type = IntBuffer.allocate( bufferSize );
final NativeLongByReference number = new NativeLongByReference( new NativeLong( bufferSize ) );
EdsError err = CanonUtils.toEdsError( CanonCamera.EDSDK.EdsGetPropertySize( camera.getEdsCamera(), new NativeLong( i ), new NativeLong( 0 ), type, number ) );
if ( !err.equals( EdsError.EDS_ERR_PROPERTIES_UNAVAILABLE ) ) {
System.out.println( i + " (0x" +
Integer.toHexString( i ) + "): " +
err.description() );
}
if ( err == EdsError.EDS_ERR_OK ) {
final int size = (int) number.getValue().longValue();
final EdsDataType edsType = EdsDataType.enumOfValue( type.get( 0 ) );
if ( size > -1 ) {
if ( edsType == null ||
edsType.equals( EdsDataType.kEdsDataType_Unknown ) ) {
System.out.println( "WARNING: size is greater than -1 (" +
size +
"), but edsType is unknown!" );
} else {
final Memory memory = new Memory( size > 0
? size
: 1 );
err = CanonUtils.toEdsError( CanonCamera.EDSDK.EdsGetPropertyData( camera.getEdsCamera(), new NativeLong( i ), new NativeLong( 0 ), new NativeLong( size ), memory ) );
if ( err == EdsError.EDS_ERR_OK ) {
if ( edsType.equals( EdsDataType.kEdsDataType_Int32 ) ||
edsType.equals( EdsDataType.kEdsDataType_UInt32 ) ) {
System.out.println( " property: " +
i +
" (0x" +
Integer.toHexString( i ) +
"), value: " +
memory.getNativeLong( 0 ) +
", data type: " +
edsType.description() +
", size: " + size );
} else if ( edsType.equals( EdsDataType.kEdsDataType_String ) ) {
System.out.println( " property: " +
i +
" (0x" +
Integer.toHexString( i ) +
"), value: " +
memory.getString( 0 ) +
", data type: " +
edsType.description() +
", size: " + size );
} else {
System.out.println( " property: " +
i +
" (0x" +
Integer.toHexString( i ) +
"), value: NOT SUPPORTED, data type: " +
edsType.description() +
", size: " + size );
}
}
}
}