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

📄 protocol_wr_wdc07a.java

📁 GPRS数据通讯软件源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public static String ReturnGetItems(String MN,String ST){        String SendStr = "ST="+ST+";CN=5021;PW=753951;MN="+MN+";Flag=3;CP=&&&&";        return RetuSendStr(SendStr);    }        //返回读取监测项目是否上传的命令    public static String ReturnGetItemsSet(String MN,String ST){        String SendStr = "ST="+ST+";CN=5011;PW=753951;MN="+MN+";Flag=3;CP=&&&&";        return RetuSendStr(SendStr);    }        //返回设置监测项目是否上传的命令    public static String ReturnSetItemsSet(String MN,String TDSet,String ST){        String SendStr = "ST="+ST+";CN=5012;PW=753951;MN="+MN+";Flag=3;CP=&&TDSet="+TDSet+"&&";        return RetuSendStr(SendStr);    }            //返回设置系统时间的命令    public static String ReturnSetSystemTime(String MN,Date SystemTime,String ST){        String SendStr = "ST="+ST+";CN=1012;PW=753951;MN="+MN+";Flag=3;CP=&&SystemTime="+df2.format(SystemTime)+"&&";        return RetuSendStr(SendStr);    }        //提取上传间隔    public static String ReturnGetFixTime(String MN,String ST){        String SendStr = "ST="+ST+";CN=1061;PW=753951;MN="+MN+";Flag=3;CP=&&&&";        return RetuSendStr(SendStr);    }        //返回CN    public static String GetCN(byte[] bytes){        String temp = new String(bytes);        String ReStr = "";        int i = temp.indexOf("CN=");        if(i>-1){            temp = temp.substring(i+3);            int l = temp.indexOf(";");            if(l>-1){                temp = temp.substring(0,l);                ReStr = temp;            }        }        return ReStr;    }        //返回CP    public static String GetCP(byte[] bytes){        String temp = new String(bytes);        String ReStr = "";        int i = temp.indexOf("&&");        if(i>-1){            temp = temp.substring(i+2);            int l = temp.indexOf("&&");            if(l>-1){                temp = temp.substring(0,l);                ReStr = temp;            }        }        return ReStr;    }        //返回以分号分割的字符串数组    public static String[] GetStrs(byte[] bytes){        String temp = new String(bytes);        String[] Strs = temp.split(";");        return Strs;    }        //给定时数据添上最大值最小值    public static String AddMaxMin(String temp){        String rstr = temp;        String[] Strs = temp.split(";");        for(int i=0;i<Strs.length;i++){            if(Strs[i].indexOf("Avg")>0){                String Item = GetItem(Strs[i]);                rstr = rstr.replaceAll(Strs[i], Strs[i]+","+Item+"-Max=0,"+Item+"-Min=0");                            }        }        return rstr;    }        //返回数据项名    public static String GetItem(String Str){        int i = Str.indexOf("=");        if(i>0){            String R = Str.substring(0,i);            int j = R.indexOf("-");            if(j>0){                R = R.substring(0,j);            }            return R;        }else{            return "";        }    }        //返回数据值    public static String GetValue(String Str){        int i = Str.indexOf("=");        int j = Str.indexOf(",");        int k = Str.indexOf(";");        int l = -1;        if(j!=-1){            l = j;        }else{            l = k;        }        if(l>0){            return Str.substring(i+1,l);        }else{            return Str.substring(i+1);        }                }           //返回数据时间    public static String GetDataTime(byte[] bytes){        String temp = new String(bytes);        String ReStr = "";        int i = temp.indexOf("DataTime=");        if(i>-1){            temp = temp.substring(i+9);            int l = temp.indexOf(";");            if(l>-1){                temp = temp.substring(0,l);                ReStr = temp;            }        }        if(!ReStr.equals("")){            try {                Date date = df2.parse(ReStr);                ReStr = df3.format(date);            } catch (ParseException ex) {//                Logger.getLogger(Protocol_WR_WDC07A.class.getName()).log(Level.SEVERE, null, ex);            } catch (NumberFormatException ex) {//                Logger.getLogger(Protocol_WR_WDC07A.class.getName()).log(Level.SEVERE, null, ex);            } catch (ArrayIndexOutOfBoundsException ex) {//                Logger.getLogger(Protocol_WR_WDC07A.class.getName()).log(Level.SEVERE, null, ex);            }        }        return ReStr;    }        //返回特定数据段的值    public static String GetValue(String ItemName,String CP){        String ReStr = "";        String FindStr = ItemName+"=";        int i = CP.indexOf(FindStr);        i += FindStr.length();        try {            CP = CP.substring(i);            int k = CP.indexOf(";");            if(k>0){                CP = CP.substring(0,k);            }            ReStr = CP;        } catch (StringIndexOutOfBoundsException exception) {        }        return ReStr;    }        //读取十六个通道用逗号隔开    public static String GetChannel(byte[] bytes){        String CP = GetCP(bytes);                String ReStr = "";        String[] Strs = CP.split(";");        for(int i=1;i<Strs.length;i++){            ReStr += GetValue(Strs[i])+",";        }        return ReStr;    }        //把实时数据CP中的值取出来,添加到集合返回    public static Vector GetValues(byte[] bytes){        String CP = GetCP(bytes);                Vector ReVector = new Vector();        ReVector.add(GetDataTime(bytes));        String[] Strs = CP.split(";");        for(int i=1;i<Strs.length;i++){            String temp = GetItem(Strs[i]);            if(temp.equals("DO")||temp.equals("DI")){                            }else if(temp.equals("KGL")){                int kgl = Integer.parseInt(GetValue(Strs[i]), 16);                String skgl = "";                for(int j=0;j<8;j++){                    if(kgl%2==1){                        skgl += "○";                    }else{                        skgl += "●";                    }                    kgl /= 2;                }                ReVector.add(skgl);            }else{                if(Strs[i].indexOf("Cou")==-1){                                        ReVector.add(GetValue(Strs[i]));                }                            }                    }        return ReVector;    }        //把实时数据CP中的监测项目取出来,添加到集合返回    public static Vector GetItms(byte[] bytes){        String CP = GetCP(bytes);        Vector ReVector = new Vector();        ReVector.add(GetDataTime(bytes));        String[] Strs = CP.split(";");        for(int i=1;i<Strs.length;i++){            String temp = GetItem(Strs[i]);            if(temp.equals("DO")||temp.equals("DI")){                            }else{                if(Strs[i].indexOf("Cou")==-1){                    ReVector.add(temp);                }                            }                    }        return ReVector;    }}

⌨️ 快捷键说明

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