package org.josast.amicalsat;

import java.util.logging.Logger;

import org.josast.amicalsat.generated.FrameTlmAmicalsat;

import io.kaitai.struct.ByteBufferKaitaiStream;

public class FactoryConsumer {
    private Logger log = Logger.getLogger(getClass().getName());
    FrameFactory ff = new FrameFactory();
    public FactoryConsumer() {
        
        

    }
    
    public Frame getFrame (byte [] data)
    {
        Frame fm  = null;
        
        try { 
            
 
        FrameTlmAmicalsat cube = new FrameTlmAmicalsat(new ByteBufferKaitaiStream(data));
        String tlmArea = cube.frameTlmEntrySat().payload().tlmArea();
        String typeFrame = cube.frameTlmEntrySat().payload().tlmType();
        fm = ff.creerFrame(tlmArea, typeFrame);
        fm.setUp(cube);
        }
        catch (Exception e)
        {
            log.severe("Data input received not decoded " + e.toString());
        }
        
        return fm;
    }
    
    

}
