Critical Link MityCam SoC Firmware  1.0
Critical Link MityCam SoC Firmware
FilesystemIO.h
Go to the documentation of this file.
1 #ifndef FILESYSTEMIO_H
2 #define FILESYSTEMIO_H
3 
4 #include <string>
5 #include <unistd.h>
6 #include <list>
7 
8 #include "IOChannel.h"
9 #include "Sensors/SensorBoard.h"
10 #include "Utility/Types.h"
11 
12 #define MAX_FILENAME_SIZE (4096)
13 
14 // Invalidate the first 10MB of cache when initially snapping a request.
15 #define INVALIDATE_SIZE (0xA00000)
16 
17 // Observer class for the FilesystemIO channel. has hooks incase the subclasser doesn't care about a specific operation.
19 public:
22 
23  virtual void onFileWritten(int32 anNumWritten) {}
24 
25  enum teWriteError {
28  };
29 
34  virtual void onWriteErrorDetected(teWriteError aeError) {}
35 };
36 
42 {
43 public:
45  virtual ~tcFilesystemIO();
46 
50  void registerWatcher(tcFilesystemIOWatcher *apWatcher);
51 
56 
68 
75 
80  virtual void sendUpdate(tsNewFrameMsg *apMsg);
81 
87  SocCamera::teNackCode setFilenamePrefix(std::string asName);
88 
93  std::string getFilenamePrefix();
94 
102 
107 
113  SocCamera::teNackCode setPath(std::string asPath, bool abCreate = true);
114 
119  std::string getPath();
120 
126 
132 
133 private:
134  void closeAll();
135 
136  void issueWriteError(tcFilesystemIOWatcher::teWriteError aeError);
137 
138  bool mbIsOpen;
139  bool mbOutputting;
140  bool mbCancel;
141  tcMutex mcFileMutex;
142  FILE* mpIndexFile;
143  FILE* mpRawFile;
144  uint32 mnCurrentHeaderIndex;
145  uint32 mnImagesSinceClose;
146  uint32 mnImagesToWrite;
147 
148  uint32 mnBufferSize;
149  uint8* mpIntermediateBuffer;
150 
151  std::string msFilePrefix;
152  std::string msPath;
153  std::string msExtension;
154  char maFilename[MAX_FILENAME_SIZE];
155 
156  std::list<tcFilesystemIOWatcher*> mcWatcherList;
157 
158  uint32 mnImagesWritten;
159 };
160 
161 #endif // FILESYSTEMIO_H
tcFilesystemIOWatcher::teWriteError
teWriteError
Definition: FilesystemIO.h:25
tcFilesystemIOWatcher::onFileWritten
virtual void onFileWritten(int32 anNumWritten)
Definition: FilesystemIO.h:23
int32
int32_t int32
Definition: Types.h:8
tcFilesystemIO::registerWatcher
void registerWatcher(tcFilesystemIOWatcher *apWatcher)
Definition: FilesystemIO.cpp:320
tcFilesystemIO::~tcFilesystemIO
virtual ~tcFilesystemIO()
Definition: FilesystemIO.cpp:39
Types.h
tcFilesystemIOWatcher::eeFrameWriteFailure
@ eeFrameWriteFailure
Definition: FilesystemIO.h:27
tcFilesystemIO::getCurrentFrameIndex
uint32 getCurrentFrameIndex()
Definition: FilesystemIO.cpp:287
tcFilesystemIO::setPath
SocCamera::teNackCode setPath(std::string asPath, bool abCreate=true)
Definition: FilesystemIO.cpp:236
tcFilesystemIO::getImagesPerFile
uint32 getImagesPerFile()
Definition: FilesystemIO.cpp:274
tcFilesystemIO::getPath
std::string getPath()
Definition: FilesystemIO.cpp:262
SensorBoard.h
tcFilesystemIO::tcFilesystemIO
tcFilesystemIO(SocCamera::tcSensorBoard *apSensor)
Definition: FilesystemIO.cpp:19
tcFilesystemIOWatcher
Definition: FilesystemIO.h:18
tcFilesystemIO::sendUpdate
virtual void sendUpdate(tsNewFrameMsg *apMsg)
Definition: FilesystemIO.cpp:106
tcFilesystemIO::capture
virtual SocCamera::teNackCode capture(tsCaptureRequest asRequest)
Definition: FilesystemIO.cpp:44
tcFilesystemIO::getFilenamePrefix
std::string getFilenamePrefix()
Definition: FilesystemIO.cpp:231
tcFilesystemIO
Definition: FilesystemIO.h:41
uint8
uint8_t uint8
Definition: Types.h:9
SocCamera::teNackCode
teNackCode
Definition: CameraTypes.h:62
tcIOChannel
Camera Output IO channel management class.
Definition: IOChannel.h:34
SocCamera::teBPPMode
teBPPMode
Definition: CameraTypes.h:133
tcFilesystemIOWatcher::~tcFilesystemIOWatcher
virtual ~tcFilesystemIOWatcher()
Definition: FilesystemIO.h:21
tcFilesystemIO::flush
SocCamera::teNackCode flush()
Definition: FilesystemIO.cpp:279
tcFilesystemIO::unregisterWatcher
void unregisterWatcher(tcFilesystemIOWatcher *apWatcher)
Definition: FilesystemIO.cpp:325
tcFilesystemIOWatcher::onWriteErrorDetected
virtual void onWriteErrorDetected(teWriteError aeError)
Definition: FilesystemIO.h:34
MAX_FILENAME_SIZE
#define MAX_FILENAME_SIZE
Definition: FilesystemIO.h:12
tcFilesystemIO::setBpp
virtual SocCamera::teNackCode setBpp(SocCamera::teBPPMode aeBppMode)
Definition: FilesystemIO.cpp:97
tcFilesystemIO::setImagesPerFile
SocCamera::teNackCode setImagesPerFile(uint32 anImagesPerFile)
Definition: FilesystemIO.cpp:267
uint32
uint32_t uint32
Definition: Types.h:11
tsNewFrameMsg
Definition: IOCallback.h:11
tcFilesystemIOWatcher::eeIndexMismatch
@ eeIndexMismatch
Definition: FilesystemIO.h:26
tcFilesystemIOWatcher::tcFilesystemIOWatcher
tcFilesystemIOWatcher()
Definition: FilesystemIO.h:20
SocCamera::tcSensorBoard
Definition: SensorBoard.h:40
tcMutex
Definition: Mutex.h:11
tsCaptureRequest
Definition: IOCallback.h:56
IOChannel.h
tcFilesystemIO::setFilenamePrefix
SocCamera::teNackCode setFilenamePrefix(std::string asName)
Definition: FilesystemIO.cpp:219