/[PAMELA software]/yodaUtility/YMcmd.cpp
ViewVC logotype

Contents of /yodaUtility/YMcmd.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Tue Jun 13 09:03:08 2006 UTC (18 years, 5 months ago) by kusanagi
Branch: MAIN
CVS Tags: yodaUtility2_0/00, yodaUtility2_2/00, yodaUtility2_1/00, HEAD
Changes since 1.2: +26 -16 lines
BugFix: wrong decoding of the Inclination/Orbital MCMD

1 #include <YMcmd.h>
2 #include <sstream>
3
4 //using namespace std;
5
6
7 const char* ElseItem::toXML(char* tab = "") {
8 std::stringstream oss;
9 oss.str("");
10 oss << tab << "<Else>\n";
11 oss << tab << "</Else>\n";
12 return oss.str().c_str();
13 }
14
15
16
17
18 const char* DownLinkItem::toXML(char* tab = ""){
19 stringstream oss;
20 oss.str("");
21 return oss.str().c_str();
22 }
23
24
25 void OrbitalInfoItem::fill(TArrayC* data){
26 //pos = float[3];
27 //vel = float[3]
28 long tempData = 0;
29 time = (((data->At(1) << 24) & 0xFF000000) + ((data->At(0) << 16) & 0x00FF0000) + ((data->At(3) << 8) & 0x0000FF00) + (data->At(2) & 0x000000FF))/128.0;
30
31 short index = 0;
32 for (int i = 0; i < 3; i++){
33 index = 4*i;
34 tempData = ((data->At(index + 4) << 24) & 0xFF000000) + ((data->At(index + 5) << 16) & 0x00FF0000) + ((data->At(index + 6) << 8) & 0x0000FF00) + (data->At(index + 7) & 0x000000FF);
35 if (data->At(index + 4) >> 8) {
36 pos[i] = (~tempData * -1.0)/262144.0;
37 } else {
38 pos[i] = tempData /262144.0;
39 }
40
41 tempData = ((data->At(index + 16) << 24) & 0xFF000000) + ((data->At(index + 17) << 16) & 0x00FF0000) + ((data->At(index + 18) << 8) & 0x0000FF00) + (data->At(index + 19) & 0x000000FF);
42 if (data->At(index + 16) >> 8) {
43 vel[i] = (~tempData * -1.0)/134217728.0;
44 } else {
45 vel[i] = tempData /134217728.0;
46 }
47 }
48 }
49
50 const char* OrbitalInfoItem::toXML(char* tab = ""){
51 stringstream oss;
52 oss.str("");
53 oss << tab << "<param name = 'time'>" << time << "</param>\n";
54 oss << tab << "<param name = 'posX'>" << pos[0] << "</param>\n";
55 oss << tab << "<param name = 'posY'>" << pos[1] << "</param>\n";
56 oss << tab << "<param name = 'posZ'>" << pos[2] << "</param>\n";
57 oss << tab << "<param name = 'velX'>" << vel[0] << "</param>\n";
58 oss << tab << "<param name = 'velY'>" << vel[1] << "</param>\n";
59 oss << tab << "<param name = 'velZ'>" << vel[2] << "</param>\n";
60 return oss.str().c_str();
61 }
62
63
64 void InclinationInfoItem::fill(TArrayC* data){
65 short extIndex = 0;
66 short innIndex = 0;
67 long tempData = 0;
68 for (int i = 0; i < 6; i++){
69 extIndex = 20*i;
70 time[i] = (((data->At(extIndex) << 24) & 0xFF000000) +
71 ((data->At(extIndex + 1) << 16) & 0x00FF0000) + ((data->At(extIndex + 2) << 8) & 0x0000FF00) +
72 (data->At(extIndex + 3) & 0x000000FF))/128.0;
73
74 for (int j = 0; j < 4; j++){
75 innIndex = extIndex + 4*j;
76 tempData = ((data->At(innIndex + 4) << 24) & 0xFF000000) + ((data->At(innIndex + 5) << 16) & 0x00FF0000) + ((data->At(innIndex + 6) << 8) & 0x0000FF00) + (data->At(innIndex + 7) & 0x000000FF);
77 if (data->At(innIndex + 4) >> 8) {
78 quat[i][j] = (~tempData * -1.0)/1073741824.0;
79 } else {
80 quat[i][j] = tempData / 1073741824.0;
81 }
82 }
83 }
84 }
85
86 const char* InclinationInfoItem::toXML(char* tab = ""){
87 stringstream oss;
88 oss.str("");
89 for (int i = 0; i < 6; i++){
90 oss << tab << "<QUATERNION>\n";
91 oss << tab << "\t <param name = 'time'>" << time[i] << "</param>\n";
92 oss << tab << "\t <param name = 'L0'>" << quat[i][0] << "</param>\n";
93 oss << tab << "\t <param name = 'L1'>" << quat[i][1] << "</param>\n";
94 oss << tab << "\t <param name = 'L2'>" << quat[i][2] << "</param>\n";
95 oss << tab << "\t <param name = 'L3'>" << quat[i][3] << "</param>\n";
96 oss << tab << "</QUATERNION>\n";
97 }
98 return oss.str().c_str();
99 }
100
101 void TimeSyncItem::fill(TArrayC* data){
102 newTime = (((unsigned int)data->At(0)<<24)&0xFF000000) + (((unsigned int)data->At(1)<<16)&0x00FF0000) + (((unsigned int)data->At(2)<<8)&0x0000FF00) + (((unsigned int)data->At(3))&0x000000FF);
103 }
104
105 const char* TimeSyncItem::toXML(char* tab = ""){
106 stringstream oss;
107 oss.str("");
108 oss << tab << "<param name = 'newTime'>" << newTime << "</param>\n";
109 return oss.str().c_str();
110 }
111
112
113 void SelectOpModeItem::fill(TArrayC* data){
114 /*for (int i = 0; i<data->GetSize(); i++){
115 printf("array[%i]: %x", i, data->At(i));
116 }*/
117 mode = data->At(1)&0xFF;
118 paramNumber = (((unsigned int)data->At(2)<<8)&0x00000100) + (((unsigned int)data->At(3))&0x000000FF);
119 }
120
121 const char* SelectOpModeItem::toXML(char* tab = ""){
122 stringstream oss;
123 oss.str("");
124 oss << tab << "<param name = 'mode'>" << hex << mode << dec << "</param>\n";
125 oss << tab << "<param name = 'paramNumber'>" << paramNumber << "</param>\n";
126 return oss.str().c_str();
127 }
128
129
130
131
132
133 void BiteItem::fill(TArrayC* data){
134 fillerWord = (((unsigned int)data->At(0)<<8)&0x0000FF00) + (((unsigned int)data->At(1))&0x000000FF);
135 }
136
137 const char* BiteItem::toXML(char* tab = ""){
138 stringstream oss;
139 oss.str("");
140 oss << tab << "<param name = 'fillerWord'>" << fillerWord << "</param>\n";
141 return oss.str().c_str();
142 }
143
144
145 const char* McmdScan::extract(TArrayC *data, int id, char* tabs){
146 switch(id){
147 case 0xE0:
148 mcmdItem = new TimeSyncItem();
149 break;
150 case 0xE1:
151 mcmdItem = new OrbitalInfoItem();
152 break;
153 case 0xE2:
154 mcmdItem = new InclinationInfoItem();
155 break;
156 case 0x33:
157 mcmdItem = new SelectOpModeItem();
158 break;
159 default:
160 mcmdItem = new ElseItem();
161 break;
162 }
163 mcmdItem->fill(data);
164 return mcmdItem->toXML(tabs);
165 }
166

  ViewVC Help
Powered by ViewVC 1.1.23