/** * Bandscope Receiver Applet 1.0.0 [AR86000-SPECIFIC] * @author Robert J Morton * @version 13 March 2002, 20 March 2012 * @copyright Robert J Morton (all rights reserved) */ /* This class contains the methods that are specific to the way the AR86000 scanner provides bandscope data. The loader{} class places the requested scan data in a large byte array B[]. The methods below unpack the data in B[] and place it in the Plots[] array located in the scope{} class, where it is used to construct the scope displays. */ class ar86000 { private static final int D[] = {0,5,1,2,4,2,4}, // multipliers and divisors // starting points in bandscope samples array S[] = {0,249,399,449,474,0,24}, // extents of bandscope samples within array E[] = {1000,500,200,100,50,100,50}; private int fs, // currently-selected frequency span d, // multiplier factor for current frequency span s, // starting point for currently selected scope width e, // end point for currently selected scope width L; /* Length of the byte array B[] that contains the received scan data file. */ private boolean dataOK = false; // true when banscope scan data is valid // References to... private scope sc; // the scope object (instance of the scope class) private loader ld; // the loader object (instance of the loader class) private msgpanel mp; // message panel class instance private freqspan sp; // frequency-span class instance ar86000(loader ld, scope sc, msgpanel mp, freqspan sp) { this.ld = ld; // loader object reference this.sc = sc; // scope object reference this.mp = mp; // message panel class instance this.sp = sp; // frequency-span class instance } /* This method is called only by 1) the "loader" class to set up the graph plots for newly-loaded data and 2) the "freqspan" class to reorg- anise the graph plots after a new frequency span has been selected. */ void computePlots() { // create graph plots from the bandscope data fs = sp.getFreqSpan(); // get the currently-selected frequency span d = D[fs]; // multiplier for this frequency span s = S[fs]; // starting point for currently selected scope width e = s + E[fs]; // end point for currently selected scope width dataOK = true; // initially assume that the scan data is all valid L = ld.getL(); /* Length of array B[] containing the received scan data file. */ /* If the data received is 1000 bytes long, it's a big file; else if it is 100 bytes long, it's a small file so assume first 100 bytes of B[] contain 2kHz samples. Otherwise it is an invalid scan data file, so erase all the signal strength plots and display error message. */ if(L == 1000) bigFile(); else if(L == 100) smallFile(); else { mp.showMsg("L = " + L + ", default data file corrupt.", true); killPlots(); } } private void bigFile() { // A 1000-BYTE SCAN DATA FILE HAS BEEN DOWNLOADED /* Set up the signal strength plots according to the currently-selected frequency span of 10MHz, 05 MHz. */ if(fs == 0) freqSpan10MHz(); else if(fs == 1) freqSpan05MHz(); /* if fs = 2 (2 MHz span), 3 (1MHz span) or 4 (500kHz span) set up only the plots required for each option respecively. */ else if(fs < 5) lesserSpans(); // Otherwise, the file contains 2kHz samples. else { mp.showMsg("Loading 2kHz samples.", false); killPlots(); } } private void smallFile() { // A 100-BYTE SCAN DATA FILE HAS BEEN DOWNLOADED /* Set up the signal strength plots accordingly if the currently-selected frequency span is 200kHz or 100kHz. */ if(fs > 4) freqSpan200kHz(); else { mp.showMsg("Loading 10kHz samples.", false); killPlots(); } } private void freqSpan10MHz() { // FREQUENCY BAND SPAN OF 10MHz // 5 samples are averaged to form 1 pixel plot int j = 0, h = 0, plot = 0; /* For each bandscope sample over the prescribed range sum next 5 data points in h (-2 takes off noise) store average in next graphical signal plot. */ for(int i = s; i < e; i++) { h += ld.getB(i) - 2; if(++j == 5) { sc.putPlot(plot++, (h << 3) / 5); j = 0; h = 0; } } } private void freqSpan05MHz() { // FREQUENCY BAND SPAN OF 5MHz // 2.5 samples are averaged (sort of) to form 1 pixel plot boolean MustStepBack = true; int j = 0, h = 0, plot = 0; // for each bandscope sample over the prescribed range for(int i = s; i < e; i++) { h += ld.getB(i) - 2; // the -2 takes off the noise /* Sum the next 3 bandscope samples store average in next graphical signal plot. */ if(++j == 3) { sc.putPlot(plot++, (h << 3) / 3); j = 0; h = 0; /* if done first 3 samples of current 5-sample group back up by one bandscope sample. */ if(MustStepBack) i--; MustStepBack = !MustStepBack; // Then reverse the flag. } } } private void lesserSpans() { // FREQUENCY SPANS OF 2mhZ, 1mhZ AND 500kHz int plot = 0; // start at beginning of graph plots array // for each bandscope sample over the prescribed range for(int i = s; i < e; i++) { int x = ld.getB(i) - 2; // get the sample and subtract the noise /* Store it in the next 1, 2 or 4 graph plots according to currently selected frequency span. */ for(int j = 0; j < d; j++) sc.putPlot(plot++, x << 3); } } private void freqSpan200kHz() { // FREQUENCY SPANS OF 200kHz AND 100kHz int plot = 0; // start at beginning of graph plots array // for each bandscope sample over the prescribed range for(int i = s; i < e; i++) { int x = ld.getB(i) - 2; // get the sample and subtract the noise /* Store it in the next 1, 2 or 4 graph plots according to currently selected frequency span. */ for(int j = 0; j < d; j++) sc.putPlot(plot++, x << 3); } } private void killPlots() {sc.killPlots(); dataOK = false;} boolean getDataOK() {return dataOK;} // called only by "scope" //ENCAPSULATES AR86000 COMMUNICATIONS RECEIVER COMMANDS void tuneTo(int f) { /* code for constructing the receiver command to tune to the frequency specified in hertz. Then encapsulate this command within a POST request to the AR86000 server. */ } void mute() { /* code for constructing the receiver command to mute the receiver. Then encapsulate this command within a POST request to the AR86000 server. */ } void setPeakHold(boolean b) { /* code for constructing the receiver command to set the state of the receiver's Peak Hold function. Then encapsulate this command within a POST request to the AR86000 server. */ } /* AT What is the attenuator status? AT1 Engage attanuator AT0 Disengage attenuator AM Switch to bandscope mode CF Set bandscope centre frequency in hertz DC Set bandscope data centre frequency DS Acquire current bandscope data MF Bandscope: set marker frequency PH Bandscope peak hold SW Bandscope frequency span */ }