Bladeren bron

ALL改为all

tags/v1.0.0^2
林万龙 3 jaren geleden
bovenliggende
commit
0c5ca5e6f0
2 gewijzigde bestanden met toevoegingen van 38 en 40 verwijderingen
  1. +16
    -28
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java
  2. +22
    -12
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java

+ 16
- 28
src/main/java/com/telpo/dipperposition/service/impl/DipperAstPosAsyncTaskServiceImpl.java Bestand weergeven

@@ -209,38 +209,26 @@ public class DipperAstPosAsyncTaskServiceImpl implements IDipperAstPosAsyncTaskS
// A0 86 01 00 表示注入的位置精度为 1000 米 0186a0
// 00 2F 为校验和

// astTimeCmd 组装
String astTimeCmd = "23 3E 04 01 ";
astTimeCmd += "10 00 ";
byte[] lanBytes = HexConvert.hexStringToBytes(HexConvert.encodeHEX(lanLongValue).toUpperCase());

byte[] altBytes = HexConvert.hexStringToBytes(HexConvert.encodeHEX(altLongValue).toUpperCase());

StringBuffer lanBuf = new StringBuffer();
for(int i=0; i<lanBytes.length; i++) {
String s = Integer.toHexString(lanBytes[i] & 0xff);
// astPosCmd 组装
String astPosCmd = "233E0401";
astPosCmd += "1000";
astPosCmd += HexConvert.hexStringToBytes(HexConvert.encodeHEX(lanLongValue).toUpperCase());
astPosCmd += HexConvert.hexStringToBytes(HexConvert.encodeHEX(altLongValue).toUpperCase());
astPosCmd += "70170000";
astPosCmd += "A0860100";

byte[] astPosCmdBytes = HexConvert.hexStringToBytes(astPosCmd);
StringBuffer astPosCmdBuf = new StringBuffer();
for(int i=0; i<astPosCmdBytes.length; i++) {
String s = Integer.toHexString(astPosCmdBytes[i] & 0xff);
if (s.length() < 2) {
lanBuf.append('0');
astPosCmdBuf.append('0');
}
lanBuf.append(s + " ");
astPosCmdBuf.append(s + " ");
}

StringBuffer altBuf = new StringBuffer();
for(int i=0; i<altBytes.length; i++) {
String s = Integer.toHexString(altBytes[i] & 0xff);
if (s.length() < 2) {
altBuf.append('0');
}
altBuf.append(s + " ");
}

astTimeCmd += lanBuf;
astTimeCmd += altBuf;
astTimeCmd += "70 17 00 00 ";
astTimeCmd += "A0 86 01 00 ";

String checkSum = HexConvert.makeChecksum(astTimeCmd).toUpperCase();
return astTimeCmd + checkSum.substring(0,1) + " " + checkSum.substring(2,3);
String checkSum = HexConvert.makeChecksum(astPosCmd).toUpperCase();
return astPosCmdBuf.toString() + checkSum.substring(0,1) + " " + checkSum.substring(2,3);

}
}

+ 22
- 12
src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java Bestand weergeven

@@ -43,25 +43,25 @@ public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTas
// 00 5E D0 B2 表示 3 秒的时间精度(十六进制 B2 D0 5E 00 转为十进制为3000000000,乘以比 例因子 10-9就是 3 秒 小端模式00 5E D0 B2)
// 00 2F 为校验和
// TODO astTimeCmd 组装
String astTimeCmd = "23 3E 04 02 ";
astTimeCmd += "10 00 ";
astTimeCmd += "20 E1 ";
String astTimeCmd = "233E0402";
astTimeCmd += "1000";
astTimeCmd += "20E1";
LocalDateTime now = LocalDateTime.now();
int year = now.getYear();
int month = now.getMonthValue();
int day = now.getDayOfMonth();
String hexYearString = Integer.toHexString(year);
hexYearString = "0" + hexYearString;
astTimeCmd += hexYearString.substring(2,3).toUpperCase() + " " + hexYearString.substring(0,1).toUpperCase() + " ";
astTimeCmd += hexYearString.substring(2,3).toUpperCase() + hexYearString.substring(0,1).toUpperCase();
String hexMonthString = Integer.toHexString(month);
hexMonthString = "0" + hexMonthString;
astTimeCmd += hexMonthString.toUpperCase() + " ";
astTimeCmd += hexMonthString.toUpperCase();

String hexDayString = Integer.toHexString(day);
if (day < 16) {
hexDayString = "0" + hexDayString;
}
astTimeCmd += hexDayString.toUpperCase() + " ";
astTimeCmd += hexDayString.toUpperCase();

int hour = now.getHour();
int minitor = now.getMinute();
@@ -70,22 +70,32 @@ public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTas
if (hour < 16) {
hexHourString = "0" + hexHourString;
}
astTimeCmd += hexHourString.toUpperCase() + " ";
astTimeCmd += hexHourString.toUpperCase();
String hexMinitorString = Integer.toHexString(minitor);
if (minitor < 16) {
hexMinitorString = "0" + hexMinitorString;
}
astTimeCmd += hexMinitorString.toUpperCase() + " ";
astTimeCmd += hexMinitorString.toUpperCase();
String hexSecondString = Integer.toHexString(second);
if (second < 16) {
hexSecondString = "0" + hexSecondString;
}
astTimeCmd += hexSecondString.toUpperCase() + " ";
astTimeCmd += "00 00 00 00 00 ";
astTimeCmd += "00 5E D0 B2 ";
astTimeCmd += hexSecondString.toUpperCase();
astTimeCmd += "0000000000";
astTimeCmd += "005ED0B2";

byte[] astTimeCmdBytes = HexConvert.hexStringToBytes(astTimeCmd);
StringBuffer astTimeCmdBuf = new StringBuffer();
for(int i=0; i<astTimeCmdBytes.length; i++) {
String s = Integer.toHexString(astTimeCmdBytes[i] & 0xff);
if (s.length() < 2) {
astTimeCmdBuf.append('0');
}
astTimeCmdBuf.append(s + " ");
}

String checkSum = HexConvert.makeChecksum(astTimeCmd).toUpperCase();
return astTimeCmd + checkSum.substring(0,1) + " " + checkSum.substring(2,3);
return astTimeCmdBuf.toString() + checkSum.substring(0,1) + " " + checkSum.substring(2,3);
//String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd);
//log.info("DipperAstTimeAsyncTaskServiceImpl 返回时间:" + hexIn);



Laden…
Annuleren
Opslaan