Impact Acquire SDK Java
UserDataEntry Class Reference

A helper class that represents one entry in the devices non-volatile memory (if available). More...

Public Member Functions

synchronized void delete ()
 
PropertyI getAccess ()
 The access rights for this entry.
 
PropertyS getData ()
 The data stored in this entry.
 
PropertyS getName ()
 The name of the entry.
 
PropertyS getPassword ()
 The password needed to modify this entry.
 
boolean isValid ()
 Call this function to check if this object references an existing entry.
 

Protected Member Functions

void finalize ()
 
 UserDataEntry (long cPtr, boolean cMemoryOwn)
 

Static Protected Member Functions

static long swigRelease (UserDataEntry obj)
 

Protected Attributes

transient boolean swigCMemOwn
 

Detailed Description

A helper class that represents one entry in the devices non-volatile memory (if available).

Each entry of user and device specific data consists of a name, data a property defining the access rights for this entry and an optional password.

The name can be any string, but currently is limited to 255 characters.

The mvIMPACT.acquire.UserDataEntry.getData() property can hold any type of user data that shall be stored in the device's non-volatile memory. This can either be a string or binary data. To store binary data the function mvIMPACT.acquire.PropertyS.writeBinary can be used. Internally however binary data will be stored as a Base64 encoded string. To read binary data from the property again the function mvIMPACT.acquire.PropertyS.readBinary must be called. The theoretical limit for the amount of data per entry is 2^16 (64KB) bytes, however the real limit might be below this value because the device does not offer that much memory.

The mvIMPACT.acquire.UserDataEntry.getAccess() property defines the access rights the user has when working with the entry. AFTER creation but BEFORE storing the entry into the device this property can be modified. At this point the creator of the entry can choose between 2 options: mvIMPACT.acquire.TUserDataAccessRight.udarFull and mvIMPACT.acquire.TUserDataAccessRight.udarRW. After storing the entry into the device by calling mvIMPACT.acquire.UserData.writeToHardware this property will become read-only and will remain read-only until the complete entry is deleted.

When the user creates a new entry for the user accessible device non-volatile memory he can either create a read/write data set, which means that every user can modify the data and the name property. In that case the property password is ignored. Apart from that an entry that can only be modified when the correct password has been written to the password property. To read a value is always allowed.

The password property will hold the user input and NOT the actual password needed to unlock the data set. However when an entry has been created the creator afterwards can write to the password. When the creator then calls the function mvIMPACT.acquire.UserData.writeToHardware the value of the password property is used as the 'real' password from that moment onwards.

The maximum length for the password currently is 255 characters. This does not provide total security of cause, but the idea of the password only is to hinder the user from deleting an import entry by accident.

The memory consumed by a single mvIMPACT.acquire.UserDataEntry can vary from device to device and depends on the way the data is stored internally. In any case when an entry is created it will consume more memory than the amount of bytes written to the mvIMPACT.acquire.UserDataEntry.getData(). After data has been written to an entry it is therefore important to check the mvIMPACT.acquire.UserData.getMemoryAvailable_bytes() property if there is still enough memory available.

Note
There might be entries that can't be modified by the user. These entries contain important data that have been written to the memory during production. An attempt to delete this data will fail.
//-----------------------------------------------------------------------------
public static int storeUserData( Device pDev, byte[] data_bytes, final String entryName )
//-----------------------------------------------------------------------------
{
UserData userData = pDev.getUserData();
if( !userData.isAvailable() )
{
System.out.println( "This device does not support user data" );
return -1;
}
System.out.println( String.format( "Available user memory(bytes): %d", userData.getMemoryAvailable_bytes().read() ) );
System.out.println( String.format( "Memory consumed already(bytes): %d", userData.getMemoryConsumed_bytes().read() ) );
// create a new entry
UserDataEntry entry = userData.createEntry();
if( !entry.isValid() )
{
System.out.println( "Failed to create new entry" );
return -2;
}
ByteBuffer data = ByteBuffer.allocateDirect( data_bytes.length );
data.put( data_bytes );
entry.getData().writeBinary( data );
entry.getName().write( entryName );
// write to non-volatile memory (therefore the device MUST be closed)
if( pDev.isOpen() )
{
System.out.println( "Can't store data as the device is already in use" );
return -3;
}
userData.writeToHardware();
if( pDev.getHWUpdateResult().read() != THWUpdateResult.urSetUserDataWriteOK )
{
System.out.println( "Failed to store data in device non-volatile memory" );
return -4;
}
// now this data is stored in the devices permanent memory
return 0;
}
This class and its functions represent an actual device detected by this interface in the current sys...
Definition Device.java:52
PropertyI getHWUpdateResult()
An enumerated integer property (read-only) defining user executed hardware update results.
Definition Device.java:683
boolean isOpen()
Returns the current initialisation status in this process.
Definition Device.java:195
UserData getUserData()
Returns a reference to a helper class to handle user specific data stored in the devices non-volatile...
Definition Device.java:309
int read(int index)
Reads a value from a property.
Definition PropertyI.java:198
void writeBinary(java.nio.ByteBuffer pBuf, int index)
Writes a block of binary data to one entry of the property.
Definition PropertyS.java:401
PropertyS write(String value, int index)
Writes one value to the property.
Definition PropertyS.java:192
A helper class that represents one entry in the devices non-volatile memory (if available).
Definition UserDataEntry.java:200
PropertyS getData()
The data stored in this entry.
Definition UserDataEntry.java:268
boolean isValid()
Call this function to check if this object references an existing entry.
Definition UserDataEntry.java:246
PropertyS getName()
The name of the entry.
Definition UserDataEntry.java:254
A helper class to work with the device specific non-volatile memory(if available).
Definition UserData.java:62
PropertyI getMemoryAvailable_bytes()
An integer property (read-only) containing the number of bytes of user accessible,...
Definition UserData.java:208
boolean isAvailable()
This function should be called to check if this device offers non-volatile memory that can be accesse...
Definition UserData.java:178
PropertyI getMemoryConsumed_bytes()
An integer property (read-only) containing the number of bytes of user accessible,...
Definition UserData.java:224
void writeToHardware()
Writes the current set of user data into the devices non-volatile memory.
Definition UserData.java:191
UserDataEntry createEntry()
Creates and returns a new entry to store user specific data.
Definition UserData.java:114
Note
Instances of this class can only be created by the class UserData.

Constructor & Destructor Documentation

◆ UserDataEntry()

UserDataEntry ( long cPtr,
boolean cMemoryOwn )
protected

Member Function Documentation

◆ delete()

synchronized void delete ( )

◆ finalize()

void finalize ( )
protected

◆ getAccess()

PropertyI getAccess ( )

The access rights for this entry.

After this entry has been written to the devices non-volatile memory, this property will become read-only.

Valid values for this property are defined by the enumeration mvIMPACT.acquire.TUserDataAccessRight.

◆ getData()

PropertyS getData ( )

The data stored in this entry.

The theoretical limit for the amount of data per entry is 2^16 (64KB) bytes, however the real limit might be below this value because the device does not offer that much memory.

This property can either store string or binary data. See mvIMPACT.acquire.PropertyS to find out how to work with binary data.

◆ getName()

PropertyS getName ( )

The name of the entry.

The maximum length for the name currently is 255 characters.

◆ getPassword()

PropertyS getPassword ( )

The password needed to modify this entry.

The maximum length for the password is 255 characters currently. When the mvIMPACT.acquire.TUserDataAccessRight.udarPassword is not specified by the access property, this property will be ignored. Otherwise this property must have been assigned the correct password (case sensitive) before the name and data properties can be modified.

◆ isValid()

boolean isValid ( )

Call this function to check if this object references an existing entry.

Returns
  • true if this object references an existing entry
  • false otherwise

◆ swigRelease()

static long swigRelease ( UserDataEntry obj)
staticprotected

Member Data Documentation

◆ swigCMemOwn

transient boolean swigCMemOwn
protected