/** * 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 aor 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 // Bandscope Samples Array: D[] = {0,5,1,2,4,2,4}, // multipliers and divisors S[] = {0,249,399,449,474,0,24}, // starting points E[] = {1000,500,200,100,50,100,50}; // extents of bandscope samples 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 byte array B[] that contains received scan data file private boolean dataOK = false; // true when banscope scan data is valid private scope sc; // reference to scope object (instance of scope class) private loader ld; // reference to loader object (instance of loader class) private msgpanel mp; // reference to message panel class instance private freqspan sp; // reference to frequency-span class instance ar86000(loader ld, scope sc, msgpanel mp, freqspan sp) { this.ld = ld; // loader object reference to local private variable this.sc = sc; // scope object reference to local private variable this.mp = mp; // reference to message panel class instance this.sp = sp; // reference to frequency-span class instance } /* This method is called only by - the "loader" class to set up the graph plots for newly-loaded data and - the "freqspan" class to reorganise the graph plots after a new frequency span has been selected. */ void computePlots() { // create graph plots from 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 received scan data if(L == 1000) // if the data received is 1000 bytes long bigFile(); else if(L == 100) // assume first 100 bytes of B[] contain 2kHz samples smallFile(); else { // otherwise it is an invalid scan data file mp.showMsg("L = " + L + ", default data file corrupt.", true); killPlots(); // so erase all the signal strength plots } } // A 1000-BYTE SCAN DATA FILE HAS BEEN DOWNLOADED private void bigFile() { if(fs == 0) // if currently-selected frequency span is 10MHz freqSpan10MHz(); // set up the signal strength plots accordingly else if(fs == 1) // if currently-selected frequency span is 5 MHz freqSpan05MHz(); // set up the signal strength plots accordingly else if(fs < 5) /* ie, if fs = 2 (2 MHz span), 3 (1MHz span) or 4 (500kHz span) */ lesserSpans(); // set up only the plots required for it respecively else { mp.showMsg("Loading 2kHz samples.", false); killPlots(); } } // A 100-BYTE SCAN DATA FILE HAS BEEN DOWNLOADED private void smallFile(){ if(fs > 4) /* if currently-selected frequency span is 200kHz or 100kHz */ freqSpan200kHz(); // set up the signal strength plots accordingly else { mp.showMsg("Loading 10kHz samples.", false); killPlots(); } } /* FREQUENCY BAND SPAN OF 10MHz: 5 samples are averaged to form 1 pixel plot for each bandscope sample over the prescribed range. */ private void freqSpan10MHz() { int j = 0, h = 0, plot = 0; for(int i = s; i < e; i++) { // sum the next 5 data points in h (the -2 removes the noise) h += ld.getB(i) - 2; if(++j == 5) { // store average in next graphical signal plot sc.putPlot(plot++,(h << 3) / 5); j = 0; h = 0; } } } /* FREQUENCY BAND SPAN OF 5MHz: 2.5 samples are averaged (sort of) to form 1 pixel plot. */ private void freqSpan05MHz() { 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; // in h (-2 takes off noise) if(++j == 3) { // sum the next 3 bandscope samples // store the average in next graphical signal plot sc.putPlot(plot++, (h << 3) / 3); j = 0; h = 0; // if the first 3 samples of the current 5-sample group have been done if(MustStepBack) i--; // back up by one bandscope sample MustStepBack = !MustStepBack; // 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 next 1, 2 or 4 graph plots accord- ing to the 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 in accordance with the 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 */ }