|
|
@@ -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); |
|
|
|
|
|
|
|