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

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;

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

@Slf4j
@Data
public class ItemProtocol {

    public static String item_action = "action";

    public static String item_to_command = "to_command";

    private HongXiangStationDeviceDriver driver;

    public ItemProtocol(HongXiangStationDeviceDriver driver) {
        this.driver = driver;
    }


    public int getItem_action(){
        return this.getOpcIntegerValue(item_action);
    };

    Boolean isonline;

    public int getOpcIntegerValue(String protocol) {
        Integer value = this.driver.getIntegeregerValue(protocol);
        if (value == null) {
            setIsonline(false);
        } else {
            setIsonline(true);
            return value;
        }
        return 0;

    }

    public static List<ItemDto> getReadableItemDtos() {
        ArrayList list = new ArrayList();

        list.add(new ItemDto(item_action, "动作信号", "450"));

        return list;
    }

    public static List<ItemDto> getWriteableItemDtos() {
        ArrayList list = new ArrayList();
        list.add(new ItemDto(item_to_command, "下发命令", "226"));
        return list;
    }


}

