| | |
| | | package com.iedscout;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileNotFoundException;
|
| | | import java.io.IOException;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.net.InetAddress;
|
| | |
| | |
|
| | | }
|
| | |
|
| | | public void connectIEDDevice() { |
| | | public void connectIEDDevice() throws FileNotFoundException { |
| | | try {
|
| | | param.setFail_reasion(IEDScout_Param.FAILREASION_NULL);
|
| | | while(m_App_IsConnect) {
|
| | | try {
|
| | | logger.info("BTS_IEC61850_Client Start to connect to device IP:" + param.target_ip + " Port:" + param.target_port);
|
| | |
| | | m_Association = m_ClientSap.associate(InetAddress.getByName(param.target_ip), param.target_port, null, null);
|
| | |
|
| | | } catch (Exception e) {
|
| | | logger.error("BTS_IEC61850_Client Unable to connect to device IP:" + param.target_ip);
|
| | | logger.error(e.toString(), e);
|
| | | m_App_IsConnect = false;
|
| | | param.setFail_reasion(IEDScout_Param.FAILREASION_PARAMERROR);
|
| | | param.setConn_st(IEDScout_Param.CONN_STATE_FAIL);
|
| | | logger.info("BTS_IEC61850_Client Unable to connect to device IP:" + param.target_ip);
|
| | | break;
|
| | | }
|
| | | logger.info("Start Load ICD File '" + param.target_icd + "'");
|
| | | |
| | | try {
|
| | | File file = new File(param.target_icd);
|
| | | if(!file.exists()) {
|
| | | param.setFail_reasion(IEDScout_Param.FAILREASION_FILENOTFOUND);
|
| | | param.setConn_st(IEDScout_Param.CONN_STATE_FAIL);
|
| | | logger.info("ICD File '" + param.target_icd + "' Not EXISTS ");
|
| | | break;
|
| | | }
|
| | | |
| | | try { |
| | | //加载模型文件
|
| | | List<ServerSap> serverSaps = ServerSap.getSapsFromSclFile(param.target_icd);
|
| | | m_ServerModel = serverSaps.get(0).serverModel;
|
| | | } catch (Exception e1) {
|
| | | m_App_IsConnect = false;
|
| | | param.setFail_reasion(IEDScout_Param.FAILREASION_FILENOTFOUND);
|
| | | param.setConn_st(IEDScout_Param.CONN_STATE_FAIL);
|
| | | }catch (Exception e1) {
|
| | |
|
| | | logger.error("Error Parsing ICD File: " + e1.getMessage());
|
| | | logger.info("Error Parsing ICD File: " + e1.getMessage());
|
| | | |
| | | }
|
| | | if(null==m_ServerModel) {
|
| | | m_ServerModel = m_Association.retrieveModel();
|
| | | }
|
| | | if(null==m_ServerModel) {
|
| | | param.setFail_reasion(IEDScout_Param.FAILREASION_FILEERROR);
|
| | | param.setConn_st(IEDScout_Param.CONN_STATE_FAIL);
|
| | | break;
|
| | | }
|
| | | logger.info("Successfully Read Model ");
|
| | | List<BasicDataAttribute> ms = m_ServerModel.getBasicDataAttributes();
|
| | |
| | | if(m_App_IsConnect) {
|
| | | new Thread(mySQL_Task).start();
|
| | | is_clear_data = true;
|
| | | param.setConn_st(IEDScout_Param.CONN_STATE_SUCCESS);
|
| | | }
|
| | | BTS61850_IEDScout_Task_Thread_SQL.updateConnect_Inf_Table(pool, param);
|
| | | while(m_App_IsConnect) {
|
| | |
| | | }
|
| | | data.setNode_name(zh_name);
|
| | | }
|
| | | |
| | | data.setNode_path(modelNode.toString1());
|
| | | data.setNode_value(getBasicDataAttributeData(modelNode));
|
| | | if(data.node_path.equals("ZJDYCPSS/btgGGIO1.AnIn1.mag.f")) {
|
| | | System.out.println(data.getNode_name()+getBasicDataAttributeData(modelNode));
|
| | | }
|
| | | BTS61850_IEDScout_Task_Thread_SQL.updateupdateIed_NodeState_Table(pool, data);
|
| | | }
|
| | | }
|
| | | param.addCommNum();
|
| | |
| | | }else {
|
| | | param.addErrorNum();
|
| | | }
|
| | | |
| | | param.setConn_st(IEDScout_Param.CONN_STATE_SUCCESS);
|
| | | BTS61850_IEDScout_Task_Thread_SQL.updateConnect_Inf_Table(pool, param);
|
| | |
|
| | | ds = null;
|
| | |
| | |
|
| | | logger.error("DevIp:"+param.target_ip + " DisConnect ... ");
|
| | | }
|
| | | }
|
| | | |
| | | public void setAppIsConnect(boolean state) {
|
| | | this.m_App_IsConnect = state;
|
| | | }
|
| | |
|
| | |
|
| | |
| | |
|
| | |
|
| | | public static void main(String[] args) {
|
| | | MysqlConnPool pool = new MysqlConnPool("127.0.0.1",3360,10);
|
| | | MysqlConnPool pool = new MysqlConnPool("192.168.10.82",3360,10);
|
| | |
|
| | | BTS61850_IEDScout_Task_Thread thread = new BTS61850_IEDScout_Task_Thread(pool);
|
| | | thread.start();
|