KSquare Utilities
ScannerFile.cpp
Go to the documentation of this file.
1 #include "FirstIncludes.h"
2 #include <stdio.h>
3 #include <errno.h>
4 #include <string.h>
5 #include <ctype.h>
6 
7 #include <iostream>
8 #include <fstream>
9 #include <map>
10 #include <vector>
11 
12 #include "MemoryDebug.h"
13 
14 using namespace std;
15 
16 
17 #include "KKBaseTypes.h"
18 #include "OSservices.h"
19 #include "RunLog.h"
20 #include "KKStr.h"
21 using namespace KKB;
22 
23 
24 #include "ScannerFile.h"
25 
27 #include "ScannerFileSimple.h"
32 #include "ScannerFileEntry.h"
33 #include "StartStopPoint.h"
34 #include "Variables.h"
35 using namespace KKLSC;
36 
37 
38 
39 /** Constructor for opening file for reading */
40 ScannerFile::ScannerFile (const KKStr& _fileName,
41  RunLog& _log
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),
78  scannerFileEntry (NULL),
80 {
82 
85 
87  if (opened)
88  {
89  ReadHeader ();
91  if (frameHeight == 0)
97  }
98 }
99 
100 
101 
102 
103 /** Constructor for opening file for Writing */
104 ScannerFile::ScannerFile (const KKStr& _fileName,
105  kkuint32 _pixelsPerScanLine,
106  kkuint32 _frameHeight,
107  RunLog& _log
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),
145  scannerFileEntry (NULL),
146  startStopPoints ()
147 {
151 
153  if (opened)
154  {
157  //UpdateFrameOffset (0, 0, byteOffsetScanLineZero);
158  }
159 }
160 
161 
162 
164 {
165  if (opened)
166  Close ();
167 
168  delete headerFields; headerFields = NULL;
169  delete frameBuffer; frameBuffer = NULL;
170 
172  goalie = NULL;
173 }
174 
175 
176 
178 {
179  kkint32 mem = sizeof (*this) +
180  fileName.MemoryConsumedEstimated () +
181  frameOffsets.size () * sizeof(kkint64) +
182  indexFileName.MemoryConsumedEstimated () +
183  startStopPoints.MemoryConsumedEstimated ();
184 
185  if (file) mem += 2000;
187  if (frameBuffer) mem += frameBufferSize;
188  if (indexFile) mem += 2000;
190  return mem;
191 }
192 
193 
194 
196 {
197  delete frameBuffer; frameBuffer = NULL;
199  frameBufferLen = 0;
201 }
202 
203 
204 
206 {
207  if (opened && (ioMode == ScannerFile::ioWrite))
208  {
209  if (frameBufferNextLine > 0)
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 }
224 
225 
226 
228 {
229  if (file)
230  {
231  fflush (file);
232  }
233 }
234 
235 
236 
237 
238 void ScannerFile::ScanRate (float _scanRate)
239 {
240  scanRate = _scanRate;
241 }
242 
243 
244 
245 
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 */
261 
262 
263 
264 
265 void ScannerFile::Open (const KKStr& _fileName)
266 {
267  eof = false;
268  fileName = _fileName;
269  fileSizeInBytes = 0;
270 
271  if (ioMode == ioRead)
272  {
274  if (file)
276  }
277  else
278  {
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 */
302 
303 
305 {
306  if (!goalie)
307  {
309  }
310 }
311 
312 
313 
316  bool deleteEntry
317  )
318 {
320  return;
321 
323 
324  bool clearToUpdate = false;
325  while (!clearToUpdate)
326  {
328  if (indexFile != NULL)
329  {
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;
350 }
351 
352 
353 
354 
355 void ScannerFile::AddStartPoint (kkint32 _scanLineNum)
356 {
357  startStopPoints.AddEntry (_scanLineNum, StartStopPoint::StartStopType::StartPoint);
359 }
360 
361 
362 
363 void ScannerFile::AddStopPoint (kkint32 _scanLineNum)
364 {
365  startStopPoints.AddEntry (_scanLineNum, StartStopPoint::StartStopType::StopPoint);
367 }
368 
369 
370 
372 {
373  startStopPoints.DeleteEntry (_scanLineNum);
375 }
376 
377 
378 
379 
380 StartStopPointPtr ScannerFile::StartStopPointNearestEntry (kkint32 _scanLineNum)
381 {
382  return startStopPoints.NearestEntry (_scanLineNum);
383 }
384 
385 
386 
387 StartStopPointPtr ScannerFile::StartStopPointPrevEntry (kkint32 _scanLineNum)
388 {
389  return startStopPoints.PrevEntry (_scanLineNum);
390 }
391 
392 
393 
394 StartStopPointPtr ScannerFile::StartStopPointSuccEntry (kkint32 _scanLineNum)
395 {
396  return startStopPoints.SuccEntry (_scanLineNum);
397 }
398 
399 
400 
401 
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 */
449 
450 
451 
452 
453 
454 
455 
457  kkuint32 scanLineNum,
458  kkint64 byteOffset
459  )
460 {
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 
483 } /* UpdateFrameOffset */
484 
485 
486 
488 {
489  kkint64 offset = -1;
491  if (frameNum < frameOffsets.size ())
492  offset = frameOffsets[frameNum];
494  return offset;
495 } /* GetFrameOffset */
496 
497 
498 
499 
501  bool& found
502  )
503 {
504  if (frameNum >= frameOffsets.size ())
505  {
506  found = false;
507  return;
508  }
509 
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;
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  }
536 } /* FrameRead */
537 
538 
539 
540 
541 
542 void ScannerFile::GetNextLine (uchar* lineBuff,
543  kkuint32 lineBuffSize,
544  kkuint32& lineSize,
545  kkuint32 colCount[],
546  kkuint32& pixelsInRow
547  )
548 {
549  if (eof)
550  return;
551 
553 
555  {
557  {
558  eof = true;
559  return;
560  }
561 
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  }
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 */
610 
611 
612 
613 
614 
616 {
617  if (eof)
618  return;
619 
621 
623  {
625  {
626  eof = true;
627  return;
628  }
629 
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  }
648  }
649 
651  ++nextScanLine;
652 } /* SkipNextLine */
653 
654 
655 
656 
657 void ScannerFile::WriteScanLine (const uchar* buffer,
658  kkuint32 bufferLen
659  )
660 {
662 
664  {
669  }
670 
672  kkuint32 bytesToCopy = Min (bufferLen, pixelsPerScanLine);
673  memcpy (frameBuffer + byteOffset, buffer, bytesToCopy);
674 
675  ++nextScanLine;
677 } /* WriteScanLine */
678 
679 
680 
681 
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 */
709 
710 
711 
712 /**
713  *@brief Adds Instrument data to the underlying Scanner files as text.
714  */
716  kkuint32 scanLineNum,
717  WordFormat32Bits dataWord
718  )
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 */
724 
725 
726 
727 
728 
730  RunLog& _log
731  )
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 */
751 
752 
753 
754 void ScannerFile::GetScannerFileParameters (const KKStr& _scannerFileName,
755  ScannerHeaderFieldsPtr& _headerFields,
756  Format& _scannerFileFormat,
757  kkint32& _frameHeight,
758  kkint32& _frameWidth,
759  float& _scanRate,
760  bool& _successful,
761  RunLog& _log
762  )
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 */
783 
784 
785 
786 
787 ScannerFilePtr ScannerFile::CreateScannerFile (KKStr _fileName,
788  RunLog& _log
789  )
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 */
812 
813 
814 
815 
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 */
845 
846 
847 
848 ScannerFilePtr ScannerFile::CreateScannerFileForOutput (const KKStr& _fileName,
849  Format _format,
850  kkuint32 _pixelsPerScanLine,
851  kkuint32 _frameHeight,
852  RunLog& _log
853  )
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 
870  case Format::sf2BitEncoded:
871  scannerFile = new ScannerFile2BitEncoded (_fileName, _pixelsPerScanLine, _frameHeight, _log);
872  break;
873 
874  case Format::sf3BitEncoded:
875  scannerFile = new ScannerFile3BitEncoded (_fileName, _pixelsPerScanLine, _frameHeight, _log);
876  break;
877 
878  case Format::sf4BitEncoded:
879  scannerFile = new ScannerFile4BitEncoded (_fileName, _pixelsPerScanLine, _frameHeight, _log);
880  break;
881 
882  case Format::sfZlib3BitEncoded:
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 */
902 
903 
904 
905 
906 ScannerFilePtr ScannerFile::CreateScannerFileForOutput (const KKStr& _fileName,
907  const KKStr& _formatStr,
908  kkuint32 _pixelsPerScanLine,
909  kkuint32 _frameHeight,
910  RunLog& _log
911  )
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 */
928 
929 
930 
931 
932 
934  = {"Simple",
935  "2BitEncoded",
936  "3BitEncoded",
937  "4BitEncoded",
938  "Zlib3BitEncoded",
939  "UnKnown"
940  };
941 
942 
944 {
945  if (((int)fileFormat < 0) || (fileFormat >= Format::sfUnKnown))
947  else
948  return fileFormatOptions[(int)fileFormat];
949 } /* ScannerFileFormatToStr */
950 
951 
952 
954 {
956 }
957 
958 
959 
960 
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 */
973 
974 
975 
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 */
990 
991 
992 
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 */
1012 
1013 
1014 
1016  bool& endOfText,
1017  KKStr& line
1018  )
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 */
1034 
1035 
1036 
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 */
1054 
1055 
1056 
1057 
1058 void ScannerFile::ExtractHeaderField (const KKStr& fieldName,
1059  const KKStr& fieldValue
1060  )
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 */
1079 
1080 
1081 
1082 void ScannerFile::AddHeaderField (const KKStr& _fieldName,
1083  const KKStr& _fieldValue
1084  )
1085 {
1086  if (!headerFields)
1088  headerFields->Add (_fieldName, _fieldValue);
1089  ExtractHeaderField (_fieldName, _fieldValue);
1090 } /* AddHeaderField */
1091 
1092 
1093 
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 */
1104 
1105 
1106 
1107 const KKStr& ScannerFile::GetValue (const KKStr& fieldName)
1108 {
1109  if (!headerFields)
1110  return KKStr::EmptyStr ();
1111  else
1112  return headerFields->GetValue (fieldName);
1113 }
1114 
1115 
1116 float ScannerFile::GetValueFloat (const KKStr& fieldName)
1117 {
1118  if (!headerFields)
1119  return 0.0f;
1120  else
1121  return headerFields->GetValueFloat (fieldName);
1122 }
1123 
1124 
1125 
1126 void ScannerFile::ReportTextMsg (const char* textBuff,
1127  kkint32 numTextBytes
1128  )
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 */
1147 
1148 
1149 
1150 
1151 
1153  kkuint32 scanLineNum,
1154  WordFormat32Bits dataWord
1155  )
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 */
1168 
1169 
1170 
1171 
1172 /**
1173  *@brief Updates the byte offset for specified entry in 'frameOffsets' that is currently flagged with "-1".
1174  *@details This is meant to update entries in 'frameOffsets' that were flagged with '-1'. It will not work
1175  * for frameNum == 0; this is okay since frameNum == 0 is updated when the scanner file is first opened.
1176  * It is also assumed that the entry in frameOfsets just before 'frameNum' is already properly updated.
1177  */
1179 {
1180  if ((frameNum < 1) || (frameNum >= frameOffsets.size ()))
1181  return;
1182 
1183  CreateGoalie ();
1185 
1186  FSeek (frameOffsets[frameNum - 1]);
1187 
1188  frameOffsets[frameNum] = SkipToNextFrame ();
1189 
1191 } /* DetermineFrameOffsetForFrame */
1192 
1193 
1194 
1195 void ScannerFile::BuildFrameOffsets (const volatile bool& cancelFlag)
1196 {
1197  CreateGoalie ();
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)
1212  frameOffsets.push_back (byteOffsetScanLineZero);
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);
1244  while ((goalie->NumBlockedThreads () > 0) && (loopCount < 10))
1245  {
1246  osSleepMiliSecs (10);
1247  ++loopCount;
1248  }
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)
1275  SaveIndexFile (frameOffsets);
1276  }
1277 
1278  if (!cancelFlag)
1279  frameOffsetsLoaded = true;
1280 
1281  FSeek (origFilePos);
1282 
1284 
1285  frameOffsetsBuildRunning = false;
1286 
1287  return;
1288 } /* BuildFrameOffsets */
1289 
1290 
1291 
1292 void ScannerFile::SaveIndexFile (vector<kkint64>& frameOffsets)
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 */
1319 
1320 
1321 
1322 
1323 void ScannerFile::LoadIndexFile (bool& successful)
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;
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  {
1365  startStopPoints.Clear ();
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 */
1394 
1395 
1396 
1397 
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 */
1406 
1407 
1408 
1409 
1410 
1412 {
1413  kkint32 returnCd = 0;
1414  returnCd = osFSEEK (file, filePos, SEEK_SET);
1415  return returnCd;
1416 } /* FSeek */
void ScanRate(float _scanRate)
void FullName(const KKStr &_fullName)
KKStr(kkint32 size)
Creates a KKStr object that pre-allocates space for &#39;size&#39; characters.
Definition: KKStr.cpp:655
static ScannerFilePtr CreateScannerFileForOutput(const KKStr &_fileName, const KKStr &_formatStr, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
kkint64 frameBufferFileOffsetLast
Definition: ScannerFile.h:427
virtual void WriteTextBlock(const uchar *txtBlock, kkuint32 txtBlockLen)=0
kkint64 frameBufferFileOffsetNext
Definition: ScannerFile.h:429
void SaveIndexFile(std::vector< kkint64 > &frameOffsets)
bool EqualIgnoreCase(const char *s2) const
Definition: KKStr.cpp:1257
StartStopPointPtr StartStopPointPrevEntry(kkint32 _scanLineNum)
void LoadIndexFile(bool &successful)
Call this method to Load the FrameOffsets and StartStop points from the index file.
static const KKStr & ScannerFileFormatToStr(Format fileFormat)
kkint64 fileSizeInBytes
Definition: ScannerFile.h:396
KKStr osRemoveExtension(const KKStr &_fullFileName)
__int32 kkint32
Definition: KKBaseTypes.h:88
Structure used to break 32 bit word into different formats;.
Definition: KKBaseTypes.h:283
kkint64 osFTELL(FILE *f)
Calls the appropriate 64 bit function for operating system.
Definition: OSservices.cpp:93
ScannerFile * ScannerFilePtr
Definition: ScannerFile.h:48
kkuint32 ExtractTokenUint(const char *delStr)
Definition: KKStr.cpp:3141
ScannerHeaderFields * ScannerHeaderFieldsPtr
virtual void WriteInstrumentDataWord(uchar idNum, kkuint32 scanLineNum, WordFormat32Bits dataWord)
Writes a 32 bit number into the Scanner File Stream at current location.
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
GoalKeeperPtr goalie
Definition: ScannerFile.h:464
void Open(const KKStr &_fileName)
static const uchar * CompensationTable()
void WriteHeader()
This method is called before any scanner data is added to the file. It will write the header informat...
KKStr & operator=(const char *src)
Definition: KKStr.cpp:1442
Implements a 2 bit Encoded format.
static void Destroy(volatile GoalKeeperPtr &_goalKeeperInstance)
Destroys an existing instance of GoalKeeper.
Definition: GoalKeeper.cpp:491
void AddStartPoint(kkint32 _scanLineNum)
Adds a Start-Point to the &#39;StartStopPoints&#39; list.
void ReportInstrumentDataWord(uchar idNum, kkuint32 scanLineNum, WordFormat32Bits dataWord)
static const uchar * CompensationTable()
kkint32 ToInt() const
Definition: KKStr.cpp:3565
VectorFloatPtr RecordRateByTimeIntervals(int intervalSecs)
Returns an array indication the record rate in bytes/sec for specified time-intervals.
void SkipBytesForward(kkuint32 numBytes)
void AddStopPoint(kkint32 _scanLineNum)
Adds a Stop-Point to the &#39;StartStopPoints&#39; list.
float ScanRate() const
Definition: ScannerFile.h:109
void ReportTextMsg(const char *textBuff, kkint32 numTextBytes)
Text messages that are embedded in a scanner file can be reported here.
kkuint32 frameBufferNumScanLines
Definition: ScannerFile.h:445
virtual kkuint32 ReadBufferFrame()=0
Read in one Scanner File Frame return number of actual scan-lines read.
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...
void AddHeaderFields(const ScannerHeaderFieldsPtr _headerFields)
static void Create(const KKStr &_name, volatile GoalKeeperPtr &_newGoalKeeper)
Create a GoalKeeper object and avoid a race condition doing it.
Definition: GoalKeeper.cpp:346
KKStr operator+(const char *right) const
Definition: KKStr.cpp:3986
kkuint32 frameBufferLen
Definition: ScannerFile.h:435
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
StartStopPointPtr StartStopPointSuccEntry(kkint32 _scanLineNum)
kkuint32 frameBufferSize
Definition: ScannerFile.h:447
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
const KKStr & GetValue(const KKStr &fieldName)
__int64 kkint64
Definition: KKBaseTypes.h:90
static ScannerFileEntryPtr GetOrCreateScannerFileEntry(const KKStr &rootName)
KKStr & operator=(KKStr &&src)
Definition: KKStr.cpp:1369
kkuint32 Len() const
Returns the number of characters in the string.
Definition: KKStr.h:366
kkuint32 flowMeterCounterScanLine
Definition: ScannerFile.h:416
KKTHread * KKTHreadPtr
void ExtractHeaderField(const KKStr &fieldName, const KKStr &fieldValue)
void Append(char ch)
Definition: KKStr.cpp:1863
Class that keeps track of parameter details of a single scanner file.
ScannerHeaderFieldsPtr headerFields
Definition: ScannerFile.h:400
KKStr operator+(const char *left, const KKStr &right)
Definition: KKStr.cpp:3976
void AddStartStopEntryToIndexFile(kkint32 scanLineNum, StartStopPoint::StartStopType type, bool deleteEntry)
kkint32 MemoryConsumedEstimated()
void DetermineFrameOffsetForFrame(kkuint32 frameNum)
Updates the byte offset for specified entry in &#39;frameOffsets&#39; that is currently flagged with "-1"...
KKStr(const KKStr &str)
Copy Constructor.
Definition: KKStr.cpp:561
static ScannerFilePtr CreateScannerFile(KKStr _fileName, RunLog &_log)
void StartBlock()
Initiates a Block as long as another thread has not already locked this object.
Definition: GoalKeeper.cpp:214
float GetValueFloat(const KKStr &fieldName) const
std::ofstream * indexFile
Definition: ScannerFile.h:466
bool Empty() const
Definition: KKStr.h:241
static const KKStr fileFormatOptions[]
Definition: ScannerFile.h:363
KKStr FileFormatStr() const
void EndBlock()
Ends the block and allows other threads to pass through StatBlock.
Definition: GoalKeeper.cpp:295
void PixelsPerScanLine(kkuint32 _pixelsPerScanLine)
kkint32 ToInt32() const
Definition: KKStr.cpp:3587
unsigned char uchar
Unsigned character.
Definition: KKBaseTypes.h:77
static Format ScannerFileFormatFromStr(const KKStr &fileFormatStr)
virtual Format FileFormat() const
Definition: ScannerFile.h:78
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
virtual ~ScannerFile()
void UpdateFrameOffset(kkuint32 frameNum, kkuint32 scanLineNum, kkint64 byteOffset)
void osSleepMiliSecs(kkuint32 numMiliSecs)
KKStr(const char *src, kkuint32 startPos, kkuint32 endPos)
Constructs a KKStr instance from a sub-string of &#39;src&#39;.
Definition: KKStr.cpp:693
Contains Classes that are specific to Cameras physical characteristics.
static const KKStr & EmptyStr()
Static method that returns an Empty String.
Definition: KKStr.cpp:3453
virtual void WriteScanLine(const uchar *buffer, kkuint32 bufferLen)
kkint64 GetFrameOffset(kkuint32 frameNum)
virtual void Flush()
ScannerHeaderFieldsPtr HeaderFields() const
Definition: ScannerFile.h:102
virtual void WriteBufferFrame()=0
Write the contents of &#39;frameBuffer&#39; to he end of the scanner file.
StartStopType Type() const
void StartStopPointDelete(kkint32 _scanLineNum)
unsigned __int64 kkuint64
Definition: KKBaseTypes.h:91
bool StartsWith(const char *value, bool ignoreCase) const
Definition: KKStr.cpp:1169
KKStr StrFormatInt(kkint32 val, const char *mask)
Definition: KKStr.cpp:5004
bool frameOffsetsBuildRunning
Definition: ScannerFile.h:457
static const uchar * CompensationTable()
kkint32 ExtractTokenInt(const char *delStr)
Definition: KKStr.cpp:3129
void BuildFrameOffsets(const volatile bool &cancelFlag)
Will update the &#39;frameOffsets&#39; table by scanning the file from the last known entry until the end of ...
kkuint64 ExtractTokenUint64(const char *delStr)
Definition: KKStr.cpp:3153
StartStopPoint(const KKStr &s)
Represents a list of header fields from a Scanner File.
float GetValueFloat(const KKStr &fieldName)
kkuint32 frameNumCurLoaded
Definition: ScannerFile.h:451
static const uchar * ConpensationTable(Format format)
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
KKStr StrFormatDouble(double val, const char *mask)
Definition: KKStr.cpp:4819
Implements a 3 bit Encoded format.
kkuint32 frameHeight
Definition: ScannerFile.h:398
bool osFileExists(const KKStr &_fileName)
Definition: OSservices.cpp:568
FILE * osFOPEN(const char *fileName, const char *mode)
Definition: OSservices.cpp:74
static const uchar * CompensationTable()
kkuint32 frameBufferNextLine
Definition: ScannerFile.h:441
kkint32 FSeek(kkint64 filePos)
static void ReadHeaderOneLine(FILE *f, bool &endOfText, KKStr &line)
Implements a 4 bit Encoded format.
KKStr & operator=(const KKStr &src)
Definition: KKStr.cpp:1390
virtual void GetNextLine(uchar *lineBuff, kkuint32 lineBuffSize, kkuint32 &lineSize, kkuint32 colCount[], kkuint32 &pixelsInRow)
kkuint32 pixelsPerScanLine
Definition: ScannerFile.h:407
void AddHeaderField(const KKStr &_fieldName, const KKStr &_fieldValue)
Used for logging messages.
Definition: RunLog.h:49
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.
kkint32 NumBlockedThreads()
Returns the number of threads that are waiting to establish a lock on this instance.
Definition: GoalKeeper.cpp:579
virtual void ScanRate(float _scanRate)
const KKStr & GetValue(const KKStr &fieldName) const
virtual kkint64 SkipToNextFrame()=0
Skip to start of next frame returning back byte offset of that frame.
kkuint32 PixelsPerScanLine() const
Definition: ScannerFile.h:108
kkint32 FrameHeight() const
Definition: ScannerFile.h:97
void SkipToScanLine(kkint32 scanLine)
Repositions the file such that the next call to &#39;GetNextLine&#39; returns the &#39;scanLine&#39; scan-line...
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
ScannerFile(const KKStr &_fileName, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
kkint32 largestKnownScanLine
Definition: ScannerFile.h:402
static ScannerFilePtr CreateScannerFileForOutput(const KKStr &_fileName, Format _format, kkuint32 _pixelsPerScanLine, kkuint32 _frameHeight, RunLog &_log)
kkint64 byteOffsetScanLineZero
Definition: ScannerFile.h:392
virtual void Close()
ScannerHeaderFields(const ScannerHeaderFields &fields)
WordFormat32Bits(kkuint32 d)
Class that keeps track of parameter details of a single scanner file.
ScannerFile(const KKStr &_fileName, RunLog &_log)
Definition: ScannerFile.cpp:40
StartStopPointPtr StartStopPointNearestEntry(kkint32 _scanLineNum)
static Format GuessFormatOfFile(const KKStr &_fileName, RunLog &_log)
ScannerFileEntryPtr scannerFileEntry
Definition: ScannerFile.h:471
kkint64 osGetFileSize(const KKStr &fileName)
void Add(const KKB::KKStr &fieldName, const KKB::KKStr &fieldValue)
kkuint32 flowMeterCounter
Definition: ScannerFile.h:412
KKB::KKStrPtr osReadRestOfLine(FILE *in, bool &eof)
KKStr osGetRootName(const KKStr &fullFileName)
virtual kkint32 MemoryConsumedEstimated() const
VectorFloat * VectorFloatPtr
Definition: KKBaseTypes.h:157