diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-17 16:28:36 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-07-17 16:28:36 +1200 |
commit | 3f6f92cedd969e741e65bb6e14737b98722b214e (patch) | |
tree | 97b19d441bb9f79c73db493d6ad52b2e422ec1ba /src/org/traccar/BaseProtocol.java | |
parent | b6ba5a8ac60e8013e22ed44b15ffdc5ad8097060 (diff) | |
download | trackermap-server-3f6f92cedd969e741e65bb6e14737b98722b214e.tar.gz trackermap-server-3f6f92cedd969e741e65bb6e14737b98722b214e.tar.bz2 trackermap-server-3f6f92cedd969e741e65bb6e14737b98722b214e.zip |
Start re-factoring commands
Diffstat (limited to 'src/org/traccar/BaseProtocol.java')
-rw-r--r-- | src/org/traccar/BaseProtocol.java | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java index 86bebacc7..932c0d9cc 100644 --- a/src/org/traccar/BaseProtocol.java +++ b/src/org/traccar/BaseProtocol.java @@ -15,31 +15,31 @@ */ package org.traccar; +import org.traccar.model.Command; import org.traccar.database.ActiveDevice; -import org.traccar.command.CommandType; -import org.traccar.command.CommandTemplate; -import org.traccar.command.GpsCommand; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public abstract class BaseProtocol implements Protocol { private final String name; - private Map<CommandType, CommandTemplate> commandTemplates = new HashMap<>(); + private final Set<String> supportedCommands = new HashSet<>(); public BaseProtocol(String name) { this.name = name; - this.initCommandsTemplates(commandTemplates); } public String getName() { return name; } + public void setSupportedCommands(String[] commands) { + supportedCommands.addAll(Arrays.asList(commands)); + } + @Override - public void sendCommand(ActiveDevice activeDevice, GpsCommand command) { - CommandTemplate commandMessage = commandTemplates.get(command.getType()); + public void sendCommand(ActiveDevice activeDevice, Command command) { + /*CommandTemplate commandMessage = commandTemplates.get(command.getType()); if (commandMessage == null) { throw new RuntimeException("The command " + command + " is not yet supported in protocol " + this.getName()); @@ -47,10 +47,7 @@ public abstract class BaseProtocol implements Protocol { Object response = commandMessage.applyTo(activeDevice, command); - activeDevice.write(response); - } - - protected void initCommandsTemplates(Map<CommandType, CommandTemplate> templates) { + activeDevice.write(response);*/ } } |