org.fosstrak.llrp.commander
Class ResourceCenter

java.lang.Object
  extended by org.fosstrak.llrp.commander.ResourceCenter

public class ResourceCenter
extends java.lang.Object

This single access point for lower level resources, like Reader and Messages, from the GUI side. The class apply the Singleton pattern.

Version:
1.0
Author:
Haoning Zhang, sawielan

Field Summary
static java.lang.String CONFIG_SUBFOLDER
          folder storing the configuration files.
static java.lang.String DB_SUBFOLDER
           
static java.lang.String DEFAULT_ECLIPSE_PROJECT
          Default Eclipse Project for storing editable messages
static java.lang.String DEFAULT_READER_DEF_FILENAME
          Default reader configuration file name
static java.lang.String DRAFT_SUBFOLDER
          Pre-built folder, for editable outgoing messages
static int GET_MAX_MESSAGES
          Maximal message retrieval number
static java.lang.String RDR_CFG_FILE
          the name of the configuration file for the reader configuration.
static java.lang.String REPO_SUBFOLDER
          Pre-built folder, for opened incoming messages
static java.lang.String SAMPLE_SUBFOLDER
          Pre-built folder, for messages template (samples)
 
Method Summary
 void addMessage(LLRPMessageItem aNewMessage)
          Add LLRP Message Item to Repository and Content Provider.
 void addReaderConfig(java.lang.String aAdapterName, java.lang.String aReaderName, java.lang.String aMessageID)
           
 void addReaderROSpec(java.lang.String aAdapterName, java.lang.String aReaderName, java.lang.String aMessageID)
           
 void addToMessageMetadataList(LLRPMessageItem aNewMessage)
          Add new message meta data item into list
 void clearMessageMetadataList()
          Clear all data in meta data list
 void close()
          tear down the resource center.
 void disconnectAllReaders()
          Disconnect all readers.
 boolean existReaderConfig(java.lang.String aAdapterName, java.lang.String aReaderName)
           
 boolean existReaderROSpec(java.lang.String aAdapterName, java.lang.String aReaderName)
           
 org.llrp.ltk.types.LLRPMessage generateLLRPMessage(java.lang.String aXMLFileContent)
          Helper function.
 java.lang.String getCurrentFile()
          Get current editing XML content
 java.lang.String getCurrentFileName()
          Get current editing file name
 org.eclipse.core.resources.IProject getEclipseProject()
          Get Eclipse IProject instance
 java.lang.String getEclipseProjectName()
          Get Eclipse Project Name
 org.eclipse.swt.graphics.Image getImage(java.lang.String aFilename)
          Get Image from icon folder
 org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String aFilename)
          Get ImageDescriptor from icon folder
static ResourceCenter getInstance()
          Return the only instance of this class, call the Constructor in its first call.
 MessageBoxRefresh getMessageBoxRefresh()
           
 java.lang.String getMessageContent(java.lang.String aMsgId)
          Get LLRP XML content by Message ID
 java.util.ArrayList<LLRPMessageItem> getMessageMetadataList()
          Get the message meta data list.
 MessageModel getMessageModel()
          Get the Message model
 java.lang.String getReaderConfigMsgId(java.lang.String aAdapterName, java.lang.String aReaderName)
           
 java.lang.String getReaderDefinitionFilename()
          Get Reader definition filename
 ReaderExplorerView getReaderExplorerView()
           
 java.lang.String getReaderROSpecMsgId(java.lang.String aAdapterName, java.lang.String aReaderName)
           
 Repository getRepository()
          Get the Repository interface.
 void initializeAdaptorMgmt()
          helper to initialize the adaptor management at the right moment.
 void initializeROAccessReportsLogging()
          initialize the RO_ACCESS_REPORTS logging facility.
 boolean isLogROAccessReports()
           
 void postExceptionToGUI(LLRPExceptionHandlerTypeMap aExceptionType, java.lang.String aAdapter, java.lang.String aReader)
           
 void removeReaderConfig(java.lang.String aAdapterName, java.lang.String aReaderName)
           
 void removeReaderROSpec(java.lang.String aAdapterName, java.lang.String aReaderName)
           
 void sendMessage(java.lang.String aAdapterName, java.lang.String aReaderName, org.llrp.ltk.types.LLRPMessage aMessage, java.lang.String aComment)
          Send LLRP Message.
 void setEclipseProjectName(java.lang.String aName)
          Set Eclipse Project Name
 void setExceptionHandler(ExceptionHandler aHandler)
           
 void setMessageboxView(MessageboxView aMessagebox)
          set the message box view in the message box refresh thread.
 void setReaderDefinitionFilename(java.lang.String aReaderDefinitionFilename)
          Set Reader definition filename
 void setReaderExplorerView(ReaderExplorerView readerExplorerView)
           
 Repository setRepository(Repository repo)
          allows to set a new repository.
 void writeMessageToFile(java.lang.String aMsgId)
          writes the content of the given id into a temporary file.
 org.eclipse.core.resources.IFile writeMessageToFile(java.lang.String folder, java.lang.String fileName, java.lang.String msg)
          writes a chunk of data to a folder within a requested file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET_MAX_MESSAGES

public static final int GET_MAX_MESSAGES
Maximal message retrieval number

See Also:
Constant Field Values

DEFAULT_ECLIPSE_PROJECT

public static final java.lang.String DEFAULT_ECLIPSE_PROJECT
Default Eclipse Project for storing editable messages

See Also:
Constant Field Values

DEFAULT_READER_DEF_FILENAME

public static final java.lang.String DEFAULT_READER_DEF_FILENAME
Default reader configuration file name

See Also:
Constant Field Values

REPO_SUBFOLDER

public static final java.lang.String REPO_SUBFOLDER
Pre-built folder, for opened incoming messages

See Also:
Constant Field Values

DRAFT_SUBFOLDER

public static final java.lang.String DRAFT_SUBFOLDER
Pre-built folder, for editable outgoing messages

See Also:
Constant Field Values

SAMPLE_SUBFOLDER

public static final java.lang.String SAMPLE_SUBFOLDER
Pre-built folder, for messages template (samples)

See Also:
Constant Field Values

CONFIG_SUBFOLDER

public static final java.lang.String CONFIG_SUBFOLDER
folder storing the configuration files.

See Also:
Constant Field Values

RDR_CFG_FILE

public static final java.lang.String RDR_CFG_FILE
the name of the configuration file for the reader configuration.

See Also:
Constant Field Values

DB_SUBFOLDER

public static final java.lang.String DB_SUBFOLDER
See Also:
Constant Field Values
Method Detail

initializeAdaptorMgmt

public void initializeAdaptorMgmt()
helper to initialize the adaptor management at the right moment.


initializeROAccessReportsLogging

public void initializeROAccessReportsLogging()
initialize the RO_ACCESS_REPORTS logging facility. This initializer should be called once. Basically it registers the repository on the adapter management to be notified about new RO_ACCESS_REPORTS.


getMessageModel

public MessageModel getMessageModel()
Get the Message model

Returns:
Message Model

getInstance

public static ResourceCenter getInstance()
Return the only instance of this class, call the Constructor in its first call.


addMessage

public void addMessage(LLRPMessageItem aNewMessage)
Add LLRP Message Item to Repository and Content Provider.

Parameters:
aNewMessage - Incoming LLRP Message

getMessageMetadataList

public java.util.ArrayList<LLRPMessageItem> getMessageMetadataList()
Get the message meta data list.

Returns:
Message meta data list

addToMessageMetadataList

public void addToMessageMetadataList(LLRPMessageItem aNewMessage)
Add new message meta data item into list

Parameters:
aNewMessage - New message meta data item

clearMessageMetadataList

public void clearMessageMetadataList()
Clear all data in meta data list


getMessageContent

public java.lang.String getMessageContent(java.lang.String aMsgId)
Get LLRP XML content by Message ID

Parameters:
aMsgId - Message ID
Returns:
LLRP XML Content

setRepository

public Repository setRepository(Repository repo)
allows to set a new repository.

Parameters:
repo - the new repository.
Returns:
the old repository.

getRepository

public Repository getRepository()
Get the Repository interface.

Returns:
Repository interface

isLogROAccessReports

public boolean isLogROAccessReports()
Returns:
true if RO_ACCESS_REPORTS shall be logged, false otherwise.

getEclipseProjectName

public java.lang.String getEclipseProjectName()
Get Eclipse Project Name

Returns:
Eclipse Project Name

setEclipseProjectName

public void setEclipseProjectName(java.lang.String aName)
Set Eclipse Project Name

Parameters:
aName - Eclipse Project Name

getEclipseProject

public org.eclipse.core.resources.IProject getEclipseProject()
Get Eclipse IProject instance

Returns:
Eclipse IProject instance

getCurrentFileName

public java.lang.String getCurrentFileName()
Get current editing file name

Returns:
Current editing file name

getCurrentFile

public java.lang.String getCurrentFile()
Get current editing XML content

Returns:
Current editing XML content

generateLLRPMessage

public org.llrp.ltk.types.LLRPMessage generateLLRPMessage(java.lang.String aXMLFileContent)
Helper function. Generate LLRPMessage instance by XML content. If the exchange by LTKJava hold errors, return null.

Parameters:
aXMLFileContent - XML file content
Returns:
LLRPMessage instance.

sendMessage

public void sendMessage(java.lang.String aAdapterName,
                        java.lang.String aReaderName,
                        org.llrp.ltk.types.LLRPMessage aMessage,
                        java.lang.String aComment)
Send LLRP Message.

Parameters:
aAdapterName - Adapter Logical Name
aReaderName - Reader Logical Name
aMessage - LLRPMessage instance
aComment - User Input Comments

disconnectAllReaders

public void disconnectAllReaders()
Disconnect all readers.


getReaderDefinitionFilename

public java.lang.String getReaderDefinitionFilename()
Get Reader definition filename

Returns:
Reader definition filename

setReaderDefinitionFilename

public void setReaderDefinitionFilename(java.lang.String aReaderDefinitionFilename)
Set Reader definition filename

Parameters:
aReaderDefinitionFilename - Reader definition filename

getImage

public org.eclipse.swt.graphics.Image getImage(java.lang.String aFilename)
Get Image from icon folder

Parameters:
aFilename - Image filename
Returns:
Image instance

getImageDescriptor

public org.eclipse.jface.resource.ImageDescriptor getImageDescriptor(java.lang.String aFilename)
Get ImageDescriptor from icon folder

Parameters:
aFilename - Image filename
Returns:
ImageDescriptor instance

setExceptionHandler

public void setExceptionHandler(ExceptionHandler aHandler)

postExceptionToGUI

public void postExceptionToGUI(LLRPExceptionHandlerTypeMap aExceptionType,
                               java.lang.String aAdapter,
                               java.lang.String aReader)

setMessageboxView

public void setMessageboxView(MessageboxView aMessagebox)
set the message box view in the message box refresh thread. If the refresh thread is not started yet, a new instance is generated and the thread is started, otherwise the new message box view is registered on the running thread.

Parameters:
aMessagebox - the message box to be set.

setReaderExplorerView

public void setReaderExplorerView(ReaderExplorerView readerExplorerView)
Parameters:
readerExplorerView - the readerExplorerView to set

getReaderExplorerView

public ReaderExplorerView getReaderExplorerView()
Returns:
the readerExplorerView

addReaderConfig

public void addReaderConfig(java.lang.String aAdapterName,
                            java.lang.String aReaderName,
                            java.lang.String aMessageID)

removeReaderConfig

public void removeReaderConfig(java.lang.String aAdapterName,
                               java.lang.String aReaderName)

getReaderConfigMsgId

public java.lang.String getReaderConfigMsgId(java.lang.String aAdapterName,
                                             java.lang.String aReaderName)

addReaderROSpec

public void addReaderROSpec(java.lang.String aAdapterName,
                            java.lang.String aReaderName,
                            java.lang.String aMessageID)

removeReaderROSpec

public void removeReaderROSpec(java.lang.String aAdapterName,
                               java.lang.String aReaderName)

getReaderROSpecMsgId

public java.lang.String getReaderROSpecMsgId(java.lang.String aAdapterName,
                                             java.lang.String aReaderName)

existReaderConfig

public boolean existReaderConfig(java.lang.String aAdapterName,
                                 java.lang.String aReaderName)

existReaderROSpec

public boolean existReaderROSpec(java.lang.String aAdapterName,
                                 java.lang.String aReaderName)

writeMessageToFile

public org.eclipse.core.resources.IFile writeMessageToFile(java.lang.String folder,
                                                           java.lang.String fileName,
                                                           java.lang.String msg)
                                                    throws java.lang.Exception
writes a chunk of data to a folder within a requested file.

Parameters:
folder - the folder where to write to. if null uses "temporary".
fileName - the file name where to write to. if null, abort.
msg - the data chunk to be written.
Returns:
the file handle interface of the written file.
Throws:
java.lang.Exception - when there is a problem.

writeMessageToFile

public void writeMessageToFile(java.lang.String aMsgId)
writes the content of the given id into a temporary file.

Parameters:
aMsgId - the message id to write to file.

close

public void close()
tear down the resource center.


getMessageBoxRefresh

public MessageBoxRefresh getMessageBoxRefresh()
Returns:
the messageBoxRefresh


Copyright © 2009. All Rights Reserved.