From 7dd65b03752efc7022006de152044df8c25fa1fa Mon Sep 17 00:00:00 2001 From: egthomas Date: Fri, 20 Aug 2021 16:42:24 -0400 Subject: [PATCH 01/22] Updating CV versions of interleavesound and normalsound for compatibility with site-specific code --- qnx6/interleavesound.1.0/interleavesound_cv.c | 4 ++-- qnx6/normalsound.2.0/normalsound_cv.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qnx6/interleavesound.1.0/interleavesound_cv.c b/qnx6/interleavesound.1.0/interleavesound_cv.c index f10c26d..64f16dc 100644 --- a/qnx6/interleavesound.1.0/interleavesound_cv.c +++ b/qnx6/interleavesound.1.0/interleavesound_cv.c @@ -346,7 +346,7 @@ int main(int argc,char *argv[]) { } else xcf=0; } else xcf=0; - skip = OpsFindSkip(scnsc,scnus); + skip = OpsFindSkip(scnsc,scnus,intsc,intus,0); bmnum = bms[skip]; /* no longer need forward and backward arrays... */ @@ -559,7 +559,7 @@ int main(int argc,char *argv[]) { /* now wait for the next interleavescan */ intsc = fast_intt_sc; intus = fast_intt_us; - if (scannowait==0) SiteEndScan(scnsc,scnus); + if (scannowait==0) SiteEndScan(scnsc,scnus,5000); } } while (exitpoll==0); diff --git a/qnx6/normalsound.2.0/normalsound_cv.c b/qnx6/normalsound.2.0/normalsound_cv.c index d2ecf37..3c2e3cf 100644 --- a/qnx6/normalsound.2.0/normalsound_cv.c +++ b/qnx6/normalsound.2.0/normalsound_cv.c @@ -200,6 +200,7 @@ int main(int argc,char *argv[]) OptionAdd(&opt, "di", 'x', &discretion); OptionAdd(&opt, "frang", 'i', &frang); OptionAdd(&opt, "rsep", 'i', &rsep); + OptionAdd(&opt, "nrang", 'i', &nrang); OptionAdd(&opt, "dt", 'i', &day); OptionAdd(&opt, "nt", 'i', &night); OptionAdd(&opt, "df", 'i', &dfrq); @@ -375,7 +376,7 @@ int main(int argc,char *argv[]) } else xcf=0; } else xcf=0; - skip=OpsFindSkip(scnsc,scnus); + skip=OpsFindSkip(scnsc,scnus,intsc,intus,0); if (backward) { bmnum=sbm-skip; @@ -606,7 +607,7 @@ int main(int argc,char *argv[]) /* now wait for the next normalscan */ intsc = def_intt_sc; intus = def_intt_us; - if (scannowait==0) SiteEndScan(scnsc,scnus); + if (scannowait==0) SiteEndScan(scnsc,scnus,5000); } } while (exitpoll == 0); @@ -628,6 +629,7 @@ void usage(void) printf(" -di : indicates running during discretionary time\n"); printf(" -frang int : delay to first range (km) [180]\n"); printf(" -rsep int : range separation (km) [45]\n"); + printf(" -nrang int : number of range gates [100]\n"); printf(" -dt int : hour when day freq. is used [site.c]\n"); printf(" -nt int : hour when night freq. is used [site.c]\n"); printf(" -df int : daytime frequency (kHz) [site.c]\n"); From 3d9845e246df145c6776a89080541ab42d4f4e81 Mon Sep 17 00:00:00 2001 From: egthomas Date: Tue, 24 Aug 2021 13:30:47 -0400 Subject: [PATCH 02/22] Modifying sndwrite.c for QNX6 interleavesound and normalsound control programs to allow writing sounding records even if there are no ranges with valid fits, in order to preserve radar operations info usually stored in the radar parameter block --- qnx6/interleavesound.1.0/sndwrite.c | 59 +++++++++++++++-------------- qnx6/normalsound.2.0/sndwrite.c | 59 +++++++++++++++-------------- 2 files changed, 60 insertions(+), 58 deletions(-) diff --git a/qnx6/interleavesound.1.0/sndwrite.c b/qnx6/interleavesound.1.0/sndwrite.c index 9a3e3fb..7a14bd1 100644 --- a/qnx6/interleavesound.1.0/sndwrite.c +++ b/qnx6/interleavesound.1.0/sndwrite.c @@ -109,47 +109,48 @@ int SndWrite(int fid, struct RadarParm *prm, struct FitData *fit) { if (prm->xcf !=0) xnum=snum; else xnum=0; - if (snum==0) return 0; + if (snum !=0) { - slist=DataMapStoreArray(ptr,"slist",DATASHORT,1,&snum,NULL); + slist=DataMapStoreArray(ptr,"slist",DATASHORT,1,&snum,NULL); - qflg=DataMapStoreArray(ptr,"qflg",DATACHAR,1,&snum,NULL); - gflg=DataMapStoreArray(ptr,"gflg",DATACHAR,1,&snum,NULL); + qflg=DataMapStoreArray(ptr,"qflg",DATACHAR,1,&snum,NULL); + gflg=DataMapStoreArray(ptr,"gflg",DATACHAR,1,&snum,NULL); - v=DataMapStoreArray(ptr,"v",DATAFLOAT,1,&snum,NULL); - v_e=DataMapStoreArray(ptr,"v_e",DATAFLOAT,1,&snum,NULL); - p_l=DataMapStoreArray(ptr,"p_l",DATAFLOAT,1,&snum,NULL); - w_l=DataMapStoreArray(ptr,"w_l",DATAFLOAT,1,&snum,NULL); + v=DataMapStoreArray(ptr,"v",DATAFLOAT,1,&snum,NULL); + v_e=DataMapStoreArray(ptr,"v_e",DATAFLOAT,1,&snum,NULL); + p_l=DataMapStoreArray(ptr,"p_l",DATAFLOAT,1,&snum,NULL); + w_l=DataMapStoreArray(ptr,"w_l",DATAFLOAT,1,&snum,NULL); - if (prm->xcf !=0) { - x_qflg=DataMapStoreArray(ptr,"x_qflg",DATACHAR,1,&xnum,NULL); + if (prm->xcf !=0) { + x_qflg=DataMapStoreArray(ptr,"x_qflg",DATACHAR,1,&xnum,NULL); - phi0=DataMapStoreArray(ptr,"phi0",DATAFLOAT,1,&xnum,NULL); - phi0_e=DataMapStoreArray(ptr,"phi0_e",DATAFLOAT,1,&xnum,NULL); - } + phi0=DataMapStoreArray(ptr,"phi0",DATAFLOAT,1,&xnum,NULL); + phi0_e=DataMapStoreArray(ptr,"phi0_e",DATAFLOAT,1,&xnum,NULL); + } - x=0; + x=0; - for (c=0;cnrang;c++) { - if ( (fit->rng[c].qflg==1) || - ((fit->xrng !=NULL) && (fit->xrng[c].qflg==1))) { - slist[x]=c; + for (c=0;cnrang;c++) { + if ( (fit->rng[c].qflg==1) || + ((fit->xrng !=NULL) && (fit->xrng[c].qflg==1))) { + slist[x]=c; - qflg[x]=fit->rng[c].qflg; - gflg[x]=fit->rng[c].gsct; + qflg[x]=fit->rng[c].qflg; + gflg[x]=fit->rng[c].gsct; - p_l[x]=fit->rng[c].p_l; - v[x]=fit->rng[c].v; - v_e[x]=fit->rng[c].v_err; - w_l[x]=fit->rng[c].w_l; + p_l[x]=fit->rng[c].p_l; + v[x]=fit->rng[c].v; + v_e[x]=fit->rng[c].v_err; + w_l[x]=fit->rng[c].w_l; - if (xnum !=0) { - x_qflg[x]=fit->xrng[c].qflg; + if (xnum !=0) { + x_qflg[x]=fit->xrng[c].qflg; - phi0[x]=fit->xrng[c].phi0; - phi0_e[x]=fit->xrng[c].phi0_err; + phi0[x]=fit->xrng[c].phi0; + phi0_e[x]=fit->xrng[c].phi0_err; + } + x++; } - x++; } } diff --git a/qnx6/normalsound.2.0/sndwrite.c b/qnx6/normalsound.2.0/sndwrite.c index 9a3e3fb..7a14bd1 100644 --- a/qnx6/normalsound.2.0/sndwrite.c +++ b/qnx6/normalsound.2.0/sndwrite.c @@ -109,47 +109,48 @@ int SndWrite(int fid, struct RadarParm *prm, struct FitData *fit) { if (prm->xcf !=0) xnum=snum; else xnum=0; - if (snum==0) return 0; + if (snum !=0) { - slist=DataMapStoreArray(ptr,"slist",DATASHORT,1,&snum,NULL); + slist=DataMapStoreArray(ptr,"slist",DATASHORT,1,&snum,NULL); - qflg=DataMapStoreArray(ptr,"qflg",DATACHAR,1,&snum,NULL); - gflg=DataMapStoreArray(ptr,"gflg",DATACHAR,1,&snum,NULL); + qflg=DataMapStoreArray(ptr,"qflg",DATACHAR,1,&snum,NULL); + gflg=DataMapStoreArray(ptr,"gflg",DATACHAR,1,&snum,NULL); - v=DataMapStoreArray(ptr,"v",DATAFLOAT,1,&snum,NULL); - v_e=DataMapStoreArray(ptr,"v_e",DATAFLOAT,1,&snum,NULL); - p_l=DataMapStoreArray(ptr,"p_l",DATAFLOAT,1,&snum,NULL); - w_l=DataMapStoreArray(ptr,"w_l",DATAFLOAT,1,&snum,NULL); + v=DataMapStoreArray(ptr,"v",DATAFLOAT,1,&snum,NULL); + v_e=DataMapStoreArray(ptr,"v_e",DATAFLOAT,1,&snum,NULL); + p_l=DataMapStoreArray(ptr,"p_l",DATAFLOAT,1,&snum,NULL); + w_l=DataMapStoreArray(ptr,"w_l",DATAFLOAT,1,&snum,NULL); - if (prm->xcf !=0) { - x_qflg=DataMapStoreArray(ptr,"x_qflg",DATACHAR,1,&xnum,NULL); + if (prm->xcf !=0) { + x_qflg=DataMapStoreArray(ptr,"x_qflg",DATACHAR,1,&xnum,NULL); - phi0=DataMapStoreArray(ptr,"phi0",DATAFLOAT,1,&xnum,NULL); - phi0_e=DataMapStoreArray(ptr,"phi0_e",DATAFLOAT,1,&xnum,NULL); - } + phi0=DataMapStoreArray(ptr,"phi0",DATAFLOAT,1,&xnum,NULL); + phi0_e=DataMapStoreArray(ptr,"phi0_e",DATAFLOAT,1,&xnum,NULL); + } - x=0; + x=0; - for (c=0;cnrang;c++) { - if ( (fit->rng[c].qflg==1) || - ((fit->xrng !=NULL) && (fit->xrng[c].qflg==1))) { - slist[x]=c; + for (c=0;cnrang;c++) { + if ( (fit->rng[c].qflg==1) || + ((fit->xrng !=NULL) && (fit->xrng[c].qflg==1))) { + slist[x]=c; - qflg[x]=fit->rng[c].qflg; - gflg[x]=fit->rng[c].gsct; + qflg[x]=fit->rng[c].qflg; + gflg[x]=fit->rng[c].gsct; - p_l[x]=fit->rng[c].p_l; - v[x]=fit->rng[c].v; - v_e[x]=fit->rng[c].v_err; - w_l[x]=fit->rng[c].w_l; + p_l[x]=fit->rng[c].p_l; + v[x]=fit->rng[c].v; + v_e[x]=fit->rng[c].v_err; + w_l[x]=fit->rng[c].w_l; - if (xnum !=0) { - x_qflg[x]=fit->xrng[c].qflg; + if (xnum !=0) { + x_qflg[x]=fit->xrng[c].qflg; - phi0[x]=fit->xrng[c].phi0; - phi0_e[x]=fit->xrng[c].phi0_err; + phi0[x]=fit->xrng[c].phi0; + phi0_e[x]=fit->xrng[c].phi0_err; + } + x++; } - x++; } } From bf2847194d2d2dee79906348e205209d5d3eeccf Mon Sep 17 00:00:00 2001 From: egthomas Date: Thu, 26 Aug 2021 16:05:29 -0400 Subject: [PATCH 03/22] Modifying QNX4 and QNX6 interleavesound and normalsound control programs to try fixing the number of range gates used for sounding while still allowing for any number of ranges during normal operation --- qnx4/interleavesound.1.00/interleavesound.c | 9 ++++++++- qnx4/normalsound.3.00/normalsound.c | 10 +++++++++- qnx6/interleavesound.1.0/interleavesound_cv.c | 15 +++++++++++---- qnx6/interleavesound.1.0/interleavesound_fh.c | 15 +++++++++++---- qnx6/normalsound.2.0/normalsound_cv.c | 14 ++++++++++---- qnx6/normalsound.2.0/normalsound_fh.c | 14 ++++++++++---- 6 files changed, 59 insertions(+), 18 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index b844080..0443db9 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -120,6 +120,8 @@ int main(int argc,char *argv[]) { int skip; int cnt=0; + int def_nrang=75; + unsigned char discretion=0; /* ---------- Beam sequence for interleavedscan ---------- */ @@ -176,6 +178,7 @@ int main(int argc,char *argv[]) { int odd_beams=0; int snd_freq; int snd_frqrng=100; + int snd_nrang=75; float snd_time, snd_intt, time_needed=1.25; unsigned char limit_fswitch=0; @@ -239,7 +242,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = 75; + nrang = def_nrang; rsep = 45; txpl = 300; /* recalculated below with rsep */ frang = 180; @@ -285,6 +288,8 @@ int main(int argc,char *argv[]) { SiteSetupHardware(); + def_nrang = nrang; + // set a negative CPID for discretionary time if (discretion) cp = -cp; @@ -444,6 +449,7 @@ int main(int argc,char *argv[]) { while (snd_time-snd_intt > time_needed) { intsc = snd_intt_sc; intus = snd_intt_us; + nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -548,6 +554,7 @@ int main(int argc,char *argv[]) { /* now wait for the next interleavescan */ intsc = fast_intt_sc; intus = fast_intt_us; + nrang = def_nrang; OpsWaitBoundary(scnsc,scnus); } diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index 753ab41..11d10dc 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -145,6 +145,8 @@ int main(int argc,char *argv[]) { int skip; int cnt=0; + int def_nrang=75; + unsigned char fast=0; unsigned char discretion=0; @@ -190,6 +192,7 @@ int main(int argc,char *argv[]) { int odd_beams=0; int snd_freq; int snd_frqrng=100; + int snd_nrang=75; float snd_time, snd_intt, time_needed=1.25; if (snd_bms_tot == 8) { @@ -253,7 +256,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = 75; + nrang = def_nrang; rsep = 45; txpl = 300; /* recalculated below with rsep */ frang = 180; @@ -305,6 +308,9 @@ int main(int argc,char *argv[]) { intsc = fast_intt_sc; intus = fast_intt_us; } + + def_nrang = nrang; + if (discretion) cp = -cp; // recalculate txpl @@ -454,6 +460,7 @@ int main(int argc,char *argv[]) { while (snd_time-snd_intt > time_needed) { intsc = snd_intt_sc; intus = snd_intt_us; + nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -549,6 +556,7 @@ int main(int argc,char *argv[]) { intsc = normal_intt_sc; intus = normal_intt_us; } + nrang = def_nrang; OpsWaitBoundary(scnsc,scnus); } diff --git a/qnx6/interleavesound.1.0/interleavesound_cv.c b/qnx6/interleavesound.1.0/interleavesound_cv.c index 64f16dc..e035e95 100644 --- a/qnx6/interleavesound.1.0/interleavesound_cv.c +++ b/qnx6/interleavesound.1.0/interleavesound_cv.c @@ -121,6 +121,8 @@ int main(int argc,char *argv[]) { int status=0; int fixfrq=0; + int def_nrang=100; + /* new variables for dynamically creating beam sequences */ int *bms; /* scanning beams */ int intgt[20]; /* start times of each integration period */ @@ -153,6 +155,7 @@ int main(int argc,char *argv[]) { int snd_bms_tot=10, odd_beams=0; int snd_freq; int snd_frqrng=100; + int snd_nrang=75; int fast_intt_sc=2; int fast_intt_us=500000; int snd_intt_sc=1; @@ -174,7 +177,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = 100; + nrang = def_nrang; rsep = 45; txpl = 300; /* note: recomputed below */ dfrq = 10200; @@ -306,6 +309,8 @@ int main(int argc,char *argv[]) { exit (1); } + def_nrang = nrang; + if (discretion) cp = -cp; txpl=(rsep*20)/3; /* computing TX pulse length */ @@ -320,10 +325,10 @@ int main(int argc,char *argv[]) { OpsFitACFStart(); - tsgid=SiteTimeSeq(ptab); /* get the timing sequence */ - do { + tsgid=SiteTimeSeq(ptab); /* get the timing sequence */ + if (SiteStartScan() !=0) continue; if (OpsReOpen(2,0,0) !=0) { @@ -456,6 +461,7 @@ int main(int argc,char *argv[]) { while (snd_time-snd_intt > time_needed) { intsc = snd_intt_sc; intus = snd_intt_us; + nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -464,6 +470,7 @@ int main(int argc,char *argv[]) { snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ + tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); @@ -476,7 +483,6 @@ int main(int argc,char *argv[]) { * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); * ErrLog(errlog.sock, progname, logtxt); * */ - tsgid = SiteTimeSeq(ptab); nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -559,6 +565,7 @@ int main(int argc,char *argv[]) { /* now wait for the next interleavescan */ intsc = fast_intt_sc; intus = fast_intt_us; + nrang = def_nrang; if (scannowait==0) SiteEndScan(scnsc,scnus,5000); } diff --git a/qnx6/interleavesound.1.0/interleavesound_fh.c b/qnx6/interleavesound.1.0/interleavesound_fh.c index c5471af..b75f460 100644 --- a/qnx6/interleavesound.1.0/interleavesound_fh.c +++ b/qnx6/interleavesound.1.0/interleavesound_fh.c @@ -128,6 +128,8 @@ int main(int argc,char *argv[]) { int status=0; int fixfrq=0; + int def_nrang=100; + /* new variables for dynamically creating beam sequences */ int *bms; /* scanning beams */ int intgt[20]; /* start times of each integration period */ @@ -160,6 +162,7 @@ int main(int argc,char *argv[]) { int snd_bms_tot=10, odd_beams=0; int snd_freq; int snd_frqrng=100; + int snd_nrang=75; int fast_intt_sc=2; int fast_intt_us=500000; int snd_intt_sc=1; @@ -181,7 +184,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = 100; + nrang = def_nrang; rsep = 45; txpl = 300; /* note: recomputed below */ dfrq = 10200; @@ -324,6 +327,8 @@ int main(int argc,char *argv[]) { exit (1); } + def_nrang = nrang; + if (discretion) cp = -cp; txpl=(rsep*20)/3; /* computing TX pulse length */ @@ -338,10 +343,10 @@ int main(int argc,char *argv[]) { OpsFitACFStart(); - tsgid=SiteTimeSeq(ptab); /* get the timing sequence */ - do { + tsgid=SiteTimeSeq(ptab); /* get the timing sequence */ + if (SiteStartScan() !=0) continue; if (OpsReOpen(2,0,0) !=0) { @@ -474,6 +479,7 @@ int main(int argc,char *argv[]) { while (snd_time-snd_intt > time_needed) { intsc = snd_intt_sc; intus = snd_intt_us; + nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -482,6 +488,7 @@ int main(int argc,char *argv[]) { snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ + tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); @@ -494,7 +501,6 @@ int main(int argc,char *argv[]) { * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); * ErrLog(errlog.sock, progname, logtxt); * */ - tsgid = SiteTimeSeq(ptab); nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -577,6 +583,7 @@ int main(int argc,char *argv[]) { /* now wait for the next interleavescan */ intsc = fast_intt_sc; intus = fast_intt_us; + nrang = def_nrang; if (scannowait==0) SiteEndScan(scnsc,scnus); } diff --git a/qnx6/normalsound.2.0/normalsound_cv.c b/qnx6/normalsound.2.0/normalsound_cv.c index 3c2e3cf..96e4911 100644 --- a/qnx6/normalsound.2.0/normalsound_cv.c +++ b/qnx6/normalsound.2.0/normalsound_cv.c @@ -135,6 +135,7 @@ int main(int argc,char *argv[]) int total_integration_usecs=0; int def_intt_sc=0; int def_intt_us=0; + int def_nrang=0; int debug=0; unsigned char hlp=0; @@ -170,6 +171,7 @@ int main(int argc,char *argv[]) int snd_bms_tot=10, odd_beams=0; int snd_freq; int snd_frqrng=100; + int snd_nrang=75; int snd_sc=12; int snd_intt_sc=1; int snd_intt_us=500000; @@ -325,6 +327,8 @@ int main(int argc,char *argv[]) def_intt_sc = total_integration_usecs/1E6; def_intt_us = total_integration_usecs - (intsc*1e6); + def_nrang = nrang; + intsc = def_intt_sc; intus = def_intt_us; @@ -346,14 +350,14 @@ int main(int argc,char *argv[]) printf("Preparing OpsFitACFStart Station ID: %s %d\n",ststr,stid); OpsFitACFStart(); - printf("Preparing SiteTimeSeq Station ID: %s %d\n",ststr,stid); - tsgid=SiteTimeSeq(ptab); - printf("Entering Scan loop Station ID: %s %d\n",ststr,stid); do { // if (timed) gettimeofday(&t0,NULL); + printf("Preparing SiteTimeSeq Station ID: %s %d\n",ststr,stid); + tsgid=SiteTimeSeq(ptab); + printf("Entering Site Start Scan Station ID: %s %d\n",ststr,stid); if (SiteStartScan() !=0) continue; @@ -504,6 +508,7 @@ int main(int argc,char *argv[]) while (snd_time-snd_intt > time_needed) { intsc = snd_intt_sc; intus = snd_intt_us; + nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -512,6 +517,7 @@ int main(int argc,char *argv[]) snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ + tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); @@ -524,7 +530,6 @@ int main(int argc,char *argv[]) * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); * ErrLog(errlog.sock, progname, logtxt); * */ - tsgid = SiteTimeSeq(ptab); nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -607,6 +612,7 @@ int main(int argc,char *argv[]) /* now wait for the next normalscan */ intsc = def_intt_sc; intus = def_intt_us; + nrang = def_nrang; if (scannowait==0) SiteEndScan(scnsc,scnus,5000); } diff --git a/qnx6/normalsound.2.0/normalsound_fh.c b/qnx6/normalsound.2.0/normalsound_fh.c index 78849f0..ae29cbc 100644 --- a/qnx6/normalsound.2.0/normalsound_fh.c +++ b/qnx6/normalsound.2.0/normalsound_fh.c @@ -138,6 +138,7 @@ int main(int argc,char *argv[]) int total_integration_usecs=0; int def_intt_sc=0; int def_intt_us=0; + int def_nrang=0; int debug=0; unsigned char hlp=0; @@ -173,6 +174,7 @@ int main(int argc,char *argv[]) int snd_bms_tot=10, odd_beams=0; int snd_freq; int snd_frqrng=100; + int snd_nrang=75; int snd_sc=12; int snd_intt_sc=1; int snd_intt_us=500000; @@ -336,6 +338,8 @@ int main(int argc,char *argv[]) def_intt_sc = total_integration_usecs/1E6; def_intt_us = total_integration_usecs - (intsc*1e6); + def_nrang = nrang; + intsc = def_intt_sc; intus = def_intt_us; @@ -357,14 +361,14 @@ int main(int argc,char *argv[]) printf("Preparing OpsFitACFStart Station ID: %s %d\n",ststr,stid); OpsFitACFStart(); - printf("Preparing SiteTimeSeq Station ID: %s %d\n",ststr,stid); - tsgid=SiteTimeSeq(ptab); - printf("Entering Scan loop Station ID: %s %d\n",ststr,stid); do { // if (timed) gettimeofday(&t0,NULL); + printf("Preparing SiteTimeSeq Station ID: %s %d\n",ststr,stid); + tsgid=SiteTimeSeq(ptab); + printf("Entering Site Start Scan Station ID: %s %d\n",ststr,stid); if (SiteStartScan() !=0) continue; @@ -515,6 +519,7 @@ int main(int argc,char *argv[]) while (snd_time-snd_intt > time_needed) { intsc = snd_intt_sc; intus = snd_intt_us; + nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -523,6 +528,7 @@ int main(int argc,char *argv[]) snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ + tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); @@ -535,7 +541,6 @@ int main(int argc,char *argv[]) * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); * ErrLog(errlog.sock, progname, logtxt); * */ - tsgid = SiteTimeSeq(ptab); nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -618,6 +623,7 @@ int main(int argc,char *argv[]) /* now wait for the next normalscan */ intsc = def_intt_sc; intus = def_intt_us; + nrang = def_nrang; if (scannowait==0) SiteEndScan(scnsc,scnus); } From 8763895c6df0ca8a1fa1649d494f3f0ed77ef0ec Mon Sep 17 00:00:00 2001 From: egthomas Date: Thu, 26 Aug 2021 20:44:41 -0400 Subject: [PATCH 04/22] Adding sd_leicester QNX4 subdirectory --- qnx4/sd_leicester/han/nailedscan/makefile | 55 + qnx4/sd_leicester/han/nailedscan/nailedscan.c | 1281 +++++++++++++++ qnx4/sd_leicester/han/nailedscan/version.info | 15 + .../sd_leicester/han/normalscan.1.08/makefile | 44 + .../han/normalscan.1.08/makefile.bak | 48 + .../han/normalscan.1.08/normalscan.c | 394 +++++ .../han/normalscan.1.08/version.info | 27 + .../han/normalsound.2.05/makefile | 44 + .../han/normalsound.2.05/normalsound.c | 966 ++++++++++++ .../han/normalsound.2.05/version.info | 19 + .../han/pcpstereoscan.1.02/makefile | 55 + .../han/pcpstereoscan.1.02/pcpstereoscan.c | 874 +++++++++++ .../pcpstereoscan.1.02/pcpstereoscan.c.orig | 864 +++++++++++ .../han/pcpstereoscan.1.02/version.info | 9 + .../sd_leicester/han/stereoscan.1.04/makefile | 55 + .../han/stereoscan.1.04/stereoscan.c | 1271 +++++++++++++++ .../han/stereoscan.1.04/version.info | 15 + .../sd_leicester/pyk/normalscan.1.08/makefile | 44 + .../pyk/normalscan.1.08/makefile.bak | 48 + .../pyk/normalscan.1.08/normalscan.c | 394 +++++ .../pyk/normalscan.1.08/version.info | 27 + .../pyk/normalsound.2.05/makefile | 44 + .../pyk/normalsound.2.05/normalsound.c | 966 ++++++++++++ .../pyk/normalsound.2.05/version.info | 19 + .../sd_leicester/pyk/stereoscan.1.04/makefile | 55 + .../pyk/stereoscan.1.04/stereoscan.c | 1371 +++++++++++++++++ .../pyk/stereoscan.1.04/stereoscan.c.orig | 1271 +++++++++++++++ .../pyk/stereoscan.1.04/version.info | 15 + 28 files changed, 10290 insertions(+) create mode 100644 qnx4/sd_leicester/han/nailedscan/makefile create mode 100644 qnx4/sd_leicester/han/nailedscan/nailedscan.c create mode 100644 qnx4/sd_leicester/han/nailedscan/version.info create mode 100644 qnx4/sd_leicester/han/normalscan.1.08/makefile create mode 100644 qnx4/sd_leicester/han/normalscan.1.08/makefile.bak create mode 100644 qnx4/sd_leicester/han/normalscan.1.08/normalscan.c create mode 100644 qnx4/sd_leicester/han/normalscan.1.08/version.info create mode 100644 qnx4/sd_leicester/han/normalsound.2.05/makefile create mode 100644 qnx4/sd_leicester/han/normalsound.2.05/normalsound.c create mode 100644 qnx4/sd_leicester/han/normalsound.2.05/version.info create mode 100644 qnx4/sd_leicester/han/pcpstereoscan.1.02/makefile create mode 100644 qnx4/sd_leicester/han/pcpstereoscan.1.02/pcpstereoscan.c create mode 100644 qnx4/sd_leicester/han/pcpstereoscan.1.02/pcpstereoscan.c.orig create mode 100644 qnx4/sd_leicester/han/pcpstereoscan.1.02/version.info create mode 100644 qnx4/sd_leicester/han/stereoscan.1.04/makefile create mode 100644 qnx4/sd_leicester/han/stereoscan.1.04/stereoscan.c create mode 100644 qnx4/sd_leicester/han/stereoscan.1.04/version.info create mode 100644 qnx4/sd_leicester/pyk/normalscan.1.08/makefile create mode 100644 qnx4/sd_leicester/pyk/normalscan.1.08/makefile.bak create mode 100644 qnx4/sd_leicester/pyk/normalscan.1.08/normalscan.c create mode 100644 qnx4/sd_leicester/pyk/normalscan.1.08/version.info create mode 100644 qnx4/sd_leicester/pyk/normalsound.2.05/makefile create mode 100644 qnx4/sd_leicester/pyk/normalsound.2.05/normalsound.c create mode 100644 qnx4/sd_leicester/pyk/normalsound.2.05/version.info create mode 100644 qnx4/sd_leicester/pyk/stereoscan.1.04/makefile create mode 100644 qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c create mode 100644 qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c.orig create mode 100644 qnx4/sd_leicester/pyk/stereoscan.1.04/version.info diff --git a/qnx4/sd_leicester/han/nailedscan/makefile b/qnx4/sd_leicester/han/nailedscan/makefile new file mode 100644 index 0000000..5c3d18b --- /dev/null +++ b/qnx4/sd_leicester/han/nailedscan/makefile @@ -0,0 +1,55 @@ +# Makefile for nailedscan +# ======================= +# by R.J.Barnes +# +# + + +INCLUDE=-I$(IPATH)/base -I$(IPATH)/general -I$(IPATH)/superdarn \ + -I$(IPATH)/radarqnx4 \ + -I$(USR_IPATH)/radarqnx4/ops \ + -I$(USR_IPATH)/radarqnx4/site.$(SD_RADARCODE) + +OBJS = nailedscan.o +SRC=nailedscan.c +IGNVER=1 +OUTPUT = $(USR_BINPATH)/nailedscan +SUDO = 1 +LIBS=-lsite.${SD_RADARCODE}.1 -lops.1 -lfitacf.1 -lradar.1 -lerrlog.1 \ + -lrs.1 -lfreq.1 -lacf.1 -ltcpipmsg.1 -lrawfeed.1 -ltsg.1 \ + -ltaskid.1 -lrmsgsnd.1 -lrtimer.1 -lrtime.1 -lrmath.1 -lopt.1 + +include $(SITELIB).${SD_RADARCODE} + +ifdef STEREO +include $(MAKEBIN) +else +version: version.info $(SRC) + $(BINPATH)/rcsv -t version.info +clean: + rm -f *.o + rm -f $(OUTPUT) +endif + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qnx4/sd_leicester/han/nailedscan/nailedscan.c b/qnx4/sd_leicester/han/nailedscan/nailedscan.c new file mode 100644 index 0000000..3b529a5 --- /dev/null +++ b/qnx4/sd_leicester/han/nailedscan/nailedscan.c @@ -0,0 +1,1281 @@ +/* nailedscan.c + ============ + + Modified stereoscan to run channel B at a fixed frequency + + Author: R.J.Barnes +*/ +#define NAILEDFREQ 11210 +/* this is the fixed frequency for channel B. It is not allowed as a + command line argument to prevent errors in entering the frequency */ + + +/* + Copyright 2004 The Johns Hopkins University/Applied Physics Laboratory. + All rights reserved. + + This material may be used, modified, or reproduced by or for the U.S. + Government pursuant to the license rights granted under the clauses at DFARS + 252.227-7013/7014. + + For any other permissions, please contact the Space Department + Program Office at JHU/APL. + + This Distribution and Disclaimer Statement must be included in all copies of + "Radar Operating System - Control Programs" (hereinafter "the Program"). + + The Program was developed at The Johns Hopkins University/Applied Physics + Laboratory (JHU/APL) which is the author thereof under the "work made for + hire" provisions of the copyright law. + + JHU/APL assumes no obligation to provide support of any kind with regard to + the Program. This includes no obligation to provide assistance in using the + Program or to provide updated versions of the Program. + + THE PROGRAM AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT ANY EXPRESS + OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES INCLUDING, BUT NOT LIMITED + TO, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE + HEREBY DISCLAIMED. YOU ASSUME THE ENTIRE RISK AND LIABILITY OF USING THE + PROGRAM TO INCLUDE USE IN COMPLIANCE WITH ANY THIRD PARTY RIGHTS. YOU ARE + ADVISED TO TEST THE PROGRAM THOROUGHLY BEFORE RELYING ON IT. IN NO EVENT + SHALL JHU/APL BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING, WITHOUT + LIMITATION, ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR + CONSEQUENTIAL DAMAGES, ARISING OUT OF THE USE OR INABILITY TO USE THE + PROGRAM." + + + + + + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + +#include "taskid.h" +#include "errlog.h" +#include "freq.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "globals.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raws.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: nailedscan.c,v $ + Revision 1.4 2007/08/09 14:09:51 code + Allowed command lines to be passed as a file. + + Revision 1.3 2007/08/08 16:55:44 code + Fixed bug in using hex notation for stid. + + Revision 1.2 2006/07/12 15:51:43 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.1 2006/03/30 11:19:18 barnes + Initial revision + +*/ + +/* + Modified 10/12/2001 PH + + Added bnA and bnB frequency band options to cycle through frequency + bands during each scan. No check is made for invalid band numbers. + A band number of -1 is ignored. Bands can be added/removed at any + time using radar_shell, changes won't take effect until the end of + the current scan. If no band numbers are specified, normal day/night + frequencies are used. + + Frequency bands can also be specified for campA and campB modes. + + Extra options can be placed in a separate schedule file. The file + name should be the last argument in the schedule argument list and + should include the full path. + + Modified 16/01/02 PH + + Fixed synchronisation bug. The code wasn't subtracting the time taken + for a clear frequency search from the beam integration time, resulting + in an extended beam dwell time and a sweep lasting for more than 60 s + for fast stereo and 120 s for slow stereo 7 s integration. + + Standard slow stereo (normal stereo) is now 7 seconds (by Mark Lester). + + Modified 30/01/02 PH + + added -cts? options that pre-set other options + + dwell chan A cpidA chan B cpidB Ice/Fin offset range + ------ ------ ------ ------ ------ ------- ------ ----- + cts2 - 7 normal 152 tbj -26002 5 / 9 +400 45 + cts4 - 7 normal 152 normal -26004 5 / 9 +400 45 + cts6 - 7 normal 152 1 camp -26006 5 / 9 +400 45 + cts8 - 7 normal 152 2 camp -26008 5 / 9 +400 45 + + cts3 - 3 normal 153 tbj -26003 5 / 9 +400 45 + cts5 - 3 normal 153 normal -26005 5 / 9 +400 45 + cts7 - 3 normal 153 1 camp -26007 5 / 9 +400 45 + cts9 - 3 normal 153 2 camp -26009 5 / 9 +400 45 + + Single camp beams are hard coded to the standard Finland beam 9 and + Iceland beam 5. + + Double camp beams are the same for both radars and defined as + DOUBLE_CAMP_LOW and DOUBLE_CAMP_HIGH. + + range gates and first range are let to the default settings of 45km + and 180km respectively. + + specifying any cts option will override low and high beam, offset, cpIDs, + integration time and scan boundary. tbj mode overrides frequencies. + + Modified 05/04/02 PH + + Uses the new stereo aware version of fitacf (1.06). + + Modified 30/04/2002 PH + + Added cpidA and cpidB to set the cpid. This option overrides any + previously defined cpid. + + Added bmnA and bmnB to cycle through beams numbers on both channels. + To specify double camp beams use -bm0B 5 -bm1B 9 + To specify single camp beams use -bm0B 5 + The same beam number can be specified more than once. + The number of beams in the channel A beam list determines the number of + beams per scan. This is important if you are also using frequency lists. + + cts 2, 3, 4, 5 beams patterns can be changed with bm*A and bm*B options. + + Modified 25/09/02 PH + + Changed so that the B channel frequency band changes at the end of the + channel B scan, so that it is independent of the number of beams on + channel A. + + Modified 7th Dec 2001 to add camp beam flags + Modified 23 Nov 2001 to add new -ns and -fs flags and changed some defaults + Modified 10th Aug to account for backwards scanning radars + Modified 8th Aug fitacf_s + Julian modified version. March 2001 + +*/ + +#define CPID_A -6401 +#define CPID_B -26410 +#define CPID_NS 152 +#define CPID_FS 153 + + +#define INTT 7 +#define RSEP_A 45 +#define RSEP_B 45 +#define FRANG_A 180 +#define FRANG_B 180 + + +#define LOW_BEAM_A 0 +#define HIGH_BEAM_A 15 +#define LOW_BEAM_B 0 +#define HIGH_BEAM_B 15 + +#define SINGLE_CAMP_BEAM_PYK 5 +#define SINGLE_CAMP_BEAM_HAN 9 + + +#define DOUBLE_CAMP_LOW 5 +#define DOUBLE_CAMP_HIGH 9 + +#define UCONT_NAME "ucont_moni" + +#define CHN_A 0 +#define CHN_B 1 + +#define NUMBANDS 10 +#define NUMBEAMS 16 + + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + + + +void u_read_uconts(void); +void u_init_freq_bands(void); + +void RemInvalidEntries(int ifreqsA[], int ifreqsB[]); +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, int *day_nightA, int *day_nightB, int ifreqsA[], int ifreqsB[], int print); +void RemInvalidBeams(int ibeamsA[], int ibeamsB[]); +void FindNumBeams(int *numbeamsA, int *numbeamsB, int ibeamsA[], int ibeamsB[], int print); + +char cmdlne[1024]; +char progid[80]={"$Id: nailedscan.c,v 1.4 2007/08/09 14:09:51 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +int usfreq[42]; +int ufreq_range[42]; + +pid_t uucont_proxy; + +int low_beam_A=LOW_BEAM_A; +int high_beam_A=HIGH_BEAM_A; +int low_beam_B=LOW_BEAM_B; +int high_beam_B=HIGH_BEAM_B; + + + + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; +struct OptionFile *optf=NULL; + +int main(int argc,char *argv[]) { + + int ptab[7] = {0,9,12,20,22,26,27}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {26,27}, /* 1 */ + {20,22}, /* 2 */ + {9,12}, /* 3 */ + {22,26}, /* 4 */ + {22,27}, /* 5 */ + + {20,26}, /* 7 */ + {20,27}, /* 8 */ + {0,9}, /* 9 */ + {12,22}, /* 10 */ + {9,20}, /* 11 */ + {0,12}, /* 12 */ + {9,22}, /* 13 */ + {12,26}, /* 14 */ + {12,27}, /* 15 */ + {9,26}, /* 16 */ + {9,27}, /* 17 */ + {27,27}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + char a[10]; + + int n,i; + pid_t sid; + int exitpoll=0; + + int scnsc=0; + int scnus=0; + + unsigned char ns=0; + unsigned char fs=0; + + int stereo_offset=400; /* channel A delayed by this + number of microseconds */ + + + int ifreqsA[NUMBANDS],ifreqsB[NUMBANDS]; + + int ibeamsA[NUMBEAMS],ibeamsB[NUMBEAMS]; + + int day_nightA=1; + int day_nightB=1; + + int numfreqbandsA; + int numfreqbandsB; + + int ifreqsA_index=0; + int ifreqsB_index=0; + + int ifreqsAband; + int ifreqsBband; + + int numbeamsA,numbeamsB; + + int ibeamsA_index=0; + int ibeamsB_index=0; + + unsigned char cts2=0,cts4=0,cts6=0,cts8=0; + unsigned char cts3=0,cts5=0,cts7=0,cts9=0; + + int cpidA=0,cpidB=0; + + for (i=0;iargc,optf->argv,&opt,NULL); + OptionFreeFile(optf); + } + fclose(fp); + } + } + + if (sname==NULL) sname=sdname; + if (ename==NULL) ename=edname; + + sid=RShellRegister(sname,CONTROL_NAME); + + errlog=TaskIDMake(ename); + OpsLogStart(errlog,progname,argc,argv); + + /* handle CTs */ + + if ((cts2) || (cts4) || (cts6) || (cts8)) { + cpA = 152; + intsc = 7; + intus = 0; + stereo_offset = 400; + scnsc = 120; + scnus = 0; + + /* tbj mode */ + + if (cts2) { + cpB = -26002; + if (stid==9) { + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } + } + + /* normal scan */ + + if (cts4) cpB = -26004; + + /* single camp beam */ + + if (cts6) { + cpB = -26006; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts8) { + cpB = -26008; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else if ((cts3) || (cts5) || (cts7) || (cts9)) { + cpA = 153; + intsc = 3; + stereo_offset = 400; + scnsc = 60.0; + scnus = 0.0; + + /* tbj */ + + if (cts3) { + cpB = -26003; + + if (stid==9) { + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } + } + + /* normal scan */ + + if (cts5) cpB = -26005; + + + /* single camp beam */ + + if (cts7) { + cpB = -26007; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts9) { + cpB = -26009; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else + /* check for normal scan emulation */ + if (ns) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 7; + intus = 0; + scnsc = 120.0; + scnus = 0.0; + cpA = CPID_NS; + } else + /* check for fast scan emulation */ + if (fs) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 3; + intus = 0; + scnsc = 60.0; + scnus = 0.0; + cpA = CPID_FS; + } + + /* set cpid for channel A */ + + if (cpidA) { + cpA = cpidA; + cpB = -1 * abs(cpidA) - 20000; + } + + /* set cpid for channel B */ + + if (cpidB) cpB = cpidB; + + /* Calculate delay offsets + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* remember stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + mppulA = mppulB = 7; + mplgsA = mplgsB = 18; + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + /* just a dummy frequency */ + + tfreqA = 13500; + tfreqB = 14500; + + SiteSetupHardware(); + + /* remove invalid entries in the frequency band lists */ + + RemInvalidEntries(ifreqsA, ifreqsB); + + /* determine the number of frequency bands */ + + FindNumBands(&numfreqbandsA, &numfreqbandsB, + &day_nightA, &day_nightB, ifreqsA, ifreqsB, 1); + + /* check beams */ + + if (low_beam_A < LOW_BEAM_A) low_beam_A = LOW_BEAM_A; + if (high_beam_A > HIGH_BEAM_A) high_beam_A = HIGH_BEAM_A; + + if (low_beam_B < LOW_BEAM_B) low_beam_B = LOW_BEAM_B; + if (high_beam_B > HIGH_BEAM_B) high_beam_B = HIGH_BEAM_B; + + /* end beams in the wrong order */ + + if (low_beam_A > high_beam_A) { + int beam = high_beam_A; + high_beam_A = low_beam_A; + low_beam_A = beam; + } + + if (low_beam_B > high_beam_B) { + int beam = high_beam_B; + high_beam_B = low_beam_B; + low_beam_B = beam; + } + + /* sort beam lists */ + + RemInvalidBeams(ibeamsA, ibeamsB); + FindNumBeams(&numbeamsA, &numbeamsB, ibeamsA, ibeamsB, 1); + + /* + the beam lists now contain: + 1) the number of beams in the beam lists + 2) if no beam list or camp beams were specified = 0 -> 15 + 3) if high and low beams were specified = low_beam -> high_beam + */ + + sprintf(progname,"nailedscan"); + + OpsFitACFStart(); + + OpsSetupTask(tasklist); + for (n=0;ndfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; + + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + +// nailedscan change + tfreqB=NAILEDFREQ; + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d (%02d) %5d (%02d) - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, ifreqsAband, tfreqB, ifreqsBband, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + + ErrLog(errlog,progname,logtxt); + + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + + + msg.num=0; + msg.tsize=0; + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + + + for (n=0;n= numfreqbandsA) ifreqsA_index = 0; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + + /* Calculate delay offsets if stereo offset has been changed + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + scanA = 0; + scanB = 0; + + /* change beam number index */ + + ibeamsB_index++; + + if (ibeamsB_index >= numbeamsB) ibeamsB_index = 0; + + /* change band at the end of channel B scan */ + + if (ibeamsB_index == 0) { + if (numfreqbandsB != 0) { + ifreqsB_index++; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + } + } + } + + /* increment individual frequency band index. Doesn't matter whether + individual frequency bands are being used for this channel or not. + */ + + if (numfreqbandsA != 0) { + ifreqsA_index++; + if (ifreqsA_index >= numfreqbandsA) ifreqsA_index = 0; + } + + ErrLog(errlog,progname,"Waiting for scan boundary."); + if ((scnsc !=0) || (scnus !=0)) { + if (exitpoll==0) OpsWaitBoundary(scnsc,scnus); + } + } while (exitpoll==0); + SiteEnd(); + for (n=0;n 0; i--) { + + /* if the preceding element is -1 then move all the following + bands down + */ + + if ((ifreqsA[i] != -1) && (ifreqsA[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsA[j - 1] = ifreqsA[j]; + ifreqsA[j] = -1; + } + } + + if ((ifreqsB[i] != -1) && (ifreqsB[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsB[j - 1] = ifreqsB[j]; + ifreqsB[j] = -1; + } + } + } +} + +/* determine the number of frequency bands */ + +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, + int *day_nightA, int *day_nightB, + int ifreqsA[NUMBANDS], int ifreqsB[NUMBANDS], + int print) { + int i; + char logtxt[256]; + + *numfreqbandsA = 0; + *numfreqbandsB = 0; + + for (i = 0; i < NUMBANDS; i++) { + if (ifreqsA[i] != -1) (*numfreqbandsA)++; + if (ifreqsB[i] != -1) (*numfreqbandsB)++; + } + + /* check to see if day/night frequencies are to be used */ + + if (*numfreqbandsA != 0) *day_nightA = 0; + else *day_nightA = 1; + + if (*numfreqbandsB != 0) *day_nightB = 0; + else *day_nightB = 1; + + if (print) { + sprintf(logtxt, "Channel A: %d Channel B: %d", *numfreqbandsA, + *numfreqbandsB); + ErrLog(errlog, progname, logtxt); + } + + /* print frequency bands for each channel */ + + if ((*numfreqbandsA > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel A: "); + + for (i = 0; i < *numfreqbandsA; i++) { + sprintf(logtxt, "%1d ", ifreqsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if ((*numfreqbandsB > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel B: "); + + for (i = 0; i < *numfreqbandsB; i++) { + sprintf(logtxt, "%1d ", ifreqsB[i]); + ErrLog(errlog,progname,logtxt); + } + } +} + +/* remove invalid entries in the beam lists */ + +void RemInvalidBeams(int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS]) { + int i, j; + + for (i = NUMBEAMS - 1; i > 0; i--) { + if (ibeamsA[i] < 0) ibeamsA[i] = -1; + if (ibeamsA[i] > 15) ibeamsA[i] = -1; + + if (ibeamsB[i] < 0) ibeamsB[i] = -1; + if (ibeamsB[i] > 15) ibeamsB[i] = -1; + } + + for (i = NUMBEAMS - 1; i > 0; i--) { + + /* if the preceding element is -1 then move all the + following beams down + */ + + if ((ibeamsA[i - 1] == -1) && (ibeamsA[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsA[j - 1] = ibeamsA[j]; + ibeamsA[j] = -1; + } + } + + if ((ibeamsB[i - 1] == -1) && (ibeamsB[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsB[j - 1] = ibeamsB[j]; + ibeamsB[j] = -1; + } + } + } +} + +/* determine the number of beams */ + +void FindNumBeams(int *numbeamsA, int *numbeamsB, + int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS], + int print) { + int i; + char logtxt[256]; + + *numbeamsA = 0; + *numbeamsB = 0; + + /* count channel A beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsA[i] != -1) (*numbeamsA)++; + else break; + } + + /* count channel B beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsB[i] != -1) (*numbeamsB)++; + else break; + } + + if (print) { + sprintf(logtxt, "Beams A: %d Beams B: %d", *numbeamsA, *numbeamsB); + ErrLog(errlog, progname, logtxt); + + /* print frequency bands for each channel */ + + if (*numbeamsA > 0) { + ErrLog(errlog,progname,"Beams for channel A: "); + + for (i = 0; i < *numbeamsA; i++) { + sprintf(logtxt, "%1d ", ibeamsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if (*numbeamsB > 0) { + ErrLog(errlog,progname,"Beams for channel B: "); + for (i = 0; i < *numbeamsB; i++) { + sprintf(logtxt, "%1d ", ibeamsB[i]); + ErrLog(errlog,progname,logtxt); + } + } + } + + /* if no beams have been specified fill the arrays with normal sequence + between low_beam and high beam. + */ + + if (*numbeamsA == 0) { + if (backward) { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = high_beam_A - i; + (*numbeamsA)++; + } + } else { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = low_beam_A + i; + (*numbeamsA)++; + } + } + } + + if (*numbeamsB == 0) { + + if (backward) { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = high_beam_B - i; + (*numbeamsB)++; + } + } else { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = low_beam_B + i; + (*numbeamsB)++; + } + } + } +} + + + + diff --git a/qnx4/sd_leicester/han/nailedscan/version.info b/qnx4/sd_leicester/han/nailedscan/version.info new file mode 100644 index 0000000..78055df --- /dev/null +++ b/qnx4/sd_leicester/han/nailedscan/version.info @@ -0,0 +1,15 @@ +# $Log: version.info,v $ +# Revision 1.4 2007/08/09 14:10:26 code +# Added the ability to pass command line options as a file. +# +# Revision 1.3 2007/08/08 16:56:07 code +# Fixed bug in using hex notation for stid. +# +# Revision 1.2 2006/07/12 15:51:55 code +# Added call to set up command line and limited data written to rawacf and fitacf. +# +# Revision 1.1 2006/03/30 11:28:25 barnes +# Initial revision +# +# +nailedscan.c 1.04 diff --git a/qnx4/sd_leicester/han/normalscan.1.08/makefile b/qnx4/sd_leicester/han/normalscan.1.08/makefile new file mode 100644 index 0000000..39146e0 --- /dev/null +++ b/qnx4/sd_leicester/han/normalscan.1.08/makefile @@ -0,0 +1,44 @@ +# Makefile for tauscan +# ======================= +# by R.J.Barnes +# +# + + +INCLUDE=-I$(IPATH)/base -I$(IPATH)/general -I$(IPATH)/superdarn \ + -I$(IPATH)/radarqnx4 \ + -I$(USR_IPATH)/radarqnx4/ops \ + -I$(USR_IPATH)/radarqnx4/site.$(SD_RADARCODE) + +OBJS = normalscan.o +SRC=normalscan.c +IGNVER=1 +OUTPUT = $(USR_BINPATH)/normalscan +SUDO = 1 +LIBS=-lsite.${SD_RADARCODE}.1 -lops.1 -lfitacf.1 -lradar.1 -lerrlog.1 \ + -lrs.1 -lfreq.1 -lacf.1 -ltcpipmsg.1 -lrawfeed.1 -ltsg.1 \ + -ltaskid.1 -lrmsgsnd.1 -lrtimer.1 -lrtime.1 -lrmath.1 -lopt.1 +include $(SITELIB).${SD_RADARCODE} +include $(MAKEBIN) + + + + + + + + + + + + + + + + + + + + + + diff --git a/qnx4/sd_leicester/han/normalscan.1.08/makefile.bak b/qnx4/sd_leicester/han/normalscan.1.08/makefile.bak new file mode 100644 index 0000000..a61a7f9 --- /dev/null +++ b/qnx4/sd_leicester/han/normalscan.1.08/makefile.bak @@ -0,0 +1,48 @@ +# Makefile for tauscan +# ======================= +# by R.J.Barnes +# +# + + +INCLUDE=-I$(IPATH)/base -I$(IPATH)/general -I$(IPATH)/superdarn \ + -I$(IPATH)/radarqnx4 \ + -I$(USR_IPATH)/radarqnx4/ops \ + -I$(USR_IPATH)/radarqnx4/site.$(SD_RADARCODE) + +OBJS = normalscan.o +SRC=normalscan.c +IGNVER=1 +OUTPUT = $(USR_BINPATH)/normalscan +SUDO = 1 +LIBS=-lsite.${SD_RADARCODE}.1 -lops.1 -lfitacf.1 -lradar.1 -lerrlog.1 \ + -lfclr.1 -lfclrgc214.1 -lfclrs.1 \ + -lintegrate.1 -lintegrategc214.1 -lintegrategc214ex.1 \ + -lintegrates.1 -lrs.1 -lfreq.1 \ + -lacf.1 -lacfex.1 -lgc214.1 -lad.1 -ldio.1 \ + -ltcpipmsg.1 -lrawfeed.1 -ltsg.1 \ + -ltaskid.1 -lrmsgsnd.1 -lrtimer.1 -lrtime.1 -lrmath.1 -lopt.1 +SLIB=-lm +include $(MAKEBIN) + + + + + + + + + + + + + + + + + + + + + + diff --git a/qnx4/sd_leicester/han/normalscan.1.08/normalscan.c b/qnx4/sd_leicester/han/normalscan.1.08/normalscan.c new file mode 100644 index 0000000..c2430c0 --- /dev/null +++ b/qnx4/sd_leicester/han/normalscan.1.08/normalscan.c @@ -0,0 +1,394 @@ +/* normalscan.c + ============ + Author: R.J.Barnes +*/ + +/* + Copyright 2004 The Johns Hopkins University/Applied Physics Laboratory. + All rights reserved. + + This material may be used, modified, or reproduced by or for the U.S. + Government pursuant to the license rights granted under the clauses at DFARS + 252.227-7013/7014. + + For any other permissions, please contact the Space Department + Program Office at JHU/APL. + + This Distribution and Disclaimer Statement must be included in all copies of + "Radar Operating System - Control Programs" (hereinafter "the Program"). + + The Program was developed at The Johns Hopkins University/Applied Physics + Laboratory (JHU/APL) which is the author thereof under the "work made for + hire" provisions of the copyright law. + + JHU/APL assumes no obligation to provide support of any kind with regard to + the Program. This includes no obligation to provide assistance in using the + Program or to provide updated versions of the Program. + + THE PROGRAM AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT ANY EXPRESS + OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES INCLUDING, BUT NOT LIMITED + TO, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE + HEREBY DISCLAIMED. YOU ASSUME THE ENTIRE RISK AND LIABILITY OF USING THE + PROGRAM TO INCLUDE USE IN COMPLIANCE WITH ANY THIRD PARTY RIGHTS. YOU ARE + ADVISED TO TEST THE PROGRAM THOROUGHLY BEFORE RELYING ON IT. IN NO EVENT + SHALL JHU/APL BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING, WITHOUT + LIMITATION, ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR + CONSEQUENTIAL DAMAGES, ARISING OUT OF THE USE OR INABILITY TO USE THE + PROGRAM." + + + + + + +*/ + +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + + +#include "taskid.h" +#include "errlog.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raw.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: normalscan.c,v $ + Revision 1.8 2006/07/12 15:48:23 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.7 2006/02/07 20:55:06 barnes + Simon Shepherd's modification to the lag table. + + Revision 1.6 2006/02/07 17:50:17 barnes + Fixed bug in calling Errlog. + + Revision 1.5 2006/02/07 17:43:41 barnes + Dieter Andre's modification to make integration errors less mysterious. + + Revision 1.4 2005/08/01 18:18:47 barnes + Fixed incorrect command line option. + + Revision 1.3 2005/07/19 15:26:59 barnes + Added Dieter Andre's extra command line options. + + Revision 1.2 2004/07/23 15:48:27 barnes + Fixed bug in beam swinging direction. + + Revision 1.1 2004/05/11 17:43:22 barnes + Initial revision + +*/ + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + +char cmdlne[1024]; +char progid[80]={"$Id: normalscan.c,v 1.8 2006/07/12 15:48:23 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; + +int main(int argc,char *argv[]) { + + int ptab[8] = {0,14,22,24,27,31,42,43}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {42,43}, /* 1 */ + {22,24}, /* 2 */ + {24,27}, /* 3 */ + {27,31}, /* 4 */ + {22,27}, /* 5 */ + + {24,31}, /* 7 */ + {14,22}, /* 8 */ + {22,31}, /* 9 */ + {14,24}, /* 10 */ + {31,42}, /* 11 */ + {31,43}, /* 12 */ + {14,27}, /* 13 */ + { 0,14}, /* 14 */ + {27,42}, /* 15 */ + {27,43}, /* 16 */ + {14,31}, /* 17 */ + {24,42}, /* 18 */ + {24,43}, /* 19 */ + {22,42}, /* 20 */ + {22,43}, /* 21 */ + { 0,22}, /* 22 */ + + { 0,24}, /* 24 */ + + {43,43}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + int n; + pid_t sid; + int exitpoll=0; + + int scnsc=120; + int scnus=0; + int skip; + int cnt=0; + + unsigned char fast=0; + unsigned char discretion=0; + + strcpy(cmdlne,argv[0]); + for (n=1;n0) { + cnt++; + if (cnt==xcnt) { + xcf=1; + cnt=0; + } else xcf=0; + } else xcf=0; + + skip=OpsFindSkip(scnsc,scnus); + + if (backward) { + bmnum=sbm-skip; + if (bmnumebm) bmnum=sbm; + } + + do { + + TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); + + if (OpsDayNight()==1) { + stfrq=dfrq; + mpinc=dmpinc; + frang=dfrang; + } else { + stfrq=nfrq; + mpinc=nmpinc; + frang=nfrang; + } + + sprintf(logtxt,"Integrating beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum, + intsc,intus,hr,mt,sc,us); + ErrLog(errlog,progname,logtxt); + + ErrLog(errlog,progname,"Setting beam."); + + SiteSetIntt(intsc,intus); + SiteSetBeam(bmnum); + + ErrLog(errlog,progname,"Doing clear frequency search."); + + sprintf(logtxt, "FRQ: %d %d", stfrq, frqrng); + ErrLog( errlog, progname, logtxt); + + if (SiteFCLR(stfrq,stfrq+frqrng)==FREQ_LOCAL) + ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); + + SiteSetFreq(tfreq); + + sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); + + ErrLog(errlog,progname,logtxt); + + tsgid=SiteTimeSeq(ptab); + + nave=SiteIntegrate(lags); + if (nave<0) { + sprintf(logtxt,"Integration error:%d",nave); + ErrLog(errlog,progname,logtxt); + continue; + } + sprintf(logtxt,"Number of sequences: %d",nave); + ErrLog(errlog,progname,logtxt); + + + OpsBuildRaw(&prm,&raw,ptab,lags); + + FitACF(&prm,&raw,&fblk,&fit); + + ErrLog(errlog,progname,"Sending messages."); + + + msg.num=0; + msg.tsize=0; + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prm, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &raw, + RAW_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fit, + FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + + + for (n=0;n +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + + +#include "taskid.h" +#include "errlog.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raw.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: normalsound.c,v $ + Revision 2.5 2006/07/12 15:50:19 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 2.4 2006/04/13 18:14:36 barnes + Incorporated Dieter Andre's bug fix. + + Revision 2.3 2006/02/07 20:55:52 barnes + Simon Shepherd's modification to the lag table. + + Revision 2.2 2006/02/07 17:50:57 barnes + Added Dieter Andre's improved error logging. + + Revision 2.1 2005/07/19 18:43:54 barnes + First revision included in the ROS 1.08. + + + Revision 2.0 2004/03/23 andre + Initial revision from John Hughes program + +*/ + +/*======================================================================*/ +/* Program Description: */ +/* This version of normalsound runs under ROS 1.08 */ +/* If you want to run fastsound just run normalsound -fast */ +/* */ +/* normalsound performs a scan through all 16 beams at 6s or 3s */ +/* integration time. In the remaining time until the end of the minute */ +/* it performs scans through a set of up to 12 frequencies and through */ +/* all beams [even/odd]. This is used to determine the frequency which */ +/* gives the most ionospheric scatter from time to time [default 15min] */ +/* */ +/* The file $SD_HDWPATH/sounder.dat shoudl contain the following values */ +/* one per line: */ +/* Time between frequency evaluations [min] */ +/* Number of sounder frequencies */ +/* The sounder frequencies [kHz] */ +/* */ +/* If this file does not exist, default values are used. This is not a */ +/* good idea, as the program may try to sound at forbidden frequencies. */ +/* */ +/* The sounding data are writen to *.snd files, for each beam one */ +/* header and a data record for each good [qflg=1] range. */ +/* We have decided to do away with the internal compression, since we */ +/* feel, that zipping the files afterwards gives the same result. */ +/* */ +/* The information used to determine the optimal frequency is kept in */ +/* an internal circular buffer, that can hold 1 hour of data. This way */ +/* we avoid having to read the files each 15 minutes or so. */ +/* */ +/* At the moment the whole buffer is used to calculate for each beam */ +/* and each sounder frequency : */ +/* ( #total_returns - #groundscatter_returns)/ #ranges */ +/* These values are then averaged over all beams and if the maximum */ +/* gives a sufficient improvement over the presently used one, the */ +/* frequency is switched [ see find_optimal_freq for details] */ +/*======================================================================*/ + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + +char cmdlne[1024]; +char progid[80]={"$Id: normalsound.c,v 2.5 2006/07/12 15:50:19 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; + +/* used by cutlass radars */ +/* extern int lsfreq[], lfreq_range[]; */ + +/* Up to 1 hour of sounding data is stored in this structure */ + +/* 24* 30/ sounder_intt */ +#define NUM_SND_DATA 360 +#define SND_NRANG 75 +#define SND_NBM 16 +#define SND_NFBIN 26 +#define MAX_SND_FREQS 12 + +struct sounder_struct + { + double stime; + char program_name[40]; + int site_id; + int beam_num; + int freq; + int noise; + int frange; + int rsep; + float pwr[ SND_NRANG]; + float vel[ SND_NRANG]; + float width[ SND_NRANG]; + float AOA[ SND_NRANG]; + int gsct[ SND_NRANG]; + int qflg[ SND_NRANG]; + }; + + +int main(int argc,char *argv[]) { + + int ptab[8] = {0,14,22,24,27,31,42,43}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {42,43}, /* 1 */ + {22,24}, /* 2 */ + {24,27}, /* 3 */ + {27,31}, /* 4 */ + {22,27}, /* 5 */ + + {24,31}, /* 7 */ + {14,22}, /* 8 */ + {22,31}, /* 9 */ + {14,24}, /* 10 */ + {31,42}, /* 11 */ + {31,43}, /* 12 */ + {14,27}, /* 13 */ + { 0,14}, /* 14 */ + {27,42}, /* 15 */ + {27,43}, /* 16 */ + {14,31}, /* 17 */ + {24,42}, /* 18 */ + {24,43}, /* 19 */ + {22,42}, /* 20 */ + {22,43}, /* 21 */ + { 0,22}, /* 22 */ + + { 0,24}, /* 24 */ + + {43,43}}; /* alternate lag-0 */ + + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + int n; + pid_t sid; + int exitpoll=0; + + int scnsc=120; + int scnus=0; + int skip; + int cnt=0; + + unsigned char fast=0; + unsigned char discretion=0; + + /* Variables for sounding */ + char snd_filename[ 100]; + FILE *snd_dat; + /* If the file $SD_HDWPATH/sounder.dat exists, the next three parameters are read from it */ + /* the file contains one integer value per line */ + int freq_dwell=15; /* after so many minutes a new optimal frequency is evaluated */ + int sounder_freqs_total=8; + int sounder_freqs[ MAX_SND_FREQS]= { 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 0, 0, 0, 0 }; + time_t last_freq_search, t_now; + int fw=0; // frequency weighting flag used in selecting the optimal freq + int sounder_beams[]={0,2,4,6,8,10,12,14}; + int sounder_freq_count=0, sounder_beam_count=0; + int sounder_beams_total=8, odd_beams=0; + int sounder_freq; + int sounder_beam_loop=1; + int normal_intt=6; + int fast_intt=3; + int sounder_intt=2; + int do_new_freq_search=0; + float sounder_time, time_needed=1.25; + int cutlass=0; + struct sounder_struct *sounder_data; + int act_snd_rec= 0; + + sprintf( snd_filename,"%s/sounder.dat", getenv("SD_HDWPATH")); + snd_dat= fopen( snd_filename, "r"); + if( snd_dat != NULL ) { + fscanf( snd_dat, "%d", &freq_dwell); + fscanf( snd_dat, "%d", &sounder_freqs_total); + if (sounder_freqs_total > 12) sounder_freqs_total= 12; + for ( sounder_freq_count=0; sounder_freq_count < sounder_freqs_total; sounder_freq_count++ ) + fscanf( snd_dat, "%d", &sounder_freqs[ sounder_freq_count] ); + sounder_freq_count= 0; + fclose( snd_dat); + } + + + sounder_data= ( struct sounder_struct *) calloc( sizeof( struct sounder_struct), NUM_SND_DATA); + + strcpy(cmdlne,argv[0]); + for (n=1;n0) { + cnt++; + if (cnt==xcnt) { + xcf=1; + cnt=0; + } else xcf=0; + } else xcf=0; + + skip=OpsFindSkip(scnsc,scnus); + if (backward) { + bmnum=sbm-skip; + if (bmnumebm) bmnum=sbm; + } + + do { + TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); + if (OpsDayNight()==1) { + mpinc=dmpinc; + frang=dfrang; + } else { + mpinc=nmpinc; + frang=nfrang; + } + + sprintf(logtxt,"Integrating beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum, + intsc,intus,hr,mt,sc,us); + ErrLog(errlog,progname,logtxt); + ErrLog(errlog,progname,"Setting beam."); + SiteSetIntt(intsc,intus); + SiteSetBeam(bmnum); + + ErrLog(errlog,progname,"Doing clear frequency search."); + if (SiteFCLR(stfrq,stfrq+frqrng)==FREQ_LOCAL) + ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); + SiteSetFreq(tfreq); + + sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog,progname,logtxt); + tsgid=SiteTimeSeq(ptab); + nave=SiteIntegrate(lags); + if (nave < 0) { + sprintf( logtxt, "Integration error: %d", nave); + ErrLog(errlog,progname, logtxt); + continue; + } + sprintf(logtxt,"Number of sequences: %d",nave); + ErrLog(errlog,progname,logtxt); + + OpsBuildRaw(&prm,&raw,ptab,lags); + FitACF(&prm,&raw,&fblk,&fit); + + ErrLog(errlog,progname,"Sending messages."); + msg.num=0; + msg.tsize=0; + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prm, PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &raw, RAW_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fit, FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, NME_TYPE,0); + for (n=0;n0 && freq_dwell<=((t_now-last_freq_search)/60.) ); + /* set the "sounder mode" scan variable */ + scan=-2; + /* set the xcf variable to do cross-correlations (AOA) */ + xcf=1; + /* we have time until the end of the minute to do sounding */ + /* minus a safety factor given in time_needed */ + TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); + sounder_time= 60.0 - ( sc + us/ 1000000.0); + /* we do not implement to no sounding mode here */ + /* do a new frequency search if it's time */ + if( do_new_freq_search && sounder_time>=5 ) { + do_new_freq_search=0; + stfrq= find_optimal_freq( stfrq, cutlass, fw, sounder_freqs, sounder_freqs_total, sounder_data, act_snd_rec); + sprintf( logtxt,"New Opt Freq; %d\n", stfrq); + ErrLog( errlog, progname, logtxt); + last_freq_search= t_now; + } + sounder_beam_loop= ( sounder_time-(float)sounder_intt > time_needed ); + while( sounder_beam_loop ) { + intsc= sounder_intt; + /* set the beam */ + bmnum=sounder_beams[sounder_beam_count]+odd_beams; + /* sounder_freq will be an array of frequencies to step through */ + if( !cutlass ) + sounder_freq=sounder_freqs[sounder_freq_count]; +/* + else { + sounder_freq=lsfreq[sounder_freqs[sounder_freq_count]]; + frqrng=lfreq_range[sounder_freqs[sounder_freq_count]]; + } +*/ + /* the scanning code here */ + sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)", bmnum, intsc,intus,hr,mt,sc,us); + ErrLog(errlog,progname,logtxt); + ErrLog(errlog,progname,"Setting SND beam."); + SiteSetIntt(intsc,intus); + SiteSetBeam(bmnum); + ErrLog( errlog, progname, "Doing SND clear frequency search."); + if (SiteFCLR( sounder_freq, sounder_freq + frqrng)==FREQ_LOCAL) + ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); + SiteSetFreq(tfreq); +/* + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog( errlog, progname, logtxt); +*/ + tsgid= SiteTimeSeq(ptab); + nave= SiteIntegrate( lags); + if (nave < 0) { + sprintf( logtxt, "SND integration error: %d", nave); + ErrLog(errlog,progname, logtxt); + continue; + } + sprintf(logtxt,"Number of SND sequences: %d",nave); + ErrLog(errlog,progname,logtxt); + + OpsBuildRaw(&prm,&raw,ptab,lags); + FitACF(&prm,&raw,&fblk,&fit); + + ErrLog( errlog, progname, "Sending SND messages."); + msg.num= 0; + msg.tsize= 0; + RMsgSndAdd( &msg, sizeof(struct RadarParm), (unsigned char *) &prm, PRM_TYPE, 0); + RMsgSndAdd( &msg, sizeof(struct RawData), (unsigned char *) &raw, RAW_TYPE, 0); + RMsgSndAdd( &msg, sizeof(struct FitData), (unsigned char *) &fit, FIT_TYPE, 0); + RMsgSndAdd( &msg, strlen(progname)+1, progname, NME_TYPE, 0); + /* Only send these to echo_data; otherwise they get written to the data files */ + RMsgSndSend( tlist[ 0], &msg); + + sprintf( logtxt, "SBC: %d SFC: %d\n", sounder_beam_count, sounder_freq_count); + ErrLog( errlog, progname, logtxt); + /* save the sounding mode data */ + write_sounding_record_new( progname, &prm, &fit, sounder_data, &act_snd_rec); + + ErrLog( errlog, progname, "Polling SND for exit."); + exitpoll=RadarShell(sid,&rstable); + if (exitpoll !=0) break; + + /* check for the end of a beam loop */ + sounder_freq_count++; + if( sounder_freq_count >= sounder_freqs_total ) { + /* reset the freq counter and increment the beam counter */ + sounder_freq_count=0; + sounder_beam_count++; + if( sounder_beam_count>=sounder_beams_total ) { + sounder_beam_count=0; + if( odd_beams==0 ) + odd_beams=1; + else + odd_beams=0; + sounder_freq_count=0; + } + } + /* see if we have enough time for another go round */ + TimeReadClock( &yr, &mo, &dy, &hr, &mt, &sc, &us); + sounder_time= 60.0 - ( sc + us/ 1000000.0); + sounder_beam_loop= ( sounder_time-(float)sounder_intt > time_needed ); + } + /* now wait for the next normal_scan */ + intsc=normal_intt; + if ( fast) intsc= fast_intt; + OpsWaitBoundary(scnsc,scnus); + } + + } while (exitpoll==0); + SiteEnd(); + for (n=0;ntime.yr, prm->time.mo, prm->time.dy, (prm->time.hr/ 2)* 2, getenv("SD_RADARCODE")); + /* finally make the filename */ + sprintf( filename, "%s/%s.snd", data_path, data_filename); + + /* open the output file */ + out= fopen(filename,"a"); + if( out==NULL ) { + /* crap. might as well go home */ + return; + } + + /* make the header */ + /* initialize the unused values */ + //header.unused1=0x0FFE; + header.unused1= prm->atten; + header.unused2= 0x0FFE; + header.unused3= 0x0FFE; + data.unused1= 0x0FFE; + data.unused2= 0x0FFE; + data.unused3= 0xFE; + + header.stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + header.site_id= prm->stid; + header.beam_no= prm->bmnum; + header.freq= prm->tfreq; + header.noise= prm->noise.mean; + header.frange= prm->frang; + header.rsep= prm->rsep; + memcpy( header.program_name, progname, sizeof( header.program_name)); + /* zero out the gscat and qual bytes */ + for( i=0; i<10; i++ ) { + header.gsct[i]= 0; + header.qflg[i]= 0; + } + + /* now fill them in */ + byte= 0; + for( i=0; i< SND_NRANG; i++ ) { + byte=i/8; + if( fit->rng[i].gsct==1 ) header.gsct[byte]+=(0x01<<(i%8)); + if( fit->rng[i].qflg==1 ) { + header.qflg[byte]+= (0x01<<(i%8)); + good_ranges[i]=1; + } else { + good_ranges[i]=0; + } + } + + /* write out the header */ + fwrite( &header, sizeof( header), 1, out); + + /* scale the fit data into the char/shorts */ + for( i=0; i< SND_NRANG; i++ ) { + /* only do the good ranges */ + if( good_ranges[i] ) { + /* do the power */ + if( fit->rng[i].p_l < min_power ) data.pwr= 0; + else if ( fit->rng[i].p_l > max_power ) data.pwr= 255; + else data.pwr= 255* fit->rng[i].p_l/ (max_power - min_power); + /* do the AOA */ + if( fit->elv[i].normal < 0 ) data.AOA= 0; + else if( fit->elv[i].normal > 90.0 ) data.AOA= 65535; + else data.AOA= 65535* fit->elv[i].normal/ (max_AOA-min_AOA); + /* do the velocity */ + if( fit->rng[i].v < 0 ) { + if( fit->rng[i].v < min_vel ) data.vel=-32768; + else data.vel= -(32767/ min_vel)* fit->rng[i].v-1; + } else { + if( fit->rng[i].v > max_vel ) data.vel=32767; + else data.vel=(32767/ max_vel)* fit->rng[i].v; + } + /* do the width */ + if( fit->rng[i].w_l > max_width ) data.width= 65535; + else data.width= ( 65535/ max_width)* fit->rng[i].w_l; + /* write out the data structure */ + fwrite( &data, sizeof( data), 1, out); + } + } + fclose(out); + + + /* Fill the next sounder data record */ + act_snd_data= sounder_data + *act_snd_rec; + act_snd_data->stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + memcpy( act_snd_data->program_name, progname, sizeof(act_snd_data->program_name)); + act_snd_data->site_id= prm->stid; + act_snd_data->beam_num= prm->bmnum; + act_snd_data->freq= prm->tfreq; + act_snd_data->noise= prm->noise.mean; + act_snd_data->frange= prm->frang; + act_snd_data->rsep= prm->rsep; + for( i=0; i< SND_NRANG; i++ ) { + act_snd_data->pwr[ i]= fit->rng[ i].p_l; + act_snd_data->vel[ i]= fit->rng[ i].v; + act_snd_data->width[ i]= fit->rng[ i].w_l; + act_snd_data->AOA[ i]= fit->elv[ i].normal; + act_snd_data->gsct[ i]= fit->rng[ i].gsct; + act_snd_data->qflg[ i]= fit->rng[ i].qflg; + } + *act_snd_rec= *act_snd_rec + 1; + if ( *act_snd_rec >= NUM_SND_DATA) *act_snd_rec= 0; +} + +/********************** function write_sounding_record_new() ************************/ +/* changed the data structure */ + +void write_sounding_record_new( char *progname, struct RadarParm *prm, struct FitData *fit, struct sounder_struct *sounder_data, int *act_snd_rec) +{ + int i; + + struct header_struct + { + long int stime; + short int site_id; + short int beam_no; + short int freq; + short int noise; + short int frange; + short int rsep; + short int gsct[ SND_NRANG]; + short int qflg[ SND_NRANG]; + char program_name[40]; + } header; + + struct data_struct + { + short int pwr; + short int vel; + short int width; + short int AOA; + } data; + + //char data_path[]={"/data/snd/"}, data_filename[50], filename[80]; + char data_path[100], data_filename[50], filename[80]; + + + int good_ranges[ SND_NRANG]; + + char *snd_dir; + FILE *out; + + struct sounder_struct *act_snd_data; + + + /* set up the data directory */ + /* get the snd data dir */ + snd_dir= getenv("SD_SND_PATH"); + if( snd_dir==NULL ) + sprintf( data_path,"/data/snd/"); + else { + memcpy( data_path,snd_dir,strlen(snd_dir)); + data_path[ strlen( snd_dir)]= '/'; + data_path[ strlen( snd_dir) + 1]= 0; + } + + /* make up the filename */ + /* YYYYMMDDHH */ + sprintf( data_filename, "%04d%02d%02d%02d%s", prm->time.yr, prm->time.mo, prm->time.dy, (prm->time.hr/ 2)* 2, getenv("SD_RADARCODE")); + /* finally make the filename */ + sprintf( filename, "%s%s.snd", data_path, data_filename); + /* open the output file */ + out= fopen(filename,"a"); + if( out==NULL ) { + /* crap. might as well go home */ + return; + } + + /* make the header */ + + header.stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + header.site_id= prm->stid; + header.beam_no= prm->bmnum; + header.freq= prm->tfreq; + header.noise= prm->noise.mean; + header.frange= prm->frang; + header.rsep= prm->rsep; + memcpy( header.program_name, progname, sizeof( header.program_name)); + /* zero out the gscat and qual bytes */ + for( i=0; i< SND_NRANG; i++ ) { + header.gsct[i]= fit->rng[i].gsct; + header.qflg[i]= fit->rng[i].qflg; + good_ranges[ i]= ( fit->rng[i].qflg == 1); + } + + /* write out the header */ + fwrite( &header, sizeof( header), 1, out); + + /* scale the fit data into the char/shorts */ + for( i=0; i< SND_NRANG; i++ ) { + /* only do the good ranges */ + if( good_ranges[i] ) { + /* do the power */ + data.pwr= fit->rng[i].p_l; + /* do the velocity */ + data.vel= fit->rng[i].v; + /* do the AOA */ + data.AOA= fit->elv[i].normal; + /* do the width */ + data.width= fit->rng[i].w_l; + /* write out the data structure */ + fwrite( &data, sizeof( data), 1, out); + } + } + fclose(out); + + + /* Fill the next sounder data record */ + act_snd_data= sounder_data + *act_snd_rec; + act_snd_data->stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + memcpy( act_snd_data->program_name, progname, sizeof(act_snd_data->program_name)); + act_snd_data->site_id= prm->stid; + act_snd_data->beam_num= prm->bmnum; + act_snd_data->freq= prm->tfreq; + act_snd_data->noise= prm->noise.mean; + act_snd_data->frange= prm->frang; + act_snd_data->rsep= prm->rsep; + for( i=0; i< SND_NRANG; i++ ) { + act_snd_data->pwr[ i]= fit->rng[ i].p_l; + act_snd_data->vel[ i]= fit->rng[ i].v; + act_snd_data->width[ i]= fit->rng[ i].w_l; + act_snd_data->AOA[ i]= fit->elv[ i].normal; + act_snd_data->gsct[ i]= fit->rng[ i].gsct; + act_snd_data->qflg[ i]= fit->rng[ i].qflg; + } + *act_snd_rec= *act_snd_rec + 1; + if ( *act_snd_rec >= NUM_SND_DATA) *act_snd_rec= 0; +} + +/****************** function compute_scatter_percentage *************************/ +/* Mod: 20050315 */ +/* Use ths last ~15min sounder data to calculate the ionospheric scatter percentage */ +/* for each sounder frequency and in each beam */ +/* a lot more could be done, but for now we will keep it simple */ + +void compute_scatter_percentage( struct sounder_struct *sounder_data, int act_snd_rec, int sounder_freqs[], int sft, float iscat_percent[ MAX_SND_FREQS][ SND_NBM] ) +{ + struct sounder_struct *act_snd_data; + int isnd, jsnd, ifrq, i; + int returns=0, gscat_returns=0; + + for ( jsnd=0; jsnd< NUM_SND_DATA/ 4; jsnd++) { + isnd= act_snd_rec - jsnd; + if (isnd < 0) isnd= isnd + NUM_SND_DATA; + act_snd_data= sounder_data + isnd; + /* make sure this record has data */ + if (act_snd_data->stime > 0 ) { + returns=0; + gscat_returns=0; + for( i=0; i< SND_NRANG; i++ ) { + if( ( act_snd_data->qflg[i] == 1) && act_snd_data->pwr[i] >= 3.0 && act_snd_data->width[i] < 500.0 ) { + returns++; + if( act_snd_data->gsct[i] ) gscat_returns++; + } + } + for ( ifrq=0; ifrq< sft; ifrq++) { + if ( (act_snd_data->freq >= sounder_freqs[ ifrq]) && (act_snd_data->freq <= sounder_freqs[ ifrq] + frqrng) ) + break; + } + iscat_percent[ ifrq][act_snd_data->beam_num]= 100.0* (float)(returns - gscat_returns)/ SND_NRANG; + } + } +} + +/****************** function average_scatter_percentage *************************/ +/* what is fw good for ?? */ + +void average_scatter_percentages( float iscat_percent[ MAX_SND_FREQS][ SND_NBM], int sft, float average_iscat_percent[ MAX_SND_FREQS], int fw ) +{ +int ifrq, ibm; + + /* average the scatter percentages over all beams */ + for( ifrq=0; ifrq < sft; ifrq++ ) { + average_iscat_percent[ifrq]= 0.0; + for( ibm=0; ibm < SND_NBM; ibm++ ) + average_iscat_percent[ ifrq]+= iscat_percent[ ifrq][ ibm]; + average_iscat_percent[ ifrq]/= 16.0; + if( fw ) average_iscat_percent[ ifrq]*= ifrq; + } +} + +/******************* function find_optimal_freq_local() ************************/ +/* our frequency optimization scheme is this: */ +/* */ +/* at each frequency, find the most recent set of range data for each */ +/* beam. filter this data and then find the percentage of data points */ +/* that were ionospheric backscatter. to get the optimal frequency, */ +/* average over all beams at each frequency and look for the freq */ +/* with the highest percentage of ionsopheric backscatter. */ + +int find_optimal_freq(int start_freq, int cutlass, int fw, int sounder_freqs[], int sft, struct sounder_struct *sounder_data, int act_snd_rec) +{ + int i,j; + int def_freq, def_freq_bin; + /* array of iono scatter percentages (freq and beam number) */ + float iscat_percent[ MAX_SND_FREQS][ SND_NBM]; + float average_iscat_percent[ MAX_SND_FREQS]; + float max_scatter=-10; + int max_freq_bin=0; + int dlf; + FILE *out; + + + /* set the optimal freq to the sounder frequency closest to start_freq in case we don't find a good one; 20060308 DAndre */ + if( !cutlass ) { + dlf= 100000; + for ( i= 0; i < sft; i++) { + if ( fabs( start_freq - sounder_freqs[ i]) < dlf) { + dlf= fabs( start_freq - sounder_freqs[ i]); + def_freq_bin= i; + } + } + } +/* + else + def_freq_bin=lsfreq[def_freq]/1000; +*/ + + /* initialize the arrays */ + for( i=0; i= max_scatter ) { + max_scatter= average_iscat_percent[ i]; + max_freq_bin=i; + } + + /* set a threshold on the improvement */ + if( max_scatter < 1.15* average_iscat_percent[def_freq_bin] || ( max_scatter - average_iscat_percent[def_freq_bin]) < 0.75 ) + max_freq_bin=def_freq_bin; + + def_freq= sounder_freqs[ max_freq_bin]; + + out=fopen("/tmp/freq_search.out","w"); + if( out != NULL ) { + for( i= 0; i < sft; i++ ) { + if( !fw ) + fprintf(out,"\n%2d %d %10.7lf", i, sounder_freqs[ i], average_iscat_percent[i]); + else + fprintf(out,"\n%2d %d %10.7lf", i, sounder_freqs[ i], average_iscat_percent[i]/ i); + } + fprintf( out, "\nCutlass: %d",cutlass); + fprintf( out, "\nFreq Weighting: %d",fw); + fprintf( out, "\nReturned Frequency: %d kHz",def_freq); + fprintf( out, "\n"); + fclose(out); + } + + return(def_freq); +} + + + + + + diff --git a/qnx4/sd_leicester/han/normalsound.2.05/version.info b/qnx4/sd_leicester/han/normalsound.2.05/version.info new file mode 100644 index 0000000..13c5530 --- /dev/null +++ b/qnx4/sd_leicester/han/normalsound.2.05/version.info @@ -0,0 +1,19 @@ +#$Log: version.info,v $ +#Revision 2.5 2006/07/12 15:50:45 code +#Added call to set up command line and limited data written to rawacf and fitacf. +# +#Revision 2.4 2006/04/13 18:14:56 barnes +#Incorporated Dieter Andre's bug fix. +# +#Revision 2.3 2006/02/07 20:56:24 barnes +#Simon Shepherd's modification to the lag table. +# +#Revision 2.2 2006/02/07 17:51:13 barnes +#Added Dieter Andre's improved error logging. +# +#Revision 2.1 2005/07/19 18:45:06 barnes +#First revision included in the ROS 1.08. +# +# +normalsound.c 2.05 + diff --git a/qnx4/sd_leicester/han/pcpstereoscan.1.02/makefile b/qnx4/sd_leicester/han/pcpstereoscan.1.02/makefile new file mode 100644 index 0000000..094de25 --- /dev/null +++ b/qnx4/sd_leicester/han/pcpstereoscan.1.02/makefile @@ -0,0 +1,55 @@ +# Makefile for stereoscan +# ======================= +# by R.J.Barnes +# +# + + +INCLUDE=-I$(IPATH)/base -I$(IPATH)/general -I$(IPATH)/superdarn \ + -I$(IPATH)/radarqnx4 \ + -I$(USR_IPATH)/radarqnx4/ops \ + -I$(USR_IPATH)/radarqnx4/site.$(SD_RADARCODE) + +OBJS = pcpstereoscan.o +SRC=pcpstereoscan.c +IGNVER=1 +OUTPUT = $(USR_BINPATH)/pcpstereoscan +SUDO = 1 +LIBS=-lsite.${SD_RADARCODE}.1 -lops.1 -lfitacf.1 -lradar.1 -lerrlog.1 \ + -lrs.1 -lfreq.1 -lacf.1 -ltcpipmsg.1 -lrawfeed.1 -ltsg.1 \ + -ltaskid.1 -lrmsgsnd.1 -lrtimer.1 -lrtime.1 -lrmath.1 -lopt.1 + +include $(SITELIB).${SD_RADARCODE} + +ifdef STEREO +include $(MAKEBIN) +else +version: version.info $(SRC) + $(BINPATH)/rcsv -t version.info +clean: + rm -f *.o + rm -f $(OUTPUT) +endif + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qnx4/sd_leicester/han/pcpstereoscan.1.02/pcpstereoscan.c b/qnx4/sd_leicester/han/pcpstereoscan.1.02/pcpstereoscan.c new file mode 100644 index 0000000..96be6dd --- /dev/null +++ b/qnx4/sd_leicester/han/pcpstereoscan.1.02/pcpstereoscan.c @@ -0,0 +1,874 @@ +/* stereoscan.c + ============ + Author: R.J.Barnes +*/ + +/* + Copyright 2004 The Johns Hopkins University/Applied Physics Laboratory. + All rights reserved. + + This material may be used, modified, or reproduced by or for the U.S. + Government pursuant to the license rights granted under the clauses at DFARS + 252.227-7013/7014. + + For any other permissions, please contact the Space Department + Program Office at JHU/APL. + + This Distribution and Disclaimer Statement must be included in all copies of + "Radar Operating System - Control Programs" (hereinafter "the Program"). + + The Program was developed at The Johns Hopkins University/Applied Physics + Laboratory (JHU/APL) which is the author thereof under the "work made for + hire" provisions of the copyright law. + + JHU/APL assumes no obligation to provide support of any kind with regard to + the Program. This includes no obligation to provide assistance in using the + Program or to provide updated versions of the Program. + + THE PROGRAM AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT ANY EXPRESS + OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES INCLUDING, BUT NOT LIMITED + TO, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE + HEREBY DISCLAIMED. YOU ASSUME THE ENTIRE RISK AND LIABILITY OF USING THE + PROGRAM TO INCLUDE USE IN COMPLIANCE WITH ANY THIRD PARTY RIGHTS. YOU ARE + ADVISED TO TEST THE PROGRAM THOROUGHLY BEFORE RELYING ON IT. IN NO EVENT + SHALL JHU/APL BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING, WITHOUT + LIMITATION, ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR + CONSEQUENTIAL DAMAGES, ARISING OUT OF THE USE OR INABILITY TO USE THE + PROGRAM." + + + + + + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + +#include "taskid.h" +#include "errlog.h" +#include "freq.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "globals.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raws.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: pcpstereoscan.c,v $ + Revision 1.2 2006/07/12 15:51:43 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.1 2006/03/30 11:19:18 barnes + Initial revision + +*/ + +/* + Modified 10/12/2001 PH + + Added bnA and bnB frequency band options to cycle through frequency + bands during each scan. No check is made for invalid band numbers. + A band number of -1 is ignored. Bands can be added/removed at any + time using radar_shell, changes won't take effect until the end of + the current scan. If no band numbers are specified, normal day/night + frequencies are used. + + Frequency bands can also be specified for campA and campB modes. + + Extra options can be placed in a separate schedule file. The file + name should be the last argument in the schedule argument list and + should include the full path. + + Modified 16/01/02 PH + + Fixed synchronisation bug. The code wasn't subtracting the time taken + for a clear frequency search from the beam integration time, resulting + in an extended beam dwell time and a sweep lasting for more than 60 s + for fast stereo and 120 s for slow stereo 7 s integration. + + Standard slow stereo (normal stereo) is now 7 seconds (by Mark Lester). + + Modified 30/01/02 PH + + added -cts? options that pre-set other options + + dwell chan A cpidA chan B cpidB Ice/Fin offset range + ------ ------ ------ ------ ------ ------- ------ ----- + cts2 - 7 normal 152 tbj -26002 5 / 9 +400 45 + cts4 - 7 normal 152 normal -26004 5 / 9 +400 45 + cts6 - 7 normal 152 1 camp -26006 5 / 9 +400 45 + cts8 - 7 normal 152 2 camp -26008 5 / 9 +400 45 + + cts3 - 3 normal 153 tbj -26003 5 / 9 +400 45 + cts5 - 3 normal 153 normal -26005 5 / 9 +400 45 + cts7 - 3 normal 153 1 camp -26007 5 / 9 +400 45 + cts9 - 3 normal 153 2 camp -26009 5 / 9 +400 45 + + Single camp beams are hard coded to the standard Finland beam 9 and + Iceland beam 5. + + Double camp beams are the same for both radars and defined as + DOUBLE_CAMP_LOW and DOUBLE_CAMP_HIGH. + + range gates and first range are let to the default settings of 45km + and 180km respectively. + + specifying any cts option will override low and high beam, offset, cpIDs, + integration time and scan boundary. tbj mode overrides frequencies. + + Modified 05/04/02 PH + + Uses the new stereo aware version of fitacf (1.06). + + Modified 30/04/2002 PH + + Added cpidA and cpidB to set the cpid. This option overrides any + previously defined cpid. + + Added bmnA and bmnB to cycle through beams numbers on both channels. + To specify double camp beams use -bm0B 5 -bm1B 9 + To specify single camp beams use -bm0B 5 + The same beam number can be specified more than once. + The number of beams in the channel A beam list determines the number of + beams per scan. This is important if you are also using frequency lists. + + cts 2, 3, 4, 5 beams patterns can be changed with bm*A and bm*B options. + + Modified 25/09/02 PH + + Changed so that the B channel frequency band changes at the end of the + channel B scan, so that it is independent of the number of beams on + channel A. + + Modified 7th Dec 2001 to add camp beam flags + Modified 23 Nov 2001 to add new -ns and -fs flags and changed some defaults + Modified 10th Aug to account for backwards scanning radars + Modified 8th Aug fitacf_s + Julian modified version. March 2001 + +*/ + +/* set CPIDs for this experiment, 9212 is CPID provided by UAF for polar cap patch experiment + -26999 is dummy CPID for the non-existent channelB */ +#define CPID_A 9212 +#define CPID_B -26999 + + +#define INTT 3 +#define RSEP_A 15 +#define RSEP_B 15 +#define FRANG_A 180 +#define FRANG_B 180 + + +#define LOW_BEAM_A 0 +#define HIGH_BEAM_A 15 +#define LOW_BEAM_B 0 +#define HIGH_BEAM_B 15 + +#define SINGLE_CAMP_BEAM_PYK 5 +#define SINGLE_CAMP_BEAM_HAN 9 + + +#define DOUBLE_CAMP_LOW 5 +#define DOUBLE_CAMP_HIGH 9 + +#define UCONT_NAME "ucont_moni" + +#define CHN_A 0 +#define CHN_B 1 + +#define NUMBANDS 10 +#define NUMBEAMS 16 + + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + +#define PCPBEAM 9 +#define PCPFNUM 8 +int pcpfreqs[PCPFNUM]; +int pcpcnt; + +void u_read_uconts(void); +void u_init_freq_bands(void); + +char cmdlne[1024]; +char progid[80]={"$Id: pcpstereoscan.c,v 1.2 2011/12/13 15:51:43 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +int usfreq[42]; +int ufreq_range[42]; + +pid_t uucont_proxy; + +int low_beam_A=LOW_BEAM_A; +int high_beam_A=HIGH_BEAM_A; +int low_beam_B=LOW_BEAM_B; +int high_beam_B=HIGH_BEAM_B; + + + + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; + +int main(int argc,char *argv[]) { + + int ptab[7] = {0,9,12,20,22,26,27}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {26,27}, /* 1 */ + {20,22}, /* 2 */ + {9,12}, /* 3 */ + {22,26}, /* 4 */ + {22,27}, /* 5 */ + + {20,26}, /* 7 */ + {20,27}, /* 8 */ + {0,9}, /* 9 */ + {12,22}, /* 10 */ + {9,20}, /* 11 */ + {0,12}, /* 12 */ + {9,22}, /* 13 */ + {12,26}, /* 14 */ + {12,27}, /* 15 */ + {9,26}, /* 16 */ + {9,27}, /* 17 */ + {27,27}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + char a[10]; + + int n,i; + pid_t sid; + int exitpoll=0; + + int scnsc=0; + int scnus=0; + + unsigned char ns=0; + unsigned char fs=0; + + int stereo_offset=400; /* channel A delayed by this + number of microseconds */ + + + int ifreqsA[NUMBANDS],ifreqsB[NUMBANDS]; + + int day_nightA=1; + int day_nightB=1; + + int numfreqbandsA; + int numfreqbandsB; + + int ifreqsA_index=0; + int ifreqsB_index=0; + + int ifreqsAband; + int ifreqsBband; + + int sbm, ebm, bmnm[16], bmcnt; + + int numbeamsA,numbeamsB; + + unsigned char cts2=0,cts4=0,cts6=0,cts8=0; + unsigned char cts3=0,cts5=0,cts7=0,cts9=0; + + int cpidA=0,cpidB=0; + + xcfA=xcfB=1; + + cpA=CPID_A; + cpB=CPID_B; + + SiteStart(); + + intsc=INTT; + intus=0; + + maxattenA=maxattenB=7; + + if ((uucont_proxy=SiteInitProxy(UCONT_NAME))==-1) { + perror("cannot attach proxy"); + } + + u_init_freq_bands(); + + strcpy(cmdlne,argv[0]); + for (n=1;n 15 + 3) if high and low beams were specified = low_beam -> high_beam + */ + + sprintf(progname,"pcpstereoscan"); +printf("** 3\n"); + + OpsFitACFStart(); + + OpsSetupTask(tasklist); + for (n=0;n=0;bmcnt--){ + bmnm[bmcnt]=15-bmcnt; + } + } + else{ + for(bmcnt=0;bmcnt<=15;bmcnt++){ + bmnm[bmcnt]=bmcnt; + } + } +printf("** 4\n"); + + /* Set up the array of frequency indices to use for sounding */ + if(stid==0x09){ + pcpfreqs[0]=20; + pcpfreqs[1]=22; + pcpfreqs[2]=23; + pcpfreqs[3]=26; + pcpfreqs[4]=30; + pcpfreqs[5]=32; + pcpfreqs[6]=33; + pcpfreqs[7]=35; + }else if (stid==0x10){ + pcpfreqs[0]=0; + pcpfreqs[1]=1; + pcpfreqs[2]=2; + pcpfreqs[3]=4; + pcpfreqs[4]=6; + pcpfreqs[5]=7; + pcpfreqs[6]=8; + pcpfreqs[7]=10; + } +printf("** 5\n"); + + /* set the number of range gates to 225 */ + nrangA=225; + nrangB=225; + /* set range seperation to 15km */ + rsepA=15; + rsepB=15; + + /* scan loop */ + do { + /* 3 second integrations during the scan */ + intsc=3; + intus=0; +printf("** 6\n"); + if (SiteStartScan()==0) continue; + if (OpsReOpen(2,0,0) !=0) { + ErrLog(errlog,progname,"Opening new files."); +printf("** 7\n"); + for (n=0;ndfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; +printf("** 13\n"); + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d %5d - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, tfreqB, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + ErrLog(errlog,progname,logtxt); + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + msg.num=0; + msg.tsize=0; + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + for (n=0;n 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + scanA = 0; + scanB = 0; + + } + + /* increment individual frequency band index. Doesn't matter whether + individual frequency bands are being used for this channel or not. + */ + /************ Sounding at end of scan ******************************/ + + scanA=-2; + scanB=-2; + /* set sounding integration time to 1 second */ + intsc=1; + intus=0; + /* step through array of 8 frequencies */ + for(pcpcnt=0;pcpcntdfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; + + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d %5d - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, tfreqB, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + ErrLog(errlog,progname,logtxt); + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + msg.num=0; + msg.tsize=0; + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + for (n=0;n 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + + + } + scanA = 0; + scanB = 0; + + /************ Sounding at end of scan ******************************/ + + ErrLog(errlog,progname,"Waiting for scan boundary."); + if ((scnsc !=0) || (scnus !=0)) { + if (exitpoll==0) OpsWaitBoundary(scnsc,scnus); + } + } while (exitpoll==0); + SiteEnd(); + for (n=0;n +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + +#include "taskid.h" +#include "errlog.h" +#include "freq.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "globals.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raws.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: pcpstereoscan.c,v $ + Revision 1.2 2006/07/12 15:51:43 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.1 2006/03/30 11:19:18 barnes + Initial revision + +*/ + +/* + Modified 10/12/2001 PH + + Added bnA and bnB frequency band options to cycle through frequency + bands during each scan. No check is made for invalid band numbers. + A band number of -1 is ignored. Bands can be added/removed at any + time using radar_shell, changes won't take effect until the end of + the current scan. If no band numbers are specified, normal day/night + frequencies are used. + + Frequency bands can also be specified for campA and campB modes. + + Extra options can be placed in a separate schedule file. The file + name should be the last argument in the schedule argument list and + should include the full path. + + Modified 16/01/02 PH + + Fixed synchronisation bug. The code wasn't subtracting the time taken + for a clear frequency search from the beam integration time, resulting + in an extended beam dwell time and a sweep lasting for more than 60 s + for fast stereo and 120 s for slow stereo 7 s integration. + + Standard slow stereo (normal stereo) is now 7 seconds (by Mark Lester). + + Modified 30/01/02 PH + + added -cts? options that pre-set other options + + dwell chan A cpidA chan B cpidB Ice/Fin offset range + ------ ------ ------ ------ ------ ------- ------ ----- + cts2 - 7 normal 152 tbj -26002 5 / 9 +400 45 + cts4 - 7 normal 152 normal -26004 5 / 9 +400 45 + cts6 - 7 normal 152 1 camp -26006 5 / 9 +400 45 + cts8 - 7 normal 152 2 camp -26008 5 / 9 +400 45 + + cts3 - 3 normal 153 tbj -26003 5 / 9 +400 45 + cts5 - 3 normal 153 normal -26005 5 / 9 +400 45 + cts7 - 3 normal 153 1 camp -26007 5 / 9 +400 45 + cts9 - 3 normal 153 2 camp -26009 5 / 9 +400 45 + + Single camp beams are hard coded to the standard Finland beam 9 and + Iceland beam 5. + + Double camp beams are the same for both radars and defined as + DOUBLE_CAMP_LOW and DOUBLE_CAMP_HIGH. + + range gates and first range are let to the default settings of 45km + and 180km respectively. + + specifying any cts option will override low and high beam, offset, cpIDs, + integration time and scan boundary. tbj mode overrides frequencies. + + Modified 05/04/02 PH + + Uses the new stereo aware version of fitacf (1.06). + + Modified 30/04/2002 PH + + Added cpidA and cpidB to set the cpid. This option overrides any + previously defined cpid. + + Added bmnA and bmnB to cycle through beams numbers on both channels. + To specify double camp beams use -bm0B 5 -bm1B 9 + To specify single camp beams use -bm0B 5 + The same beam number can be specified more than once. + The number of beams in the channel A beam list determines the number of + beams per scan. This is important if you are also using frequency lists. + + cts 2, 3, 4, 5 beams patterns can be changed with bm*A and bm*B options. + + Modified 25/09/02 PH + + Changed so that the B channel frequency band changes at the end of the + channel B scan, so that it is independent of the number of beams on + channel A. + + Modified 7th Dec 2001 to add camp beam flags + Modified 23 Nov 2001 to add new -ns and -fs flags and changed some defaults + Modified 10th Aug to account for backwards scanning radars + Modified 8th Aug fitacf_s + Julian modified version. March 2001 + +*/ + +/* set CPIDs for this experiment, 9212 is CPID provided by UAF for polar cap patch experiment + -26999 is dummy CPID for the non-existent channelB */ +#define CPID_A 9212 +#define CPID_B -26999 + + +#define INTT 3 +#define RSEP_A 15 +#define RSEP_B 15 +#define FRANG_A 180 +#define FRANG_B 180 + + +#define LOW_BEAM_A 0 +#define HIGH_BEAM_A 15 +#define LOW_BEAM_B 0 +#define HIGH_BEAM_B 15 + +#define SINGLE_CAMP_BEAM_PYK 5 +#define SINGLE_CAMP_BEAM_HAN 9 + + +#define DOUBLE_CAMP_LOW 5 +#define DOUBLE_CAMP_HIGH 9 + +#define UCONT_NAME "ucont_moni" + +#define CHN_A 0 +#define CHN_B 1 + +#define NUMBANDS 10 +#define NUMBEAMS 16 + + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + +#define PCPBEAM 9 +#define PCPFNUM 8 +int pcpfreqs[PCPFNUM]; +int pcpcnt; + +void u_read_uconts(void); +void u_init_freq_bands(void); + +char cmdlne[1024]; +char progid[80]={"$Id: pcpstereoscan.c,v 1.2 2011/12/13 15:51:43 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +int usfreq[42]; +int ufreq_range[42]; + +pid_t uucont_proxy; + +int low_beam_A=LOW_BEAM_A; +int high_beam_A=HIGH_BEAM_A; +int low_beam_B=LOW_BEAM_B; +int high_beam_B=HIGH_BEAM_B; + + + + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; + +int main(int argc,char *argv[]) { + + int ptab[7] = {0,9,12,20,22,26,27}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {26,27}, /* 1 */ + {20,22}, /* 2 */ + {9,12}, /* 3 */ + {22,26}, /* 4 */ + {22,27}, /* 5 */ + + {20,26}, /* 7 */ + {20,27}, /* 8 */ + {0,9}, /* 9 */ + {12,22}, /* 10 */ + {9,20}, /* 11 */ + {0,12}, /* 12 */ + {9,22}, /* 13 */ + {12,26}, /* 14 */ + {12,27}, /* 15 */ + {9,26}, /* 16 */ + {9,27}, /* 17 */ + {27,27}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + char a[10]; + + int n,i; + pid_t sid; + int exitpoll=0; + + int scnsc=0; + int scnus=0; + + unsigned char ns=0; + unsigned char fs=0; + + int stereo_offset=400; /* channel A delayed by this + number of microseconds */ + + + int ifreqsA[NUMBANDS],ifreqsB[NUMBANDS]; + + int day_nightA=1; + int day_nightB=1; + + int numfreqbandsA; + int numfreqbandsB; + + int ifreqsA_index=0; + int ifreqsB_index=0; + + int ifreqsAband; + int ifreqsBband; + + int sbm, ebm, bmnm[16], bmcnt; + + int numbeamsA,numbeamsB; + + unsigned char cts2=0,cts4=0,cts6=0,cts8=0; + unsigned char cts3=0,cts5=0,cts7=0,cts9=0; + + int cpidA=0,cpidB=0; + + xcfA=xcfB=1; + + cpA=CPID_A; + cpB=CPID_B; + + SiteStart(); + + intsc=INTT; + intus=0; + + maxattenA=maxattenB=7; + + if ((uucont_proxy=SiteInitProxy(UCONT_NAME))==-1) { + perror("cannot attach proxy"); + } + + u_init_freq_bands(); + + strcpy(cmdlne,argv[0]); + for (n=1;n 15 + 3) if high and low beams were specified = low_beam -> high_beam + */ + + sprintf(progname,"pcpstereoscan"); + + OpsFitACFStart(); + + OpsSetupTask(tasklist); + for (n=0;n=0;bmcnt--){ + bmnm[bmcnt]=15-bmcnt; + } + } + else{ + for(bmcnt=0;bmcnt<=15;bmcnt++){ + bmnm[bmcnt]=bmcnt; + } + } + /* Set up the array of frequency indices to use for sounding */ + if(stid==0x09){ + pcpfreqs[0]=20; + pcpfreqs[1]=22; + pcpfreqs[2]=23; + pcpfreqs[3]=26; + pcpfreqs[4]=30; + pcpfreqs[5]=32; + pcpfreqs[6]=33; + pcpfreqs[7]=35; + }else if (stid==0x10){ + pcpfreqs[0]=0; + pcpfreqs[1]=1; + pcpfreqs[2]=2; + pcpfreqs[3]=4; + pcpfreqs[4]=6; + pcpfreqs[5]=7; + pcpfreqs[6]=8; + pcpfreqs[7]=10; + } + /* set the number of range gates to 225 */ + nrangA=225; + nrangB=225; + /* set range seperation to 15km */ + rsepA=15; + rsepB=15; + + /* scan loop */ + do { + /* 3 second integrations during the scan */ + intsc=3; + intus=0; + if (SiteStartScan()==0) continue; + if (OpsReOpen(2,0,0) !=0) { + ErrLog(errlog,progname,"Opening new files."); + for (n=0;ndfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; + + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d %5d - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, tfreqB, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + ErrLog(errlog,progname,logtxt); + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + msg.num=0; + msg.tsize=0; + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + for (n=0;n 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + scanA = 0; + scanB = 0; + + } + + /* increment individual frequency band index. Doesn't matter whether + individual frequency bands are being used for this channel or not. + */ + /************ Sounding at end of scan ******************************/ + + scanA=-2; + scanB=-2; + /* set sounding integration time to 1 second */ + intsc=1; + intus=0; + /* step through array of 8 frequencies */ + for(pcpcnt=0;pcpcntdfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; + + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d %5d - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, tfreqB, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + ErrLog(errlog,progname,logtxt); + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + msg.num=0; + msg.tsize=0; + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + for (n=0;n 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + + + } + scanA = 0; + scanB = 0; + + /************ Sounding at end of scan ******************************/ + + ErrLog(errlog,progname,"Waiting for scan boundary."); + if ((scnsc !=0) || (scnus !=0)) { + if (exitpoll==0) OpsWaitBoundary(scnsc,scnus); + } + } while (exitpoll==0); + SiteEnd(); + for (n=0;n +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + +#include "taskid.h" +#include "errlog.h" +#include "freq.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "globals.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raws.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: stereoscan.c,v $ + Revision 1.4 2007/08/09 14:09:51 code + Allowed command lines to be passed as a file. + + Revision 1.3 2007/08/08 16:55:44 code + Fixed bug in using hex notation for stid. + + Revision 1.2 2006/07/12 15:51:43 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.1 2006/03/30 11:19:18 barnes + Initial revision + +*/ + +/* + Modified 10/12/2001 PH + + Added bnA and bnB frequency band options to cycle through frequency + bands during each scan. No check is made for invalid band numbers. + A band number of -1 is ignored. Bands can be added/removed at any + time using radar_shell, changes won't take effect until the end of + the current scan. If no band numbers are specified, normal day/night + frequencies are used. + + Frequency bands can also be specified for campA and campB modes. + + Extra options can be placed in a separate schedule file. The file + name should be the last argument in the schedule argument list and + should include the full path. + + Modified 16/01/02 PH + + Fixed synchronisation bug. The code wasn't subtracting the time taken + for a clear frequency search from the beam integration time, resulting + in an extended beam dwell time and a sweep lasting for more than 60 s + for fast stereo and 120 s for slow stereo 7 s integration. + + Standard slow stereo (normal stereo) is now 7 seconds (by Mark Lester). + + Modified 30/01/02 PH + + added -cts? options that pre-set other options + + dwell chan A cpidA chan B cpidB Ice/Fin offset range + ------ ------ ------ ------ ------ ------- ------ ----- + cts2 - 7 normal 152 tbj -26002 5 / 9 +400 45 + cts4 - 7 normal 152 normal -26004 5 / 9 +400 45 + cts6 - 7 normal 152 1 camp -26006 5 / 9 +400 45 + cts8 - 7 normal 152 2 camp -26008 5 / 9 +400 45 + + cts3 - 3 normal 153 tbj -26003 5 / 9 +400 45 + cts5 - 3 normal 153 normal -26005 5 / 9 +400 45 + cts7 - 3 normal 153 1 camp -26007 5 / 9 +400 45 + cts9 - 3 normal 153 2 camp -26009 5 / 9 +400 45 + + Single camp beams are hard coded to the standard Finland beam 9 and + Iceland beam 5. + + Double camp beams are the same for both radars and defined as + DOUBLE_CAMP_LOW and DOUBLE_CAMP_HIGH. + + range gates and first range are let to the default settings of 45km + and 180km respectively. + + specifying any cts option will override low and high beam, offset, cpIDs, + integration time and scan boundary. tbj mode overrides frequencies. + + Modified 05/04/02 PH + + Uses the new stereo aware version of fitacf (1.06). + + Modified 30/04/2002 PH + + Added cpidA and cpidB to set the cpid. This option overrides any + previously defined cpid. + + Added bmnA and bmnB to cycle through beams numbers on both channels. + To specify double camp beams use -bm0B 5 -bm1B 9 + To specify single camp beams use -bm0B 5 + The same beam number can be specified more than once. + The number of beams in the channel A beam list determines the number of + beams per scan. This is important if you are also using frequency lists. + + cts 2, 3, 4, 5 beams patterns can be changed with bm*A and bm*B options. + + Modified 25/09/02 PH + + Changed so that the B channel frequency band changes at the end of the + channel B scan, so that it is independent of the number of beams on + channel A. + + Modified 7th Dec 2001 to add camp beam flags + Modified 23 Nov 2001 to add new -ns and -fs flags and changed some defaults + Modified 10th Aug to account for backwards scanning radars + Modified 8th Aug fitacf_s + Julian modified version. March 2001 + +*/ + +#define CPID_A -6401 +#define CPID_B -26401 +#define CPID_NS 152 +#define CPID_FS 153 + + +#define INTT 7 +#define RSEP_A 45 +#define RSEP_B 45 +#define FRANG_A 180 +#define FRANG_B 180 + + +#define LOW_BEAM_A 0 +#define HIGH_BEAM_A 15 +#define LOW_BEAM_B 0 +#define HIGH_BEAM_B 15 + +#define SINGLE_CAMP_BEAM_PYK 5 +#define SINGLE_CAMP_BEAM_HAN 9 + + +#define DOUBLE_CAMP_LOW 5 +#define DOUBLE_CAMP_HIGH 9 + +#define UCONT_NAME "ucont_moni" + +#define CHN_A 0 +#define CHN_B 1 + +#define NUMBANDS 10 +#define NUMBEAMS 16 + + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + + + +void u_read_uconts(void); +void u_init_freq_bands(void); + +void RemInvalidEntries(int ifreqsA[], int ifreqsB[]); +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, int *day_nightA, int *day_nightB, int ifreqsA[], int ifreqsB[], int print); +void RemInvalidBeams(int ibeamsA[], int ibeamsB[]); +void FindNumBeams(int *numbeamsA, int *numbeamsB, int ibeamsA[], int ibeamsB[], int print); + +char cmdlne[1024]; +char progid[80]={"$Id: stereoscan.c,v 1.4 2007/08/09 14:09:51 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +int usfreq[42]; +int ufreq_range[42]; + +pid_t uucont_proxy; + +int low_beam_A=LOW_BEAM_A; +int high_beam_A=HIGH_BEAM_A; +int low_beam_B=LOW_BEAM_B; +int high_beam_B=HIGH_BEAM_B; + + + + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; +struct OptionFile *optf=NULL; + +int main(int argc,char *argv[]) { + + int ptab[7] = {0,9,12,20,22,26,27}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {26,27}, /* 1 */ + {20,22}, /* 2 */ + {9,12}, /* 3 */ + {22,26}, /* 4 */ + {22,27}, /* 5 */ + + {20,26}, /* 7 */ + {20,27}, /* 8 */ + {0,9}, /* 9 */ + {12,22}, /* 10 */ + {9,20}, /* 11 */ + {0,12}, /* 12 */ + {9,22}, /* 13 */ + {12,26}, /* 14 */ + {12,27}, /* 15 */ + {9,26}, /* 16 */ + {9,27}, /* 17 */ + {27,27}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + char a[10]; + + int n,i; + pid_t sid; + int exitpoll=0; + + int scnsc=0; + int scnus=0; + + unsigned char ns=0; + unsigned char fs=0; + + int stereo_offset=400; /* channel A delayed by this + number of microseconds */ + + + int ifreqsA[NUMBANDS],ifreqsB[NUMBANDS]; + + int ibeamsA[NUMBEAMS],ibeamsB[NUMBEAMS]; + + int day_nightA=1; + int day_nightB=1; + + int numfreqbandsA; + int numfreqbandsB; + + int ifreqsA_index=0; + int ifreqsB_index=0; + + int ifreqsAband; + int ifreqsBband; + + int numbeamsA,numbeamsB; + + int ibeamsA_index=0; + int ibeamsB_index=0; + + unsigned char cts2=0,cts4=0,cts6=0,cts8=0; + unsigned char cts3=0,cts5=0,cts7=0,cts9=0; + + int cpidA=0,cpidB=0; + + for (i=0;iargc,optf->argv,&opt,NULL); + OptionFreeFile(optf); + } + fclose(fp); + } + } + + if (sname==NULL) sname=sdname; + if (ename==NULL) ename=edname; + + sid=RShellRegister(sname,CONTROL_NAME); + + errlog=TaskIDMake(ename); + OpsLogStart(errlog,progname,argc,argv); + + /* handle CTs */ + + if ((cts2) || (cts4) || (cts6) || (cts8)) { + cpA = 152; + intsc = 7; + intus = 0; + stereo_offset = 400; + scnsc = 120; + scnus = 0; + + /* tbj mode */ + + if (cts2) { + cpB = -26002; + if (stid==9) { + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } + } + + /* normal scan */ + + if (cts4) cpB = -26004; + + /* single camp beam */ + + if (cts6) { + cpB = -26006; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts8) { + cpB = -26008; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else if ((cts3) || (cts5) || (cts7) || (cts9)) { + cpA = 153; + intsc = 3; + stereo_offset = 400; + scnsc = 60.0; + scnus = 0.0; + + /* tbj */ + + if (cts3) { + cpB = -26003; + + if (stid==9) { + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } + } + + /* normal scan */ + + if (cts5) cpB = -26005; + + + /* single camp beam */ + + if (cts7) { + cpB = -26007; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts9) { + cpB = -26009; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else + /* check for normal scan emulation */ + if (ns) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 7; + intus = 0; + scnsc = 120.0; + scnus = 0.0; + cpA = CPID_NS; + } else + /* check for fast scan emulation */ + if (fs) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 3; + intus = 0; + scnsc = 60.0; + scnus = 0.0; + cpA = CPID_FS; + } + + /* set cpid for channel A */ + + if (cpidA) { + cpA = cpidA; + cpB = -1 * abs(cpidA) - 20000; + } + + /* set cpid for channel B */ + + if (cpidB) cpB = cpidB; + + /* Calculate delay offsets + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* remember stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + mppulA = mppulB = 7; + mplgsA = mplgsB = 18; + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + /* just a dummy frequency */ + + tfreqA = 13500; + tfreqB = 14500; + + SiteSetupHardware(); + + /* remove invalid entries in the frequency band lists */ + + RemInvalidEntries(ifreqsA, ifreqsB); + + /* determine the number of frequency bands */ + + FindNumBands(&numfreqbandsA, &numfreqbandsB, + &day_nightA, &day_nightB, ifreqsA, ifreqsB, 1); + + /* check beams */ + + if (low_beam_A < LOW_BEAM_A) low_beam_A = LOW_BEAM_A; + if (high_beam_A > HIGH_BEAM_A) high_beam_A = HIGH_BEAM_A; + + if (low_beam_B < LOW_BEAM_B) low_beam_B = LOW_BEAM_B; + if (high_beam_B > HIGH_BEAM_B) high_beam_B = HIGH_BEAM_B; + + /* end beams in the wrong order */ + + if (low_beam_A > high_beam_A) { + int beam = high_beam_A; + high_beam_A = low_beam_A; + low_beam_A = beam; + } + + if (low_beam_B > high_beam_B) { + int beam = high_beam_B; + high_beam_B = low_beam_B; + low_beam_B = beam; + } + + /* sort beam lists */ + + RemInvalidBeams(ibeamsA, ibeamsB); + FindNumBeams(&numbeamsA, &numbeamsB, ibeamsA, ibeamsB, 1); + + /* + the beam lists now contain: + 1) the number of beams in the beam lists + 2) if no beam list or camp beams were specified = 0 -> 15 + 3) if high and low beams were specified = low_beam -> high_beam + */ + + sprintf(progname,"stereoscan"); + + OpsFitACFStart(); + + OpsSetupTask(tasklist); + for (n=0;ndfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; + + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d (%02d) %5d (%02d) - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, ifreqsAband, tfreqB, ifreqsBband, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + + ErrLog(errlog,progname,logtxt); + + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + + + msg.num=0; + msg.tsize=0; + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + + + for (n=0;n= numfreqbandsA) ifreqsA_index = 0; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + + /* Calculate delay offsets if stereo offset has been changed + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + scanA = 0; + scanB = 0; + + /* change beam number index */ + + ibeamsB_index++; + + if (ibeamsB_index >= numbeamsB) ibeamsB_index = 0; + + /* change band at the end of channel B scan */ + + if (ibeamsB_index == 0) { + if (numfreqbandsB != 0) { + ifreqsB_index++; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + } + } + } + + /* increment individual frequency band index. Doesn't matter whether + individual frequency bands are being used for this channel or not. + */ + + if (numfreqbandsA != 0) { + ifreqsA_index++; + if (ifreqsA_index >= numfreqbandsA) ifreqsA_index = 0; + } + + ErrLog(errlog,progname,"Waiting for scan boundary."); + if ((scnsc !=0) || (scnus !=0)) { + if (exitpoll==0) OpsWaitBoundary(scnsc,scnus); + } + } while (exitpoll==0); + SiteEnd(); + for (n=0;n 0; i--) { + + /* if the preceding element is -1 then move all the following + bands down + */ + + if ((ifreqsA[i] != -1) && (ifreqsA[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsA[j - 1] = ifreqsA[j]; + ifreqsA[j] = -1; + } + } + + if ((ifreqsB[i] != -1) && (ifreqsB[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsB[j - 1] = ifreqsB[j]; + ifreqsB[j] = -1; + } + } + } +} + +/* determine the number of frequency bands */ + +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, + int *day_nightA, int *day_nightB, + int ifreqsA[NUMBANDS], int ifreqsB[NUMBANDS], + int print) { + int i; + char logtxt[256]; + + *numfreqbandsA = 0; + *numfreqbandsB = 0; + + for (i = 0; i < NUMBANDS; i++) { + if (ifreqsA[i] != -1) (*numfreqbandsA)++; + if (ifreqsB[i] != -1) (*numfreqbandsB)++; + } + + /* check to see if day/night frequencies are to be used */ + + if (*numfreqbandsA != 0) *day_nightA = 0; + else *day_nightA = 1; + + if (*numfreqbandsB != 0) *day_nightB = 0; + else *day_nightB = 1; + + if (print) { + sprintf(logtxt, "Channel A: %d Channel B: %d", *numfreqbandsA, + *numfreqbandsB); + ErrLog(errlog, progname, logtxt); + } + + /* print frequency bands for each channel */ + + if ((*numfreqbandsA > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel A: "); + + for (i = 0; i < *numfreqbandsA; i++) { + sprintf(logtxt, "%1d ", ifreqsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if ((*numfreqbandsB > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel B: "); + + for (i = 0; i < *numfreqbandsB; i++) { + sprintf(logtxt, "%1d ", ifreqsB[i]); + ErrLog(errlog,progname,logtxt); + } + } +} + +/* remove invalid entries in the beam lists */ + +void RemInvalidBeams(int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS]) { + int i, j; + + for (i = NUMBEAMS - 1; i > 0; i--) { + if (ibeamsA[i] < 0) ibeamsA[i] = -1; + if (ibeamsA[i] > 15) ibeamsA[i] = -1; + + if (ibeamsB[i] < 0) ibeamsB[i] = -1; + if (ibeamsB[i] > 15) ibeamsB[i] = -1; + } + + for (i = NUMBEAMS - 1; i > 0; i--) { + + /* if the preceding element is -1 then move all the + following beams down + */ + + if ((ibeamsA[i - 1] == -1) && (ibeamsA[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsA[j - 1] = ibeamsA[j]; + ibeamsA[j] = -1; + } + } + + if ((ibeamsB[i - 1] == -1) && (ibeamsB[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsB[j - 1] = ibeamsB[j]; + ibeamsB[j] = -1; + } + } + } +} + +/* determine the number of beams */ + +void FindNumBeams(int *numbeamsA, int *numbeamsB, + int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS], + int print) { + int i; + char logtxt[256]; + + *numbeamsA = 0; + *numbeamsB = 0; + + /* count channel A beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsA[i] != -1) (*numbeamsA)++; + else break; + } + + /* count channel B beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsB[i] != -1) (*numbeamsB)++; + else break; + } + + if (print) { + sprintf(logtxt, "Beams A: %d Beams B: %d", *numbeamsA, *numbeamsB); + ErrLog(errlog, progname, logtxt); + + /* print frequency bands for each channel */ + + if (*numbeamsA > 0) { + ErrLog(errlog,progname,"Beams for channel A: "); + + for (i = 0; i < *numbeamsA; i++) { + sprintf(logtxt, "%1d ", ibeamsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if (*numbeamsB > 0) { + ErrLog(errlog,progname,"Beams for channel B: "); + for (i = 0; i < *numbeamsB; i++) { + sprintf(logtxt, "%1d ", ibeamsB[i]); + ErrLog(errlog,progname,logtxt); + } + } + } + + /* if no beams have been specified fill the arrays with normal sequence + between low_beam and high beam. + */ + + if (*numbeamsA == 0) { + if (backward) { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = high_beam_A - i; + (*numbeamsA)++; + } + } else { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = low_beam_A + i; + (*numbeamsA)++; + } + } + } + + if (*numbeamsB == 0) { + + if (backward) { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = high_beam_B - i; + (*numbeamsB)++; + } + } else { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = low_beam_B + i; + (*numbeamsB)++; + } + } + } +} + + + + diff --git a/qnx4/sd_leicester/han/stereoscan.1.04/version.info b/qnx4/sd_leicester/han/stereoscan.1.04/version.info new file mode 100644 index 0000000..cc48e31 --- /dev/null +++ b/qnx4/sd_leicester/han/stereoscan.1.04/version.info @@ -0,0 +1,15 @@ +# $Log: version.info,v $ +# Revision 1.4 2007/08/09 14:10:26 code +# Added the ability to pass command line options as a file. +# +# Revision 1.3 2007/08/08 16:56:07 code +# Fixed bug in using hex notation for stid. +# +# Revision 1.2 2006/07/12 15:51:55 code +# Added call to set up command line and limited data written to rawacf and fitacf. +# +# Revision 1.1 2006/03/30 11:28:25 barnes +# Initial revision +# +# +stereoscan.c 1.04 diff --git a/qnx4/sd_leicester/pyk/normalscan.1.08/makefile b/qnx4/sd_leicester/pyk/normalscan.1.08/makefile new file mode 100644 index 0000000..39146e0 --- /dev/null +++ b/qnx4/sd_leicester/pyk/normalscan.1.08/makefile @@ -0,0 +1,44 @@ +# Makefile for tauscan +# ======================= +# by R.J.Barnes +# +# + + +INCLUDE=-I$(IPATH)/base -I$(IPATH)/general -I$(IPATH)/superdarn \ + -I$(IPATH)/radarqnx4 \ + -I$(USR_IPATH)/radarqnx4/ops \ + -I$(USR_IPATH)/radarqnx4/site.$(SD_RADARCODE) + +OBJS = normalscan.o +SRC=normalscan.c +IGNVER=1 +OUTPUT = $(USR_BINPATH)/normalscan +SUDO = 1 +LIBS=-lsite.${SD_RADARCODE}.1 -lops.1 -lfitacf.1 -lradar.1 -lerrlog.1 \ + -lrs.1 -lfreq.1 -lacf.1 -ltcpipmsg.1 -lrawfeed.1 -ltsg.1 \ + -ltaskid.1 -lrmsgsnd.1 -lrtimer.1 -lrtime.1 -lrmath.1 -lopt.1 +include $(SITELIB).${SD_RADARCODE} +include $(MAKEBIN) + + + + + + + + + + + + + + + + + + + + + + diff --git a/qnx4/sd_leicester/pyk/normalscan.1.08/makefile.bak b/qnx4/sd_leicester/pyk/normalscan.1.08/makefile.bak new file mode 100644 index 0000000..a61a7f9 --- /dev/null +++ b/qnx4/sd_leicester/pyk/normalscan.1.08/makefile.bak @@ -0,0 +1,48 @@ +# Makefile for tauscan +# ======================= +# by R.J.Barnes +# +# + + +INCLUDE=-I$(IPATH)/base -I$(IPATH)/general -I$(IPATH)/superdarn \ + -I$(IPATH)/radarqnx4 \ + -I$(USR_IPATH)/radarqnx4/ops \ + -I$(USR_IPATH)/radarqnx4/site.$(SD_RADARCODE) + +OBJS = normalscan.o +SRC=normalscan.c +IGNVER=1 +OUTPUT = $(USR_BINPATH)/normalscan +SUDO = 1 +LIBS=-lsite.${SD_RADARCODE}.1 -lops.1 -lfitacf.1 -lradar.1 -lerrlog.1 \ + -lfclr.1 -lfclrgc214.1 -lfclrs.1 \ + -lintegrate.1 -lintegrategc214.1 -lintegrategc214ex.1 \ + -lintegrates.1 -lrs.1 -lfreq.1 \ + -lacf.1 -lacfex.1 -lgc214.1 -lad.1 -ldio.1 \ + -ltcpipmsg.1 -lrawfeed.1 -ltsg.1 \ + -ltaskid.1 -lrmsgsnd.1 -lrtimer.1 -lrtime.1 -lrmath.1 -lopt.1 +SLIB=-lm +include $(MAKEBIN) + + + + + + + + + + + + + + + + + + + + + + diff --git a/qnx4/sd_leicester/pyk/normalscan.1.08/normalscan.c b/qnx4/sd_leicester/pyk/normalscan.1.08/normalscan.c new file mode 100644 index 0000000..c2430c0 --- /dev/null +++ b/qnx4/sd_leicester/pyk/normalscan.1.08/normalscan.c @@ -0,0 +1,394 @@ +/* normalscan.c + ============ + Author: R.J.Barnes +*/ + +/* + Copyright 2004 The Johns Hopkins University/Applied Physics Laboratory. + All rights reserved. + + This material may be used, modified, or reproduced by or for the U.S. + Government pursuant to the license rights granted under the clauses at DFARS + 252.227-7013/7014. + + For any other permissions, please contact the Space Department + Program Office at JHU/APL. + + This Distribution and Disclaimer Statement must be included in all copies of + "Radar Operating System - Control Programs" (hereinafter "the Program"). + + The Program was developed at The Johns Hopkins University/Applied Physics + Laboratory (JHU/APL) which is the author thereof under the "work made for + hire" provisions of the copyright law. + + JHU/APL assumes no obligation to provide support of any kind with regard to + the Program. This includes no obligation to provide assistance in using the + Program or to provide updated versions of the Program. + + THE PROGRAM AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT ANY EXPRESS + OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES INCLUDING, BUT NOT LIMITED + TO, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE + HEREBY DISCLAIMED. YOU ASSUME THE ENTIRE RISK AND LIABILITY OF USING THE + PROGRAM TO INCLUDE USE IN COMPLIANCE WITH ANY THIRD PARTY RIGHTS. YOU ARE + ADVISED TO TEST THE PROGRAM THOROUGHLY BEFORE RELYING ON IT. IN NO EVENT + SHALL JHU/APL BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING, WITHOUT + LIMITATION, ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR + CONSEQUENTIAL DAMAGES, ARISING OUT OF THE USE OR INABILITY TO USE THE + PROGRAM." + + + + + + +*/ + +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + + +#include "taskid.h" +#include "errlog.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raw.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: normalscan.c,v $ + Revision 1.8 2006/07/12 15:48:23 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.7 2006/02/07 20:55:06 barnes + Simon Shepherd's modification to the lag table. + + Revision 1.6 2006/02/07 17:50:17 barnes + Fixed bug in calling Errlog. + + Revision 1.5 2006/02/07 17:43:41 barnes + Dieter Andre's modification to make integration errors less mysterious. + + Revision 1.4 2005/08/01 18:18:47 barnes + Fixed incorrect command line option. + + Revision 1.3 2005/07/19 15:26:59 barnes + Added Dieter Andre's extra command line options. + + Revision 1.2 2004/07/23 15:48:27 barnes + Fixed bug in beam swinging direction. + + Revision 1.1 2004/05/11 17:43:22 barnes + Initial revision + +*/ + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + +char cmdlne[1024]; +char progid[80]={"$Id: normalscan.c,v 1.8 2006/07/12 15:48:23 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; + +int main(int argc,char *argv[]) { + + int ptab[8] = {0,14,22,24,27,31,42,43}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {42,43}, /* 1 */ + {22,24}, /* 2 */ + {24,27}, /* 3 */ + {27,31}, /* 4 */ + {22,27}, /* 5 */ + + {24,31}, /* 7 */ + {14,22}, /* 8 */ + {22,31}, /* 9 */ + {14,24}, /* 10 */ + {31,42}, /* 11 */ + {31,43}, /* 12 */ + {14,27}, /* 13 */ + { 0,14}, /* 14 */ + {27,42}, /* 15 */ + {27,43}, /* 16 */ + {14,31}, /* 17 */ + {24,42}, /* 18 */ + {24,43}, /* 19 */ + {22,42}, /* 20 */ + {22,43}, /* 21 */ + { 0,22}, /* 22 */ + + { 0,24}, /* 24 */ + + {43,43}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + int n; + pid_t sid; + int exitpoll=0; + + int scnsc=120; + int scnus=0; + int skip; + int cnt=0; + + unsigned char fast=0; + unsigned char discretion=0; + + strcpy(cmdlne,argv[0]); + for (n=1;n0) { + cnt++; + if (cnt==xcnt) { + xcf=1; + cnt=0; + } else xcf=0; + } else xcf=0; + + skip=OpsFindSkip(scnsc,scnus); + + if (backward) { + bmnum=sbm-skip; + if (bmnumebm) bmnum=sbm; + } + + do { + + TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); + + if (OpsDayNight()==1) { + stfrq=dfrq; + mpinc=dmpinc; + frang=dfrang; + } else { + stfrq=nfrq; + mpinc=nmpinc; + frang=nfrang; + } + + sprintf(logtxt,"Integrating beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum, + intsc,intus,hr,mt,sc,us); + ErrLog(errlog,progname,logtxt); + + ErrLog(errlog,progname,"Setting beam."); + + SiteSetIntt(intsc,intus); + SiteSetBeam(bmnum); + + ErrLog(errlog,progname,"Doing clear frequency search."); + + sprintf(logtxt, "FRQ: %d %d", stfrq, frqrng); + ErrLog( errlog, progname, logtxt); + + if (SiteFCLR(stfrq,stfrq+frqrng)==FREQ_LOCAL) + ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); + + SiteSetFreq(tfreq); + + sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); + + ErrLog(errlog,progname,logtxt); + + tsgid=SiteTimeSeq(ptab); + + nave=SiteIntegrate(lags); + if (nave<0) { + sprintf(logtxt,"Integration error:%d",nave); + ErrLog(errlog,progname,logtxt); + continue; + } + sprintf(logtxt,"Number of sequences: %d",nave); + ErrLog(errlog,progname,logtxt); + + + OpsBuildRaw(&prm,&raw,ptab,lags); + + FitACF(&prm,&raw,&fblk,&fit); + + ErrLog(errlog,progname,"Sending messages."); + + + msg.num=0; + msg.tsize=0; + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prm, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &raw, + RAW_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fit, + FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + + + for (n=0;n +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + + +#include "taskid.h" +#include "errlog.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raw.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: normalsound.c,v $ + Revision 2.5 2006/07/12 15:50:19 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 2.4 2006/04/13 18:14:36 barnes + Incorporated Dieter Andre's bug fix. + + Revision 2.3 2006/02/07 20:55:52 barnes + Simon Shepherd's modification to the lag table. + + Revision 2.2 2006/02/07 17:50:57 barnes + Added Dieter Andre's improved error logging. + + Revision 2.1 2005/07/19 18:43:54 barnes + First revision included in the ROS 1.08. + + + Revision 2.0 2004/03/23 andre + Initial revision from John Hughes program + +*/ + +/*======================================================================*/ +/* Program Description: */ +/* This version of normalsound runs under ROS 1.08 */ +/* If you want to run fastsound just run normalsound -fast */ +/* */ +/* normalsound performs a scan through all 16 beams at 6s or 3s */ +/* integration time. In the remaining time until the end of the minute */ +/* it performs scans through a set of up to 12 frequencies and through */ +/* all beams [even/odd]. This is used to determine the frequency which */ +/* gives the most ionospheric scatter from time to time [default 15min] */ +/* */ +/* The file $SD_HDWPATH/sounder.dat shoudl contain the following values */ +/* one per line: */ +/* Time between frequency evaluations [min] */ +/* Number of sounder frequencies */ +/* The sounder frequencies [kHz] */ +/* */ +/* If this file does not exist, default values are used. This is not a */ +/* good idea, as the program may try to sound at forbidden frequencies. */ +/* */ +/* The sounding data are writen to *.snd files, for each beam one */ +/* header and a data record for each good [qflg=1] range. */ +/* We have decided to do away with the internal compression, since we */ +/* feel, that zipping the files afterwards gives the same result. */ +/* */ +/* The information used to determine the optimal frequency is kept in */ +/* an internal circular buffer, that can hold 1 hour of data. This way */ +/* we avoid having to read the files each 15 minutes or so. */ +/* */ +/* At the moment the whole buffer is used to calculate for each beam */ +/* and each sounder frequency : */ +/* ( #total_returns - #groundscatter_returns)/ #ranges */ +/* These values are then averaged over all beams and if the maximum */ +/* gives a sufficient improvement over the presently used one, the */ +/* frequency is switched [ see find_optimal_freq for details] */ +/*======================================================================*/ + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + +char cmdlne[1024]; +char progid[80]={"$Id: normalsound.c,v 2.5 2006/07/12 15:50:19 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; + +/* used by cutlass radars */ +/* extern int lsfreq[], lfreq_range[]; */ + +/* Up to 1 hour of sounding data is stored in this structure */ + +/* 24* 30/ sounder_intt */ +#define NUM_SND_DATA 360 +#define SND_NRANG 75 +#define SND_NBM 16 +#define SND_NFBIN 26 +#define MAX_SND_FREQS 12 + +struct sounder_struct + { + double stime; + char program_name[40]; + int site_id; + int beam_num; + int freq; + int noise; + int frange; + int rsep; + float pwr[ SND_NRANG]; + float vel[ SND_NRANG]; + float width[ SND_NRANG]; + float AOA[ SND_NRANG]; + int gsct[ SND_NRANG]; + int qflg[ SND_NRANG]; + }; + + +int main(int argc,char *argv[]) { + + int ptab[8] = {0,14,22,24,27,31,42,43}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {42,43}, /* 1 */ + {22,24}, /* 2 */ + {24,27}, /* 3 */ + {27,31}, /* 4 */ + {22,27}, /* 5 */ + + {24,31}, /* 7 */ + {14,22}, /* 8 */ + {22,31}, /* 9 */ + {14,24}, /* 10 */ + {31,42}, /* 11 */ + {31,43}, /* 12 */ + {14,27}, /* 13 */ + { 0,14}, /* 14 */ + {27,42}, /* 15 */ + {27,43}, /* 16 */ + {14,31}, /* 17 */ + {24,42}, /* 18 */ + {24,43}, /* 19 */ + {22,42}, /* 20 */ + {22,43}, /* 21 */ + { 0,22}, /* 22 */ + + { 0,24}, /* 24 */ + + {43,43}}; /* alternate lag-0 */ + + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + int n; + pid_t sid; + int exitpoll=0; + + int scnsc=120; + int scnus=0; + int skip; + int cnt=0; + + unsigned char fast=0; + unsigned char discretion=0; + + /* Variables for sounding */ + char snd_filename[ 100]; + FILE *snd_dat; + /* If the file $SD_HDWPATH/sounder.dat exists, the next three parameters are read from it */ + /* the file contains one integer value per line */ + int freq_dwell=15; /* after so many minutes a new optimal frequency is evaluated */ + int sounder_freqs_total=8; + int sounder_freqs[ MAX_SND_FREQS]= { 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 0, 0, 0, 0 }; + time_t last_freq_search, t_now; + int fw=0; // frequency weighting flag used in selecting the optimal freq + int sounder_beams[]={0,2,4,6,8,10,12,14}; + int sounder_freq_count=0, sounder_beam_count=0; + int sounder_beams_total=8, odd_beams=0; + int sounder_freq; + int sounder_beam_loop=1; + int normal_intt=6; + int fast_intt=3; + int sounder_intt=2; + int do_new_freq_search=0; + float sounder_time, time_needed=1.25; + int cutlass=0; + struct sounder_struct *sounder_data; + int act_snd_rec= 0; + + sprintf( snd_filename,"%s/sounder.dat", getenv("SD_HDWPATH")); + snd_dat= fopen( snd_filename, "r"); + if( snd_dat != NULL ) { + fscanf( snd_dat, "%d", &freq_dwell); + fscanf( snd_dat, "%d", &sounder_freqs_total); + if (sounder_freqs_total > 12) sounder_freqs_total= 12; + for ( sounder_freq_count=0; sounder_freq_count < sounder_freqs_total; sounder_freq_count++ ) + fscanf( snd_dat, "%d", &sounder_freqs[ sounder_freq_count] ); + sounder_freq_count= 0; + fclose( snd_dat); + } + + + sounder_data= ( struct sounder_struct *) calloc( sizeof( struct sounder_struct), NUM_SND_DATA); + + strcpy(cmdlne,argv[0]); + for (n=1;n0) { + cnt++; + if (cnt==xcnt) { + xcf=1; + cnt=0; + } else xcf=0; + } else xcf=0; + + skip=OpsFindSkip(scnsc,scnus); + if (backward) { + bmnum=sbm-skip; + if (bmnumebm) bmnum=sbm; + } + + do { + TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); + if (OpsDayNight()==1) { + mpinc=dmpinc; + frang=dfrang; + } else { + mpinc=nmpinc; + frang=nfrang; + } + + sprintf(logtxt,"Integrating beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum, + intsc,intus,hr,mt,sc,us); + ErrLog(errlog,progname,logtxt); + ErrLog(errlog,progname,"Setting beam."); + SiteSetIntt(intsc,intus); + SiteSetBeam(bmnum); + + ErrLog(errlog,progname,"Doing clear frequency search."); + if (SiteFCLR(stfrq,stfrq+frqrng)==FREQ_LOCAL) + ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); + SiteSetFreq(tfreq); + + sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog,progname,logtxt); + tsgid=SiteTimeSeq(ptab); + nave=SiteIntegrate(lags); + if (nave < 0) { + sprintf( logtxt, "Integration error: %d", nave); + ErrLog(errlog,progname, logtxt); + continue; + } + sprintf(logtxt,"Number of sequences: %d",nave); + ErrLog(errlog,progname,logtxt); + + OpsBuildRaw(&prm,&raw,ptab,lags); + FitACF(&prm,&raw,&fblk,&fit); + + ErrLog(errlog,progname,"Sending messages."); + msg.num=0; + msg.tsize=0; + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prm, PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &raw, RAW_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fit, FIT_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,progname, NME_TYPE,0); + for (n=0;n0 && freq_dwell<=((t_now-last_freq_search)/60.) ); + /* set the "sounder mode" scan variable */ + scan=-2; + /* set the xcf variable to do cross-correlations (AOA) */ + xcf=1; + /* we have time until the end of the minute to do sounding */ + /* minus a safety factor given in time_needed */ + TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); + sounder_time= 60.0 - ( sc + us/ 1000000.0); + /* we do not implement to no sounding mode here */ + /* do a new frequency search if it's time */ + if( do_new_freq_search && sounder_time>=5 ) { + do_new_freq_search=0; + stfrq= find_optimal_freq( stfrq, cutlass, fw, sounder_freqs, sounder_freqs_total, sounder_data, act_snd_rec); + sprintf( logtxt,"New Opt Freq; %d\n", stfrq); + ErrLog( errlog, progname, logtxt); + last_freq_search= t_now; + } + sounder_beam_loop= ( sounder_time-(float)sounder_intt > time_needed ); + while( sounder_beam_loop ) { + intsc= sounder_intt; + /* set the beam */ + bmnum=sounder_beams[sounder_beam_count]+odd_beams; + /* sounder_freq will be an array of frequencies to step through */ + if( !cutlass ) + sounder_freq=sounder_freqs[sounder_freq_count]; +/* + else { + sounder_freq=lsfreq[sounder_freqs[sounder_freq_count]]; + frqrng=lfreq_range[sounder_freqs[sounder_freq_count]]; + } +*/ + /* the scanning code here */ + sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)", bmnum, intsc,intus,hr,mt,sc,us); + ErrLog(errlog,progname,logtxt); + ErrLog(errlog,progname,"Setting SND beam."); + SiteSetIntt(intsc,intus); + SiteSetBeam(bmnum); + ErrLog( errlog, progname, "Doing SND clear frequency search."); + if (SiteFCLR( sounder_freq, sounder_freq + frqrng)==FREQ_LOCAL) + ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); + SiteSetFreq(tfreq); +/* + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog( errlog, progname, logtxt); +*/ + tsgid= SiteTimeSeq(ptab); + nave= SiteIntegrate( lags); + if (nave < 0) { + sprintf( logtxt, "SND integration error: %d", nave); + ErrLog(errlog,progname, logtxt); + continue; + } + sprintf(logtxt,"Number of SND sequences: %d",nave); + ErrLog(errlog,progname,logtxt); + + OpsBuildRaw(&prm,&raw,ptab,lags); + FitACF(&prm,&raw,&fblk,&fit); + + ErrLog( errlog, progname, "Sending SND messages."); + msg.num= 0; + msg.tsize= 0; + RMsgSndAdd( &msg, sizeof(struct RadarParm), (unsigned char *) &prm, PRM_TYPE, 0); + RMsgSndAdd( &msg, sizeof(struct RawData), (unsigned char *) &raw, RAW_TYPE, 0); + RMsgSndAdd( &msg, sizeof(struct FitData), (unsigned char *) &fit, FIT_TYPE, 0); + RMsgSndAdd( &msg, strlen(progname)+1, progname, NME_TYPE, 0); + /* Only send these to echo_data; otherwise they get written to the data files */ + RMsgSndSend( tlist[ 0], &msg); + + sprintf( logtxt, "SBC: %d SFC: %d\n", sounder_beam_count, sounder_freq_count); + ErrLog( errlog, progname, logtxt); + /* save the sounding mode data */ + write_sounding_record_new( progname, &prm, &fit, sounder_data, &act_snd_rec); + + ErrLog( errlog, progname, "Polling SND for exit."); + exitpoll=RadarShell(sid,&rstable); + if (exitpoll !=0) break; + + /* check for the end of a beam loop */ + sounder_freq_count++; + if( sounder_freq_count >= sounder_freqs_total ) { + /* reset the freq counter and increment the beam counter */ + sounder_freq_count=0; + sounder_beam_count++; + if( sounder_beam_count>=sounder_beams_total ) { + sounder_beam_count=0; + if( odd_beams==0 ) + odd_beams=1; + else + odd_beams=0; + sounder_freq_count=0; + } + } + /* see if we have enough time for another go round */ + TimeReadClock( &yr, &mo, &dy, &hr, &mt, &sc, &us); + sounder_time= 60.0 - ( sc + us/ 1000000.0); + sounder_beam_loop= ( sounder_time-(float)sounder_intt > time_needed ); + } + /* now wait for the next normal_scan */ + intsc=normal_intt; + if ( fast) intsc= fast_intt; + OpsWaitBoundary(scnsc,scnus); + } + + } while (exitpoll==0); + SiteEnd(); + for (n=0;ntime.yr, prm->time.mo, prm->time.dy, (prm->time.hr/ 2)* 2, getenv("SD_RADARCODE")); + /* finally make the filename */ + sprintf( filename, "%s/%s.snd", data_path, data_filename); + + /* open the output file */ + out= fopen(filename,"a"); + if( out==NULL ) { + /* crap. might as well go home */ + return; + } + + /* make the header */ + /* initialize the unused values */ + //header.unused1=0x0FFE; + header.unused1= prm->atten; + header.unused2= 0x0FFE; + header.unused3= 0x0FFE; + data.unused1= 0x0FFE; + data.unused2= 0x0FFE; + data.unused3= 0xFE; + + header.stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + header.site_id= prm->stid; + header.beam_no= prm->bmnum; + header.freq= prm->tfreq; + header.noise= prm->noise.mean; + header.frange= prm->frang; + header.rsep= prm->rsep; + memcpy( header.program_name, progname, sizeof( header.program_name)); + /* zero out the gscat and qual bytes */ + for( i=0; i<10; i++ ) { + header.gsct[i]= 0; + header.qflg[i]= 0; + } + + /* now fill them in */ + byte= 0; + for( i=0; i< SND_NRANG; i++ ) { + byte=i/8; + if( fit->rng[i].gsct==1 ) header.gsct[byte]+=(0x01<<(i%8)); + if( fit->rng[i].qflg==1 ) { + header.qflg[byte]+= (0x01<<(i%8)); + good_ranges[i]=1; + } else { + good_ranges[i]=0; + } + } + + /* write out the header */ + fwrite( &header, sizeof( header), 1, out); + + /* scale the fit data into the char/shorts */ + for( i=0; i< SND_NRANG; i++ ) { + /* only do the good ranges */ + if( good_ranges[i] ) { + /* do the power */ + if( fit->rng[i].p_l < min_power ) data.pwr= 0; + else if ( fit->rng[i].p_l > max_power ) data.pwr= 255; + else data.pwr= 255* fit->rng[i].p_l/ (max_power - min_power); + /* do the AOA */ + if( fit->elv[i].normal < 0 ) data.AOA= 0; + else if( fit->elv[i].normal > 90.0 ) data.AOA= 65535; + else data.AOA= 65535* fit->elv[i].normal/ (max_AOA-min_AOA); + /* do the velocity */ + if( fit->rng[i].v < 0 ) { + if( fit->rng[i].v < min_vel ) data.vel=-32768; + else data.vel= -(32767/ min_vel)* fit->rng[i].v-1; + } else { + if( fit->rng[i].v > max_vel ) data.vel=32767; + else data.vel=(32767/ max_vel)* fit->rng[i].v; + } + /* do the width */ + if( fit->rng[i].w_l > max_width ) data.width= 65535; + else data.width= ( 65535/ max_width)* fit->rng[i].w_l; + /* write out the data structure */ + fwrite( &data, sizeof( data), 1, out); + } + } + fclose(out); + + + /* Fill the next sounder data record */ + act_snd_data= sounder_data + *act_snd_rec; + act_snd_data->stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + memcpy( act_snd_data->program_name, progname, sizeof(act_snd_data->program_name)); + act_snd_data->site_id= prm->stid; + act_snd_data->beam_num= prm->bmnum; + act_snd_data->freq= prm->tfreq; + act_snd_data->noise= prm->noise.mean; + act_snd_data->frange= prm->frang; + act_snd_data->rsep= prm->rsep; + for( i=0; i< SND_NRANG; i++ ) { + act_snd_data->pwr[ i]= fit->rng[ i].p_l; + act_snd_data->vel[ i]= fit->rng[ i].v; + act_snd_data->width[ i]= fit->rng[ i].w_l; + act_snd_data->AOA[ i]= fit->elv[ i].normal; + act_snd_data->gsct[ i]= fit->rng[ i].gsct; + act_snd_data->qflg[ i]= fit->rng[ i].qflg; + } + *act_snd_rec= *act_snd_rec + 1; + if ( *act_snd_rec >= NUM_SND_DATA) *act_snd_rec= 0; +} + +/********************** function write_sounding_record_new() ************************/ +/* changed the data structure */ + +void write_sounding_record_new( char *progname, struct RadarParm *prm, struct FitData *fit, struct sounder_struct *sounder_data, int *act_snd_rec) +{ + int i; + + struct header_struct + { + long int stime; + short int site_id; + short int beam_no; + short int freq; + short int noise; + short int frange; + short int rsep; + short int gsct[ SND_NRANG]; + short int qflg[ SND_NRANG]; + char program_name[40]; + } header; + + struct data_struct + { + short int pwr; + short int vel; + short int width; + short int AOA; + } data; + + //char data_path[]={"/data/snd/"}, data_filename[50], filename[80]; + char data_path[100], data_filename[50], filename[80]; + + + int good_ranges[ SND_NRANG]; + + char *snd_dir; + FILE *out; + + struct sounder_struct *act_snd_data; + + + /* set up the data directory */ + /* get the snd data dir */ + snd_dir= getenv("SD_SND_PATH"); + if( snd_dir==NULL ) + sprintf( data_path,"/data/snd/"); + else { + memcpy( data_path,snd_dir,strlen(snd_dir)); + data_path[ strlen( snd_dir)]= '/'; + data_path[ strlen( snd_dir) + 1]= 0; + } + + /* make up the filename */ + /* YYYYMMDDHH */ + sprintf( data_filename, "%04d%02d%02d%02d%s", prm->time.yr, prm->time.mo, prm->time.dy, (prm->time.hr/ 2)* 2, getenv("SD_RADARCODE")); + /* finally make the filename */ + sprintf( filename, "%s%s.snd", data_path, data_filename); + /* open the output file */ + out= fopen(filename,"a"); + if( out==NULL ) { + /* crap. might as well go home */ + return; + } + + /* make the header */ + + header.stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + header.site_id= prm->stid; + header.beam_no= prm->bmnum; + header.freq= prm->tfreq; + header.noise= prm->noise.mean; + header.frange= prm->frang; + header.rsep= prm->rsep; + memcpy( header.program_name, progname, sizeof( header.program_name)); + /* zero out the gscat and qual bytes */ + for( i=0; i< SND_NRANG; i++ ) { + header.gsct[i]= fit->rng[i].gsct; + header.qflg[i]= fit->rng[i].qflg; + good_ranges[ i]= ( fit->rng[i].qflg == 1); + } + + /* write out the header */ + fwrite( &header, sizeof( header), 1, out); + + /* scale the fit data into the char/shorts */ + for( i=0; i< SND_NRANG; i++ ) { + /* only do the good ranges */ + if( good_ranges[i] ) { + /* do the power */ + data.pwr= fit->rng[i].p_l; + /* do the velocity */ + data.vel= fit->rng[i].v; + /* do the AOA */ + data.AOA= fit->elv[i].normal; + /* do the width */ + data.width= fit->rng[i].w_l; + /* write out the data structure */ + fwrite( &data, sizeof( data), 1, out); + } + } + fclose(out); + + + /* Fill the next sounder data record */ + act_snd_data= sounder_data + *act_snd_rec; + act_snd_data->stime= TimeYMDHMSToEpoch( prm->time.yr, prm->time.mo, prm->time.dy, prm->time.hr, prm->time.mt, prm->time.sc); + memcpy( act_snd_data->program_name, progname, sizeof(act_snd_data->program_name)); + act_snd_data->site_id= prm->stid; + act_snd_data->beam_num= prm->bmnum; + act_snd_data->freq= prm->tfreq; + act_snd_data->noise= prm->noise.mean; + act_snd_data->frange= prm->frang; + act_snd_data->rsep= prm->rsep; + for( i=0; i< SND_NRANG; i++ ) { + act_snd_data->pwr[ i]= fit->rng[ i].p_l; + act_snd_data->vel[ i]= fit->rng[ i].v; + act_snd_data->width[ i]= fit->rng[ i].w_l; + act_snd_data->AOA[ i]= fit->elv[ i].normal; + act_snd_data->gsct[ i]= fit->rng[ i].gsct; + act_snd_data->qflg[ i]= fit->rng[ i].qflg; + } + *act_snd_rec= *act_snd_rec + 1; + if ( *act_snd_rec >= NUM_SND_DATA) *act_snd_rec= 0; +} + +/****************** function compute_scatter_percentage *************************/ +/* Mod: 20050315 */ +/* Use ths last ~15min sounder data to calculate the ionospheric scatter percentage */ +/* for each sounder frequency and in each beam */ +/* a lot more could be done, but for now we will keep it simple */ + +void compute_scatter_percentage( struct sounder_struct *sounder_data, int act_snd_rec, int sounder_freqs[], int sft, float iscat_percent[ MAX_SND_FREQS][ SND_NBM] ) +{ + struct sounder_struct *act_snd_data; + int isnd, jsnd, ifrq, i; + int returns=0, gscat_returns=0; + + for ( jsnd=0; jsnd< NUM_SND_DATA/ 4; jsnd++) { + isnd= act_snd_rec - jsnd; + if (isnd < 0) isnd= isnd + NUM_SND_DATA; + act_snd_data= sounder_data + isnd; + /* make sure this record has data */ + if (act_snd_data->stime > 0 ) { + returns=0; + gscat_returns=0; + for( i=0; i< SND_NRANG; i++ ) { + if( ( act_snd_data->qflg[i] == 1) && act_snd_data->pwr[i] >= 3.0 && act_snd_data->width[i] < 500.0 ) { + returns++; + if( act_snd_data->gsct[i] ) gscat_returns++; + } + } + for ( ifrq=0; ifrq< sft; ifrq++) { + if ( (act_snd_data->freq >= sounder_freqs[ ifrq]) && (act_snd_data->freq <= sounder_freqs[ ifrq] + frqrng) ) + break; + } + iscat_percent[ ifrq][act_snd_data->beam_num]= 100.0* (float)(returns - gscat_returns)/ SND_NRANG; + } + } +} + +/****************** function average_scatter_percentage *************************/ +/* what is fw good for ?? */ + +void average_scatter_percentages( float iscat_percent[ MAX_SND_FREQS][ SND_NBM], int sft, float average_iscat_percent[ MAX_SND_FREQS], int fw ) +{ +int ifrq, ibm; + + /* average the scatter percentages over all beams */ + for( ifrq=0; ifrq < sft; ifrq++ ) { + average_iscat_percent[ifrq]= 0.0; + for( ibm=0; ibm < SND_NBM; ibm++ ) + average_iscat_percent[ ifrq]+= iscat_percent[ ifrq][ ibm]; + average_iscat_percent[ ifrq]/= 16.0; + if( fw ) average_iscat_percent[ ifrq]*= ifrq; + } +} + +/******************* function find_optimal_freq_local() ************************/ +/* our frequency optimization scheme is this: */ +/* */ +/* at each frequency, find the most recent set of range data for each */ +/* beam. filter this data and then find the percentage of data points */ +/* that were ionospheric backscatter. to get the optimal frequency, */ +/* average over all beams at each frequency and look for the freq */ +/* with the highest percentage of ionsopheric backscatter. */ + +int find_optimal_freq(int start_freq, int cutlass, int fw, int sounder_freqs[], int sft, struct sounder_struct *sounder_data, int act_snd_rec) +{ + int i,j; + int def_freq, def_freq_bin; + /* array of iono scatter percentages (freq and beam number) */ + float iscat_percent[ MAX_SND_FREQS][ SND_NBM]; + float average_iscat_percent[ MAX_SND_FREQS]; + float max_scatter=-10; + int max_freq_bin=0; + int dlf; + FILE *out; + + + /* set the optimal freq to the sounder frequency closest to start_freq in case we don't find a good one; 20060308 DAndre */ + if( !cutlass ) { + dlf= 100000; + for ( i= 0; i < sft; i++) { + if ( fabs( start_freq - sounder_freqs[ i]) < dlf) { + dlf= fabs( start_freq - sounder_freqs[ i]); + def_freq_bin= i; + } + } + } +/* + else + def_freq_bin=lsfreq[def_freq]/1000; +*/ + + /* initialize the arrays */ + for( i=0; i= max_scatter ) { + max_scatter= average_iscat_percent[ i]; + max_freq_bin=i; + } + + /* set a threshold on the improvement */ + if( max_scatter < 1.15* average_iscat_percent[def_freq_bin] || ( max_scatter - average_iscat_percent[def_freq_bin]) < 0.75 ) + max_freq_bin=def_freq_bin; + + def_freq= sounder_freqs[ max_freq_bin]; + + out=fopen("/tmp/freq_search.out","w"); + if( out != NULL ) { + for( i= 0; i < sft; i++ ) { + if( !fw ) + fprintf(out,"\n%2d %d %10.7lf", i, sounder_freqs[ i], average_iscat_percent[i]); + else + fprintf(out,"\n%2d %d %10.7lf", i, sounder_freqs[ i], average_iscat_percent[i]/ i); + } + fprintf( out, "\nCutlass: %d",cutlass); + fprintf( out, "\nFreq Weighting: %d",fw); + fprintf( out, "\nReturned Frequency: %d kHz",def_freq); + fprintf( out, "\n"); + fclose(out); + } + + return(def_freq); +} + + + + + + diff --git a/qnx4/sd_leicester/pyk/normalsound.2.05/version.info b/qnx4/sd_leicester/pyk/normalsound.2.05/version.info new file mode 100644 index 0000000..13c5530 --- /dev/null +++ b/qnx4/sd_leicester/pyk/normalsound.2.05/version.info @@ -0,0 +1,19 @@ +#$Log: version.info,v $ +#Revision 2.5 2006/07/12 15:50:45 code +#Added call to set up command line and limited data written to rawacf and fitacf. +# +#Revision 2.4 2006/04/13 18:14:56 barnes +#Incorporated Dieter Andre's bug fix. +# +#Revision 2.3 2006/02/07 20:56:24 barnes +#Simon Shepherd's modification to the lag table. +# +#Revision 2.2 2006/02/07 17:51:13 barnes +#Added Dieter Andre's improved error logging. +# +#Revision 2.1 2005/07/19 18:45:06 barnes +#First revision included in the ROS 1.08. +# +# +normalsound.c 2.05 + diff --git a/qnx4/sd_leicester/pyk/stereoscan.1.04/makefile b/qnx4/sd_leicester/pyk/stereoscan.1.04/makefile new file mode 100644 index 0000000..9951388 --- /dev/null +++ b/qnx4/sd_leicester/pyk/stereoscan.1.04/makefile @@ -0,0 +1,55 @@ +# Makefile for stereoscan +# ======================= +# by R.J.Barnes +# +# + + +INCLUDE=-I$(IPATH)/base -I$(IPATH)/general -I$(IPATH)/superdarn \ + -I$(IPATH)/radarqnx4 \ + -I$(USR_IPATH)/radarqnx4/ops \ + -I$(USR_IPATH)/radarqnx4/site.$(SD_RADARCODE) + +OBJS = stereoscan.o +SRC=stereoscan.c +IGNVER=1 +OUTPUT = $(USR_BINPATH)/stereoscan +SUDO = 1 +LIBS=-lsite.${SD_RADARCODE}.1 -lops.1 -lfitacf.1 -lradar.1 -lerrlog.1 \ + -lrs.1 -lfreq.1 -lacf.1 -ltcpipmsg.1 -lrawfeed.1 -ltsg.1 \ + -ltaskid.1 -lrmsgsnd.1 -lrtimer.1 -lrtime.1 -lrmath.1 -lopt.1 + +include $(SITELIB).${SD_RADARCODE} + +ifdef STEREO +include $(MAKEBIN) +else +version: version.info $(SRC) + $(BINPATH)/rcsv -t version.info +clean: + rm -f *.o + rm -f $(OUTPUT) +endif + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c b/qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c new file mode 100644 index 0000000..d3a2e9c --- /dev/null +++ b/qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c @@ -0,0 +1,1371 @@ +/* modfied to add correct cts x functionality for Blackstone JDT 30 Jne 2008 */ +/* modifed for Blackstone by JDT 29 Feb 2008 */ + +/* stereoscan.c + ============ + Author: R.J.Barnes +*/ + +/* + Copyright 2004 The Johns Hopkins University/Applied Physics Laboratory. + All rights reserved. + + This material may be used, modified, or reproduced by or for the U.S. + Government pursuant to the license rights granted under the clauses at DFARS + 252.227-7013/7014. + + For any other permissions, please contact the Space Department + Program Office at JHU/APL. + + This Distribution and Disclaimer Statement must be included in all copies of + "Radar Operating System - Control Programs" (hereinafter "the Program"). + + The Program was developed at The Johns Hopkins University/Applied Physics + Laboratory (JHU/APL) which is the author thereof under the "work made for + hire" provisions of the copyright law. + + JHU/APL assumes no obligation to provide support of any kind with regard to + the Program. This includes no obligation to provide assistance in using the + Program or to provide updated versions of the Program. + + THE PROGRAM AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT ANY EXPRESS + OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES INCLUDING, BUT NOT LIMITED + TO, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE + HEREBY DISCLAIMED. YOU ASSUME THE ENTIRE RISK AND LIABILITY OF USING THE + PROGRAM TO INCLUDE USE IN COMPLIANCE WITH ANY THIRD PARTY RIGHTS. YOU ARE + ADVISED TO TEST THE PROGRAM THOROUGHLY BEFORE RELYING ON IT. IN NO EVENT + SHALL JHU/APL BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING, WITHOUT + LIMITATION, ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR + CONSEQUENTIAL DAMAGES, ARISING OUT OF THE USE OR INABILITY TO USE THE + PROGRAM." + + + + + + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + +#include "taskid.h" +#include "errlog.h" +#include "freq.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "globals.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raws.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: stereoscan.c,v $ + Revision 1.4 2007/08/09 14:09:51 code + Allowed command lines to be passed as a file. + + Revision 1.3 2007/08/08 16:55:44 code + Fixed bug in using hex notation for stid. + + Revision 1.2 2006/07/12 15:51:43 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.1 2006/03/30 11:19:18 barnes + Initial revision + +*/ + +/* + Modified 10/12/2001 PH + + Added bnA and bnB frequency band options to cycle through frequency + bands during each scan. No check is made for invalid band numbers. + A band number of -1 is ignored. Bands can be added/removed at any + time using radar_shell, changes won't take effect until the end of + the current scan. If no band numbers are specified, normal day/night + frequencies are used. + + Frequency bands can also be specified for campA and campB modes. + + Extra options can be placed in a separate schedule file. The file + name should be the last argument in the schedule argument list and + should include the full path. + + Modified 16/01/02 PH + + Fixed synchronisation bug. The code wasn't subtracting the time taken + for a clear frequency search from the beam integration time, resulting + in an extended beam dwell time and a sweep lasting for more than 60 s + for fast stereo and 120 s for slow stereo 7 s integration. + + Standard slow stereo (normal stereo) is now 7 seconds (by Mark Lester). + + Modified 30/01/02 PH + + added -cts? options that pre-set other options + + dwell chan A cpidA chan B cpidB Ice/Fin/BKS offset range + ------ ------ ------ ------ ------ ----------- ------ ----- + cts2 - 7 normal 152 tbj -26002 5 / 9 / 7 +400 45 + cts4 - 7 normal 152 normal -26004 5 / 9 / 7 +400 45 + cts6 - 7 normal 152 1 camp -26006 5 / 9 / 7 +400 45 + cts8 - 7 normal 152 2 camp -26008 5 / 9 / 7 +400 45 + + cts3 - 3 normal 153 tbj -26003 5 / 9 / 7 +400 45 + cts5 - 3 normal 153 normal -26005 5 / 9 / 7 +400 45 + cts7 - 3 normal 153 1 camp -26007 5 / 9 / 7 +400 45 + cts9 - 3 normal 153 2 camp -26009 5 / 9 / 7 +400 45 + + Single camp beams are hard coded to the standard Finland beam 9, + Iceland beam 5 and Blackstone 7 + + Double camp beams are the same for both radars and defined as + DOUBLE_CAMP_LOW and DOUBLE_CAMP_HIGH. + + range gates and first range are let to the default settings of 45km + and 180km respectively. + + specifying any cts option will override low and high beam, offset, cpIDs, + integration time and scan boundary. tbj mode overrides frequencies. + + Modified 05/04/02 PH + + Uses the new stereo aware version of fitacf (1.06). + + Modified 30/04/2002 PH + + Added cpidA and cpidB to set the cpid. This option overrides any + previously defined cpid. + + Added bmnA and bmnB to cycle through beams numbers on both channels. + To specify double camp beams use -bm0B 5 -bm1B 9 + To specify single camp beams use -bm0B 5 + The same beam number can be specified more than once. + The number of beams in the channel A beam list determines the number of + beams per scan. This is important if you are also using frequency lists. + + cts 2, 3, 4, 5 beams patterns can be changed with bm*A and bm*B options. + + Modified 25/09/02 PH + + Changed so that the B channel frequency band changes at the end of the + channel B scan, so that it is independent of the number of beams on + channel A. + + Modified 7th Dec 2001 to add camp beam flags + Modified 23 Nov 2001 to add new -ns and -fs flags and changed some defaults + Modified 10th Aug to account for backwards scanning radars + Modified 8th Aug fitacf_s + Julian modified version. March 2001 + +*/ + +#define CPID_A -6401 +#define CPID_B -26401 +#define CPID_NS 152 +#define CPID_FS 153 + + +#define INTT 7 +#define RSEP_A 45 +#define RSEP_B 45 +#define FRANG_A 180 +#define FRANG_B 180 + + +#define LOW_BEAM_A 0 +#define HIGH_BEAM_A 15 +#define LOW_BEAM_B 0 +#define HIGH_BEAM_B 15 + +#define SINGLE_CAMP_BEAM_PYK 5 +#define SINGLE_CAMP_BEAM_HAN 9 +#define SINGLE_CAMP_BEAM_BKS 7 + + +#define DOUBLE_CAMP_LOW 5 +#define DOUBLE_CAMP_HIGH 9 + + +#define UCONT_NAME "ucont_moni" + +#define CHN_A 0 +#define CHN_B 1 + +#define NUMBANDS 10 +#define NUMBEAMS 16 + + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + + + +void u_read_uconts(void); +void u_init_freq_bands(void); + +void RemInvalidEntries(int ifreqsA[], int ifreqsB[]); +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, int *day_nightA, int *day_nightB, int ifreqsA[], int ifreqsB[], int print); +void RemInvalidBeams(int ibeamsA[], int ibeamsB[]); +void FindNumBeams(int *numbeamsA, int *numbeamsB, int ibeamsA[], int ibeamsB[], int print); + +char cmdlne[1024]; +char progid[80]={"$Id: stereoscan.c,v 1.4 2007/08/09 14:09:51 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +int usfreq[100]; +int ufreq_range[100]; + +pid_t uucont_proxy; + +int low_beam_A=LOW_BEAM_A; +int high_beam_A=HIGH_BEAM_A; +int low_beam_B=LOW_BEAM_B; +int high_beam_B=HIGH_BEAM_B; + + + + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; +struct OptionFile *optf=NULL; + +int main(int argc,char *argv[]) { + + int ptab[7] = {0,9,12,20,22,26,27}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {26,27}, /* 1 */ + {20,22}, /* 2 */ + {9,12}, /* 3 */ + {22,26}, /* 4 */ + {22,27}, /* 5 */ + + {20,26}, /* 7 */ + {20,27}, /* 8 */ + {0,9}, /* 9 */ + {12,22}, /* 10 */ + {9,20}, /* 11 */ + {0,12}, /* 12 */ + {9,22}, /* 13 */ + {12,26}, /* 14 */ + {12,27}, /* 15 */ + {9,26}, /* 16 */ + {9,27}, /* 17 */ + {27,27}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + char a[10]; + + int n,i; + pid_t sid; + int exitpoll=0; + + int scnsc=0; + int scnus=0; + + unsigned char ns=0; + unsigned char fs=0; + + int stereo_offset=400; /* channel A delayed by this + number of microseconds */ + + + int ifreqsA[NUMBANDS],ifreqsB[NUMBANDS]; + + int ibeamsA[NUMBEAMS],ibeamsB[NUMBEAMS]; + + int day_nightA=1; + int day_nightB=1; + + int numfreqbandsA; + int numfreqbandsB; + + int ifreqsA_index=0; + int ifreqsB_index=0; + + int ifreqsAband; + int ifreqsBband; + + int numbeamsA,numbeamsB; + + int ibeamsA_index=0; + int ibeamsB_index=0; + + unsigned char cts2=0,cts4=0,cts6=0,cts8=0; + unsigned char cts3=0,cts5=0,cts7=0,cts9=0; + + int cpidA=0,cpidB=0; + + for (i=0;iargc,optf->argv,&opt,NULL); + OptionFreeFile(optf); + } + fclose(fp); + } + } + + if (sname==NULL) sname=sdname; + if (ename==NULL) ename=edname; + + sid=RShellRegister(sname,CONTROL_NAME); + + errlog=TaskIDMake(ename); + OpsLogStart(errlog,progname,argc,argv); + + /* handle CTs */ + + if ((cts2) || (cts4) || (cts6) || (cts8)) { + cpA = 152; + intsc = 7; + intus = 0; + stereo_offset = 400; + scnsc = 120; + scnus = 0; + + /* tbj mode */ + + if (cts2) { + cpB = -26002; + if (stid==9) { + ifreqsA[0] = 23; + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsA[0] = 3; + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } else if (stid==33) { + ifreqsA[0] = 42; + ifreqsB[0] = 50; + ifreqsB[1] = 40; + ifreqsB[2] = 41; + ifreqsB[3] = 42; + ifreqsB[4] = 43; + ifreqsB[5] = 44; + ifreqsB[6] = 45; + } + } + + /* normal scan */ + + if (cts4) cpB = -26004; + + /* single camp beam */ + + if (cts6) { + cpB = -26006; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else if (stid==33) ibeamsB[0] = SINGLE_CAMP_BEAM_BKS; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts8) { + cpB = -26008; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else if ((cts3) || (cts5) || (cts7) || (cts9)) { + cpA = 153; + intsc = 3; + stereo_offset = 400; + scnsc = 60.0; + scnus = 0.0; + + /* tbj */ + + if (cts3) { + cpB = -26003; + + if (stid==9) { + ifreqsA[0] = 23; + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsA[0] = 3; + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } else if (stid==33) { + ifreqsA[0] = 42; + ifreqsB[0] = 50; + ifreqsB[1] = 40; + ifreqsB[2] = 41; + ifreqsB[3] = 42; + ifreqsB[4] = 43; + ifreqsB[5] = 44; + ifreqsB[6] = 45; + } + } + + /* normal scan */ + + if (cts5) cpB = -26005; + + + /* single camp beam */ + + if (cts7) { + cpB = -26007; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else if (stid==33) ibeamsB[0] = SINGLE_CAMP_BEAM_BKS; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts9) { + cpB = -26009; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else + /* check for normal scan emulation */ + if (ns) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 7; + intus = 0; + scnsc = 120.0; + scnus = 0.0; + cpA = CPID_NS; + } else + /* check for fast scan emulation */ + if (fs) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 3; + intus = 0; + scnsc = 60.0; + scnus = 0.0; + cpA = CPID_FS; + } + + /* set cpid for channel A */ + + if (cpidA) { + cpA = cpidA; + cpB = -1 * abs(cpidA) - 20000; + } + + /* set cpid for channel B */ + + if (cpidB) cpB = cpidB; + + /* Calculate delay offsets + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* remember stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + mppulA = mppulB = 7; + mplgsA = mplgsB = 18; + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + /* just a dummy frequency */ + + tfreqA = 13500; + tfreqB = 14500; + + SiteSetupHardware(); + + /* remove invalid entries in the frequency band lists */ + + RemInvalidEntries(ifreqsA, ifreqsB); + + /* determine the number of frequency bands */ + + FindNumBands(&numfreqbandsA, &numfreqbandsB, + &day_nightA, &day_nightB, ifreqsA, ifreqsB, 1); + + /* check beams */ + + if (low_beam_A < LOW_BEAM_A) low_beam_A = LOW_BEAM_A; + if (high_beam_A > HIGH_BEAM_A) high_beam_A = HIGH_BEAM_A; + + if (low_beam_B < LOW_BEAM_B) low_beam_B = LOW_BEAM_B; + if (high_beam_B > HIGH_BEAM_B) high_beam_B = HIGH_BEAM_B; + + /* end beams in the wrong order */ + + if (low_beam_A > high_beam_A) { + int beam = high_beam_A; + high_beam_A = low_beam_A; + low_beam_A = beam; + } + + if (low_beam_B > high_beam_B) { + int beam = high_beam_B; + high_beam_B = low_beam_B; + low_beam_B = beam; + } + + /* sort beam lists */ + + RemInvalidBeams(ibeamsA, ibeamsB); + FindNumBeams(&numbeamsA, &numbeamsB, ibeamsA, ibeamsB, 1); + + /* + the beam lists now contain: + 1) the number of beams in the beam lists + 2) if no beam list or camp beams were specified = 0 -> 15 + 3) if high and low beams were specified = low_beam -> high_beam + */ + + sprintf(progname,"stereoscan"); + + OpsFitACFStart(); + + OpsSetupTask(tasklist); + for (n=0;ndfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; + + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d (%02d) %5d (%02d) - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, ifreqsAband, tfreqB, ifreqsBband, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + + ErrLog(errlog,progname,logtxt); + + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + + + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + + + msg.num=0; + msg.tsize=0; + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + + + for (n=0;n= numfreqbandsA) ifreqsA_index = 0; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + + /* Calculate delay offsets if stereo offset has been changed + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + scanA = 0; + scanB = 0; + + /* change beam number index */ + + ibeamsB_index++; + + if (ibeamsB_index >= numbeamsB) ibeamsB_index = 0; + + /* change band at the end of channel B scan */ + + if (ibeamsB_index == 0) { + if (numfreqbandsB != 0) { + ifreqsB_index++; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + } + } + } + + /* increment individual frequency band index. Doesn't matter whether + individual frequency bands are being used for this channel or not. + */ + + if (numfreqbandsA != 0) { + ifreqsA_index++; + if (ifreqsA_index >= numfreqbandsA) ifreqsA_index = 0; + } + + ErrLog(errlog,progname,"Waiting for scan boundary."); + if ((scnsc !=0) || (scnus !=0)) { + if (exitpoll==0) OpsWaitBoundary(scnsc,scnus); + } + } while (exitpoll==0); + SiteEnd(); + for (n=0;n 0; i--) { + + /* if the preceding element is -1 then move all the following + bands down + */ + + if ((ifreqsA[i] != -1) && (ifreqsA[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsA[j - 1] = ifreqsA[j]; + ifreqsA[j] = -1; + } + } + + if ((ifreqsB[i] != -1) && (ifreqsB[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsB[j - 1] = ifreqsB[j]; + ifreqsB[j] = -1; + } + } + } +} + +/* determine the number of frequency bands */ + +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, + int *day_nightA, int *day_nightB, + int ifreqsA[NUMBANDS], int ifreqsB[NUMBANDS], + int print) { + int i; + char logtxt[256]; + + *numfreqbandsA = 0; + *numfreqbandsB = 0; + + for (i = 0; i < NUMBANDS; i++) { + if (ifreqsA[i] != -1) (*numfreqbandsA)++; + if (ifreqsB[i] != -1) (*numfreqbandsB)++; + } + + /* check to see if day/night frequencies are to be used */ + + if (*numfreqbandsA != 0) *day_nightA = 0; + else *day_nightA = 1; + + if (*numfreqbandsB != 0) *day_nightB = 0; + else *day_nightB = 1; + + if (print) { + sprintf(logtxt, "Channel A: %d Channel B: %d", *numfreqbandsA, + *numfreqbandsB); + ErrLog(errlog, progname, logtxt); + } + + /* print frequency bands for each channel */ + + if ((*numfreqbandsA > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel A: "); + + for (i = 0; i < *numfreqbandsA; i++) { + sprintf(logtxt, "%1d ", ifreqsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if ((*numfreqbandsB > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel B: "); + + for (i = 0; i < *numfreqbandsB; i++) { + sprintf(logtxt, "%1d ", ifreqsB[i]); + ErrLog(errlog,progname,logtxt); + } + } +} + +/* remove invalid entries in the beam lists */ + +void RemInvalidBeams(int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS]) { + int i, j; + + for (i = NUMBEAMS - 1; i > 0; i--) { + if (ibeamsA[i] < 0) ibeamsA[i] = -1; + if (ibeamsA[i] > 15) ibeamsA[i] = -1; + + if (ibeamsB[i] < 0) ibeamsB[i] = -1; + if (ibeamsB[i] > 15) ibeamsB[i] = -1; + } + + for (i = NUMBEAMS - 1; i > 0; i--) { + + /* if the preceding element is -1 then move all the + following beams down + */ + + if ((ibeamsA[i - 1] == -1) && (ibeamsA[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsA[j - 1] = ibeamsA[j]; + ibeamsA[j] = -1; + } + } + + if ((ibeamsB[i - 1] == -1) && (ibeamsB[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsB[j - 1] = ibeamsB[j]; + ibeamsB[j] = -1; + } + } + } +} + +/* determine the number of beams */ + +void FindNumBeams(int *numbeamsA, int *numbeamsB, + int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS], + int print) { + int i; + char logtxt[256]; + + *numbeamsA = 0; + *numbeamsB = 0; + + /* count channel A beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsA[i] != -1) (*numbeamsA)++; + else break; + } + + /* count channel B beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsB[i] != -1) (*numbeamsB)++; + else break; + } + + if (print) { + sprintf(logtxt, "Beams A: %d Beams B: %d", *numbeamsA, *numbeamsB); + ErrLog(errlog, progname, logtxt); + + /* print frequency bands for each channel */ + + if (*numbeamsA > 0) { + ErrLog(errlog,progname,"Beams for channel A: "); + + for (i = 0; i < *numbeamsA; i++) { + sprintf(logtxt, "%1d ", ibeamsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if (*numbeamsB > 0) { + ErrLog(errlog,progname,"Beams for channel B: "); + for (i = 0; i < *numbeamsB; i++) { + sprintf(logtxt, "%1d ", ibeamsB[i]); + ErrLog(errlog,progname,logtxt); + } + } + } + + /* if no beams have been specified fill the arrays with normal sequence + between low_beam and high beam. + */ + + if (*numbeamsA == 0) { + if (backward) { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = high_beam_A - i; + (*numbeamsA)++; + } + } else { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = low_beam_A + i; + (*numbeamsA)++; + } + } + } + + if (*numbeamsB == 0) { + + if (backward) { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = high_beam_B - i; + (*numbeamsB)++; + } + } else { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = low_beam_B + i; + (*numbeamsB)++; + } + } + } +} + + + + diff --git a/qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c.orig b/qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c.orig new file mode 100644 index 0000000..8360854 --- /dev/null +++ b/qnx4/sd_leicester/pyk/stereoscan.1.04/stereoscan.c.orig @@ -0,0 +1,1271 @@ +/* stereoscan.c + ============ + Author: R.J.Barnes +*/ + +/* + Copyright 2004 The Johns Hopkins University/Applied Physics Laboratory. + All rights reserved. + + This material may be used, modified, or reproduced by or for the U.S. + Government pursuant to the license rights granted under the clauses at DFARS + 252.227-7013/7014. + + For any other permissions, please contact the Space Department + Program Office at JHU/APL. + + This Distribution and Disclaimer Statement must be included in all copies of + "Radar Operating System - Control Programs" (hereinafter "the Program"). + + The Program was developed at The Johns Hopkins University/Applied Physics + Laboratory (JHU/APL) which is the author thereof under the "work made for + hire" provisions of the copyright law. + + JHU/APL assumes no obligation to provide support of any kind with regard to + the Program. This includes no obligation to provide assistance in using the + Program or to provide updated versions of the Program. + + THE PROGRAM AND ITS DOCUMENTATION ARE PROVIDED AS IS AND WITHOUT ANY EXPRESS + OR IMPLIED WARRANTIES WHATSOEVER. ALL WARRANTIES INCLUDING, BUT NOT LIMITED + TO, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE ARE + HEREBY DISCLAIMED. YOU ASSUME THE ENTIRE RISK AND LIABILITY OF USING THE + PROGRAM TO INCLUDE USE IN COMPLIANCE WITH ANY THIRD PARTY RIGHTS. YOU ARE + ADVISED TO TEST THE PROGRAM THOROUGHLY BEFORE RELYING ON IT. IN NO EVENT + SHALL JHU/APL BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING, WITHOUT + LIMITATION, ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR + CONSEQUENTIAL DAMAGES, ARISING OUT OF THE USE OR INABILITY TO USE THE + PROGRAM." + + + + + + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include "rtypes.h" +#include "option.h" +#include "rtime.h" +#include "limit.h" +#include "radar.h" +#include "rprm.h" +#include "rawdata.h" +#include "fitblk.h" +#include "fitdata.h" +#include "fitacf.h" + +#include "taskid.h" +#include "errlog.h" +#include "freq.h" +#include "rmsg.h" +#include "radarshell.h" +#include "rmsgsnd.h" +#include "tsg.h" +#include "tsgtable.h" +#include "maketsg.h" +#include "global.h" +#include "globals.h" +#include "setup.h" +#include "reopen.h" +#include "tmseq.h" +#include "raws.h" +#include "sync.h" +#include "interface.h" +#include "hdw.h" + +/* + $Log: stereoscan.c,v $ + Revision 1.4 2007/08/09 14:09:51 code + Allowed command lines to be passed as a file. + + Revision 1.3 2007/08/08 16:55:44 code + Fixed bug in using hex notation for stid. + + Revision 1.2 2006/07/12 15:51:43 code + Added call to set up command line and limited data written to rawacf and fitacf. + + Revision 1.1 2006/03/30 11:19:18 barnes + Initial revision + +*/ + +/* + Modified 10/12/2001 PH + + Added bnA and bnB frequency band options to cycle through frequency + bands during each scan. No check is made for invalid band numbers. + A band number of -1 is ignored. Bands can be added/removed at any + time using radar_shell, changes won't take effect until the end of + the current scan. If no band numbers are specified, normal day/night + frequencies are used. + + Frequency bands can also be specified for campA and campB modes. + + Extra options can be placed in a separate schedule file. The file + name should be the last argument in the schedule argument list and + should include the full path. + + Modified 16/01/02 PH + + Fixed synchronisation bug. The code wasn't subtracting the time taken + for a clear frequency search from the beam integration time, resulting + in an extended beam dwell time and a sweep lasting for more than 60 s + for fast stereo and 120 s for slow stereo 7 s integration. + + Standard slow stereo (normal stereo) is now 7 seconds (by Mark Lester). + + Modified 30/01/02 PH + + added -cts? options that pre-set other options + + dwell chan A cpidA chan B cpidB Ice/Fin offset range + ------ ------ ------ ------ ------ ------- ------ ----- + cts2 - 7 normal 152 tbj -26002 5 / 9 +400 45 + cts4 - 7 normal 152 normal -26004 5 / 9 +400 45 + cts6 - 7 normal 152 1 camp -26006 5 / 9 +400 45 + cts8 - 7 normal 152 2 camp -26008 5 / 9 +400 45 + + cts3 - 3 normal 153 tbj -26003 5 / 9 +400 45 + cts5 - 3 normal 153 normal -26005 5 / 9 +400 45 + cts7 - 3 normal 153 1 camp -26007 5 / 9 +400 45 + cts9 - 3 normal 153 2 camp -26009 5 / 9 +400 45 + + Single camp beams are hard coded to the standard Finland beam 9 and + Iceland beam 5. + + Double camp beams are the same for both radars and defined as + DOUBLE_CAMP_LOW and DOUBLE_CAMP_HIGH. + + range gates and first range are let to the default settings of 45km + and 180km respectively. + + specifying any cts option will override low and high beam, offset, cpIDs, + integration time and scan boundary. tbj mode overrides frequencies. + + Modified 05/04/02 PH + + Uses the new stereo aware version of fitacf (1.06). + + Modified 30/04/2002 PH + + Added cpidA and cpidB to set the cpid. This option overrides any + previously defined cpid. + + Added bmnA and bmnB to cycle through beams numbers on both channels. + To specify double camp beams use -bm0B 5 -bm1B 9 + To specify single camp beams use -bm0B 5 + The same beam number can be specified more than once. + The number of beams in the channel A beam list determines the number of + beams per scan. This is important if you are also using frequency lists. + + cts 2, 3, 4, 5 beams patterns can be changed with bm*A and bm*B options. + + Modified 25/09/02 PH + + Changed so that the B channel frequency band changes at the end of the + channel B scan, so that it is independent of the number of beams on + channel A. + + Modified 7th Dec 2001 to add camp beam flags + Modified 23 Nov 2001 to add new -ns and -fs flags and changed some defaults + Modified 10th Aug to account for backwards scanning radars + Modified 8th Aug fitacf_s + Julian modified version. March 2001 + +*/ + +#define CPID_A -6401 +#define CPID_B -26401 +#define CPID_NS 152 +#define CPID_FS 153 + + +#define INTT 7 +#define RSEP_A 45 +#define RSEP_B 45 +#define FRANG_A 180 +#define FRANG_B 180 + + +#define LOW_BEAM_A 0 +#define HIGH_BEAM_A 15 +#define LOW_BEAM_B 0 +#define HIGH_BEAM_B 15 + +#define SINGLE_CAMP_BEAM_PYK 5 +#define SINGLE_CAMP_BEAM_HAN 9 + + +#define DOUBLE_CAMP_LOW 5 +#define DOUBLE_CAMP_HIGH 9 + +#define UCONT_NAME "ucont_moni" + +#define CHN_A 0 +#define CHN_B 1 + +#define NUMBANDS 10 +#define NUMBEAMS 16 + + +#define SCHEDULER "schedule" +#define ERRLOG "errlog" + +#define CONTROL_NAME "control_program" +#define TASK_NAMES "echo_data","rawacfwrite","fitacfwrite" + + + +void u_read_uconts(void); +void u_init_freq_bands(void); + +void RemInvalidEntries(int ifreqsA[], int ifreqsB[]); +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, int *day_nightA, int *day_nightB, int ifreqsA[], int ifreqsB[], int print); +void RemInvalidBeams(int ibeamsA[], int ibeamsB[]); +void FindNumBeams(int *numbeamsA, int *numbeamsB, int ibeamsA[], int ibeamsB[], int print); + +char cmdlne[1024]; +char progid[80]={"$Id: stereoscan.c,v 1.4 2007/08/09 14:09:51 code Exp $"}; +char progname[256]; +struct TaskID *errlog; + +int usfreq[42]; +int ufreq_range[42]; + +pid_t uucont_proxy; + +int low_beam_A=LOW_BEAM_A; +int high_beam_A=HIGH_BEAM_A; +int low_beam_B=LOW_BEAM_B; +int high_beam_B=HIGH_BEAM_B; + + + + +char *tasklist[]= + { TASK_NAMES, + 0}; + +int arg=0; +struct OptionData opt; +struct OptionFile *optf=NULL; + +int main(int argc,char *argv[]) { + + int ptab[7] = {0,9,12,20,22,26,27}; + + int lags[LAG_SIZE][2] = { + { 0, 0}, /* 0 */ + {26,27}, /* 1 */ + {20,22}, /* 2 */ + {9,12}, /* 3 */ + {22,26}, /* 4 */ + {22,27}, /* 5 */ + + {20,26}, /* 7 */ + {20,27}, /* 8 */ + {0,9}, /* 9 */ + {12,22}, /* 10 */ + {9,20}, /* 11 */ + {0,12}, /* 12 */ + {9,22}, /* 13 */ + {12,26}, /* 14 */ + {12,27}, /* 15 */ + {9,26}, /* 16 */ + {9,27}, /* 17 */ + {27,27}}; /* alternate lag-0 */ + + + char *sname=NULL; + char *ename=NULL; + char *sdname={SCHEDULER}; + char *edname={ERRLOG}; + char logtxt[1024]; + + char a[10]; + + int n,i; + pid_t sid; + int exitpoll=0; + + int scnsc=0; + int scnus=0; + + unsigned char ns=0; + unsigned char fs=0; + + int stereo_offset=400; /* channel A delayed by this + number of microseconds */ + + + int ifreqsA[NUMBANDS],ifreqsB[NUMBANDS]; + + int ibeamsA[NUMBEAMS],ibeamsB[NUMBEAMS]; + + int day_nightA=1; + int day_nightB=1; + + int numfreqbandsA; + int numfreqbandsB; + + int ifreqsA_index=0; + int ifreqsB_index=0; + + int ifreqsAband; + int ifreqsBband; + + int numbeamsA,numbeamsB; + + int ibeamsA_index=0; + int ibeamsB_index=0; + + unsigned char cts2=0,cts4=0,cts6=0,cts8=0; + unsigned char cts3=0,cts5=0,cts7=0,cts9=0; + + int cpidA=0,cpidB=0; + + for (i=0;iargc,optf->argv,&opt,NULL); + OptionFreeFile(optf); + } + fclose(fp); + } + } + + if (sname==NULL) sname=sdname; + if (ename==NULL) ename=edname; + + sid=RShellRegister(sname,CONTROL_NAME); + + errlog=TaskIDMake(ename); + OpsLogStart(errlog,progname,argc,argv); + + /* handle CTs */ + + if ((cts2) || (cts4) || (cts6) || (cts8)) { + cpA = 152; + intsc = 7; + intus = 0; + stereo_offset = 400; + scnsc = 120; + scnus = 0; + + /* tbj mode */ + + if (cts2) { + cpB = -26002; + if (stid==9) { + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } + } + + /* normal scan */ + + if (cts4) cpB = -26004; + + /* single camp beam */ + + if (cts6) { + cpB = -26006; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts8) { + cpB = -26008; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else if ((cts3) || (cts5) || (cts7) || (cts9)) { + cpA = 153; + intsc = 3; + stereo_offset = 400; + scnsc = 60.0; + scnus = 0.0; + + /* tbj */ + + if (cts3) { + cpB = -26003; + + if (stid==9) { + ifreqsB[0] = 23; + ifreqsB[1] = 26; + ifreqsB[2] = 28; + ifreqsB[3] = 30; + ifreqsB[4] = 32; + ifreqsB[5] = 34; + ifreqsB[6] = 35; + } else if (stid==10) { + ifreqsB[0] = 2; + ifreqsB[1] = 4; + ifreqsB[2] = 5; + ifreqsB[3] = 6; + ifreqsB[4] = 7; + ifreqsB[5] = 8; + ifreqsB[6] = 10; + } + } + + /* normal scan */ + + if (cts5) cpB = -26005; + + + /* single camp beam */ + + if (cts7) { + cpB = -26007; + if (stid==9) ibeamsB[0] = SINGLE_CAMP_BEAM_PYK; + else ibeamsB[0] = SINGLE_CAMP_BEAM_HAN; + + } + + /* double camp beam */ + + if (cts9) { + cpB = -26009; + + ibeamsB[0] = DOUBLE_CAMP_LOW; + ibeamsB[1] = DOUBLE_CAMP_HIGH; + } + } else + /* check for normal scan emulation */ + if (ns) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 7; + intus = 0; + scnsc = 120.0; + scnus = 0.0; + cpA = CPID_NS; + } else + /* check for fast scan emulation */ + if (fs) { + frangA = FRANG_A; + rsepA = RSEP_A; + low_beam_A = LOW_BEAM_A; + high_beam_A = HIGH_BEAM_A; + + intsc = 3; + intus = 0; + scnsc = 60.0; + scnus = 0.0; + cpA = CPID_FS; + } + + /* set cpid for channel A */ + + if (cpidA) { + cpA = cpidA; + cpB = -1 * abs(cpidA) - 20000; + } + + /* set cpid for channel B */ + + if (cpidB) cpB = cpidB; + + /* Calculate delay offsets + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* remember stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + mppulA = mppulB = 7; + mplgsA = mplgsB = 18; + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + /* just a dummy frequency */ + + tfreqA = 13500; + tfreqB = 14500; + + SiteSetupHardware(); + + /* remove invalid entries in the frequency band lists */ + + RemInvalidEntries(ifreqsA, ifreqsB); + + /* determine the number of frequency bands */ + + FindNumBands(&numfreqbandsA, &numfreqbandsB, + &day_nightA, &day_nightB, ifreqsA, ifreqsB, 1); + + /* check beams */ + + if (low_beam_A < LOW_BEAM_A) low_beam_A = LOW_BEAM_A; + if (high_beam_A > HIGH_BEAM_A) high_beam_A = HIGH_BEAM_A; + + if (low_beam_B < LOW_BEAM_B) low_beam_B = LOW_BEAM_B; + if (high_beam_B > HIGH_BEAM_B) high_beam_B = HIGH_BEAM_B; + + /* end beams in the wrong order */ + + if (low_beam_A > high_beam_A) { + int beam = high_beam_A; + high_beam_A = low_beam_A; + low_beam_A = beam; + } + + if (low_beam_B > high_beam_B) { + int beam = high_beam_B; + high_beam_B = low_beam_B; + low_beam_B = beam; + } + + /* sort beam lists */ + + RemInvalidBeams(ibeamsA, ibeamsB); + FindNumBeams(&numbeamsA, &numbeamsB, ibeamsA, ibeamsB, 1); + + /* + the beam lists now contain: + 1) the number of beams in the beam lists + 2) if no beam list or camp beams were specified = 0 -> 15 + 3) if high and low beams were specified = low_beam -> high_beam + */ + + sprintf(progname,"stereoscan"); + + OpsFitACFStart(); + + OpsSetupTask(tasklist); + for (n=0;ndfrq; + if (tfreqB==-1) tfreqB=ftable->dfrq; + + sprintf(logtxt,"Channel A Transmitting on: %d (Noise=%g)",tfreqA,noiseA); + ErrLog(errlog,progname,logtxt); + + sprintf(logtxt,"Channel B Transmitting on: %d (Noise=%g)",tfreqB,noiseB); + ErrLog(errlog,progname,logtxt); + + SiteSetChannel(CHN_A); + SiteSetFreq(tfreqA); + SiteSetChannel(CHN_B); + SiteSetFreq(tfreqB); + + sprintf(logtxt,"Integrating:%2d,%2d intt:%d (%02d:%02d:%02d) %5d (%02d) %5d (%02d) - %s %d\n", + bmnumA, bmnumB, intsc, hr, mt, + sc, tfreqA, ifreqsAband, tfreqB, ifreqsBband, + OpsDayNight() ? "day" : "night", abs(tfreqA - tfreqB)); + + ErrLog(errlog,progname,logtxt); + + u_read_uconts(); + + txplA = (rsepA * 20) / 3; + txplB = (rsepB * 20) / 3; + + tsgidA=SiteTimeSeqS(0,ptab); + tsgidB=SiteTimeSeqS(1,ptab); + + SiteIntegrateS(lags,lags); + + + if (naveA<0) { + sprintf(logtxt,"Integration A failed:%d",naveA); + ErrLog(errlog,progname,logtxt); + continue; + } + if (naveB<0) { + sprintf(logtxt,"Integration B failed:%d",naveB); + ErrLog(errlog,progname,logtxt); + continue; + } + + sprintf(logtxt,"Number of sequences: %d %d",naveA,naveB); + ErrLog(errlog,progname,logtxt); + + OpsBuildRawS(0,&prmA,&rawA,ptab,lags); + OpsBuildRawS(1,&prmB,&rawB,ptab,lags); + + FitACF(&prmA,&rawA,&fblk,&fitA); + FitACF(&prmB,&rawB,&fblk,&fitB); + + ErrLog(errlog,progname,"Sending messages."); + + + msg.num=0; + msg.tsize=0; + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmA, + PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawA, + RAW_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitA, + FIT_TYPE,0); + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,0); + + RMsgSndAdd(&msg,sizeof(struct RadarParm),(unsigned char *) &prmB, + PRM_TYPE,1); + RMsgSndAdd(&msg,sizeof(struct RawData),(unsigned char *) &rawB, + RAW_TYPE,1); + + RMsgSndAdd(&msg,sizeof(struct FitData),(unsigned char *) &fitB, + FIT_TYPE,1); + + + RMsgSndAdd(&msg,strlen(progname)+1,progname, + NME_TYPE,1); + + + for (n=0;n= numfreqbandsA) ifreqsA_index = 0; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + + /* Calculate delay offsets if stereo offset has been changed + If stereo_offset is +ve A is later than B + */ + + if (stereo_offset > 0) { + delays[1] = 0; + delays[0] = stereo_offset / 10; /* stereo_offset is in usec */ + } else { + delays[0] = 0; + delays[1] = (stereo_offset / 10) * (-1); /* stereo_offset is in usec */ + } + + if (exitpoll !=0) break; + + scanA = 0; + scanB = 0; + + /* change beam number index */ + + ibeamsB_index++; + + if (ibeamsB_index >= numbeamsB) ibeamsB_index = 0; + + /* change band at the end of channel B scan */ + + if (ibeamsB_index == 0) { + if (numfreqbandsB != 0) { + ifreqsB_index++; + if (ifreqsB_index >= numfreqbandsB) ifreqsB_index = 0; + } + } + } + + /* increment individual frequency band index. Doesn't matter whether + individual frequency bands are being used for this channel or not. + */ + + if (numfreqbandsA != 0) { + ifreqsA_index++; + if (ifreqsA_index >= numfreqbandsA) ifreqsA_index = 0; + } + + ErrLog(errlog,progname,"Waiting for scan boundary."); + if ((scnsc !=0) || (scnus !=0)) { + if (exitpoll==0) OpsWaitBoundary(scnsc,scnus); + } + } while (exitpoll==0); + SiteEnd(); + for (n=0;n 0; i--) { + + /* if the preceding element is -1 then move all the following + bands down + */ + + if ((ifreqsA[i] != -1) && (ifreqsA[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsA[j - 1] = ifreqsA[j]; + ifreqsA[j] = -1; + } + } + + if ((ifreqsB[i] != -1) && (ifreqsB[i - 1] == -1)) { + for (j = i; j < NUMBANDS; j++) { + ifreqsB[j - 1] = ifreqsB[j]; + ifreqsB[j] = -1; + } + } + } +} + +/* determine the number of frequency bands */ + +void FindNumBands(int *numfreqbandsA, int *numfreqbandsB, + int *day_nightA, int *day_nightB, + int ifreqsA[NUMBANDS], int ifreqsB[NUMBANDS], + int print) { + int i; + char logtxt[256]; + + *numfreqbandsA = 0; + *numfreqbandsB = 0; + + for (i = 0; i < NUMBANDS; i++) { + if (ifreqsA[i] != -1) (*numfreqbandsA)++; + if (ifreqsB[i] != -1) (*numfreqbandsB)++; + } + + /* check to see if day/night frequencies are to be used */ + + if (*numfreqbandsA != 0) *day_nightA = 0; + else *day_nightA = 1; + + if (*numfreqbandsB != 0) *day_nightB = 0; + else *day_nightB = 1; + + if (print) { + sprintf(logtxt, "Channel A: %d Channel B: %d", *numfreqbandsA, + *numfreqbandsB); + ErrLog(errlog, progname, logtxt); + } + + /* print frequency bands for each channel */ + + if ((*numfreqbandsA > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel A: "); + + for (i = 0; i < *numfreqbandsA; i++) { + sprintf(logtxt, "%1d ", ifreqsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if ((*numfreqbandsB > 0) && print) { + ErrLog(errlog,progname,"Frequency bands for channel B: "); + + for (i = 0; i < *numfreqbandsB; i++) { + sprintf(logtxt, "%1d ", ifreqsB[i]); + ErrLog(errlog,progname,logtxt); + } + } +} + +/* remove invalid entries in the beam lists */ + +void RemInvalidBeams(int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS]) { + int i, j; + + for (i = NUMBEAMS - 1; i > 0; i--) { + if (ibeamsA[i] < 0) ibeamsA[i] = -1; + if (ibeamsA[i] > 15) ibeamsA[i] = -1; + + if (ibeamsB[i] < 0) ibeamsB[i] = -1; + if (ibeamsB[i] > 15) ibeamsB[i] = -1; + } + + for (i = NUMBEAMS - 1; i > 0; i--) { + + /* if the preceding element is -1 then move all the + following beams down + */ + + if ((ibeamsA[i - 1] == -1) && (ibeamsA[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsA[j - 1] = ibeamsA[j]; + ibeamsA[j] = -1; + } + } + + if ((ibeamsB[i - 1] == -1) && (ibeamsB[i] != -1)) { + for (j = i; j < NUMBEAMS; j++) { + ibeamsB[j - 1] = ibeamsB[j]; + ibeamsB[j] = -1; + } + } + } +} + +/* determine the number of beams */ + +void FindNumBeams(int *numbeamsA, int *numbeamsB, + int ibeamsA[NUMBEAMS], int ibeamsB[NUMBEAMS], + int print) { + int i; + char logtxt[256]; + + *numbeamsA = 0; + *numbeamsB = 0; + + /* count channel A beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsA[i] != -1) (*numbeamsA)++; + else break; + } + + /* count channel B beams */ + + for (i = 0; i < NUMBEAMS; i++) { + if (ibeamsB[i] != -1) (*numbeamsB)++; + else break; + } + + if (print) { + sprintf(logtxt, "Beams A: %d Beams B: %d", *numbeamsA, *numbeamsB); + ErrLog(errlog, progname, logtxt); + + /* print frequency bands for each channel */ + + if (*numbeamsA > 0) { + ErrLog(errlog,progname,"Beams for channel A: "); + + for (i = 0; i < *numbeamsA; i++) { + sprintf(logtxt, "%1d ", ibeamsA[i]); + ErrLog(errlog,progname,logtxt); + } + } + + if (*numbeamsB > 0) { + ErrLog(errlog,progname,"Beams for channel B: "); + for (i = 0; i < *numbeamsB; i++) { + sprintf(logtxt, "%1d ", ibeamsB[i]); + ErrLog(errlog,progname,logtxt); + } + } + } + + /* if no beams have been specified fill the arrays with normal sequence + between low_beam and high beam. + */ + + if (*numbeamsA == 0) { + if (backward) { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = high_beam_A - i; + (*numbeamsA)++; + } + } else { + for (i = 0; i < (high_beam_A - low_beam_A + 1); i++) { + ibeamsA[i] = low_beam_A + i; + (*numbeamsA)++; + } + } + } + + if (*numbeamsB == 0) { + + if (backward) { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = high_beam_B - i; + (*numbeamsB)++; + } + } else { + for (i = 0; i < (high_beam_B - low_beam_B + 1); i++) { + ibeamsB[i] = low_beam_B + i; + (*numbeamsB)++; + } + } + } +} + + + + diff --git a/qnx4/sd_leicester/pyk/stereoscan.1.04/version.info b/qnx4/sd_leicester/pyk/stereoscan.1.04/version.info new file mode 100644 index 0000000..cc48e31 --- /dev/null +++ b/qnx4/sd_leicester/pyk/stereoscan.1.04/version.info @@ -0,0 +1,15 @@ +# $Log: version.info,v $ +# Revision 1.4 2007/08/09 14:10:26 code +# Added the ability to pass command line options as a file. +# +# Revision 1.3 2007/08/08 16:56:07 code +# Fixed bug in using hex notation for stid. +# +# Revision 1.2 2006/07/12 15:51:55 code +# Added call to set up command line and limited data written to rawacf and fitacf. +# +# Revision 1.1 2006/03/30 11:28:25 barnes +# Initial revision +# +# +stereoscan.c 1.04 From 896ca30a99f8a12f4139fb5d7c889414ec5f71a7 Mon Sep 17 00:00:00 2001 From: egthomas Date: Sat, 28 Aug 2021 09:59:11 -0400 Subject: [PATCH 05/22] Fixing bug in QNX6 normalsound causing error in calculated def_intt_us / intt.us for the normalscan portion --- qnx6/normalsound.2.0/normalsound_cv.c | 2 +- qnx6/normalsound.2.0/normalsound_fh.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qnx6/normalsound.2.0/normalsound_cv.c b/qnx6/normalsound.2.0/normalsound_cv.c index 3c2e3cf..a9afe08 100644 --- a/qnx6/normalsound.2.0/normalsound_cv.c +++ b/qnx6/normalsound.2.0/normalsound_cv.c @@ -323,7 +323,7 @@ int main(int argc,char *argv[]) total_scan_usecs = (scnsc-snd_sc)*1E6 + scnus; total_integration_usecs = total_scan_usecs/beams; def_intt_sc = total_integration_usecs/1E6; - def_intt_us = total_integration_usecs - (intsc*1e6); + def_intt_us = total_integration_usecs - (def_intt_sc*1e6); intsc = def_intt_sc; intus = def_intt_us; diff --git a/qnx6/normalsound.2.0/normalsound_fh.c b/qnx6/normalsound.2.0/normalsound_fh.c index 78849f0..f97b383 100644 --- a/qnx6/normalsound.2.0/normalsound_fh.c +++ b/qnx6/normalsound.2.0/normalsound_fh.c @@ -334,7 +334,7 @@ int main(int argc,char *argv[]) total_scan_usecs = (scnsc-snd_sc)*1E6 + scnus; total_integration_usecs = total_scan_usecs/beams; def_intt_sc = total_integration_usecs/1E6; - def_intt_us = total_integration_usecs - (intsc*1e6); + def_intt_us = total_integration_usecs - (def_intt_sc*1e6); intsc = def_intt_sc; intus = def_intt_us; From bbfe46c9433e212ce08abda1595b01f019910973 Mon Sep 17 00:00:00 2001 From: egthomas Date: Sat, 28 Aug 2021 10:11:07 -0400 Subject: [PATCH 06/22] Modifying QNX4 and QNX6 sounding mode integration time for 20-beam radars --- qnx4/interleavesound.1.00/interleavesound.c | 2 +- qnx4/normalsound.3.00/normalsound.c | 2 +- qnx6/interleavesound.1.0/interleavesound_cv.c | 2 +- qnx6/interleavesound.1.0/interleavesound_fh.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index b844080..1e8b341 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -188,7 +188,7 @@ int main(int argc,char *argv[]) { else if (num_scans == 20) { int snd_bms_tot=10; int fast_intt_sc=2; - int fast_intt_us=500000; + int fast_intt_us=400000; int snd_intt_sc=1; int snd_intt_us=500000; } diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index 753ab41..3e55623 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -203,7 +203,7 @@ int main(int argc,char *argv[]) { int normal_intt_sc=5; int normal_intt_us=0; int fast_intt_sc=2; - int fast_intt_us=500000; + int fast_intt_us=400000; int snd_intt_sc=1; int snd_intt_us=500000; } diff --git a/qnx6/interleavesound.1.0/interleavesound_cv.c b/qnx6/interleavesound.1.0/interleavesound_cv.c index 64f16dc..42a6c3b 100644 --- a/qnx6/interleavesound.1.0/interleavesound_cv.c +++ b/qnx6/interleavesound.1.0/interleavesound_cv.c @@ -154,7 +154,7 @@ int main(int argc,char *argv[]) { int snd_freq; int snd_frqrng=100; int fast_intt_sc=2; - int fast_intt_us=500000; + int fast_intt_us=400000; int snd_intt_sc=1; int snd_intt_us=500000; float snd_time, snd_intt, time_needed=1.25; diff --git a/qnx6/interleavesound.1.0/interleavesound_fh.c b/qnx6/interleavesound.1.0/interleavesound_fh.c index c5471af..d09051b 100644 --- a/qnx6/interleavesound.1.0/interleavesound_fh.c +++ b/qnx6/interleavesound.1.0/interleavesound_fh.c @@ -161,7 +161,7 @@ int main(int argc,char *argv[]) { int snd_freq; int snd_frqrng=100; int fast_intt_sc=2; - int fast_intt_us=500000; + int fast_intt_us=400000; int snd_intt_sc=1; int snd_intt_us=500000; float snd_time, snd_intt, time_needed=1.25; From 9b3dce1257602aac105330e61c026e3f107eba7d Mon Sep 17 00:00:00 2001 From: egthomas Date: Tue, 31 Aug 2021 10:52:07 -0400 Subject: [PATCH 07/22] Fixing normalsound_cv for site-specific bugs --- qnx6/normalsound.2.0/normalsound_cv.c | 31 +++++++++++---------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/qnx6/normalsound.2.0/normalsound_cv.c b/qnx6/normalsound.2.0/normalsound_cv.c index bb1c4e6..e9d74f3 100644 --- a/qnx6/normalsound.2.0/normalsound_cv.c +++ b/qnx6/normalsound.2.0/normalsound_cv.c @@ -141,19 +141,19 @@ int main(int argc,char *argv[]) unsigned char hlp=0; if (debug) { - printf("Size of int %ld\n",sizeof(int)); - printf("Size of long %ld\n",sizeof(long)); - printf("Size of long long %ld\n",sizeof(long long)); - printf("Size of struct TRTimes %ld\n",sizeof(struct TRTimes)); - printf("Size of struct SeqPRM %ld\n",sizeof(struct SeqPRM)); - printf("Size of struct RosData %ld\n",sizeof(struct RosData)); - printf("Size of struct DataPRM %ld\n",sizeof(struct DataPRM)); - printf("Size of Struct ControlPRM %ld\n",sizeof(struct ControlPRM)); - printf("Size of Struct RadarPRM %ld\n",sizeof(struct RadarPRM)); - printf("Size of Struct ROSMsg %ld\n",sizeof(struct ROSMsg)); - printf("Size of Struct CLRFreq %ld\n",sizeof(struct CLRFreqPRM)); - printf("Size of Struct TSGprm %ld\n",sizeof(struct TSGprm)); - printf("Size of Struct SiteSettings %ld\n",sizeof(struct SiteSettings)); + printf("Size of int %u\n",sizeof(int)); + printf("Size of long %u\n",sizeof(long)); + printf("Size of long long %u\n",sizeof(long long)); + printf("Size of struct TRTimes %u\n",sizeof(struct TRTimes)); + printf("Size of struct SeqPRM %u\n",sizeof(struct SeqPRM)); + printf("Size of struct RosData %u\n",sizeof(struct RosData)); + printf("Size of struct DataPRM %u\n",sizeof(struct DataPRM)); + printf("Size of Struct ControlPRM %u\n",sizeof(struct ControlPRM)); + printf("Size of Struct RadarPRM %u\n",sizeof(struct RadarPRM)); + printf("Size of Struct ROSMsg %u\n",sizeof(struct ROSMsg)); + printf("Size of Struct CLRFreq %u\n",sizeof(struct CLRFreqPRM)); + printf("Size of Struct TSGprm %u\n",sizeof(struct TSGprm)); + printf("Size of Struct SiteSettings %u\n",sizeof(struct SiteSettings)); } @@ -353,8 +353,6 @@ int main(int argc,char *argv[]) printf("Entering Scan loop Station ID: %s %d\n",ststr,stid); do { -// if (timed) gettimeofday(&t0,NULL); - printf("Preparing SiteTimeSeq Station ID: %s %d\n",ststr,stid); tsgid=SiteTimeSeq(ptab); @@ -392,8 +390,6 @@ int main(int argc,char *argv[]) do { -// if (timed) gettimeofday(&t1,NULL); - TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); if (OpsDayNight()==1) { @@ -425,7 +421,6 @@ int main(int argc,char *argv[]) sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); ErrLog(errlog.sock,progname,logtxt); -// if (timed) gettimeofday(&t2,NULL); nave=SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt,"Integration error:%d",nave); From a77178015a1cb9ca56f19a4d636d63825ea7cb94 Mon Sep 17 00:00:00 2001 From: egthomas Date: Tue, 31 Aug 2021 10:52:55 -0400 Subject: [PATCH 08/22] Fixing normalsound_cv for more site-specific bugs --- qnx6/normalsound.2.0/normalsound_cv.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/qnx6/normalsound.2.0/normalsound_cv.c b/qnx6/normalsound.2.0/normalsound_cv.c index e9d74f3..180a927 100644 --- a/qnx6/normalsound.2.0/normalsound_cv.c +++ b/qnx6/normalsound.2.0/normalsound_cv.c @@ -463,10 +463,6 @@ int main(int argc,char *argv[]) for (n=0;n Date: Tue, 31 Aug 2021 13:59:55 -0400 Subject: [PATCH 09/22] Updating normalsound and interleavesound code for optimization and more robust error logging --- qnx4/interleavesound.1.00/interleavesound.c | 25 ++++--- .../interleavesound_stereo.c | 2 + qnx4/normalsound.3.00/normalsound.c | 25 ++++--- qnx6/interleavesound.1.0/interleavesound_cv.c | 43 ++++++------ qnx6/interleavesound.1.0/interleavesound_fh.c | 46 ++++++------- qnx6/normalsound.2.0/normalsound_cv.c | 30 +++++--- qnx6/normalsound.2.0/normalsound_fh.c | 69 +++++++++---------- .../interleavesound.1.00/interleavesound.c | 5 +- 8 files changed, 133 insertions(+), 112 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 307637b..946f6a4 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -120,7 +120,7 @@ int main(int argc,char *argv[]) { int skip; int cnt=0; - int def_nrang=75; + int def_nrang=0; unsigned char discretion=0; @@ -242,7 +242,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = def_nrang; + nrang = 75; rsep = 45; txpl = 300; /* recalculated below with rsep */ frang = 180; @@ -373,7 +373,6 @@ int main(int argc,char *argv[]) { SiteSetFreq(tfreq); sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); - ErrLog(errlog,progname,logtxt); tsgid=SiteTimeSeq(ptab); @@ -431,7 +430,7 @@ int main(int argc,char *argv[]) { } } while (1); - ErrLog(errlog,progname,"Waiting for scan boundary."); + if (exitpoll == 0) { /* In here comes the sounder code */ @@ -441,15 +440,17 @@ int main(int argc,char *argv[]) { /* set the xcf variable to do cross-correlations (AOA) */ xcf = 1; + /* set the sounding mode integration time and number of ranges */ + intsc = snd_intt_sc; + intus = snd_intt_us; + nrang = snd_nrang; + /* we have time until the end of the minute to do sounding */ /* minus a safety factor given in time_needed */ TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); snd_time = 60.0 - (sc + us*1e-6); while (snd_time-snd_intt > time_needed) { - intsc = snd_intt_sc; - intus = snd_intt_us; - nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -463,14 +464,15 @@ int main(int argc,char *argv[]) { ErrLog(errlog,progname,"Setting SND beam."); SiteSetIntt(intsc,intus); SiteSetBeam(bmnum); + ErrLog(errlog, progname, "Doing SND clear frequency search."); if (SiteFCLR(snd_freq, snd_freq + snd_frqrng)==FREQ_LOCAL) ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); SiteSetFreq(tfreq); -/* + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); ErrLog(errlog, progname, logtxt); -*/ + tsgid = SiteTimeSeq(ptab); nave = SiteIntegrate(lags); if (nave < 0) { @@ -552,9 +554,12 @@ int main(int argc,char *argv[]) { } /* now wait for the next interleavescan */ + ErrLog(errlog,progname,"Waiting for scan boundary."); + intsc = fast_intt_sc; intus = fast_intt_us; nrang = def_nrang; + OpsWaitBoundary(scnsc,scnus); } @@ -613,6 +618,8 @@ void write_snd_record(char *progname, struct RadarParm *prm, struct FitData *fit status = SndFwrite(out, prm, fit); if (status == -1) { ErrLog(errlog,progname,"Error writing sounding record."); + } else { + ErrLog(errlog,progname,"Sounding record succesfully written."); } fclose(out); diff --git a/qnx4/interleavesound_stereo.1.00/interleavesound_stereo.c b/qnx4/interleavesound_stereo.1.00/interleavesound_stereo.c index dffd575..662322f 100644 --- a/qnx4/interleavesound_stereo.1.00/interleavesound_stereo.c +++ b/qnx4/interleavesound_stereo.1.00/interleavesound_stereo.c @@ -1007,6 +1007,8 @@ void write_snd_record(char *progname, struct RadarParm *prm, struct FitData *fit status = SndFwrite(out, prm, fit); if (status == -1) { ErrLog(errlog,progname,"Error writing sounding record."); + } else { + ErrLog(errlog,progname,"Sounding record succesfully written."); } fclose(out); diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index c88457a..c9762ea 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -145,7 +145,7 @@ int main(int argc,char *argv[]) { int skip; int cnt=0; - int def_nrang=75; + int def_nrang=0; unsigned char fast=0; unsigned char discretion=0; @@ -256,7 +256,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = def_nrang; + nrang = 75; rsep = 45; txpl = 300; /* recalculated below with rsep */ frang = 180; @@ -393,7 +393,6 @@ int main(int argc,char *argv[]) { SiteSetFreq(tfreq); sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); - ErrLog(errlog,progname,logtxt); tsgid=SiteTimeSeq(ptab); @@ -442,7 +441,7 @@ int main(int argc,char *argv[]) { else bmnum++; } while (1); - ErrLog(errlog,progname,"Waiting for scan boundary."); + if (exitpoll == 0) { /* In here comes the sounder code */ @@ -452,15 +451,17 @@ int main(int argc,char *argv[]) { /* set the xcf variable to do cross-correlations (AOA) */ xcf = 1; + /* set the sounding mode integration time and number of ranges */ + intsc = snd_intt_sc; + intus = snd_intt_us; + nrang = snd_nrang; + /* we have time until the end of the minute to do sounding */ /* minus a safety factor given in time_needed */ TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); snd_time = 60.0 - (sc + us*1e-6); while (snd_time-snd_intt > time_needed) { - intsc = snd_intt_sc; - intus = snd_intt_us; - nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -474,14 +475,15 @@ int main(int argc,char *argv[]) { ErrLog(errlog,progname,"Setting SND beam."); SiteSetIntt(intsc,intus); SiteSetBeam(bmnum); + ErrLog(errlog, progname, "Doing SND clear frequency search."); if (SiteFCLR(snd_freq, snd_freq + snd_frqrng)==FREQ_LOCAL) ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); SiteSetFreq(tfreq); -/* + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); ErrLog(errlog, progname, logtxt); -*/ + tsgid = SiteTimeSeq(ptab); nave = SiteIntegrate(lags); if (nave < 0) { @@ -549,6 +551,8 @@ int main(int argc,char *argv[]) { } /* now wait for the next normalscan */ + ErrLog(errlog,progname,"Waiting for scan boundary."); + if (fast) { intsc = fast_intt_sc; intus = fast_intt_us; @@ -557,6 +561,7 @@ int main(int argc,char *argv[]) { intus = normal_intt_us; } nrang = def_nrang; + OpsWaitBoundary(scnsc,scnus); } @@ -613,6 +618,8 @@ void write_snd_record(char *progname, struct RadarParm *prm, struct FitData *fit status = SndFwrite(out, prm, fit); if (status == -1) { ErrLog(errlog,progname,"Error writing sounding record."); + } else { + ErrLog(errlog,progname,"Sounding record succesfully written."); } fclose(out); diff --git a/qnx6/interleavesound.1.0/interleavesound_cv.c b/qnx6/interleavesound.1.0/interleavesound_cv.c index 2893bc4..72ce9f9 100644 --- a/qnx6/interleavesound.1.0/interleavesound_cv.c +++ b/qnx6/interleavesound.1.0/interleavesound_cv.c @@ -109,7 +109,6 @@ int main(int argc,char *argv[]) { char tempLog[40]; int exitpoll=0; - int scannowait=0; int scnsc=60; int scnus=0; @@ -121,7 +120,7 @@ int main(int argc,char *argv[]) { int status=0; int fixfrq=0; - int def_nrang=100; + int def_nrang=0; /* new variables for dynamically creating beam sequences */ int *bms; /* scanning beams */ @@ -177,7 +176,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = def_nrang; + nrang = 100; rsep = 45; txpl = 300; /* note: recomputed below */ dfrq = 10200; @@ -250,9 +249,6 @@ int main(int argc,char *argv[]) { fprintf(stderr,"Sounder File: %s not found\n",snd_filename); } - /* end of main Dartmouth mods */ - /* not sure if -nrang commandline option works */ - if ((errlog.sock=TCPIPMsgOpen(errlog.host,errlog.port))==-1) { fprintf(stderr,"Error connecting to error log.\n"); } @@ -262,14 +258,9 @@ int main(int argc,char *argv[]) { for (n=0;n time_needed) { - intsc = snd_intt_sc; - intus = snd_intt_us; - nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -470,19 +464,19 @@ int main(int argc,char *argv[]) { snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ - tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); SiteStartIntt(intsc,intus); + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); ErrLog(errlog.sock,progname, logtxt); tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); -/* - * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - * ErrLog(errlog.sock, progname, logtxt); - * */ + + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -563,10 +557,13 @@ int main(int argc,char *argv[]) { } /* now wait for the next interleavescan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + intsc = fast_intt_sc; intus = fast_intt_us; nrang = def_nrang; - if (scannowait==0) SiteEndScan(scnsc,scnus,5000); + + SiteEndScan(scnsc,scnus,5000); } } while (exitpoll==0); @@ -651,6 +648,8 @@ void write_snd_record(char *progname, struct RadarParm *prm, struct FitData *fit status = SndFwrite(out, prm, fit); if (status == -1) { ErrLog(errlog.sock,progname,"Error writing sounding record."); + } else { + ErrLog(errlog.sock,progname,"Sounding record successfully written."); } fclose(out); diff --git a/qnx6/interleavesound.1.0/interleavesound_fh.c b/qnx6/interleavesound.1.0/interleavesound_fh.c index 1273b85..d5c633a 100644 --- a/qnx6/interleavesound.1.0/interleavesound_fh.c +++ b/qnx6/interleavesound.1.0/interleavesound_fh.c @@ -116,7 +116,6 @@ int main(int argc,char *argv[]) { char tempLog[40]; int exitpoll=0; - int scannowait=0; int scnsc=60; int scnus=0; @@ -128,7 +127,7 @@ int main(int argc,char *argv[]) { int status=0; int fixfrq=0; - int def_nrang=100; + int def_nrang=0; /* new variables for dynamically creating beam sequences */ int *bms; /* scanning beams */ @@ -184,7 +183,7 @@ int main(int argc,char *argv[]) { mplgs = 23; mpinc = 1500; dmpinc = 1500; - nrang = def_nrang; + nrang = 100; rsep = 45; txpl = 300; /* note: recomputed below */ dfrq = 10200; @@ -263,9 +262,6 @@ int main(int argc,char *argv[]) { fprintf(stderr,"Sounder File: %s not found\n",snd_filename); } - /* end of main Dartmouth mods */ - /* not sure if -nrang commandline option works */ - if ((errlog.sock=TCPIPMsgOpen(errlog.host,errlog.port))==-1) { fprintf(stderr,"Error connecting to error log.\n"); } @@ -275,16 +271,8 @@ int main(int argc,char *argv[]) { for (n=0;n time_needed) { - intsc = snd_intt_sc; - intus = snd_intt_us; - nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -488,19 +479,19 @@ int main(int argc,char *argv[]) { snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ - tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); SiteStartIntt(intsc,intus); + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); ErrLog(errlog.sock,progname, logtxt); tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); -/* - * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - * ErrLog(errlog.sock, progname, logtxt); - * */ + + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -581,10 +572,13 @@ int main(int argc,char *argv[]) { } /* now wait for the next interleavescan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + intsc = fast_intt_sc; intus = fast_intt_us; nrang = def_nrang; - if (scannowait==0) SiteEndScan(scnsc,scnus); + + SiteEndScan(scnsc,scnus); } } while (exitpoll==0); @@ -670,6 +664,8 @@ void write_snd_record(char *progname, struct RadarParm *prm, struct FitData *fit status = SndFwrite(out, prm, fit); if (status == -1) { ErrLog(errlog.sock,progname,"Error writing sounding record."); + } else { + ErrLog(errlog.sock,progname,"Sounding record successfully written."); } fclose(out); diff --git a/qnx6/normalsound.2.0/normalsound_cv.c b/qnx6/normalsound.2.0/normalsound_cv.c index 180a927..43fb674 100644 --- a/qnx6/normalsound.2.0/normalsound_cv.c +++ b/qnx6/normalsound.2.0/normalsound_cv.c @@ -116,7 +116,6 @@ int main(int argc,char *argv[]) char logtxt[1024]; int exitpoll=0; - int scannowait=0; int scnsc=120; /* total scan period in seconds */ int scnus=0; @@ -481,7 +480,6 @@ int main(int argc,char *argv[]) } while (1); - ErrLog(errlog.sock,progname,"Waiting for scan boundary."); if (exitpoll==0) { /* In here comes the sounder code */ @@ -491,15 +489,20 @@ int main(int argc,char *argv[]) /* set the xcf variable to do cross-correlations (AOA) */ xcf = 1; + /* set the sounding mode integration time and number of ranges */ + intsc = snd_intt_sc; + intus = snd_intt_us; + nrang = snd_nrang; + + /* make a new timing sequence for the sounding */ + tsgid = SiteTimeSeq(ptab); + /* we have time until the end of the minute to do sounding */ /* minus a safety factor given in time_needed */ TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); snd_time = 60.0 - (sc + us*1e-6); while (snd_time-snd_intt > time_needed) { - intsc = snd_intt_sc; - intus = snd_intt_us; - nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -508,19 +511,19 @@ int main(int argc,char *argv[]) snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ - tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); SiteStartIntt(intsc,intus); + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); ErrLog(errlog.sock,progname, logtxt); tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); -/* - * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - * ErrLog(errlog.sock, progname, logtxt); - * */ + + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -601,10 +604,13 @@ int main(int argc,char *argv[]) } /* now wait for the next normalscan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + intsc = def_intt_sc; intus = def_intt_us; nrang = def_nrang; - if (scannowait==0) SiteEndScan(scnsc,scnus,5000); + + SiteEndScan(scnsc,scnus,5000); } } while (exitpoll == 0); @@ -692,6 +698,8 @@ void write_snd_record(char *progname, struct RadarParm *prm, struct FitData *fit status = SndFwrite(out, prm, fit); if (status == -1) { ErrLog(errlog.sock,progname,"Error writing sounding record."); + } else { + ErrLog(errlog.sock,progname,"Sounding record successfully written."); } fclose(out); diff --git a/qnx6/normalsound.2.0/normalsound_fh.c b/qnx6/normalsound.2.0/normalsound_fh.c index 3766172..c4fb354 100644 --- a/qnx6/normalsound.2.0/normalsound_fh.c +++ b/qnx6/normalsound.2.0/normalsound_fh.c @@ -119,7 +119,6 @@ int main(int argc,char *argv[]) char logtxt[1024]; int exitpoll=0; - int scannowait=0; int scnsc=120; /* total scan period in seconds */ int scnus=0; @@ -144,19 +143,19 @@ int main(int argc,char *argv[]) unsigned char hlp=0; if (debug) { - printf("Size of int %ld\n",sizeof(int)); - printf("Size of long %ld\n",sizeof(long)); - printf("Size of long long %ld\n",sizeof(long long)); - printf("Size of struct TRTimes %ld\n",sizeof(struct TRTimes)); - printf("Size of struct SeqPRM %ld\n",sizeof(struct SeqPRM)); - printf("Size of struct RosData %ld\n",sizeof(struct RosData)); - printf("Size of struct DataPRM %ld\n",sizeof(struct DataPRM)); - printf("Size of Struct ControlPRM %ld\n",sizeof(struct ControlPRM)); - printf("Size of Struct RadarPRM %ld\n",sizeof(struct RadarPRM)); - printf("Size of Struct ROSMsg %ld\n",sizeof(struct ROSMsg)); - printf("Size of Struct CLRFreq %ld\n",sizeof(struct CLRFreqPRM)); - printf("Size of Struct TSGprm %ld\n",sizeof(struct TSGprm)); - printf("Size of Struct SiteSettings %ld\n",sizeof(struct SiteSettings)); + printf("Size of int %u\n",sizeof(int)); + printf("Size of long %u\n",sizeof(long)); + printf("Size of long long %u\n",sizeof(long long)); + printf("Size of struct TRTimes %u\n",sizeof(struct TRTimes)); + printf("Size of struct SeqPRM %u\n",sizeof(struct SeqPRM)); + printf("Size of struct RosData %u\n",sizeof(struct RosData)); + printf("Size of struct DataPRM %u\n",sizeof(struct DataPRM)); + printf("Size of Struct ControlPRM %u\n",sizeof(struct ControlPRM)); + printf("Size of Struct RadarPRM %u\n",sizeof(struct RadarPRM)); + printf("Size of Struct ROSMsg %u\n",sizeof(struct ROSMsg)); + printf("Size of Struct CLRFreq %u\n",sizeof(struct CLRFreqPRM)); + printf("Size of Struct TSGprm %u\n",sizeof(struct TSGprm)); + printf("Size of Struct SiteSettings %u\n",sizeof(struct SiteSettings)); } @@ -205,6 +204,7 @@ int main(int argc,char *argv[]) OptionAdd(&opt, "di", 'x', &discretion); OptionAdd(&opt, "frang", 'i', &frang); OptionAdd(&opt, "rsep", 'i', &rsep); + OptionAdd(&opt, "nrang", 'i', &nrang); OptionAdd(&opt, "dt", 'i', &day); OptionAdd(&opt, "nt", 'i', &night); OptionAdd(&opt, "df", 'i', &dfrq); @@ -289,9 +289,7 @@ int main(int argc,char *argv[]) OpsStart(ststr); - /* status=SiteBuild(stid); */ status=SiteBuild(ststr,NULL); /* second argument is version string */ - if (status==-1) { fprintf(stderr,"Could not identify station.\n"); exit(1); @@ -364,8 +362,6 @@ int main(int argc,char *argv[]) printf("Entering Scan loop Station ID: %s %d\n",ststr,stid); do { -// if (timed) gettimeofday(&t0,NULL); - printf("Preparing SiteTimeSeq Station ID: %s %d\n",ststr,stid); tsgid=SiteTimeSeq(ptab); @@ -403,8 +399,6 @@ int main(int argc,char *argv[]) do { -// if (timed) gettimeofday(&t1,NULL); - TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); if (OpsDayNight()==1) { @@ -436,7 +430,6 @@ int main(int argc,char *argv[]) sprintf(logtxt,"Transmitting on: %d (Noise=%g)",tfreq,noise); ErrLog(errlog.sock,progname,logtxt); -// if (timed) gettimeofday(&t2,NULL); nave=SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt,"Integration error:%d",nave); @@ -479,10 +472,6 @@ int main(int argc,char *argv[]) for (n=0;n time_needed) { - intsc = snd_intt_sc; - intus = snd_intt_us; - nrang = snd_nrang; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; @@ -528,19 +521,19 @@ int main(int argc,char *argv[]) snd_freq = snd_freqs[snd_freq_cnt]; /* the scanning code is here */ - tsgid = SiteTimeSeq(ptab); sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); ErrLog(errlog.sock,progname,logtxt); ErrLog(errlog.sock,progname,"Setting SND beam."); SiteStartIntt(intsc,intus); + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); ErrLog(errlog.sock,progname, logtxt); tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); -/* - * sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - * ErrLog(errlog.sock, progname, logtxt); - * */ + + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + nave = SiteIntegrate(lags); if (nave < 0) { sprintf(logtxt, "SND integration error: %d", nave); @@ -621,10 +614,13 @@ int main(int argc,char *argv[]) } /* now wait for the next normalscan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + intsc = def_intt_sc; intus = def_intt_us; nrang = def_nrang; - if (scannowait==0) SiteEndScan(scnsc,scnus); + + SiteEndScan(scnsc,scnus); } } while (exitpoll == 0); @@ -646,6 +642,7 @@ void usage(void) printf(" -di : indicates running during discretionary time\n"); printf(" -frang int : delay to first range (km) [180]\n"); printf(" -rsep int : range separation (km) [45]\n"); + printf(" -nrang int : number of range gates [100]\n"); printf(" -dt int : hour when day freq. is used [site.c]\n"); printf(" -nt int : hour when night freq. is used [site.c]\n"); printf(" -df int : daytime frequency (kHz) [site.c]\n"); @@ -712,6 +709,8 @@ void write_snd_record(char *progname, struct RadarParm *prm, struct FitData *fit status = SndFwrite(out, prm, fit); if (status == -1) { ErrLog(errlog.sock,progname,"Error writing sounding record."); + } else { + ErrLog(errlog.sock,progname,"Sounding record successfully written."); } fclose(out); diff --git a/ros.1.02/interleavesound.1.00/interleavesound.c b/ros.1.02/interleavesound.1.00/interleavesound.c index ec46469..2f98b6a 100644 --- a/ros.1.02/interleavesound.1.00/interleavesound.c +++ b/ros.1.02/interleavesound.1.00/interleavesound.c @@ -418,6 +418,7 @@ void main(int argc,char *argv[]) { } } while (1); + if (exit_poll==0) { /* set the "sounder mode" scan variable */ scan=-2; @@ -425,6 +426,9 @@ void main(int argc,char *argv[]) { /* set the xcf variable to do cross-correlations (AOA) */ xcf=1; + /* set the sounding mode integration time and number of ranges */ + intt = snd_intt; + /* setup the sounder mode integration time */ /* determine the number of seconds we have for this mode */ /* subtract the current sec from 59 so we have at least */ @@ -433,7 +437,6 @@ void main(int argc,char *argv[]) { snd_time = 60.0 - (sec+msec/1000.); while(snd_time-(float)snd_intt > time_needed) { - intt = snd_intt; /* set the beam */ bmnum = snd_bms[snd_bm_cnt] + odd_beams; From c20a35dda00b27b12a809d31b6d6f9191e81151f Mon Sep 17 00:00:00 2001 From: egthomas Date: Tue, 7 Sep 2021 12:36:50 -0400 Subject: [PATCH 10/22] Modifying QNX4 and QNX6 sounding code errlog messages to put line break in more sensible place at end of sounding loop rather than midway through --- qnx4/interleavesound.1.00/interleavesound.c | 4 ++-- qnx4/normalsound.3.00/normalsound.c | 4 ++-- qnx6/interleavesound.1.0/interleavesound_cv.c | 4 ++-- qnx6/interleavesound.1.0/interleavesound_fh.c | 4 ++-- qnx6/normalsound.2.0/normalsound_cv.c | 4 ++-- qnx6/normalsound.2.0/normalsound_fh.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 946f6a4..069c31f 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -505,7 +505,7 @@ int main(int argc,char *argv[]) { /* Only send these to echo_data; otherwise they get written to the data files */ RMsgSndSend(tlist[0], &msg); - sprintf(logtxt, "SBC: %d SFC: %d\n", snd_bm_cnt, snd_freq_cnt); + sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); ErrLog(errlog, progname, logtxt); /* set the scan variable for the sounding mode data file only */ @@ -518,7 +518,7 @@ int main(int argc,char *argv[]) { /* save the sounding mode data */ write_snd_record(progname, &prm, &fit); - ErrLog(errlog, progname, "Polling SND for exit."); + ErrLog(errlog, progname, "Polling SND for exit.\n"); exitpoll=RadarShell(sid,&rstable); if (exitpoll !=0) break; diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index c9762ea..58a2791 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -516,7 +516,7 @@ int main(int argc,char *argv[]) { /* Only send these to echo_data; otherwise they get written to the data files */ RMsgSndSend(tlist[0], &msg); - sprintf(logtxt, "SBC: %d SFC: %d\n", snd_bm_cnt, snd_freq_cnt); + sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); ErrLog(errlog, progname, logtxt); /* set the scan variable for the sounding mode data file only */ @@ -529,7 +529,7 @@ int main(int argc,char *argv[]) { /* save the sounding mode data */ write_snd_record(progname, &prm, &fit); - ErrLog(errlog, progname, "Polling SND for exit."); + ErrLog(errlog, progname, "Polling SND for exit.\n"); exitpoll=RadarShell(sid,&rstable); if (exitpoll !=0) break; diff --git a/qnx6/interleavesound.1.0/interleavesound_cv.c b/qnx6/interleavesound.1.0/interleavesound_cv.c index 72ce9f9..4d502bb 100644 --- a/qnx6/interleavesound.1.0/interleavesound_cv.c +++ b/qnx6/interleavesound.1.0/interleavesound_cv.c @@ -523,7 +523,7 @@ int main(int argc,char *argv[]) { if (msg.data[n].type==FIT_TYPE) free(msg.ptr[n]); } - sprintf(logtxt, "SBC: %d SFC: %d\n", snd_bm_cnt, snd_freq_cnt); + sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); ErrLog(errlog.sock, progname, logtxt); /* set the scan variable for the sounding mode data file only */ @@ -536,7 +536,7 @@ int main(int argc,char *argv[]) { /* save the sounding mode data */ write_snd_record(progname, prm, fit); - ErrLog(errlog.sock, progname, "Polling SND for exit."); + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); if (exitpoll !=0) break; /* check for the end of a beam loop */ diff --git a/qnx6/interleavesound.1.0/interleavesound_fh.c b/qnx6/interleavesound.1.0/interleavesound_fh.c index d5c633a..c722dac 100644 --- a/qnx6/interleavesound.1.0/interleavesound_fh.c +++ b/qnx6/interleavesound.1.0/interleavesound_fh.c @@ -538,7 +538,7 @@ int main(int argc,char *argv[]) { if (msg.data[n].type==FIT_TYPE) free(msg.ptr[n]); } - sprintf(logtxt, "SBC: %d SFC: %d\n", snd_bm_cnt, snd_freq_cnt); + sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); ErrLog(errlog.sock, progname, logtxt); /* set the scan variable for the sounding mode data file only */ @@ -551,7 +551,7 @@ int main(int argc,char *argv[]) { /* save the sounding mode data */ write_snd_record(progname, prm, fit); - ErrLog(errlog.sock, progname, "Polling SND for exit."); + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); if (exitpoll !=0) break; /* check for the end of a beam loop */ diff --git a/qnx6/normalsound.2.0/normalsound_cv.c b/qnx6/normalsound.2.0/normalsound_cv.c index 43fb674..6a151e8 100644 --- a/qnx6/normalsound.2.0/normalsound_cv.c +++ b/qnx6/normalsound.2.0/normalsound_cv.c @@ -570,7 +570,7 @@ int main(int argc,char *argv[]) if (msg.data[n].type==FIT_TYPE) free(msg.ptr[n]); } - sprintf(logtxt, "SBC: %d SFC: %d\n", snd_bm_cnt, snd_freq_cnt); + sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); ErrLog(errlog.sock, progname, logtxt); /* set the scan variable for the sounding mode data file only */ @@ -583,7 +583,7 @@ int main(int argc,char *argv[]) /* save the sounding mode data */ write_snd_record(progname, prm, fit); - ErrLog(errlog.sock, progname, "Polling SND for exit."); + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); if (exitpoll !=0) break; /* check for the end of a beam loop */ diff --git a/qnx6/normalsound.2.0/normalsound_fh.c b/qnx6/normalsound.2.0/normalsound_fh.c index c4fb354..37b4f96 100644 --- a/qnx6/normalsound.2.0/normalsound_fh.c +++ b/qnx6/normalsound.2.0/normalsound_fh.c @@ -580,7 +580,7 @@ int main(int argc,char *argv[]) if (msg.data[n].type==FIT_TYPE) free(msg.ptr[n]); } - sprintf(logtxt, "SBC: %d SFC: %d\n", snd_bm_cnt, snd_freq_cnt); + sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); ErrLog(errlog.sock, progname, logtxt); /* set the scan variable for the sounding mode data file only */ @@ -593,7 +593,7 @@ int main(int argc,char *argv[]) /* save the sounding mode data */ write_snd_record(progname, prm, fit); - ErrLog(errlog.sock, progname, "Polling SND for exit."); + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); if (exitpoll !=0) break; /* check for the end of a beam loop */ From 0d8bac7e0c89aa943dc527b6db9feae800126109 Mon Sep 17 00:00:00 2001 From: egthomas Date: Wed, 8 Sep 2021 13:20:05 -0400 Subject: [PATCH 11/22] Modifying QNX6 sounding code to remove unused exitpoll checks --- qnx6/interleavesound.1.0/interleavesound_cv.c | 204 +++++++++-------- qnx6/interleavesound.1.0/interleavesound_fh.c | 204 +++++++++-------- qnx6/normalsound.2.0/normalsound_cv.c | 205 +++++++++--------- qnx6/normalsound.2.0/normalsound_fh.c | 205 +++++++++--------- 4 files changed, 396 insertions(+), 422 deletions(-) diff --git a/qnx6/interleavesound.1.0/interleavesound_cv.c b/qnx6/interleavesound.1.0/interleavesound_cv.c index 4d502bb..8d9230d 100644 --- a/qnx6/interleavesound.1.0/interleavesound_cv.c +++ b/qnx6/interleavesound.1.0/interleavesound_cv.c @@ -108,8 +108,6 @@ int main(int argc,char *argv[]) { char logtxt[1024]=""; char tempLog[40]; - int exitpoll=0; - int scnsc=60; int scnus=0; @@ -425,7 +423,6 @@ int main(int argc,char *argv[]) { RadarShell(shell.sock,&rstable); - if (exitpoll !=0 ) break; scan = 0; if (skip == (nintgs-1)) break; skip++; @@ -434,139 +431,136 @@ int main(int argc,char *argv[]) { } while (1); - if (exitpoll==0) { - /* In here comes the sounder code */ - /* set the "sounder mode" scan variable */ - scan = -2; + /* In here comes the sounder code */ + /* set the "sounder mode" scan variable */ + scan = -2; - /* set the xcf variable to do cross-correlations (AOA) */ - xcf = 1; + /* set the xcf variable to do cross-correlations (AOA) */ + xcf = 1; - /* set the sounding mode integration time and number of ranges */ - intsc = snd_intt_sc; - intus = snd_intt_us; - nrang = snd_nrang; + /* set the sounding mode integration time and number of ranges */ + intsc = snd_intt_sc; + intus = snd_intt_us; + nrang = snd_nrang; - /* make a new timing sequence for the sounding */ - tsgid = SiteTimeSeq(ptab); + /* make a new timing sequence for the sounding */ + tsgid = SiteTimeSeq(ptab); - /* we have time until the end of the minute to do sounding */ - /* minus a safety factor given in time_needed */ - TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); - snd_time = 60.0 - (sc + us*1e-6); + /* we have time until the end of the minute to do sounding */ + /* minus a safety factor given in time_needed */ + TimeReadClock(&yr,&mo,&dy,&hr,&mt,&sc,&us); + snd_time = 60.0 - (sc + us*1e-6); - while (snd_time-snd_intt > time_needed) { + while (snd_time-snd_intt > time_needed) { - /* set the beam */ - bmnum = snd_bms[snd_bm_cnt] + odd_beams; + /* set the beam */ + bmnum = snd_bms[snd_bm_cnt] + odd_beams; - /* snd_freq will be an array of frequencies to step through */ - snd_freq = snd_freqs[snd_freq_cnt]; + /* snd_freq will be an array of frequencies to step through */ + snd_freq = snd_freqs[snd_freq_cnt]; - /* the scanning code is here */ - sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); - ErrLog(errlog.sock,progname,logtxt); - ErrLog(errlog.sock,progname,"Setting SND beam."); - SiteStartIntt(intsc,intus); + /* the scanning code is here */ + sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); + ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock,progname,"Setting SND beam."); + SiteStartIntt(intsc,intus); - ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); - sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); + sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + ErrLog(errlog.sock,progname, logtxt); + tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); + + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + + nave = SiteIntegrate(lags); + if (nave < 0) { + sprintf(logtxt, "SND integration error: %d", nave); ErrLog(errlog.sock,progname, logtxt); - tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); + continue; + } + sprintf(logtxt,"Number of SND sequences: %d",nave); + ErrLog(errlog.sock,progname,logtxt); - sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - ErrLog(errlog.sock, progname, logtxt); + OpsBuildPrm(prm,ptab,lags); + OpsBuildIQ(iq,&badtr); + OpsBuildRaw(raw); + FitACF(prm,raw,fblk,fit); - nave = SiteIntegrate(lags); - if (nave < 0) { - sprintf(logtxt, "SND integration error: %d", nave); - ErrLog(errlog.sock,progname, logtxt); - continue; - } - sprintf(logtxt,"Number of SND sequences: %d",nave); - ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock, progname, "Sending SND messages."); + msg.num = 0; + msg.tsize = 0; - OpsBuildPrm(prm,ptab,lags); - OpsBuildIQ(iq,&badtr); - OpsBuildRaw(raw); - FitACF(prm,raw,fblk,fit); + tmpbuf=RadarParmFlatten(prm,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); - ErrLog(errlog.sock, progname, "Sending SND messages."); - msg.num = 0; - msg.tsize = 0; + tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); - tmpbuf=RadarParmFlatten(prm,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, + (unsigned char *) badtr,BADTR_TYPE,0); - tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); + RMsgSndAdd(&msg,strlen(sharedmemory)+1, + (unsigned char *) sharedmemory,IQS_TYPE,0); - RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, - (unsigned char *) badtr,BADTR_TYPE,0); + tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); - RMsgSndAdd(&msg,strlen(sharedmemory)+1, - (unsigned char *) sharedmemory,IQS_TYPE,0); + tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); - tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,(unsigned char *) progname,NME_TYPE,0); - tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); + RMsgSndSend(task[RT_TASK].sock,&msg); + for (n=0;nscan = 1; + } else { + prm->scan = 0; + } - sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); - ErrLog(errlog.sock, progname, logtxt); + /* save the sounding mode data */ + write_snd_record(progname, prm, fit); - /* set the scan variable for the sounding mode data file only */ - if ((bmnum == snd_bms[0]) && (snd_freq == snd_freqs[0])) { - prm->scan = 1; - } else { - prm->scan = 0; - } + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - /* save the sounding mode data */ - write_snd_record(progname, prm, fit); - - ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - if (exitpoll !=0) break; - - /* check for the end of a beam loop */ - snd_freq_cnt++; - if (snd_freq_cnt >= snd_freqs_tot) { - /* reset the freq counter and increment the beam counter */ - snd_freq_cnt = 0; - snd_bm_cnt++; - if (snd_bm_cnt >= snd_bms_tot) { - snd_bm_cnt = 0; - odd_beams = !odd_beams; - } + /* check for the end of a beam loop */ + snd_freq_cnt++; + if (snd_freq_cnt >= snd_freqs_tot) { + /* reset the freq counter and increment the beam counter */ + snd_freq_cnt = 0; + snd_bm_cnt++; + if (snd_bm_cnt >= snd_bms_tot) { + snd_bm_cnt = 0; + odd_beams = !odd_beams; } - - /* see if we have enough time for another go round */ - TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); - snd_time = 60.0 - (sc + us*1e-6); } - /* now wait for the next interleavescan */ - ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + /* see if we have enough time for another go round */ + TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); + snd_time = 60.0 - (sc + us*1e-6); + } - intsc = fast_intt_sc; - intus = fast_intt_us; - nrang = def_nrang; + /* now wait for the next interleavescan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); - SiteEndScan(scnsc,scnus,5000); - } + intsc = fast_intt_sc; + intus = fast_intt_us; + nrang = def_nrang; + + SiteEndScan(scnsc,scnus,5000); - } while (exitpoll==0); + } while (1); for (n=0;n time_needed) { + while (snd_time-snd_intt > time_needed) { - /* set the beam */ - bmnum = snd_bms[snd_bm_cnt] + odd_beams; + /* set the beam */ + bmnum = snd_bms[snd_bm_cnt] + odd_beams; - /* snd_freq will be an array of frequencies to step through */ - snd_freq = snd_freqs[snd_freq_cnt]; + /* snd_freq will be an array of frequencies to step through */ + snd_freq = snd_freqs[snd_freq_cnt]; - /* the scanning code is here */ - sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); - ErrLog(errlog.sock,progname,logtxt); - ErrLog(errlog.sock,progname,"Setting SND beam."); - SiteStartIntt(intsc,intus); + /* the scanning code is here */ + sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); + ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock,progname,"Setting SND beam."); + SiteStartIntt(intsc,intus); - ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); - sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); + sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + ErrLog(errlog.sock,progname, logtxt); + tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); + + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + + nave = SiteIntegrate(lags); + if (nave < 0) { + sprintf(logtxt, "SND integration error: %d", nave); ErrLog(errlog.sock,progname, logtxt); - tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); + continue; + } + sprintf(logtxt,"Number of SND sequences: %d",nave); + ErrLog(errlog.sock,progname,logtxt); - sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - ErrLog(errlog.sock, progname, logtxt); + OpsBuildPrm(prm,ptab,lags); + OpsBuildIQ(iq,&badtr); + OpsBuildRaw(raw); + FitACF(prm,raw,fblk,fit); - nave = SiteIntegrate(lags); - if (nave < 0) { - sprintf(logtxt, "SND integration error: %d", nave); - ErrLog(errlog.sock,progname, logtxt); - continue; - } - sprintf(logtxt,"Number of SND sequences: %d",nave); - ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock, progname, "Sending SND messages."); + msg.num = 0; + msg.tsize = 0; - OpsBuildPrm(prm,ptab,lags); - OpsBuildIQ(iq,&badtr); - OpsBuildRaw(raw); - FitACF(prm,raw,fblk,fit); + tmpbuf=RadarParmFlatten(prm,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); - ErrLog(errlog.sock, progname, "Sending SND messages."); - msg.num = 0; - msg.tsize = 0; + tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); - tmpbuf=RadarParmFlatten(prm,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, + (unsigned char *) badtr,BADTR_TYPE,0); - tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); + RMsgSndAdd(&msg,strlen(sharedmemory)+1, + (unsigned char *) sharedmemory,IQS_TYPE,0); - RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, - (unsigned char *) badtr,BADTR_TYPE,0); + tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); - RMsgSndAdd(&msg,strlen(sharedmemory)+1, - (unsigned char *) sharedmemory,IQS_TYPE,0); + tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); - tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,(unsigned char *) progname,NME_TYPE,0); - tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); + RMsgSndSend(task[RT_TASK].sock,&msg); + for (n=0;nscan = 1; + } else { + prm->scan = 0; + } - sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); - ErrLog(errlog.sock, progname, logtxt); + /* save the sounding mode data */ + write_snd_record(progname, prm, fit); - /* set the scan variable for the sounding mode data file only */ - if ((bmnum == snd_bms[0]) && (snd_freq == snd_freqs[0])) { - prm->scan = 1; - } else { - prm->scan = 0; - } + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - /* save the sounding mode data */ - write_snd_record(progname, prm, fit); - - ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - if (exitpoll !=0) break; - - /* check for the end of a beam loop */ - snd_freq_cnt++; - if (snd_freq_cnt >= snd_freqs_tot) { - /* reset the freq counter and increment the beam counter */ - snd_freq_cnt = 0; - snd_bm_cnt++; - if (snd_bm_cnt >= snd_bms_tot) { - snd_bm_cnt = 0; - odd_beams = !odd_beams; - } + /* check for the end of a beam loop */ + snd_freq_cnt++; + if (snd_freq_cnt >= snd_freqs_tot) { + /* reset the freq counter and increment the beam counter */ + snd_freq_cnt = 0; + snd_bm_cnt++; + if (snd_bm_cnt >= snd_bms_tot) { + snd_bm_cnt = 0; + odd_beams = !odd_beams; } - - /* see if we have enough time for another go round */ - TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); - snd_time = 60.0 - (sc + us*1e-6); } - /* now wait for the next interleavescan */ - ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + /* see if we have enough time for another go round */ + TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); + snd_time = 60.0 - (sc + us*1e-6); + } - intsc = fast_intt_sc; - intus = fast_intt_us; - nrang = def_nrang; + /* now wait for the next interleavescan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); - SiteEndScan(scnsc,scnus); - } + intsc = fast_intt_sc; + intus = fast_intt_us; + nrang = def_nrang; + + SiteEndScan(scnsc,scnus); - } while (exitpoll==0); + } while (1); for (n=0;n time_needed) { + while (snd_time-snd_intt > time_needed) { - /* set the beam */ - bmnum = snd_bms[snd_bm_cnt] + odd_beams; + /* set the beam */ + bmnum = snd_bms[snd_bm_cnt] + odd_beams; - /* snd_freq will be an array of frequencies to step through */ - snd_freq = snd_freqs[snd_freq_cnt]; + /* snd_freq will be an array of frequencies to step through */ + snd_freq = snd_freqs[snd_freq_cnt]; - /* the scanning code is here */ - sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); - ErrLog(errlog.sock,progname,logtxt); - ErrLog(errlog.sock,progname,"Setting SND beam."); - SiteStartIntt(intsc,intus); + /* the scanning code is here */ + sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); + ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock,progname,"Setting SND beam."); + SiteStartIntt(intsc,intus); + + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); + sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + ErrLog(errlog.sock,progname, logtxt); + tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); - ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); - sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + + nave = SiteIntegrate(lags); + if (nave < 0) { + sprintf(logtxt, "SND integration error: %d", nave); ErrLog(errlog.sock,progname, logtxt); - tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); + continue; + } + sprintf(logtxt,"Number of SND sequences: %d",nave); + ErrLog(errlog.sock,progname,logtxt); - sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - ErrLog(errlog.sock, progname, logtxt); + OpsBuildPrm(prm,ptab,lags); + OpsBuildIQ(iq,&badtr); + OpsBuildRaw(raw); + FitACF(prm,raw,fblk,fit); - nave = SiteIntegrate(lags); - if (nave < 0) { - sprintf(logtxt, "SND integration error: %d", nave); - ErrLog(errlog.sock,progname, logtxt); - continue; - } - sprintf(logtxt,"Number of SND sequences: %d",nave); - ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock, progname, "Sending SND messages."); + msg.num = 0; + msg.tsize = 0; - OpsBuildPrm(prm,ptab,lags); - OpsBuildIQ(iq,&badtr); - OpsBuildRaw(raw); - FitACF(prm,raw,fblk,fit); + tmpbuf=RadarParmFlatten(prm,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); - ErrLog(errlog.sock, progname, "Sending SND messages."); - msg.num = 0; - msg.tsize = 0; + tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); - tmpbuf=RadarParmFlatten(prm,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, + (unsigned char *) badtr,BADTR_TYPE,0); - tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); + RMsgSndAdd(&msg,strlen(sharedmemory)+1, + (unsigned char *) sharedmemory,IQS_TYPE,0); - RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, - (unsigned char *) badtr,BADTR_TYPE,0); + tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); - RMsgSndAdd(&msg,strlen(sharedmemory)+1, - (unsigned char *) sharedmemory,IQS_TYPE,0); + tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); - tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,(unsigned char *) progname,NME_TYPE,0); - tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); + RMsgSndSend(task[RT_TASK].sock,&msg); + for (n=0;nscan = 1; + } else { + prm->scan = 0; + } - sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); - ErrLog(errlog.sock, progname, logtxt); + /* save the sounding mode data */ + write_snd_record(progname, prm, fit); - /* set the scan variable for the sounding mode data file only */ - if ((bmnum == snd_bms[0]) && (snd_freq == snd_freqs[0])) { - prm->scan = 1; - } else { - prm->scan = 0; - } + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - /* save the sounding mode data */ - write_snd_record(progname, prm, fit); - - ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - if (exitpoll !=0) break; - - /* check for the end of a beam loop */ - snd_freq_cnt++; - if (snd_freq_cnt >= snd_freqs_tot) { - /* reset the freq counter and increment the beam counter */ - snd_freq_cnt = 0; - snd_bm_cnt++; - if (snd_bm_cnt >= snd_bms_tot) { - snd_bm_cnt = 0; - odd_beams = !odd_beams; - } + /* check for the end of a beam loop */ + snd_freq_cnt++; + if (snd_freq_cnt >= snd_freqs_tot) { + /* reset the freq counter and increment the beam counter */ + snd_freq_cnt = 0; + snd_bm_cnt++; + if (snd_bm_cnt >= snd_bms_tot) { + snd_bm_cnt = 0; + odd_beams = !odd_beams; } - - /* see if we have enough time for another go round */ - TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); - snd_time = 60.0 - (sc + us*1e-6); } - /* now wait for the next normalscan */ - ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + /* see if we have enough time for another go round */ + TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); + snd_time = 60.0 - (sc + us*1e-6); + } - intsc = def_intt_sc; - intus = def_intt_us; - nrang = def_nrang; + /* now wait for the next normalscan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); - SiteEndScan(scnsc,scnus,5000); - } + intsc = def_intt_sc; + intus = def_intt_us; + nrang = def_nrang; + + SiteEndScan(scnsc,scnus,5000); - } while (exitpoll == 0); + } while (1); for (n=0; n time_needed) { + while (snd_time-snd_intt > time_needed) { - /* set the beam */ - bmnum = snd_bms[snd_bm_cnt] + odd_beams; + /* set the beam */ + bmnum = snd_bms[snd_bm_cnt] + odd_beams; - /* snd_freq will be an array of frequencies to step through */ - snd_freq = snd_freqs[snd_freq_cnt]; + /* snd_freq will be an array of frequencies to step through */ + snd_freq = snd_freqs[snd_freq_cnt]; - /* the scanning code is here */ - sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); - ErrLog(errlog.sock,progname,logtxt); - ErrLog(errlog.sock,progname,"Setting SND beam."); - SiteStartIntt(intsc,intus); + /* the scanning code is here */ + sprintf(logtxt,"Integrating SND beam:%d intt:%ds.%dus (%d:%d:%d:%d)",bmnum,intsc,intus,hr,mt,sc,us); + ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock,progname,"Setting SND beam."); + SiteStartIntt(intsc,intus); + + ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); + sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + ErrLog(errlog.sock,progname, logtxt); + tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); - ErrLog(errlog.sock, progname, "Doing SND clear frequency search."); - sprintf(logtxt, "FRQ: %d %d", snd_freq, snd_frqrng); + sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); + ErrLog(errlog.sock, progname, logtxt); + + nave = SiteIntegrate(lags); + if (nave < 0) { + sprintf(logtxt, "SND integration error: %d", nave); ErrLog(errlog.sock,progname, logtxt); - tfreq = SiteFCLR(snd_freq, snd_freq + snd_frqrng); + continue; + } + sprintf(logtxt,"Number of SND sequences: %d",nave); + ErrLog(errlog.sock,progname,logtxt); - sprintf(logtxt,"Transmitting SND on: %d (Noise=%g)",tfreq,noise); - ErrLog(errlog.sock, progname, logtxt); + OpsBuildPrm(prm,ptab,lags); + OpsBuildIQ(iq,&badtr); + OpsBuildRaw(raw); + FitACF(prm,raw,fblk,fit); - nave = SiteIntegrate(lags); - if (nave < 0) { - sprintf(logtxt, "SND integration error: %d", nave); - ErrLog(errlog.sock,progname, logtxt); - continue; - } - sprintf(logtxt,"Number of SND sequences: %d",nave); - ErrLog(errlog.sock,progname,logtxt); + ErrLog(errlog.sock, progname, "Sending SND messages."); + msg.num = 0; + msg.tsize = 0; - OpsBuildPrm(prm,ptab,lags); - OpsBuildIQ(iq,&badtr); - OpsBuildRaw(raw); - FitACF(prm,raw,fblk,fit); + tmpbuf=RadarParmFlatten(prm,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); - ErrLog(errlog.sock, progname, "Sending SND messages."); - msg.num = 0; - msg.tsize = 0; + tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); - tmpbuf=RadarParmFlatten(prm,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,PRM_TYPE,0); + RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, + (unsigned char *) badtr,BADTR_TYPE,0); - tmpbuf=IQFlatten(iq,prm->nave,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,IQ_TYPE,0); + RMsgSndAdd(&msg,strlen(sharedmemory)+1, + (unsigned char *) sharedmemory,IQS_TYPE,0); - RMsgSndAdd(&msg,sizeof(unsigned int)*2*iq->tbadtr, - (unsigned char *) badtr,BADTR_TYPE,0); + tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); - RMsgSndAdd(&msg,strlen(sharedmemory)+1, - (unsigned char *) sharedmemory,IQS_TYPE,0); + tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); + RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); - tmpbuf=RawFlatten(raw,prm->nrang,prm->mplgs,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,RAW_TYPE,0); + RMsgSndAdd(&msg,strlen(progname)+1,(unsigned char *) progname,NME_TYPE,0); - tmpbuf=FitFlatten(fit,prm->nrang,&tmpsze); - RMsgSndAdd(&msg,tmpsze,tmpbuf,FIT_TYPE,0); + RMsgSndSend(task[RT_TASK].sock,&msg); + for (n=0;nscan = 1; + } else { + prm->scan = 0; + } - sprintf(logtxt, "SBC: %d SFC: %d", snd_bm_cnt, snd_freq_cnt); - ErrLog(errlog.sock, progname, logtxt); + /* save the sounding mode data */ + write_snd_record(progname, prm, fit); - /* set the scan variable for the sounding mode data file only */ - if ((bmnum == snd_bms[0]) && (snd_freq == snd_freqs[0])) { - prm->scan = 1; - } else { - prm->scan = 0; - } + ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - /* save the sounding mode data */ - write_snd_record(progname, prm, fit); - - ErrLog(errlog.sock, progname, "Polling SND for exit.\n"); - if (exitpoll !=0) break; - - /* check for the end of a beam loop */ - snd_freq_cnt++; - if (snd_freq_cnt >= snd_freqs_tot) { - /* reset the freq counter and increment the beam counter */ - snd_freq_cnt = 0; - snd_bm_cnt++; - if (snd_bm_cnt >= snd_bms_tot) { - snd_bm_cnt = 0; - odd_beams = !odd_beams; - } + /* check for the end of a beam loop */ + snd_freq_cnt++; + if (snd_freq_cnt >= snd_freqs_tot) { + /* reset the freq counter and increment the beam counter */ + snd_freq_cnt = 0; + snd_bm_cnt++; + if (snd_bm_cnt >= snd_bms_tot) { + snd_bm_cnt = 0; + odd_beams = !odd_beams; } - - /* see if we have enough time for another go round */ - TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); - snd_time = 60.0 - (sc + us*1e-6); } - /* now wait for the next normalscan */ - ErrLog(errlog.sock,progname,"Waiting for scan boundary."); + /* see if we have enough time for another go round */ + TimeReadClock(&yr, &mo, &dy, &hr, &mt, &sc, &us); + snd_time = 60.0 - (sc + us*1e-6); + } - intsc = def_intt_sc; - intus = def_intt_us; - nrang = def_nrang; + /* now wait for the next normalscan */ + ErrLog(errlog.sock,progname,"Waiting for scan boundary."); - SiteEndScan(scnsc,scnus); - } + intsc = def_intt_sc; + intus = def_intt_us; + nrang = def_nrang; + + SiteEndScan(scnsc,scnus); - } while (exitpoll == 0); + } while (1); for (n=0; n Date: Mon, 13 Sep 2021 13:50:35 -0400 Subject: [PATCH 12/22] Adding missing if statement bracket --- qnx4/interleavesound.1.00/interleavesound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 069c31f..8f14ece 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -188,7 +188,7 @@ int main(int argc,char *argv[]) { int fast_intt_us=0; int snd_intt_sc=2; int snd_intt_us=0; - else if (num_scans == 20) { + } else if (num_scans == 20) { int snd_bms_tot=10; int fast_intt_sc=2; int fast_intt_us=400000; From ff6ee357b0c6c5ee0a6baa9b82fb9504b40cf933 Mon Sep 17 00:00:00 2001 From: egthomas Date: Mon, 13 Sep 2021 14:06:17 -0400 Subject: [PATCH 13/22] Fixing errors in QNX4 interleavesound and normalsound identified by Kevin Sterne --- qnx4/interleavesound.1.00/interleavesound.c | 22 ++++++++-------- qnx4/normalsound.3.00/normalsound.c | 28 +++++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 8f14ece..3e23406 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -180,20 +180,22 @@ int main(int argc,char *argv[]) { int snd_frqrng=100; int snd_nrang=75; float snd_time, snd_intt, time_needed=1.25; + int snd_bms_tot, snd_intt_sc, snd_intt_us; + int fast_intt_sc, fast_intt_us; unsigned char limit_fswitch=0; if (num_scans == 16) { - int snd_bms_tot=8; - int fast_intt_sc=3; - int fast_intt_us=0; - int snd_intt_sc=2; - int snd_intt_us=0; + snd_bms_tot=8; + fast_intt_sc=3; + fast_intt_us=0; + snd_intt_sc=2; + snd_intt_us=0; } else if (num_scans == 20) { - int snd_bms_tot=10; - int fast_intt_sc=2; - int fast_intt_us=400000; - int snd_intt_sc=1; - int snd_intt_us=500000; + snd_bms_tot=10; + fast_intt_sc=2; + fast_intt_us=400000; + snd_intt_sc=1; + snd_intt_us=500000; } snd_intt = snd_intt_sc + snd_intt_us*1e-6; diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index 58a2791..dacda78 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -194,21 +194,23 @@ int main(int argc,char *argv[]) { int snd_frqrng=100; int snd_nrang=75; float snd_time, snd_intt, time_needed=1.25; + int snd_bms_tot, snd_intt_sc, snd_intt_us; + int fast_intt_sc, fast_intt_us; if (snd_bms_tot == 8) { - int normal_intt_sc=6; - int normal_intt_us=0; - int fast_intt_sc=3; - int fast_intt_us=0; - int snd_intt_sc=2; - int snd_intt_us=0; - else if (snd_bms_tot == 10) { - int normal_intt_sc=5; - int normal_intt_us=0; - int fast_intt_sc=2; - int fast_intt_us=400000; - int snd_intt_sc=1; - int snd_intt_us=500000; + normal_intt_sc=6; + normal_intt_us=0; + fast_intt_sc=3; + fast_intt_us=0; + snd_intt_sc=2; + snd_intt_us=0; + } else if (snd_bms_tot == 10) { + normal_intt_sc=5; + normal_intt_us=0; + fast_intt_sc=2; + fast_intt_us=400000; + snd_intt_sc=1; + snd_intt_us=500000; } snd_intt = snd_intt_sc + snd_intt_us*1e-6; From c8592f31e34bcdd7ac94d1ee0f4fd0c0b3d9b743 Mon Sep 17 00:00:00 2001 From: egthomas Date: Mon, 13 Sep 2021 14:10:48 -0400 Subject: [PATCH 14/22] Fixing error introduced in QNX4 normalsound --- qnx4/normalsound.3.00/normalsound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index dacda78..817a659 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -194,7 +194,7 @@ int main(int argc,char *argv[]) { int snd_frqrng=100; int snd_nrang=75; float snd_time, snd_intt, time_needed=1.25; - int snd_bms_tot, snd_intt_sc, snd_intt_us; + int snd_intt_sc, snd_intt_us; int fast_intt_sc, fast_intt_us; if (snd_bms_tot == 8) { From 0d827f81eee5e87f8df3ac48c9117deec58a385c Mon Sep 17 00:00:00 2001 From: egthomas Date: Mon, 13 Sep 2021 14:12:08 -0400 Subject: [PATCH 15/22] Fixing one more error in QNX4 normalsound --- qnx4/normalsound.3.00/normalsound.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index 817a659..d6e9615 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -194,8 +194,9 @@ int main(int argc,char *argv[]) { int snd_frqrng=100; int snd_nrang=75; float snd_time, snd_intt, time_needed=1.25; - int snd_intt_sc, snd_intt_us; + int normal_intt_sc, normal_intt_us; int fast_intt_sc, fast_intt_us; + int snd_intt_sc, snd_intt_us; if (snd_bms_tot == 8) { normal_intt_sc=6; From af32c682cccb6a4e1a6efcf7097d43959a0b53a4 Mon Sep 17 00:00:00 2001 From: egthomas Date: Mon, 13 Sep 2021 14:59:53 -0400 Subject: [PATCH 16/22] Fixing error in QNX4 normalsound and interleavesound code identified by Kevin Sterne --- qnx4/interleavesound.1.00/interleavesound.c | 24 +++++++++-------- qnx4/normalsound.3.00/normalsound.c | 29 ++++++++++++--------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 1e8b341..965cffc 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -177,20 +177,22 @@ int main(int argc,char *argv[]) { int snd_freq; int snd_frqrng=100; float snd_time, snd_intt, time_needed=1.25; + int snd_bms_tot, snd_intt_sc, snd_intt_us; + int fast_intt_sc, fast_intt_us; unsigned char limit_fswitch=0; if (num_scans == 16) { - int snd_bms_tot=8; - int fast_intt_sc=3; - int fast_intt_us=0; - int snd_intt_sc=2; - int snd_intt_us=0; - else if (num_scans == 20) { - int snd_bms_tot=10; - int fast_intt_sc=2; - int fast_intt_us=400000; - int snd_intt_sc=1; - int snd_intt_us=500000; + snd_bms_tot=8; + fast_intt_sc=3; + fast_intt_us=0; + snd_intt_sc=2; + snd_intt_us=0; + } else if (num_scans == 20) { + snd_bms_tot=10; + fast_intt_sc=2; + fast_intt_us=400000; + snd_intt_sc=1; + snd_intt_us=500000; } snd_intt = snd_intt_sc + snd_intt_us*1e-6; diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index 3e55623..9fe23a8 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -191,21 +191,24 @@ int main(int argc,char *argv[]) { int snd_freq; int snd_frqrng=100; float snd_time, snd_intt, time_needed=1.25; + int normal_intt_sc, normal_intt_us; + int fast_intt_sc, fast_intt_us; + int snd_intt_sc, snd_intt_us; if (snd_bms_tot == 8) { - int normal_intt_sc=6; - int normal_intt_us=0; - int fast_intt_sc=3; - int fast_intt_us=0; - int snd_intt_sc=2; - int snd_intt_us=0; - else if (snd_bms_tot == 10) { - int normal_intt_sc=5; - int normal_intt_us=0; - int fast_intt_sc=2; - int fast_intt_us=400000; - int snd_intt_sc=1; - int snd_intt_us=500000; + normal_intt_sc=6; + normal_intt_us=0; + fast_intt_sc=3; + fast_intt_us=0; + snd_intt_sc=2; + snd_intt_us=0; + } else if (snd_bms_tot == 10) { + normal_intt_sc=5; + normal_intt_us=0; + fast_intt_sc=2; + fast_intt_us=400000; + snd_intt_sc=1; + snd_intt_us=500000; } snd_intt = snd_intt_sc + snd_intt_us*1e-6; From 28dd120050f1d29cd22cef525a95d6259fa7a6d6 Mon Sep 17 00:00:00 2001 From: egthomas Date: Mon, 13 Sep 2021 20:45:22 -0400 Subject: [PATCH 17/22] Modifying QNX4 interleavesound and normalsound to set mpinc after call to SiteStart --- qnx4/interleavesound.1.00/interleavesound.c | 6 +++--- qnx4/normalsound.3.00/normalsound.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 3e23406..5d166d2 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -236,21 +236,21 @@ int main(int argc,char *argv[]) { &dmpinc,&nmpinc, &frqrng,&xcnt); + SiteStart(); + // For 1-min normal scan cp = 197; intsc = fast_intt_sc; intus = fast_intt_us; mppul = 8; mplgs = 23; - mpinc = 1500; dmpinc = 1500; + nmpinc = 1500; nrang = 75; rsep = 45; txpl = 300; /* recalculated below with rsep */ frang = 180; - SiteStart(); - #if 1 //maxatten=1; //Chris //maxatten=2; //Sessai diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index d6e9615..fa4fec3 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -252,20 +252,20 @@ int main(int argc,char *argv[]) { &dmpinc,&nmpinc, &frqrng,&xcnt); + SiteStart(); + cp = 155; intsc = normal_intt_sc; intus = normal_intt_us; mppul = 8; mplgs = 23; - mpinc = 1500; dmpinc = 1500; + nmpinc = 1500; nrang = 75; rsep = 45; txpl = 300; /* recalculated below with rsep */ frang = 180; - SiteStart(); - #if 1 //maxatten=1; //Chris //maxatten=2; //Sessai From ce64a1c576b76599c325ab62bf083f55d690d0d2 Mon Sep 17 00:00:00 2001 From: egthomas Date: Thu, 16 Sep 2021 11:03:24 -0400 Subject: [PATCH 18/22] Updating QNX4 interleavesound.c version number to reflect changes in sounding behavior; hopefully this can be different from the directory version number, otherwise this commit should be reversed --- qnx4/interleavesound.1.00/interleavesound.c | 6 +++++- qnx4/interleavesound.1.00/version.info | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 5d166d2..62444b7 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -45,6 +45,10 @@ /* $Log: interleavesound.c,v $ + Revision 1.1 2021/09/15 egthomas + Modification to set number of ranges used for frequency + sounding independently of nrang for the interleaved scan + Revision 1.0 2019/06/14 egthomas Initial revision from interleavedscan and normalsound @@ -57,7 +61,7 @@ #define TASK_NAMES "echo_data","iqwrite","rawacfwrite","fitacfwrite" char cmdlne[1024]; -char progid[80]={"$Id: interleavesound.c,v 1.0 2019/06/14 egthomas Exp $"}; +char progid[80]={"$Id: interleavesound.c,v 1.1 2021/09/15 egthomas Exp $"}; char progname[256]; struct TaskID *errlog; diff --git a/qnx4/interleavesound.1.00/version.info b/qnx4/interleavesound.1.00/version.info index 5b26287..52b0ad0 100644 --- a/qnx4/interleavesound.1.00/version.info +++ b/qnx4/interleavesound.1.00/version.info @@ -1,9 +1,13 @@ # $Log: version.info,v $ # +# Revision 1.1 2021/09/15 egthomas +# Modification to set number of ranges used for frequency +# sounding independently of nrang for the interleaved scan +# # Revision 1.0 2019/06/14 egthomas # Initial revision from interleavedscan and normalsound # # -interleavesound.c 1.00 +interleavesound.c 1.01 sndwrite.c 1.01 sndwrite.h 1.00 From 2f406a102f5d734e208c4a0973e9a9a39e7b23c9 Mon Sep 17 00:00:00 2001 From: Evan Thomas Date: Fri, 17 Sep 2021 10:00:44 -0400 Subject: [PATCH 19/22] Update README.md --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 01df040..8501b55 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ -This repository contains an archive of requested non-standard Special Time (ST) -and Discretionary Time (DT) radar control programs. Please contact the radar -control program author or experiment requester with any questions. +This repository contains an archive of SuperDARN radar control programs. +Please contact the control program author or experiment requester with any questions. From 130ce3d27b3bca22c1dc72129ec30141142faf35 Mon Sep 17 00:00:00 2001 From: egthomas Date: Fri, 17 Sep 2021 20:06:41 -0400 Subject: [PATCH 20/22] Adding some extra errlog info about SND frequencies to QNX4 inerleavesound and normalsound to match the QNX6 versions --- qnx4/interleavesound.1.00/interleavesound.c | 2 ++ qnx4/normalsound.3.00/normalsound.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 62444b7..85f59d5 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -472,6 +472,8 @@ int main(int argc,char *argv[]) { SiteSetBeam(bmnum); ErrLog(errlog, progname, "Doing SND clear frequency search."); + sprintf(logtxt,"FRQ: %d %d",snd_freq,snd_frqrng); + ErrLog(errlog,progname,logtxt); if (SiteFCLR(snd_freq, snd_freq + snd_frqrng)==FREQ_LOCAL) ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); SiteSetFreq(tfreq); diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index fa4fec3..082816f 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -480,6 +480,8 @@ int main(int argc,char *argv[]) { SiteSetBeam(bmnum); ErrLog(errlog, progname, "Doing SND clear frequency search."); + sprintf(logtxt,"FRQ: %d %d",snd_freq,snd_frqrng); + ErrLog(errlog,progname,logtxt); if (SiteFCLR(snd_freq, snd_freq + snd_frqrng)==FREQ_LOCAL) ErrLog(errlog,progname,"Frequency Synthesizer in local mode."); SiteSetFreq(tfreq); From 670c85cf636d8345f905386b9c3e74f68769ce0c Mon Sep 17 00:00:00 2001 From: egthomas Date: Fri, 17 Sep 2021 20:25:12 -0400 Subject: [PATCH 21/22] Modifying QNX4 version of normalsound to add the -lf option for limiting the amount of frequency switching, same as for interleavesound --- qnx4/interleavesound.1.00/interleavesound.c | 2 +- qnx4/normalsound.3.00/normalsound.c | 35 ++++++++++++++++----- qnx4/normalsound.3.00/version.info | 5 +-- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 85f59d5..3cb719e 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -531,7 +531,7 @@ int main(int argc,char *argv[]) { if (exitpoll !=0) break; if (limit_fswitch) { - /* check for the end of a frequency loop */ + /* check for the end of a frequency loop (optional) */ snd_bm_cnt++; if (snd_bm_cnt >= snd_bms_tot) { /* reset the beam counter and increment the freq counter */ diff --git a/qnx4/normalsound.3.00/normalsound.c b/qnx4/normalsound.3.00/normalsound.c index 082816f..05515fa 100644 --- a/qnx4/normalsound.3.00/normalsound.c +++ b/qnx4/normalsound.3.00/normalsound.c @@ -46,8 +46,9 @@ /* $Log: normalsound.c,v $ - Revision 3.0 2020/09/25 egthomas - Modification to use dmap sounding file format + Revision 3.0 2021/09/15 egthomas + Modification to use dmap sounding file format and + independent number of ranges for frequency sounding Revision 2.7 2008/03/15 00:47:25 code Added iqwrite. @@ -82,7 +83,7 @@ #define TASK_NAMES "echo_data","iqwrite","rawacfwrite","fitacfwrite" char cmdlne[1024]; -char progid[80]={"$Id: normalsound.c,v 3.0 2020/09/25 egthomas Exp $"}; +char progid[80]={"$Id: normalsound.c,v 3.0 2021/09/15 egthomas Exp $"}; char progname[256]; struct TaskID *errlog; @@ -197,6 +198,7 @@ int main(int argc,char *argv[]) { int normal_intt_sc, normal_intt_us; int fast_intt_sc, fast_intt_us; int snd_intt_sc, snd_intt_us; + unsigned char limit_fswitch=0; if (snd_bms_tot == 8) { normal_intt_sc=6; @@ -291,6 +293,9 @@ int main(int argc,char *argv[]) { OptionAdd(&opt, "fast", 'x', &fast); OptionAdd(&opt, "frqrng", 'i', &frqrng); OptionAdd(&opt, "sfrqrng", 'i',&snd_frqrng); /* sounding FCLR window [kHz] */ + OptionAdd(&opt, "lf", 'x', &limit_fswitch); /* limit amount of frequency switching + by iterating over all sounding beams + before proceeding to next frequency */ arg=OptionProcess(1,argc,argv,&opt,NULL); @@ -538,15 +543,29 @@ int main(int argc,char *argv[]) { exitpoll=RadarShell(sid,&rstable); if (exitpoll !=0) break; - /* check for the end of a beam loop */ - snd_freq_cnt++; - if (snd_freq_cnt >= snd_freqs_tot) { - /* reset the freq counter and increment the beam counter */ - snd_freq_cnt = 0; + if (limit_fswitch) { + /* check for the end of a frequency loop (optional) */ snd_bm_cnt++; if (snd_bm_cnt >= snd_bms_tot) { + /* reset the beam counter and increment the freq counter */ snd_bm_cnt = 0; odd_beams = !odd_beams; + if (!odd_beams) snd_freq_cnt++; + if (snd_freq_cnt >= snd_freqs_tot) { + snd_freq_cnt = 0; + } + } + } else { + /* check for the end of a beam loop (default) */ + snd_freq_cnt++; + if (snd_freq_cnt >= snd_freqs_tot) { + /* reset the freq counter and increment the beam counter */ + snd_freq_cnt = 0; + snd_bm_cnt++; + if (snd_bm_cnt >= snd_bms_tot) { + snd_bm_cnt = 0; + odd_beams = !odd_beams; + } } } diff --git a/qnx4/normalsound.3.00/version.info b/qnx4/normalsound.3.00/version.info index 284a0c6..b2f593f 100644 --- a/qnx4/normalsound.3.00/version.info +++ b/qnx4/normalsound.3.00/version.info @@ -1,7 +1,8 @@ # $Log: version.info,v $ # -# Revision 3.0 2020/09/25 egthomas -# Modification to use dmap sounding file format +# Revision 3.0 2021/09/15 egthomas +# Modification to use dmap sounding file format and +# independent number of ranges for frequency sounding # #Revision 2.7 2008/03/15 00:47:44 code #Added iqwrite. From 9005ff0cefbe14ab15b22529be28b47b4873c369 Mon Sep 17 00:00:00 2001 From: egthomas Date: Wed, 6 Oct 2021 10:37:32 -0400 Subject: [PATCH 22/22] Making site-specific change to interleavesound.c for GBR to use interleave_sounder.dat file, although in the future this should be fixed for eventual use of the revised normalsound control program which will need access to the same sounder.dat file --- qnx4/interleavesound.1.00/interleavesound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qnx4/interleavesound.1.00/interleavesound.c b/qnx4/interleavesound.1.00/interleavesound.c index 3cb719e..ddf47eb 100644 --- a/qnx4/interleavesound.1.00/interleavesound.c +++ b/qnx4/interleavesound.1.00/interleavesound.c @@ -174,7 +174,7 @@ int main(int argc,char *argv[]) { /* ---------------- Variables for sounding --------------- */ char snd_filename[100]; FILE *snd_dat; - /* If the file $SD_HDWPATH/sounder_[rad].dat exists, the next two parameters are read from it */ + /* If the file $SD_HDWPATH/interleave_sounder.dat exists, the next two parameters are read from it */ /* the file contains one integer value per line */ int snd_freqs_tot=8; int snd_freqs[MAX_SND_FREQS] = {11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 0, 0, 0, 0}; @@ -205,7 +205,7 @@ int main(int argc,char *argv[]) { snd_intt = snd_intt_sc + snd_intt_us*1e-6; /* load the sounder frequencies from file if present */ - sprintf(snd_filename, "%s/sounder_%s.dat", getenv("SD_HDWPATH"), getenv("SD_RADARCODE")); + sprintf(snd_filename, "%s/interleave_sounder.dat", getenv("SD_HDWPATH")); fprintf(stderr, "Checking Sounder File: %s\n", snd_filename); snd_dat = fopen(snd_filename, "r"); if (snd_dat != NULL) {