00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <RectangularSeries.h>
00038 #include <Vector.h>
00039 #include <Channel.h>
00040
00041 RectangularSeries::RectangularSeries(double startTime, double finishTime,
00042 double theFactor)
00043 :TimeSeries(TSERIES_TAG_RectangularSeries),
00044 tStart(startTime),tFinish(finishTime),cFactor(theFactor)
00045 {
00046
00047 }
00048
00049 RectangularSeries::RectangularSeries()
00050 :TimeSeries(TSERIES_TAG_RectangularSeries),
00051 tStart(0),tFinish(0),cFactor(0)
00052 {
00053
00054 }
00055
00056
00057 RectangularSeries::~RectangularSeries()
00058 {
00059
00060 }
00061
00062 double
00063 RectangularSeries::getFactor(double pseudoTime)
00064 {
00065 if (pseudoTime >= tStart && pseudoTime <= tFinish)
00066 return cFactor;
00067 else
00068 return 0;
00069 }
00070
00071 int
00072 RectangularSeries::sendSelf(int commitTag, Channel &theChannel)
00073 {
00074 int dbTag = this->getDbTag();
00075 Vector data(3);
00076 data(0) = cFactor;
00077 data(1) = tStart;
00078 data(2) = tFinish;
00079 int result = theChannel.sendVector(dbTag,commitTag, data);
00080 if (result < 0) {
00081 cerr << "RectangularSeries::sendSelf() - channel failed to send data\n";
00082 return result;
00083 }
00084 return 0;
00085 }
00086
00087
00088 int
00089 RectangularSeries::recvSelf(int commitTag, Channel &theChannel,
00090 FEM_ObjectBroker &theBroker)
00091 {
00092 int dbTag = this->getDbTag();
00093 Vector data(3);
00094 int result = theChannel.recvVector(dbTag,commitTag, data);
00095 if (result < 0) {
00096 cerr << "RectangularSeries::sendSelf() - channel failed to receive data\n";
00097 cFactor = 1.0;
00098 tStart= 0.0;
00099 tFinish = 0.0;
00100 return result;
00101 }
00102 cFactor = data(0);
00103 tStart = data(1);
00104 tFinish = data(2);
00105
00106 return 0;
00107 }
00108
00109 void
00110 RectangularSeries::Print(ostream &s, int flag)
00111 {
00112 s << "Linear Series: constant factor: " << cFactor;
00113 s << " tStart: " << tStart << " tFinish: " << tFinish << endl;
00114
00115 }