Gruppe 1
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DetectionReport.java 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.example.ueberwachungssystem.Detection;
  2. import android.annotation.SuppressLint;
  3. import android.util.Log;
  4. import com.example.ueberwachungssystem.WifiCommunication;
  5. import java.text.SimpleDateFormat;
  6. import java.util.Calendar;
  7. import java.util.Date;
  8. /** Detection Report Class */
  9. public class DetectionReport {
  10. public String timeStamp;
  11. public String detectionType;
  12. public float detectedValue;
  13. public boolean detectionState;
  14. public DetectionReport(boolean detectionState, String detectionType, float detectedAmplitude) {
  15. // New Date Format
  16. @SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
  17. Date curDate = new Date(System.currentTimeMillis());
  18. this.timeStamp = formatter.format(curDate);
  19. //Old Date Format: this.timeStamp = String.valueOf(Calendar.getInstance().getTime());
  20. this.detectionType = detectionType;
  21. this.detectedValue = detectedAmplitude;
  22. this.detectionState = detectionState;
  23. //this.detectorID = detectorID;
  24. }
  25. /** Get Detection Report in String format */
  26. public String toString() {
  27. String state = "State: " + "[" + this.detectionState + "]";
  28. String time = "Time: " + "[" + this.timeStamp + "]";
  29. String type = "Type: " + "[" + this.detectionType + "]";
  30. String value = "Value: " + "[" + this.detectedValue + "]";
  31. return String.join("\t", state, time, type, value);
  32. }
  33. public String toMessage() {
  34. String state;
  35. if(detectionState)
  36. state = "An";
  37. else
  38. state = "Aus";
  39. return String.join(",", "1", timeStamp, "Gruppe2", WifiCommunication.getLocalIpAddress(), state, detectionType, String.valueOf(detectedValue));
  40. }
  41. /** Debug Report */
  42. public void log(String tag) {
  43. Log.d(tag, this.toString());
  44. }
  45. }