def vsaplay(): global vsasess, vsasn, vsasr t = [(i + 1) / vsasr for i in range(vsasn)] average = int(request.args.get('average')) if average: avenum = int(request.args.get('avenum')) else: avenum = 1 # Start Measure Loop: iqdata = [] for i in range(avenum): VSA.Arm_Measure(vsasess) gd = VSA.Get_Data(vsasess, 2 * vsasn) iqdata.append(gd[1]['ComplexData']) nloop = i iqdata = mean(array(iqdata), axis=0) I, Q, Amp, Pha = IQAParray(iqdata) A = [sqrt(i**2 + q**2) for (i, q) in zip(I, Q)] log = pauselog() #disable logging (NOT applicable on Apache) return jsonify(nIQpair=vsasn, nloop=nloop, log=str(log), t=t, I=list(I), Q=list(Q), A=list(A), Amp=list(Amp), Pha=list(Pha))
def bdrhistory(): global b, bdrlogs wday = int(request.args.get('wday')) P_Ch = int(request.args.get('P_Ch')) T_Ch = int(request.args.get('T_Ch')) P_Ch2 = int(request.args.get('P_Ch2')) T_Ch2 = int(request.args.get('T_Ch2')) OptionS = request.args.get('OptS') OptionV = request.args.get('OptV') b = bluefors() b.selectday(wday) tp, P, P_stat = b.pressurelog(P_Ch) tt, T = b.temperaturelog(T_Ch) tp2, P2, P_stat2 = b.pressurelog(P_Ch2) tt2, T2 = b.temperaturelog(T_Ch2) if OptionS == 'flow': tos, Opts = b.flowmeterlog() else: tos, Opts = b.statuslog(OptionS) tov, Optv = b.channellog(OptionV) bdrlogs = dict(bdr_P=P,bdr_T=T) # for forecast # print("T: %s"%bdrlogs['bdr_%s'%('T')][-15:]) log = pauselog() #disable logging (NOT applicable on Apache) return jsonify(log=str(log), tp=tp, P=P, P_stat=P_stat, tt=tt, T=T, tp2=tp2, P2=P2, P_stat2=P_stat2, tt2=tt2, T2=T2, tos=tos, Opts=Opts, tov=tov, Optv=Optv)
def allstatus(): dr = bluefors() dr.selectday(-1) # Logging Latest Key-Readings for ALL latestbdr = {} for i in range(6): latestbdr.update({"P%s" % (i + 1): dr.pressurelog(i + 1)[1][-1]}) for i in [1, 2, 5, 6, 7]: latestbdr.update({"T%s" % (i + 1): dr.temperaturelog(i + 1)[1][-1]}) set_status("BDR", latestbdr) status = {} status['PSGV'] = get_status('PSGV')["state"] status['AWG'] = get_status('AWG')["state"] log = pauselog() #disable logging (NOT applicable on Apache) return jsonify(log=str(log), latestbdr=latestbdr, status=status)