Browse Source

Added reportViolation()

lm
Leon Market 1 year ago
parent
commit
d33ab299ab

+ 3
- 0
app/src/main/java/com/example/ueberwachungssystem/Accelerometer.java View File

@@ -47,6 +47,7 @@ public class Accelerometer extends Detector implements SensorEventListener {
private DetectionReport detectionReport;
TextView textView;


//Queue for taking in values
LinkedBlockingQueue<Float> linkedBlockingQueue = new LinkedBlockingQueue<>();

@@ -94,6 +95,7 @@ public class Accelerometer extends Detector implements SensorEventListener {
if (betrag > threshold) {
alarm = true;
detectionReport = new DetectionReport("Accelerometer1", "Bewegung", betrag);
reportViolation("Accelo1", "Bewegung", betrag);

stringBuffer.append("\nDetectionReport = ").append(detectionReport).append("\nAlarm an");
logger.clearLog();
@@ -124,6 +126,7 @@ public class Accelerometer extends Detector implements SensorEventListener {
@Override
public void startDetection() {
// entspricht void start()
getSensor();
if (accelerometer != null) {
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
logger.log("Sensor registriert");

+ 1
- 1
app/src/main/java/com/example/ueberwachungssystem/Detector.java View File

@@ -21,7 +21,7 @@ abstract public class Detector {


/** Triggers onDetectionListener - call this to trigger violation/alarm */
private void reportViolation(String detectorID, String detectionType, float amplitude) {
public void reportViolation(String detectorID, String detectionType, float amplitude) {
if (listener != null) {
DetectionReport detectionReport = new DetectionReport(detectorID, detectionType, amplitude);
listener.onDetection(detectionReport);

+ 1
- 1
app/src/main/java/com/example/ueberwachungssystem/MainActivity.java View File

@@ -41,7 +41,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe

//Accelerometer Setup
beschleunigungssensor = new Accelerometer(this, logger, textViewLog); //logger and textview only for debugging necessary
beschleunigungssensor.getSensor();
//beschleunigungssensor.getSensor();

logger.log("onCreate");
}

Loading…
Cancel
Save