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

import net.northking.cctp.upperComputer.driver.agent.command.protocol.ProtocolCommand;

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

public class WatchCpuUsageCommand implements ProtocolCommand<Float[]> {
    private static WatchCpuUsageCommand instance = null;

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

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

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

    }

    @Override
    public Float[] buildReceive(DataInput input) throws IOException {
        int count = input.readInt();
        Float[] usageList = new Float[count];
        for (int i = 0; i < count; i++) {
            usageList[i] = input.readFloat();
        }
        return usageList;
    }
}
