Files
DP44/Common/DTS.Common.Serialization/DDAS (Chrysler)/DataFloat.h
2026-04-17 14:55:32 -04:00

167 lines
5.4 KiB
C++

//////////////////////////////////////////////////////////////////////
// DataFloat.h: interface for the CDataFloat class.
// -----------------------------------------------
//
// REVISIONS:
// 6-22-10 AJO Add bool GetTimeAtValue(float fValue, float *pTvalue)
#pragma once
#include "FilePath.h" // Added by ClassView for def of CFilePath
#include "ChannelDefinition.h" // for def of CHANNEL
#include "DDASTestDefinition.h" // for def of FILEINFOBLOCK
#include <Afxtempl.h> // CArray definitions
#ifndef TESTPATHSIZE
#define TESTPATHSIZE 128
#endif
enum FileTypes {UNKNOWN, FLOATPOINT, PROCESSED}; // File types
//File Definitions
#define FILEERROR -1 // Error in file I/O
// File Types and Version
#define FLOATDATANAME "DDAS FlPt" // Floating Point Data File type
#define FLOATDATARAW "DDAS fpRAW" // Float Raw data
#define FLOATDATAVER "Ver 500" // Floating Point Data File version
// Standard Messages
#define CantOpenMsg "Could not open file "
#define NonExistMsg "Non-existent file "
typedef struct tagTESTINFO
{
unsigned long Size; // Block Size (including Size)
unsigned long DeviceID; // DAQ device ID
long ChannelNo; // Channel number (1-32)
long SampleRate; // Samples per second
long TotalSamples; // Total samples in data record
long PreEventSamples; // Samples before event
short ChanNumInSys; // Channel Number (1-128) in system (many devices)
short NumPreCalPts; // Number of preCal points included with data
short NumPostCalPts; // Number of preCal points included with data
char TestCreation[TESTPATHSIZE]; // Test path and date
char TimeAxisTitle[32]; // Time axis title
byte SpareBytes[2]; // 2 bytes of spare (for 4 byte alignment)
} TESTINFO;
typedef struct tagFILEHEADER
{
FILEINFOBLOCK FileInfo;
TESTINFO TestInfo;
CHANNEL Channel;
//---------------the following must add up to 32 bytes -----------------
byte SpareBytes[32]; // 32 bytes of spare
} FILEHEADER;
/* DATA PEAK STRUCTURE TYPE DEFINITION */
typedef struct tagDATAPEAK
{
float Min;
short Xmin;
float Max;
short Xmax;
} DATAPEAK;
typedef DATAPEAK *PDATAPEAK; // Pointer to data peak structure
typedef DATAPEAK *LPDP; // Pointer to data peak
// types of peak value calculations
enum PeakTypes {PEAKS_MINMAX, PEAKS_3MSCONTIN, PEAKS_3MSCUMUL};
typedef struct tagDATAHIST // Histogram (number of occurrences) of data values
{
float fVal; // Data value
int nOccurrences; // Number of occurrences in data set
// float fX; // First x value of occurrence
// int nX; // First x index of occurrence
} DATAHIST;
class CDataFloat
{
public:
CDataFloat(unsigned int nSize);
CDataFloat();
virtual ~CDataFloat();
class CPeakList
{
public:
CPeakList() { };
virtual ~CPeakList() {};
void RemoveAll() { m_lstDHist.RemoveAll(); }
void AddDataPoint(DATAHIST* pDHist);
void Get3msMin(int nPtPer3ms, DATAHIST* pDHist);
void Get3msMax(int nPtPer3ms, DATAHIST* pDHist);
private:
CList<DATAHIST, DATAHIST&> m_lstDHist;
// int m_nMaxXIndex;
// float m_fMaxXVal;
};
int GetChannelNumberInBox();
bool VerifyAndCoerceAxis(bool bNegativeSign, const char* szAxis, BOOL bVerbose);
void SetEngrgUnits(char *szNewEngrgUnits);
void SetChannelName(char* szNewChannelName);
int CalcSampIn3mSecInt();
int ConvertTimeToIndex(float fTime);
float ConvertIndexToTime(int nIndex);
const CString GetFileName();
int AppendArrayFloat(CArray<float, float&>* srcArray);
CArray<float, float&>* GetDataArray();
bool GetTimeAtValue(float fValue, float *pTvalue);
bool GetDataPeaks(int nPkType, int nVerbose, float* pTStart, float* pTEnd, float* pTMin, float* pDMin, float* pTMax, float* pDMax);
bool GetDataPeaks(int nPkType, int nVerbose, float* pTMin, float* pDMin, float* pTMax, float* pDMax);
bool GetDataPeaks(int nPkType, int nVerbose, int *pXMin, float *pTMin, float *pDMin, int *pXMax, float *pTMax, float *pDMax);
int GetChannelNumber();
float GetStartTime(bool bmSec);
float GetStartTimeData(bool bmSec);
float GetStopTime(bool bmSec);
float GetStopTimeData(bool bmSec);
const char* GetFileExt();
const char* GetFileTitle();
long GetSampleRate();
const char* GetFilePathAndName();
int SetFilePathAndName(char* szNewFileSpec);
int ClearAll(long NewNumberElements);
TESTINFO* GetTestInfo();
FILEINFOBLOCK* GetFileInfo();
CHANNEL* GetChannel();
float GetFilterClass();
int GetEventOffset();
// char* GetDataSetName();
CString GetDataSetName(CString &csName);
FILEHEADER* CDataFloat::GetFileHeader();
bool WriteToFile(const char *lpFilename, bool bPrint);
bool ReadFromFile(const char *lpFilename);
float* GetDataBuffer();
bool SetSize(long lNumberElements);
long GetSize();
bool GetDataNext(float* fData);
bool StoreDataNext(float fData);
bool SetIndexToStart();
void operator=(const CDataFloat &src);
// File Extensions
#define RawExt ".raw" // Unprocessed Data File Extension
#define FlPtExt ".fpd" // Floating Point Data File Extension
enum FPDVerbosity {FPD_SILENT, // Amount of messages printed
FPD_ERRORS, FPD_STATUS, FPD_RESULTS, FPD_VERBOSE};
protected:
void Peak3mS(float *pfDataBlock, PDATAPEAK p3msPeak);
CFilePath FilePathAndName;
FILEHEADER FileHeader;
CArray<float, float&> FloatData; // Floating point Data array
float * pfBfr; // working pointer to buffer at FloatData
};