|
|
@@ -43,24 +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 = "233E0402"; |
|
|
|
astTimeCmd += "1000"; |
|
|
|
astTimeCmd += "20E1"; |
|
|
|
String astTimeCmd = "23 3E 04 02 "; |
|
|
|
astTimeCmd += "10 00 "; |
|
|
|
astTimeCmd += "20 E1 "; |
|
|
|
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,2) + hexYearString.substring(0,2); |
|
|
|
astTimeCmd += hexYearString.substring(2,3).toUpperCase() + " " + hexYearString.substring(0,1).toUpperCase() + " "; |
|
|
|
String hexMonthString = Integer.toHexString(month); |
|
|
|
hexMonthString = "0" + hexMonthString; |
|
|
|
astTimeCmd += hexMonthString; |
|
|
|
astTimeCmd += hexMonthString.toUpperCase() + " "; |
|
|
|
|
|
|
|
String hexDayString = Integer.toHexString(day); |
|
|
|
if (day < 16) { |
|
|
|
hexDayString = "0" + hexDayString; |
|
|
|
} |
|
|
|
astTimeCmd += hexDayString; |
|
|
|
astTimeCmd += hexDayString.toUpperCase() + " "; |
|
|
|
|
|
|
|
int hour = now.getHour(); |
|
|
|
int minitor = now.getMinute(); |
|
|
@@ -69,23 +70,24 @@ public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTas |
|
|
|
if (hour < 16) { |
|
|
|
hexHourString = "0" + hexHourString; |
|
|
|
} |
|
|
|
astTimeCmd += hexHourString; |
|
|
|
astTimeCmd += hexHourString.toUpperCase() + " "; |
|
|
|
String hexMinitorString = Integer.toHexString(minitor); |
|
|
|
if (minitor < 16) { |
|
|
|
hexMinitorString = "0" + hexMinitorString; |
|
|
|
} |
|
|
|
astTimeCmd += hexMinitorString; |
|
|
|
astTimeCmd += hexMinitorString.toUpperCase() + " "; |
|
|
|
String hexSecondString = Integer.toHexString(second); |
|
|
|
if (second < 16) { |
|
|
|
hexSecondString = "0" + hexSecondString; |
|
|
|
} |
|
|
|
astTimeCmd += hexSecondString; |
|
|
|
astTimeCmd += "0000000000"; |
|
|
|
astTimeCmd += "005ED0B2"; |
|
|
|
astTimeCmd += hexSecondString.toUpperCase() + " "; |
|
|
|
astTimeCmd += "00 00 00 00 00 "; |
|
|
|
astTimeCmd += "00 5E D0 B2 "; |
|
|
|
|
|
|
|
String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd); |
|
|
|
log.info("DipperAstTimeAsyncTaskServiceImpl 返回时间:" + hexIn); |
|
|
|
String checkSum = HexConvert.makeChecksum(astTimeCmd).toUpperCase(); |
|
|
|
return astTimeCmd + checkSum.substring(0,1) + " " + checkSum.substring(2,3); |
|
|
|
//String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd); |
|
|
|
//log.info("DipperAstTimeAsyncTaskServiceImpl 返回时间:" + hexIn); |
|
|
|
|
|
|
|
return hexIn; |
|
|
|
} |
|
|
|
} |