Skip to content

Commit 3628f78

Browse files
committed
update
1 parent 6c605fa commit 3628f78

File tree

80 files changed

+8378
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+8378
-17
lines changed

DataRecorder.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
import matplotlib.pyplot as plt
77
from collections import deque
88
import matplotlib.animation as animation
9+
import thread
910
import numpy as np
1011
from numpy import *
1112
import scipy
1213
from scipy import *
1314
from Tkinter import *
1415
import time,datetime
1516
from nn import init,classfiy1,classfiy2
17+
import requests
18+
import json
19+
1620

1721
class DataRecorder:
1822
def __init__(self,tty,serialSpeed,outputPath,upthreshold=5,downthreshold=5,isThresholdRelativeToMean=True,preLength=10,postLength=120,mode='threshold'):
@@ -27,8 +31,8 @@ def __init__(self,tty,serialSpeed,outputPath,upthreshold=5,downthreshold=5,isThr
2731
self.plotY=deque([0.0]*self.maxPlotLen)
2832
self.plotX=np.arange(0,self.maxPlotLen)
2933
self.figure=plt.figure()
30-
self.minY=290
31-
self.maxY=320
34+
self.minY=200
35+
self.maxY=300
3236
self.plt= plt.axes(xlim=(0, self.maxPlotLen), ylim=(self.minY,self.maxY))
3337
self.plt.grid(True)
3438
self.line,=self.plt.plot([],[],lw=2)
@@ -66,8 +70,8 @@ def __startReading(self):
6670
if self.isThresholdRelativeToMean==True and self.mean ==-1:
6771
tempArray=[]
6872
print('plz hold static while calculating the mean')
69-
for i in range(500):
70-
print_progress(iteration=i,total=499)
73+
for i in range(1000):
74+
print_progress(iteration=i,total=999)
7175
tempArray.append(self.__readIntFromSerial())
7276
self.mean=sum(tempArray)/float(len(tempArray))
7377
print ("the mean is "+str(self.mean))
@@ -95,7 +99,8 @@ def addCallBack(self, fn):
9599
def updatePlot(self, i):
96100
self.line.set_data(self.plotX,self.plotY)
97101
try:
98-
# self.plt.set_ylim([min(self.plotY)-5,max(self.plotY)+5])
102+
self.plt.set_ylim([min(self.plotY)-5,max(self.plotY)+5])
103+
99104
pass
100105
except Exception as e:
101106
raise
@@ -165,14 +170,17 @@ def registerFemgHandler(self, fn):
165170
self.__caputredSignalListner.append(fn)
166171

167172
def examnLiveData(self,raw,ffemg):
168-
173+
pass
169174
print("we are trying to classfiy it !!!!!")
170-
print (classfiy1([ffemg]))
175+
result= (classfiy1([ffemg]))
176+
print result
177+
thread.start_new_thread(post,(result,))
171178
print (classfiy2([ffemg]))
172179

173180

174181

175182

183+
176184
def showSaveMsg(self):
177185
root=Tk()
178186
self.root=Frame(root)
@@ -209,8 +217,9 @@ def cleanup(self):
209217

210218

211219

212-
213-
220+
def post(result):
221+
requests.post('http://10.151.42.251:8000/api/pizza/da',json={"data":result.lower()})
222+
pass
214223
def print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_length=100):
215224
"""
216225
Call in a loop to create terminal progress bar
@@ -241,7 +250,7 @@ def pr(i):
241250
try:
242251
pass
243252

244-
recorder=DataRecorder(tty='/dev/ttyACM0',serialSpeed=115200,outputPath="omar2/",isThresholdRelativeToMean=True,upthreshold=8,downthreshold=8,postLength=120,preLength=30)
253+
recorder=DataRecorder(tty='/dev/ttyACM0',serialSpeed=115200,outputPath="data_repo/raw/Enes_6_6_30_120/",isThresholdRelativeToMean=True,upthreshold=6,downthreshold=6,postLength=120,preLength=30)
245254
recorder.addCallBack(pr)
246255
recorder.registerFemgHandler(recorder.examnLiveData)
247256
recorder.addCallBack(recorder.thresholdCapture)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
1.731369131769952441e+00
2+
8.884612767737528616e-01
3+
1.722432275704063320e+00
4+
1.929791713629961825e+00
5+
1.654751020945237627e+00
6+
1.307107063632379162e+00
7+
6.759480461087411518e-01
8+
1.395586115703902064e-01
9+
1.170272395401514426e-01
10+
4.125790605125168597e-01
11+
3.217696941345268846e-01
12+
2.031722964668618570e-01
13+
1.744331772984626938e-01
14+
5.435071200259782714e-02
15+
3.369933182997288390e-01
16+
1.740898971701641262e-01
17+
1.944668847621565388e-01
18+
4.826040127141190128e-02
19+
1.384759668435364688e-01
20+
1.881057296340952478e-01
21+
7.775275062817858795e-02
22+
1.257871481695468363e-01
23+
1.547106416483040037e-01
24+
1.375967596660671033e-01
25+
7.055336829505519380e-02
26+
1.909471226946615474e-01
27+
1.269293329523528968e-01
28+
9.477322050004530207e-02
29+
1.116355658388784727e-01
30+
2.322187715333159097e-01
31+
1.426295361426058173e-01
32+
1.920933415775329667e-01
33+
2.209217026332567779e-01
34+
1.563294849086294680e-01
35+
1.211016746383093701e-01
36+
1.865561603982712202e-01
37+
6.028209895405864382e-02
38+
4.973527661401306449e-02
39+
1.538392092313306814e-01
40+
1.157874007458951360e-01
41+
8.550930635345482811e-02
42+
1.037247161755665142e-01
43+
1.182408969074341121e-01
44+
2.014678426246790388e-01
45+
1.287199936088839480e-01
46+
4.237191961558629538e-01
47+
6.634306396717674914e-02
48+
2.106136460644582598e-01
49+
9.999865996893117503e-02
50+
1.665332799572908362e-01
51+
1.457529996705216602e-01
52+
7.943212547724193273e-02
53+
1.305721476847936935e-01
54+
1.289304812548509871e-01
55+
1.279948110168409314e-01
56+
9.785707505170472553e-02
57+
2.796339686835287441e-01
58+
1.470440145663898801e-01
59+
2.150613968177151614e-01
60+
1.255521048666445316e-01
61+
7.306043504233582231e-02
62+
4.770233812328191630e-02
63+
1.013436198708622255e-01
64+
1.420139458472405858e-01
65+
1.299388501049311417e-01
66+
1.134631683031590010e-01
67+
4.373904766153254020e-02
68+
2.174126437240714582e-01
69+
1.957133682229843241e-01
70+
1.912613164548699132e-02
71+
1.325407361266572048e-01
72+
2.174647100846526238e-01
73+
3.730966006973009397e-01
74+
3.056526833029648421e-02
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
299
2+
301
3+
301
4+
300
5+
300
6+
301
7+
300
8+
301
9+
299
10+
301
11+
299
12+
302
13+
299
14+
301
15+
300
16+
301
17+
301
18+
301
19+
301
20+
302
21+
300
22+
300
23+
300
24+
300
25+
299
26+
300
27+
298
28+
296
29+
296
30+
295
31+
295
32+
297
33+
297
34+
296
35+
298
36+
299
37+
301
38+
303
39+
303
40+
304
41+
307
42+
308
43+
309
44+
308
45+
311
46+
309
47+
311
48+
309
49+
309
50+
309
51+
309
52+
308
53+
308
54+
306
55+
305
56+
303
57+
303
58+
303
59+
297
60+
298
61+
299
62+
298
63+
299
64+
300
65+
302
66+
300
67+
302
68+
302
69+
301
70+
301
71+
304
72+
302
73+
304
74+
304
75+
301
76+
303
77+
302
78+
304
79+
303
80+
303
81+
303
82+
304
83+
304
84+
304
85+
303
86+
304
87+
304
88+
303
89+
302
90+
303
91+
304
92+
304
93+
302
94+
303
95+
304
96+
303
97+
303
98+
301
99+
302
100+
304
101+
302
102+
303
103+
302
104+
303
105+
302
106+
303
107+
303
108+
302
109+
303
110+
303
111+
301
112+
301
113+
303
114+
302
115+
301
116+
301
117+
302
118+
302
119+
302
120+
302
121+
300
122+
300
123+
302
124+
301
125+
301
126+
302
127+
301
128+
300
129+
302
130+
300
131+
301
132+
301
133+
301
134+
300
135+
300
136+
300
137+
302
138+
298
139+
300
140+
298
141+
298
142+
301
143+
302
144+
300
145+
303
146+
303
147+
302
148+
301
149+
301
150+
300
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
1.950778688677954786e+00
2+
4.106630685204812004e+00
3+
2.840328143557381946e+00
4+
2.997475827515499791e+00
5+
1.937255048564760607e+00
6+
1.484959516429208426e+00
7+
1.270206279890950585e+00
8+
1.365770843665530254e+00
9+
1.303607321825523746e+00
10+
8.234342148398203776e-01
11+
5.051768290667063566e-01
12+
5.090607337316448433e-01
13+
5.005531546905607199e-01
14+
3.129108403325960852e-01
15+
3.132494417928818886e-01
16+
2.473410861140184214e-01
17+
2.139007072335325221e-01
18+
2.225416616292329730e-01
19+
2.396256379874146525e-01
20+
3.696309122461984842e-01
21+
1.688714048412600088e-01
22+
2.859283496704554950e-01
23+
2.436541522683366434e-01
24+
3.117459985532322619e-01
25+
3.014041214788619749e-01
26+
2.459599874862848645e-01
27+
2.291095021513763763e-01
28+
1.897068072847203912e-01
29+
3.261237402863939039e-01
30+
1.141475038457788610e-01
31+
1.543037459751952778e-01
32+
1.354845625232566908e-01
33+
8.129049972021624992e-02
34+
1.952357603933815022e-01
35+
2.277820699811334282e-01
36+
1.578389395739547563e-01
37+
9.148030985019242611e-02
38+
3.350578469510854807e-01
39+
3.762729293108412199e-01
40+
2.070304683523968570e-01
41+
1.104092958498419375e-01
42+
5.816082739658787193e-02
43+
9.247856973411261450e-02
44+
8.688654681749966024e-02
45+
1.555181607644557651e-01
46+
3.465456355389726628e-01
47+
2.038445912982779495e-01
48+
1.495913413445956568e-02
49+
4.456713205185071358e-02
50+
6.666666666666652696e-02
51+
3.247592581213108037e-02
52+
2.246528004778760856e-01
53+
1.936569703874870541e-01
54+
9.593030509470695799e-02
55+
1.654399882010214040e-01
56+
1.066755031550746663e-01
57+
3.466527764436527770e-02
58+
2.557388471446285158e-02
59+
1.934218878900752503e-01
60+
1.241563200575063336e-01
61+
1.636490223565605362e-01
62+
1.556906707708357041e-01
63+
8.788641880639294635e-02
64+
9.086342083949985882e-02
65+
2.300942660412482188e-01
66+
2.717791160826697472e-01
67+
5.898910110364508075e-02
68+
1.600441089547762763e-01
69+
4.433305234926886856e-02
70+
6.848131087516712290e-02
71+
2.751698469068513675e-01
72+
9.492892584593906613e-02
73+
7.976785805383422578e-02
74+
1.245564135064288758e-01

0 commit comments

Comments
 (0)