package com.xydl.cac.spectrogram;

import com.xydl.cac.model.spectrogram.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.DataInputStream;
import java.io.FileInputStream;

@Service
@Slf4j
public class ProcessorYsp {

    public SouthYsp process(String localFilePath) {
        try (DataInputStream dis = new DataInputStream(new FileInputStream(localFilePath))) {
            SouthYsp model = this.readOneBlock(dis);
            return model;
        } catch (Exception e) {
            log.error("解析文件失败" + localFilePath, e);
            return null;
        }
    }

    private SouthYsp readOneBlock(DataInputStream dis) throws Exception {
        SouthYsp model = new SouthYsp();
        model.readFrom(dis);
        return model;
    }

    public static void main(String[] args) {
        ProcessorYsp processorYsp = new ProcessorYsp();
        processorYsp.process("C:/Code/cac/谱图文件/0312B12000042A3840001_203_07_20250113163055.dat");
    }
}
