13 #ifndef FI_DEVICE_FUNCTION_FACTORY_H
14 #define FI_DEVICE_FUNCTION_FACTORY_H
65 bool littleEndian =
false);
68 void close(
const std::string& fileName);
70 void close(
int fileIndex);
82 int zeroAd = 0,
double shift = 0.0,
double scale = 1.0)
const;
93 bool getValues(
int fileIndex,
double x0,
double x1,
94 std::vector<double>&
x, std::vector<double>& y,
95 int channel = 0,
int zeroAdjust = 0,
96 double shift = 0.0,
double scale = 1.0)
const;
99 double getStep(
int fileIndex)
const;
104 void getAxisTitle(
int fileIndex,
int axis,
char* axisText,
size_t n)
const;
106 void getAxisUnit(
int fileIndex,
int axis,
char* unitText,
size_t n)
const;
109 bool setValue(
int fileIndex,
double xVal,
double yVal);
112 void setStep(
int fileIndex,
double step)
const;
117 void setAxisTitle(
int fileIndex,
int axis,
const char* axisText)
const;
119 void setAxisUnit(
int fileIndex,
int axis,
const char* unitText)
const;
124 bool getChannelList(
int fileIndex, std::vector<std::string>& ch)
const;
128 std::vector<std::string>& channels);
132 const std::string& path =
"",
142 const std::string& labels =
"");
152 return this->
getValue(0,0.0,stat,idx);
171 int create(
const std::string& fileName,
int inputChannel,
Functions and data type for direct access of large binary files.
#define FT_FILE
File pointer.
Definition: FFaIO.H:136
FiStatus
Enum for file opening modes.
Definition: FiDeviceFunctionFactory.H:26
@ IO_WRITE
Write access.
Definition: FiDeviceFunctionFactory.H:28
@ IO_READ
Read only access.
Definition: FiDeviceFunctionFactory.H:27
FiDevFormat
Enum for file formats.
Definition: FiDeviceFunctionFactory.H:32
@ EXT_FUNC
External function (no file)
Definition: FiDeviceFunctionFactory.H:39
@ RPC_TH_FILE
RPC time history fomrat (MTS binary format)
Definition: FiDeviceFunctionFactory.H:38
@ DAC_FILE
DAC file (nCode binary format)
Definition: FiDeviceFunctionFactory.H:35
@ UNKNOWN_FILE
Unknown or undefined file format.
Definition: FiDeviceFunctionFactory.H:34
@ ASC_MC_FILE
Multi-column ASCII format.
Definition: FiDeviceFunctionFactory.H:37
@ ASC_FILE
Two-column ASCII format.
Definition: FiDeviceFunctionFactory.H:36
@ NON_EXISTING
Non-existing file.
Definition: FiDeviceFunctionFactory.H:33
Template class for singleton classes.
Definition: FFaSingelton.H:20
Definition: FiDeviceFunctionBase.H:19
Singleton class for external device functions (functions from file).
Definition: FiDeviceFunctionFactory.H:48
FileChnMap myFileChannelMap
File name/channel to device index mapping.
Definition: FiDeviceFunctionFactory.H:191
std::vector< double > myExtValues
Function values for external functions.
Definition: FiDeviceFunctionFactory.H:193
int create(const std::string &fileName, int inputChannel, FiDevFormat format, FiStatus status, bool useLittleEndian)
Opens the named file, not already opened.
Definition: FiDeviceFunctionFactory.C:108
double getFrequency(int fileIndex) const
Returns (constant) sampling frequency of the indexed function.
Definition: FiDeviceFunctionFactory.C:378
FiDeviceFunctionFactory()
Default constructor.
Definition: FiDeviceFunctionFactory.H:51
void getAxisUnit(int fileIndex, int axis, char *unitText, size_t n) const
Returns the axis unit of the indexed function.
Definition: FiDeviceFunctionFactory.C:340
virtual ~FiDeviceFunctionFactory()
The destructor closes all opened files.
Definition: FiDeviceFunctionFactory.C:27
void setAxisTitle(int fileIndex, int axis, const char *axisText) const
Sets the axis title of the indexed function.
Definition: FiDeviceFunctionFactory.C:315
std::pair< std::string, int > FileChannel
File name and column index pair.
Definition: FiDeviceFunctionFactory.H:184
static FiDevFormat identify(const std::string &fileName, const std::string &path="", FiStatus status=IO_READ)
Returns the file format of a named function file.
Definition: FiDeviceFunctionFactory.C:180
std::vector< FiDeviceFunctionBase * > myDevices
Device function container.
Definition: FiDeviceFunctionFactory.H:188
void getAxisTitle(int fileIndex, int axis, char *axisText, size_t n) const
Returns the axis title of the indexed function.
Definition: FiDeviceFunctionFactory.C:332
bool initExtFuncFromFile(const std::string &fileName, const std::string &labels="")
Opens a file to read external function values from.
Definition: FiDeviceFunctionFactory.C:471
bool getValues(int fileIndex, double x0, double x1, std::vector< double > &x, std::vector< double > &y, int channel=0, int zeroAdjust=0, double shift=0.0, double scale=1.0) const
Evaluate the indexed function for the specified argument range.
Definition: FiDeviceFunctionFactory.C:258
bool getChannelList(int fileIndex, std::vector< std::string > &ch) const
Returns the list of channel labels for the indexed function.
Definition: FiDeviceFunctionFactory.C:395
bool setValue(int fileIndex, double xVal, double yVal)
Sets an argument/value pair for an indexed function.
Definition: FiDeviceFunctionFactory.C:276
FT_FILE myExtFnFile
External function value file handle.
Definition: FiDeviceFunctionFactory.H:195
double getStep(int fileIndex) const
Returns (constant) argument increment of the indexed function.
Definition: FiDeviceFunctionFactory.C:372
double getValue(int fileIndex, double arg, int &stat, int channel=0, int zeroAd=0, double shift=0.0, double scale=1.0) const
Evaluates the indexed function for the specified argument value.
Definition: FiDeviceFunctionFactory.C:227
std::map< std::string, size_t > FileMap
File name to device index mapping.
Definition: FiDeviceFunctionFactory.H:182
void setFrequency(int fileIndex, double freq) const
Sets the constant sampling frequency of the indexed function.
Definition: FiDeviceFunctionFactory.C:353
void dump() const
Prints a summary of the currently open files to std::cout.
Definition: FiDeviceFunctionFactory.C:438
int channelIndex(int fileIndex, const std::string &channel) const
Returns the index of a named channel of the indexed function.
Definition: FiDeviceFunctionFactory.C:387
void setAxisUnit(int fileIndex, int axis, const char *unitText) const
Sets the axis unit of the indexed function.
Definition: FiDeviceFunctionFactory.C:323
std::map< FileChannel, size_t > FileChnMap
File name and column to device index mapping.
Definition: FiDeviceFunctionFactory.H:186
FileMap myFileToIndexMap
File name to device index mapping.
Definition: FiDeviceFunctionFactory.H:190
void setStep(int fileIndex, double step) const
Sets the constant argument increment of the indexed function.
Definition: FiDeviceFunctionFactory.C:360
double getExtFunc(int idx, int stat=0) const
Evaluates an indexed external function.
Definition: FiDeviceFunctionFactory.H:150
int open(const std::string &fileName, FiDevFormat format=UNKNOWN_FILE, FiStatus status=IO_READ, int inputChannel=0, bool littleEndian=false)
Opens the named file.
Definition: FiDeviceFunctionFactory.C:35
std::vector< int > myExtIndex
Associated file column indices.
Definition: FiDeviceFunctionFactory.H:194
FiDeviceFunctionBase * getDevice(size_t fileIndex) const
Returns the device object for the indexed function.
Definition: FiDeviceFunctionFactory.C:450
void close(const std::string &fileName)
Closes the named file.
Definition: FiDeviceFunctionFactory.C:96
void storeExtFuncValues(double *data, unsigned int ndat, int iop, int &offs)
Stores/extracts external function values from in-core array.
Definition: FiDeviceFunctionFactory.C:545
bool updateExtFuncFromFile(int nstep=1)
Updates the external function values from file.
Definition: FiDeviceFunctionFactory.C:532
static int myNumExtFun
Number of external functions in current model.
Definition: FiDeviceFunctionFactory.H:178
integer(ptr), save, private x
Definition: extCtrlSysRoutinesModule.f90:16
integer channel
Column index for data file.
Definition: initiateFunctionTypeModule.f90:26
integer, save nstep
Definition: saveVTFModule.f90:25
static int iop
Internal operation status variable.
Definition: solverInterface.C:49
subroutine scale(vec, a)
Definition: windTurbineRoutinesModule.f90:510