package com.xydl.cac.model.spectrogram;

import lombok.Data;

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

@Data
public class Ysp extends SpectrogramModel {
    Integer code;
    Integer length;
    Long createTime;
    Integer flag;
    Float xInterval;
    Float yMax;
    Integer xUnit;
    Integer yUnit;
    Integer k;
    Integer m;
    List<YspChannel> channels = new ArrayList<>();

    public void readFrom(DataInputStream dis) throws Exception {
        code = dis.read();
        length = readLittleEndianInt(dis);
        createTime = readLittleEndianLong(dis);
        flag = dis.read();
        xInterval = readLittleEndianFloat(dis);
        yMax = readLittleEndianFloat(dis);
        xUnit = dis.read();
        yUnit = dis.read();
        k = readLittleEndianInt(dis);
        m = dis.read();
        for (int i = 0; i < m; i++) {
            YspChannel channel = new YspChannel();
            channel.readFrom(dis, k);
            channels.add(channel);
        }
    }
}
