|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrcs.nml.NMLConnection
public class NMLConnection
Class for connecting to NML buffers, ussually via network sockets.
Related Documentation: RCS Library, NML Programmers Guide (Java Version)
Constructor Summary | |
---|---|
NMLConnection()
This constructs an NMLConnection which will not work until the host and port are set manually or by reading the NML configuration file with ReadNMLConfigurationFile(). |
|
NMLConnection(NMLMessageDictionary msg_dict,
java.lang.String BufferName,
java.lang.String ProcessName,
java.lang.String ConfigurationFile)
This constuctor creates a fully functional NML Connection using the application defined NMLMessageDictionary, read the NML configuration file, and connects immediately. |
|
NMLConnection(NMLMessageDictionary msg_dict,
java.lang.String BufferName,
java.lang.String ProcessName,
java.lang.String ConfigurationFile,
java.lang.String[] _additional_options)
This constuctor creates a fully functional NML Connection using the application defined NMLMessageDictionary, read the NML configuration file, and connects immediately. |
Method Summary | |
---|---|
static void |
AddNMLErrorAppender(NMLErrorAppender nea)
Add an opject to be called with each error to append messages. |
protected int |
cancelUDPSubscription()
|
static void |
ClearStaticData()
Clear any data saved from previously read configuration files. |
int |
closeSingleVarLog(int var_log_number)
Stop collecting data on a single variable setup in setupSingleVarLog(). |
int |
connect()
Connect or reconnect to the sockets as appropriate. |
int |
connectNoThrow()
Connect as connect() but simply print a message to strderr and return -1 in case of an error rather than throwing an exception. |
void |
disconnect()
Disconnect this object from the NML server. |
protected void |
finalize()
|
java.lang.String |
get_buffer_name()
Get the buffer name. |
int |
get_buffer_number()
Get the buffer_number for this buffer. |
java.lang.String |
get_configuration_file()
Get the name of the NML configuration file being used. |
long |
get_connect_time()
Get the time in milliseconds when the last connect() was attempted. |
long |
get_disconnect_time()
Get the time in milliseconds when the last disconnect() was attempted. |
java.lang.String |
get_host()
Get the host name where the buffer is supposed to be located. |
java.lang.String |
get_last_exception_string()
Stop collecting data on a single variable setup in setupSingleVarLog(). |
int |
get_last_id_read()
Each message has an id used to determine if it is new. |
int |
get_msg_count()
Get the number of messages that have been successfully written to the buffer, including messages written by other processes/systems. |
int |
get_msg_type()
Get the type of message in the currently in the buffer. |
int |
get_port()
Return the TCP or UDP port number associated with this connection. |
java.lang.String |
get_process_name()
Get the process name. |
java.lang.String |
get_returned_buffer_name()
When the NMLConnection performs a verify bufname (which it normally does in the constructor) it requests the buffername from the server that corresponds to the selected port and buffer number. |
static NMLConfigInfo |
GetAllConfigInfoFromServer(java.lang.String server)
|
int |
getAllocation_size_max()
|
java.lang.String |
getBufferLine()
Get the buffer line from the configuration file. |
static NMLConfigInfo |
GetConfigInfo(java.lang.String configuration_file)
Parse or return configution info from a previously parsed NML configuration file. |
NMLFormatConverter |
GetFormatConverter()
This functions gets the NMLFormatConverter for this connection. |
NMLMessageDictionary |
GetMessageDictionary()
This functions gets the NMLMessageDictionary for this connection. |
int |
getNoThrowErrorCount()
Get the number of times a NoThrow fuction returned -1 for this object. |
long |
getRequest_sent_time_millis()
Get the value of request_sent_time_millis |
NMLSingleVarLog |
getSingleVarLog(int var_log_number)
Get a NMLSingleVaLog object associated with the var_log_number that should have been returned by setupSingleVarLog() |
boolean |
is_connected()
Get the value of the connected property. |
static boolean |
isDefault_poll_state()
|
boolean |
isPoll()
|
boolean |
isRead_only()
|
boolean |
isWrite_only()
|
boolean |
login(java.lang.String name,
java.lang.String passwd)
This function allows the application to gain access to NML servers with security enabled. |
boolean |
loginNoThrow(java.lang.String _name,
java.lang.String _passwd)
Login to an NML server using a name and passwd. |
protected boolean |
loginTCP(java.lang.String name,
java.lang.String passwd)
|
void |
ParseAdditionalOptions(java.lang.String[] _additional_options)
|
protected void |
peek_raw_data()
|
NMLmsg |
peek()
Read an NMLmsg but do not change the was_read flag. |
java.lang.String |
peekDataString()
Reads an NMLmsg using peek() and converts it to a String. |
java.lang.String |
peekDataStringNoThrow()
Peek a message and convert it to a comma delimeted string. |
protected java.lang.String |
peekSTCPDataString()
|
protected void |
peekTCP_raw_data()
|
protected NMLmsg |
peekTCP()
|
protected void |
peekUDP_raw_data()
|
protected NMLmsg |
peekUDP()
|
java.lang.String |
read_errlog_string()
|
protected void |
read_raw_data()
|
NMLmsg |
read()
Read a NMLmsg. |
java.lang.String |
readDataString()
Reads an NMLmsg and converts it to a String. |
java.lang.String |
readDataStringNoThrow()
Read a message and convert it to a comma delimeted string. |
void |
ReadNMLConfigurationFile()
Rereadn the NML Configuration file. |
void |
ReadNMLConfigurationFile(java.lang.String BufferName,
java.lang.String ProcessName,
java.lang.String ConfigurationFile)
This function reads configuration information from the NML configuration file. |
void |
ReadNMLConfigurationFileNoThrow()
Reread the NML Configuration and reconnect. |
protected java.lang.String |
readSTCPDataString()
|
protected void |
readTCP_raw_data()
|
protected NMLmsg |
readTCP()
|
protected void |
readUDP_raw_data()
|
protected NMLmsg |
readUDP()
|
void |
set_buffer_name(java.lang.String _buffer_name)
Set the buffer name. |
void |
set_buffer_number(int _buffer_number)
Set the buffer_number for this buffer. |
static void |
set_config_debug_on(boolean b)
Print messages to the console/stderr to debug the config related code. |
void |
set_configuration_file(java.lang.String _configuration_file)
Set the name of the NML configuration file. |
void |
set_host(java.lang.String _host)
Set the host name where the buffer is supposed to be located which will be used for the next connection attempt. |
void |
set_last_id_read(int _id)
Set the id which will be compared with messages recieved to determine if the message is new. |
void |
set_port(int _port)
Set the TCP or UDP port to be used for the next time a connect() is performed. |
void |
set_process_name(java.lang.String _process_name)
Set the process name. |
void |
set_read_debug_on(boolean b)
|
void |
set_write_debug_on(boolean b)
|
void |
setAllocation_size_max(int allocation_size_max)
|
static void |
setDefault_poll_state(boolean aDefault_poll_state)
|
int |
setDiagInfo()
Send additional diagnostics info to server so it can better track which process is doing what. |
void |
SetFormatConverter(NMLFormatConverter new_fc)
This functions sets the NMLFormatConverter for this connection. |
void |
SetFormatConvertErrCallback(NMLFormatConvertErrCallbackInterface new_nfceci)
Set an interface that will have its member functions called for various errors. |
void |
SetMessageDictionary(NMLMessageDictionary new_dict)
This functions sets the NMLMessageDictionary for this connection. |
void |
setPoll(boolean poll)
|
void |
setRead_only(boolean read_only)
|
int |
setSubscriptionPeriod(double period)
Tell the server to send this process messages from the buffer every period seconds without needing a request message. |
protected int |
setTCPDiagInfo()
|
protected int |
setTCPSubscriptionPeriod(double period)
|
protected int |
setUDPSubscriptionPeriod(double period)
|
int |
setupSingleVarLog(java.lang.String varname,
int maxlogsize,
double period,
int type)
Setup a single variable log. |
void |
setWrite_only(boolean write_only)
|
java.lang.String |
toString()
|
protected int |
UDP_get_msg_count()
|
protected int |
UDP_get_msg_type()
|
boolean |
verify_bufname()
When the NMLConnection performs a verify bufname (which it normally does in the constructor) it requests the buffername from the server that corresponds to the selected port and buffer number. |
protected boolean |
verify_bufnameTCP()
|
int |
write(NMLmsg msg)
Writes an NMLmsg. |
int |
writeDataString(java.lang.String dataString)
Convert the string into an NMLmsg and send it to this channel. |
int |
writeDataStringNoThrow(java.lang.String dataString)
Convert the string into an NMLmsg and send it to this channel. |
protected int |
writeSTCPDataString(java.lang.String dataString)
|
protected int |
writeTCP(NMLmsg msg)
|
protected int |
writeUDP(NMLmsg msg)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static java.util.Hashtable previously_read_nml_configurations
protected NMLFormatConverterBase format_converter
protected NMLMessageDictionary message_dictionary
protected static final int NML_STCP_PROTOCOL_TYPE
protected static final int NML_TCP_PROTOCOL_TYPE
protected static final int NML_UDP_PROTOCOL_TYPE
protected int protocol_option
protected static final int NML_ASCII_ENCODING_TYPE
protected static final int NML_DISP_ENCODING_TYPE
protected static final int NML_XDR_ENCODING_TYPE
protected static final int NML_XML_ENCODING_TYPE
protected static final int NML_PACKED_ENCODING_TYPE
protected static final int NML_PACKEDL64_ENCODING_TYPE
protected static final int REMOTE_CMS_READ_REQUEST_TYPE
protected static final int REMOTE_CMS_WRITE_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_KEYS_REQUEST_TYPE
protected static final int REMOTE_CMS_LOGIN_REQUEST_TYPE
protected static final int REMOTE_CMS_SET_SUBSCRIPTION_REQUEST_TYPE
protected static final int REMOTE_CMS_READ_COMBINED_REQUEST_TYPE
protected static final int REMOTE_CMS_BLOCKING_READ_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_BUF_NAME_REQUEST_TYPE
protected static final int REMOTE_CMS_CANCEL_SUBSCRIPTION_REQUEST_TYPE
protected static final int REMOTE_CMS_SET_DIAG_INFO_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_DIAG_INFO_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_MSG_COUNT_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_QUEUE_LENGTH_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_SPACE_AVAILABLE_REQUEST_TYPE
protected static final int REMOTE_CMS_WRITE_WITH_PRIORITY_REQUEST_TYPE
protected static final int REMOTE_CMS_WRITE_WITH_BITWISE_OP_REQUEST_TYPE
protected static final int REMOTE_CMS_WAIT_FOR_WRITE_REQUEST_TYPE
protected static final int REMOTE_CMS_WAIT_FOR_READ_REQUEST_TYPE
protected static final int REMOTE_CMS_WAIT_FOR_QUEUE_LENGTH_REQUEST_TYPE
protected static final int REMOTE_CMS_WAIT_FOR_CLEAR_REQUEST_TYPE
protected static final int REMOTE_CMS_WAIT_FOR_ANYTHING_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_READ_COUNT_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_IS_CLEAR_REQUEST_TYPE
protected static final int REMOTE_CMS_SETUP_SINGLE_VAR_LOG_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_SINGLE_VAR_LOG_REQUEST_TYPE
protected static final int REMOTE_CMS_CLOSE_SINGLE_VAR_LOG_REQUEST_TYPE
protected static final int REMOTE_CMS_GET_MSG_TYPE_REQUEST_TYPE
protected boolean bad_host
protected static java.util.Vector unknown_hosts_vector
protected static final int CMS_READ_ACCESS
protected static final int CMS_CHECK_IF_READ_ACCESS
protected static final int CMS_PEEK_ACCESS
protected static final int CMS_WRITE_ACCESS
protected static final int CMS_WRITE_IF_READ_ACCESS
protected int output_data_size
protected NMLmsg last_msg_read
protected boolean read_request_sent
public static boolean do_not_print_errors
protected NMLFormatConvertErrCallbackInterface nfceci
public static boolean keep_old_configs
protected long request_sent_time_millis
public static final NMLConnectionCreator Creator
Constructor Detail |
---|
public NMLConnection()
NMLConnection(rcs.nml.NMLMessageDictionary, java.lang.String, java.lang.String, java.lang.String)
,
ReadNMLConfigurationFile(java.lang.String, java.lang.String, java.lang.String)
public NMLConnection(NMLMessageDictionary msg_dict, java.lang.String BufferName, java.lang.String ProcessName, java.lang.String ConfigurationFile) throws NMLException
msg_dict
- the NMLMessageDictionary for this connection to use (the NMLMessageDictionary allows this Connection to determine the message structure from the message type)BufferName
- the name of the buffer to connect to, (must match one of the buffers in the configuration file.)ProcessName
- the name of the process that will use this connection (must match one of the process names in the configuration file)ConfigurationFile
- the file name or URL of an NML configuration file (URL's should either be complete, or they can be relative to
rcs.utils.URL_and_FileLoader.current_directory)
NMLException
- If the configuration file can not be read, the file is improperly formatted or the buffer or process can
can not be found in it.public NMLConnection(NMLMessageDictionary msg_dict, java.lang.String BufferName, java.lang.String ProcessName, java.lang.String ConfigurationFile, java.lang.String[] _additional_options) throws NMLException
msg_dict
- the NMLMessageDictionary for this connection to use (the NMLMessageDictionary allows this Connection to determine the message structure from the message type)BufferName
- the name of the buffer to connect to, (must match one of the buffers in the configuration file.)ProcessName
- the name of the process that will use this connection (must match one of the process names in the configuration file)ConfigurationFile
- the file name or URL of an NML configuration file (URL's should either be complete, or they can be relative to
rcs.utils.URL_and_FileLoader.current_directory)_additional_options
-
NMLException
- If the configuration file can not be read, the file is improperly formatted or the buffer or process can
can not be found in it.Method Detail |
---|
public static boolean isDefault_poll_state()
public static void setDefault_poll_state(boolean aDefault_poll_state)
aDefault_poll_state
- the default_poll_state to setpublic long get_connect_time()
get_connect_time
in interface NMLConnectionInterface
public long get_disconnect_time()
get_disconnect_time
in interface NMLConnectionInterface
public java.lang.String get_last_exception_string()
get_last_exception_string
in interface NMLConnectionInterface
public int get_last_id_read()
get_last_id_read
in interface NMLConnectionInterface
public void set_last_id_read(int _id)
set_last_id_read
in interface NMLConnectionInterface
_id
- public java.lang.String get_returned_buffer_name()
get_returned_buffer_name
in interface NMLConnectionInterface
public int getNoThrowErrorCount()
getNoThrowErrorCount
in interface NMLConnectionInterface
public java.lang.String toString()
toString
in class java.lang.Object
public static void AddNMLErrorAppender(NMLErrorAppender nea)
nea
- public void SetMessageDictionary(NMLMessageDictionary new_dict)
SetMessageDictionary
in interface NMLConnectionInterface
new_dict
- the NMLMessageDictionary for this NMLConnection to use.NMLMessageDictionary
public void SetFormatConvertErrCallback(NMLFormatConvertErrCallbackInterface new_nfceci)
SetFormatConvertErrCallback
in interface NMLConnectionInterface
new_nfceci
- public NMLMessageDictionary GetMessageDictionary() throws NMLException
NMLException
SetMessageDictionary(rcs.nml.NMLMessageDictionary)
,
NMLMessageDictionary
public void SetFormatConverter(NMLFormatConverter new_fc) throws NMLException
new_fc
- the NMLFormatConverter for this Connection to use.
NMLException
NMLFormatConverter
public NMLFormatConverter GetFormatConverter() throws NMLException
NMLException
SetFormatConverter(rcs.nml.NMLFormatConverter)
public void ParseAdditionalOptions(java.lang.String[] _additional_options) throws NMLException
NMLException
public void ReadNMLConfigurationFile(java.lang.String BufferName, java.lang.String ProcessName, java.lang.String ConfigurationFile) throws NMLException
BufferName
- the name of the buffer to connect to, (must match one of the buffers in the configuration file.)ProcessName
- the name of the process that will use this connection (must match one of the process names in the configuration file)ConfigurationFile
- the file name or URL of an NML configuration file (URL's should either be complete, or they can be relative to
rcs.utils.URL_and_FileLoader.current_directory)
NMLException
- If the configuration file can not be read, the file is improperly formatted or the buffer or process can
can not be found in it.public static void ClearStaticData()
public static NMLConfigInfo GetConfigInfo(java.lang.String configuration_file)
configuration_file
-
public static NMLConfigInfo GetAllConfigInfoFromServer(java.lang.String server)
public void ReadNMLConfigurationFile() throws NMLException
NMLException
protected void finalize()
finalize
in class java.lang.Object
public int connect() throws NMLException
connect
in interface NMLConnectionInterface
NMLException
public void disconnect()
disconnect
in interface NMLConnectionInterface
public boolean login(java.lang.String name, java.lang.String passwd) throws NMLException
name
- the login name of the user running the client programpasswd
- the passwd of the user to login as.
NMLException
- If the login could not be attempted because the connection to the
NML server failed. (If the passwd is wrong it returns false.)public boolean verify_bufname()
verify_bufname
in interface NMLConnectionInterface
public NMLmsg read() throws NMLException
NMLException
- The read failed (ussually because of some network error).public int setDiagInfo()
protected int setTCPDiagInfo()
public int setupSingleVarLog(java.lang.String varname, int maxlogsize, double period, int type)
setupSingleVarLog
in interface NMLConnectionInterface
varname
- name of the variable to logmaxlogsize
- maximum number of variable updates to storeperiod
- time in seconds between checks to see if the variable changed.type
- type of expected message, no data is logged when other message types are in the buffer.
public NMLSingleVarLog getSingleVarLog(int var_log_number)
getSingleVarLog
in interface NMLConnectionInterface
var_log_number
-
public int closeSingleVarLog(int var_log_number)
closeSingleVarLog
in interface NMLConnectionInterface
var_log_number
-
public int setSubscriptionPeriod(double period)
period
-
protected int setUDPSubscriptionPeriod(double period)
protected int cancelUDPSubscription()
protected int setTCPSubscriptionPeriod(double period)
protected void read_raw_data() throws NMLException
NMLException
protected boolean verify_bufnameTCP() throws NMLException
NMLException
protected void readTCP_raw_data() throws NMLException
NMLException
protected NMLmsg readTCP() throws NMLException
NMLException
protected NMLmsg readUDP() throws NMLException
NMLException
protected void readUDP_raw_data() throws NMLException
NMLException
public NMLmsg peek() throws NMLException
NMLException
- The peek failed.protected void peek_raw_data() throws NMLException
NMLException
public long getRequest_sent_time_millis()
protected void peekTCP_raw_data() throws NMLException
NMLException
protected NMLmsg peekTCP() throws NMLException
NMLException
protected NMLmsg peekUDP() throws NMLException
NMLException
protected void peekUDP_raw_data() throws NMLException
NMLException
protected int UDP_get_msg_count() throws NMLException
NMLException
protected int UDP_get_msg_type() throws NMLException
NMLException
public java.lang.String readDataString() throws NMLException
NMLException
- The read failed.read()
protected java.lang.String readSTCPDataString() throws NMLException
NMLException
public java.lang.String peekDataString() throws NMLException
NMLException
- The peek failed.peek()
protected java.lang.String peekSTCPDataString() throws NMLException
NMLException
protected boolean loginTCP(java.lang.String name, java.lang.String passwd) throws NMLException
NMLException
protected int writeTCP(NMLmsg msg)
protected int writeUDP(NMLmsg msg)
public int write(NMLmsg msg) throws NMLException
msg
- the NMLmsg to write.
NMLException
public int writeDataString(java.lang.String dataString) throws NMLException
writeDataString
in interface NMLConnectionInterface
dataString
- string to be converted
NMLException
public int writeDataStringNoThrow(java.lang.String dataString)
writeDataStringNoThrow
in interface NMLConnectionInterface
dataString
- string to be converted
protected int writeSTCPDataString(java.lang.String dataString)
public java.lang.String get_host()
get_host
in interface NMLConnectionInterface
public void set_host(java.lang.String _host)
set_host
in interface NMLConnectionInterface
_host
- public java.lang.String get_configuration_file()
get_configuration_file
in interface NMLConnectionInterface
public void set_configuration_file(java.lang.String _configuration_file)
set_configuration_file
in interface NMLConnectionInterface
_configuration_file
- public java.lang.String get_buffer_name()
get_buffer_name
in interface NMLConnectionInterface
public void set_buffer_name(java.lang.String _buffer_name)
set_buffer_name
in interface NMLConnectionInterface
_buffer_name
- public java.lang.String get_process_name()
get_process_name
in interface NMLConnectionInterface
public void set_process_name(java.lang.String _process_name)
set_process_name
in interface NMLConnectionInterface
_process_name
- public java.lang.String readDataStringNoThrow()
readDataStringNoThrow
in interface NMLConnectionInterface
public java.lang.String peekDataStringNoThrow()
peekDataStringNoThrow
in interface NMLConnectionInterface
public int get_port()
get_port
in interface NMLConnectionInterface
public void set_port(int _port)
set_port
in interface NMLConnectionInterface
_port
- public int get_buffer_number()
get_buffer_number
in interface NMLConnectionInterface
public void set_buffer_number(int _buffer_number)
set_buffer_number
in interface NMLConnectionInterface
_buffer_number
- public void ReadNMLConfigurationFileNoThrow()
ReadNMLConfigurationFileNoThrow
in interface NMLConnectionInterface
public int connectNoThrow()
connectNoThrow
in interface NMLConnectionInterface
public boolean is_connected()
is_connected
in interface NMLConnectionInterface
public boolean loginNoThrow(java.lang.String _name, java.lang.String _passwd)
loginNoThrow
in interface NMLConnectionInterface
_name
- _passwd
-
public java.lang.String getBufferLine()
getBufferLine
in interface NMLConnectionInterface
public void set_read_debug_on(boolean b)
public void set_write_debug_on(boolean b)
public static void set_config_debug_on(boolean b)
b
- public java.lang.String read_errlog_string() throws NMLException
read_errlog_string
in interface NMLConnectionInterface
NMLException
public int get_msg_type() throws NMLException
NMLConnectionInterface
get_msg_type
in interface NMLConnectionInterface
NMLException
public int get_msg_count() throws NMLException
NMLConnectionInterface
get_msg_count
in interface NMLConnectionInterface
NMLException
public boolean isRead_only()
public void setRead_only(boolean read_only)
public boolean isWrite_only()
public void setWrite_only(boolean write_only)
public int getAllocation_size_max()
getAllocation_size_max
in interface NMLConnectionInterface
public void setAllocation_size_max(int allocation_size_max)
setAllocation_size_max
in interface NMLConnectionInterface
public boolean isPoll()
public void setPoll(boolean poll)
poll
- the poll to set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |