package ifc.bim.openecg.jtools.jparser; /** *

Title: SCP-ECG Section Header

*

Description: The structure of a section's header, able to load itself from a file

*

Company: Ist. Fisiologia Clinica del CNR via G.Moruzzi,1 54124 Pisa Italy

* @authors Giacomo Ciani - Fabrizio Conforti (conforti@ifc.cnr.it) * @version 1.0 */ import java.io.*; import java.nio.*; import java.util.*; import javax.imageio.stream.*; /** * The structure of a section's header, able to load itself from a file */ public class SectHeader { /**Stores the section Id*/ public int sectId; /**Stores the section Crc*/ public int sectCrc; /**Stores the section lenght*/ public int sectLen; /**Stores the computed section data lenght*/ public int dataLen; /**Stores the section version*/ public int sectVer; /**Stores the section protocol version*/ public int protVer; /**Stores the reserved bytes*/ public String res; /** * Constructs a SectHeader with empty fields */ public SectHeader(){} /** * Retrieves the header information from the specified FileImageOutputStream starting * at current stream index and stores them in the header fields. * @param fHandle the FileImageOutputStream associated with SCP-ECG file * @throws Exception if any error occurs during the operation. */ public void Load( FileImageOutputStream fHandle ) throws Exception{ byte[] tempRes = new byte[6]; sectCrc = fHandle.readShort(); sectId = fHandle.readShort(); sectLen = fHandle.readInt(); dataLen = sectLen-16; sectVer = fHandle.readByte(); protVer = fHandle.readByte(); fHandle.readFully(tempRes); res = new String(tempRes); } /** * Prints the headers basic information on the standard output. */ public void Print(){ System.out.println ("\r\nsectId = "+sectId +"\r\nsectCrc= "+sectCrc +"\r\nsectLen= "+sectLen +"\r\ndataLen= "+dataLen +"\r\nsectVer= "+sectVer +"\r\nprotVer= "+protVer +"\r\nscp_ecg= "+res ); } }