;P75/P175/P275 automated FM monitoring script (C) Pira.cz 2018
;FM Scope version required: 1.5 rev. 20 or later
Again:
reset
;*************************************************************
;*** User configurable parameters: ***
;*************************************************************
set (DataPath,c:\monitor)
set (BandscanSize,800x288) ;bandscan image size in pixels
set (GraphSize,529x260) ;graph image size in pixels
set (DelayMeasuring,900)
set (DelayRDS,60)
set (DevPercentOverAllowed,3)
set (PmPercentOverAllowed,10)
set (PmAbsoluteLimit,1.5)
set (AMLimit,18)
set (SkipAntPolH,08790 09140 09430 09630 09670 09540 10710)
set (SkipAntPolV,08970 09390 09740 10010 10270 10600)
frequencydeviation.histogram (1)
setproperty (OnlineUpdate,0)
setproperty (Encoding,UTF-8)
;*************************************************************
;*** Main program: ***
;*************************************************************
setproperty (ExecutionSpeed,4)
textwindow.clear
textwindow.addline([Batch script file v. 1.4 starting at %date %time])
mpx.doubletimebase(0)
rfmaxhold(1)
rfmask(1)
rfhistogram(1)
com_ini:
set (tcpconfailed,0)
if (%connected=0)
connect
textwindow.addline({%time} -[ Script reconnection attempt (A))
sleep(10)
goto (com_ini)
endif
set (antpol,H)
send (ARK:GH*X)
setmode (0)
set (tempfreq,102.7)
tune (%tempfreq)
call (CheckStation)
if (%Result!=0)
imf.setasnormal
textwindow.addline({%time} Getting carrier frequency normal from %frequency)
endif
if (%tcpconfailed=1)
textwindow.addline({%time} WiFi link failure detected - trying again)
goto (com_ini)
endif
location.load (monitor)
location.unlock
set (antpol,H)
send (ARK:GH*X)
set (BandscanName,bs0.svg)
call (ProcessBand)
set (antpol,V)
send (ARK:GD*X)
set (BandscanName,bs1.svg)
call (ProcessBand)
textwindow.addline([END %date %time])
textwindow.savedata(%DataPath\log.txt)
ftp.connect
ftp.put(log.txt)
ftp.disconnect
;email.to (mail@pira.cz)
;email.body (Monitoring log %date %time)
;email.attachfile (%DataPath\log.txt)
;email.send
modulationpower.stop
sleep(5)
disconnect
stop
;*************************************************************
;*** Band processing: ***
;*************************************************************
ProcessBand:
set (tcpconfailed,0)
if (%connected=0)
connect
textwindow.addline({%time} -[ Script reconnection attempt (B))
sleep(10)
goto (ProcessBand)
endif
textwindow.addline({%time} Getting bandscan)
bandscan.acquire
if (%tcpconfailed=1)
textwindow.addline({%time} WiFi link failure detected - trying again)
goto (ProcessBand)
endif
bandscan.savegraph (%DataPath\%BandscanName,%BandscanSize)
ftp.connect
ftp.put(%BandscanName)
ftp.disconnect
set (stationindex,1)
Loop1: ;loop through stations from bandscan
if (%stationindex>%stationcount)
RETURN
endif
if (%station.noise>80)
goto (Next1)
endif
if (%antpol$=H)
if (%station.freq@%SkipAntPolH)
goto (Next1)
endif
endif
if (%antpol$=V)
if (%station.freq@%SkipAntPolV)
goto (Next1)
endif
endif
call (ProcessStation)
Next1:
inc (stationindex)
goto (Loop1)
;*************************************************************
;*** Station measuring: ***
;*************************************************************
ProcessStation:
set (tcpconfailed,0)
if (%connected=0)
connect
textwindow.addline({%time} -[ Script reconnection attempt (C))
sleep(10)
goto (ProcessStation)
endif
call (ResetWarnings)
setmode (0)
tune (%station.frequency)
send (*1)
send (*0)
set (tempfreq,%station.frequency)
call (CheckStation) ;check the station's reception quality
if (%Result=0)
RETURN ;poor quality, return
endif
;-------------------------------------------------------------
textwindow.addline({%time} Monitoring station %station.frequency)
imf.get
mpx.run
modulationpower.run
set(LowestQuality,5)
set (EndTime,%timestamp)
inc (EndTime,%DelayMeasuring)
call (WaitAndProcessWarnings)
modulationpower.stop
mpx.stop
getquality
send (?U)
modulationpower.savegraph (%DataPath\pm.svg,%GraphSize)
frequencydeviation.acquire
frequencydeviation.savegraph (%DataPath\hi.svg,%GraphSize)
mpx.savegraph (%DataPath\mx.svg,%GraphSize)
rf.savegraph (%DataPath\rf.svg,%GraphSize)
setmode (1)
send (*6)
send (*0)
rawdata.run
sleep (%DelayRDS)
rawdata.stop
rawdata.save (%DataPath\rw.spy)
rds.getdata
rds.getstatistics
call (EvaluateWarnings)
if (%tcpconfailed=1)
textwindow.addline({%time} WiFi link failure detected - trying again)
goto (ProcessStation)
endif
savetext (%DataPath\rd.txt,PS: %rdsps, PI: %rdspi, PTY: %rdspty, TP: %rdstp, TA: %rdsta, MS: %rdsms, DI: %rdsdi, CT: %rdsct, EON: %rdseon
RT: %rdsrt, ECC: %rdsecc, PTYN: %rdsptyn)
appendtext (%DataPath\rd.txt,
AF: %rdsaf)
appendtext (%DataPath\rd.txt,%cr%rdsstat1
%rdsstat2
%rdsstat3
%rdsstat4)
savetext (%DataPath\dt.txt,