package net.northking.cctp.upperComputer.driver.agent.command;


import net.northking.cctp.upperComputer.driver.agent.command.data.DisplayData;
import net.northking.cctp.upperComputer.driver.agent.command.protocol.AbstractProtocolCommand;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.ArrayList;

public class WatchDisplayInfoCommand extends AbstractProtocolCommand<ArrayList<DisplayData>> {

    private static WatchDisplayInfoCommand instance = null;

    public static WatchDisplayInfoCommand getInstance() {
        if (instance == null) {
            instance = new WatchDisplayInfoCommand();
        }
        return instance;
    }

    @Override
    public int getCommandId() {
        return 38;
    }

    @Override
    public void doSend(DataOutput output) throws IOException {

    }

    @Override
    public ArrayList<DisplayData> buildReceive(DataInput input) throws IOException {
        ArrayList result = new ArrayList<DisplayData>();
        int displayNum = input.readInt();
        for (int i = 0; i < displayNum; i++) {
            DisplayData displayData = new DisplayData();
            displayData.setId(input.readInt());
            displayData.setWidth(input.readInt());
            displayData.setHeight(input.readInt());
            displayData.setXdpi(input.readFloat());
            displayData.setYdpi(input.readFloat());
            displayData.setRotation(input.readInt());
            displayData.setRefreshRate(input.readFloat());
            displayData.setDensity(input.readFloat());
            displayData.setDensityDpi(input.readInt());
            displayData.setFlag(input.readInt());
            displayData.setHdr(input.readBoolean());
            result.add(displayData);
        }
        return result;
    }
}
