1
zhang
2 天以前 818fdd469e2ed47c9e02e06fcb4c7dc791977a0b
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
@@ -164,7 +164,7 @@
        OperateResultExOne<byte[]> result = siemensS7Net.Read(
                DeviceField.BARCODE.buildAddress(),
                (short) ( DeviceField.BARCODE.getByteLength() * DeviceField.BARCODE.getArrLength()));
                (short) (DeviceField.BARCODE.getByteLength() * DeviceField.BARCODE.getArrLength()));
        if (!result.IsSuccess) {
            log.warn("读取条码失败 [id:{}]", slave.getId());
@@ -175,12 +175,12 @@
        for (int i = 0; i < DeviceField.BARCODE.getArrLength(); i++) {
            int[] seg = DeviceField.BARCODE.getSeg();
            Short staNo = siemensS7Net.getByteTransform().TransInt16(
                    content, seg[0]+i * DeviceField.BARCODE.getByteLength());
                    content, seg[0] + i * DeviceField.BARCODE.getByteLength());
            String barcode = siemensS7Net.getByteTransform().TransString(
                    content, seg[1]+i * DeviceField.BARCODE.getByteLength(),
                    DeviceField.BARCODE.getByteLength()-seg[1], "UTF-8");
                    content, seg[1] + i * DeviceField.BARCODE.getByteLength(),
                    DeviceField.BARCODE.getByteLength() - seg[1], "UTF-8");
            if (!Cools.isEmpty(barcode)&& staNo !=null) {
            if (!Cools.isEmpty(barcode) && staNo != null) {
                StaProtocol staProtocol = station.get(staNo);
                if (staProtocol == null) {
                    log.warn("扫码站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNo);
@@ -196,7 +196,7 @@
     * 读取重量信息
     */
    private void readWeight() {
        if ( slave.getWeight() == null || ! slave.getWeight()) {
        if (slave.getWeight() == null || !slave.getWeight()) {
            return;
        }
@@ -209,13 +209,13 @@
            return;
        }
        byte[] content = result.Content;
        for (int i = 0; i < DeviceField.WEIGHT.getArrLength() ; i++) {
        for (int i = 0; i < DeviceField.WEIGHT.getArrLength(); i++) {
            int[] seg = DeviceField.WEIGHT.getSeg();
            Short staNo = siemensS7Net.getByteTransform().TransInt16(
                    content, seg[0]+i * DeviceField.WEIGHT.getByteLength());
                    content, seg[0] + i * DeviceField.WEIGHT.getByteLength());
            Double weight = (double) siemensS7Net.getByteTransform().TransSingle(
                    content, seg[1] + i * DeviceField.WEIGHT.getByteLength());
            if (!Cools.isEmpty(weight)&& staNo !=null) {
            if (!Cools.isEmpty(weight) && staNo != null) {
                StaProtocol staProtocol = station.get(staNo);
                if (staProtocol == null) {
                    log.warn("称重站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNo);
@@ -223,14 +223,14 @@
                }
                staProtocol.setWeight(BigDecimal.valueOf(weight).setScale(4, RoundingMode.HALF_UP).doubleValue());
            }
           }
        }
    }
    /**
     * 读取外形检测错误
     */
    private void readDimensionErrors() {
        if ( slave.getStaNosError() == null ||  !slave.getStaNosError()) {
        if (slave.getStaNosError() == null || !slave.getStaNosError()) {
            return;
        }
@@ -248,14 +248,14 @@
            int[] seg = DeviceField.DIMENSION_WORD.getSeg();
            Short staNo = siemensS7Net.getByteTransform().TransInt16(
                    content, seg[0]);
            if ( staNo !=null) {
            if (staNo != null) {
                StaProtocol staProtocol = station.get(staNo);
                if (staProtocol == null){
                if (staProtocol == null) {
                    log.warn("异常站点不存在 [id:{}] [staNo:{}]", slave.getId(), staNo);
                    continue;
                }
                boolean[] status = siemensS7Net.getByteTransform().TransBool(
                        content, seg[1]+i * DeviceField.DIMENSION_WORD.getByteLength(),
                        content, seg[1] + i * DeviceField.DIMENSION_WORD.getByteLength(),
                        1);
//未使用,预留
//                boolean[] status1 = siemensS7Net.getByteTransform().TransBool(