public abstract class SessionManager extends java.lang.Object implements SimulationListener
Modifier and Type | Field and Description |
---|---|
java.util.Vector |
eventListeners
The event listeners for this session.
|
static boolean |
globalSimulation
This variable will be true if we are simulating.
|
LoggerInterface |
logger
The logger used for this session manager.
|
static int |
MULTI_THREADED |
static int |
primaryThreads |
static int |
responseThreads |
boolean |
sendErrorMessages
Whether we send the S9Fx messages for unknown streams and functions.
|
static int |
SINGLE_THREADED |
Constructor and Description |
---|
SessionManager()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addMessageHandler(java.lang.Object newMessageHandler)
Adds a new message handle object.
|
void |
addToConnection(ConnectionManager newConnectionManager)
Add the session from the provided connection.
|
void |
breakConnection()
This will close a connection.
|
abstract byte[][] |
convertToBytes(SecsMsg msg)
Convert a SecsMsg to a byte stream suitable for passing through whatever
port we are using.
|
abstract SecsMsg |
createMessage(byte[] unconverted)
This method will convert the provided byte stream into a secs message.
|
static SessionManager |
createSessionManager(ConnectionManager cm,
int deviceId,
int sessionId)
Returns the session for the given connection manager.
|
static SessionManager |
createSessionManager(ConnectionManager cm,
int deviceId,
int sessionId,
LoggerInterface theLogger)
Returns the session for the given connection manager.
|
static SessionManager |
createSessionManager(int port,
java.lang.String connectionId,
int deviceId,
int sessionId,
java.lang.Class portManagerClass)
Returns the session for the given port host and string.
|
static SessionManager |
createSessionManager(int port,
java.lang.String connectionId,
int deviceId,
int sessionId,
java.lang.Class portManagerClass,
LoggerInterface theLogger)
Returns the session for the given port host and string.
|
void |
endSession()
End the session.
|
ConnectionManager |
getConnectionManager()
Set the connection manager.
|
static SessionManager |
getDefault()
Returns the port manager that will be the default active port on a new thread.
|
int |
getDeviceId()
Returns the device id.
|
int |
getExpectsReply(byte[] unconv)
Returns true if the message expects a reply, otherwise false.
|
abstract int |
getHeaderSize()
Get the header size for this port.
|
boolean |
getIsHost()
Returns true if this session manager is capable of sending host (primary) messages.
|
LoggerInterface |
getLogger()
Returns the current logger object.
|
java.util.Vector<java.lang.Object> |
getMessageHandlers()
Returns the current message handlers.
|
static SessionManager |
getNewSessionManager()
Return a new session manager object.
|
PortManager |
getPortManager()
This will return the port manager for this session
|
double |
getReplyTimeout()
Returns the T3 timeout.
|
static SessionManager |
getSessionManager(int port,
java.lang.String connectionId,
int deviceId,
int sessionId,
boolean shouldCreate,
java.lang.Class portManagerClass)
Returns the session for the given port host and string.
|
static SessionManager |
getSessionManager(int port,
java.lang.String connectionId,
int deviceId,
int sessionId,
boolean shouldCreate,
java.lang.Class portManagerClass,
LoggerInterface theLogger)
Returns the session for the given port host and string.
|
static int |
getThreadingModel()
Retur the current threading model.
|
java.util.Hashtable<java.lang.Object,SecsMsg> |
getWaitingMessages()
Returns a Hashtable of messages waiting for an acknowledgment or a response.
|
boolean |
isDefault()
Returns true if this port manager is the default active port manager.
|
boolean |
isSimulating() |
boolean |
isSimulationFlag() |
boolean |
isValid() |
boolean |
isValidHostCommandMessage(SecsMsg msgIn)
host command - must have at least this structure.
|
void |
removeMessageHandler(java.lang.Object oldMessageHandler)
Removes a new message handle object.
|
boolean |
reprocessMessage(SecsMsg msg)
This allows for a messages to be processed as though it had been received.
|
abstract void |
sendMessage(SecsMsg msg)
Sends the SECS Message over the HSMS link.
|
void |
setDefault()
Set this session manager to be the default session manager.
|
void |
setDefault(SessionManager sm)
Set this session manager to be the default session manager.
|
void |
setDeviceId(int newValue)
Sets the device id for this port manager.
|
void |
setIsHost(boolean newValue)
Sets whether this session manager is capable of sending host (primary) messages.
|
void |
setLogger(LoggerInterface newLogger)
Register a logger.
|
void |
setMessageHandlers(java.util.Vector<java.lang.Object> newMessageHandlers)
Replaces all the current message handle objects with those contained in the vector.
|
void |
setReplyTimeout(double newT3)
Sets the T3 timeout.
|
void |
setSimulationFlag(boolean simulationFlag)
Sets the state of the simulation flag.
|
static void |
setThreadingModel(int model)
Set the threading model.
|
void |
setValid(boolean isValid) |
void |
simulationStateChanged(SimulationChangedEvent simulationChangedEvent)
Changes the state of the simulation mode.
|
java.lang.String |
toString()
Returns a description of this session manager.
|
public java.util.Vector eventListeners
public static boolean globalSimulation
public LoggerInterface logger
public static final int MULTI_THREADED
public static int primaryThreads
public static int responseThreads
public boolean sendErrorMessages
public static final int SINGLE_THREADED
public void addMessageHandler(java.lang.Object newMessageHandler)
an
- object that will receive the messages.createMessage(byte[])
,
SecsMsg.processSelf(java.lang.Object)
public void addToConnection(ConnectionManager newConnectionManager) throws java.util.TooManyListenersException
java.util.TooManyListenersException
- if there is already a connection manager setpublic void breakConnection() throws SecsException
SecsException
public abstract byte[][] convertToBytes(SecsMsg msg) throws SecsException
SecsException
public abstract SecsMsg createMessage(byte[] unconverted) throws SecsException
SecsException
SecsMsg.getData()
public static SessionManager createSessionManager(ConnectionManager cm, int deviceId, int sessionId) throws SecsException
cm
- the connection managersession
- ID for HSMS, ignored for SECS1deviceId
- the device idSecsException
public static SessionManager createSessionManager(ConnectionManager cm, int deviceId, int sessionId, LoggerInterface theLogger) throws SecsException
cm
- the connection managersession
- ID for HSMS, ignored for SECS1deviceId
- the device idtheLogger
- the logger objectSecsException
public static SessionManager createSessionManager(int port, java.lang.String connectionId, int deviceId, int sessionId, java.lang.Class portManagerClass) throws SecsException
port
- the port identifier. The socket port for HSMS and arbitrary designation for SECS1.connectionId
- the host name for HSMS, ignored for SECS1deviceId
- the device idSecsException
public static SessionManager createSessionManager(int port, java.lang.String connectionId, int deviceId, int sessionId, java.lang.Class portManagerClass, LoggerInterface theLogger) throws SecsException
port
- the port identifier. The socket port for HSMS and arbitrary designation for SECS1.connectionId
- the host name for HSMS, ignored for SECS1deviceId
- the device idtheLogger
- the Logger objectSecsException
public void endSession()
public ConnectionManager getConnectionManager()
public static SessionManager getDefault()
public int getDeviceId()
public int getExpectsReply(byte[] unconv)
public abstract int getHeaderSize()
public boolean getIsHost()
public LoggerInterface getLogger()
public java.util.Vector<java.lang.Object> getMessageHandlers()
public static SessionManager getNewSessionManager()
public PortManager getPortManager()
public double getReplyTimeout()
public static SessionManager getSessionManager(int port, java.lang.String connectionId, int deviceId, int sessionId, boolean shouldCreate, java.lang.Class portManagerClass) throws SecsException
port
- the port identifier. The socket port for HSMS and arbitrary designation for SECS1.connectionId
- the host name for HSMS, ignored for SECS1deviceId
- the device idSecsException
public static SessionManager getSessionManager(int port, java.lang.String connectionId, int deviceId, int sessionId, boolean shouldCreate, java.lang.Class portManagerClass, LoggerInterface theLogger) throws SecsException
port
- the port identifier. The socket port for HSMS and arbitrary designation for SECS1.connectionId
- the host name for HSMS, ignored for SECS1deviceId
- the device idtheLogger
- the logger objectSecsException
public static int getThreadingModel()
public java.util.Hashtable<java.lang.Object,SecsMsg> getWaitingMessages()
public boolean isDefault()
public boolean isSimulating()
public boolean isSimulationFlag()
public boolean isValid()
public boolean isValidHostCommandMessage(SecsMsg msgIn)
messageData
- public void removeMessageHandler(java.lang.Object oldMessageHandler)
oldMessageHandler
- the message handler to removeaddMessageHandler(java.lang.Object)
,
setMessageHandlers(java.util.Vector<java.lang.Object>)
public boolean reprocessMessage(SecsMsg msg) throws SecsException
SecsException
public abstract void sendMessage(SecsMsg msg) throws SecsException
SecsException
public void setDefault()
public void setDefault(SessionManager sm)
public void setDeviceId(int newValue)
public void setIsHost(boolean newValue)
newValue
- true if this is the host. This value is ignored for HSMS.public void setLogger(LoggerInterface newLogger)
newLogger
- the new logger objectpublic void setMessageHandlers(java.util.Vector<java.lang.Object> newMessageHandlers)
an
- object that will receive the messages.createMessage(byte[])
,
SecsMsg.processSelf(java.lang.Object)
public void setReplyTimeout(double newT3)
public void setSimulationFlag(boolean simulationFlag)
setSimulationFlag
in interface SimulationListener
simulationFlag
- will be written as "false" when code is generated.public static void setThreadingModel(int model) throws java.lang.IndexOutOfBoundsException
model
- 0 for single threaded. Currently anything else is multi-threaded.java.lang.IndexOutOfBoundsException
public void setValid(boolean isValid)
isValid
- the isValid to setpublic void simulationStateChanged(SimulationChangedEvent simulationChangedEvent) throws java.lang.Exception
simulationStateChanged
in interface SimulationListener
java.lang.Exception
- TODOpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 1999-2025 ErgoTech Systems, Inc. All Rights Reserved.