aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorGábor Somogyi <gabor.g.somogyi@gmail.com>2016-04-23 15:26:38 +0200
committerGábor Somogyi <gabor.g.somogyi@gmail.com>2016-04-23 15:26:38 +0200
commit45f1471fc612834128d4ce3751905060fda04042 (patch)
treed4963a866bcd6133ee33946d160bd48d3a504d94 /src/org/traccar
parent40620ab3f10c686499ae2b25c8019280b1c82c1f (diff)
downloadtrackermap-server-45f1471fc612834128d4ce3751905060fda04042.tar.gz
trackermap-server-45f1471fc612834128d4ce3751905060fda04042.tar.bz2
trackermap-server-45f1471fc612834128d4ce3751905060fda04042.zip
Throw away mockito
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/protocol/H02ProtocolEncoder.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/org/traccar/protocol/H02ProtocolEncoder.java b/src/org/traccar/protocol/H02ProtocolEncoder.java
index 302773eaa..0b41b9c93 100644
--- a/src/org/traccar/protocol/H02ProtocolEncoder.java
+++ b/src/org/traccar/protocol/H02ProtocolEncoder.java
@@ -23,20 +23,15 @@ import org.traccar.model.Command;
public class H02ProtocolEncoder extends StringProtocolEncoder {
- DateTime getActualDateTime() {
- return new DateTime(DateTimeZone.UTC);
- }
-
- private Object formatCommand(String uniqueId, String cmd, String... params) {
+ private Object formatCommand(DateTime dt, String uniqueId, String cmd, String... params) {
- DateTime now = getActualDateTime();
String result = String.format(
"*HQ,%s,%s,%02d%02d%02d",
uniqueId,
cmd,
- now.getHourOfDay(),
- now.getMinuteOfHour(),
- now.getSecondOfMinute()
+ dt.getHourOfDay(),
+ dt.getMinuteOfHour(),
+ dt.getSecondOfMinute()
);
for(String param : params) {
@@ -48,15 +43,14 @@ public class H02ProtocolEncoder extends StringProtocolEncoder {
return result;
}
- @Override
- protected Object encodeCommand(Command command) {
+ protected Object encodeCommand(Command command, DateTime dt) {
String uniqueId = getUniqueId(command.getDeviceId());
switch (command.getType()) {
case Command.TYPE_ALARM_ARM:
- return formatCommand(uniqueId, "SCF", "0", "0");
+ return formatCommand(dt, uniqueId, "SCF", "0", "0");
case Command.TYPE_ALARM_DISARM:
- return formatCommand(uniqueId, "SCF", "1", "1");
+ return formatCommand(dt, uniqueId, "SCF", "1", "1");
default:
Log.warning(new UnsupportedOperationException(command.getType()));
break;
@@ -64,4 +58,10 @@ public class H02ProtocolEncoder extends StringProtocolEncoder {
return null;
}
+
+ @Override
+ protected Object encodeCommand(Command command) {
+ DateTime dt = new DateTime(DateTimeZone.UTC);
+ return encodeCommand(command, dt);
+ }
}