|
FEDEM Model Database
R8.0
Source code of the FEDEM model database
|
Class representing external device functions based on ASCII files. More...
#include <FiASCFile.H>


Public Member Functions | |
| FiASCFile (const char *fname=NULL, int nchan=1) | |
| Default constructor. More... | |
| virtual size_t | getValueCount () const |
| Returns the number of (x,y) pairs of the function. More... | |
| virtual double | getValue (double x, int channel, bool zeroAdjust, double vertShift, double scaleFac) |
| Evaluates the function for a given x value. More... | |
| virtual bool | getValues (double x0, double x1, Doubles &x, Doubles &y, int channel, bool zeroAdj, double shift, double scale) |
| Evaluates the function at all points within specified interval. More... | |
| virtual void | getRawData (Doubles &x, Doubles &y, double minX, double maxX, int channel) |
| Extracts all function data point values within specified interval. More... | |
| virtual void | getData (Doubles &x, Doubles &y, const std::string &channel, double minX, double maxX) |
| Extracts all function data point values within specified interval. More... | |
| virtual void | setValue (double x, double y) |
| Assigns a function value for a single-channel function. More... | |
| virtual bool | setData (const Doubles &x, const Doubles &y) |
| Adds a channel to current file by interpolation. More... | |
| virtual void | setDescription (const std::string &desc) |
| Assigns a name to the (last) channel in file. More... | |
| virtual void | setEmptyChannel (const std::string &desc) |
| Adds an empty channel to the file. More... | |
| virtual void | setPrecision (int type) |
| Defines the output precision. More... | |
| virtual bool | getChannelList (Strings &list) |
| Extracts the list of channel names (file column labels). More... | |
| virtual int | isChannelPresentInFile (const std::string &channel) |
| Returns the column index of the named channel. More... | |
| virtual bool | isChannelPresentInFile (int channel) |
| Returns true if channel is a valid column index. More... | |
Public Member Functions inherited from FiDeviceFunctionBase | |
| virtual | ~FiDeviceFunctionBase () |
| The destructor closes the device function file. More... | |
| bool | open (const char *devicename, FileStatus status=Read_Only) |
| Opens the specified device function file for reading or writing. More... | |
| bool | open (FileStatus status=Read_Only) |
| Opens the file myDatasetDevice for reading or writing. More... | |
| bool | close (bool noHeader=false) |
| Closes the device function file. More... | |
| const std::string & | getDevicename () const |
| Returns the myDatasetDevice of this device function. More... | |
| void | setExtrapolationPolicy (InterpolationPolicy policy=Constant) |
| Defines the extrapolation policy to be used. More... | |
| void | setInterpolationPolicy (InterpolationPolicy policy=Linear) |
| Defines the interpolation policy to be used. More... | |
| virtual void | getValueRange (double &mn, double &mx) const |
| Calculates the function value range for this device. More... | |
| virtual double | getXAxisOrigin () const |
| Returns the function argument origin for this device. More... | |
| virtual void | setTimeSpan (double) |
| Sets the maximum time span for the device function. More... | |
| double | integrate (double x, int order=1, int channel=0, double vertShift=0.0, double scaleFac=1.0) |
| Computes the integral of this device over the interval [0,x]. More... | |
| int | getRefCount () const |
| Returns the current reference count for this device. More... | |
| int | ref () |
| Increments the reference count fir this device. More... | |
| int | unref () |
| Decrements the reference count for this device. More... | |
| double | getStep () const |
| returns the constant sampling time increment. More... | |
| double | getFrequency () const |
| returns the constant sampling frequency. More... | |
| void | setStep (double aStep) |
| Sets the sampling increment for devices with constant sampling. More... | |
| void | setFrequency (double aFreqency) |
| Sets the sampling frequency for devices with constant sampling. More... | |
| void | setParent (const std::string &modelfile) |
| Sets the model file name associated with this device. More... | |
| bool | isReadOnly () const |
| Returns whether this is a read-only device or not. More... | |
| FileStatus | getFileStatus () const |
| Returns the myFileStatus of this device function. More... | |
| void | getAxisUnit (int axis, char *unitText, size_t n) const |
| Gets the axis unit. More... | |
| void | getAxisTitle (int axis, char *titleText, size_t n) const |
| Gets the axis title. More... | |
| void | setAxisUnit (int axis, const char *unitText) |
| Sets the axis unit. More... | |
| void | setAxisTitle (int axis, const char *titleText) |
| Sets the axis title. More... | |
Static Public Member Functions | |
| static int | getNoChannels (const char *fname) |
| Counts the number of channels (number of columns minus one). More... | |
| static bool | isMultiChannel (FT_FILE fd, const char *fname=NULL, bool rewind=false) |
| Checks if the specified file consists of two or more columns. More... | |
| static int | readHeader (FT_FILE fd, Strings &header) |
| Reads the header section of a specified file. More... | |
| static bool | readNext (FT_FILE fd, const std::vector< int > &columns, Doubles &values) |
| Reads the next line of data from specified file. More... | |
Static Public Attributes | |
| static size_t | bufferSize = 0 |
| Buffer size for ASCII output in KBytes. More... | |
Protected Member Functions | |
| virtual bool | concludingDeviceWrite (bool noHeader) |
| Writes all function data to file. More... | |
| virtual bool | initialDeviceRead () |
| Reads the file and loads the first channel into core. More... | |
| virtual bool | preliminaryDeviceWrite () |
| Dummy method doing nothing. More... | |
Protected Member Functions inherited from FiDeviceFunctionBase | |
| FiDeviceFunctionBase (const char *devicename=NULL) | |
| The default constructor initialize the data members. More... | |
| FiDeviceFunctionBase (const FiDeviceFunctionBase &)=delete | |
| Deleted copy constructor. More... | |
| FiDeviceFunctionBase & | operator= (const FiDeviceFunctionBase &)=delete |
| Deleted assignment operator. More... | |
| double | interpolate (double x, double x0, double f0, double x1, double f1) const |
| Calculates the function value at x by interpolation. More... | |
| double | extrapolate (double x, double x0, double f0, double x1, double f1) const |
| Calculates the function value at x by extrapolation. More... | |
| bool | writeString (const char *str) |
| Convenience method for a writing text header. More... | |
| bool | writeString (const char *lab, const std::string &val) |
| Convenience method for writing text headers. More... | |
Private Types | |
| using | ValuesMap = std::map< double, Doubles > |
| Mapping from x-value (time) to channel values. More... | |
| using | ValuesIter = ValuesMap::iterator |
| Convenience type alias. More... | |
Private Member Functions | |
| int | readChannel (int channel) |
| Reads the specified channel into core. More... | |
Private Attributes | |
| Strings | chn |
| Channel names (columns labels) More... | |
| ValuesMap | myValues |
| Curve data, either for all or one channel. More... | |
| ValuesIter | vit0 |
| Start iterator of last evaluation interval. More... | |
| ValuesIter | vit1 |
| End iterator of last evaluation interval. More... | |
| int | myChannel |
| Channel (column index) that currently resides in core. More... | |
| int | myNumChannels |
| Number of columns minus 1 (column 1 is the X-values) More... | |
| int | outputFormat |
| 0: 4-digits, 1: 8 digits, 2: 16-digits More... | |
| bool | isCSVt |
| If true, this file has microsec as first column. More... | |
Additional Inherited Members | |
Public Types inherited from FiDeviceFunctionBase | |
| enum | Endianness { LittleEndian , BigEndian } |
| Enumerator for endianness values. More... | |
| enum | FileFormat { ascii , binary } |
| Enumerator for the file formats. More... | |
| enum | FileStatus { Not_Loaded =-1 , Not_Open =0 , Read_Only =1 , Write_Only =2 } |
| Enumerator for file opening statuses. More... | |
| enum | InterpolationPolicy { Constant , Linear , Previous_Value , Next_Value } |
| Enumerator for interpolation and extrapolation policies. More... | |
Protected Types inherited from FiDeviceFunctionBase | |
| using | Doubles = std::vector< double > |
| Convenience type alias. More... | |
| using | Strings = std::vector< std::string > |
| Convenience type alias. More... | |
Protected Attributes inherited from FiDeviceFunctionBase | |
| FT_FILE | myFile |
| File handle of this device function. More... | |
| std::string | myParent |
| Name of FEDEM model that owns this function. More... | |
| std::string | myDatasetDevice |
| Name of file associated with myFile. More... | |
| Endianness | myOutputEndian |
| Endianness assumed for binary output. More... | |
| Endianness | myInputEndian |
| Endianness assumed for binary input. More... | |
| double | myStep |
| Time series information. More... | |
| std::array< AxisInfo, 2 > | myAxisInfo |
Static Protected Attributes inherited from FiDeviceFunctionBase | |
| static Endianness | myMachineEndian |
| Endianness for the running computer. More... | |
Class representing external device functions based on ASCII files.
This class is used to represent a polyline (or piece-wise linear) function defined through a sequence of (x,y) points, where the x- and y-values are stored as two columns of a multi-column ASCII file (the file itself may contain two or more columns of data). The first column of the file is always the x-values, which need to be monotonically increasing, i.e., xi-1 ≤ xi ≤ xi+1 for all i.
|
private |
Convenience type alias.
|
private |
Mapping from x-value (time) to channel values.
|
explicit |
Default constructor.
| [in] | fname | Name of file containing the function data. |
| [in] | nchan | Number of channels in file (used when writing the file) |
|
protectedvirtual |
Writes all function data to file.
Implements FiDeviceFunctionBase.
|
virtual |
Extracts the list of channel names (file column labels).
Reimplemented from FiDeviceFunctionBase.
|
virtual |
Extracts all function data point values within specified interval.
| [out] | x | X-values (argument values) of all points within the interval |
| [out] | y | Y-values (function values) of all points within the interval |
| [in] | channel | Channel name identifying the function values to use |
| [in] | minX | Lower bound of function argument interval |
| [in] | maxX | Upper bound of function argument interval |
Reimplemented from FiDeviceFunctionBase.
|
static |
Counts the number of channels (number of columns minus one).
|
virtual |
Extracts all function data point values within specified interval.
| [out] | x | X-values (argument values) of all points within the interval |
| [out] | y | Y-values (function values) of all points within the interval |
| [in] | minX | Lower bound of function argument interval |
| [in] | maxX | Upper bound of function argument interval |
| [in] | channel | Column index identifying the function values to use |
Implements FiDeviceFunctionBase.
|
virtual |
Evaluates the function for a given x value.
| [in] | x | The function argument to evaluate for |
| [in] | channel | Column index identifying the function values to use |
| [in] | zeroAdjust | If true, the function values are shifted such that it evaluates to zero (or vertShift) at its first point value |
| [in] | vertShift | Additional function-value shift |
| [in] | scaleFac | Function-value scaling factor |
Implements FiDeviceFunctionBase.
|
inlinevirtual |
Returns the number of (x,y) pairs of the function.
Implements FiDeviceFunctionBase.
|
virtual |
Evaluates the function at all points within specified interval.
| [in] | x0 | Lower bound of function argument interval |
| [in] | x1 | Upper bound of function argument interval |
| [out] | x | X-values (argument values) of all points within the interval |
| [out] | y | Y-values (function values) of all points within the interval |
| [in] | channel | Column index identifying the function values to use |
| [in] | zeroAdj | If true, the function values are shifted such that it evaluates to zero (or shift) at its first point value |
| [in] | shift | Additional function-value shift |
| [in] | scale | Function-value scaling factor |
This method is equivalent to the getRawData() method if invoked with zeroAdj = false, shift = 0.0 and scale = 1.0, however, the former method will be more efficient in that case.
Implements FiDeviceFunctionBase.
|
protectedvirtual |
Reads the file and loads the first channel into core.
Implements FiDeviceFunctionBase.
|
virtual |
Returns the column index of the named channel.
Reimplemented from FiDeviceFunctionBase.
|
virtual |
Returns true if channel is a valid column index.
Reimplemented from FiDeviceFunctionBase.
|
static |
Checks if the specified file consists of two or more columns.
|
inlineprotectedvirtual |
Dummy method doing nothing.
Implements FiDeviceFunctionBase.
|
private |
Reads the specified channel into core.
Reads the header section of a specified file.
| [in] | fd | File descriptor to read from |
| [out] | header | Array of channel names (column labels) of the file |
|
static |
Reads the next line of data from specified file.
| [in] | fd | File descriptor to read from |
| [in] | columns | Column indices of the channels to read |
| [out] | values | Array of channel values |
Adds a channel to current file by interpolation.
Implements FiDeviceFunctionBase.
|
virtual |
Assigns a name to the (last) channel in file.
Reimplemented from FiDeviceFunctionBase.
|
virtual |
Adds an empty channel to the file.
Reimplemented from FiDeviceFunctionBase.
|
inlinevirtual |
Defines the output precision.
Reimplemented from FiDeviceFunctionBase.
|
virtual |
Assigns a function value for a single-channel function.
Implements FiDeviceFunctionBase.
|
static |
Buffer size for ASCII output in KBytes.
|
private |
Channel names (columns labels)
|
private |
If true, this file has microsec as first column.
|
private |
Channel (column index) that currently resides in core.
|
private |
Number of columns minus 1 (column 1 is the X-values)
|
private |
Curve data, either for all or one channel.
|
private |
0: 4-digits, 1: 8 digits, 2: 16-digits
|
private |
Start iterator of last evaluation interval.
|
private |
End iterator of last evaluation interval.