eWON JTK

com.ewon.ewonitf
Class SysControlBlock

java.lang.Object
  extended by com.ewon.ewonitf.SysControlBlock

public class SysControlBlock
extends Object

This class is used to read and edit configurations and status blocks.
The configuration blocks are one of: SYS, COM, TAG, USER
The status block is the INF block. When an instance of the SysControlBlock is created, its block type must be specified and the content is loaded. The content on any field in the block can be read or written and it can be applied back to the system at any time using the saveBlock() command.


Field Summary
static byte BY_ID
          ReferenceType for SysControlBlock(int,int,int) indicating if that the refence to the object (User or Tag) is its ID.
static byte BY_NDX
          ReferenceType for SysControlBlock(int,int,int) indicating if that the refence to the object (User or Tag) is its index (starting at 0).
static byte COM
          Type for SysControlBlock(int) indicating that this object will manage the comcfg.txt configuration.
static byte INF
          Type for SysControlBlock(int) indicating that this object will manage the estat.htm or $dtSS information block.
static byte SYS
          Type for SysControlBlock(int) indicating that this object will manage the config.txt data.
static byte TAG
          Type for SysControlBlock(int) indicating that this object will manage the information about a given tag.
static byte USER
          Type for SysControlBlock(int) indicating that this object will manage the information about a given user.
static byte WIZ
          Type for SysControlBlock(int) indicating that this object will manage the wizard or $dtWZ block.
 
Constructor Summary
SysControlBlock(int BlockType)
          Creates a new instance of SysControlBlock
SysControlBlock(int BlockType, int RecordId)
          Creates a new instance of SysControlBlock.
SysControlBlock(int BlockType, int RecordRefType, int RecordRef)
          Creates a new instance of SysControlBlock.
SysControlBlock(int BlockType, String RecordName)
          Creates a new instance of SysControlBlock.
 
Method Summary
protected  void finalize()
           
 String getItem(String itemName)
          Read one item of the current block by its name.
 void reloadBlock()
          This function will reload the data from the Control block When data are loaded in the block, they may change in the system.
 void saveBlock()
          Make the currently edited block content active in the eWON
REM: The modification made is effective but volatile.
 void saveBlock(boolean saveToFlash)
          Make the currently edited block content active in the eWON
The modification is also saved permanently in the eWON flash memory.
 void saveBlockById()
          Make the currently edited block content active in the eWON
Compared to saveBlock(), this function will update an existing item based on its "Id" and not based on its "Name".
 void saveBlockById(boolean saveToFlash)
          Make the currently edited block content active in the eWON
Compared to saveBlock(), this function will update an existing item based on its "Id" and not based on its "Name".
 void setItem(String itemName, String itemValue)
          Read one item of the current block by its name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BY_NDX

public static final byte BY_NDX
ReferenceType for SysControlBlock(int,int,int) indicating if that the refence to the object (User or Tag) is its index (starting at 0).

See Also:
Constant Field Values

BY_ID

public static final byte BY_ID
ReferenceType for SysControlBlock(int,int,int) indicating if that the refence to the object (User or Tag) is its ID.

See Also:
Constant Field Values

SYS

public static final byte SYS
Type for SysControlBlock(int) indicating that this object will manage the config.txt data.

See Also:
Constant Field Values

TAG

public static final byte TAG
Type for SysControlBlock(int) indicating that this object will manage the information about a given tag.

See Also:
Constant Field Values

USER

public static final byte USER
Type for SysControlBlock(int) indicating that this object will manage the information about a given user.

See Also:
Constant Field Values

COM

public static final byte COM
Type for SysControlBlock(int) indicating that this object will manage the comcfg.txt configuration.

See Also:
Constant Field Values

INF

public static final byte INF
Type for SysControlBlock(int) indicating that this object will manage the estat.htm or $dtSS information block.

See Also:
Constant Field Values

WIZ

public static final byte WIZ
Type for SysControlBlock(int) indicating that this object will manage the wizard or $dtWZ block.

See Also:
Constant Field Values
Constructor Detail

SysControlBlock

public SysControlBlock(int BlockType,
                       int RecordId)
                throws EWException
Creates a new instance of SysControlBlock. This constructor is reserved for creation of block that need to manage a specific element described by its ID: ex: Tag or User.

Parameters:
BlockType - The type of block this object will contain (either TAG, USER).
RecordId - This is the ID of the the Tag or User (depending on BlockType).
Throws:
EWException - In case the operation fails.

SysControlBlock

public SysControlBlock(int BlockType,
                       int RecordRefType,
                       int RecordRef)
                throws EWException
Creates a new instance of SysControlBlock. This constructor is reserved for creation of block that need to manage a specific element described by its reference: ex: Tag or User. The reference can be the item ID or item index. Each tag or user has a unique ID.

Parameters:
BlockType - The type of block this object will contain (either TAG, USER).
RecordRefType - This field defines the type of reference passed (either BY_NDX, BY_ID)
RecordRef - This is an ID or an index according to RecordRefType
Throws:
EWException - In case the operation fails.

SysControlBlock

public SysControlBlock(int BlockType,
                       String RecordName)
                throws EWException
Creates a new instance of SysControlBlock. This constructor is reserved for creation of block that need to manage a specific element descripbed by its name: ex: Tag or User.

Parameters:
BlockType - The type of block this object will contain (either TAG, USER).
RecordName - The tag's name or the user's to edit. If the given name does not exists, the element will be created.
Throws:
EWException - In case the operation fails.

SysControlBlock

public SysControlBlock(int BlockType)
                throws EWException
Creates a new instance of SysControlBlock

Parameters:
BlockType - The type of block this object will contain (either SYS, TAG, USER, COM, INF).
Throws:
EWException - In case the operation fails.
Method Detail

reloadBlock

public void reloadBlock()
                 throws EWException
This function will reload the data from the Control block When data are loaded in the block, they may change in the system. The only way to synchronize the system with that data in the block is either to Save the data or to Reload the data.

Throws:
EWException

saveBlock

public void saveBlock()
               throws EWException
Make the currently edited block content active in the eWON
REM: The modification made is effective but volatile. It is not saved to flash and will return to it's previousely saved value after a device reboot.

Throws:
EWException

saveBlock

public void saveBlock(boolean saveToFlash)
               throws EWException
Make the currently edited block content active in the eWON
The modification is also saved permanently in the eWON flash memory. This is the same as calling saveBlock() followed by StorageControl.saveConfig()

Parameters:
saveToFlash - if true to modification is also saved to flash.
Throws:
EWException

saveBlockById

public void saveBlockById()
                   throws EWException
Make the currently edited block content active in the eWON
Compared to saveBlock(), this function will update an existing item based on its "Id" and not based on its "Name". This is usefull if you want to change a user's name or a tag's name, because the default function would create a new user or tag with the new name otherwise.
If the Id defined in the block is invalid or does not exists, then the function will work as saveBlock().
REM: The modification made is effective but volatile. It is not saved to flash and will return to it's previousely saved value after a device reboot.

Throws:
EWException

saveBlockById

public void saveBlockById(boolean saveToFlash)
                   throws EWException
Make the currently edited block content active in the eWON
Compared to saveBlock(), this function will update an existing item based on its "Id" and not based on its "Name". This is usefull if you want to change a user's name or a tag's name, because the default function would create a new user or tag with the new name otherwise.
If the Id defined in the block is invalid or does not exists, then the function will work as saveBlock().
The modification is also saved permanently in the eWON flash memory. This is the same as calling saveBlock() followed by StorageControl.saveConfig()

Parameters:
saveToFlash - if true to modification is also saved to flash.
Throws:
EWException

getItem

public String getItem(String itemName)
               throws EWException
Read one item of the current block by its name.

Parameters:
itemName - Name of the item to read. The name is not case sensitive.
Returns:
The item value.
Throws:
EWException - In case the operation fails (for example if the item requested does not exists).

setItem

public void setItem(String itemName,
                    String itemValue)
             throws EWException
Read one item of the current block by its name.

Parameters:
itemName - Name of the item to set. The name is not case sensitive.
itemValue - The value to set to the item. The operation is neither verified or applied until the saveBlock() function is called.
Throws:
EWException - In case the operation fails (for example if the item requested does not exists).

finalize

protected void finalize()

eWON JTK

www.eWON.biz: Your Eyes Watching Over Net