package com.xydl.cac.spectrogram;

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

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

@Service
@Slf4j
public class ProcessorPd {

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

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

    public static void main(String[] args) {
        ProcessorPd processorYsp = new ProcessorPd();
        processorYsp.process("C:/Code/cac/局放谱图/50100055_5__001_01_20250409180000.dat");
    }
}
