This example shows off some of the new features in the latest Calico, version 2.3.5: you can programmatically create a spreadsheet, put data in it, collect data from other users, and make the data available on the web. This might be a way of collecting data in a classroom activity (perhaps measurements of some kind), or perhaps a multiplayer game. The program below is what the teacher might show on the screen, as it shows the spreadsheet as it changes as new data comes in from the student.
You can download the latest Calico from http://calicoproject.org/Calico_Download
# Example showing show to programmatically # create a spreadsheet, and get data from # distributed programs. import time, random calico.Open("Experiment1.csv") # create a new file, and open it in the IDE doc = calico.GetDocument("Experiment1.csv") # get the doc # let's put in the Calico Cloud, so students can download # it at any time from: # http://myro.roboteducation.org/data/username/Experiment1.csv doc.inCloud = True # now you could manipulate the spreadsheet programmatically # this example receives data from distributed users: doc = "Average:" doc = 0.0 doc = "Count:" doc = 0 count = 0 total = 0.0 calico.ReceiveData() # clear the queue while True: # First add the data to the spreadsheet: data = calico.ReceiveData() received = False for message in data: from_name, from_data = message doc[count + 2] = from_name doc[count + 2] = from_data count += 1 total += float(from_data) doc = total/count doc = count received = True if received: doc.Save() # Wait a bit: time.sleep(1) # send a sample message to myself representing some computation # in real usage, these would come from classmates: calico.SendData(calico.connection.user, str(random.random()))
|Screenshot from 2013-05-12 11:19:42.png||34.35 KB|