From fe50b376ee5bee1a738aef3baca97e56f75633a4 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 20 Apr 2022 16:58:46 -0700 Subject: Clean up alarm commands --- src/main/java/org/traccar/model/Command.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/main/java/org/traccar/model/Command.java') diff --git a/src/main/java/org/traccar/model/Command.java b/src/main/java/org/traccar/model/Command.java index 03961c7b2..49486bdbc 100644 --- a/src/main/java/org/traccar/model/Command.java +++ b/src/main/java/org/traccar/model/Command.java @@ -58,11 +58,10 @@ public class Command extends Message implements Cloneable { public static final String TYPE_GET_MODEM_STATUS = "getModemStatus"; public static final String TYPE_GET_DEVICE_STATUS = "getDeviceStatus"; public static final String TYPE_SET_SPEED_LIMIT = "setSpeedLimit"; - public static final String TYPE_MODE_POWER_SAVING = "modePowerSaving"; public static final String TYPE_MODE_DEEP_SLEEP = "modeDeepSleep"; - public static final String TYPE_ALARM_GEOFENCE = "movementAlarm"; + public static final String TYPE_ALARM_GEOFENCE = "alarmGeofence"; public static final String TYPE_ALARM_BATTERY = "alarmBattery"; public static final String TYPE_ALARM_SOS = "alarmSos"; public static final String TYPE_ALARM_REMOVE = "alarmRemove"; -- cgit v1.2.3 From 257ee673e08d2d4080d156079ce7b62752f1476d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 28 Sep 2022 07:13:11 -0700 Subject: Queued command model --- src/main/java/org/traccar/model/BaseCommand.java | 40 +++++++++++++++++++ src/main/java/org/traccar/model/Command.java | 29 +------------- src/main/java/org/traccar/model/QueuedCommand.java | 45 ++++++++++++++++++++++ 3 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 src/main/java/org/traccar/model/BaseCommand.java create mode 100644 src/main/java/org/traccar/model/QueuedCommand.java (limited to 'src/main/java/org/traccar/model/Command.java') diff --git a/src/main/java/org/traccar/model/BaseCommand.java b/src/main/java/org/traccar/model/BaseCommand.java new file mode 100644 index 000000000..16df9c126 --- /dev/null +++ b/src/main/java/org/traccar/model/BaseCommand.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.model; + +public class BaseCommand extends Message { + + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + private boolean textChannel; + + public boolean getTextChannel() { + return textChannel; + } + + public void setTextChannel(boolean textChannel) { + this.textChannel = textChannel; + } + +} diff --git a/src/main/java/org/traccar/model/Command.java b/src/main/java/org/traccar/model/Command.java index 49486bdbc..4ea619e95 100644 --- a/src/main/java/org/traccar/model/Command.java +++ b/src/main/java/org/traccar/model/Command.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2022 Anton Tananaev (anton@traccar.org) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.traccar.storage.StorageName; @StorageName("tc_commands") @JsonIgnoreProperties(ignoreUnknown = true) -public class Command extends Message implements Cloneable { +public class Command extends BaseCommand { public static final String TYPE_CUSTOM = "custom"; public static final String TYPE_IDENTIFICATION = "deviceIdentification"; @@ -84,21 +84,6 @@ public class Command extends Message implements Cloneable { public static final String KEY_SERVER = "server"; public static final String KEY_PORT = "port"; - @Override - public Command clone() throws CloneNotSupportedException { - return (Command) super.clone(); - } - - private boolean textChannel; - - public boolean getTextChannel() { - return textChannel; - } - - public void setTextChannel(boolean textChannel) { - this.textChannel = textChannel; - } - @QueryIgnore @Override public long getDeviceId() { @@ -111,14 +96,4 @@ public class Command extends Message implements Cloneable { super.setDeviceId(deviceId); } - private String description; - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - } diff --git a/src/main/java/org/traccar/model/QueuedCommand.java b/src/main/java/org/traccar/model/QueuedCommand.java new file mode 100644 index 000000000..fff77a22b --- /dev/null +++ b/src/main/java/org/traccar/model/QueuedCommand.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.model; + +import org.traccar.storage.StorageName; + +import java.util.HashMap; + +@StorageName("tc_commands_queue") +public class QueuedCommand extends BaseCommand { + + public static QueuedCommand fromCommand(Command command) { + QueuedCommand queuedCommand = new QueuedCommand(); + queuedCommand.setDeviceId(command.getDeviceId()); + queuedCommand.setType(command.getType()); + queuedCommand.setDescription(command.getDescription()); + queuedCommand.setTextChannel(command.getTextChannel()); + queuedCommand.setAttributes(new HashMap<>(command.getAttributes())); + return queuedCommand; + } + + public Command toCommand() { + Command command = new Command(); + command.setDeviceId(getDeviceId()); + command.setType(getType()); + command.setDescription(getDescription()); + command.setTextChannel(getTextChannel()); + command.setAttributes(new HashMap<>(getAttributes())); + return command; + } + +} -- cgit v1.2.3 From 8f537de3bbf4dc1a742222dfd3123090b79e6419 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 19 Oct 2022 09:24:25 -0700 Subject: Fix command queue issue --- schema/changelog-5.5.xml | 15 +++++++++++++++ schema/changelog-master.xml | 1 + src/main/java/org/traccar/model/BaseCommand.java | 10 ---------- src/main/java/org/traccar/model/Command.java | 10 ++++++++++ src/main/java/org/traccar/model/QueuedCommand.java | 5 +++-- 5 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 schema/changelog-5.5.xml (limited to 'src/main/java/org/traccar/model/Command.java') diff --git a/schema/changelog-5.5.xml b/schema/changelog-5.5.xml new file mode 100644 index 000000000..4f5b210c5 --- /dev/null +++ b/schema/changelog-5.5.xml @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/schema/changelog-master.xml b/schema/changelog-master.xml index e877c1afd..cc39c5c41 100644 --- a/schema/changelog-master.xml +++ b/schema/changelog-master.xml @@ -35,5 +35,6 @@ + diff --git a/src/main/java/org/traccar/model/BaseCommand.java b/src/main/java/org/traccar/model/BaseCommand.java index 16df9c126..f87b8ef65 100644 --- a/src/main/java/org/traccar/model/BaseCommand.java +++ b/src/main/java/org/traccar/model/BaseCommand.java @@ -17,16 +17,6 @@ package org.traccar.model; public class BaseCommand extends Message { - private String description; - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - private boolean textChannel; public boolean getTextChannel() { diff --git a/src/main/java/org/traccar/model/Command.java b/src/main/java/org/traccar/model/Command.java index 4ea619e95..99988dd82 100644 --- a/src/main/java/org/traccar/model/Command.java +++ b/src/main/java/org/traccar/model/Command.java @@ -96,4 +96,14 @@ public class Command extends BaseCommand { super.setDeviceId(deviceId); } + private String description; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + } diff --git a/src/main/java/org/traccar/model/QueuedCommand.java b/src/main/java/org/traccar/model/QueuedCommand.java index fff77a22b..96a1eca4b 100644 --- a/src/main/java/org/traccar/model/QueuedCommand.java +++ b/src/main/java/org/traccar/model/QueuedCommand.java @@ -15,18 +15,19 @@ */ package org.traccar.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import org.traccar.storage.StorageName; import java.util.HashMap; @StorageName("tc_commands_queue") +@JsonIgnoreProperties(ignoreUnknown = true) public class QueuedCommand extends BaseCommand { public static QueuedCommand fromCommand(Command command) { QueuedCommand queuedCommand = new QueuedCommand(); queuedCommand.setDeviceId(command.getDeviceId()); queuedCommand.setType(command.getType()); - queuedCommand.setDescription(command.getDescription()); queuedCommand.setTextChannel(command.getTextChannel()); queuedCommand.setAttributes(new HashMap<>(command.getAttributes())); return queuedCommand; @@ -36,7 +37,7 @@ public class QueuedCommand extends BaseCommand { Command command = new Command(); command.setDeviceId(getDeviceId()); command.setType(getType()); - command.setDescription(getDescription()); + command.setDescription(""); command.setTextChannel(getTextChannel()); command.setAttributes(new HashMap<>(getAttributes())); return command; -- cgit v1.2.3