Go to Post I'd like to welcome all the rookie teams to FIRST. Hang on tight! It is a wild, crazy and fun ride that will impact your lives for decades to come. - Sayrah [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #20   Spotlight this post!  
Unread 09-11-2009, 02:44
Andrew Schreiber Andrew Schreiber is offline
Joining the 900 Meme Team
FRC #0079
 
Join Date: Jan 2005
Rookie Year: 2000
Location: Misplaced Michigander
Posts: 4,077
Andrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond reputeAndrew Schreiber has a reputation beyond repute
Re: FRC Event Data in XML Format

There have been some minor updates:

The request can come in any order now, as long as you specify an What and an Event and the When where applicable it will do its best to figure out what you meant.

Human format has been tweaked to be tabular.

XML option should be a little more standard. I am now using an XML generator instead of just string concatenation.

Got rid of all evals in the python code. I also cleaned up the code to use one function in the place of 4.

Also, as a small project I decided to put together some a Javascript object for getting data. I forgot how ugly Javascript's object stuff is. I have included it below.

Code:
function Event(eventCode,year){
  this.eventCode = eventCode;
  this.year = year;
}

Event.prototype.getRankings = function(){
  myEvent = this
  url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/rankings/json"
  new AJAX_Request(url,function(){myEvent.Rankings = eval("("+xmlhttp.responseText+")")},myEvent)
  return myEvent
  }
  
Event.prototype.getAwards = function(){
  myEvent = this
  url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/awards/json"
  new AJAX_Request(url,function(){myEvent.Awards = eval("("+xmlhttp.responseText+")")},myEvent)
  return myEvent
}

Event.prototype.getQualificationSchedule = function(){
  myEvent = this
  url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/qualification/schedule/json"
  new AJAX_Request(url,function(){myEvent.Qualification_Schedule = eval("("+xmlhttp.responseText+")")},myEvent)
  return myEvent
}

Event.prototype.getEliminationSchedule = function(){
  myEvent = this
  url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/elimination/schedule/json"
  new AJAX_Request(url,function(){myEvent.Elimination_Schedule = eval("("+xmlhttp.responseText+")")},myEvent)
  return myEvent
}

Event.prototype.getQualificationResults = function(){
  myEvent = this
  url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/qualification/results/json"
  new AJAX_Request(url,function(){myEvent.Qualification_Results = eval("("+xmlhttp.responseText+")")},myEvent)
  return myEvent
}

Event.prototype.getEliminationResults = function(){
  myEvent = this
  url = "http://frcfeed.appspot.com/"+myEvent.year+"/"+myEvent.eventCode+"/elimination/results/json"
  new AJAX_Request(url,function(){myEvent.Elimination_Results = eval("("+xmlhttp.responseText+")")},myEvent)
  return myEvent
}


// Utility Functions
function AJAX_Request(url,handlerFunction,newEvent){
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else{
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  url = url
  xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
    handlerFunction(newEvent)
    }
  }
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}
Usage is incredibly simple, create an Event and then get whatever data you want. The data will be placed inside the Event object. Below is an example of getting the first team on the winning alliance.
Code:
kettering = new Event("Kettering",2009);
kettering.getAwards();
kettering.Awards["Regional Winner #1"]["Team"]
__________________




.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2009 FRC Kit of Parts (Pro/ENGINEER format) - Supported by PTC PTC_FRC CAD 18 18-11-2009 01:02
FIRST Event Data in XML format Andrew Schreiber Technical Discussion 11 03-05-2009 04:18
XML Interchange format Nibbles Scouting 25 03-10-2008 02:09
How to write image data to binary PGM file format(P5)? tommy_chai Programming 0 08-10-2007 08:22
Scouting Data Interchange Format proegssilb Scouting 7 06-06-2007 19:29


All times are GMT -5. The time now is 22:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi