- DataTreeCore:
- Bug fix: GetMember() error if member not found
- FunctionCore: (affected: SelectableCore, FileCore, WatchdogCore)
- Made destructor virual
- Standardize method parameter naming, e.g. pName, pLog
- Renamed parameters: DebugLevel -> LogLevel, OutputDisplay -> LogOutput
- Reinstated parameter BaseMember
- Removed logging parameters from constructor
- Created method InitLoggging() (shows "Function Created" message)
- Split LoadConfig() method into parts:
- Implemented public LoadConfig() methods
- Implemented LoadConfigData() method, load parameters from DataTree
- WatchdogCore:
- Derive from CSelectableCore instead of CFunctionCore
- Rename parameter: PingTimeout -> PingInterval
- Replace Ping Channel with Handle only
- Add method SetInterval()
- Send command direct to handle with (channel) Input()
- SelectableCore:
- Rename parameters: Auto -> AutoManage, ReopenTimeout -> ReopenDelay
- Implemented own virtual LoadConfigData() method
- DeviceCore:
- Made all logging conditional: if (Log) Log->Message(...)
- SelectCore:
- Renamed parameters: DebugLevel -> LogLevel
79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
/*
|
|
* FileCore.h
|
|
*
|
|
* Created on: 1 Jun 2016
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
#ifndef JOANETELEMETRY_FILECORE_H_
|
|
#define JOANETELEMETRY_FILECORE_H_
|
|
|
|
// redA Libraries
|
|
#include "FunctionCore.h"
|
|
|
|
// Standard C/C++ Libraries
|
|
/* none */
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
const int NO_FD = -1;
|
|
|
|
typedef struct SFileHandle TFileHandle;
|
|
struct SFileHandle
|
|
{
|
|
char * Name; // Quick reference
|
|
char * Path; // Actual location of file
|
|
int FD; // File Descriptor
|
|
|
|
bool Append; // Append data to end of file
|
|
|
|
bool Persistent; // Keep file open after write
|
|
timeval PersistTime; // Time opened/last written to
|
|
bool PersistTimeout; // Time to remain open, 0 = permanently open
|
|
|
|
TFileHandle * Next;
|
|
};
|
|
//---------------------------------------------------------------------------
|
|
|
|
class CFileCore : public CFunctionCore
|
|
{
|
|
private:
|
|
// File
|
|
TFileHandle * FirstFile;
|
|
|
|
// Manage File
|
|
virtual bool OpenFile( TFileHandle * FileHandle );
|
|
virtual bool CloseFile( TFileHandle * FileHandle );
|
|
|
|
virtual int ReadFromFD( int FD, char * Data, int MaxLen );
|
|
virtual int WriteToFD( int FD, const char * Data, int Len );
|
|
|
|
inline TFileHandle * GetFile( const char * Name ) {
|
|
if (!Name || !*Name) return NULL;
|
|
TFileHandle * FileHandle = FirstFile;
|
|
while (FileHandle && strcmp( Name, FileHandle->Name ))
|
|
FileHandle = FileHandle->Next;
|
|
return FileHandle;
|
|
};
|
|
|
|
inline bool isOpen( TFileHandle * FileHandle ) { return (FileHandle->FD != NO_FD); };
|
|
|
|
public:
|
|
// Life cycle
|
|
CFileCore( const char * pName, CLogCore * pLog );
|
|
virtual ~CFileCore();
|
|
|
|
// Manage files
|
|
virtual TFileHandle * AddFile( const char * Name, const char * Path, bool Append = true, bool CreateChannel = true );
|
|
virtual bool SetFilePersistence( TFileHandle * FileHandle, bool Persistent, int PersistTimeout );
|
|
|
|
// Data Input
|
|
virtual int Input( const char * ChannelName, const char * Data, int MaxLen = -1 );
|
|
|
|
// Processing data
|
|
virtual bool Process();
|
|
};
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif /* JOANETELEMETRY_FILECORE_H_ */
|