-
大小: 50KB文件類型: .rar金幣: 2下載: 0 次發布日期: 2021-05-28
- 語言: Java
- 標簽:
資源簡介
dlt645-2007電能表協議解析源碼+串口編程源碼,利用串口編程直接與電能表通信,Java源碼

代碼片段和文件信息
import?java.io.*;
import?java.math.BigDecimal;
import?java.util.ArrayList;
import?java.util.List;
import?java.util.Properties;
/**
?*?Created?by?WuSong
?*?2017-05-02
?*/
public?class?AgreementDemo?{
????public?void?analysis(String?command)?throws?Exception?{
????????String[]?commands=command.trim().split(“?“);
????????List?list?=new?ArrayList();
????????for?(int?i?=?0;?i? ????????????if?(!commands[i].equalsIgnoreCase(“FE“)){
????????????????list.add(commands[i]);
????????????}
????????}
????????//解析報文格式
????????String[]?newCommands=list.toArray(new?String[list.size()]);
????????/*for?(int?i?=?0;?i?????????????//System.out.println(Integer.parseInt(newCommands[newCommands.length-1]));
????????????System.out.print(newCommands[i]+“?“);
????????}*/
????????if?(newCommands.length<16||newCommands.length>22||Integer.parseInt(newCommands[0])!=68||Integer.parseInt(newCommands[newCommands.length-1])!=16){
????????????System.err.print(“非法幀,無法解析!“);
????????????return;
????????}else?{
????????????System.out.println(“您的輸入:“?+?command);
????????????System.out.println(“原始地址:“?+?list);
????????????System.out.println(“幀起始符:“?+?newCommands[0]);
????????????System.out.println(“電表地址:“?+?Byte.parseByte(newCommands[6])?+?Byte.parseByte(newCommands[5])?+?Byte.parseByte(newCommands[4])?+?Byte.parseByte(newCommands[3])?+?Byte.parseByte(newCommands[2])?+?Byte.parseByte(newCommands[1]));
????????????System.out.println(“控制域:“?+?newCommands[8]);
????????????System.out.println(“數據域長度:“?+?newCommands[9]);
????????????System.out.println(“校驗碼:“?+?newCommands[newCommands.length?-?2]);
????????????System.out.println(“停止位:“?+?newCommands[newCommands.length?-?1]);
????????????//int?DTID=newCommands[newCommands.length?-?2?-?newCommands[9]];
????????????//解析數據標識
????????????List?list2?=?new?ArrayList();
????????????for?(int?i?=?0;?i?4;?i++)?{
????????????????list2.add(Integer.toHexString(Integer.parseInt(newCommands[newCommands.length?-?3?-?i-(Integer.parseInt(newCommands[9]16)-4)]?16)?-?51));
????????????}
????????????String[]?DTID?=?list2.toArray(new?String[list2.size()]);
????????????StringBuffer?sbr?=?new?StringBuffer();
????????????for?(int?i?=?0;?i?????????????????if?(DTID[i].length()?==?1)?{
????????????????????DTID[i]?=?String.format(“%02d“?Integer.parseInt(DTID[i]));
????????????????}else?if?(DTID[i].length()?==?8){
????????????????????DTID[i]?=?“FF“;
????????????????}
????????????????sbr.append(DTID[i]);
????????????}
????????????//InputStream?is=this.getClass().getClassLoader().getResourceAsStream(“resource/config.properties“);
????????????//加載文件,取值
????????????InputStream?is?=?new?BufferedInputStream(new?FileInputStream(“src/config.properties“));
????????????InputStreamReader?isr?=?new?InputStreamReader(is?“GBK“);
????????????Properties?properties?=?new?Properties();
????????????try?{
??????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????28??2017-05-09?17:43??Agreement_wu\.git\COMMIT_EDITMSG
?????文件????????312??2017-05-09?17:42??Agreement_wu\.git\config
?????文件?????????73??2017-05-05?09:36??Agreement_wu\.git\desc
?????文件????????121??2017-05-09?17:43??Agreement_wu\.git\FETCH_HEAD
?????文件?????????23??2017-05-05?09:36??Agreement_wu\.git\HEAD
?????文件????????478??2017-05-05?09:36??Agreement_wu\.git\hooks\applypatch-msg.sample
?????文件????????896??2017-05-05?09:36??Agreement_wu\.git\hooks\commit-msg.sample
?????文件????????189??2017-05-05?09:36??Agreement_wu\.git\hooks\post-update.sample
?????文件????????424??2017-05-05?09:36??Agreement_wu\.git\hooks\pre-applypatch.sample
?????文件???????1642??2017-05-05?09:36??Agreement_wu\.git\hooks\pre-commit.sample
?????文件???????1348??2017-05-05?09:36??Agreement_wu\.git\hooks\pre-push.sample
?????文件???????4951??2017-05-05?09:36??Agreement_wu\.git\hooks\pre-reba
?????文件????????544??2017-05-05?09:36??Agreement_wu\.git\hooks\pre-receive.sample
?????文件???????1239??2017-05-05?09:36??Agreement_wu\.git\hooks\prepare-commit-msg.sample
?????文件???????3610??2017-05-05?09:36??Agreement_wu\.git\hooks\update.sample
?????文件????????437??2017-05-09?17:43??Agreement_wu\.git\index
?????文件????????240??2017-05-05?09:36??Agreement_wu\.git\info\exclude
?????文件????????323??2017-05-09?17:43??Agreement_wu\.git\logs\HEAD
?????文件????????323??2017-05-09?17:43??Agreement_wu\.git\logs\refs\heads\master
?????文件????????433??2017-05-09?17:44??Agreement_wu\.git\logs\refs\remotes\origin\master
?????文件???????2599??2017-05-05?09:37??Agreement_wu\.git\ob
?????文件????????972??2017-05-05?09:37??Agreement_wu\.git\ob
?????文件????????164??2017-05-09?17:43??Agreement_wu\.git\ob
?????文件????????128??2017-05-05?09:39??Agreement_wu\.git\ob
?????文件????????196??2017-05-09?17:43??Agreement_wu\.git\ob
?????文件?????????82??2017-05-05?09:39??Agreement_wu\.git\ob
?????文件???????1688??2017-05-05?09:37??Agreement_wu\.git\ob
?????文件?????????54??2017-05-05?09:39??Agreement_wu\.git\ob
?????文件????????126??2017-05-05?09:38??Agreement_wu\.git\ob
?????文件????????510??2017-05-05?09:37??Agreement_wu\.git\ob
............此處省略71個文件信息
- 上一篇:二手房數據庫:JAVA+SQL Server
- 下一篇:基于Java的飯店點餐系統
評論
共有 條評論