package com.xydl.cac.model.spectrogram;

import lombok.Data;

import java.io.DataInputStream;
import java.util.ArrayList;
import java.util.List;

import static com.xydl.cac.model.spectrogram.SpectrogramModel.readLittleEndianFloat;

@Data
public class SouthYspChannel {
    Integer n;
    List<YspChannelCrest> crests = new ArrayList<>();
    List<Float> data = new ArrayList<>();

    public void readFrom(DataInputStream dis) throws Exception {
        n = dis.read();
        for (int i = 0; i < n; i++) {
            YspChannelCrest crest = new YspChannelCrest();
            crest.readFrom(dis);
            crests.add(crest);
        }
    }

    public void readDataFrom(DataInputStream dis, Integer k) throws Exception {
        for (int i = 0; i < k; i++) {
            Float v = readLittleEndianFloat(dis);
            data.add(v);
        }
    }
}
