KSquare Utilities
KKLSC::ScannerFile Class Referenceabstract

#include <base>

+ Inheritance diagram for KKLSC::ScannerFile:

Public Types

enum  Format {
  Format::sfSimple, Format::sf2BitEncoded, Format::sf3BitEncoded, Format::sf4BitEncoded,
  Format::sfZlib3BitEncoded, Format::sfUnKnown
}
 
enum  IOMode { ioRead, ioWrite }
 
typedef ScannerFileScannerFilePtr
 

Public Member Functions

 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
 
virtual Format FileFormat () 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 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

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)
 
virtual kkuint32 ReadBufferFrame ()=0
 Read in one Scanner File Frame return number of actual scan-lines read. More...
 
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)
 
virtual kkint64 SkipToNextFrame ()=0
 Skip to start of next frame returning back byte offset of that frame. More...
 
void UpdateFrameOffset (kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
 
virtual void WriteBufferFrame ()=0
 Write the contents of 'frameBuffer' to he end of the scanner file. More...
 
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...
 

Static Protected Member Functions

static void ReadHeaderOneLine (FILE *f, bool &endOfText, KKStr &line)
 

Protected Attributes

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

static const KKStr fileFormatOptions []
 

Detailed Description

class to be used for all the different Scanner File Formats.

Definition at line 45 of file ScannerFile.h.

Member Typedef Documentation

Definition at line 48 of file ScannerFile.h.

Member Enumeration Documentation

Enumerator
sfSimple 
sf2BitEncoded 
sf3BitEncoded 
sf4BitEncoded 
sfZlib3BitEncoded 
sfUnKnown 

Definition at line 50 of file ScannerFile.h.

51  {sfSimple,
52  sf2BitEncoded,
53  sf3BitEncoded,
54  sf4BitEncoded,
55  sfZlib3BitEncoded,
56  sfUnKnown
57  };

Constructor & Destructor Documentation

ScannerFile::ScannerFile ( const KKStr _fileName,
RunLog _log 
)

Constructor for opening file for reading

Definition at line 40 of file ScannerFile.cpp.

References AllocateFrameBuffer(), byteOffsetScanLineZero, CreateGoalie(), eof, file, fileName, fileSizeInBytes, flatFieldEnabled, flowMeterCounter, flowMeterCounterScanLine, frameBuffer, frameBufferFileOffsetLast, frameBufferFileOffsetNext, frameBufferLastReadEof, frameBufferLen, frameBufferNextLine, frameBufferNumScanLines, frameBufferSize, frameHeight, frameNumCurLoaded, frameOffsetsBuildRunning, frameOffsetsLoaded, KKLSC::ScannerFileEntry::FullName(), KKLSC::ScannerFileEntry::GetOrCreateScannerFileEntry(), goalie, headerDataWritten, headerFields, indexFile, indexFileName, ioMode, ioRead, KKB::KKStr::KKStr(), largestKnownScanLine, lastScanLine, log, nextScanLine, Open(), opened, KKB::osFTELL(), KKB::osGetRootName(), KKLSC::ScannerFileEntry::PixelsPerScanLine(), pixelsPerScanLine, ReadHeader(), ScannerFile(), scannerFileEntry, KKLSC::ScannerFileEntry::ScanRate(), scanRate, and UpdateFrameOffset().

Referenced by ScannerFile(), KKLSC::ScannerFile2BitEncoded::ScannerFile2BitEncoded(), KKLSC::ScannerFile3BitEncoded::ScannerFile3BitEncoded(), KKLSC::ScannerFile4BitEncoded::ScannerFile4BitEncoded(), and KKLSC::ScannerFileZLib3BitEncoded::ScannerFileZLib3BitEncoded().

42  :
44  eof (false),
45  file (NULL),
46  fileName (_fileName),
47  fileSizeInBytes (0),
48  flatFieldEnabled (false),
49  frameHeight (0),
50  headerDataWritten (false),
51  headerFields (NULL),
52  ioMode (ioRead),
54  lastScanLine (0),
55  log (_log),
56  nextScanLine (0),
57  opened (false),
58  pixelsPerScanLine (4096),
59  scanRate (20000),
60 
61  flowMeterCounter (0),
63  frameBuffer (NULL),
66  frameBufferLastReadEof (false),
67  frameBufferLen (0),
70  frameBufferSize (0),
72  frameOffsets (),
74  frameOffsetsLoaded (false),
75  goalie (NULL),
76  indexFile (NULL),
77  indexFileName (),
78  scannerFileEntry (NULL),
80 {
81  CreateGoalie ();
82 
84  scannerFileEntry->FullName (fileName);
85 
86  Open (fileName);
87  if (opened)
88  {
89  ReadHeader ();
91  if (frameHeight == 0)
95  scannerFileEntry->PixelsPerScanLine (pixelsPerScanLine);
96  scannerFileEntry->ScanRate (scanRate);
97  }
98 }
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
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
void Open(const KKStr &_fileName)
kkuint32 frameBufferNumScanLines
Definition: ScannerFile.h:445
kkuint32 frameBufferLen
Definition: ScannerFile.h:435
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
static ScannerFileEntryPtr GetOrCreateScannerFileEntry(const KKStr &rootName)
kkuint32 flowMeterCounterScanLine
Definition: ScannerFile.h:416
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
std::ofstream * indexFile
Definition: ScannerFile.h:466
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
bool frameOffsetsBuildRunning
Definition: ScannerFile.h:457
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
kkint64 byteOffsetScanLineZero
Definition: ScannerFile.h:392
ScannerFileEntryPtr scannerFileEntry
Definition: ScannerFile.h:471
kkuint32 flowMeterCounter
Definition: ScannerFile.h:412
KKStr osGetRootName(const KKStr &fullFileName)
ScannerFile::ScannerFile ( const KKStr _fileName,
kkuint32  _pixelsPerScanLine,
kkuint32  _frameHeight,
RunLog _log 
)

Constructor for opening file for Writing

Definition at line 104 of file ScannerFile.cpp.

References AllocateFrameBuffer(), byteOffsetScanLineZero, eof, file, fileName, fileSizeInBytes, flatFieldEnabled, flowMeterCounter, flowMeterCounterScanLine, frameBuffer, frameBufferFileOffsetLast, frameBufferFileOffsetNext, frameBufferLastReadEof, frameBufferLen, frameBufferNextLine, frameBufferNumScanLines, frameBufferSize, frameHeight, frameNumCurLoaded, frameOffsetsBuildRunning, frameOffsetsLoaded, KKLSC::ScannerFileEntry::FullName(), KKLSC::ScannerFileEntry::GetOrCreateScannerFileEntry(), goalie, headerDataWritten, headerFields, indexFile, indexFileName, ioMode, ioWrite, KKB::KKStr::KKStr(), largestKnownScanLine, lastScanLine, log, nextScanLine, Open(), opened, KKB::osFTELL(), KKB::osGetRootName(), KKLSC::ScannerFileEntry::PixelsPerScanLine(), pixelsPerScanLine, ScannerFile(), scannerFileEntry, and scanRate.

Referenced by ScannerFile(), KKLSC::ScannerFile2BitEncoded::ScannerFile2BitEncoded(), KKLSC::ScannerFile3BitEncoded::ScannerFile3BitEncoded(), KKLSC::ScannerFile4BitEncoded::ScannerFile4BitEncoded(), and KKLSC::ScannerFileZLib3BitEncoded::ScannerFileZLib3BitEncoded().

108  :
109 
111  eof (false),
112  file (NULL),
113  fileName (_fileName),
114  fileSizeInBytes (0),
115  flatFieldEnabled (false),
116  frameHeight (_frameHeight),
117  headerDataWritten (false),
118  headerFields (NULL),
119  ioMode (ioWrite),
121  lastScanLine (0),
122  log (_log),
123  nextScanLine (0),
124  opened (false),
125  pixelsPerScanLine (_pixelsPerScanLine),
126  scanRate (20000),
127 
128  flowMeterCounter (0),
130  frameBuffer (NULL),
133  frameBufferLastReadEof (false),
134  frameBufferLen (0),
137  frameBufferSize (0),
138  frameNumCurLoaded (0),
139  frameOffsets (),
140  frameOffsetsBuildRunning (false),
141  frameOffsetsLoaded (false),
142  goalie (NULL),
143  indexFile (NULL),
144  indexFileName (),
145  scannerFileEntry (NULL),
146  startStopPoints ()
147 {
149  scannerFileEntry->FullName (fileName);
150  scannerFileEntry->PixelsPerScanLine (pixelsPerScanLine);
151 
152  Open (fileName);
153  if (opened)
154  {
157  //UpdateFrameOffset (0, 0, byteOffsetScanLineZero);
158  }
159 }
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
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
void Open(const KKStr &_fileName)
kkuint32 frameBufferNumScanLines
Definition: ScannerFile.h:445
kkuint32 frameBufferLen
Definition: ScannerFile.h:435
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
static ScannerFileEntryPtr GetOrCreateScannerFileEntry(const KKStr &rootName)
kkuint32 flowMeterCounterScanLine
Definition: ScannerFile.h:416
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
std::ofstream * indexFile
Definition: ScannerFile.h:466
bool frameOffsetsBuildRunning
Definition: ScannerFile.h:457
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
kkint64 byteOffsetScanLineZero
Definition: ScannerFile.h:392
ScannerFileEntryPtr scannerFileEntry
Definition: ScannerFile.h:471
kkuint32 flowMeterCounter
Definition: ScannerFile.h:412
KKStr osGetRootName(const KKStr &fullFileName)
ScannerFile::~ScannerFile ( )
virtual

Definition at line 163 of file ScannerFile.cpp.

References Close(), KKB::GoalKeeper::Destroy(), frameBuffer, goalie, headerFields, and opened.

164 {
165  if (opened)
166  Close ();
167 
168  delete headerFields; headerFields = NULL;
169  delete frameBuffer; frameBuffer = NULL;
170 
171  GoalKeeper::Destroy (goalie);
172  goalie = NULL;
173 }
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
virtual void Close()

Member Function Documentation

void ScannerFile::AddHeaderField ( const KKStr _fieldName,
const KKStr _fieldValue 
)

Definition at line 1082 of file ScannerFile.cpp.

References KKLSC::ScannerHeaderFields::Add(), ExtractHeaderField(), headerFields, and KKLSC::ScannerHeaderFields::ScannerHeaderFields().

Referenced by InitiateWritting().

1085 {
1086  if (!headerFields)
1088  headerFields->Add (_fieldName, _fieldValue);
1089  ExtractHeaderField (_fieldName, _fieldValue);
1090 } /* AddHeaderField */
void ExtractHeaderField(const KKStr &fieldName, const KKStr &fieldValue)
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
Represents a list of header fields from a Scanner File.
void Add(ScannerHeaderFieldsPtr fields)
void ScannerFile::AddHeaderFields ( const ScannerHeaderFieldsPtr  _headerFields)

Definition at line 1094 of file ScannerFile.cpp.

References KKLSC::ScannerHeaderFields::EndBlock(), and KKLSC::ScannerHeaderFields::StartBlock().

1095 {
1096  _headerFields->StartBlock ();
1097 
1098  ScannerHeaderFields::const_iterator idx;
1099  for (idx = _headerFields->begin (); idx != _headerFields->end (); ++idx)
1100  AddHeaderField (idx->first, idx->second);
1101 
1102  _headerFields->EndBlock ();
1103 } /* AddHeaderFields */
void AddHeaderField(const KKStr &_fieldName, const KKStr &_fieldValue)
void ScannerFile::AddStartPoint ( kkint32  _scanLineNum)

Adds a Start-Point to the 'StartStopPoints' list.

Definition at line 355 of file ScannerFile.cpp.

References AddStartStopEntryToIndexFile(), and KKLSC::StartStopPoint::StartPoint.

356 {
359 }
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
void AddStartStopEntryToIndexFile(kkint32 scanLineNum, StartStopPoint::StartStopType type, bool deleteEntry)
StartStopPointPtr AddEntry(kkint32 _scanLineNum, StartStopPoint::StartStopType _type)
void ScannerFile::AddStartStopEntryToIndexFile ( kkint32  scanLineNum,
StartStopPoint::StartStopType  type,
bool  deleteEntry 
)
protected

Definition at line 314 of file ScannerFile.cpp.

References CreateGoalie(), KKB::KKStr::Empty(), KKB::GoalKeeper::EndBlock(), goalie, indexFile, indexFileName, KKB::osSleepMiliSecs(), and KKB::GoalKeeper::StartBlock().

Referenced by AddStartPoint(), AddStopPoint(), and StartStopPointDelete().

318 {
319  if (indexFileName.Empty ())
320  return;
321 
322  CreateGoalie ();
323 
324  bool clearToUpdate = false;
325  while (!clearToUpdate)
326  {
327  goalie->StartBlock ();
328  if (indexFile != NULL)
329  {
330  goalie->EndBlock ();
331  osSleepMiliSecs (10);
332  }
333  else
334  {
335  clearToUpdate = true;
336  }
337  }
338 
339  indexFile = new ofstream (indexFileName.Str (), ios_base::app);
340 
341  if (deleteEntry)
342  *indexFile << "DeleteStartStopPoint" << "\t" << scanLineNum << endl;
343  else
344  *indexFile << "StartStopPoint" << "\t" << scanLineNum << "\t" << StartStopPoint::StartStopTypeToStr (type) << endl;
345 
346  indexFile->close ();
347  delete indexFile;
348  indexFile = NULL;
349  goalie->EndBlock ();
350 }
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
static const KKStr & StartStopTypeToStr(StartStopType t)
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
std::ofstream * indexFile
Definition: ScannerFile.h:466
bool Empty() const
Definition: KKStr.h:241
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void osSleepMiliSecs(kkuint32 numMiliSecs)
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
void ScannerFile::AddStopPoint ( kkint32  _scanLineNum)

Adds a Stop-Point to the 'StartStopPoints' list.

Definition at line 363 of file ScannerFile.cpp.

References AddStartStopEntryToIndexFile(), and KKLSC::StartStopPoint::StopPoint.

364 {
367 }
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
void AddStartStopEntryToIndexFile(kkint32 scanLineNum, StartStopPoint::StartStopType type, bool deleteEntry)
StartStopPointPtr AddEntry(kkint32 _scanLineNum, StartStopPoint::StartStopType _type)
void ScannerFile::AllocateFrameBuffer ( )
protected

Definition at line 195 of file ScannerFile.cpp.

References frameBuffer, frameBufferLen, frameBufferSize, frameHeight, and pixelsPerScanLine.

Referenced by ScannerFile().

196 {
197  delete frameBuffer; frameBuffer = NULL;
199  frameBufferLen = 0;
201 }
kkuint32 frameBufferLen
Definition: ScannerFile.h:435
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
void ScannerFile::BuildFrameOffsets ( const volatile bool &  cancelFlag)

Will update the 'frameOffsets' table by scanning the file from the last known entry until the end of file.

It would be best to call this method using a separate thread. The method will utilize synchronization code to prevent interference with the other access methods such as 'GetNextLine', 'FrameRead', etc. The idea is that it will not interfere with file positioning.

Parameters
[in]cancelFlagThis Boolean variable will be monitored by the method; if it turns true it will terminate and return immediately.

Definition at line 1195 of file ScannerFile.cpp.

References CreateGoalie(), KKB::GoalKeeper::EndBlock(), file, frameHeight, frameOffsetsBuildRunning, frameOffsetsLoaded, FSeek(), goalie, largestKnownScanLine, LoadIndexFile(), KKB::GoalKeeper::NumBlockedThreads(), KKB::osFTELL(), KKB::osSleepMiliSecs(), SkipToNextFrame(), and KKB::GoalKeeper::StartBlock().

1196 {
1197  CreateGoalie ();
1198  goalie->StartBlock ();
1199 
1200  kkint64 origFilePos = osFTELL (file);
1201 
1202  frameOffsetsBuildRunning = true;
1203 
1204  bool changesMadeToIndexFile = false;
1205  bool loadSuccessful = false;
1206  LoadIndexFile (loadSuccessful);
1207  if (!loadSuccessful)
1208  changesMadeToIndexFile = true;
1209 
1210  {
1211  if (frameOffsets.size () < 1)
1213 
1214  // Update any entries that are pointing to -1.
1215  for (kkuint32 frameNum = 0; frameNum < frameOffsets.size (); ++frameNum)
1216  {
1217  if (frameOffsets[frameNum] < 0)
1218  {
1219  if (goalie->NumBlockedThreads () > 0)
1220  {
1221  // Since other threads are currently blocked trying to get access to this resource; we will release
1222  // it for 10 mili-secs before we continue.
1223  FSeek (origFilePos);
1224  goalie->EndBlock ();
1225  osSleepMiliSecs (10);
1226  goalie->StartBlock ();
1227  origFilePos = osFTELL (file);
1228  }
1229  changesMadeToIndexFile = true;
1230  DetermineFrameOffsetForFrame (frameNum);
1231  }
1232  }
1233 
1234  bool readToEOF = false;
1235  while ((!readToEOF) && (!cancelFlag))
1236  {
1237  kkuint32 loopCount = 0;
1238 
1239  if (goalie->NumBlockedThreads () > 0)
1240  {
1241  // Give other threads a chance to access this instance of ScannerFile.
1242  FSeek (origFilePos);
1243  goalie->EndBlock ();
1244  while ((goalie->NumBlockedThreads () > 0) && (loopCount < 10))
1245  {
1246  osSleepMiliSecs (10);
1247  ++loopCount;
1248  }
1249  goalie->StartBlock ();
1250  origFilePos = osFTELL (file);
1251  }
1252 
1253  kkuint32 lastFrameNum = frameOffsets.size () - 1;
1254 
1255  // Reposition to beginning of last frame that is recorded in frameOfsets.
1256  FSeek (frameOffsets[lastFrameNum]);
1257 
1258  kkint64 nextFrameByteOffset = SkipToNextFrame ();
1259  while ((nextFrameByteOffset >= 0) && (goalie->NumBlockedThreads () < 1))
1260  {
1261  kkint32 fileSizeInScanLines = (lastFrameNum + 1) * frameHeight;
1262  if (fileSizeInScanLines > largestKnownScanLine)
1263  largestKnownScanLine = fileSizeInScanLines;
1264  frameOffsets.push_back (nextFrameByteOffset);
1265  ++lastFrameNum;
1266  changesMadeToIndexFile = true;
1267  nextFrameByteOffset = SkipToNextFrame ();
1268  }
1269 
1270  if (nextFrameByteOffset < 0)
1271  readToEOF = true;
1272  }
1273 
1274  if ((!cancelFlag) && changesMadeToIndexFile)
1276  }
1277 
1278  if (!cancelFlag)
1279  frameOffsetsLoaded = true;
1280 
1281  FSeek (origFilePos);
1282 
1283  goalie->EndBlock ();
1284 
1285  frameOffsetsBuildRunning = false;
1286 
1287  return;
1288 } /* BuildFrameOffsets */
void SaveIndexFile(std::vector< kkint64 > &frameOffsets)
void LoadIndexFile(bool &successful)
Call this method to Load the FrameOffsets and StartStop points from the index file.
__int32 kkint32
Definition: KKBaseTypes.h:88
kkint64 osFTELL(FILE *f)
Calls the appropriate 64 bit function for operating system.
Definition: OSservices.cpp:93
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
__int64 kkint64
Definition: KKBaseTypes.h:90
void DetermineFrameOffsetForFrame(kkuint32 frameNum)
Updates the byte offset for specified entry in &#39;frameOffsets&#39; that is currently flagged with "-1"...
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void osSleepMiliSecs(kkuint32 numMiliSecs)
bool frameOffsetsBuildRunning
Definition: ScannerFile.h:457
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkint32 FSeek(kkint64 filePos)
kkint32 NumBlockedThreads()
Returns the number of threads that are waiting to establish a lock on this instance.
Definition: GoalKeeper.cpp:579
virtual kkint64 SkipToNextFrame()=0
Skip to start of next frame returning back byte offset of that frame.
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
kkint64 byteOffsetScanLineZero
Definition: ScannerFile.h:392
bool KKLSC::ScannerFile::BuildFrameOffsetsRunning ( ) const
inline

Definition at line 89 of file ScannerFile.h.

References frameOffsetsBuildRunning.

bool frameOffsetsBuildRunning
Definition: ScannerFile.h:457
kkint64 KKLSC::ScannerFile::ByteOffsetScanLineZero ( ) const
inline

Byte offset of 1st scan line after header field.

Definition at line 90 of file ScannerFile.h.

References byteOffsetScanLineZero.

void ScannerFile::Close ( )
virtual

Definition at line 205 of file ScannerFile.cpp.

References file, frameBufferNextLine, indexFile, ioMode, ioWrite, opened, and WriteBufferFrame().

Referenced by ~ScannerFile().

206 {
207  if (opened && (ioMode == ScannerFile::ioWrite))
208  {
209  if (frameBufferNextLine > 0)
210  WriteBufferFrame ();
211  fclose (file);
212  file = NULL;
213 
214  if (indexFile)
215  {
216  indexFile->close ();
217  delete indexFile;
218  indexFile = NULL;
219  }
220 
221  opened = false;
222  }
223 }
std::ofstream * indexFile
Definition: ScannerFile.h:466
virtual void WriteBufferFrame()=0
Write the contents of &#39;frameBuffer&#39; to he end of the scanner file.
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
const uchar * ScannerFile::ConpensationTable ( Format  format)
static

Definition at line 816 of file ScannerFile.cpp.

References KKLSC::ScannerFileSimple::CompensationTable(), KKLSC::ScannerFile2BitEncoded::CompensationTable(), KKLSC::ScannerFile3BitEncoded::CompensationTable(), KKLSC::ScannerFile4BitEncoded::CompensationTable(), sf2BitEncoded, sf3BitEncoded, sf4BitEncoded, sfSimple, sfUnKnown, and sfZlib3BitEncoded.

817 {
818  const uchar* result = NULL;
819 
820  switch (format)
821  {
822  case Format::sfSimple:
824  break;
825 
828  break;
829 
832  break;
833 
836  break;
837 
838  case Format::sfUnKnown:
840  result = NULL;
841  break;
842  }
843  return result;
844 } /* ConpensationTable */
static const uchar * CompensationTable()
static const uchar * CompensationTable()
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
static const uchar * CompensationTable()
static const uchar * CompensationTable()
void ScannerFile::CreateGoalie ( )
protected

Definition at line 304 of file ScannerFile.cpp.

References KKB::GoalKeeper::Create(), fileName, goalie, KKB::operator+(), and KKB::osGetRootName().

Referenced by AddStartStopEntryToIndexFile(), BuildFrameOffsets(), DetermineFrameOffsetForFrame(), ScannerFile(), and UpdateFrameOffset().

305 {
306  if (!goalie)
307  {
308  GoalKeeper::Create ("ScannerFile-" + osGetRootName (fileName), goalie);
309  }
310 }
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
KKStr osGetRootName(const KKStr &fullFileName)
ScannerFilePtr ScannerFile::CreateScannerFile ( KKStr  _fileName,
RunLog _log 
)
static

Definition at line 787 of file ScannerFile.cpp.

References GuessFormatOfFile(), and sfUnKnown.

Referenced by GetScannerFileParameters().

790 {
791  Format format = GuessFormatOfFile (_fileName, _log);
792  if (format == Format::sfUnKnown)
793  return NULL;
794 
795  if (format == Format::sfSimple)
796  return new ScannerFileSimple (_fileName, _log);
797 
798  if (format == Format::sf2BitEncoded)
799  return new ScannerFile2BitEncoded (_fileName, _log);
800 
801  if (format == Format::sf3BitEncoded)
802  return new ScannerFile3BitEncoded (_fileName, _log);
803 
804  if (format == Format::sf4BitEncoded)
805  return new ScannerFile4BitEncoded (_fileName, _log);
806 
807  if (format == Format::sfZlib3BitEncoded)
808  return new ScannerFileZLib3BitEncoded (_fileName, _log);
809 
810  return NULL;
811 } /* CreateScanLineFile */
Implements a 2 bit Encoded format.
Implements a 3 bit Encoded format.
Implements a 4 bit Encoded format.
static Format GuessFormatOfFile(const KKStr &_fileName, RunLog &_log)
Implements Zlib compression on 3bit pixel data.
ScannerFilePtr ScannerFile::CreateScannerFileForOutput ( const KKStr _fileName,
Format  _format,
kkuint32  _pixelsPerScanLine,
kkuint32  _frameHeight,
RunLog _log 
)
static

Definition at line 848 of file ScannerFile.cpp.

References KKB::KKStr::Concat(), KKB::osFileExists(), and sfUnKnown.

Referenced by CreateScannerFileForOutput().

854 {
855  ScannerFilePtr scannerFile = NULL;
856  if (osFileExists (_fileName))
857  {
858  KKStr errMsg;
859  errMsg << "ScannerFile::CreateScannerFileForOutput ***ERROR*** ScannerFile[" << _fileName << "] already exists.";
860  _log.Level (-1) << endl << endl << errMsg << endl << endl;
861  }
862  else
863  {
864  switch (_format)
865  {
866  case Format::sfSimple:
867  scannerFile = new ScannerFileSimple (_fileName, _pixelsPerScanLine, _frameHeight, _log);
868  break;
869 
871  scannerFile = new ScannerFile2BitEncoded (_fileName, _pixelsPerScanLine, _frameHeight, _log);
872  break;
873 
875  scannerFile = new ScannerFile3BitEncoded (_fileName, _pixelsPerScanLine, _frameHeight, _log);
876  break;
877 
879  scannerFile = new ScannerFile4BitEncoded (_fileName, _pixelsPerScanLine, _frameHeight, _log);
880  break;
881 
883  scannerFile = new ScannerFileZLib3BitEncoded (_fileName, _pixelsPerScanLine, _frameHeight, _log);
884  break;
885 
886  case Format::sfUnKnown:
887  scannerFile = NULL;
888  break;
889 
890  }
891 
892  if (!scannerFile)
893  {
894  KKStr errMsg;
895  errMsg << "ScannerFile::CreateScannerFileForOutput ***ERROR*** Invalid ScannerFile Format specified.";
896  _log.Level (-1) << endl << endl << errMsg << endl << endl;
897  }
898  }
899 
900  return scannerFile;
901 } /* CreateScannerFileForOutput */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
Implements a 2 bit Encoded format.
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
Implements a 3 bit Encoded format.
bool osFileExists(const KKStr &_fileName)
Definition: OSservices.cpp:568
Implements a 4 bit Encoded format.
Implements Zlib compression on 3bit pixel data.
ScannerFilePtr ScannerFile::CreateScannerFileForOutput ( const KKStr _fileName,
const KKStr _formatStr,
kkuint32  _pixelsPerScanLine,
kkuint32  _frameHeight,
RunLog _log 
)
static

Definition at line 906 of file ScannerFile.cpp.

References CreateScannerFileForOutput(), ScannerFileFormatFromStr(), and sfUnKnown.

912 {
913  ScannerFilePtr scannerFile = NULL;
914 
915  Format format = ScannerFileFormatFromStr (_formatStr);
916  if (format == Format::sfUnKnown)
917  {
918  _log.Level (-1) << endl << endl << "ScannerFile::CreateScannerFileForOutput ***ERROR*** Invalid Format[" << _formatStr << "]" << endl << endl;
919  }
920  else
921  {
923  (_fileName, (Format)format, _pixelsPerScanLine, _frameHeight, _log);
924  }
925 
926  return scannerFile;
927 } /* CreateScannerFileForOutput */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
static Format ScannerFileFormatFromStr(const KKStr &fileFormatStr)
static ScannerFilePtr CreateScannerFileForOutput(const KKStr &_fileName, Format _format, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
void ScannerFile::DetermineFrameOffsetForFrame ( kkuint32  frameNum)
protected

Updates the byte offset for specified entry in 'frameOffsets' that is currently flagged with "-1".

This is meant to update entries in 'frameOffsets' that were flagged with '-1'. It will not work for frameNum == 0; this is okay since frameNum == 0 is updated when the scanner file is first opened. It is also assumed that the entry in frameOfsets just before 'frameNum' is already properly updated.

Definition at line 1178 of file ScannerFile.cpp.

References CreateGoalie(), KKB::GoalKeeper::EndBlock(), goalie, and KKB::GoalKeeper::StartBlock().

1179 {
1180  if ((frameNum < 1) || (frameNum >= frameOffsets.size ()))
1181  return;
1182 
1183  CreateGoalie ();
1184  goalie->StartBlock ();
1185 
1186  FSeek (frameOffsets[frameNum - 1]);
1187 
1188  frameOffsets[frameNum] = SkipToNextFrame ();
1189 
1190  goalie->EndBlock ();
1191 } /* DetermineFrameOffsetForFrame */
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkint32 FSeek(kkint64 filePos)
virtual kkint64 SkipToNextFrame()=0
Skip to start of next frame returning back byte offset of that frame.
bool KKLSC::ScannerFile::Eof ( ) const
inline

Definition at line 91 of file ScannerFile.h.

References eof.

91 {return eof;}
void ScannerFile::ExtractHeaderField ( const KKStr fieldName,
const KKStr fieldValue 
)
protected

Definition at line 1058 of file ScannerFile.cpp.

References KKB::KKStr::EqualIgnoreCase(), flatFieldEnabled, frameHeight, pixelsPerScanLine, scanRate, KKB::KKStr::ToBool(), KKB::KKStr::ToFloat(), KKB::KKStr::ToInt(), and KKB::KKStr::ToInt32().

Referenced by AddHeaderField(), and ReadHeader().

1061 {
1062  if (fieldName.EqualIgnoreCase ("FrameHeight"))
1063  {
1064  kkuint32 fieldValueUint = fieldValue.ToInt32 ();
1065  if ((fieldValueUint > 0) && (fieldValueUint < (1024 * 1024)))
1066  frameHeight = fieldValue.ToInt32 ();
1067  }
1068 
1069  else if (fieldName.EqualIgnoreCase ("PixelsPerScanLine"))
1070  pixelsPerScanLine = fieldValue.ToInt ();
1071 
1072  else if (fieldName.EqualIgnoreCase ("ScanRate"))
1073  scanRate = fieldValue.ToFloat ();
1074 
1075  else if (fieldName.EqualIgnoreCase ("FlatFieldCorrectionEnabled"))
1076  flatFieldEnabled = fieldValue.ToBool ();
1077 
1078 } /* ExtractHeaderField */
kkint32 ToInt() const
Definition: KKStr.cpp:3565
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkint32 ToInt32() const
Definition: KKStr.cpp:3587
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
float ToFloat() const
Definition: KKStr.cpp:3553
bool ToBool() const
Returns the bool equivalent of the string, ex &#39;Yes&#39; = true, &#39;No&#39; = false, &#39;True&#39; = true...
Definition: KKStr.cpp:3523
KKStr ScannerFile::FileFormatStr ( ) const

Definition at line 953 of file ScannerFile.cpp.

References FileFormat(), and ScannerFileFormatToStr().

Referenced by WriteHeader().

954 {
956 }
static const KKStr & ScannerFileFormatToStr(Format fileFormat)
virtual Format FileFormat() const
Definition: ScannerFile.h:78
const KKStr& KKLSC::ScannerFile::FileName ( ) const
inline

Definition at line 92 of file ScannerFile.h.

References fileName.

Referenced by KKLSC::ScannerFileEntry::GetOrCreateScannerFileEntry().

92 {return fileName;}
kkint64 KKLSC::ScannerFile::FileSizeInBytes ( ) const
inline

When opening a existing file represents size of file in Bytes.

Definition at line 93 of file ScannerFile.h.

References fileSizeInBytes.

bool KKLSC::ScannerFile::FlatFieldEnabled ( ) const
inline

Definition at line 94 of file ScannerFile.h.

References flatFieldEnabled.

94 {return flatFieldEnabled;}
kkuint32 KKLSC::ScannerFile::FlowMeterCounter ( ) const
inline

Definition at line 95 of file ScannerFile.h.

References flowMeterCounter.

95 {return flowMeterCounter;}
kkuint32 flowMeterCounter
Definition: ScannerFile.h:412
kkuint32 KKLSC::ScannerFile::FlowMeterCounterScanLine ( ) const
inline

Definition at line 96 of file ScannerFile.h.

References flowMeterCounterScanLine.

kkuint32 flowMeterCounterScanLine
Definition: ScannerFile.h:416
void ScannerFile::Flush ( )
virtual

Definition at line 227 of file ScannerFile.cpp.

References file.

228 {
229  if (file)
230  {
231  fflush (file);
232  }
233 }
uchar* KKLSC::ScannerFile::FrameBuffer ( ) const
inline

Definition at line 98 of file ScannerFile.h.

References frameBuffer.

98 {return frameBuffer;}
kkint64 KKLSC::ScannerFile::FrameBufferFileOffsetLast ( ) const
inline

Definition at line 100 of file ScannerFile.h.

References frameBufferFileOffsetLast.

kkint64 frameBufferFileOffsetLast
Definition: ScannerFile.h:427
kkint64 KKLSC::ScannerFile::FrameBufferFileOffsetNext ( ) const
inline

Definition at line 101 of file ScannerFile.h.

References frameBufferFileOffsetNext.

kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
kkint32 KKLSC::ScannerFile::FrameHeight ( ) const
inline

Definition at line 97 of file ScannerFile.h.

References frameHeight.

Referenced by GetScannerFileParameters().

97 {return frameHeight;}
kkuint32 frameHeight
Definition: ScannerFile.h:398
bool KKLSC::ScannerFile::FrameOffsetsLoaded ( ) const
inline

Definition at line 99 of file ScannerFile.h.

References frameOffsetsLoaded.

99 {return frameOffsetsLoaded;}
void ScannerFile::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.

The purpose of this method is to allow you to get whole frames at a time. Use the access method 'FrameBuffer' to get a pointer to the contents of the frame retrieved. The next call to 'GetNextLine' will return the first scan line in frame 'frameNum'.

Definition at line 500 of file ScannerFile.cpp.

References KKB::GoalKeeper::EndBlock(), frameBufferFileOffsetNext, frameBufferNextLine, frameBufferNumScanLines, frameHeight, frameNumCurLoaded, goalie, largestKnownScanLine, lastScanLine, nextScanLine, ReadBufferFrame(), KKB::GoalKeeper::StartBlock(), and UpdateFrameOffset().

Referenced by SkipToScanLine().

503 {
504  if (frameNum >= frameOffsets.size ())
505  {
506  found = false;
507  return;
508  }
509 
510  goalie->StartBlock ();
511  FSeek (frameOffsets[frameNum]);
512 
514 
516  frameBufferLastReadEof = (feof (file) != 0);
517  frameNumCurLoaded = frameNum;
518 
519  if (frameBufferNumScanLines > 1)
520  {
521  found = true;
522  nextScanLine = frameNum * frameHeight;
524  kkint32 lastScanLineInFrame = nextScanLine + frameBufferNumScanLines - 1;
525  if (lastScanLineInFrame > largestKnownScanLine)
526  largestKnownScanLine = lastScanLineInFrame;
527  UpdateFrameOffset (frameNum + 1, (nextScanLine + frameHeight), frameBufferFileOffsetNext);
528  }
529  else
530  {
531  // Only time I can think this would happen is while reading the last frame; meaning that the last frame
532  // in the file has exactly 'frameHeight' scan lines. This way when you read the next frame there are no scan lines.
533  cerr << endl << "ScannerFile::FrameRead ***ERROR*** No scan lines were loaded." << endl << endl;
534  }
535  goalie->EndBlock ();
536 } /* FrameRead */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
__int32 kkint32
Definition: KKBaseTypes.h:88
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
kkuint32 frameBufferNumScanLines
Definition: ScannerFile.h:445
virtual kkuint32 ReadBufferFrame()=0
Read in one Scanner File Frame return number of actual scan-lines read.
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkint32 FSeek(kkint64 filePos)
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
kkint32 ScannerFile::FSeek ( kkint64  filePos)
protected

Definition at line 1411 of file ScannerFile.cpp.

Referenced by BuildFrameOffsets().

1412 {
1413  kkint32 returnCd = 0;
1414  returnCd = osFSEEK (file, filePos, SEEK_SET);
1415  return returnCd;
1416 } /* FSeek */
__int32 kkint32
Definition: KKBaseTypes.h:88
int osFSEEK(FILE *f, kkint64 offset, int origin)
Definition: OSservices.cpp:104
kkint64 ScannerFile::GetFrameOffset ( kkuint32  frameNum)
protected

Definition at line 487 of file ScannerFile.cpp.

References KKB::GoalKeeper::EndBlock(), goalie, and KKB::GoalKeeper::StartBlock().

488 {
489  kkint64 offset = -1;
490  goalie->StartBlock ();
491  if (frameNum < frameOffsets.size ())
492  offset = frameOffsets[frameNum];
493  goalie->EndBlock ();
494  return offset;
495 } /* GetFrameOffset */
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
__int64 kkint64
Definition: KKBaseTypes.h:90
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
void ScannerFile::GetNextLine ( uchar lineBuff,
kkuint32  lineBuffSize,
kkuint32 lineSize,
kkuint32  colCount[],
kkuint32 pixelsInRow 
)
virtual

Definition at line 542 of file ScannerFile.cpp.

References KKB::GoalKeeper::EndBlock(), eof, frameBuffer, frameBufferFileOffsetNext, frameBufferLastReadEof, frameBufferNextLine, frameBufferNumScanLines, frameHeight, frameNumCurLoaded, goalie, largestKnownScanLine, lastScanLine, nextScanLine, pixelsPerScanLine, ReadBufferFrame(), KKB::GoalKeeper::StartBlock(), and UpdateFrameOffset().

548 {
549  if (eof)
550  return;
551 
553 
555  {
557  {
558  eof = true;
559  return;
560  }
561 
562  goalie->StartBlock ();
565  frameBufferLastReadEof = (feof (file) != 0);
566 
568  {
569  // We already are at EOF.
570  eof = true;
571  return;
572  }
573 
574  if (frameBufferNumScanLines > 0)
575  {
577  kkint32 lastScanLineInFrame = nextScanLine + frameBufferNumScanLines - 1;
578  if (lastScanLineInFrame > largestKnownScanLine)
579  largestKnownScanLine = lastScanLineInFrame;
581  }
582  else
583  {
584  // There were no scan lines loaded.
585  cerr << endl << "ScannerFile::GetNextLine ***ERROR*** No scan lines loaded." << endl << endl;
586  }
587  goalie->EndBlock ();
588  }
589 
590  kkuint32 frameBufferOffset = frameBufferNextLine * pixelsPerScanLine;
591 
592  lineSize= 0;
593  kkuint32 bytesToCopy = Min (lineBuffSize, pixelsPerScanLine);
594  for (kkuint32 x = 0; x < bytesToCopy; ++x)
595  {
596  uchar pixel = frameBuffer[frameBufferOffset];
597  lineBuff[x] = pixel;
598  if (pixel > 0)
599  {
600  colCount[x] += 1;
601  ++pixelsInRow;
602  }
603  ++lineSize;
604  ++frameBufferOffset;
605  }
606 
608  ++nextScanLine;
609 } /* GetNextLine */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
__int32 kkint32
Definition: KKBaseTypes.h:88
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
kkuint32 frameBufferNumScanLines
Definition: ScannerFile.h:445
virtual kkuint32 ReadBufferFrame()=0
Read in one Scanner File Frame return number of actual scan-lines read.
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
void ScannerFile::GetScannerFileParameters ( const KKStr _scannerFileName,
ScannerHeaderFieldsPtr _headerFields,
Format _scannerFileFormat,
kkint32 _frameHeight,
kkint32 _frameWidth,
float &  _scanRate,
bool &  _successful,
RunLog _log 
)
static

Retrieves statistics for a specified Scanner File.

Will read the header information for the specified scanner file to retrieve parameters.

Parameters
[in]_scannerFileNameName of scanner file that you want to retrieve parameters for.
[out]_headerFieldsCopy of header fields from Scanner File; caller will own them and be responsible for deleting them; if != NULL upon call previous instance will be deleted.
[out]_scannerFileFormatFormat of scanner file; ex: sf3BitEncoded.
[out]_frameHeightFrame height of source camera.
[out]_frameWidthWidth in pixels of scanner file.
[out]_scanRateScan lines/sec that imagery was acquired at.
[out]_successfulIndicates if successful in retrieving parameters.
[in,out]_logLog file.

Definition at line 754 of file ScannerFile.cpp.

References CreateScannerFile(), FileFormat(), FrameHeight(), HeaderFields(), PixelsPerScanLine(), KKLSC::ScannerHeaderFields::ScannerHeaderFields(), and ScanRate().

763 {
764  _successful = false;
765  ScannerFilePtr sf = CreateScannerFile (_scannerFileName, _log);
766  if (sf == NULL)
767  {
768  _log.Level (-1) << "Could not determine scanner file format." << endl;
769  return;
770  }
771 
772  delete _headerFields;
773  _headerFields = new ScannerHeaderFields (*(sf->HeaderFields ()));
774  _scannerFileFormat = sf->FileFormat ();
775  _frameHeight = sf->FrameHeight ();
776  _frameWidth = sf->PixelsPerScanLine ();
777  _scanRate = sf->ScanRate ();
778 
779  _successful = true;
780  delete sf;
781  sf = NULL;
782 } /* GetScannerFileParameters */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
float ScanRate() const
Definition: ScannerFile.h:109
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
static ScannerFilePtr CreateScannerFile(KKStr _fileName, RunLog &_log)
virtual Format FileFormat() const
Definition: ScannerFile.h:78
ScannerHeaderFieldsPtr HeaderFields() const
Definition: ScannerFile.h:102
Represents a list of header fields from a Scanner File.
kkuint32 PixelsPerScanLine() const
Definition: ScannerFile.h:108
kkint32 FrameHeight() const
Definition: ScannerFile.h:97
const KKStr & ScannerFile::GetValue ( const KKStr fieldName)

Definition at line 1107 of file ScannerFile.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), KKLSC::ScannerHeaderFields::GetValue(), and headerFields.

1108 {
1109  if (!headerFields)
1110  return KKStr::EmptyStr ();
1111  else
1112  return headerFields->GetValue (fieldName);
1113 }
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
const KKStr & GetValue(const KKStr &fieldName) const
float ScannerFile::GetValueFloat ( const KKStr fieldName)

Definition at line 1116 of file ScannerFile.cpp.

References KKLSC::ScannerHeaderFields::GetValueFloat(), and headerFields.

1117 {
1118  if (!headerFields)
1119  return 0.0f;
1120  else
1121  return headerFields->GetValueFloat (fieldName);
1122 }
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
float GetValueFloat(const KKStr &fieldName) const
ScannerFile::Format ScannerFile::GuessFormatOfFile ( const KKStr _fileName,
RunLog _log 
)
static

Definition at line 729 of file ScannerFile.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::EqualIgnoreCase(), KKB::KKStr::ExtractToken2(), KKB::KKStr::KKStr(), KKB::osFOPEN(), ReadHeaderOneLine(), ScannerFileFormatFromStr(), sfUnKnown, and KKB::KKStr::Str().

Referenced by CreateScannerFile().

732 {
733  // Will guess what file format by trying to open each one until one is considered valid.
734 
735  FILE* f = osFOPEN (_fileName.Str (), "rb");
736  if (!f)
737  return Format::sfUnKnown;
738 
739  bool endOfText = false;
740  KKStr ln (100);
741  ReadHeaderOneLine (f, endOfText, ln);
742  fclose (f);
743 
744  KKStr fieldName = ln.ExtractToken2 ("\t");
745  if (!fieldName.EqualIgnoreCase ("ScannerFile"))
746  return Format::sfUnKnown;
747 
748  KKStr scannerFileFormatStr = ln.ExtractToken2 ("\t");
749  return ScannerFileFormatFromStr (scannerFileFormatStr);
750 } /* GuessFormatOfFile */
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
static Format ScannerFileFormatFromStr(const KKStr &fileFormatStr)
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
static void ReadHeaderOneLine(FILE *f, bool &endOfText, KKStr &line)
ScannerHeaderFieldsPtr KKLSC::ScannerFile::HeaderFields ( ) const
inline

Definition at line 102 of file ScannerFile.h.

References headerFields.

Referenced by GetScannerFileParameters().

102 {return headerFields;}
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
void ScannerFile::InitiateWritting ( )

Definition at line 976 of file ScannerFile.cpp.

References AddHeaderField(), byteOffsetScanLineZero, file, frameBufferFileOffsetLast, frameBufferFileOffsetNext, frameHeight, lastScanLine, nextScanLine, KKB::osFTELL(), pixelsPerScanLine, scanRate, KKB::StrFormatDouble(), KKB::StrFormatInt(), UpdateFrameOffset(), and WriteHeader().

977 {
978  AddHeaderField ("ScanRate", StrFormatDouble (scanRate, "##0.00"));
979  AddHeaderField ("PixelsPerScanLine", StrFormatInt (pixelsPerScanLine, "#####0"));
980  AddHeaderField ("FrameHeight", StrFormatInt (frameHeight, "#####0"));
981  WriteHeader ();
982 
983  lastScanLine = 0;
984  nextScanLine = 0;
989 } /* InitiateWritting */
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
void WriteHeader()
This method is called before any scanner data is added to the file. It will write the header informat...
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
KKStr StrFormatDouble(double val, const char *mask)
Definition: KKStr.cpp:4819
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
void AddHeaderField(const KKStr &_fieldName, const KKStr &_fieldValue)
kkint64 byteOffsetScanLineZero
Definition: ScannerFile.h:392
kkint32 KKLSC::ScannerFile::LargestKnowmFrameNum ( ) const
inline

Definition at line 103 of file ScannerFile.h.

103 {return ((kkint32)frameOffsets.size () - 1);}
__int32 kkint32
Definition: KKBaseTypes.h:88
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkint32 KKLSC::ScannerFile::LargestKnownScanLine ( ) const
inline

Definition at line 104 of file ScannerFile.h.

References largestKnownScanLine.

104 {return largestKnownScanLine;}
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
kkint32 KKLSC::ScannerFile::LastScanLine ( ) const
inline

Last Scan-line read or written.

Definition at line 105 of file ScannerFile.h.

References lastScanLine.

void ScannerFile::LoadIndexFile ( bool &  successful)

Call this method to Load the FrameOffsets and StartStop points from the index file.

This method is also called from 'BuildFrameOffsets',

Definition at line 1323 of file ScannerFile.cpp.

References KKB::KKStr::Concat(), eof, KKB::KKStr::EqualIgnoreCase(), KKB::KKStr::ExtractToken2(), KKB::KKStr::ExtractTokenInt(), KKB::KKStr::ExtractTokenUint(), KKB::KKStr::ExtractTokenUint64(), fileName, indexFile, indexFileName, KKLSC::StartStopPoint::Invalid, largestKnownScanLine, KKB::KKStr::operator+(), KKB::KKStr::operator=(), KKB::osFOPEN(), KKB::osReadRestOfLine(), KKB::osRemoveExtension(), KKLSC::StartStopPoint::StartStopPoint(), KKB::KKStr::Str(), KKLSC::StartStopPoint::Type(), and UpdateFrameOffset().

Referenced by BuildFrameOffsets().

1324 {
1325  if (indexFile)
1326  {
1327  delete indexFile;
1328  indexFile = NULL;
1329  }
1330 
1332  FILE* f = osFOPEN (indexFileName.Str (), "r");
1333 
1334  if (!f)
1335  {
1336  log.Level (-1) << "LoadIndexFile IndexFile[" << indexFileName << "] does not exist." << endl;
1337  successful = false;
1338  return;
1339  }
1340 
1341  KKStrPtr ln = NULL;
1342 
1343  while (true)
1344  {
1345  bool eol = false;
1346  delete ln;
1347  ln = KKB::osReadRestOfLine (f, eof);
1348  if (eof) break;
1349  if (!ln) continue;
1350 
1351  KKStr lineName = ln->ExtractToken2 ("\t\n\r");
1352 
1353  if (lineName.EqualIgnoreCase ("IndexEntry"))
1354  {
1355  kkuint32 frameNum = ln->ExtractTokenUint ("\t\n\r");
1356  kkint32 scanLineNum = ln->ExtractTokenInt ("\t\n\r");
1357  kkuint64 byteOffset = ln->ExtractTokenUint64 ("\t\n\r");
1358  UpdateFrameOffset (frameNum, scanLineNum, byteOffset);
1359  if (scanLineNum > largestKnownScanLine)
1360  largestKnownScanLine = scanLineNum;
1361  }
1362 
1363  else if (lineName.EqualIgnoreCase ("ClearStartStopPoints"))
1364  {
1366  }
1367 
1368  else if (lineName.EqualIgnoreCase ("StartStopPoint"))
1369  {
1370  StartStopPointPtr entry = new StartStopPoint (*ln);
1372  {
1373  delete entry;
1374  entry = NULL;
1375  }
1376  else
1377  {
1378  startStopPoints.AddEntry (entry);
1379  }
1380  }
1381 
1382  else if (lineName.EqualIgnoreCase ("DeleteStartStopPoint"))
1383  {
1384  kkint32 scanLineNum = ln->ExtractTokenInt ("\n\t\r");
1385  startStopPoints.DeleteEntry (scanLineNum);
1386  }
1387  }
1388  delete ln;
1389  ln = NULL;
1390 
1391  fclose (f);
1392  successful = true;
1393 } /* LoadIndexFile */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr osRemoveExtension(const KKStr &_fullFileName)
__int32 kkint32
Definition: KKBaseTypes.h:88
KKB::KKStrPtr osReadRestOfLine(std::istream &in, bool &eof)
Extracts text up to and including the next end-of-line character and returns pointer to dynamical all...
kkuint32 ExtractTokenUint(const char *delStr)
Definition: KKStr.cpp:3141
void DeleteEntry(kkint32 _scanLineNum)
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
std::ofstream * indexFile
Definition: ScannerFile.h:466
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
StartStopType Type() const
unsigned __int64 kkuint64
Definition: KKBaseTypes.h:91
StartStopPointPtr AddEntry(kkint32 _scanLineNum, StartStopPoint::StartStopType _type)
kkint32 ExtractTokenInt(const char *delStr)
Definition: KKStr.cpp:3129
kkuint64 ExtractTokenUint64(const char *delStr)
Definition: KKStr.cpp:3153
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
Class that keeps track of parameter details of a single scanner file.
kkint32 ScannerFile::MemoryConsumedEstimated ( ) const
virtual

Definition at line 177 of file ScannerFile.cpp.

References file, frameBuffer, frameBufferSize, headerFields, indexFile, KKLSC::ScannerHeaderFields::MemoryConsumedEstimated(), KKLSC::ScannerFileEntry::MemoryConsumedEstimated(), and scannerFileEntry.

178 {
179  kkint32 mem = sizeof (*this) +
181  frameOffsets.size () * sizeof(kkint64) +
184 
185  if (file) mem += 2000;
187  if (frameBuffer) mem += frameBufferSize;
188  if (indexFile) mem += 2000;
189  if (scannerFileEntry) mem += scannerFileEntry->MemoryConsumedEstimated ();
190  return mem;
191 }
kkint32 MemoryConsumedEstimated() const
Definition: KKStr.cpp:766
__int32 kkint32
Definition: KKBaseTypes.h:88
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
__int64 kkint64
Definition: KKBaseTypes.h:90
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
std::ofstream * indexFile
Definition: ScannerFile.h:466
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkint32 MemoryConsumedEstimated() const
ScannerFileEntryPtr scannerFileEntry
Definition: ScannerFile.h:471
kkint32 KKLSC::ScannerFile::NextScanLine ( ) const
inline

Next scan-line to be read.

Definition at line 106 of file ScannerFile.h.

References nextScanLine.

void ScannerFile::Open ( const KKStr _fileName)
protected

Definition at line 265 of file ScannerFile.cpp.

References eof, file, fileName, fileSizeInBytes, indexFileName, ioMode, ioRead, opened, KKB::KKStr::operator+(), KKB::KKStr::operator=(), KKB::osFOPEN(), KKB::osGetFileSize(), KKB::osRemoveExtension(), and KKB::KKStr::Str().

Referenced by ScannerFile().

266 {
267  eof = false;
268  fileName = _fileName;
269  fileSizeInBytes = 0;
270 
271  if (ioMode == ioRead)
272  {
273  file = osFOPEN (fileName.Str (), "rb");
274  if (file)
276  }
277  else
278  {
279  file = osFOPEN (fileName.Str (), "wb");
280  indexFileName = osRemoveExtension (_fileName) + ".idx";
281  indexFile = new ofstream (indexFileName.Str ());
282  *indexFile << "IndexFile" << endl
283  << "ScannerFile" << "\t" << _fileName << endl
284  << "DateTime" << "\t" << osGetLocalDateTime () << endl;
285 
286  *indexFile << "IndexEntryFields" << "\t" << "FrameNum"
287  << "\t" << "ScanLineNum"
288  << "\t" << "ByteOffset"
289  << endl;
290  }
291 
292  if (file)
293  {
294  opened = true;
295  }
296  else
297  {
298  opened = false;
299  log.Level (-1) << endl << endl << "ScannerFile::Open ***ERROR*** Opening File[" << fileName << "]" << endl << endl;
300  }
301 } /* Open */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
kkint64 fileSizeInBytes
Definition: ScannerFile.h:396
KKStr osRemoveExtension(const KKStr &_fullFileName)
KKB::DateTime osGetLocalDateTime()
Returned the current local date and time.
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
std::ofstream * indexFile
Definition: ScannerFile.h:466
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
kkint64 osGetFileSize(const KKStr &fileName)
bool KKLSC::ScannerFile::Opened ( ) const
inline

Definition at line 107 of file ScannerFile.h.

References opened.

107 {return opened;}
kkuint32 KKLSC::ScannerFile::PixelsPerScanLine ( ) const
inline
virtual kkuint32 KKLSC::ScannerFile::ReadBufferFrame ( )
protectedpure virtual

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.

Implemented in KKLSC::ScannerFile4BitEncoded, KKLSC::ScannerFile3BitEncoded, KKLSC::ScannerFile2BitEncoded, and KKLSC::ScannerFileSimple.

Referenced by FrameRead(), GetNextLine(), and SkipNextLine().

void ScannerFile::ReadHeader ( )
protected

Definition at line 1037 of file ScannerFile.cpp.

References KKLSC::ScannerHeaderFields::Add(), KKB::KKStr::Concat(), ExtractHeaderField(), KKB::KKStr::ExtractToken2(), file, headerFields, KKB::KKStr::KKStr(), ReadHeaderOneLine(), and KKLSC::ScannerHeaderFields::ScannerHeaderFields().

Referenced by Reset(), and ScannerFile().

1038 {
1039  delete headerFields;
1041  bool endOfText = false;
1042  KKStr ln (100);
1043 
1044  ReadHeaderOneLine (file, endOfText, ln);
1045  while (!endOfText)
1046  {
1047  KKStr fieldName = ln.ExtractToken2 ("\t");
1048  KKStr fieldValue = ln.ExtractToken2 ("\t");
1049  headerFields->Add (fieldName, fieldValue);
1050  ExtractHeaderField (fieldName, fieldValue);
1051  ReadHeaderOneLine (file, endOfText, ln);
1052  }
1053 } /* ReadHeader */
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
void ExtractHeaderField(const KKStr &fieldName, const KKStr &fieldValue)
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
Represents a list of header fields from a Scanner File.
static void ReadHeaderOneLine(FILE *f, bool &endOfText, KKStr &line)
void Add(ScannerHeaderFieldsPtr fields)
void ScannerFile::ReadHeaderOneLine ( FILE *  f,
bool &  endOfText,
KKStr line 
)
staticprotected

Definition at line 1015 of file ScannerFile.cpp.

References KKB::KKStr::Append(), and KKB::KKStr::operator=().

Referenced by GuessFormatOfFile(), and ReadHeader().

1019 {
1020  char ch;
1021  line = "";
1022  endOfText = false;
1023 
1024  kkint32 bytesReturned = fread (&ch, 1, 1, f);
1025  while ((ch != 0) && (ch != '\n') && (bytesReturned > 0))
1026  {
1027  line.Append (ch);
1028  bytesReturned = fread (&ch, 1, 1, f);
1029  }
1030 
1031  if ((ch == 0) || (bytesReturned == 0))
1032  endOfText = true;
1033 } /* ReadHeaderOneLine */
__int32 kkint32
Definition: KKBaseTypes.h:88
void Append(const char *buff)
Definition: KKStr.cpp:1783
VectorFloatPtr ScannerFile::RecordRateByTimeIntervals ( int  intervalSecs)

Returns an array indication the record rate in bytes/sec for specified time-intervals.

Each element in the returned array will give the average number of bytes recorded for the time the corresponding time interval. Array element 0 starts at the beginning of the Scanner file and covers the number of scan lines required to account for 'intervalSecs' seconds.

Definition at line 402 of file ScannerFile.cpp.

References frameHeight, and scanRate.

403 {
404  float secsPerFrame = 1.0f;
405  if (scanRate > 0.0f)
406  secsPerFrame = frameHeight / scanRate;
407  else
408  secsPerFrame = frameHeight / 5000.0f; // Assume 5k ScanLines per second
409 
410  float totalTime = (float)(frameOffsets.size ()) * secsPerFrame;
411  int totalNumIntervals = (int)(0.5f + totalTime / (float)intervalSecs);
412 
413  VectorFloatPtr recordRates = new VectorFloat (totalNumIntervals, 0.0f);
414  int idx = 0;
415 
416  kkuint32 frameOffsetsIdx = 0;
417  kkint64 bytesThisFrame = frameOffsets[frameOffsetsIdx];
418  float frameOffsetsStartTime = 0;
419  float frameOffsetsEndTime = secsPerFrame;
420  float frameOffsetsRecRate = (float)bytesThisFrame / secsPerFrame;
421 
422  while (idx < totalNumIntervals)
423  {
424  float timeIntervalStartTime = (float)(idx * intervalSecs);
425  float timeIntervalEndTime = timeIntervalStartTime + (float)intervalSecs;
426 
427  float timeIntervalCurTime = timeIntervalStartTime;
428  while (timeIntervalCurTime < timeIntervalEndTime)
429  {
430  float nextMark = Min (timeIntervalEndTime, frameOffsetsEndTime);
431  float deltaTime = nextMark - timeIntervalCurTime;
432  (*recordRates)[idx] += frameOffsetsRecRate * (deltaTime / secsPerFrame);
433  timeIntervalCurTime = nextMark;
434 
435  ++frameOffsetsIdx;
436  frameOffsetsStartTime = frameOffsetsIdx * secsPerFrame;
437  frameOffsetsEndTime = frameOffsetsStartTime + (float)secsPerFrame;
438  if (frameOffsetsIdx < frameOffsets.size ())
439  bytesThisFrame = frameOffsets[frameOffsetsIdx] - frameOffsets[frameOffsetsIdx - 1];
440  else
441  bytesThisFrame = 0;
442  frameOffsetsRecRate = (float)bytesThisFrame / secsPerFrame;
443  }
444  ++idx;
445  }
446 
447  return recordRates;
448 } /* RecordRateByTimeIntervals */
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
__int64 kkint64
Definition: KKBaseTypes.h:90
std::vector< float > VectorFloat
Definition: KKBaseTypes.h:149
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
VectorFloat * VectorFloatPtr
Definition: KKBaseTypes.h:157
void ScannerFile::ReportInstrumentDataWord ( uchar  idNum,
kkuint32  scanLineNum,
WordFormat32Bits  dataWord 
)
protected
Todo:
Need to add code to do something the data word just posted.

Definition at line 1152 of file ScannerFile.cpp.

References flowMeterCounter, flowMeterCounterScanLine, and KKB::WordFormat32Bits::unsigned32BitInt.

Referenced by ReportTextMsg().

1156 {
1157  /**
1158  *@todo Need to add code to do something the data word just posted.
1159  */
1160 
1161  if (idNum == 0)
1162  {
1163  // This is the FlowMeterCounter field,
1165  flowMeterCounterScanLine = scanLineNum;
1166  }
1167 } /* ReportInstrumentDataWord */
kkuint32 flowMeterCounterScanLine
Definition: ScannerFile.h:416
kkuint32 flowMeterCounter
Definition: ScannerFile.h:412
void ScannerFile::ReportTextMsg ( const char *  textBuff,
kkint32  numTextBytes 
)
protected

Text messages that are embedded in a scanner file can be reported here.

If a derived class/format of 'ScannerFile' contains Text messages, that class would call this method with the embedded text message. Possible uses of this would be instrumentation data such as that produced by CTD.

Todo:
Need to add code to do something with the textBuff message.

Definition at line 1126 of file ScannerFile.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::ExtractToken2(), KKB::KKStr::ExtractTokenInt(), KKB::KKStr::ExtractTokenUint(), KKB::KKStr::KKStr(), ReportInstrumentDataWord(), KKB::KKStr::StartsWith(), and KKB::WordFormat32Bits::WordFormat32Bits().

1129 {
1130  KKStr s (textBuff, 0, numTextBytes - 1);
1131  if (s.StartsWith ("InstrumentDataWord\t", true))
1132  {
1133  s.ExtractToken2 ("\t");
1134  kkint32 idNum = s.ExtractTokenInt ("\t");
1135  kkuint32 scanLineNum = s.ExtractTokenUint ("\t");
1136  kkuint32 dataWord = s.ExtractTokenUint ("\t");
1137  WordFormat32Bits w (dataWord);
1138  ReportInstrumentDataWord (idNum, scanLineNum, w);
1139  }
1140  else
1141  {
1142  /**
1143  *@todo Need to add code to do something with the textBuff message.
1144  */
1145  }
1146 } /* ReportTextMsg */
__int32 kkint32
Definition: KKBaseTypes.h:88
Structure used to break 32 bit word into different formats;.
Definition: KKBaseTypes.h:283
void ReportInstrumentDataWord(uchar idNum, kkuint32 scanLineNum, WordFormat32Bits dataWord)
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void ScannerFile::Reset ( )

Definition at line 246 of file ScannerFile.cpp.

References eof, file, frameBufferFileOffsetLast, frameBufferFileOffsetNext, frameBufferLastReadEof, lastScanLine, nextScanLine, opened, KKB::osFTELL(), and ReadHeader().

247 {
248  if (!opened)
249  return;
250 
251  eof = false;
252  rewind (file);
253  ReadHeader ();
254 
255  frameBufferLastReadEof = false;
256  lastScanLine = 0;
257  nextScanLine = 0;
260 } /* Reset */
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
void ScannerFile::SaveIndexFile ( std::vector< kkint64 > &  frameOffsets)
protected

Definition at line 1292 of file ScannerFile.cpp.

References fileName, indexFileName, KKB::KKStr::operator+(), KKB::KKStr::operator=(), and KKB::osRemoveExtension().

1293 {
1295  ofstream f (indexFileName.Str ());
1296  f << "IndexFile" << endl
1297  << "ScannerFile" << "\t" << fileName << endl
1298  << "DateTime" << "\t" << osGetLocalDateTime () << endl;
1299 
1300  f << "IndexEntryFields" << "\t" << "FrameNum"
1301  << "\t" << "ScanLineNum"
1302  << "\t" << "ByteOffset"
1303  << endl;
1304 
1305  for (kkuint32 frameNum = 0; frameNum < frameOffsets.size (); ++frameNum)
1306  {
1307  f << "IndexEntry" << "\t" << frameNum << "\t" << (frameNum * frameHeight) << "\t" << frameOffsets[frameNum] << endl;
1308  }
1309 
1310  StartStopPointList::const_iterator idx;
1311  for (idx = startStopPoints.begin (); idx != startStopPoints.end (); ++idx)
1312  {
1313  StartStopPointPtr ssp = *idx;
1314  f << "StartStopPoint" << "\t" << ssp->ToTabDelStr () << endl;
1315  }
1316 
1317  f.close ();
1318 } /* SaveIndexFile */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
KKStr osRemoveExtension(const KKStr &_fullFileName)
KKB::DateTime osGetLocalDateTime()
Returned the current local date and time.
KKStr ToTabDelStr() const
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
kkuint32 frameHeight
Definition: ScannerFile.h:398
Class that keeps track of parameter details of a single scanner file.
ScannerFile::Format ScannerFile::ScannerFileFormatFromStr ( const KKStr fileFormatStr)
static

Definition at line 961 of file ScannerFile.cpp.

References KKB::KKStr::EqualIgnoreCase(), fileFormatOptions, and sfUnKnown.

Referenced by CreateScannerFileForOutput(), and GuessFormatOfFile().

962 {
963  kkint32 x = 0;
964  while (x < (kkint32)Format::sfUnKnown)
965  {
966  if (fileFormatStr.EqualIgnoreCase (fileFormatOptions[x]))
967  return (Format)x;
968  ++x;
969  }
970 
971  return Format::sfUnKnown;
972 } /* ScannerFileFormatFromStr */
__int32 kkint32
Definition: KKBaseTypes.h:88
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
static const KKStr fileFormatOptions[]
Definition: ScannerFile.h:363
const KKStr & ScannerFile::ScannerFileFormatToStr ( Format  fileFormat)
static

Definition at line 943 of file ScannerFile.cpp.

References fileFormatOptions, and sfUnKnown.

Referenced by FileFormatStr().

944 {
945  if (((int)fileFormat < 0) || (fileFormat >= Format::sfUnKnown))
947  else
948  return fileFormatOptions[(int)fileFormat];
949 } /* ScannerFileFormatToStr */
static const KKStr fileFormatOptions[]
Definition: ScannerFile.h:363
float KKLSC::ScannerFile::ScanRate ( ) const
inline

Definition at line 109 of file ScannerFile.h.

References scanRate.

Referenced by KKLSC::ScannerFileEntry::GetOrCreateScannerFileEntry(), and GetScannerFileParameters().

109 {return scanRate;}
void ScannerFile::ScanRate ( float  _scanRate)
virtual

Reimplemented in KKLSC::ScannerFile4BitEncoded, KKLSC::ScannerFile3BitEncoded, KKLSC::ScannerFile2BitEncoded, and KKLSC::ScannerFileZLib3BitEncoded.

Definition at line 238 of file ScannerFile.cpp.

References scanRate.

239 {
240  scanRate = _scanRate;
241 }
void ScannerFile::SkipBytesForward ( kkuint32  numBytes)
protected

Definition at line 1398 of file ScannerFile.cpp.

1399 {
1400  kkint32 returnCd = osFSEEK (file, numBytes, SEEK_CUR);
1401  if (returnCd != 0)
1402  {
1403  log.Level (-1) << "ScannerFile::SkipBytesForward ReturnCd = " << returnCd << endl;
1404  }
1405 } /* SkipBytesForward */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
int osFSEEK(FILE *f, kkint64 offset, int origin)
Definition: OSservices.cpp:104
void ScannerFile::SkipNextLine ( )

Definition at line 615 of file ScannerFile.cpp.

References KKB::GoalKeeper::EndBlock(), eof, frameBufferFileOffsetNext, frameBufferLastReadEof, frameBufferNextLine, frameBufferNumScanLines, frameHeight, frameNumCurLoaded, goalie, largestKnownScanLine, lastScanLine, nextScanLine, ReadBufferFrame(), KKB::GoalKeeper::StartBlock(), and UpdateFrameOffset().

616 {
617  if (eof)
618  return;
619 
621 
623  {
625  {
626  eof = true;
627  return;
628  }
629 
630  goalie->StartBlock ();
633  frameBufferLastReadEof = (feof (file) != 0);
634 
635  if (frameBufferNumScanLines > 0)
636  {
638  kkint32 lastScanLineInFrame = nextScanLine + frameBufferNumScanLines - 1;
639  if (lastScanLineInFrame > largestKnownScanLine)
640  largestKnownScanLine = lastScanLineInFrame;
642  }
643  else
644  {
645  cerr << endl << "ScannerFile::SkipNextLine ***ERROR*** No scan lines were loaded." << endl << endl;
646  }
647  goalie->EndBlock ();
648  }
649 
651  ++nextScanLine;
652 } /* SkipNextLine */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
__int32 kkint32
Definition: KKBaseTypes.h:88
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
kkuint32 frameBufferNumScanLines
Definition: ScannerFile.h:445
virtual kkuint32 ReadBufferFrame()=0
Read in one Scanner File Frame return number of actual scan-lines read.
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
virtual kkint64 KKLSC::ScannerFile::SkipToNextFrame ( )
protectedpure virtual

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 .....

Implemented in KKLSC::ScannerFile4BitEncoded, KKLSC::ScannerFile3BitEncoded, KKLSC::ScannerFile2BitEncoded, and KKLSC::ScannerFileSimple.

Referenced by BuildFrameOffsets().

void ScannerFile::SkipToScanLine ( kkint32  scanLine)

Repositions the file such that the next call to 'GetNextLine' returns the 'scanLine' scan-line.

This method depends on the table'frameOffsets'; it will compute the frame number from the scan line and use the appropriate entry in 'frameOffsets' to start reading from the beginning of the frame that contains 'scanLine'. If you select a 'scanLine' that is beyond the known number of scan lines in the scanner file (see largestKnownScanLine) the eof flag will be set to 'true'.

Parameters
[in]scanLineScan line to skip to so that the next call to 'GetNextLine' retrieves it.

Definition at line 682 of file ScannerFile.cpp.

References eof, frameBufferNextLine, frameBufferNumScanLines, frameHeight, frameNumCurLoaded, FrameRead(), lastScanLine, and nextScanLine.

683 {
684  kkuint32 frameNum = scanLine / frameHeight;
685  if (frameNum >= frameOffsets.size ())
686  frameNum = frameOffsets.size () - 1;
687 
688  if (frameNum != frameNumCurLoaded)
689  {
690  bool found = false;
691  FrameRead (frameNum, found);
692  if (!found)
693  {
694  eof = true;
695  return;
696  }
697  }
698 
699  frameBufferNextLine = scanLine % frameHeight;
701  {
702  // I believe that the only way that this could happen is if 'frameNum' is the last frame in the file.
703  cerr << endl << endl << "ScannerFile::SkipToScanLine ***ERROR*** FrameBufer is short scan lines." << endl << endl;
704  }
705 
706  lastScanLine = scanLine - 1;
707  nextScanLine = scanLine;
708 } /* SkipToScanLine */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
kkuint32 frameBufferNumScanLines
Definition: ScannerFile.h:445
void FrameRead(kkuint32 frameNum, bool &found)
Read into frame buffer &#39;frameNum&#39; and reposition so that next scan-line will be the 1st line in the f...
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
void ScannerFile::StartStopPointDelete ( kkint32  _scanLineNum)

Definition at line 371 of file ScannerFile.cpp.

References AddStartStopEntryToIndexFile(), and KKLSC::StartStopPoint::StopPoint.

372 {
373  startStopPoints.DeleteEntry (_scanLineNum);
375 }
void DeleteEntry(kkint32 _scanLineNum)
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
void AddStartStopEntryToIndexFile(kkint32 scanLineNum, StartStopPoint::StartStopType type, bool deleteEntry)
StartStopPointPtr ScannerFile::StartStopPointNearestEntry ( kkint32  _scanLineNum)

Definition at line 380 of file ScannerFile.cpp.

381 {
382  return startStopPoints.NearestEntry (_scanLineNum);
383 }
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
StartStopPointPtr NearestEntry(kkint32 _scanLineNum) const
StartStopPointPtr ScannerFile::StartStopPointPrevEntry ( kkint32  _scanLineNum)

Definition at line 387 of file ScannerFile.cpp.

388 {
389  return startStopPoints.PrevEntry (_scanLineNum);
390 }
StartStopPointPtr PrevEntry(kkint32 _scanLineNum) const
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
const StartStopPointList& KKLSC::ScannerFile::StartStopPoints ( ) const
inline

Definition at line 134 of file ScannerFile.h.

134 {return startStopPoints;}
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
StartStopPointPtr ScannerFile::StartStopPointSuccEntry ( kkint32  _scanLineNum)

Definition at line 394 of file ScannerFile.cpp.

395 {
396  return startStopPoints.SuccEntry (_scanLineNum);
397 }
StartStopPointList startStopPoints
Definition: ScannerFile.h:474
StartStopPointPtr SuccEntry(kkint32 _scanLineNum) const
void ScannerFile::UpdateFrameOffset ( kkuint32  frameNum,
kkuint32  scanLineNum,
kkint64  byteOffset 
)
protected

Definition at line 456 of file ScannerFile.cpp.

References CreateGoalie(), KKB::GoalKeeper::EndBlock(), goalie, and KKB::GoalKeeper::StartBlock().

Referenced by FrameRead(), GetNextLine(), InitiateWritting(), LoadIndexFile(), ScannerFile(), SkipNextLine(), and WriteScanLine().

460 {
461  CreateGoalie ();
462  goalie->StartBlock ();
463 
464  if (frameNum == frameOffsets.size ())
465  {
466  frameOffsets.push_back (byteOffset);
467  }
468  else if (frameNum < frameOffsets.size ())
469  {
470  frameOffsets[frameNum] = byteOffset;
471  }
472  else
473  {
474  while (frameOffsets.size () < frameNum)
475  frameOffsets.push_back (-1);
476  frameOffsets.push_back (byteOffset);
477  }
478 
479  if (indexFile)
480  *indexFile << "IndexEntry" << "\t" << frameNum << "\t" << scanLineNum << "\t" << byteOffset << endl;
481 
482  goalie->EndBlock ();
483 } /* UpdateFrameOffset */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
std::ofstream * indexFile
Definition: ScannerFile.h:466
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
std::vector< kkint64 > frameOffsets
Definition: ScannerFile.h:454
virtual void KKLSC::ScannerFile::WriteBufferFrame ( )
protectedpure virtual

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.

Implemented in KKLSC::ScannerFile4BitEncoded, KKLSC::ScannerFile3BitEncoded, KKLSC::ScannerFile2BitEncoded, and KKLSC::ScannerFileSimple.

Referenced by Close(), and WriteScanLine().

void ScannerFile::WriteHeader ( )
protected

This method is called before any scanner data is added to the file. It will write the header information for the file.

Definition at line 993 of file ScannerFile.cpp.

References KKB::KKStr::Concat(), FileFormatStr(), headerDataWritten, KKB::KKStr::KKStr(), and KKB::KKStr::operator=().

Referenced by InitiateWritting().

994 {
995  KKStr ln (100);
996  ln << "ScannerFile" << "\t" << FileFormatStr () << "\n";
997  fwrite (ln.Str (), 1, ln.Len (), file);
998 
999  ScannerHeaderFields::const_iterator idx;
1000  for (idx = headerFields->begin (); idx != headerFields->end (); ++idx)
1001  {
1002  ln = "";
1003  ln << idx->first << "\t" << idx->second << "\n";
1004  fwrite (ln.Str (), 1, ln.Len (), file);
1005  }
1006 
1007  // Write End of text Marker
1008  char ch = 0;
1009  fwrite (&ch, 1, 1, file);
1010  headerDataWritten = true;
1011 } /* WriteHeader */
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
KKStr FileFormatStr() const
void ScannerFile::WriteInstrumentDataWord ( uchar  idNum,
kkuint32  scanLineNum,
WordFormat32Bits  dataWord 
)
virtual

Writes a 32 bit number into the Scanner File Stream at current location.

Adds Instrument data to the underlying Scanner files as text.

Parameters
[in]idNumnNumber that identifies Instrument data, ex: 0 is reserved for Flow Meter Count.
[in]scanLineNumScan-line that 'dataWord' occurred at.
[in]dataWord32 bit number being written.

Definition at line 715 of file ScannerFile.cpp.

References KKB::KKStr::Concat(), KKB::KKStr::KKStr(), KKB::KKStr::Len(), KKB::KKStr::Str(), KKB::WordFormat32Bits::unsigned32BitInt, and WriteTextBlock().

719 {
720  KKStr s (100);
721  s << "InstrumentDataWord" << "\t" << (int)idNum << "\t" << scanLineNum << "\t" << dataWord.unsigned32BitInt;
722  WriteTextBlock ((const uchar*)s.Str (), s.Len ());
723 } /* WriteInstrumentDataWord */
virtual void WriteTextBlock(const uchar *txtBlock, kkuint32 txtBlockLen)=0
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
void ScannerFile::WriteScanLine ( const uchar buffer,
kkuint32  bufferLen 
)
virtual

Definition at line 657 of file ScannerFile.cpp.

References frameBufferFileOffsetNext, frameBufferNextLine, frameHeight, frameNumCurLoaded, lastScanLine, nextScanLine, pixelsPerScanLine, UpdateFrameOffset(), and WriteBufferFrame().

660 {
662 
664  {
665  WriteBufferFrame ();
669  }
670 
672  kkuint32 bytesToCopy = Min (bufferLen, pixelsPerScanLine);
673  memcpy (frameBuffer + byteOffset, buffer, bytesToCopy);
674 
675  ++nextScanLine;
677 } /* WriteScanLine */
kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
virtual void WriteBufferFrame()=0
Write the contents of &#39;frameBuffer&#39; to he end of the scanner file.
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
kkuint32 frameHeight
Definition: ScannerFile.h:398
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
kkint32 Min(kkint32 x1, kkint32 x2)
Definition: Raster.cpp:229
virtual void KKLSC::ScannerFile::WriteTextBlock ( const uchar txtBlock,
kkuint32  txtBlockLen 
)
pure virtual

Member Data Documentation

kkint64 KKLSC::ScannerFile::byteOffsetScanLineZero
protected

Byte offset of 1st scan line after the header fields.

Definition at line 392 of file ScannerFile.h.

Referenced by ByteOffsetScanLineZero(), InitiateWritting(), and ScannerFile().

bool KKLSC::ScannerFile::eof
protected
const KKStr ScannerFile::fileFormatOptions
staticprotected
Initial value:
= {"Simple",
"2BitEncoded",
"3BitEncoded",
"4BitEncoded",
"Zlib3BitEncoded",
"UnKnown"
}

Definition at line 363 of file ScannerFile.h.

Referenced by ScannerFileFormatFromStr(), and ScannerFileFormatToStr().

KKStr KKLSC::ScannerFile::fileName
protected

Definition at line 395 of file ScannerFile.h.

Referenced by CreateGoalie(), FileName(), LoadIndexFile(), Open(), SaveIndexFile(), and ScannerFile().

bool KKLSC::ScannerFile::flatFieldEnabled
protected

Indicates if Flat-Field-Correction was enabled when file recorded.

Definition at line 397 of file ScannerFile.h.

Referenced by ExtractHeaderField(), FlatFieldEnabled(), and ScannerFile().

kkuint32 KKLSC::ScannerFile::flowMeterCounter
protected

Updated while reading Scanner Files; whenever InstrumentID == 0 is read this field will be updated along with 'flowMeterCounterScanLineNum'.

Definition at line 412 of file ScannerFile.h.

Referenced by FlowMeterCounter(), ReportInstrumentDataWord(), and ScannerFile().

kkuint32 KKLSC::ScannerFile::flowMeterCounterScanLine
protected

Represents the scan line that 'flowMeterCounter' was last updated for while reading a Scanner File.

Definition at line 416 of file ScannerFile.h.

Referenced by FlowMeterCounterScanLine(), ReportInstrumentDataWord(), and ScannerFile().

uchar* KKLSC::ScannerFile::frameBuffer
protected
bool KKLSC::ScannerFile::frameBufferLastReadEof
protected

Indicates that the last call to 'ReadBufferFrame' encountered * feof (file) which means the next call to 'ReadBufferFrame' should return eof. *

Definition at line 431 of file ScannerFile.h.

Referenced by GetNextLine(), Reset(), ScannerFile(), and SkipNextLine().

kkuint32 KKLSC::ScannerFile::frameBufferLen
protected

Represents the number of bytes being used in 'frameBuffer'; when data is being * read from a Scanner file you would start reading from this point in the buffer and * while data is be written it will be added to 'frameBuffer' and this variable will * be incremented to reflect the new amount occupied. *

Definition at line 435 of file ScannerFile.h.

Referenced by AllocateFrameBuffer(), KKLSC::ScannerFileSimple::ReadBufferFrame(), KKLSC::ScannerFile2BitEncoded::ReadBufferFrame(), KKLSC::ScannerFile3BitEncoded::ReadBufferFrame(), KKLSC::ScannerFile4BitEncoded::ReadBufferFrame(), and ScannerFile().

kkuint32 KKLSC::ScannerFile::frameBufferNumScanLines
protected

The Number of scan-lines that the last call to 'ReadBufferFrame' read.

Definition at line 445 of file ScannerFile.h.

Referenced by FrameRead(), GetNextLine(), ScannerFile(), SkipNextLine(), and SkipToScanLine().

kkuint32 KKLSC::ScannerFile::frameBufferSize
protected

The number of bytes that were allocated to 'frameBuffer'; 'frameBufferLen' * should never exceed this value. *

Definition at line 447 of file ScannerFile.h.

Referenced by AllocateFrameBuffer(), MemoryConsumedEstimated(), ScannerFile(), KKLSC::ScannerFileSimple::SkipToNextFrame(), and KKLSC::ScannerFileSimple::WriteBufferFrame().

kkuint32 KKLSC::ScannerFile::frameHeight
protected

Represents the number of scam lines per frame; as stored in the Scanner File.

Definition at line 398 of file ScannerFile.h.

Referenced by AllocateFrameBuffer(), BuildFrameOffsets(), ExtractHeaderField(), FrameHeight(), FrameRead(), GetNextLine(), InitiateWritting(), RecordRateByTimeIntervals(), ScannerFile(), SkipNextLine(), SkipToScanLine(), and WriteScanLine().

kkuint32 KKLSC::ScannerFile::frameNumCurLoaded
protected

Indicates the frame that is currently loaded in 'frameBuffer'.

Definition at line 451 of file ScannerFile.h.

Referenced by FrameRead(), GetNextLine(), ScannerFile(), SkipNextLine(), SkipToScanLine(), and WriteScanLine().

std::vector<kkint64> KKLSC::ScannerFile::frameOffsets
protected

Will maintain a list of byte offsets; each entry will be the byte offset for * its corresponding frame *

Definition at line 454 of file ScannerFile.h.

bool KKLSC::ScannerFile::frameOffsetsBuildRunning
protected

Definition at line 457 of file ScannerFile.h.

Referenced by BuildFrameOffsets(), BuildFrameOffsetsRunning(), and ScannerFile().

bool KKLSC::ScannerFile::frameOffsetsLoaded
protected

Indicates if the entire scannerFile has been scanned and all entries in * frameOffsets are updated. Can only be set to 'true' upon successful completion * of 'BuildFrameOffsets'. *

Definition at line 459 of file ScannerFile.h.

Referenced by BuildFrameOffsets(), FrameOffsetsLoaded(), and ScannerFile().

GoalKeeperPtr KKLSC::ScannerFile::goalie
protected
bool KKLSC::ScannerFile::headerDataWritten
protected

Sets to true after all Header data has been written.

Definition at line 399 of file ScannerFile.h.

Referenced by ScannerFile(), and WriteHeader().

ScannerHeaderFieldsPtr KKLSC::ScannerFile::headerFields
protected
std::ofstream* KKLSC::ScannerFile::indexFile
protected

When writing a Scanner file will also write out a ByteOffset index file to aid future access to this file.

Definition at line 466 of file ScannerFile.h.

Referenced by AddStartStopEntryToIndexFile(), Close(), LoadIndexFile(), MemoryConsumedEstimated(), and ScannerFile().

KKStr KKLSC::ScannerFile::indexFileName
protected
IOMode KKLSC::ScannerFile::ioMode
protected

Definition at line 401 of file ScannerFile.h.

Referenced by Close(), Open(), and ScannerFile().

kkint32 KKLSC::ScannerFile::largestKnownScanLine
protected
kkint32 KKLSC::ScannerFile::lastScanLine
protected

The last scan-line read.

Definition at line 403 of file ScannerFile.h.

Referenced by FrameRead(), GetNextLine(), InitiateWritting(), LastScanLine(), Reset(), ScannerFile(), SkipNextLine(), SkipToScanLine(), and WriteScanLine().

RunLog& KKLSC::ScannerFile::log
protected

Definition at line 404 of file ScannerFile.h.

Referenced by ScannerFile().

kkint32 KKLSC::ScannerFile::nextScanLine
protected

The next scan-line that will be returned by 'GetNextLine'.

Definition at line 405 of file ScannerFile.h.

Referenced by FrameRead(), GetNextLine(), InitiateWritting(), NextScanLine(), Reset(), ScannerFile(), SkipNextLine(), SkipToScanLine(), and WriteScanLine().

bool KKLSC::ScannerFile::opened
protected

Definition at line 406 of file ScannerFile.h.

Referenced by Close(), Open(), Opened(), Reset(), ScannerFile(), and ~ScannerFile().

ScannerFileEntryPtr KKLSC::ScannerFile::scannerFileEntry
protected

Definition at line 471 of file ScannerFile.h.

Referenced by MemoryConsumedEstimated(), and ScannerFile().

float KKLSC::ScannerFile::scanRate
protected

Scan-Lines Per Second.

Definition at line 408 of file ScannerFile.h.

Referenced by ExtractHeaderField(), InitiateWritting(), RecordRateByTimeIntervals(), ScannerFile(), and ScanRate().

StartStopPointList KKLSC::ScannerFile::startStopPoints
protected

Points where he user does or does-not want to process(Count) are tacked in this data structure. Each entry is flagged as a Start or Stop point. These entries are saved in the IndexFile along with the frame offsets table.

Definition at line 474 of file ScannerFile.h.


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