removed divide by zero errors if spectrum power is zero.

This commit is contained in:
Graham Jones
2015-12-23 21:41:43 +00:00
parent 13a9c10211
commit ebde242ef6
2 changed files with 17 additions and 5 deletions

View File

@@ -393,11 +393,21 @@ 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;
((TextView) findViewById(R.id.powerTv)).setText("Power = " + mConnection.mSdServer.mSdData.roiPower +
" (threshold = " + mConnection.mSdServer.mSdData.alarmThresh + ")");
@@ -434,7 +444,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

View File

@@ -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();
}