示例#1
1
def update():
    global a, b0, c0, g0, im, isec0, line0, newMinute, nscroll, nspeed00, pim, root_geom, t0, mousedf0, nfreeze0, tol0, mode0, nmark0, logm0

    utc = time.gmtime(time.time() + 0.1 * Audio.gcom1.ndsec)
    isec = utc[5]

    if isec != isec0:  # Do once per second
        isec0 = isec
        t0 = time.strftime("%H:%M:%S", utc)
        ltime.configure(text=t0)
        root_geom = root.geometry()
        g.rms = Audio.gcom1.rms
        if isec == 0:
            nscroll = 0
        if isec == 59:
            newMinute = 1

    if g.showspecjt == 1:
        showspecjt()
    nspeed = nspeed0.get()  # Waterfall update rate
    if (nspeed < 6 and nspeed00 >= 6) or (nspeed >= 6 and nspeed00 < 6):
        draw_axis()
    nspeed00 = nspeed

    brightness = sc1.get()
    contrast = sc2.get()
    logm = logmap.get()
    g0 = sc3.get()
    if Audio.gcom2.monitoring or Audio.gcom2.ndiskdat:
        Audio.spec(brightness, contrast, logm, g0, nspeed, a)  # Call Fortran routine spec
        newdat = Audio.gcom1.newdat  # True if new data available
    else:
        newdat = 0

    sm.updateProgress(newValue=Audio.gcom1.level)  # S-meter bar
    if newdat or brightness != b0 or contrast != c0 or logm != logm0:
        if brightness == b0 and contrast == c0 and logm == logm0 and nspeed < 6:
            n = Audio.gcom2.nlines
            box = (0, 0, 750, 300 - n)  # Define region
            region = im.crop(box)  # Get all but last line(s)
            im.paste(region, (0, n))  # Move waterfall down
            for i in range(n):
                line0.putdata(a[750 * i : 750 * (i + 1)])  # One row of pixels to line0
                im.paste(line0, (0, i))  # Paste in new top line
            nscroll = nscroll + n
        else:  # A scale factor has changed
            im.putdata(a)  # Compute whole new image
            b0 = brightness  # Save scale values
            c0 = contrast
            logm0 = logm

    if newdat:
        if Audio.gcom2.monitoring:
            if minsep.get() and newMinute:
                draw.line((0, 0, 749, 0), fill=128)  # Draw the minute separator
            if nscroll == 13:
                draw.text((5, 2), t0[0:5], fill=253)  # Insert time label
        else:
            if minsep.get():
                draw.line((0, 0, 749, 0), fill=128)  # Draw the minute separator

        # Don't update waterfall while decoding
        pim = ImageTk.PhotoImage(im)  # Convert Image to PhotoImage
        graph1.delete(ALL)
        # For some reason, top two lines are invisible, so we move down 2
        graph1.create_image(0, 0 + 2, anchor="nw", image=pim)

        if nspeed > 5:
            color = "white"
            if g.cmap == "gray1":
                color = "black"
            t = time.strftime("%H:%M:%S", time.gmtime(Audio.gcom2.ntime + 0.1 * Audio.gcom1.ndsec))
            graph1.create_text(5, 110, anchor=W, text=t, fill=color)
            t = g.filetime(g.ftnstr(Audio.gcom2.fnamea))
            graph1.create_text(5, 260, anchor=W, text=t, fill=color)

        newMinute = 0

    if (Audio.gcom2.mousedf != mousedf0 or Audio.gcom2.dftolerance != tol0) and g.mode[:4] == "JT65":
        df_mark()

        # The following int() calls are to ensure that the values copied to
        # mousedf0 and tol0 are static.
        mousedf0 = int(Audio.gcom2.mousedf)
        tol0 = int(Audio.gcom2.dftolerance)

    if Audio.gcom2.nfreeze != nfreeze0:
        if not Audio.gcom2.nfreeze:
            draw_axis()
        if Audio.gcom2.nfreeze:
            df_mark()
        nfreeze0 = int(Audio.gcom2.nfreeze)

    if g.mode != mode0:
        if g.mode[:4] == "JT65" and nspeed0.get() > 5:
            nspeed0.set(3)
        if g.mode == "FSK441" and nspeed0.get() < 6:
            nspeed0.set(6)
        if g.mode == "JT6M" and nspeed0.get() < 6:
            nspeed0.set(6)
        draw_axis()
        mode0 = g.mode

    if nmark.get() != nmark0:
        df_mark()
        nmark0 = nmark.get()

    if newdat:
        Audio.gcom2.ndiskdat = 0
    Audio.gcom2.nlines = 0
    Audio.gcom2.nflat = nflat.get()
    if g.focus == 2:
        root.focus_set()
    ltime.after(200, update)  # Reset the timer
示例#2
1
def update():
    global a,a2,b0,c0,g0,im,im2,isec0,line0,line02,newMinute,\
           nscroll,pim,pim2,nfa0,nfb0,bw,gfspan0, \
           root_geom,t0,mousedf0,mousefqso0,nfreeze0,tol0,mode0,nmark0, \
           fmid,fmid0,frange,frange0,dftolerance0,ff0
    
    utc=time.gmtime(time.time()+0.1*Audio.gcom1.ndsec)
    isec=utc[5]

    if isec != isec0:                           #Do once per second
        isec0=isec
        t0=time.strftime('%H:%M:%S',utc)
        ltime.configure(text=t0)
        root_geom=root.geometry()
        g.rms=Audio.gcom1.rms
        if isec==0: nscroll=0
        if isec==59: newMinute=1

    if g.showspecjt==1:
        showspecjt()
    nspeed=nspeed0.get()                        #Waterfall update rate
    brightness=sc1.get()
    contrast=sc2.get()
    g0=sc3.get()

    newspec=Audio.gcom2.newspec                   #True if new data available
    if newspec or brightness != b0 or contrast != c0 or g.cmap != g.cmap0:
        Audio.spec(brightness,contrast,g0,nspeed,a,a2) #Call Fortran routine spec
        n=Audio.gcom2.nlines
        box=(0,0,NX,130-n)                  #Define region
        region=im.crop(box)                 #Get all but last line(s)
        region2=im2.crop(box)               #Get all but last line(s)
        box=(125,0,624,120)
        try:
            if newspec==1:
                im.paste(region,(0,n))      #Move waterfall down
                im2.paste(region2,(0,n))        #Move waterfall down
        except:
            print "Images did not match, continuing anyway."
        for i in range(n):
            line0.putdata(a[NX*i:NX*(i+1)]) #One row of pixels to line0
            im.paste(line0,(0,i))           #Paste in new top line(s)
            line02.putdata(a2[NX*i:NX*(i+1)])#One row of pixels to line0
            im2.paste(line02,(0,i))         #Paste in new top line(s)
        nscroll=nscroll+n

    if newspec:
        if Audio.gcom2.monitoring:
            if newMinute:
                draw.line((0,0,749,0),fill=128)     #Draw the minute separator
                draw2.line((0,0,749,0),fill=128)    #Draw the minute separator
#            if nscroll == 13:
#                draw.text((5,2),t0[0:5],fill=253)   #Insert time label
#                draw2.text((5,2),t0[0:5],fill=253)  #Insert time label
        else:
            draw.line((0,0,749,0),fill=128)     #Draw the minute separator
            draw2.line((0,0,749,0),fill=128)    #Draw the minute separator

        t=g.ftnstr(Audio.gcom2.utcdata)

# This test shouldn.t be needed, but ...
        try:
            draw.text((4,1),t[0:5],fill=253)   #Insert time label
            draw2.text((4,1),t[0:5],fill=253)  #Insert time label
        except:
            pass

    if newspec or brightness != b0 or contrast != c0 or g.cmap != g.cmap0:
        pim=ImageTk.PhotoImage(im)              #Convert Image to PhotoImage
        graph1.delete(ALL)
        pim2=ImageTk.PhotoImage(im2)            #Convert Image to PhotoImage
        graph2.delete(ALL)
        #For some reason, top two lines are invisible, so we move down 2
        graph1.create_image(0,0+2,anchor='nw',image=pim)
        graph2.create_image(0,0+2,anchor='nw',image=pim2)        
        g.ndecphase=2
        newMinute=0
        Audio.gcom2.newspec=0
        b0=brightness                           #Save scale values
        c0=contrast
        g.cmap0=g.cmap

    if Audio.gcom2.nfreeze != nfreeze0:
        if not Audio.gcom2.nfreeze: draw_axis()
        if Audio.gcom2.nfreeze: df_mark()
        nfreeze0=int(Audio.gcom2.nfreeze)

    if (Audio.gcom2.fcenter + Audio.gcom2.fadd != ff0) or \
            g.fspan != gfspan0:
        draw_axis()
        df_mark()
        ff0=float(Audio.gcom2.fcenter+Audio.gcom2.fadd)
        gfspan0=g.fspan
        msub=int(1000*(ff0-int(ff0))+0.5)
        try:
            Audio.gcom2.nfa=msub - 0.5*g.fspan
        except:
            Audio.gcom2.nfa=msub-30
        try:
            Audio.gcom2.nfb=msub + 0.5*g.fspan
        except:
            Audio.gcom2.nfa=msub+30

    nbpp=int((Audio.gcom2.nfb - Audio.gcom2.nfa)*32768/(95.2381*NX))
    if nbpp<1: nbpp=1
    bw=750.0*(95.2381/32768.0)*nbpp

    if (Audio.gcom2.mousedf != mousedf0 or
            Audio.gcom2.mousefqso != mousefqso0 or
            Audio.gcom2.dftolerance != dftolerance0 or
            Audio.gcom2.nfa != nfa0 or Audio.gcom2.nfb != nfb0): 
        df_mark()
# The following int() calls are to ensure that the values copied to
# mousedf0 and mousefqso0 are static.
        mousedf0=int(Audio.gcom2.mousedf)
        mousefqso0=int(Audio.gcom2.mousefqso)
        dftolerance0=int(Audio.gcom2.dftolerance)
        nfa0=int(Audio.gcom2.nfa)
        nfb0=int(Audio.gcom2.nfb)

    if g.mode!=mode0:
        df_mark()                        ### was draw_axis()
        mode0=g.mode

    if nmark.get()!=nmark0:
        df_mark()
        nmark0=nmark.get()

#    if newspec: Audio.gcom2.ndiskdat=0
    Audio.gcom2.nlines=0
    Audio.gcom2.nflat=nflat.get()

    frange=nfr.get()*2000
    if(fmid<>fmid0 or frange<>frange0):
        if fmid<1000*nfr.get(): fmid=1000*nfr.get()
        if fmid>5000-1000*nfr.get(): fmid=5000-1000*nfr.get()
        df_mark()
        fmid0=fmid
        frange0=frange
    Audio.gcom2.nfmid=int(fmid)
    Audio.gcom2.nfrange=int(frange)

    ltime.after(200,update)                      #Reset the timer