public static void insertFromShortArray(final short[] shortValues,
	    final DeviceAttribute deviceAttributeWritten, final int dimX, final int dimY)
	    throws DevFailed {
	// by default for xdim = 1, send the sum.
	Double doubleSum = new Double(0);
	for (final short shortValue : shortValues) {
	    doubleSum = doubleSum + shortValue;
	}

	if (shortValues.length > dimX * dimY) {
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "size of array " + shortValues.length
		    + " is too great",
		    "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)");
	}

	switch (deviceAttributeWritten.getType()) {
	case TangoConst.Tango_DEV_SHORT:
	    deviceAttributeWritten.insert(doubleSum.shortValue());
	    break;
	case TangoConst.Tango_DEV_USHORT:
	    deviceAttributeWritten.insert_us(doubleSum.shortValue());
	    break;
	case TangoConst.Tango_DEV_CHAR:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_CHAR not supported",
		    "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEV_UCHAR:
	    deviceAttributeWritten.insert_uc(doubleSum.shortValue());
	    break;
	case TangoConst.Tango_DEV_LONG:
	    deviceAttributeWritten.insert(doubleSum.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG:
	    deviceAttributeWritten.insert_ul(doubleSum.longValue());
	    break;
	case TangoConst.Tango_DEV_LONG64:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_LONG64 not supported",
		    "AttributeHelper.insertFromShort(short[] values,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEV_ULONG64:
	    deviceAttributeWritten.insert_u64(doubleSum.longValue());
	    break;
	case TangoConst.Tango_DEV_INT:
	    deviceAttributeWritten.insert(doubleSum.intValue());
	    break;
	case TangoConst.Tango_DEV_FLOAT:
	    deviceAttributeWritten.insert(doubleSum.floatValue());
	    break;
	case TangoConst.Tango_DEV_DOUBLE:
	    deviceAttributeWritten.insert(doubleSum.doubleValue());
	    break;
	case TangoConst.Tango_DEV_STRING:
	    deviceAttributeWritten.insert(doubleSum.toString());
	    break;
	case TangoConst.Tango_DEV_BOOLEAN:
	    if (doubleSum.doubleValue() == 1) {
		deviceAttributeWritten.insert(true);
	    } else {
		deviceAttributeWritten.insert(false);
	    }
	    break;
	case TangoConst.Tango_DEV_STATE:
	    final DevState[] devStateValues = new DevState[shortValues.length];
	    for (int i = 0; i < shortValues.length; i++) {
		try {
		    devStateValues[i] = DevState.from_int(Short.valueOf(shortValues[i]).intValue());
		} catch (final org.omg.CORBA.BAD_PARAM badParam) {
		    devStateValues[i] = DevState.UNKNOWN;
		}
	    }
	    deviceAttributeWritten.insert(devStateValues);
	    break;

	// Array input type
	case TangoConst.Tango_DEVVAR_SHORTARRAY:
	    if (dimY == 0) {
		deviceAttributeWritten.insert(shortValues);
	    } else {
		deviceAttributeWritten.insert(shortValues, dimX, dimY);
	    }
	    break;
	case TangoConst.Tango_DEVVAR_USHORTARRAY:
	    if (dimY == 0) {
		deviceAttributeWritten.insert_uc(shortValues);
	    } else {
		deviceAttributeWritten.insert_uc(shortValues, dimX, dimY);
	    }
	    break;
	case TangoConst.Tango_DEVVAR_CHARARRAY:
	    final byte[] byteValues = new byte[shortValues.length];
	    for (int i = 0; i < shortValues.length; i++) {
		byteValues[i] = Short.valueOf(shortValues[i]).byteValue();
	    }

	    deviceAttributeWritten.insert_uc(byteValues, dimX, dimY);
	    break;
	case TangoConst.Tango_DEVVAR_LONGARRAY:
	    final int[] longValues = new int[shortValues.length];
	    for (int i = 0; i < shortValues.length; i++) {
		longValues[i] = Short.valueOf(shortValues[i]).intValue();
	    }
	    if (dimY == 0) {
		deviceAttributeWritten.insert(longValues);
	    } else {
		deviceAttributeWritten.insert(longValues, dimX, dimY);
	    }
	    break;
	case TangoConst.Tango_DEVVAR_ULONGARRAY:
	    final long[] ulongValues = new long[shortValues.length];
	    for (int i = 0; i < shortValues.length; i++) {
		ulongValues[i] = Short.valueOf(shortValues[i]).longValue();
	    }
	    if (dimY == 0) {
		deviceAttributeWritten.insert_ul(ulongValues);
	    } else {
		deviceAttributeWritten.insert_ul(ulongValues, dimX, dimY);
	    }
	    break;
	case TangoConst.Tango_DEVVAR_LONG64ARRAY:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEVVAR_LONG64ARRAY not supported",
		    "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEVVAR_ULONG64ARRAY:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEVVAR_ULONG64ARRAY not supported",
		    "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEVVAR_FLOATARRAY:
	    final float[] floatValues = new float[shortValues.length];
	    for (int i = 0; i < shortValues.length; i++) {
		floatValues[i] = Short.valueOf(shortValues[i]).floatValue();
	    }
	    if (dimY == 0) {
		deviceAttributeWritten.insert(floatValues);
	    } else {
		deviceAttributeWritten.insert(floatValues, dimX, dimY);
	    }
	    break;
	case TangoConst.Tango_DEVVAR_DOUBLEARRAY:
	    final double[] doubleValues = new double[shortValues.length];
	    for (int i = 0; i < shortValues.length; i++) {
		doubleValues[i] = Short.valueOf(shortValues[i]).doubleValue();
	    }
	    if (dimY == 0) {
		deviceAttributeWritten.insert(doubleValues);
	    } else {
		deviceAttributeWritten.insert(doubleValues, dimX, dimY);
	    }
	    break;
	case TangoConst.Tango_DEVVAR_STRINGARRAY:
	    final String[] stringValues = new String[shortValues.length];
	    for (int i = 0; i < shortValues.length; i++) {
		stringValues[i] = Short.valueOf(shortValues[i]).toString();
	    }
	    if (dimY == 0) {
		deviceAttributeWritten.insert(stringValues);
	    } else {
		deviceAttributeWritten.insert(stringValues, dimX, dimY);
	    }
	    break;

	case TangoConst.Tango_DEVVAR_LONGSTRINGARRAY:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEVVAR_LONGSTRINGARRAY not supported",
		    "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)");
	    break;
	case TangoConst.Tango_DEVVAR_DOUBLESTRINGARRAY:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEVVAR_DOUBLESTRINGARRAY not supported",
		    "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)");
	    break;

	default:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
		    + deviceAttributeWritten.getType() + " not supported",
		    "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)");
	    break;
	}
    }
public static void insertFromShortArray ( final short [ ] shortValues , final DeviceAttribute deviceAttributeWritten , final int dimX , final int dimY ) throws DevFailed { Double doubleSum = new Double ( 0 ) ; for ( final short shortValue : shortValues ) { doubleSum = doubleSum + shortValue ; } if ( shortValues . length > dimX * dimY ) { Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "size of array " + shortValues . length + " is too great" , "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)" ) ; } switch ( deviceAttributeWritten . getType ( ) ) { case TangoConst . Tango_DEV_SHORT : deviceAttributeWritten . insert ( doubleSum . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_USHORT : deviceAttributeWritten . insert_us ( doubleSum . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_CHAR : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_CHAR not supported" , "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_UCHAR : deviceAttributeWritten . insert_uc ( doubleSum . shortValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG : deviceAttributeWritten . insert ( doubleSum . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_ULONG : deviceAttributeWritten . insert_ul ( doubleSum . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_LONG64 : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEV_LONG64 not supported" , "AttributeHelper.insertFromShort(short[] values,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEV_ULONG64 : deviceAttributeWritten . insert_u64 ( doubleSum . longValue ( ) ) ; break ; case TangoConst . Tango_DEV_INT : deviceAttributeWritten . insert ( doubleSum . intValue ( ) ) ; break ; case TangoConst . Tango_DEV_FLOAT : deviceAttributeWritten . insert ( doubleSum . floatValue ( ) ) ; break ; case TangoConst . Tango_DEV_DOUBLE : deviceAttributeWritten . insert ( doubleSum . doubleValue ( ) ) ; break ; case TangoConst . Tango_DEV_STRING : deviceAttributeWritten . insert ( doubleSum . toString ( ) ) ; break ; case TangoConst . Tango_DEV_BOOLEAN : if ( doubleSum . doubleValue ( ) == 1 ) { deviceAttributeWritten . insert ( true ) ; } else { deviceAttributeWritten . insert ( false ) ; } break ; case TangoConst . Tango_DEV_STATE : final DevState [ ] devStateValues = new DevState [ shortValues . length ] ; for ( int i = 0 ; i < shortValues . length ; i ++ ) { try { devStateValues [ i ] = DevState . from_int ( Short . valueOf ( shortValues [ i ] ) . intValue ( ) ) ; } catch ( final org . omg . CORBA . BAD_PARAM badParam ) { devStateValues [ i ] = DevState . UNKNOWN ; } } deviceAttributeWritten . insert ( devStateValues ) ; break ; case TangoConst . Tango_DEVVAR_SHORTARRAY : if ( dimY == 0 ) { deviceAttributeWritten . insert ( shortValues ) ; } else { deviceAttributeWritten . insert ( shortValues , dimX , dimY ) ; } break ; case TangoConst . Tango_DEVVAR_USHORTARRAY : if ( dimY == 0 ) { deviceAttributeWritten . insert_uc ( shortValues ) ; } else { deviceAttributeWritten . insert_uc ( shortValues , dimX , dimY ) ; } break ; case TangoConst . Tango_DEVVAR_CHARARRAY : final byte [ ] byteValues = new byte [ shortValues . length ] ; for ( int i = 0 ; i < shortValues . length ; i ++ ) { byteValues [ i ] = Short . valueOf ( shortValues [ i ] ) . byteValue ( ) ; } deviceAttributeWritten . insert_uc ( byteValues , dimX , dimY ) ; break ; case TangoConst . Tango_DEVVAR_LONGARRAY : final int [ ] longValues = new int [ shortValues . length ] ; for ( int i = 0 ; i < shortValues . length ; i ++ ) { longValues [ i ] = Short . valueOf ( shortValues [ i ] ) . intValue ( ) ; } if ( dimY == 0 ) { deviceAttributeWritten . insert ( longValues ) ; } else { deviceAttributeWritten . insert ( longValues , dimX , dimY ) ; } break ; case TangoConst . Tango_DEVVAR_ULONGARRAY : final long [ ] ulongValues = new long [ shortValues . length ] ; for ( int i = 0 ; i < shortValues . length ; i ++ ) { ulongValues [ i ] = Short . valueOf ( shortValues [ i ] ) . longValue ( ) ; } if ( dimY == 0 ) { deviceAttributeWritten . insert_ul ( ulongValues ) ; } else { deviceAttributeWritten . insert_ul ( ulongValues , dimX , dimY ) ; } break ; case TangoConst . Tango_DEVVAR_LONG64ARRAY : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEVVAR_LONG64ARRAY not supported" , "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEVVAR_ULONG64ARRAY : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEVVAR_ULONG64ARRAY not supported" , "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEVVAR_FLOATARRAY : final float [ ] floatValues = new float [ shortValues . length ] ; for ( int i = 0 ; i < shortValues . length ; i ++ ) { floatValues [ i ] = Short . valueOf ( shortValues [ i ] ) . floatValue ( ) ; } if ( dimY == 0 ) { deviceAttributeWritten . insert ( floatValues ) ; } else { deviceAttributeWritten . insert ( floatValues , dimX , dimY ) ; } break ; case TangoConst . Tango_DEVVAR_DOUBLEARRAY : final double [ ] doubleValues = new double [ shortValues . length ] ; for ( int i = 0 ; i < shortValues . length ; i ++ ) { doubleValues [ i ] = Short . valueOf ( shortValues [ i ] ) . doubleValue ( ) ; } if ( dimY == 0 ) { deviceAttributeWritten . insert ( doubleValues ) ; } else { deviceAttributeWritten . insert ( doubleValues , dimX , dimY ) ; } break ; case TangoConst . Tango_DEVVAR_STRINGARRAY : final String [ ] stringValues = new String [ shortValues . length ] ; for ( int i = 0 ; i < shortValues . length ; i ++ ) { stringValues [ i ] = Short . valueOf ( shortValues [ i ] ) . toString ( ) ; } if ( dimY == 0 ) { deviceAttributeWritten . insert ( stringValues ) ; } else { deviceAttributeWritten . insert ( stringValues , dimX , dimY ) ; } break ; case TangoConst . Tango_DEVVAR_LONGSTRINGARRAY : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEVVAR_LONGSTRINGARRAY not supported" , "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)" ) ; break ; case TangoConst . Tango_DEVVAR_DOUBLESTRINGARRAY : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type Tango_DEVVAR_DOUBLESTRINGARRAY not supported" , "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)" ) ; break ; default : Except . throw_exception ( "TANGO_WRONG_DATA_ERROR" , "input type " + deviceAttributeWritten . getType ( ) + " not supported" , "AttributeHelper.insertFromShortArray(short[] values,deviceAttributeWritten)" ) ; break ; } }
Insert data in DeviceAttribute from a short Array.

@param shortValues
the value to insert on DeviceAttribute
@param deviceAttributeWritten
the DeviceAttribute attribute to write
@param dimX
the x dimension of the attribute
@param dimY
the y dimension of the attribute
@throws DevFailed