package org.nl.acs.common;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver;
import org.springframework.stereotype.Service;

/**
 * @author geng by
 * 输送机-控制点-PLC扫码器
 */
@Service("standard_conveyor_control_with_plcscanner")
public class StandardCoveyorControlWithPlcScannerDevice extends AbstractDriverService{
    @Override
    public JSONObject getDeviceInfo(Device device) {
        StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) device.getDeviceDriver();
        JSONObject jo = super.getCommonDeviceInfo(standardCoveyorControlWithPlcScannerDeviceDriver,0,0);
        jo.put("error", standardCoveyorControlWithPlcScannerDeviceDriver.getError());
        jo.put("isError", standardCoveyorControlWithPlcScannerDeviceDriver.getIserror());
        jo.put("height", standardCoveyorControlWithPlcScannerDeviceDriver.getHeight());
        jo.put("operation_type", standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type());
        jo.put("direction", standardCoveyorControlWithPlcScannerDeviceDriver.getDirection());
        jo.put("action", standardCoveyorControlWithPlcScannerDeviceDriver.getAction());
        jo.put("ioaction", standardCoveyorControlWithPlcScannerDeviceDriver.getIoaction());
        jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()) ? "" : standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode());
        jo.put("message", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getMessage()) ? "" : standardCoveyorControlWithPlcScannerDeviceDriver.getMessage());
        jo.put("requestSucess", standardCoveyorControlWithPlcScannerDeviceDriver.getRequireSucess().toString());
        jo.put("applySucess", standardCoveyorControlWithPlcScannerDeviceDriver.getApplySucess().toString());
        jo.put("instruction_message", standardCoveyorControlWithPlcScannerDeviceDriver.getInst_message());
        return jo;
    }
}
