Little code improvements done.

This commit is contained in:
klaute 2016-09-21 10:00:23 +02:00
parent 8a56cbb111
commit 5038269c24

View file

@ -369,12 +369,12 @@ if __name__ == "__main__":
# 3. get and process the commandline arguments/parameter # 3. get and process the commandline arguments/parameter
#if args.get_config == True and args.start_meas == False: #if args.get_config == True and args.start_meas == False:
# print "Send: GET_CONFIG" # print "sent: GET_CONFIG"
# sendSerialData([CC_CMD_GET_CONFIG]) # sendSerialData([CC_CMD_GET_CONFIG])
# dataSend = dataSend + 1 # dataSend = dataSend + 1
if args.start_freq != None: if args.start_freq != None:
print "Send: SET_START_FREQ" print "sent: SET_START_FREQ"
sendSerialData([CC_CMD_SET_START_FREQ, sendSerialData([CC_CMD_SET_START_FREQ,
(args.start_freq & 0xff000000) >> 24, (args.start_freq & 0xff000000) >> 24,
(args.start_freq & 0x00ff0000) >> 16, (args.start_freq & 0x00ff0000) >> 16,
@ -383,7 +383,7 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.end_freq != None: if args.end_freq != None:
print "Send: SET_END_FREQ" print "sent: SET_END_FREQ"
sendSerialData([CC_CMD_SET_END_FREQ, sendSerialData([CC_CMD_SET_END_FREQ,
(args.end_freq & 0xff000000) >> 24, (args.end_freq & 0xff000000) >> 24,
(args.end_freq & 0x00ff0000) >> 16, (args.end_freq & 0x00ff0000) >> 16,
@ -392,7 +392,7 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.step_freq != None: if args.step_freq != None:
print "Send: SET_FREQ_STEP" print "sent: SET_FREQ_STEP"
sendSerialData([CC_CMD_SET_FREQ_STEP, sendSerialData([CC_CMD_SET_FREQ_STEP,
(args.step_freq & 0xff000000) >> 24, (args.step_freq & 0xff000000) >> 24,
(args.step_freq & 0x00ff0000) >> 16, (args.step_freq & 0x00ff0000) >> 16,
@ -401,20 +401,20 @@ if __name__ == "__main__":
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.intervall != None: if args.intervall != None:
print "Send: SET_INTERVALL" print "sent: SET_INTERVALL"
sendSerialData([CC_CMD_SET_INTERVALL, sendSerialData([CC_CMD_SET_INTERVALL,
(args.intervall & 0x0000ff00) >> 8, (args.intervall & 0x0000ff00) >> 8,
(args.intervall & 0x000000ff)]) (args.intervall & 0x000000ff)])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.drive_str != None: if args.drive_str != None:
print "Send: SET_DRIVE_STRENGTH" print "sent: SET_DRIVE_STRENGTH"
sendSerialData([CC_CMD_SET_DRIVE_STRENGTH, sendSerialData([CC_CMD_SET_DRIVE_STRENGTH,
args.drive_str]) args.drive_str])
dataSend = dataSend + 1 dataSend = dataSend + 1
if args.start_meas == True: if args.start_meas == True:
print "Send: START_MEASUREMENT" print "sent: START_MEASUREMENT"
sendSerialData([CC_CMD_START_MEASUREMENT]) sendSerialData([CC_CMD_START_MEASUREMENT])
dataSend = dataSend + 1 dataSend = dataSend + 1
@ -483,14 +483,12 @@ if __name__ == "__main__":
elif e[1] == MSG_TYPE_MEAS_END_INFO: elif e[1] == MSG_TYPE_MEAS_END_INFO:
print "recv: END INFO" print "recv: END INFO"
if args.output_file != None: meas_freq = []
pass # TODO impl meas_ratio = []
if args.show_graph == True: meas_r = []
meas_freq = [] meas_p = []
meas_ratio = []
meas_r = []
meas_p = []
if args.output_file != None or args.output_file != None:
for m in meas_data: for m in meas_data:
meas_freq.append(m[0]) meas_freq.append(m[0])
@ -498,7 +496,7 @@ if __name__ == "__main__":
if m[1] > m[2]: if m[1] > m[2]:
meas_ratio.append(m[1] / m[2]) meas_ratio.append(m[1] / m[2])
elif m[1] < m[2]: elif m[1] < m[2]:
meas_ratio.append(m[1] / m[2]) meas_ratio.append(m[2] / m[1])
else: else:
meas_ratio.append(1) meas_ratio.append(1)
@ -512,9 +510,15 @@ if __name__ == "__main__":
else: else:
meas_p.append(0) meas_p.append(0)
if args.output_file != None:
pass # TODO impl
if args.show_graph == True:
plt.plot(meas_freq, meas_ratio) plt.plot(meas_freq, meas_ratio)
plt.plot(meas_freq, meas_r) plt.plot(meas_freq, meas_r)
plt.plot(meas_freq, meas_p) plt.plot(meas_freq, meas_p)
print "Please close the mathplot window to exit..."
plt.show() plt.show()
else: else: