⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autorsp126.java~1~

📁 用java写编写的一个GPS源代码请大家多多指教
💻 JAVA~1~
字号:
package com.gps.center.parsedata;

import java.util.regex.Pattern;
import java.util.Date;
//处理中心自动应答类
public class AutoRSP126 extends ParseData implements ParseInterface {

  public AutoRSP126() {
  }
  //处理车台类型信息
  public void ParseMsg(MsgObj msg) {
    if (msg.cMsgType == DEVICEUDPMSG) {
      parseTcpMsg(msg);
    }
  }
//处理消息成一定的类型并且调用函数发送出去
  private void parseTcpMsg(MsgObj msg) {
    //更新hash
    HashObj hashobj;//HashObj类的一个对象
    Pattern regex;
    //以逗号模式分割  存入数组中
    regex = Pattern.compile("[,]");
    String[] reStr = regex.split(msg.cMsg);

//    for (int i = 0; i < reStr.length; i++) {
//      System.out.println(reStr[i]);
//    }
    //GCOM0097,00000007,0000,13911584611
 //hsahtable的一个对象centerMap containsKey(Object key) Tests if the specified object is a key in this hashtable.
    if (super.centerMap.containsKey(reStr[3])) {//测试hsahtable中是否包含reStr[3]
      hashobj = (HashObj)super.centerMap.get(reStr[3]);//取出第3个值赋予
      if (hashobj.cDeviceUdpUsed) {//是hashObj类的一个boolean对象cDeviceUdpUsed--false
        if (! (hashobj.cDeviceAdd.getHostAddress().equals(msg.cDeviceAdd.//cDeviceAdd代表网络地址InetAddress的引用
            getHostAddress())
               ) |
            (hashobj.cDevicePort != msg.cUdpPort)) {
          hashobj.cDateTime = new Date();
          hashobj.cDeviceAdd = msg.cDeviceAdd;
          hashobj.cDevicePort = msg.cUdpPort;
        }
        else {
          hashobj.cDateTime = new Date();
        }
      }
      else {
        hashobj.cDateTime = new Date();
        hashobj.cUdpSocket = msg.cUdpSocket;
        hashobj.cDeviceAdd = msg.cDeviceAdd;
        hashobj.cDevicePort = msg.cUdpPort;
        hashobj.cDeviceUdpUsed = true;
      }
    }
    else {
      hashobj = new HashObj();
      hashobj.cDateTime = new Date();
      hashobj.cDeviceAdd = msg.cDeviceAdd;
      hashobj.cDevicePort = msg.cUdpPort;
      hashobj.cUdpSocket = msg.cUdpSocket;
      hashobj.cDeviceUdpUsed = true;
      super.centerMap.put(reStr[3], hashobj);//封装hashobj到第
    }

    //make send to Device command string
    //添加Msg到sendQueue
    //cMsgtype:1--TCPMSG,2--DEVICEUDPMSG,3--SMSMSG
    //4--TCPSENDTODEVICE,5--UDPSENDTODEVICE,6--SMSSENDTODEVICE,7--TCPSENDTOTERMINAL,8--TCPRETURNTERMINAL
    //String sendStr = null;
//    String queryStr = null;
//    queryStr = super.DbServer.getUserPopedom(reStr[2]);
    //GCOM0097,00000007,0000,13911584611
    //sendStr = "GCOM0097,00000126,0000,"+reStr[3];
//    System.out.println("Send: "+msg.cMsg);
    msg.cMsgType = UDPSENDTODEVICE;
    msg.cDeviceID = reStr[3];
    //msg.cMsg = sendStr;
    super.addSendMsg(msg);//调用函数送出消息

    MsgObj msgobj = new MsgObj();
    msgobj.cMsgType = TCPSENDTOTERMINAL;
    msgobj.cDeviceID = reStr[3];
    msgobj.cMsg = msg.cMsg;
    super.addSendMsg(msgobj);
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -