KSquare Utilities
KKLSC::ScannerFileSimple Class Reference

#include <A>

+ Inheritance diagram for KKLSC::ScannerFileSimple:

Public Member Functions

 ScannerFileSimple (const KKStr &_fileName, RunLog &_log)
 
 ScannerFileSimple (const KKStr &_fileName, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
 
virtual ~ScannerFileSimple ()
 
virtual Format FileFormat () const
 
virtual void WriteTextBlock (const uchar *txtBlock, kkuint32 txtBlockLen)
 
- Public Member Functions inherited from KKLSC::ScannerFile
 ScannerFile (const KKStr &_fileName, RunLog &_log)
 
 ScannerFile (const KKStr &_fileName, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
 
virtual ~ScannerFile ()
 
void AddHeaderField (const KKStr &_fieldName, const KKStr &_fieldValue)
 
void AddHeaderFields (const ScannerHeaderFieldsPtr _headerFields)
 
void AddStartPoint (kkint32 _scanLineNum)
 Adds a Start-Point to the 'StartStopPoints' list. More...
 
void AddStopPoint (kkint32 _scanLineNum)
 Adds a Stop-Point to the 'StartStopPoints' list. More...
 
void BuildFrameOffsets (const volatile bool &cancelFlag)
 Will update the 'frameOffsets' table by scanning the file from the last known entry until the end of file. More...
 
bool BuildFrameOffsetsRunning () const
 
kkint64 ByteOffsetScanLineZero () const
 
virtual void Close ()
 
bool Eof () const
 
KKStr FileFormatStr () const
 
const KKStrFileName () const
 
kkint64 FileSizeInBytes () const
 
bool FlatFieldEnabled () const
 
kkuint32 FlowMeterCounter () const
 
kkuint32 FlowMeterCounterScanLine () const
 
virtual void Flush ()
 
ucharFrameBuffer () const
 
kkint64 FrameBufferFileOffsetLast () const
 
kkint64 FrameBufferFileOffsetNext () const
 
kkint32 FrameHeight () const
 
bool FrameOffsetsLoaded () const
 
void FrameRead (kkuint32 frameNum, bool &found)
 Read into frame buffer 'frameNum' and reposition so that next scan-line will be the 1st line in the frame. More...
 
virtual void GetNextLine (uchar *lineBuff, kkuint32 lineBuffSize, kkuint32 &lineSize, kkuint32 colCount[], kkuint32 &pixelsInRow)
 
const KKStrGetValue (const KKStr &fieldName)
 
float GetValueFloat (const KKStr &fieldName)
 
ScannerHeaderFieldsPtr HeaderFields () const
 
void InitiateWritting ()
 
kkint32 LargestKnowmFrameNum () const
 
kkint32 LargestKnownScanLine () const
 
kkint32 LastScanLine () const
 
void LoadIndexFile (bool &successful)
 Call this method to Load the FrameOffsets and StartStop points from the index file. More...
 
virtual kkint32 MemoryConsumedEstimated () const
 
kkint32 NextScanLine () const
 
bool Opened () const
 
kkuint32 PixelsPerScanLine () const
 
VectorFloatPtr RecordRateByTimeIntervals (int intervalSecs)
 Returns an array indication the record rate in bytes/sec for specified time-intervals. More...
 
void Reset ()
 
float ScanRate () const
 
virtual void ScanRate (float _scanRate)
 
void SkipNextLine ()
 
void SkipToScanLine (kkint32 scanLine)
 Repositions the file such that the next call to 'GetNextLine' returns the 'scanLine' scan-line. More...
 
void StartStopPointDelete (kkint32 _scanLineNum)
 
StartStopPointPtr StartStopPointNearestEntry (kkint32 _scanLineNum)
 
StartStopPointPtr StartStopPointPrevEntry (kkint32 _scanLineNum)
 
const StartStopPointListStartStopPoints () const
 
StartStopPointPtr StartStopPointSuccEntry (kkint32 _scanLineNum)
 
virtual void WriteInstrumentDataWord (uchar idNum, kkuint32 scanLineNum, WordFormat32Bits dataWord)
 Writes a 32 bit number into the Scanner File Stream at current location. More...
 
virtual void WriteScanLine (const uchar *buffer, kkuint32 bufferLen)
 
virtual void WriteTextBlock (const uchar *txtBlock, kkuint32 txtBlockLen)=0
 

Static Public Member Functions

static const ucharCompensationTable ()
 
- Static Public Member Functions inherited from KKLSC::ScannerFile
static const ucharConpensationTable (Format format)
 
static ScannerFilePtr CreateScannerFile (KKStr _fileName, RunLog &_log)
 
static ScannerFilePtr CreateScannerFileForOutput (const KKStr &_fileName, Format _format, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
 
static ScannerFilePtr CreateScannerFileForOutput (const KKStr &_fileName, const KKStr &_formatStr, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
 
static void GetScannerFileParameters (const KKStr &_scannerFileName, ScannerHeaderFieldsPtr &_headerFields, Format &_scannerFileFormat, kkint32 &_frameHeight, kkint32 &_frameWidth, float &_scanRate, bool &_successful, RunLog &_log)
 Retrieves statistics for a specified Scanner File. More...
 
static Format GuessFormatOfFile (const KKStr &_fileName, RunLog &_log)
 
static Format ScannerFileFormatFromStr (const KKStr &fileFormatStr)
 
static const KKStrScannerFileFormatToStr (Format fileFormat)
 

Protected Member Functions

virtual kkuint32 ReadBufferFrame ()
 Read in one Scanner File Frame return number of actual scan-lines read. More...
 
virtual kkint64 SkipToNextFrame ()
 Skip to start of next frame returning back byte offset of that frame. More...
 
virtual void WriteBufferFrame ()
 Write the contents of 'frameBuffer' to he end of the scanner file. More...
 
- Protected Member Functions inherited from KKLSC::ScannerFile
void AddStartStopEntryToIndexFile (kkint32 scanLineNum, StartStopPoint::StartStopType type, bool deleteEntry)
 
void AllocateFrameBuffer ()
 
void CreateGoalie ()
 
void DetermineFrameOffsetForFrame (kkuint32 frameNum)
 Updates the byte offset for specified entry in 'frameOffsets' that is currently flagged with "-1". More...
 
void ExtractHeaderField (const KKStr &fieldName, const KKStr &fieldValue)
 
kkint32 FSeek (kkint64 filePos)
 
kkint64 GetFrameOffset (kkuint32 frameNum)
 
void Open (const KKStr &_fileName)
 
void ReadHeader ()
 
void ReportInstrumentDataWord (uchar idNum, kkuint32 scanLineNum, WordFormat32Bits dataWord)
 
void ReportTextMsg (const char *textBuff, kkint32 numTextBytes)
 Text messages that are embedded in a scanner file can be reported here. More...
 
void SaveIndexFile (std::vector< kkint64 > &frameOffsets)
 
void SkipBytesForward (kkuint32 numBytes)
 
void UpdateFrameOffset (kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
 
void WriteHeader ()
 This method is called before any scanner data is added to the file. It will write the header information for the file. More...
 

Additional Inherited Members

- Public Types inherited from KKLSC::ScannerFile
enum  Format {
  Format::sfSimple, Format::sf2BitEncoded, Format::sf3BitEncoded, Format::sf4BitEncoded,
  Format::sfZlib3BitEncoded, Format::sfUnKnown
}
 
enum  IOMode { ioRead, ioWrite }
 
typedef ScannerFileScannerFilePtr
 
- Static Protected Member Functions inherited from KKLSC::ScannerFile
static void ReadHeaderOneLine (FILE *f, bool &endOfText, KKStr &line)
 
- Protected Attributes inherited from KKLSC::ScannerFile
kkint64 byteOffsetScanLineZero
 
bool eof
 
FILE * file
 
KKStr fileName
 
kkint64 fileSizeInBytes
 
bool flatFieldEnabled
 
kkuint32 flowMeterCounter
 
kkuint32 flowMeterCounterScanLine
 
ucharframeBuffer
 
kkint64 frameBufferFileOffsetLast
 
kkint64 frameBufferFileOffsetNext
 
bool frameBufferLastReadEof
 
kkuint32 frameBufferLen
 
kkuint32 frameBufferNextLine
 
kkuint32 frameBufferNumScanLines
 
kkuint32 frameBufferSize
 
kkuint32 frameHeight
 
kkuint32 frameNumCurLoaded
 
std::vector< kkint64frameOffsets
 
bool frameOffsetsBuildRunning
 
bool frameOffsetsLoaded
 
GoalKeeperPtr goalie
 
bool headerDataWritten
 
ScannerHeaderFieldsPtr headerFields
 
std::ofstream * indexFile
 
KKStr indexFileName
 
IOMode ioMode
 
kkint32 largestKnownScanLine
 
kkint32 lastScanLine
 
RunLoglog
 
kkint32 nextScanLine
 
bool opened
 
kkuint32 pixelsPerScanLine
 
ScannerFileEntryPtr scannerFileEntry
 
float scanRate
 
StartStopPointList startStopPoints
 
- Static Protected Attributes inherited from KKLSC::ScannerFile
static const KKStr fileFormatOptions []
 

Detailed Description

simple format where each scan line is stored without any encoding or compression.

Definition at line 11 of file ScannerFileSimple.h.

Constructor & Destructor Documentation

KKLSC::ScannerFileSimple::ScannerFileSimple ( const KKStr &  _fileName,
RunLog &  _log 
)

Constructor for opening file for reading

KKLSC::ScannerFileSimple::ScannerFileSimple ( const KKStr &  _fileName,
kkuint32  _pixelsPerScanLine,
kkuint32  _frameHeight,
RunLog &  _log 
)

Constructor for opening file for Writing

ScannerFileSimple::~ScannerFileSimple ( )
virtual

Definition at line 54 of file ScannerFileSimple.cpp.

55 {
56  if (opened)
57  Close ();
58 }
virtual void Close()

Member Function Documentation

const uchar * ScannerFileSimple::CompensationTable ( )
static

Definition at line 137 of file ScannerFileSimple.cpp.

References KKB::GlobalGoalKeeper::EndBlock(), and KKB::GlobalGoalKeeper::StartBlock().

Referenced by KKLSC::ScannerFile::ConpensationTable().

138 {
139  GlobalGoalKeeper::StartBlock ();
140 
141  uchar* cs = new uchar[256];
142  for (kkuint32 x = 0; x < 256; ++x)
143  cs[x] = x;
144 
145  GlobalGoalKeeper::EndBlock ();
146 
147  return cs;
148 }
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
virtual Format KKLSC::ScannerFileSimple::FileFormat ( ) const
inlinevirtual

Reimplemented from KKLSC::ScannerFile.

Definition at line 30 of file ScannerFileSimple.h.

References KKLSC::ScannerFile::sfSimple.

kkuint32 ScannerFileSimple::ReadBufferFrame ( )
protectedvirtual

Read in one Scanner File Frame return number of actual scan-lines read.

Unless end of file is reached this method will read in 'framHeight' scan-lines.

Implements KKLSC::ScannerFile.

Definition at line 63 of file ScannerFileSimple.cpp.

References KKLSC::ScannerFile::file, KKLSC::ScannerFile::frameBufferFileOffsetLast, KKLSC::ScannerFile::frameBufferFileOffsetNext, KKLSC::ScannerFile::frameBufferLen, KKLSC::ScannerFile::frameBufferNextLine, KKB::osFTELL(), and KKLSC::ScannerFile::pixelsPerScanLine.

64 {
65  frameBufferLen = 0;
67  if (feof (file) != 0)
68  {
69  memset (frameBuffer, 0, frameBufferSize);
70  return 0;
71  }
72 
78 } /* ReadBufferFrame */
kkint64 frameBufferFileOffsetLast
Definition: ScannerFile.h:427
kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
kkint64 osFTELL(FILE *f)
Calls the appropriate 64 bit function for operating system.
Definition: OSservices.cpp:93
kkuint32 frameBufferLen
Definition: ScannerFile.h:435
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
kkint64 ScannerFileSimple::SkipToNextFrame ( )
protectedvirtual

Skip to start of next frame returning back byte offset of that frame.

This will be called by the 'UpdateFrameOffset' and 'DetermineFrameOffsetForFrame' methods used to build the 'frameOffsets' table. It is important that the implementation of this method NOT update the frameBuffer fields; such as 'frameBuffer', 'frameBufferNextLine', etc .....

Implements KKLSC::ScannerFile.

Definition at line 82 of file ScannerFileSimple.cpp.

References KKLSC::ScannerFile::file, KKLSC::ScannerFile::frameBufferSize, and KKB::osFTELL().

83 {
84  //int64 byteOffset = osFTELL (file);
85  kkint64 byteOffset = osFTELL (file);
86 
87  kkint64 nextFrameByteOffset = byteOffset + frameBufferSize;
88  kkint32 returnCd = osFSEEK (file, nextFrameByteOffset - 1, SEEK_SET);
89 
90  char buff[10];
91  returnCd = fread (buff, 1, 1, file);
92  if (returnCd < 1)
93  return -1;
94  else
95  return nextFrameByteOffset;
96 } /* SkipToNextFrame */
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint64 osFTELL(FILE *f)
Calls the appropriate 64 bit function for operating system.
Definition: OSservices.cpp:93
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
__int64 kkint64
Definition: KKBaseTypes.h:90
int osFSEEK(FILE *f, kkint64 offset, int origin)
Definition: OSservices.cpp:104
void ScannerFileSimple::WriteBufferFrame ( )
protectedvirtual

Write the contents of 'frameBuffer' to he end of the scanner file.

Will write the entire contents of 'frameBuffer' to the end of the scanner file.

Implements KKLSC::ScannerFile.

Definition at line 100 of file ScannerFileSimple.cpp.

References KKLSC::ScannerFile::file, KKLSC::ScannerFile::fileSizeInBytes, KKLSC::ScannerFile::frameBufferFileOffsetLast, KKLSC::ScannerFile::frameBufferFileOffsetNext, KKLSC::ScannerFile::frameBufferNextLine, KKLSC::ScannerFile::frameBufferSize, KKB::osFTELL(), and KKLSC::ScannerFile::pixelsPerScanLine.

101 {
103 
104  kkuint32 frameBufferSpaceUsed = frameBufferNextLine * pixelsPerScanLine;
105  fwrite (frameBuffer, 1, frameBufferSpaceUsed, file);
106 
107  kkuint32 paddingNeeded = frameBufferSize - frameBufferSpaceUsed;
108  if (paddingNeeded > 0)
109  {
110  uchar* buff = new uchar[paddingNeeded];
111  memset (buff, 0, paddingNeeded);
112  fwrite (buff, 1, paddingNeeded, file);
113  delete[] buff;
114  }
115 
117 
120 } /* WriteBufferFrame */
kkint64 frameBufferFileOffsetLast
Definition: ScannerFile.h:427
kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
kkint64 fileSizeInBytes
Definition: ScannerFile.h:396
kkint64 osFTELL(FILE *f)
Calls the appropriate 64 bit function for operating system.
Definition: OSservices.cpp:93
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
void ScannerFileSimple::WriteTextBlock ( const uchar txtBlock,
kkuint32  txtBlockLen 
)
virtual

Definition at line 125 of file ScannerFileSimple.cpp.

128 {
129  log.Level (-1) << endl
130  << "ScannerFileSimple::WriteTextBlock ***ERROR*** The SimpleFormat does not support TextBlocks" << endl
131  << endl;
132 } /* WriteTextBlock */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220

The documentation for this class was generated from the following files: