root/branches/maintenance/3.0/Modelica/C-Sources/ModelicaTables.h

Revision 1006, 5.9 kB (checked in by otter, 10 months ago)
Line 
1#ifndef MODELICA_TABLES_H
2#define MODELICA_TABLES_H
3
4/* Definition of interface to external functions for table computation
5   in the Modelica Standard Library:
6
7       Modelica.Blocks.Sources.CombiTimeTable
8       Modelica.Blocks.Tables.CombiTable1D
9       Modelica.Blocks.Tables.CombiTable1Ds
10       Modelica.Blocks.Tables.CombiTable2D
11
12
13   Release Notes:
14      Jan. 27, 2008: by Martin Otter.
15                     Implemented a first version
16
17   Copyright (C) 2008, Modelica Association and DLR.
18
19   The content of this file is free software; it can be redistributed
20   and/or modified under the terms of the Modelica license, see the
21   license conditions and the accompanying disclaimer in file
22   ModelicaLicense.txt or in Modelica.UsersGuide.ModelicaLicense.
23*/
24
25
26/* A table can be defined in the following ways when initializing the table:
27
28     (1) Explicitly supplied in the argument list
29         (= table    is "NoName" or has only blanks AND
30            fileName is "NoName" or has only blanks).
31
32     (2) Read from a file (tableName, fileName have to be supplied).
33
34*/
35
36extern int ModelicaTables_CombiTimeTable_init(
37                      const char*   tableName,
38                      const char*   fileName, 
39                      double const* table, int nRow, int nColumn,
40                      double        startTime, 
41                      int           smoothness,
42                      int           extrapolation);
43  /* Initialize 1-dim. table where first column is time
44
45      -> tableName : Name of table.
46      -> fileName  : Name of file.
47      -> table     : If tableName="NoName" or has only blanks AND
48                        fileName ="NoName" or has only blanks, then
49                     this pointer points to a 2-dim. array (row-wise storage)
50                     in the Modelica environment that holds this matrix.
51      -> nRow      : Number of rows of table
52      -> nColumn   : Number of columns of table
53      -> startTime : Output = offset for time < startTime
54      -> smoothness: Interpolation type
55                     = 1: linear
56                     = 2: continuous first derivative
57      <- RETURN    : ID of internal memory of table.   
58  */
59
60extern void ModelicaTables_CombiTimeTable_close(int tableID);
61  /* Close table and free allocated memory */
62
63
64extern double ModelicaTables_CombiTimeTable_minimumTime(int tableID);
65  /* Return minimum time defined in table (= table[1,1]) */
66
67
68extern double ModelicaTables_CombiTimeTable_maximumTime(int tableID);
69  /* Return maximum time defined in table (= table[end,1]) */
70
71
72extern double ModelicaTables_CombiTimeTable_interpolate(int tableID, int icol, double u);
73  /* Interpolate in table
74   
75     -> tableID: Pointer to table defined with ModelicaTables_CombiTimeTable_init
76     -> icol   : Column to interpolate
77     -> u      : Abscissa value (time)
78     <- RETURN : Ordinate value
79 */
80
81
82
83extern int ModelicaTables_CombiTable1D_init(
84                  const  char*  tableName, 
85                  const  char*  fileName, 
86                  double const* table, int nRow, int nColumn,
87                  int smoothness);
88  /* Initialize 1-dim. table defined by matrix, where first column
89     is x-axis and further columns of matrix are interpolated
90
91      -> tableName : Name of table.
92      -> fileName  : Name of file.
93      -> table     : If tableName="NoName" or has only blanks AND
94                        fileName ="NoName" or has only blanks, then
95                     this pointer points to a 2-dim. array (row-wise storage)
96                     in the Modelica environment that holds this matrix.
97      -> nRow      : Number of rows of table
98      -> nColumn   : Number of columns of table
99      -> smoothness: Interpolation type
100                     = 1: linear
101                     = 2: continuous first derivative
102      <- RETURN    : ID of internal memory of table.   
103  */
104
105extern void ModelicaTables_CombiTable1D_close(int tableID);
106  /* Close table and free allocated memory */
107
108extern double ModelicaTables_CombiTable1D_interpolate(int tableID, int icol, double u);
109  /* Interpolate in table
110   
111     -> tableID: Pointer to table defined with ModelicaTables_CombiTable1D_init
112     -> icol   : Column to interpolate
113     -> u      : Abscissa value
114     <- RETURN : Ordinate value
115 */
116
117
118
119extern int ModelicaTables_CombiTable2D_init(
120                   const char*   tableName,
121                   const char*   fileName, 
122                   double const* table, int nRow, int nColumn, 
123                   int smoothness);
124  /* Initialize 2-dim. table defined by matrix, where first column
125     is x-axis, first row is y-axis and the matrix elements are the
126     z-values.
127       table[2:end,1    ]: Values of x-axis
128            [1    ,2:end]: Values of y-axis
129            [2:end,2:end]: Values of z-axis
130
131      -> tableName : Name of table.
132      -> fileName  : Name of file.
133      -> table     : If tableName="NoName" or has only blanks AND
134                        fileName ="NoName" or has only blanks, then
135                     this pointer points to a 2-dim. array (row-wise storage)
136                     in the Modelica environment that holds this matrix.
137      -> nRow      : Number of rows of table
138      -> nColumn   : Number of columns of table
139      -> smoothness: Interpolation type
140                     = 1: linear
141                     = 2: continuous first derivative
142      <- RETURN    : ID of internal memory of table.   
143  */
144
145extern void ModelicaTables_CombiTable2D_close(int tableID);
146  /* Close table and free allocated memory */
147
148extern double ModelicaTables_CombiTable2D_interpolate(int tableID, double u1, double u2);
149  /* Interpolate in table
150   
151     -> tableID: Pointer to table defined with ModelicaTables_CombiTable1D_init
152     -> u1     : x-axis value
153     -> u2     : y-axis value
154     <- RETURN : y-axis value
155 */
156
157
158#endif  /* MODELICA_TABLES */
Note: See TracBrowser for help on using the browser.