void PreludeIOCurrencySource::addPairingsFromJSON(CryptoCurrencyGraph &graph, std::string data, std::string name_prefix){
    boost::property_tree::ptree pt;
    std::istringstream dins (data);
    boost::property_tree::read_json(dins, pt);
    
    std::string currency_endpoint = pt.get<std::string>("from");
    
    for( boost::property_tree::ptree::value_type &v: pt.get_child("pairings") ){
        double link_rate;
        std::string pair;
        
        if (v.second.get<std::string>("last_trade.rate") != "null") {
            
            link_rate =v.second.get<double>("last_trade.rate");
            pair = v.second.get<std::string>("pair");
            
            graph.addLink(this->getPrefixedName(currency_endpoint, name_prefix),
                          this->getPrefixedName(pair, name_prefix),
                          (1/link_rate));
            
            graph.addLink(this->getPrefixedName(pair, name_prefix),
                          this->getPrefixedName(currency_endpoint, name_prefix),
                          link_rate);
        }
    }
}
示例#2
0
task main()
{
  dins(0, 150, 100, 0, 0, 100);
  dins(1, 150, 100, 25, 25, 350);
	//dins(2, 150, 100, 0, 25, 100);
	//dins(3, 150, 100, 25, 25, 100);

  waitForStart(); // Wait for the beginning of autonomous phase.

  while (1) {
	  servo[servo1] = seq[seqindex].c;
	  servo[servo2] = seq[seqindex].d;
    motor[motorD] = seq[seqindex].mD;
    motor[motorE] = -(seq[seqindex].mE);

	  wait10Msec(seq[seqindex].wait);
    ++seqindex;
    if (seqindex > last) {
    	break;
    }
	}
}