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

private DetectionReport detectionReport; private DetectionReport detectionReport;
TextView textView; TextView textView;



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


if (betrag > threshold) { if (betrag > threshold) {
alarm = true; alarm = true;
detectionReport = new DetectionReport("Accelerometer1", "Bewegung", betrag); detectionReport = new DetectionReport("Accelerometer1", "Bewegung", betrag);
reportViolation("Accelo1", "Bewegung", betrag);


stringBuffer.append("\nDetectionReport = ").append(detectionReport).append("\nAlarm an"); stringBuffer.append("\nDetectionReport = ").append(detectionReport).append("\nAlarm an");
logger.clearLog(); logger.clearLog();
@Override @Override
public void startDetection() { public void startDetection() {
// entspricht void start() // entspricht void start()
getSensor();
if (accelerometer != null) { if (accelerometer != null) {
sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME); sensorManager.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_GAME);
logger.log("Sensor registriert"); logger.log("Sensor registriert");

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





/** Triggers onDetectionListener - call this to trigger violation/alarm */ /** 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) { if (listener != null) {
DetectionReport detectionReport = new DetectionReport(detectorID, detectionType, amplitude); DetectionReport detectionReport = new DetectionReport(detectorID, detectionType, amplitude);
listener.onDetection(detectionReport); listener.onDetection(detectionReport);

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



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


logger.log("onCreate"); logger.log("onCreate");
} }

Loading…
Cancel
Save