00001 #pragma ident "$Id: MDPSelftestStatus.cpp 1420 2008-10-27 20:14:08Z ocibu $"
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
00038
00039 #include <sstream>
00040
00041 #include "StringUtils.hpp"
00042 #include "BinUtils.hpp"
00043
00044 #include "MDPSelftestStatus.hpp"
00045 #include "MDPStream.hpp"
00046
00047 using gpstk::StringUtils::asString;
00048 using gpstk::BinUtils::encodeVar;
00049 using gpstk::BinUtils::decodeVar;
00050 using namespace std;
00051
00052 namespace gpstk
00053 {
00054
00055 MDPSelftestStatus::MDPSelftestStatus()
00056 throw() :
00057 selfTestTime(gpstk::DayTime::BEGINNING_OF_TIME),
00058 firstPVTTime(gpstk::DayTime::BEGINNING_OF_TIME),
00059 antennaTemp(0), receiverTemp(0), status(0xffffffff),
00060 cpuLoad(0), extFreqStatus(0)
00061 {
00062 id = myId;
00063 }
00064
00065
00066
00067 string MDPSelftestStatus::encode() const
00068 throw()
00069 {
00070 string str;
00071 str += encodeVar( (float) antennaTemp);
00072 str += encodeVar( (float) receiverTemp);
00073 str += encodeVar( (uint32_t) status);
00074 str += encodeVar( (float) cpuLoad);
00075 str += encodeVar( (uint32_t) 100*selfTestTime.GPSsecond());
00076 str += encodeVar( (uint16_t) selfTestTime.GPSfullweek());
00077 str += encodeVar( (uint16_t) firstPVTTime.GPSfullweek());
00078 str += encodeVar( (uint32_t) 100*firstPVTTime.GPSsecond());
00079 str += encodeVar( (uint16_t) extFreqStatus);
00080 str += encodeVar( (uint16_t) saasmStatusWord);
00081 return str;
00082 }
00083
00084
00085
00086 void MDPSelftestStatus::decode(string str)
00087 throw()
00088 {
00089 if (str.length() != myLength)
00090 return;
00091
00092 clearstate(lenbit);
00093
00094
00095 long sow100;
00096 int week;
00097
00098 antennaTemp = decodeVar<float>(str);
00099 receiverTemp = decodeVar<float>(str);
00100 status = decodeVar<uint32_t>(str);
00101 cpuLoad = decodeVar<float>(str);
00102 sow100 = decodeVar<uint32_t>(str);
00103 week = decodeVar<uint16_t>(str);
00104 selfTestTime.setGPSfullweek(week, double(sow100)*0.01);
00105 week = decodeVar<uint16_t>(str);
00106 sow100 = decodeVar<uint32_t>(str);
00107 firstPVTTime.setGPSfullweek(week, double(sow100)*0.01);
00108 extFreqStatus = decodeVar<uint16_t>(str);
00109 saasmStatusWord = decodeVar<uint16_t>(str);
00110
00111 clearstate(fmtbit);
00112 }
00113
00114
00115
00116 void MDPSelftestStatus::dump(ostream& out) const
00117 throw()
00118 {
00119 ostringstream oss;
00120 using gpstk::StringUtils::asString;
00121 using gpstk::StringUtils::leftJustify;
00122
00123 MDPHeader::dump(oss);
00124 oss << getName() << "1:"
00125 << " Tst:" << selfTestTime.printf("%4F/%9.2g")
00126 << " Tpvt:" << firstPVTTime.printf("%4F/%9.2g")
00127 << " Ant. Temp:" << antennaTemp
00128 << " Rx. Temp:" << receiverTemp
00129 << " status:" << hex << status << dec
00130 << " cpuLoad:" << cpuLoad
00131 << " extFreq:" << hex << extFreqStatus << dec
00132 << " ssw:" << hex << saasmStatusWord << dec
00133 << endl;
00134 out << oss.str() << flush;
00135 }
00136
00137 }