removed divide by zero errors if spectrum power is zero.
This commit is contained in:
@@ -393,16 +393,32 @@ public class MainActivity extends Activity {
|
||||
tv.setTextColor(okTextColour);
|
||||
}
|
||||
// Set ProgressBars to show margin to alarm.
|
||||
long powerPc = mConnection.mSdServer.mSdData.roiPower * 100 /
|
||||
long powerPc;
|
||||
if (mConnection.mSdServer.mSdData.alarmThresh != 0)
|
||||
powerPc = mConnection.mSdServer.mSdData.roiPower * 100 /
|
||||
mConnection.mSdServer.mSdData.alarmThresh;
|
||||
long specPc = 100 * (mConnection.mSdServer.mSdData.roiPower * 10 /
|
||||
else
|
||||
powerPc = 0;
|
||||
|
||||
long specPc;
|
||||
if (mConnection.mSdServer.mSdData.specPower != 0 &&
|
||||
mConnection.mSdServer.mSdData.alarmRatioThresh != 0)
|
||||
specPc = 100 * (mConnection.mSdServer.mSdData.roiPower * 10 /
|
||||
mConnection.mSdServer.mSdData.specPower) /
|
||||
mConnection.mSdServer.mSdData.alarmRatioThresh;
|
||||
else
|
||||
specPc = 0;
|
||||
|
||||
long specRatio;
|
||||
if (mConnection.mSdServer.mSdData.specPower != 0) {
|
||||
specRatio = 10 * mConnection.mSdServer.mSdData.roiPower /
|
||||
mConnection.mSdServer.mSdData.specPower;
|
||||
} else
|
||||
specRatio = 0;
|
||||
|
||||
((TextView) findViewById(R.id.powerTv)).setText("Power = " + mConnection.mSdServer.mSdData.roiPower +
|
||||
" (threshold = " + mConnection.mSdServer.mSdData.alarmThresh + ")");
|
||||
((TextView) findViewById(R.id.spectrumTv)).setText("Spectrum Ratio = " + 10 * mConnection.mSdServer.mSdData.roiPower /
|
||||
mConnection.mSdServer.mSdData.specPower +
|
||||
((TextView) findViewById(R.id.spectrumTv)).setText("Spectrum Ratio = " + specRatio +
|
||||
" (threshold = " + mConnection.mSdServer.mSdData.alarmRatioThresh + ")");
|
||||
|
||||
ProgressBar pb;
|
||||
@@ -434,7 +450,8 @@ public class MainActivity extends Activity {
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.v(TAG, "ServerStatusRunnable: Exception - " + e.toString());
|
||||
Log.v(TAG, "ServerStatusRunnable: Exception - ");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// deal with latch alarms button
|
||||
|
||||
@@ -45,6 +45,7 @@ import android.os.Environment;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.PowerManager;
|
||||
import android.os.PowerManager.WakeLock;
|
||||
import android.preference.PreferenceManager;
|
||||
@@ -413,7 +414,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
/* from http://stackoverflow.com/questions/12154940/how-to-make-a-beep-in-android */
|
||||
|
||||
/**
|
||||
* beep for duration miliseconds, but only if mAudibleAlarm is set.
|
||||
* beep for duration milliseconds, but only if mAudibleAlarm is set.
|
||||
*/
|
||||
private void beep(int duration) {
|
||||
ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 100);
|
||||
@@ -742,7 +743,7 @@ public class SdServer extends Service implements SdDataReceiver {
|
||||
Log.v(TAG, "startFaultTimer(): starting fault timer.");
|
||||
mFaultTimerCompleted = false;
|
||||
mFaultTimer =
|
||||
// conver to ms.
|
||||
// convert to ms.
|
||||
new FaultTimer(mFaultTimerPeriod * 1000, 1000);
|
||||
mFaultTimer.start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user