diff --git a/web/src/main/java/com/zhehekeji/web/config/ConfigProperties.java b/web/src/main/java/com/zhehekeji/web/config/ConfigProperties.java index 8e870af..003dd9b 100644 --- a/web/src/main/java/com/zhehekeji/web/config/ConfigProperties.java +++ b/web/src/main/java/com/zhehekeji/web/config/ConfigProperties.java @@ -65,6 +65,7 @@ public class ConfigProperties { private Long delayDownloadMp4; + public Long verticalAdjustmentTime = 2L; } @Data diff --git a/web/src/main/java/com/zhehekeji/web/controller/StreetController.java b/web/src/main/java/com/zhehekeji/web/controller/StreetController.java index 2e39603..93164fd 100644 --- a/web/src/main/java/com/zhehekeji/web/controller/StreetController.java +++ b/web/src/main/java/com/zhehekeji/web/controller/StreetController.java @@ -103,6 +103,8 @@ public class StreetController { }else if(configProperties.getLightSource().getType() == 2){ HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1); + }else if (configProperties.getLightSource().getType() == 3){ + LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),1); } }); @@ -126,6 +128,8 @@ public class StreetController { log.info("ip:{},status:{}",lightSource.getIp(),status); }else if(configProperties.getLightSource().getType() == 2){ HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0); + }else if (configProperties.getLightSource().getType() == 3){ + LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),0); } }); @@ -146,6 +150,8 @@ public class StreetController { equip.DisConnect(); }else if(configProperties.getLightSource().getType() == 2){ HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1); + }else if (configProperties.getLightSource().getType() == 3){ + LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),1); } }); @@ -166,6 +172,8 @@ public class StreetController { equip.DisConnect(); }else if(configProperties.getLightSource().getType() == 2){ HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0); + }else if (configProperties.getLightSource().getType() == 3){ + LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),0); } }); diff --git a/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java b/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java index 3f60d19..0da209e 100644 --- a/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java +++ b/web/src/main/java/com/zhehekeji/web/service/LightSourceService.java @@ -6,6 +6,12 @@ import com.zhehekeji.web.mapper.LightSourceMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; @@ -22,4 +28,52 @@ public class LightSourceService { public List getLightSourceByStreetId(Integer streetId){ return lightSourceMapper.selectList(new QueryWrapper().eq("street_id",streetId)); } + + /** + * + * @param ip + * @param port + * @param stat 1开启,2关闭 + */ + public static void lightController(String ip ,Integer port,Integer stat){ + Socket socket = new Socket(); + OutputStream os = null; + InputStream is = null; + try { + socket.connect(new InetSocketAddress(ip,port),3000); + os = socket.getOutputStream(); + is = socket.getInputStream(); + int i = 0; + socket.setSoTimeout(1000); + String startCmd = "<1,"+stat+",post>"; + byte[]bytes = startCmd.getBytes(StandardCharsets.UTF_8); + os.write(bytes); + + + } catch (IOException e) { + + }finally { + if(os != null){ + try { + os.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if(is != null){ + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + try { + socket.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + + } } diff --git a/web/src/main/java/com/zhehekeji/web/service/PlcService.java b/web/src/main/java/com/zhehekeji/web/service/PlcService.java index 13feda9..8f43b06 100644 --- a/web/src/main/java/com/zhehekeji/web/service/PlcService.java +++ b/web/src/main/java/com/zhehekeji/web/service/PlcService.java @@ -157,6 +157,11 @@ public class PlcService { public void verticalAdjustmentByStreet(String SRMNumber){ Street street = streetService.getStreetByPlcId(SRMNumber); + try { + Thread.sleep(configProperties.getCameraConfig().getVerticalAdjustmentTime()*1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } if(street.getCamera1Id()!=null){ //重置垂直方向球机 verticalAdjustment(street.getCamera1Id());