예제 #1
0
"""Creates a massive CSV table of packet values"""

from receiver import Receiver
from tempfile import TemporaryFile

with TemporaryFile(mode='w+t') as tempfile,\
    open('log.csv', mode='w') as logfile:
    receiver = Receiver()
    headers = []
    for packet in receiver.get_packets_from_file('examples/live_capture.txt'):
        #Skip invalid packets
        if 'Name' not in packet.keys():
            continue
        #Include Cell ID in name
        if 'Cell ID' in packet.keys():
            packet['Name'] = packet['Name'] + ' ' + str(packet['Cell ID'])
            del packet['Cell ID']
        #Append name to all keys
        name = packet['Name'] + ' '
        del packet['Name']
        for key in list(packet):
            packet[name + key] = packet[key]
            #Add nonexistent headers
            if name + key not in headers:
                headers.append(name + key)
            del packet[key]
        #Write to CSV
        result = []
        for header in headers:
            if header in packet.keys():
                result.append(str(packet[header]))
예제 #2
0
axR = ax[1,0]
axRR = ax[1,1]

fig2, a2x = plt.subplots(2,2) #MPPT1 In
a2x1I = a2x[0,0]
a2xM1I = a2x[0,1]
a2x2I = a2x[1,0]
a2xM2I = a2x[1,1]

#x and y axes
xs = [0,1,2,3,4,5,6,7,8,9,10]
xst = [0, 1, 2, 3, 4 ,5, 6, 7, 8, 9, 10]
ys = queue.Queue(maxsize = 12)

otherClass = Receiver()
packets = list(otherClass.get_packets_from_file('examples\live_capture.txt'))

#x and y axes for plotting
#for 10 secs at a time
ry = []  #current
ry2 = [] #rpm
ry3 = [] #M1IN
ry6 = [] #M2In
rx = xs
# the entire thing
rxt = xst
ryt = [] #current
ryt2 = [] #rpm
ryt3 = [] #M1In
ryt6 = [] #M2In