package org.nl.acs.device_driver.basedriver.standard_autodoor;

import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.device.enums.DeviceType;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * 自动门驱动定义
 */
@Service
public class StandardAutodoorDefination implements OpcDeviceDriverDefination {
    @Override
    public String getDriverCode() {
        return "standard_autodoor";
    }

    @Override
    public String getDriverName() {
        return "标准版-自动门";
    }

    @Override
    public String getDriverDescription() {
        return "标准版-自动门";
    }

    @Override
    public DeviceDriver getDriverInstance(Device device) {
        return (new StandardAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this);

    }

    @Override
    public Class<? extends DeviceDriver> getDeviceDriverType() {
        return StandardAutodoorDeviceDriver.class;
    }

    @Override
    public List<DeviceType> getFitDeviceTypes() {
        List<DeviceType> types = new LinkedList();
        types.add(DeviceType.conveyor);
        return types;
    }

    @Override
    public List<ItemDto> getReadableItemDtos() {
        return getReadableItemDtos2();
    }

    public static List<ItemDto> getReadableItemDtos2() {
        List<ItemDto> list = new ArrayList();
        list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0"));
        list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true));
        list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2"));
        list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4"));
        return list;
    }

    @Override
    public List<ItemDto> getWriteableItemDtos() {
        return ItemProtocol.getWriteableItemDtos();
    }

}
