17 #ifndef GBXUTILACFR_MATH_DEFINITIONS_H
18 #define GBXUTILACFR_MATH_DEFINITIONS_H
21 #if defined (GBXUTILACFR_STATIC)
22 #define GBXUTILACFR_EXPORT
23 #elif defined (GBXUTILACFR_EXPORTS)
24 #define GBXUTILACFR_EXPORT __declspec (dllexport)
26 #define GBXUTILACFR_EXPORT __declspec (dllimport)
29 #define GBXUTILACFR_EXPORT
41 #define _USE_MATH_DEFINES
52 #define M_PI 3.14159265358979323846
57 #define NAN (__builtin_nanf(""))
62 #define INF (__builtin_inff())
70 #define DEG2RAD_RATIO (M_PI/180.0)
74 #define DEG2RAD(deg) ((deg)*DEG2RAD_RATIO)
76 #define RAD2DEG(rad) ((rad)/DEG2RAD_RATIO)
81 GBXUTILACFR_EXPORT inline void NORMALISE_ANGLE( double &theta )
85 if (theta >= -M_PI && theta < M_PI)
88 multiplier = std::floor(theta / (2*M_PI));
89 theta -= multiplier*2*M_PI;
92 else if (theta < -M_PI)
99 GBXUTILACFR_EXPORT inline void NORMALISE_ANGLE( float &theta )
101 double thDouble = theta;
102 NORMALISE_ANGLE( thDouble );
103 theta = (float)thDouble;
115 #define MIN(x, y) (((x) < (y)) ? (x) : (y))
119 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
125 #define APPLY_LIMITS(max_x, x, min_x) \
126 if((x)>(max_x)) x=(max_x); if((x)<(min_x)) x=(min_x);
130 #define NORM2(x, y) (sqrt((x)*(x)+(y)*(y)))
134 #define NORM3(x, y, z) (sqrt((x)*(x)+(y)*(y)+(z)*(z)))
138 #define ROUND(x) ((int)(x+0.5))
143 #define ROUND_TO(n,d) (d*rint(n/d))
147 #define SIGN(A) ((A)<0?(-1):(1))
151 #define COS_LAW(side1, side2, theta) \
152 (sqrt(SQR(side1)+SQR(side2)-2.0*(side1)*(side2)*cos(theta)))
156 #define INV_COS_LAW(oppSide, side1, side2) \
157 (acos((SQR(side1)+SQR(side2)-SQR(oppSide))/(2.0*(side1)*(side2))))
161 #if defined (__SVR4) && defined (__sun)
162 #define isfinite(x) \
163 __extension__ ({ __typeof (x) __x_f = (x); \
164 __builtin_expect(!isnan(__x_f - __x_f), 1); })
167 __extension__ ({ __typeof (x) __x_i = (x); \
168 __builtin_expect(!isnan(__x_i) && !isfinite(__x_i), 0); })
178 #define NEAR(x,y,epsilon) (((x) > (y)-(epsilon)) && ((x) < (y)+(epsilon)))
184 GBXUTILACFR_EXPORT void
185 CLIP_TO_LIMITS( const T &min_x, T &x, const T &max_x )
187 assert( min_x <= max_x );
190 else if ( x < min_x )
bool conductAllHealthChecks(const OceanServerSystem &batteryData, const BatteryHealthWarningConfig &batteryConfig, std::vector< std::string > &warnShort, std::vector< std::string > &warnVerbose, bool printRawRecord) Definition: oceanserverhealthchecks.cpp:267
Definition: oceanserversystem.h:26
Base class for all GbxUtilAcfr exceptions. Definition: gbxutilacfr/exceptions.h:65
int minToEmpty() const Access minutes-to-empty. Definition: oceanserversystem.h:55
double chargeTempThreshhold Maximum charging temperature before a warning is issued. Definition: oceanserverhealthchecks.h:68
int expectedNumBatteries Expected number of battery modules installed. Definition: oceanserverhealthchecks.h:64
int chargeWarnThreshhold Minimum charge in percent before a warning is issued. Definition: oceanserverhealthchecks.h:72
int numCyclesThreshhold Maximum number of battery recharge cycles before a warning is issued. Definition: oceanserverhealthchecks.h:66
Definition: oceanserver.h:32
Exception for hardware reading problems. Definition: gbxsmartbatteryacfr/exceptions.h:19
Definition: oceanserverhealthchecks.h:61
double dischargeTempThreshhold Maximum discharging temperature before a warning is issued. Definition: oceanserverhealthchecks.h:70
A simple implementation of the tracer API which prints to cout. Definition: trivialtracer.h:35
int chargeDeviationThreshold Minimum deviation of a single battery from the average of all batteries before a warning is issued (i... Definition: oceanserverhealthchecks.h:74
|