first commit
This commit is contained in:
commit
4d332ef662
27586 changed files with 3281783 additions and 0 deletions
|
|
@ -0,0 +1,168 @@
|
|||
package com.ablia.serial;
|
||||
|
||||
import com.ablia.util.Debug;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
public class SerialClient extends Debug {
|
||||
private int serialServerPort;
|
||||
|
||||
private String serialServerHost;
|
||||
|
||||
private Socket socket;
|
||||
|
||||
private StringBuffer serialSendCommand;
|
||||
|
||||
public static final String P_CLIENT_LOG_FILE = "SERIAL_CLIENT_LOG_FILE";
|
||||
|
||||
public SerialClient(String l_cashServerHost, int l_cashServerPort) {
|
||||
setSerialServerHost(l_cashServerHost);
|
||||
setSerialServerPort(l_cashServerPort);
|
||||
}
|
||||
|
||||
public String sendCommand(String theCommand, String parms) {
|
||||
try {
|
||||
Socket theSocket = getSocket();
|
||||
if (theSocket == null)
|
||||
return "Errore! Server not ready";
|
||||
BufferedReader red = new BufferedReader(new InputStreamReader(
|
||||
theSocket.getInputStream()));
|
||||
BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(
|
||||
theSocket.getOutputStream()));
|
||||
String commandString = theCommand;
|
||||
if (parms != null && !parms.equals(""))
|
||||
commandString = String.valueOf(commandString) + " " +
|
||||
parms.replace("\n", "|");
|
||||
wr.write(commandString);
|
||||
wr.write("\n");
|
||||
wr.flush();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String str;
|
||||
while (!(str = red.readLine()).equals("##END##")) {
|
||||
sb.append(str);
|
||||
sb.append("\n");
|
||||
System.out.println(String.valueOf(str) + str.length());
|
||||
System.out.println("##END##" +
|
||||
"##END##".length());
|
||||
}
|
||||
handleDebug("Response from server: " + sb.toString());
|
||||
return sb.toString();
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
return "Error! " + e.getMessage();
|
||||
} finally {
|
||||
try {
|
||||
if (getSocket() != null) {
|
||||
handleDebug("Clossing socket...", 1);
|
||||
getSocket().close();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
handleDebug(ioe);
|
||||
}
|
||||
setSocket(null);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSerialServerPort() {
|
||||
return this.serialServerPort;
|
||||
}
|
||||
|
||||
public void setSerialServerPort(int cashServerPort) {
|
||||
this.serialServerPort = cashServerPort;
|
||||
}
|
||||
|
||||
public String getSerialServerHost() {
|
||||
return (this.serialServerHost == null) ? "" : this.serialServerHost;
|
||||
}
|
||||
|
||||
public void setSerialServerHost(String cashServerHost) {
|
||||
this.serialServerHost = cashServerHost;
|
||||
}
|
||||
|
||||
public Socket getSocket() {
|
||||
if (this.socket == null)
|
||||
try {
|
||||
System.out.println("Connecting to serial server " +
|
||||
getSerialServerHost() + ":" + getSerialServerPort() +
|
||||
" .....");
|
||||
InetAddress addr = InetAddress.getByName(getSerialServerHost());
|
||||
this.socket = new Socket(addr, getSerialServerPort());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this.socket;
|
||||
}
|
||||
|
||||
public void setSocket(Socket socket) {
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
public boolean closeConnection() {
|
||||
if (this.socket != null) {
|
||||
try {
|
||||
String res = sendCommand("CLOSE", null);
|
||||
handleDebug(res, 1);
|
||||
this.socket.close();
|
||||
this.socket = null;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
handleDebug("Error! Attempting to close a null socket",
|
||||
2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getDebugFile() {
|
||||
return getLogFile();
|
||||
}
|
||||
|
||||
public int getDebugLevel() {
|
||||
return new Integer(getResource("DEBUG_LEVEL"))
|
||||
.intValue();
|
||||
}
|
||||
|
||||
public String getLogFile() {
|
||||
return getResource("SERIAL_CLIENT_LOG_FILE");
|
||||
}
|
||||
|
||||
public void addSerialSendCommand(String aCommand) {
|
||||
getSerialSendCommand().append(aCommand);
|
||||
getSerialSendCommand().append("|");
|
||||
}
|
||||
|
||||
public StringBuffer getSerialSendCommand() {
|
||||
if (this.serialSendCommand == null)
|
||||
this.serialSendCommand = new StringBuffer();
|
||||
return this.serialSendCommand;
|
||||
}
|
||||
|
||||
public void resetSerialSendCommand() {
|
||||
setSerialSendCommand(null);
|
||||
}
|
||||
|
||||
public void setSerialSendCommand(StringBuffer stringCommand) {
|
||||
this.serialSendCommand = stringCommand;
|
||||
}
|
||||
|
||||
public String sendSerialSendCommand() {
|
||||
return sendCommand("SEND", getSerialSendCommand()
|
||||
.toString());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SerialClient cc = new SerialClient("localhost", 441);
|
||||
String res = cc.sendCommand("SEND",
|
||||
"KXCL|KXSEPRE 2/2009|KXCBSDFSADFASDF|KXSEDSFSADFADSFSAF|KXCE");
|
||||
System.out.println(res);
|
||||
cc.closeConnection();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,201 @@
|
|||
package com.ablia.serial;
|
||||
|
||||
import com.ablia.util.StringTokenizer;
|
||||
import gnu.io.CommPortIdentifier;
|
||||
import gnu.io.SerialPort;
|
||||
import gnu.io.SerialPortEvent;
|
||||
import gnu.io.SerialPortEventListener;
|
||||
import gnu.io.UnsupportedCommOperationException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public abstract class SerialPortWriter implements SerialPortEventListener {
|
||||
private String portName;
|
||||
|
||||
private CommPortIdentifier portId;
|
||||
|
||||
private SerialPort serialPort;
|
||||
|
||||
private InputStreamReader inputStream;
|
||||
|
||||
protected Thread readThread;
|
||||
|
||||
protected SerialPortWriter(String portName, long l_comDelayStart, long l_comDelayCmd, long l_comDelayEnd) {
|
||||
setPortName(portName);
|
||||
setComDelayStart(l_comDelayStart);
|
||||
setComDelayCmd(l_comDelayCmd);
|
||||
setComDelayEnd(l_comDelayEnd);
|
||||
}
|
||||
|
||||
private long comDelayStart = 1100L;
|
||||
|
||||
private long comDelayCmd = 100L;
|
||||
|
||||
private long comDelayEnd = 1000L;
|
||||
|
||||
protected static Hashtable htSerialPortWriter = new Hashtable();
|
||||
|
||||
protected SerialPortWriter() {}
|
||||
|
||||
public String getPortName() {
|
||||
return this.portName;
|
||||
}
|
||||
|
||||
public void setPortName(String portName) {
|
||||
this.portName = portName;
|
||||
}
|
||||
|
||||
public CommPortIdentifier getPortId() {
|
||||
if (this.portId == null) {
|
||||
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
|
||||
boolean portNotFound = true;
|
||||
while (portList.hasMoreElements() && portNotFound) {
|
||||
this.portId = (CommPortIdentifier)portList.nextElement();
|
||||
if (this.portId.getPortType() == 1 &&
|
||||
this.portId.getName().equals(getPortName())) {
|
||||
System.out.println("Found port: " + getPortName());
|
||||
portNotFound = false;
|
||||
}
|
||||
}
|
||||
if (portNotFound)
|
||||
System.out.println("port " + getPortName() + " not found.");
|
||||
}
|
||||
return this.portId;
|
||||
}
|
||||
|
||||
public SerialPort getSerialPort() {
|
||||
if (this.serialPort == null)
|
||||
try {
|
||||
this.serialPort = (SerialPort)getPortId().open("SimpleWrite", 2000);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Port in use." + e.getMessage());
|
||||
}
|
||||
return this.serialPort;
|
||||
}
|
||||
|
||||
public void setSerialPort(SerialPort l_serialPort) {
|
||||
this.serialPort = l_serialPort;
|
||||
}
|
||||
|
||||
public String sendToSerial(String theMsg) {
|
||||
String res = "";
|
||||
try {
|
||||
long delayIntestazione = this.comDelayStart;
|
||||
long delayFine = this.comDelayEnd;
|
||||
long delayComando = this.comDelayCmd;
|
||||
OutputStream outputStream = getSerialPort().getOutputStream();
|
||||
getSerialPort().setSerialPortParams(9600, 8,
|
||||
1, 0);
|
||||
getSerialPort().notifyOnOutputEmpty(true);
|
||||
StringTokenizer st = new StringTokenizer(theMsg, "|");
|
||||
boolean firstCmd = true;
|
||||
while (st.hasMoreTokens()) {
|
||||
String theToken = st.nextToken();
|
||||
String theCmd = String.valueOf(theToken) + "\n\r";
|
||||
System.out.println("sendToSerial: " + theCmd);
|
||||
outputStream.write(theCmd.getBytes());
|
||||
if (firstCmd) {
|
||||
Thread.sleep(delayIntestazione);
|
||||
firstCmd = false;
|
||||
} else {
|
||||
Thread.sleep(delayComando);
|
||||
}
|
||||
res = readFromSerial();
|
||||
System.out.println(String.valueOf(theToken) + ": " + getResponseMessage(res));
|
||||
}
|
||||
Thread.sleep(delayFine);
|
||||
} catch (UnsupportedCommOperationException e) {
|
||||
e.printStackTrace();
|
||||
res = e.getMessage();
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error setting event notification");
|
||||
System.out.println(e.toString());
|
||||
res = "Error setting event notification! " + e.toString();
|
||||
System.exit(-1);
|
||||
}
|
||||
getSerialPort().close();
|
||||
setSerialPort(null);
|
||||
return res;
|
||||
}
|
||||
|
||||
public void serialEvent(SerialPortEvent event) {
|
||||
switch (event.getEventType()) {
|
||||
case 1:
|
||||
notifyAll();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public String readFromSerial() {
|
||||
try {
|
||||
while (!getInputStream().ready())
|
||||
Thread.sleep(10L);
|
||||
BufferedReader bufRead = new BufferedReader(getInputStream());
|
||||
String temp = bufRead.readLine();
|
||||
getInputStream().close();
|
||||
setInputStream(null);
|
||||
return temp;
|
||||
} catch (Exception e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public InputStreamReader getInputStream() {
|
||||
if (this.inputStream == null)
|
||||
try {
|
||||
this.inputStream = new InputStreamReader(getSerialPort()
|
||||
.getInputStream());
|
||||
getSerialPort().notifyOnDataAvailable(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this.inputStream;
|
||||
}
|
||||
|
||||
public void setInputStream(InputStreamReader inputStream) {
|
||||
this.inputStream = inputStream;
|
||||
}
|
||||
|
||||
public abstract String getResponseMessage(String paramString);
|
||||
|
||||
public long getComDelayStart() {
|
||||
return this.comDelayStart;
|
||||
}
|
||||
|
||||
public void setComDelayStart(long comDelayStart) {
|
||||
this.comDelayStart = comDelayStart;
|
||||
}
|
||||
|
||||
public long getComDelayCmd() {
|
||||
return this.comDelayCmd;
|
||||
}
|
||||
|
||||
public void setComDelayCmd(long comDelayCmd) {
|
||||
this.comDelayCmd = comDelayCmd;
|
||||
}
|
||||
|
||||
public long getComDelayEnd() {
|
||||
return this.comDelayEnd;
|
||||
}
|
||||
|
||||
public void setComDelayEnd(long comDelayEnd) {
|
||||
this.comDelayEnd = comDelayEnd;
|
||||
}
|
||||
|
||||
public static synchronized SerialPortWriterInterface getInstance(String portName, long l_comDelayStart, long l_comDelayCmd, long l_comDelayEnd) {
|
||||
String cpKey = portName;
|
||||
if (htSerialPortWriter.containsKey(cpKey))
|
||||
return (SerialPortWriterInterface)htSerialPortWriter.get(cpKey);
|
||||
SerialPortWriterInterface sp = getNewWriterInstance(portName,
|
||||
l_comDelayStart, l_comDelayCmd, l_comDelayEnd);
|
||||
htSerialPortWriter.put(cpKey, sp);
|
||||
return sp;
|
||||
}
|
||||
|
||||
protected static SerialPortWriterInterface getNewWriterInstance(String l_portName, long l_comDelayStart, long l_comDelayCmd, long l_comDelayEnd) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.ablia.serial;
|
||||
|
||||
public interface SerialPortWriterInterface {
|
||||
String sendToSerial(String paramString);
|
||||
|
||||
String readFromSerial();
|
||||
|
||||
String getPortName();
|
||||
}
|
||||
|
|
@ -0,0 +1,273 @@
|
|||
package com.ablia.serial;
|
||||
|
||||
import com.ablia.util.Debug;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class SerialServer extends Debug {
|
||||
public static final String CMD_CLEAR_LOG_FILE = "CLLOG";
|
||||
|
||||
public static final String CMD_SEND = "SEND";
|
||||
|
||||
public static final String CMD_GET_LOG_FILE = "GTLOG";
|
||||
|
||||
public static final String EOM = "##END##";
|
||||
|
||||
class CommServer extends Thread {
|
||||
private static final String nl = "\r\n";
|
||||
|
||||
private final Socket socket;
|
||||
|
||||
final SerialServer this$0;
|
||||
|
||||
public CommServer(SerialServer this$0, Socket l_socket) {
|
||||
this.this$0 = this$0;
|
||||
this.socket = l_socket;
|
||||
start();
|
||||
}
|
||||
|
||||
private String getCommand(String cmd) {
|
||||
return cmd.substring(Math.min(0, cmd.length()),
|
||||
Math.min(5, cmd.length())).toUpperCase().trim();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String remoteIp = this.socket.getInetAddress().toString();
|
||||
try {
|
||||
System.out.println("Start connection with " + remoteIp);
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(
|
||||
this.socket.getInputStream()));
|
||||
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
|
||||
this.socket.getOutputStream()));
|
||||
int i = 0;
|
||||
String str;
|
||||
while (this.socket.isConnected() && (str = rd.readLine()) != null) {
|
||||
this.this$0.handleDebug("\nReceived: " + str, 1);
|
||||
if (getCommand(str).equals("GTLOG")) {
|
||||
if (new File(this.this$0.getLogFile()).exists()) {
|
||||
BufferedReader bufferedreader = new BufferedReader(
|
||||
new FileReader(this.this$0.getLogFile()));
|
||||
String theLine;
|
||||
while ((theLine = bufferedreader.readLine()) != null) {
|
||||
bw.write(theLine);
|
||||
bw.write("\r\n");
|
||||
}
|
||||
bufferedreader.close();
|
||||
} else {
|
||||
bw.write("File " + this.this$0.getLogFile() + " non trovato.");
|
||||
}
|
||||
bw.write("##END##");
|
||||
bw.write("\r\n");
|
||||
bw.flush();
|
||||
} else {
|
||||
if (getCommand(str).equals("CLOSE")) {
|
||||
bw.write("Closing the socket");
|
||||
bw.write("\r\n");
|
||||
bw.write("##END##");
|
||||
bw.write("\r\n");
|
||||
bw.flush();
|
||||
this.socket.close();
|
||||
break;
|
||||
}
|
||||
if (getCommand(str).equals("CLLOG")) {
|
||||
new File(this.this$0.getLogFile()).delete();
|
||||
bw.write("Log file deleted.");
|
||||
bw.write("\r\n");
|
||||
bw.write("##END##");
|
||||
bw.write("\r\n");
|
||||
bw.flush();
|
||||
} else if (getCommand(str).equals("SEND")) {
|
||||
String cashString = str.substring("SEND".length())
|
||||
.trim();
|
||||
this.this$0.handleDebug("\nInvio alla seriale: " + cashString,
|
||||
1);
|
||||
String temp = this.this$0.sendString(cashString);
|
||||
this.this$0.handleDebug("\nfine invio alla seriale. Risultato: " +
|
||||
temp, 1);
|
||||
bw.write(temp);
|
||||
bw.write("\r\n");
|
||||
bw.write("##END##");
|
||||
bw.write("\r\n");
|
||||
bw.flush();
|
||||
} else if (!getCommand(str).equals(
|
||||
"")) {
|
||||
bw.write("Abl Serial Server V. " +
|
||||
SerialServer.getSoftwareVersion());
|
||||
bw.write("\r\nError! Command " + str + " unknow");
|
||||
bw.write("\r\nValid Command:");
|
||||
bw.write("\r\nGet log file: GTLOG");
|
||||
bw.write("\r\nClear log file: CLLOG");
|
||||
bw.write("\r\nSend string to serial: SEND");
|
||||
bw.write("\r\n");
|
||||
bw.write("##END##");
|
||||
bw.write("\r\n");
|
||||
bw.flush();
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
this.this$0.handleDebug(e);
|
||||
} finally {
|
||||
try {
|
||||
if (this.socket != null)
|
||||
this.socket.close();
|
||||
} catch (IOException ioe) {
|
||||
this.this$0.handleDebug(ioe);
|
||||
}
|
||||
}
|
||||
System.out.println("socket close with " + remoteIp);
|
||||
}
|
||||
}
|
||||
|
||||
int logLevel = 0;
|
||||
|
||||
private ResourceBundle propertyResource;
|
||||
|
||||
public static final String P_COM_PORT = "SERIAL_COM_PORT";
|
||||
|
||||
public static final String P_COM_DELAY_END = "COM_DELAY_END";
|
||||
|
||||
public static final String P_COM_DELAY_START = "COM_DELAY_START";
|
||||
|
||||
public static final String SEP = "|";
|
||||
|
||||
public static final String P_SERVER_PORT = "SERIAL_SERVER_PORT";
|
||||
|
||||
public static final String CMD_CLOSE = "CLOSE";
|
||||
|
||||
public static final String P_SERVER_LOG_FILE = "SERIAL_SERVER_LOG_FILE";
|
||||
|
||||
public static final String P_SERVER_HOSTNAME = "SERIAL_SERVER_HOSTNAME";
|
||||
|
||||
public static final String P_COM_DELAY_CMD = "COM_DELAY_CMD";
|
||||
|
||||
public static void main(String[] args) {}
|
||||
|
||||
public SerialServer() {
|
||||
String temp = "\nServer Properties.\nproperty file:" +
|
||||
getPropertyFileName() + "\ncom port: " +
|
||||
getResource("SERIAL_COM_PORT") + "\ncom delay start: " +
|
||||
getResourceLong("COM_DELAY_START") + "\ncom delay cmd: " +
|
||||
getResourceLong("COM_DELAY_CMD") + "\ncom delay end: " +
|
||||
getResourceLong("COM_DELAY_END") + "\nserver port: " +
|
||||
getServerPort() + "\n-------------------------";
|
||||
handleDebug("\n-------------------------\nSTART Serial Server V. " +
|
||||
getSoftwareVersion() + temp, 1);
|
||||
startServer();
|
||||
}
|
||||
|
||||
public String getLogFile() {
|
||||
return getResource("SERIAL_SERVER_LOG_FILE");
|
||||
}
|
||||
|
||||
public int getDebugLevel() {
|
||||
return new Integer(getResource("DEBUG_LEVEL"))
|
||||
.intValue();
|
||||
}
|
||||
|
||||
public String getPropertyFileName() {
|
||||
return "serial";
|
||||
}
|
||||
|
||||
public int getServerPort() {
|
||||
if (getResource("SERIAL_SERVER_PORT").equals(
|
||||
""))
|
||||
return 443;
|
||||
return Integer.parseInt(getResource("SERIAL_SERVER_PORT"));
|
||||
}
|
||||
|
||||
public static String getSoftwareVersion() {
|
||||
return "AbSerial_0_07_310510";
|
||||
}
|
||||
|
||||
private ResourceBundle getPropertyResource() {
|
||||
try {
|
||||
if (this.propertyResource == null)
|
||||
this.propertyResource =
|
||||
ResourceBundle.getBundle(getPropertyFileName());
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR!! ApplParm.getPropertyResource() ");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return this.propertyResource;
|
||||
}
|
||||
|
||||
public String getResource(String key) {
|
||||
try {
|
||||
String temp = getPropertyResource().getString(key);
|
||||
return temp;
|
||||
} catch (Exception e) {
|
||||
handleDebug(e, 2);
|
||||
System.out.println("SerialServer: " + e.getMessage() +
|
||||
" . Property file:" + getPropertyFileName());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String sendString(String strMsg) {
|
||||
SerialPortWriterInterface spw = getSerialWriter();
|
||||
return spw.sendToSerial(strMsg);
|
||||
}
|
||||
|
||||
public String getDebugFile() {
|
||||
return getLogFile();
|
||||
}
|
||||
|
||||
private void startServer() {
|
||||
ServerSocket srv = null;
|
||||
Socket socket = null;
|
||||
try {
|
||||
int port = getServerPort();
|
||||
srv = new ServerSocket(port);
|
||||
while (true) {
|
||||
handleDebug(" waiting for command...", 1);
|
||||
socket = srv.accept();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
handleDebug(e);
|
||||
} finally {
|
||||
try {
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
srv.close();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
handleDebug(ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SerialPortWriterInterface getSerialWriter() {
|
||||
return SerialPortWriter.getInstance(getResource("SERIAL_COM_PORT"),
|
||||
getResourceLong("COM_DELAY_START"),
|
||||
getResourceLong("COM_DELAY_CMD"),
|
||||
getResourceLong("COM_DELAY_END"));
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public long getResourceLong(String key) {
|
||||
try {
|
||||
String temp = getPropertyResource().getString(key);
|
||||
return Long.parseLong(temp);
|
||||
} catch (Exception e) {
|
||||
handleDebug(e, 2);
|
||||
System.out.println("SerialServer: " + e.getMessage() +
|
||||
" . Property file:" + getPropertyFileName());
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue