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

Diff of /smsdaemon/plugins/TogPlugin.cpp

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

revision 322 by torben, Thu Dec 18 06:53:29 2008 UTC revision 323 by torben, Wed Sep 16 09:08:40 2009 UTC
# Line 13  Line 13 
13  using namespace std;  using namespace std;
14    
15    
16  StationInfo::StationInfo(std::string c, std::string n)  StationInfo::StationInfo(int i, std::string n)
17  {  {
18          code = Util::str_characters(c);          id = i;
19          name = Util::str_characters(n);          name = Util::str_characters(n);
20  }  }
21    
# Line 23  StationInfo::StationInfo(std::string c, Line 23  StationInfo::StationInfo(std::string c,
23  TogPlugin::TogPlugin()  TogPlugin::TogPlugin()
24                  : Plugin("tog", "Henter tog info fra bane.dk")                  : Plugin("tog", "Henter tog info fra bane.dk")
25  {  {
26          _stationInfo["ar"] = StationInfo("AR","Århus");          _stationInfo["ar"] = StationInfo(278, "Århus");
27          _stationInfo["la"] = StationInfo("LG","Langå");          _stationInfo["la"] = StationInfo(122, "Langå");
28          _stationInfo["ul"] = StationInfo("UP","Ulstrup");          _stationInfo["ul"] = StationInfo(240, "Ulstrup");
29          _stationInfo["bj"] = StationInfo("BJ","Bjerringbro");          _stationInfo["bj"] = StationInfo(10,  "Bjerringbro");
30          _stationInfo["vi"] = StationInfo("VG","Viborg");          _stationInfo["vi"] = StationInfo(253, "Viborg");
31          _stationInfo["ho"] = StationInfo("HØ","Højslev");          _stationInfo["ho"] = StationInfo(94,  "Højslev");
32          _stationInfo["sk"] = StationInfo("SK","Skive");          _stationInfo["sk"] = StationInfo(190, "Skive");
33  }  }
34    
35  string TogPlugin::GetRealStationCode(string code,  string &stationName)  int TogPlugin::GetStationId(string code,  string &stationName)
36  {  {
37          map<string, StationInfo>::iterator it = _stationInfo.find(code);          map<string, StationInfo>::iterator it = _stationInfo.find(code);
38    
39          if (it != _stationInfo.end())          if (it != _stationInfo.end())
40          {          {
41                  stationName = (*it).second.name;                  stationName = (*it).second.name;
42                  return (*it).second.code;                  return (*it).second.id;
43          }          }
44    
45          return "";          return -1;
46  }  }
47    
48  string TogPlugin::CreateStationList()  string TogPlugin::CreateStationList()
# Line 81  void TogPlugin::Execute(ISmsTransceiver& Line 81  void TogPlugin::Execute(ISmsTransceiver&
81          }          }
82    
83          string stationName;          string stationName;
84          string code = GetRealStationCode(data, stationName);          int id = GetStationId(data, stationName);
85    
86          if (code == "")          if (id < 0)
87          {          {
88                  modem.SendSms(sms.GetSender(), "Unknown station", false);                  modem.SendSms(sms.GetSender(), "Unknown station", false);
89                  return;                  return;
# Line 92  void TogPlugin::Execute(ISmsTransceiver& Line 92  void TogPlugin::Execute(ISmsTransceiver&
92          vector<TrainInfo> infos;          vector<TrainInfo> infos;
93          try          try
94          {          {
95                  infos = GetTrainInfo( code , "" );                  infos = GetTrainInfo( id  );
96          }          }
97          catch (std::exception& e)          catch (std::exception& e)
98          {          {

Legend:
Removed from v.322  
changed lines
  Added in v.323

  ViewVC Help
Powered by ViewVC 1.1.20