; Exported "Conditional Actions" for Spectrum Lab if( never ) then # ====== User definable options ====== if( never ) then # SNR_Threshold - Minimum SNR in dB to trigger an event, increase if noise is being interpreted as meteors, reduce if meteors are not being logged if( never ) then # Meteor_Gap - the period that the signal has to drop below the threshold to be considered the end of a meteor event (in seconds) if( never ) then # Log_Threshold - the minimum duration of a meteor event that will be logged (in seconds) if( never ) then # Waterfall_Length - the width or height of the waterfall display in seconds, subtract 20% to be sure of screenshot containing start and end of events if( never ) then # Log_Path - the location to log files for meteor events (remember to double escape backslashes, including trailing backslash) if( never ) then # Capture_Path - the location to save screen captures of meteor events (format as above) if( never ) then # Sound_Path - the location to save .WAV sound capture of meteor events (format as above) if( never ) then # Sound_Capture - set to 1 to capture meteor sounds, 0 to disable sound capture if( initialising ) then SNR_Threshold = 20 : Meteor_Gap = 2 : Log_Threshold = 0.05 : Waterfall_Length = 20 : Log_Path = "C:\\GRAVES\\logs\\" : Capture_Path = "C:\\GRAVES\\Screenshots\\" : Sound_Path = "C:\\GRAVES\\Sound_recordings\\" : Sound_Capture = 0 if( never ) then # ====== End Of User definable options ====== if( never ) then ##### Initialise Variables ######################################################################################################### if( initialising ) then Current_Noise = noise(cfg.SpecFreqMin, cfg.SpecFreqMax) * 6 : Current_Signal = peak_a(cfg.SpecFreqMin, cfg.SpecFreqMax): Current_Signal = 0 : Current_SNR = 0 : Current_Peak_Frequency = 0 : Current_Time = 0 if( initialising ) then Meteor_Start_Time = 0 : Meteor_End_Time = 0 : Daily_Meteor_Count = 0 : Midnight_Flag = 0 : Hourly_Meteor_Count = 0 : Hourly_Meteor_Duration = 0 : Hourly_Meteor_Longest = 0 : Hourly_Flag = 0 : Logging = 1 : Capture_Time = 0 if( initialising ) then Meteor_Max_Signal = 0 : Meteor_Max_Noise = 0 : Meteor_Max_SNR = 0: Meteor_Max_Peak = 0 : Meteor_Count = 0 if( initialising ) then Intermediate_Capture = Waterfall_Length : State = "Waiting" : Queued = 0 if( never ) then ##### Initialise buffer Variables to keep values buffered until screencapture ###################################################### if( initialising ) then Meteor_Max_Signal_Buf = 0 : Meteor_Max_SNR_Buf = 0 : Meteor_Max_Peak_Buf = 0 : Meteor_Start_Time_Buf = 0 if( never ) then ##### Measure current signal, exponential weighted average of noise and peak frequency after each FFT calculation ################# if( new_spectrum ) then Current_Noise = (Current_Noise / 6) * 5 + noise(cfg.SpecFreqMin, cfg.SpecFreqMax) : Current_Signal = peak_a(cfg.SpecFreqMin, cfg.SpecFreqMax) : Current_Peak_Frequency = peak_f(cfg.SpecFreqMin, cfg.SpecFreqMax) : Current_SNR = Current_Signal - (Current_Noise / 6) : Current_Time = time if( never ) then ##### Signal above threshold, no meteor in progress so start of new meteor event ################################################### if( State="Waiting" & Current_SNR>=SNR_Threshold ) then State = "Meteor" : Meteor_Start_Time = Current_Time : rec.filename = Sound_Path + "event_" + str("YYYYMMDD", now) + "_" + str("hhmmss", now) + "_" + str(Daily_Meteor_Count + 1) + ".wav" : Meteor_Start_Time_Buf = str("hh:mm:ss.s", now) if( never ) then ##### SNR is higher than previous max SNR, record new max (subtraction gives SNR in dB) ############################################ if( State="Meteor" & Current_SNR>=Meteor_Max_SNR ) then Meteor_Max_Signal = Current_Signal : Meteor_Max_Noise = (Current_Noise / 6) : Meteor_Max_Peak = Current_Peak_Frequency : Meteor_Max_SNR = Current_SNR : rec.trigger = Sound_Capture : Meteor_Max_Peak_Buf = Meteor_Max_Peak if( never ) then ##### Meteor in progress, signal below threshold so start timing gap in case of short break in meteor signal ####################### if( State="Meteor" & Current_SNR=SNR_Threshold ) then State = "Meteor" if( never ) then ##### Meteor hasn't finished, but start or middle of event needs to be captured before it scrolls off ############################## if( (State="Gap" | State="Meteor") & (Current_Time - Meteor_Start_Time)>=Intermediate_Capture & Logging ) then Intermediate_Capture = Intermediate_Capture + Waterfall_Length : capture(Capture_Path + "event_" + str("YYYYMMDD", now) + "_" + str("hhmmss", now) + "_" + str(Daily_Meteor_Count + 1) + ".png", 100) if( never ) then ##### Timing gap, signal below threshold and gap duration exceeded so log meteor event ############################################# if( State="Gap" & Current_SNR=Meteor_Gap ) then State = "Log" : rec.trigger = 0 if( never ) then ##### Log last meteor event ######################################################################################################## if( State="Log" & (Meteor_End_Time - Meteor_Start_Time)>=Log_Threshold & Logging ) then Daily_Meteor_Count = Daily_Meteor_Count + 1 : Hourly_Meteor_Count = Hourly_Meteor_Count + 1 : Hourly_Meteor_Duration = Hourly_Meteor_Duration + (Meteor_End_Time - Meteor_Start_Time) if( continuation ) then Meteor_Max_Signal_Buf = Meteor_Max_Signal : Meteor_Max_SNR_Buf = Meteor_Max_SNR if( continuation ) then sp.print(" --==Südwest==-- Event:", str(Daily_Meteor_Count), " Dur:", str(Meteor_End_Time - Meteor_Start_Time) + " s", " Sig:", str(Meteor_Max_Signal) + " dBm", " SNR:", str(Meteor_Max_SNR) + " dBm", " Peak-Frq: " + str(Meteor_Max_Peak_Buf + sdr.freq - 143050000) + " Hz", " UTC: " + Meteor_Start_Time_Buf) if( continuation ) then Queued = Queued + 1 : queue_event(now + max(1, (Waterfall_Length - (Meteor_End_Time - Meteor_Start_Time))), 0) if( continuation ) then fopen(Log_Path + "event_log_" + str("YYYYMM", Meteor_Start_Time) + ".csv",a,r) if( continuation ) then fp(str("YYYY/MM/DD",Meteor_Start_Time) + "," + str("hh:mm:ss",Meteor_Start_Time) + "," + str(Daily_Meteor_Count) + "," + str(Meteor_Max_Signal) + "," + str(Meteor_Max_Noise) + "," + str(Meteor_Max_SNR) + "," + str(Meteor_Max_Peak) + "," + str(Meteor_End_Time - Meteor_Start_Time)) if( continuation ) then fclose if( never ) then ##### Reset and wait for next meteor event ######################################################################################### if( State="Log" & Hourly_Meteor_Longest<(Meteor_End_Time - Meteor_Start_Time) ) then Hourly_Meteor_Longest = (Meteor_End_Time - Meteor_Start_Time) if( State="Log" ) then Intermediate_Capture = Waterfall_Length : Meteor_Max_Signal = 0 : Meteor_Max_Noise = 0 : Meteor_Max_SNR = 0: Meteor_Max_Peak = 0 if( continuation ) then State = "Waiting" if( never ) then ##### Capture a screenshot of the display at end of event (see also Screen Capture tab) ############################################ if( queued_event ) then capture(Capture_Path + "event_" + str("YYYYMMDD", now) + "_" + str("hhmmss", now) + "_" + str(Daily_Meteor_Count - Queued + 1) + "_SW.png", 100) if( continuation ) then Queued = Queued - 1 if( never ) then ##### Increment the hourly flag (this will happen multiple times during the last five seconds of the hour) ############################# if( str("mmss", Current_Time)="5955" ) then Hourly_Flag = Hourly_Flag + 1 if( never ) then # If the hourly flag has just been triggered, log and then reset the meteor count to zero for the new hour, if the hourly flag has been triggered already, do nothing if( Hourly_Flag=1 ) then fopen2(Log_Path + "hourly_log_" + str("YYYYMM", Current_Time) + ".csv",a,r) if( continuation ) then fp2(str("YYYY/MM/DD", Current_Time) + "," + str("hh", Current_Time) + "," + str(Hourly_Meteor_Count)) if( continuation ) then fclose2 if( continuation ) then fopen4(Log_Path + "RMOB-" + str("YYYYMM", Current_Time) + ".dat",a,r) if( continuation ) then fp4(str("YYYYMMDDhh", Current_Time) + "," + str("hh", Current_Time) + "," + str(Hourly_Meteor_Count)) if( continuation ) then fclose4 if( continuation ) then fopen5(Log_Path + "RMOB_Dur-" + str("YYYYMM", Current_Time) + ".dat",a,r) if( continuation ) then fp5(str("YYYYMMDDhh", Current_Time) + "," + str("hh", Current_Time) + "," + str(Hourly_Meteor_Count) + "," + str(Hourly_Meteor_Duration) + "," + str(Hourly_Meteor_Longest) + "," + str(Current_Noise)) if( continuation ) then fclose5 if( continuation ) then Hourly_Meteor_Count = 0 : Hourly_Meteor_Duration = 0 : Hourly_Meteor_Longest = 0 if( never ) then # If the current time is on the hour, reset the hourly flag ready to trigger again at the end of the next hour if( str("mmss", Current_Time)="0000" ) then Hourly_Flag = 0 if( never ) then ##### Increment the midnight flag (this will happen multiple times during the last fice seconds of the day) ############################# if( str("hhmmss", Current_Time)="235955" ) then Midnight_Flag = Midnight_Flag + 1 if( never ) then # If the midnight flag has just been triggered, log and then reset the meteor count to zero for the new day, if the midnight flag has been triggered already, do nothing if( Midnight_Flag=1 ) then fopen3(Log_Path + "daily_log_" + str("YYYYMM", Current_Time) + ".csv",a,r) if( continuation ) then fp3(str("YYYY/MM/DD", Current_Time) + "," + str(Daily_Meteor_Count)) if( continuation ) then fclose3 if( continuation ) then Daily_Meteor_Count = 0 if( never ) then # If the current time is midnight, reset the midnight flag ready to trigger again at the end of the next day if( str("hhmmss", Current_Time)="000000" ) then Midnight_Flag = 0 if( never ) then ##### ############################################################################################################################## if( never ) then # TODO: upload to web site? auto image display online, auto generate colourgramme via web.