|
From: <mk...@us...> - 2003-03-26 05:08:06
|
Update of /cvsroot/csp/APPLICATIONS/SimData/Include/SimData
In directory sc8-pr-cvs1:/tmp/cvs-serv22807/Include/SimData
Modified Files:
Date.h Interpolate.h Interpolate.i Random.h cSimData.i
vector.i
Log Message:
see CHANGES.current
Index: Date.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Date.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Date.h 19 Feb 2003 21:24:58 -0000 1.5
--- Date.h 26 Mar 2003 05:08:02 -0000 1.6
***************
*** 421,428 ****
! /*
! * Times are represented as floats in seconds since midnight. This
* makes time based calculations relatively easy. When the second
! * count exceeds 86000, the day is incremented and the clock reset.
* Resetting the clock can cause problems with calculations involving
* changes in time, so care must be taken. The advantage of keeping
--- 421,433 ----
! /**
! * class Zulu
! *
! * This class represents the time of day in "zulu" time (i.e. UTC
! * or Greenwich Mean).
! *
! * Times are stored as doubles in seconds since midnight. This
* makes time based calculations relatively easy. When the second
! * count exceeds 86400, the day is incremented and the clock reset.
* Resetting the clock can cause problems with calculations involving
* changes in time, so care must be taken. The advantage of keeping
***************
*** 430,436 ****
* intervals. In computing time intervals that should be small,
* use the SimDate::interval function.
*/
-
class SIMDATA_EXPORT Zulu {
--- 435,447 ----
* intervals. In computing time intervals that should be small,
* use the SimDate::interval function.
+ *
+ * A timezone parameter and options for operating on "local" times
+ * are provided. Care must be taken when using these methods in
+ * conjunction with dates, since the date may differ depending on
+ * whether local or zulu time is used.
+ *
+ * @author Mark Rose <mr...@st...>
*/
class SIMDATA_EXPORT Zulu {
***************
*** 438,441 ****
--- 449,457 ----
typedef double time_t;
+ /**
+ * Default constructor.
+ *
+ * Time set to midnight, Greenwich mean.
+ */
Zulu() {
m_time = 0;
***************
*** 443,446 ****
--- 459,470 ----
}
+ /**
+ * Construct a Zulu from the hour, minute, and second.
+ *
+ * @param hour hour (0-23)
+ * @param minute minute (0-59)
+ * @param second second (0.0-60.0)
+ * @param tz timezone (defaults to Greenwich mean)
+ */
Zulu(int hour, int minute, time_t second, int tz=0) {
m_time = hour*3600.0 + minute*60.0 + second;
***************
*** 448,451 ****
--- 472,481 ----
}
+ /**
+ * Construct a Zulu from the seconds since midnight.
+ *
+ * @param second seconds since midnight (0.0-86400.0)
+ * @param tz timezone (default to Greenwich mean)
+ */
Zulu(time_t second, int tz=0) {
m_time = second;
***************
*** 453,456 ****
--- 483,489 ----
}
+ /**
+ * Copy constructor
+ */
Zulu(const Zulu &z) {
*this = z;
***************
*** 458,461 ****
--- 491,497 ----
#ifndef SWIG
+ /**
+ * Copy operator.
+ */
const Zulu &operator=(const Zulu &z) {
m_time = z.m_time;
***************
*** 465,486 ****
#endif // SWIG
void setTZ(int tz) {
m_tz = tz;
}
int getTZ() const {
return m_tz;
}
int reduce();
time_t getTime(bool local=false) const {
return m_time + (local ? (m_tz * 3600.0) : 0.0);
}
bool overflow() const {
! return m_time >= 86000.0f;
}
int getHour(bool local=false) const {
int adjust = local ? m_tz : 0;
--- 501,550 ----
#endif // SWIG
+ /**
+ * Set the timezone (only effects the local time)
+ *
+ * @param tz timezone (hour offset from Greenwich mean)
+ */
void setTZ(int tz) {
m_tz = tz;
}
+ /**
+ * Get the timezone.
+ */
int getTZ() const {
return m_tz;
}
+ /**
+ * Wrap time to 24 hour period.
+ *
+ * Reduces the seconds since midnight to the range 0-86400.
+ *
+ * @returns the number of days subtracted to bring the time into range.
+ */
int reduce();
+ /**
+ * Get the curret time in seconds since midnight.
+ *
+ * @param local adjust the result to reflect the timezone.
+ */
time_t getTime(bool local=false) const {
return m_time + (local ? (m_tz * 3600.0) : 0.0);
}
+ /**
+ * Test if the time accumulator exceeds 24 hours.
+ */
bool overflow() const {
! return m_time >= 86400.0f;
}
+ /**
+ * Get the hour.
+ *
+ * @param local adjust the result to reflect the timezone.
+ */
int getHour(bool local=false) const {
int adjust = local ? m_tz : 0;
***************
*** 488,511 ****
}
int getMinute() const {
return (((int)m_time) / 60) % 60;
}
int getSecond() const {
return ((int)m_time) % 60;
}
! void addTime(time_t dt) {
m_time += dt;
}
! void setTime(time_t t) {
m_time = t;
}
void convert(struct tm *tm, bool local=false) const;
std::string formatString(const char *format, bool local=false) const;
virtual std::string asString() const {
return formatString("%H:%M:%Sz");
--- 552,611 ----
}
+ /**
+ * Get the minute.
+ */
int getMinute() const {
return (((int)m_time) / 60) % 60;
}
+ /**
+ * Get the second.
+ */
int getSecond() const {
return ((int)m_time) % 60;
}
! /**
! * Advance the time.
! *
! * @param dt the number of seconds to add.
! * @return true if the time exceeds 24 hours (zulu)
! */
! bool addTime(time_t dt) {
m_time += dt;
+ return overflow();
}
! /**
! * Set the time.
! *
! * @param t the number of seconds since midnight.
! * @param local if true, t represents the local time (not zulu).
! */
! void setTime(time_t t, bool local=false) {
! if (local) t -= m_tz * 3600.0;
m_time = t;
}
+ /**
+ * Extract time from a C tm structure.
+ *
+ * @param tm a time structure returned by gmtime() and localtime()
+ * @param local if true, tm represents the local time (not zulu).
+ */
void convert(struct tm *tm, bool local=false) const;
+ /**
+ * Format the time as a string.
+ *
+ * @param format a format string: see the standard C function strftime() for details.
+ * @param local if true, format the local time (not zulu).
+ */
std::string formatString(const char *format, bool local=false) const;
+
+ /**
+ * Return the time as a string in the form "HH:MM::SSz"
+ */
virtual std::string asString() const {
return formatString("%H:%M:%Sz");
***************
*** 518,521 ****
--- 618,630 ----
+
+ /**
+ * class DateZulu
+ *
+ * This class combines time and date operations into a single object.
+ *
+ * @author Mark Rose <mr...@st...>
+ */
+
class SIMDATA_EXPORT DateZulu: public Date, public Zulu {
***************
*** 580,583 ****
--- 689,696 ----
+ /**
+ * SimTime is not actually a class, but just a floating point
+ * type that stores seconds since midnight.
+ */
typedef DateZulu::time_t SimTime;
Index: Interpolate.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Interpolate.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Interpolate.h 28 Jan 2003 23:26:06 -0000 1.2
--- Interpolate.h 26 Mar 2003 05:08:02 -0000 1.3
***************
*** 46,52 ****
--- 46,54 ----
+ /*
#define value_t float
#define vector_t std::vector<value_t>
#define vector_it std::vector<value_t>::iterator
+ */
***************
*** 76,82 ****
public:
! // typedef float value_t;
! // typedef vector<value_t> vector_t;
! // typedef vector<value_t>::iterator vector_it;
static const Enumeration Method;;
--- 78,85 ----
public:
! typedef float value_t;
! typedef std::vector<value_t> vector_t;
! typedef std::vector<value_t>::iterator vector_it;
! typedef std::vector<value_t>::const_iterator vector_cit;
static const Enumeration Method;;
***************
*** 90,94 ****
virtual value_t getPrecise(value_t, value_t) const;
vector_t compute_second_derivatives(const vector_t& breaks, const vector_t& data);
! int find(vector_t b, value_t v);
};
--- 93,97 ----
virtual value_t getPrecise(value_t, value_t) const;
vector_t compute_second_derivatives(const vector_t& breaks, const vector_t& data);
! int find(vector_t b, value_t v) const;
};
***************
*** 122,128 ****
void interpolate(value_t spacing);
virtual void _compute_second_derivatives();
! value_t getPrecise(value_t v);
! value_t getValue(value_t p);
! void dumpCurve(FILE* f);
virtual std::string asString() const;
};
--- 125,131 ----
void interpolate(value_t spacing);
virtual void _compute_second_derivatives();
! value_t getPrecise(value_t v) const;
! value_t getValue(value_t p) const;
! void dumpCurve(FILE* f) const;
virtual std::string asString() const;
};
***************
*** 154,158 ****
#endif // SWIG
void invalidate();
! int isValid();
virtual void pack(Packer &p) const;
virtual void unpack(UnPacker &p);
--- 157,161 ----
#endif // SWIG
void invalidate();
! int isValid() const;
virtual void pack(Packer &p) const;
virtual void unpack(UnPacker &p);
***************
*** 169,179 ****
void setData(const vector_t& data);
void interpolate();
! value_t getPrecise(value_t x, value_t y);
! value_t getValue(value_t x, value_t y);
virtual void _compute_second_derivatives();
! void toPGM(FILE *fp);
! void dumpTable(FILE *fp);
! void dumpDRows(FILE *fp);
! void dumpDCols(FILE *fp);
virtual std::string asString() const;
--- 172,182 ----
void setData(const vector_t& data);
void interpolate();
! value_t getPrecise(value_t x, value_t y) const;
! value_t getValue(value_t x, value_t y) const;
virtual void _compute_second_derivatives();
! void toPGM(FILE *fp) const;
! void dumpTable(FILE *fp) const;
! void dumpDRows(FILE *fp) const;
! void dumpDCols(FILE *fp) const;
virtual std::string asString() const;
Index: Interpolate.i
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Interpolate.i,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Interpolate.i 28 Jan 2003 23:26:06 -0000 1.2
--- Interpolate.i 26 Mar 2003 05:08:02 -0000 1.3
***************
*** 5,11 ****
--- 5,14 ----
%include "std_vector.i"
+ #ifndef VFLOAT
+ #define VFLOAT
namespace std {
%template(vector_t) vector<float>;
}
+ #endif
using namespace std;
typedef std::vector vector;
Index: Random.h
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Random.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Random.h 6 Feb 2003 21:22:39 -0000 1.4
--- Random.h 26 Mar 2003 05:08:02 -0000 1.5
***************
*** 30,34 ****
#define __RANDOM_H__
! #include <math.h>
#include <SimData/Export.h>
--- 30,34 ----
#define __RANDOM_H__
! #include <cmath>
#include <SimData/Export.h>
***************
*** 61,68 ****
_r = ran2(_seed);
}
! float GetRand() {
return _r;
}
! float NewRand() {
_r = ran2(_seed);
return _r;
--- 61,71 ----
_r = ran2(_seed);
}
! float getRand() const {
return _r;
}
! long getSeed() const {
! return _seed;
! }
! float newRand() {
_r = ran2(_seed);
return _r;
***************
*** 84,88 ****
float box_muller(float, float);
float newGauss();
! float getGauss() { return _g; }
};
--- 87,91 ----
float box_muller(float, float);
float newGauss();
! float getGauss() const { return _g; }
};
Index: cSimData.i
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/cSimData.i,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** cSimData.i 20 Mar 2003 17:53:41 -0000 1.4
--- cSimData.i 26 Mar 2003 05:08:02 -0000 1.5
***************
*** 52,55 ****
--- 52,57 ----
%include "SimData/Exception.i"
%include "SimData/HashUtility.i"
+ %include "SimData/Conversions.i"
+ %include "SimData/Noise.i"
%include "SimData/Types.i"
Index: vector.i
===================================================================
RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/vector.i,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** vector.i 28 Jan 2003 23:26:06 -0000 1.2
--- vector.i 26 Mar 2003 05:08:03 -0000 1.3
***************
*** 8,15 ****
#define __VECTOR_TEMPLATES__
namespace std {
! # %template(vector_d) vector<double>;
%template(vector_s) vector<Spread>;
! # %template(vector_f) vector<float>;
! # %template(vector_i) vector<int>;
}
#endif // __VECTOR_TEMPLATES__
--- 8,15 ----
#define __VECTOR_TEMPLATES__
namespace std {
! // %template(vector_d) vector<double>;
%template(vector_s) vector<Spread>;
! // %template(vector_f) vector<float>;
! // %template(vector_i) vector<int>;
}
#endif // __VECTOR_TEMPLATES__
|