final synchronized public void set(final int index, final Number value) throws Exception, IndexOutOfBoundsException
    {
        switch (type)
        {
        case BOOL:
        case SINT:
            data.put(type.element_size * index, value.byteValue());
            break;
        case INT:
            data.putShort(type.element_size * index, value.shortValue());
            break;
        case DINT:
        case BITS:
            data.putInt(type.element_size * index, value.intValue());
            break;
        case REAL:
            data.putFloat(type.element_size * index, value.floatValue());
            break;
        default:
            throw new Exception("Cannot set type " + type + " to a number");
        }
    }