• R/O
  • SSH

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

File Info

Rev. df51ef4089652d534525d8179079a0407fc2bb54
크기 2,657 bytes
Time 2009-09-01 21:47:02
Author lorenzo
Log Message

This code can be used to study the presence of people at a conference (or
in general in a situation when the bootcount is not needed since each tag
unambiguously identifies a visitor). It relies on contact reports rather than
sighting reports to detect the presence of the tags (contact reports are
broadcast more often and at higher power). It fundamentally prints out all the
nodes (hence also isolated tags) of the graph built in a given timeslice.

Content

#!/usr/bin/env python
# loop over 20-second intervals, compute contact graph for each interval, print out the nodes of the graph

import sys
from sociopatterns.loader import Loader
from sociopatterns.analysis import ContactGraphAnalyzer
#import string #Probably I do not need this module any longer.
#Python has a lot of methods already inbuilt for a string object.


#XXTEA_CRYPTO_KEY = ( 0xf6e103d4, 0x77a739f6, 0x65eecead, 0xa40543a9 )

XXTEA_CRYPTO_KEY = (0xf6e103d4, 0x77a739f6, 0x65eecead, 0xa40543a9 )


loader = Loader(sys.argv[1:], decode=1, xxtea_crypto_key=XXTEA_CRYPTO_KEY,
                load_contacts=1, unique_contacts=1, load_sightings=0)

#analyzer = ContactGraphAnalyzer(loader, 20, tag_id_min=1100, tag_id_max=2047)

#NB: now I am NOT filtering on the tag IDs

analyzer = ContactGraphAnalyzer(loader, 20)


for frame in analyzer:

    #Thanks Corrado!

    #I changed into a comment a lot of lines which are no longer needed.
  
    # my_nodes=frame['graph'].nodes()
    # my_nodes_list=["%d" %x for x in frame['graph'].nodes()]
    # my_nodes_string=" ".join(my_nodes_list) 

    # #The same result is achieved with the suggestion by Ciro

    # #string.join(map(str, my_nodes)) ## to be  used within a print statement
    
    # my_edge_list_ini=["%d %d" %(x, y)  for x,y, in frame['graph'].edges() ]

    # my_edge_string=" ".join(my_edge_list_ini)

    # my_edge_string_vert="\n".join(my_edge_list_ini) #prints out the edge list in the form of a binary tag-tag interaction


    
    
    # time_list_ini=[frame['time']]*len(frame['graph'].edges())
    # time_list_ini=["%d" %x for x in time_list_ini]
    # time_string=" ".join(time_list_ini)
    # time_string_vert="\n".join(time_list_ini) #prints out time as a vertical string


    # # total=["%d %d %d" %(x[0], x[1], z)  for x,z in zip(frame['graph'].edges(),[frame['time']]*len(frame['graph'].edges()) ) ]
    # # total="\n".join(total)

    #Suggestion by Corrado. "\n" is a string and its .join method automatically adds another string to it.
    #the object within [] is a list of strings from which I extract a triplet of integers. 
 
    # total="\n".join(["%d %d %d" %( frame["time"],x, y)  for x,y in frame['graph'].edges()])

    total="\n".join(["%d %d"  %( frame["time"],x)  for x in frame['graph'].nodes()])


    # total=frame['graph'].nodes()


  
    # time_and_edges_vert="\n".join(time_and_edges)
    
    
    #old layout I had chosen for my printout
    #use -1 as a separator

    #print  frame['time'], -1, my_edge_list , -1,frame['graph'].number_of_nodes(),-1, my_nodes_list


    
    if (len(frame['graph'].nodes())>0):

        print total