aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/DeviceManager.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-09-12 17:42:16 +0500
committerAbyss777 <abyss@fox5.ru>2017-09-12 17:42:16 +0500
commit925806fe70e10e47bcc12eb8bcc4fe21a9ece220 (patch)
treea2972e4915f941699c6582b915c27189f28c63e4 /src/org/traccar/database/DeviceManager.java
parent195e7b5b45c08fa4fad4f9c8797f8807ded1dbea (diff)
downloadtrackermap-server-925806fe70e10e47bcc12eb8bcc4fe21a9ece220.tar.gz
trackermap-server-925806fe70e10e47bcc12eb8bcc4fe21a9ece220.tar.bz2
trackermap-server-925806fe70e10e47bcc12eb8bcc4fe21a9ece220.zip
Implement Saved Commands
Diffstat (limited to 'src/org/traccar/database/DeviceManager.java')
-rw-r--r--src/org/traccar/database/DeviceManager.java51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/org/traccar/database/DeviceManager.java b/src/org/traccar/database/DeviceManager.java
index 2157e738d..1eb90b7eb 100644
--- a/src/org/traccar/database/DeviceManager.java
+++ b/src/org/traccar/database/DeviceManager.java
@@ -16,7 +16,6 @@
package org.traccar.database;
import java.sql.SQLException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
@@ -26,12 +25,9 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
-import org.traccar.BaseProtocol;
import org.traccar.Config;
import org.traccar.Context;
import org.traccar.helper.Log;
-import org.traccar.model.Command;
-import org.traccar.model.CommandType;
import org.traccar.model.Device;
import org.traccar.model.DeviceState;
import org.traccar.model.DeviceTotalDistance;
@@ -55,8 +51,6 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
private final Map<Long, DeviceState> deviceStates = new ConcurrentHashMap<>();
- private boolean fallbackToText;
-
public DeviceManager(DataManager dataManager) {
super(dataManager, Device.class);
this.config = Context.getConfig();
@@ -68,7 +62,6 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
dataRefreshDelay = config.getLong("database.refreshDelay", DEFAULT_REFRESH_DELAY) * 1000;
lookupGroupsAttribute = config.getBoolean("deviceManager.lookupGroupsAttribute");
- fallbackToText = config.getBoolean("command.fallbackToSms");
refreshLastPositions();
}
@@ -344,50 +337,6 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
}
- public void sendCommand(Command command) throws Exception {
- long deviceId = command.getDeviceId();
- if (command.getTextChannel()) {
- Position lastPosition = getLastPosition(deviceId);
- if (lastPosition != null) {
- BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol());
- protocol.sendTextCommand(getById(deviceId).getPhone(), command);
- } else if (command.getType().equals(Command.TYPE_CUSTOM)) {
- Context.getSmppManager().sendMessageSync(getById(deviceId).getPhone(),
- command.getString(Command.KEY_DATA), true);
- } else {
- throw new RuntimeException("Command " + command.getType() + " is not supported");
- }
- } else {
- ActiveDevice activeDevice = Context.getConnectionManager().getActiveDevice(deviceId);
- if (activeDevice != null) {
- activeDevice.sendCommand(command);
- } else {
- if (fallbackToText) {
- command.setTextChannel(true);
- sendCommand(command);
- } else {
- throw new RuntimeException("Device is not online");
- }
- }
- }
- }
-
- public Collection<CommandType> getCommandTypes(long deviceId, boolean textChannel) {
- List<CommandType> result = new ArrayList<>();
- Position lastPosition = Context.getDeviceManager().getLastPosition(deviceId);
- if (lastPosition != null) {
- BaseProtocol protocol = Context.getServerManager().getProtocol(lastPosition.getProtocol());
- Collection<String> commands;
- commands = textChannel ? protocol.getSupportedTextCommands() : protocol.getSupportedDataCommands();
- for (String commandKey : commands) {
- result.add(new CommandType(commandKey));
- }
- } else {
- result.add(new CommandType(Command.TYPE_CUSTOM));
- }
- return result;
- }
-
public DeviceState getDeviceState(long deviceId) {
DeviceState deviceState = deviceStates.get(deviceId);
if (deviceState == null) {