FEDEM Model Database  R8.0
Source code of the FEDEM model database
FiDACFile.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FI_DAC_FILE_H
9 #define FI_DAC_FILE_H
10 
11 #include "FiDeviceFunctionBase.H"
12 
13 
15 {
16 public:
17  explicit FiDACFile(const char* devicename = NULL,
18  Endianness format = LittleEndian);
19 
20  virtual size_t getValueCount() const { return myNumDatavals; }
21  virtual void getValueRange(double& min, double& max) const;
22  virtual double getXAxisOrigin() const { return myXaxisOrigin; }
23 
24  virtual double getValue(double x, int = 0,
25  bool zeroAdjust = false, double vertShift = 0.0,
26  double scaleFac = 1.0);
27  virtual bool getValues(double x0, double x1, Doubles& x, Doubles& y,
28  int channel = 0, bool zeroAdjust = false,
29  double shift = 0.0, double scale = 1.0);
30  virtual void getRawData(Doubles& x, Doubles& y,
31  double minX = 0.0, double maxX = -1.0, int = 0);
32  virtual void setValue(double x, double y);
33  virtual bool setData(const Doubles& x, const Doubles& y);
34 
35 protected:
36  virtual bool initialDeviceRead();
37  virtual bool preliminaryDeviceWrite();
38  virtual bool concludingDeviceWrite(bool);
39 
40  void updateStatistics(double val);
41 
42 private:
43  double getValueAt(unsigned long pos);
44 
45  float readFloat(int pos); // DAC dump position
46  short readInt16(int pos); // DAC INT no (=Dump position 33A +)
47  int readInt32(int pos); // DAC Dump position
48  std::string readString(int start, int end, // DAC dump start & stop
49  int startOffset = 0, int endoffset = 0);
50 
51  void writeFloat(int pos, float val); // DAC dump position
52  void writeInt16(int pos, int val); // DAC INT no (=Dump position 33A +)
53  void writeInt32(int pos, int val); // DAC Dump position
54  int writeString(int start, int end, // DAC dump start & stop
55  const std::string& val,
56  int startOffset = 0, int endoffset = 0);
57 
58 protected:
59  unsigned long myNumDatavals;
60  double myXaxisOrigin;
61 
63 
64  double myLastXVal;
65  double myLastYVal;
66 
67  double myMean;
68  double myMS;
69  double myMaxVal;
70  double myMinVal;
71 
72  unsigned long maxPos;
73  unsigned long minPos;
74 
75 private:
77 };
78 
79 #endif
std::pair< double, double > Doubles
Convenience type alias.
Definition: FFaField.H:22
Base class for external device functions.
Definition: FiDACFile.H:15
double myFirstReadValue
Definition: FiDACFile.H:62
virtual void setValue(double x, double y)
Assigns a function value for a single-channel function.
Definition: FiDACFile.C:367
double myLastXVal
Definition: FiDACFile.H:64
virtual size_t getValueCount() const
Returns the number of (x,y) pairs for this device.
Definition: FiDACFile.H:20
unsigned long myNumDatavals
Definition: FiDACFile.H:59
double getValueAt(unsigned long pos)
Definition: FiDACFile.C:264
unsigned long maxPos
Definition: FiDACFile.H:72
void writeFloat(int pos, float val)
Definition: FiDACFile.C:507
double myMS
Definition: FiDACFile.H:68
double myLastYVal
Definition: FiDACFile.H:65
virtual double getValue(double x, int=0, bool zeroAdjust=false, double vertShift=0.0, double scaleFac=1.0)
Evaluates the function for a given x value.
Definition: FiDACFile.C:198
double myMaxVal
Definition: FiDACFile.H:69
virtual bool initialDeviceRead()
Reads the file content, or at least its meta data.
Definition: FiDACFile.C:37
double myXaxisOrigin
Definition: FiDACFile.H:60
double myMinVal
Definition: FiDACFile.H:70
FiDACFile(const char *devicename=NULL, Endianness format=LittleEndian)
Definition: FiDACFile.C:21
int readInt32(int pos)
Definition: FiDACFile.C:473
virtual bool preliminaryDeviceWrite()
Writes the meta data for this device function to file.
Definition: FiDACFile.C:87
virtual void getRawData(Doubles &x, Doubles &y, double minX=0.0, double maxX=-1.0, int=0)
Extracts all function data point values within specified interval.
Definition: FiDACFile.C:274
virtual void getValueRange(double &min, double &max) const
Calculates the function value range for this device.
Definition: FiDACFile.C:191
void updateStatistics(double val)
Definition: FiDACFile.C:405
void writeInt32(int pos, int val)
Definition: FiDACFile.C:530
virtual bool concludingDeviceWrite(bool)
Writes the content of this device function to file.
Definition: FiDACFile.C:120
bool isDataWriteInited
Definition: FiDACFile.H:76
std::string readString(int start, int end, int startOffset=0, int endoffset=0)
Definition: FiDACFile.C:489
int writeString(int start, int end, const std::string &val, int startOffset=0, int endoffset=0)
Definition: FiDACFile.C:541
virtual double getXAxisOrigin() const
Returns the function argument origin for this device.
Definition: FiDACFile.H:22
void writeInt16(int pos, int val)
Definition: FiDACFile.C:518
virtual bool getValues(double x0, double x1, Doubles &x, Doubles &y, int channel=0, bool zeroAdjust=false, double shift=0.0, double scale=1.0)
Evaluates the function at all points within specified interval.
Definition: FiDACFile.C:292
float readFloat(int pos)
Definition: FiDACFile.C:441
virtual bool setData(const Doubles &x, const Doubles &y)
Adds a complete set of x,y-pair values for a new channel.
Definition: FiDACFile.C:333
short readInt16(int pos)
Definition: FiDACFile.C:457
unsigned long minPos
Definition: FiDACFile.H:73
double myMean
Definition: FiDACFile.H:67
Base class for external device functions.
Definition: FiDeviceFunctionBase.H:28
Endianness
Enumerator for endianness values.
Definition: FiDeviceFunctionBase.H:45
@ LittleEndian
Definition: FiDeviceFunctionBase.H:45