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-06-28
- Revision:
- 3:5720d24f4a4a
- Parent:
- 2:58e7fabcba89
- Child:
- 4:acfd6fbf9f9e
File content as of revision 3:5720d24f4a4a:
#include <mbed.h>
#include <string>
#include "TrainStat.h"
#include "tokyoMetro.h"
#include "yahooTrain.h"
#define ERR(x, ...) std::printf("[TrainStat : ERR]"x"\r\n", ##__VA_ARGS__);
TrainStat::TrainStat(enum infoSource s) {
        source = s ;
        TMetro_initLine() ;
        YahooT_initLine() ;
} ;
 
TrainStat::~TrainStat(){ } ;
void TrainStat::setBuff(char *buff, int size)
{
    recvBuff = buff ;
    recvSize = size ;
}
bool TrainStat::setLine(string line)
{
    switch(source) {
    case YAHOO_TRAIN: 
        YahooT_setLine(line) ; 
        break ;
    case TOKYO_METRO:
        TMetro_setLine(line) ; 
        break ;
    default:
        return false ;
    }
    return true ;
}
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 ;
    }
    return ret ;
    
}