| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.google.common.base.Utf8; |
| | | import com.sun.xml.internal.bind.v2.runtime.output.Encoded; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.Slave; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | |
| | | private short heartBeatVal = 1; |
| | | public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{ |
| | | add(101);add(102);add(103);add(104);add(105);add(106);add(107);add(108);add(109); |
| | | add(110);add(111);add(112);add(113);add(114);add(115);add(116);add(117);add(118);add(119); |
| | | add(120);add(121);add(122);add(123);add(124);add(125);add(126);add(127);add(128);add(129); |
| | | add(130);add(131);add(132);add(133);add(134);add(135);add(136); |
| | | // add(201);add(202);add(203);add(204); |
| | | // add(301);add(302);add(303);add(304);add(305);add(306); |
| | | }}; |
| | | |
| | | /** |
| | | * 条码数量 |
| | | */ |
| | | private int barcodeSize = 1; |
| | | public IoModeType ioMode = IoModeType.NONE; |
| | | |
| | | public int startSignal1 = 0; |
| | | public int startSignal2 = 0; |
| | | public int startSignal3 = 0; |
| | | public int startSignal4 = 0; |
| | | |
| | | public SiemensDevpThread(DevpSlave slave) { |
| | | this.slave = slave; |
| | |
| | | // 写数据 ID+目标站 |
| | | case 2: |
| | | write((StaProtocol)task.getData()); |
| | | break; |
| | | //复位测试信号 |
| | | case 3: |
| | | siemensS7Net.Write("DB100." + (150 + (int)task.getData()), 0); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | // } |
| | | // } |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB150.0", (short) (staNoSize*2)); |
| | | OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.0", (short) (staNoSize*2)); |
| | | if (result1.IsSuccess) { |
| | | for (int i = 0; i < staNoSize; i++) { |
| | | Integer siteId = staNos.get(i); // 站点编号 |
| | |
| | | } |
| | | |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.190",(short)(barcodeSize*8)); |
| | | OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.190",(short)(barcodeSize*12)); |
| | | if (result2.IsSuccess) { |
| | | for (int i = 0; i < barcodeSize; i++) { |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8"); |
| | | String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*12,12, "UTF-8"); |
| | | // String barcode=new String(result2.Content,i*12,12); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1); |
| | | if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) { |
| | | barcodeThread.setBarcode(barcode); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | Thread.sleep(200); |
| | | OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.150", (short) 8); |
| | | if(result3.IsSuccess) { |
| | | startSignal1 = siemensS7Net.getByteTransform().TransInt16(result.Content, 0); |
| | | startSignal2 = siemensS7Net.getByteTransform().TransInt16(result.Content, 2); |
| | | startSignal3 = siemensS7Net.getByteTransform().TransInt16(result.Content, 4); |
| | | startSignal4 = siemensS7Net.getByteTransform().TransInt16(result.Content, 6); |
| | | } |
| | | // OperateResultExOne<Short> result2 = siemensS7Net.ReadInt16("DB200.0"); |
| | | // if (result2.IsSuccess) { |
| | | // this.ioMode = IoModeType.get(result2.Content); |