Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
TrainStat.cpp
- Committer:
- takashikojo
- Date:
- 2015-07-05
- Revision:
- 4:acfd6fbf9f9e
- Parent:
- 3:5720d24f4a4a
- Child:
- 6:d4d781f31f70
File content as of revision 4:acfd6fbf9f9e:
#include <mbed.h>
#include <string>
#include "TrainStat.h"
#include "tokyoMetro.h"
#include "yahooTrain.h"
#include "matchLine.h"
#define ERR(x, ...) std::printf("[TrainStat : ERR]"x"\r\n", ##__VA_ARGS__);
TrainStat::TrainStat(enum infoSource s) {
source = s ;
} ;
TrainStat::~TrainStat(){ } ;
void TrainStat::setBuff(char *buff, int size)
{
recvBuff = buff ;
recvSize = size ;
}
bool TrainStat::getStat()
{
int ret ;
switch(source) {
case YAHOO_TRAIN:
ret = YahooT_query("area/4/", recvBuff, recvSize) ;
if(ret)ret = YahooT_getStat(recvBuff) ;
break ;
case TOKYO_METRO:
ret = TMetro_query("datapoints", "odpt:TrainInformation", recvBuff, recvSize) ;
if(ret)ret = TMetro_getStat(recvBuff) ;
break ;
default:
return false ;
}
printf(" Train => %s\n", ret?"Delay":"No Delay") ;
return ret ;
}