Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Accelerator Control System
epics-support
csm
Commits
18e9ea56
Commit
18e9ea56
authored
Apr 25, 2018
by
Franksen, Benjamin
Browse files
csmbase: remove header generation, move docs for public entities to header
parent
ef5bf37e
Changes
3
Hide whitespace changes
Inline
Side-by-side
csmApp/Makefile
View file @
18e9ea56
...
...
@@ -12,13 +12,6 @@ include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
$(COMMON_DIR)/csmbase.h
:
csmbase.c $(COMMON_DIR)/hgen.pl
PATH
=
$$
PATH:
$(COMMON_DIR)
hgen.pl
-c
-h
$@
$<
$(COMMON_DIR)/hgen.pl
:
../hgen.pl
$(CP)
$<
$@
chmod
+x
$@
# $(COMMON_DIR)/%: csmbase.c ../Doxyfile.external
# rm -rf $@
# mkdir -p $@
...
...
csmApp/csmbase.c
View file @
18e9ea56
/**************************************************************/
/* Author: Götz Pfeiffer */
/**************************************************************/
/*____________________________________________________________*/
/*----------------------------------------------------*/
/* General Comments */
/*----------------------------------------------------*/
/*! \file csmbase.c
\brief implement function table
\author Götz Pfeiffer (goetz.pfeiffer\@helmholtz-berlin.de)
...
...
@@ -17,20 +8,13 @@
defined in the file don't have to be in the same distance.
*/
/*@ITI________________________________________________________*/
/*____________________________________________________________*/
/* general Defines */
/*
@ET
_________________________________________________________*/
/*
___
_________________________________________________________*/
/*@EM("\n#ifndef __CSMBASE_H\n#define __CSMBASE_H\n") */
#ifndef DOXYGEN_SKIP_THIS
#ifndef B_LINUX
/*! \internal \brief select compilation under vxWorks */
#define B_VXWORKS
#endif
/*! \internal \brief needed for POSIX compability */
#define _INCLUDE_POSIX_SOURCE
...
...
@@ -170,30 +154,20 @@
/* math.h for definition of NAN */
#include
<math.h>
/*@ITI________________________________________________________*/
/* Defines */
/*@ET_________________________________________________________*/
#include
"csmbase.h"
/*................................................
*/
/*@IL
the NAN number type
*/
/*................................................
*/
/*____________________________________________________________
*/
/*
Defines
*/
/*____________________________________________________________
*/
#ifndef NAN
/*! \internal \brief define NAN if it is not yet defined */
#define NAN (-(0.0/0.0))
#endif
/*
@ITI
________________________________________________________*/
/*
____
________________________________________________________*/
/* Types */
/*@ET_________________________________________________________*/
/*................................................*/
/*@IL the csm_bool type (public) */
/*................................................*/
/*! \brief the boolean data type used in this module */
typedef
int
csm_bool
;
/*@IL*/
/*____________________________________________________________*/
/*................................................*/
/* the coordinate type (private) */
...
...
@@ -293,15 +267,6 @@ struct csm_Function
};
/*................................................*/
/*@IL the function-object (public) */
/*................................................*/
/*! \brief the abstract csm function object */
/*@IT*/
typedef
struct
csm_Function
csm_function
;
/*@ET*/
/*____________________________________________________________*/
/* Variables */
/*____________________________________________________________*/
...
...
@@ -319,7 +284,7 @@ static csm_bool initialized= CSM_FALSE;
/*____________________________________________________________*/
/* Functions */
/*
@ET
_________________________________________________________*/
/*
___
_________________________________________________________*/
/*----------------------------------------------------*/
...
...
@@ -1006,20 +971,9 @@ printf(" ret: %f\n",
}
/*----------------------------------------------------*/
/*
@IL
generic functions (public) */
/*
generic functions (public) */
/*----------------------------------------------------*/
/*! \brief compute x from a given y
This function computes x when y is given. Note that is doesn't
work for two-dimensional function tables. For these, the
function returns 0
\param func pointer to the function object
\param y the value of y
\return x
*/
/*@EX(1)*/
double
csm_x
(
csm_function
*
func
,
double
y
)
{
double
ret
;
...
...
@@ -1051,17 +1005,6 @@ double csm_x(csm_function *func, double y)
return
(
ret
);
}
/*! \brief compute y from a given x
This function computes y when x is given. Note that is doesn't
work for two-dimensional function tables. For these, the
function returns 0
\param func pointer to the function object
\param x the value of x
\return y
*/
/*@EX(1)*/
double
csm_y
(
csm_function
*
func
,
double
x
)
{
double
ret
;
...
...
@@ -1093,18 +1036,6 @@ double csm_y(csm_function *func, double x)
return
(
ret
);
}
/*! \brief compute delta-x from a given delta-y
This function computes a delta-x when a delta-y is given.
Note that this function only works with linear functions.
For all other types, this function
returns 0.
\param func pointer to the function object
\param y the given delta-y
\return delta-x
*/
/*@EX(1)*/
double
csm_dx
(
csm_function
*
func
,
double
y
)
{
double
ret
;
...
...
@@ -1126,18 +1057,6 @@ double csm_dx(csm_function *func, double y)
return
(
ret
);
}
/*! \brief compute delta-y from a given delta-x
This function computes a delta-y when a delta-x is given.
Note that this function only works with linear functions.
For all other types, this function
returns 0.
\param func pointer to the function object
\param x the given delta-x
\return delta-y
*/
/*@EX(1)*/
double
csm_dy
(
csm_function
*
func
,
double
x
)
{
double
ret
;
...
...
@@ -1159,18 +1078,6 @@ double csm_dy(csm_function *func, double x)
return
(
ret
);
}
/*! \brief compute z from a given x and y
This function computes z for two-dimensional function table
when x and y are given. For all other function types, it returns
0.
\param func pointer to the function object
\param x the value of x
\param y the value of y
\return z
*/
/*@EX(1)*/
double
csm_z
(
csm_function
*
func
,
double
x
,
double
y
)
{
double
ret
;
...
...
@@ -1193,7 +1100,7 @@ double csm_z(csm_function *func, double x, double y)
}
/*----------------------------------------------------*/
/*
@IL
initialization */
/*
initialization */
/*----------------------------------------------------*/
/* initialize a csm_function object (private) */
...
...
@@ -1291,14 +1198,6 @@ static int strdoublescan(char *st, double *d, int no_of_cols)
/* clear a function (public) */
/*! \brief clear a function
This function clears the \ref csm_function structure. All
allocated memory is released, the internal type is set to CSM_NOTHING.
\param func pointer to the function object
*/
/*@EX(1)*/
void
csm_clear
(
csm_function
*
func
)
{
SEMTAKE
(
func
->
semaphore
);
func
->
on_hold
=
CSM_TRUE
;
...
...
@@ -1311,15 +1210,6 @@ void csm_clear(csm_function *func)
/* free all data for a function (public) */
/*! \brief free a function-structure
This function frees the \ref csm_function structure. All
allocated memory is released, even the memory of the basic internal
structure. This means that the cmd_function structure becomes
invalid and cannot be used again later. Use this function with caution.
\param func pointer to the function object
*/
/*@EX(1)*/
void
csm_free
(
csm_function
*
func
)
{
csm_clear
(
func
);
SEMDELETE
(
func
->
semaphore
);
...
...
@@ -1328,16 +1218,6 @@ void csm_free(csm_function *func)
/* define a function (public) */
/*! \brief define a linear function
This function initializes a \ref csm_function structure as
a linear function (y= a+b*x).
\param func pointer to the function object
\param a offset of y= a+b*x
\param b multiplier of y= a+b*x
*/
/*@EX(1)*/
void
csm_def_linear
(
csm_function
*
func
,
double
a
,
double
b
)
/* y= a+b*x */
{
SEMTAKE
(
func
->
semaphore
);
...
...
@@ -1353,16 +1233,6 @@ void csm_def_linear(csm_function *func, double a, double b)
func
->
on_hold
=
CSM_FALSE
;
}
/*! \brief re-define the offset of a linear function
This function re-defines the offset-factor of
a linear function (y= a+b*x).
\param func pointer to the function object
\param a offset of y= a+b*x
\return returns CSM_FALSE in case of an error, CSM_TRUE otherwise
*/
/*@EX(1)*/
csm_bool
csm_def_linear_offset
(
csm_function
*
func
,
double
a
)
{
if
(
func
->
type
!=
CSM_LINEAR
)
{
DBG_MSG_PRINTF2
(
"error in csm_def_linear_offset line %d,
\n
"
\
...
...
@@ -1377,16 +1247,6 @@ csm_bool csm_def_linear_offset(csm_function *func, double a)
return
(
CSM_TRUE
);
}
/*! \brief read parameters of one-dimensional function table
This function reads a one-dimensional function-table from a
file.
\param filename the name of the file
\param func pointer to the function object
\return returns CSM_FALSE in case of an error, CSM_TRUE otherwise
*/
/*@EX(1)*/
csm_bool
csm_read_1d_table
(
char
*
filename
,
csm_function
*
func
)
/* if len==0, the table length is determined by counting the number of lines
in the file from the current position to it's end */
...
...
@@ -1492,16 +1352,6 @@ csm_bool csm_read_1d_table(char *filename, csm_function *func)
return
(
CSM_TRUE
);
}
/*! \brief read parameters of two-dimensional function table
This function reads a two-dimensional function-table from a
file.
\param filename the name of the file
\param func pointer to the function object
\return returns CSM_FALSE in case of an error, CSM_TRUE otherwise
*/
/*@EX(1)*/
csm_bool
csm_read_2d_table
(
char
*
filename
,
csm_function
*
func
)
/* file format:
y1 y2 y3 ..
...
...
@@ -1668,13 +1518,6 @@ x2 z21 z22 z23 ...
/* initialize the module (public) */
/*! \brief initialize the module
This function should be called once to initialize the
module.
*/
/*@EX(1)*/
void
csm_init
(
void
)
{
if
(
initialized
)
...
...
@@ -1687,16 +1530,6 @@ void csm_init(void)
/* create a new function object */
/*! \brief create a new function object
This function returns a pointer to a new function object. The object
is initialized as an empty function
\return returns NULL in case of an error. Otherwise the
pointer to the csm_function is returned
*/
/*@EX(1)*/
csm_function
*
csm_new_function
(
void
)
{
csm_function
*
f
=
malloc
(
sizeof
(
csm_function
));
...
...
@@ -1719,7 +1552,7 @@ csm_function *csm_new_function(void)
}
/*----------------------------------------------------*/
/*
@IL
debugging (public) */
/*
debugging (public) */
/*----------------------------------------------------*/
/*! \internal
...
...
@@ -1818,13 +1651,6 @@ static void csm_pr_2d_table(csm_2d_functiontable *ft)
};
}
/*! \brief dump a new function object
This printfs information about the given function to
stdout.
\param func pointer to the function object
*/
/*@EX(1)*/
void
csm_pr_func
(
csm_function
*
func
)
{
if
(
func
->
on_hold
)
printf
(
"function is on hold!
\n
"
);
...
...
@@ -1858,21 +1684,3 @@ void csm_pr_func(csm_function *func)
break
;
};
}
/*@EM("#endif\n") */
#if 0
csm_free implementieren.
strukturen cachen (anhand des Filenamens)
Filenamen �bergeben
evtl die csm-struktur direkt allozieren
reload von Files implementieren
im Fehlerfall die alten Daten behalten
#endif
csmApp/csmbase.h
0 → 100644
View file @
18e9ea56
/*! \file csmbase.h
\brief interface for csmbase.c
\author Götz Pfeiffer (goetz.pfeiffer\@helmholtz-berlin.de)
\version 1.0
This module implements one and two dimensional function tables.
The tables can be specified by simple ascii files. The points
defined in the file don't have to be in the same distance.
*/
#ifndef __CSMBASE_H
#define __CSMBASE_H
/* TYPES */
/*! \brief the boolean data type used in this module */
typedef
int
csm_bool
;
/*! \brief the abstract csm function object */
typedef
struct
csm_Function
csm_function
;
/* GENERIC FUNCTIONS */
/*! \brief compute x from a given y
This function computes x when y is given. Note that is doesn't
work for two-dimensional function tables. For these, the
function returns 0
\param func pointer to the function object
\param y the value of y
\return x
*/
extern
double
csm_x
(
csm_function
*
func
,
double
y
);
/*! \brief compute y from a given x
This function computes y when x is given. Note that is doesn't
work for two-dimensional function tables. For these, the
function returns 0
\param func pointer to the function object
\param x the value of x
\return y
*/
extern
double
csm_y
(
csm_function
*
func
,
double
x
);
/*! \brief compute delta-x from a given delta-y
This function computes a delta-x when a delta-y is given.
Note that this function only works with linear functions.
For all other types, this function
returns 0.
\param func pointer to the function object
\param y the given delta-y
\return delta-x
*/
extern
double
csm_dx
(
csm_function
*
func
,
double
y
);
/*! \brief compute delta-y from a given delta-x
This function computes a delta-y when a delta-x is given.
Note that this function only works with linear functions.
For all other types, this function
returns 0.
\param func pointer to the function object
\param x the given delta-x
\return delta-y
*/
extern
double
csm_dy
(
csm_function
*
func
,
double
x
);
/*! \brief compute z from a given x and y
This function computes z for two-dimensional function table
when x and y are given. For all other function types, it returns
0.
\param func pointer to the function object
\param x the value of x
\param y the value of y
\return z
*/
extern
double
csm_z
(
csm_function
*
func
,
double
x
,
double
y
);
/* INITIALIZATION */
/*! \brief clear a function
This function clears the \ref csm_function structure. All
allocated memory is released, the internal type is set to CSM_NOTHING.
\param func pointer to the function object
*/
extern
void
csm_clear
(
csm_function
*
func
);
/*! \brief free a function-structure
This function frees the \ref csm_function structure. All
allocated memory is released, even the memory of the basic internal
structure. This means that the cmd_function structure becomes
invalid and cannot be used again later. Use this function with caution.
\param func pointer to the function object
*/
extern
void
csm_free
(
csm_function
*
func
);
/*! \brief define a linear function
This function initializes a \ref csm_function structure as
a linear function (y= a+b*x).
\param func pointer to the function object
\param a offset of y= a+b*x
\param b multiplier of y= a+b*x
*/
extern
void
csm_def_linear
(
csm_function
*
func
,
double
a
,
double
b
);
/*! \brief re-define the offset of a linear function
This function re-defines the offset-factor of
a linear function (y= a+b*x).
\param func pointer to the function object
\param a offset of y= a+b*x
\return returns CSM_FALSE in case of an error, CSM_TRUE otherwise
*/
extern
csm_bool
csm_def_linear_offset
(
csm_function
*
func
,
double
a
);
/*! \brief read parameters of one-dimensional function table
This function reads a one-dimensional function-table from a
file.
\param filename the name of the file
\param func pointer to the function object
\return returns CSM_FALSE in case of an error, CSM_TRUE otherwise
*/
extern
csm_bool
csm_read_1d_table
(
char
*
filename
,
csm_function
*
func
);
/*! \brief read parameters of two-dimensional function table
This function reads a two-dimensional function-table from a
file.
\param filename the name of the file
\param func pointer to the function object
\return returns CSM_FALSE in case of an error, CSM_TRUE otherwise
*/
extern
csm_bool
csm_read_2d_table
(
char
*
filename
,
csm_function
*
func
);
/*! \brief initialize the module
This function should be called once to initialize the
module.
*/
extern
void
csm_init
(
void
);
/*! \brief create a new function object
This function returns a pointer to a new function object. The object
is initialized as an empty function
\return returns NULL in case of an error. Otherwise the
pointer to the csm_function is returned
*/
extern
csm_function
*
csm_new_function
(
void
);
/* DEBUGGING */
/*! \brief dump a new function object
This printfs information about the given function to
stdout.
\param func pointer to the function object
*/
extern
void
csm_pr_func
(
csm_function
*
func
);
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment