| | |
| | | |
| | | import com.mes.tools.HexConversion; |
| | | import com.mes.utils.HexUtil; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.DataInputStream; |
| | | import java.io.DataOutputStream; |
| | | import java.io.IOException; |
| | | import java.net.Socket; |
| | | import java.net.UnknownHostException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.Map; |
| | | |
| | | import static com.mes.tools.HexConversion.*; |
| | | import static com.mes.tools.HexConversion.intToBytesDesc; |
| | | |
| | | @Component |
| | | @Slf4j |
| | |
| | | public void connect(){ |
| | | try { |
| | | this.socket=new Socket(Ip,Port); |
| | | this.socket.setSoTimeout(1000); |
| | | this.socket.setSoTimeout(300); |
| | | }catch (Exception e) { |
| | | log.info("The IP address of the host cannot be determined:{}",e.getMessage()); |
| | | } |
| | |
| | | bit[0]=Byte.parseByte(fontBitString[plcParameter.getAddressLength()]); |
| | | plcParameter.setReadByte(bit); |
| | | }else{ |
| | | plcParameter.setReadByte(Arrays.copyOfRange(content,plcParameter.getAddressStart(),(plcParameter.getAddressStart()+plcParameter.getAddressLength()))); |
| | | String plcAddressBegin = plcAgreement.plcAddressBegin; |
| | | Integer addressIndex = plcParameter.getAddressStart(); |
| | | int address = addressIndex -HexUtil.hexToInt(plcAddressBegin)*2; |
| | | plcParameter.setReadByte(Arrays.copyOfRange(content,address,(address+plcParameter.getAddressLength()))); |
| | | } |
| | | } |
| | | return true; |