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

Annotation of /yodaUtility/YMcmd.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sat Jun 10 05:32:47 2006 UTC (18 years, 5 months ago) by kusanagi
Branch: MAIN
Changes since 1.1: +69 -3 lines
Add inclination and orbital parameter unpacking.

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

  ViewVC Help
Powered by ViewVC 1.1.23