1.光源增加tcp控制

2.重置球机方向增加延时扩展
chengdu-mxbc-qsl
LAPTOP-S9HJSOEB\昊天 2 years ago
parent df86ccb7ef
commit 73cf35e733

@ -65,6 +65,7 @@ public class ConfigProperties {
private Long delayDownloadMp4; private Long delayDownloadMp4;
public Long verticalAdjustmentTime = 2L;
} }
@Data @Data

@ -103,6 +103,8 @@ public class StreetController {
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1); 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); log.info("ip:{},status:{}",lightSource.getIp(),status);
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0); 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(); equip.DisConnect();
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),1); 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(); equip.DisConnect();
}else if(configProperties.getLightSource().getType() == 2){ }else if(configProperties.getLightSource().getType() == 2){
HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0); HikControlSocket.openLight(lightSource.getIp(),lightSource.getPort(),configProperties.getLightSource().getIndex(),0);
}else if (configProperties.getLightSource().getType() == 3){
LightSourceService.lightController(lightSource.getIp(),lightSource.getPort(),0);
} }
}); });

@ -6,6 +6,12 @@ import com.zhehekeji.web.mapper.LightSourceMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; 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.HashMap;
import java.util.List; import java.util.List;
@ -22,4 +28,52 @@ public class LightSourceService {
public List<LightSource> getLightSourceByStreetId(Integer streetId){ public List<LightSource> getLightSourceByStreetId(Integer streetId){
return lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",streetId)); return lightSourceMapper.selectList(new QueryWrapper<LightSource>().eq("street_id",streetId));
} }
/**
*
* @param ip
* @param port
* @param stat 12
*/
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();
}
}
}
} }

@ -157,6 +157,11 @@ public class PlcService {
public void verticalAdjustmentByStreet(String SRMNumber){ public void verticalAdjustmentByStreet(String SRMNumber){
Street street = streetService.getStreetByPlcId(SRMNumber); Street street = streetService.getStreetByPlcId(SRMNumber);
try {
Thread.sleep(configProperties.getCameraConfig().getVerticalAdjustmentTime()*1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if(street.getCamera1Id()!=null){ if(street.getCamera1Id()!=null){
//重置垂直方向球机 //重置垂直方向球机
verticalAdjustment(street.getCamera1Id()); verticalAdjustment(street.getCamera1Id());

Loading…
Cancel
Save