/[projects]/smsdaemon/plugins/TrainInfo.cpp
ViewVC logotype

Diff of /smsdaemon/plugins/TrainInfo.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 195 by torben, Wed Dec 17 23:43:26 2008 UTC revision 196 by torben, Thu Dec 18 06:53:29 2008 UTC
# Line 18  using namespace std; Line 18  using namespace std;
18  string ConvertUpdateInfo(char ch)  string ConvertUpdateInfo(char ch)
19  {  {
20          string result;          string result;
21          switch( ch)          switch ( ch)
22          {          {
23                  case '1':          case '1':
24                          result = "< 3 min";                  result = "< 3 min";
25                          break;                  break;
26                  case '2':          case '2':
27                          result = "3 - 10 min";                  result = "3 - 10 min";
28                          break;                  break;
29                  case '3':          case '3':
30                          result = "> 10 min";                  result = "> 10 min";
31                          break;                  break;
32                  case '4':          case '4':
33                          result = "No info";                  result = "No info";
34                          break;                  break;
35                  default:          default:
36                          result = "Unknown";                  result = "Unknown";
37          }          }
38          return result;          return result;
39  }  }
# Line 65  vector<TrainInfo> GetTrainInfo(string st Line 65  vector<TrainInfo> GetTrainInfo(string st
65          string url = string("http://www.bane.dk/visStation.asp?W=FJRN&S=") + stationcode + "&artikelId=4275&statnavn=" + stationname;          string url = string("http://www.bane.dk/visStation.asp?W=FJRN&S=") + stationcode + "&artikelId=4275&statnavn=" + stationname;
66    
67          //string raw_doc = Util::readUrl(url, "/tmp/sms_tog.tmp" );          //string raw_doc = Util::readUrl(url, "/tmp/sms_tog.tmp" );
68            
69          string raw_doc;          string raw_doc;
70          try          try
71          {          {
72                  raw_doc = HttpClient::GetString(url);                  raw_doc = HttpClient::GetString(url);
73          }          }
74          catch (httpexception& e)          catch (httpexception& e)
75          {          {
76                  Logger::logMessage(e.what());                  Logger::logMessage(e.what());
# Line 89  vector<TrainInfo> GetTrainInfo(string st Line 89  vector<TrainInfo> GetTrainInfo(string st
89    
90          unsigned int ankomstpos = html.find("id='ankomsttabel'");          unsigned int ankomstpos = html.find("id='ankomsttabel'");
91    
92          while(1)          while (1)
93          {          {
94                  //start with time                  //start with time
95                  pos = html.find("<td class='tid'>", pos);                  pos = html.find("<td class='tid'>", pos);
# Line 132  vector<TrainInfo> GetTrainInfo(string st Line 132  vector<TrainInfo> GetTrainInfo(string st
132                  info.origin = html.substr(start, stop-start).c_str();                  info.origin = html.substr(start, stop-start).c_str();
133    
134                  //Current location                  //Current location
135          pos++; //since origin and current use the same search pattern, we must increase the position                  pos++; //since origin and current use the same search pattern, we must increase the position
136                        //so we don't get origin twice.                  //so we don't get origin twice.
137                    
138                  pos = html.find( "<td class='visikke'>", pos);                  pos = html.find( "<td class='visikke'>", pos);
139                  start = pos + 20;                  start = pos + 20;
140                  stop = html.find( "</td>", pos);                  stop = html.find( "</td>", pos);

Legend:
Removed from v.195  
changed lines
  Added in v.196

  ViewVC Help
Powered by ViewVC 1.1.20