Changeset 2517 for trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
- Timestamp:
- 11/17/03 13:40:14 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/tcpip/MCeCoCom.cc
r2514 r2517 11 11 } 12 12 13 bool MCeCoCom::InterpreteReport(TString &str) 14 { 15 int y, m, d, h, min, s, ms, len; 16 17 int n=sscanf(str.Data(), 18 "%02d %04d %02d %02d %02d %02d %02d %03d %n", 19 &fCCStatus, &y, &m, &d, &h, &min, &s, &ms, &len); 20 if (n!=8) 21 { 22 cout << "Communication Problem: Wrong number of arguments" << endl; 23 fComStat = kComProblem; 24 return false; 25 } 26 str.Remove(0, len); 27 28 fT.SetTimer(y, m, d, h, min, s, ms/1000.); 29 30 // Remove the 30 tokens of the subsystem status 31 // table 12.1 p59 32 for (int i=0; i<30; i++) 33 str.Remove(0, str.First(' ')+1); 34 35 // skip solar_irr_Wm2, wind_speed, UPS 36 float zd, az, dec, ra, temp, solar, wind, hum; 37 n=sscanf(str.Data(), 38 "%f %f %f %f %f %f %f %f %*f %*f %n", 39 &zd, &az, &dec, &ra, &temp, &solar, &wind, &hum, &len); 40 if (n!=8) 41 { 42 cout << "Communication Problem: Wrong number of arguments" << endl; 43 fComStat = kComProblem; 44 return false; 45 } 46 str.Remove(0, len); 47 48 if (str!=(TString)"OVER") 49 { 50 cout << "Communication Problem: Termination (OVER) too far away." << endl; 51 fComStat = kComProblem; 52 return false; 53 } 54 55 cout << "Zd/Az: " << zd << "/" << az << " "; 56 cout << "Ra/Dec: " << ra << "/" << dec << " "; 57 cout << "Temp: " << temp << "'C "; 58 cout << "Hum: " << hum << "% "; 59 cout << "SolRad: " << solar << "W/m² "; 60 cout << "Wind: " << wind << "km/h" << endl; 61 62 fHumidity = hum; 63 fTemperature = temp; 64 fSolarRadiation = solar; 65 fWindSpeed = wind; 66 67 fComStat = kCmdReceived; 68 return true; 69 } 70 13 71 bool MCeCoCom::InterpreteStr(TString str) 14 72 { 15 73 const Ssiz_t tok = str.First(' '); 16 const TString cmd = str(0, tok); 17 str.Remove(0, tok+1); 74 const TString cmd = tok<0 ? str : str(0, tok); 75 if (tok<0) 76 str = ""; 77 else 78 str.Remove(0, tok+1); 18 79 19 80 if (cmd==(TString)"CC-REPORT" && str.EndsWith("OVER")) 20 { 21 cout << cmd << ": " << str << endl; 22 int y, m, d, h, min, s, ms, len; 81 return InterpreteReport(str); 23 82 24 int n=sscanf(str.Data(), 25 "%02d %04d %02d %02d %02d %02d %02d %03d %n", 26 &fCCStatus, &y, &m, &d, &h, &min, &s, &ms, &len); 27 if (n!=8) 28 { 29 cout << "Communication Problem: Wrong number of arguments" << endl; 30 fComStat = kComProblem; 31 return false; 32 } 33 str.Remove(0, len+1); 34 35 fT.SetTimer(y, m, d, h, min, s, ms/1000.); 36 37 // Remove the 29 tokens of the subsystem status 38 // table 12.1 p59 39 for (int i=0; i<29; i++) 40 str.Remove(0, str.First(' ')+1); 41 42 // skip solar_irr_Wm2, wind_speed, UPS 43 float zd, az, dec, ra, temp, hum; 44 n=sscanf(str.Data(), 45 "%f %f %f %f %f %*f %*f %f %*f %n", 46 &zd, &az, &dec, &ra, &temp, &hum, &len); 47 if (n!=6) 48 { 49 cout << "Communication Problem: Wrong number of arguments" << endl; 50 fComStat = kComProblem; 51 return false; 52 } 53 str.Remove(0, len); 54 55 if (str!=(TString)"OVER") 56 { 57 cout << "Communication Problem: Termination (OVER) not found." << endl; 58 fComStat = kComProblem; 59 return false; 60 } 61 62 cout << "Zd/Az: " << zd << "/" << az << " "; 63 cout << "Ra/Dec: " << ra << "/" << dec << " "; 64 cout << "Temp: " << temp << "'C "; 65 cout << "Hum: " << hum << "%" << endl; 66 67 fHumidity = hum; 68 fTemperature = temp; 69 70 fComStat = kCmdReceived; 71 return true; 72 } 73 74 const bool rc = InterpreteCmd(cmd, str); 83 const bool rc = InterpreteCmd(cmd, str.Strip(TString::kBoth)); 75 84 fComStat = rc ? kCmdReceived : kComProblem; 76 85 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.