package com.dev.fbs9009;
|
|
import java.io.IOException;
|
import java.net.ServerSocket;
|
import java.net.Socket;
|
import java.util.Date;
|
|
import com.base.Com;
|
import com.battdata_rt.BattData_RT_Array;
|
import com.config.AppConfig;
|
import com.sql.MysqlConnPool;
|
|
public class MyModBusServerSocketThread extends Thread{
|
private MysqlConnPool m_ConnPool = null;
|
private BattData_RT_Array m_Data;
|
private AppConfig m_app_cfg;
|
|
public MyModBusServerSocketThread(MysqlConnPool pool, BattData_RT_Array data, AppConfig cfg)
|
{
|
m_ConnPool = pool;
|
m_Data = data;
|
m_app_cfg = cfg;
|
}
|
|
@Override
|
public void run() {
|
System.out.println(this.getName() + " - MyModBusServerSocketThread start at"+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
|
//´´½¨LD9É豸µÄ״̬
|
MyModBusSocketThread_SQL.createLD9_state(m_ConnPool);
|
|
//´´½¨LD9É豸µÄ²ÎÊý
|
MyModBusSocketThread_SQL.createLD9_setparam(m_ConnPool);
|
|
//´´½¨LD9É豸µÄ»ã¼¯Æ÷²ÎÊý±í
|
MyModBusSocketThread_SQL.createConcentratParamTable(m_ConnPool);
|
|
//´´½¨LD9É豸µÄ»ã¼¯Æ÷״̬±í
|
MyModBusSocketThread_SQL.createConcentratStateTable(m_ConnPool);
|
|
ServerSocket server = null;
|
while(true) {
|
try {
|
System.out.println("MyModBusServerSocketThread Listen port at 9009");
|
//¼àÌý9009¶Ë¿Ú
|
server = new ServerSocket(9009);
|
while(true) {
|
Socket tmp_socket = server.accept();
|
MyModBusSocketThread client
|
= new MyModBusSocketThread(m_ConnPool, m_Data, tmp_socket);
|
client.start();
|
}
|
} catch (IOException e) {
|
e.printStackTrace();
|
try {
|
server.close();
|
} catch (IOException e1) {
|
e1.printStackTrace();
|
}
|
}
|
}
|
}
|
|
public static void main(String[] args) {
|
MysqlConnPool pool = new MysqlConnPool("192.168.0.34",3360,10);
|
BattData_RT_Array array = new BattData_RT_Array(null, null, pool);
|
MyModBusServerSocketThread thread = new MyModBusServerSocketThread(pool,array,null);
|
thread.start();
|
}
|
}
|