| 
					
				 | 
			
			
				@@ -14,53 +14,114 @@ import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @Service 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 public class CctvControlProbeService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Map<String, String> startCmd = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Map<String, String> stopCmd = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    Map<String, String> presetCmd = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Map<String, ProbeCommand> startCmd = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Map<String, ProbeCommand> stopCmd = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    Map<String, ProbeCommand> presetCmd = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostConstruct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     void init() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("tilt-up",   "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=4&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("tilt-down", "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=5&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("pan-left",  "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=2&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("pan-right", "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=3&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("zoom-in",   "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=13&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("zoom-out",  "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=14&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("focus-in",  "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=15&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.startCmd.put("focus-out", "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=16&PTZCTRL.speed="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("tilt-up",   new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=4&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x30, (byte)0x34 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("tilt-down", new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=5&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x30, (byte)0x35 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("pan-left",  new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=2&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x30, (byte)0x32 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("pan-right", new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=3&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x30, (byte)0x33 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("zoom-in",   new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=13&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x33 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("zoom-out",  new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=14&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x34 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("focus-in",  new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=15&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x35 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.startCmd.put("focus-out", new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=16&PTZCTRL.speed=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x36 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("tilt-up",   "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("tilt-down", "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("pan-left",  "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("pan-right", "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("zoom-in",   "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("zoom-out",  "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("focus-in",  "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.stopCmd.put("focus-out", "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("tilt-up",   new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("tilt-down", new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("pan-left",  new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("pan-right", new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("zoom-in",   new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("zoom-out",  new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("focus-in",  new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.stopCmd.put("focus-out", new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=0", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x32, (byte)0x30, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.presetCmd.put("call",    "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=11&PTZCTRL.no="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.presetCmd.put("save",    "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=10&PTZCTRL.no="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.presetCmd.put("delete",  "/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=12&PTZCTRL.no="); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.presetCmd.put("call",    new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=11&PTZCTRL.no=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x31 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.presetCmd.put("save",    new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=10&PTZCTRL.no=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.presetCmd.put("delete",  new ProbeCommand("/cgi-bin/control.cgi?action=update&group=PTZCTRL&channel=0&PTZCTRL.action=12&PTZCTRL.no=", 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new byte[]{ (byte)0x38, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30, (byte)0x31, (byte)0x30 })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String getPtzCmd(String control, String action, int speed) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (StringUtils.equalsIgnoreCase("start", action)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String command = this.startCmd.get(control); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ProbeCommand command = this.startCmd.get(control); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (command != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return command + speed; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return command.getUri() + speed; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else if (StringUtils.equalsIgnoreCase("stop", action)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return this.stopCmd.get(control); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ProbeCommand command = this.stopCmd.get(control); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (command != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return command.getUri(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public byte[] getPtzControlCmd(String control, String action, int speed) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtils.equalsIgnoreCase("start", action)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ProbeCommand command = this.startCmd.get(control); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (command != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return command.getCmd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else if (StringUtils.equalsIgnoreCase("stop", action)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ProbeCommand command = this.stopCmd.get(control); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (command != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return command.getCmd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public String getPresetCmd(String action, Integer psetNmbr) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String command = this.presetCmd.get(action); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ProbeCommand command = this.presetCmd.get(action); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (command != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return command + psetNmbr; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return command.getUri() + psetNmbr; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public byte[] getPresetControlCmd(String action, Integer psetNmbr) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ProbeCommand command = this.presetCmd.get(action); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (command != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return command.getCmd(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static class ProbeCommand { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private String uri; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private byte[] cmd; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public ProbeCommand(String uri, byte[] cmd) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.uri = uri; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (cmd != null && cmd.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                this.cmd = new byte[cmd.length]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                System.arraycopy(cmd, 0, this.cmd, 0, cmd.length); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public String getUri() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return this.uri; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public byte[] getCmd() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return this.cmd; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |