Browse Source

adapted SensorMessage Type to float

Benutzeroberflaeche
Christian Tinz 1 year ago
parent
commit
c6d33925be

+ 2
- 2
app/src/main/java/com/example/greenwatch/AccelerometerActivity.java View File

@@ -96,10 +96,10 @@ public class AccelerometerActivity extends AppCompatActivity implements SensorEv
@Override
public void onChanged(Boolean aBoolean) {
if (aBoolean) {
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", mAccelerometerViewModel.getAccelerometerSensorMeanValue());
}
else {
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), false, "Accelerometer", 0);
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), false, "Accelerometer", 0.0f);
}

}

+ 2
- 2
app/src/main/java/com/example/greenwatch/AudiodetectionActivity.java View File

@@ -87,10 +87,10 @@ public class AudiodetectionActivity extends AppCompatActivity {
@Override
public void onChanged(Boolean aBoolean) {
if (aBoolean) {
mMicrofonViewModel.updateDevice(mMicrofonViewModel.getLocalDeviceUUID(), mMicrofonViewModel.getSystemTimeStamp(), true, "Microfon", (int) mMicrofonViewModel.getAmplitudeInDB());
mMicrofonViewModel.updateDevice(mMicrofonViewModel.getLocalDeviceUUID(), mMicrofonViewModel.getSystemTimeStamp(), true, "Microfon", mMicrofonViewModel.getAmplitudeInDB());
}
else {
mMicrofonViewModel.updateDevice(mMicrofonViewModel.getLocalDeviceUUID(), mMicrofonViewModel.getSystemTimeStamp(), false, "Microfon", (int) mMicrofonViewModel.getAmplitudeInDB());
mMicrofonViewModel.updateDevice(mMicrofonViewModel.getLocalDeviceUUID(), mMicrofonViewModel.getSystemTimeStamp(), false, "Microfon", mMicrofonViewModel.getAmplitudeInDB());
}

}

+ 3
- 3
app/src/main/java/com/example/greenwatch/AudiodetectionAndAccelerometerActivity.java View File

@@ -94,13 +94,13 @@ public class AudiodetectionAndAccelerometerActivity extends AppCompatActivity im
if (aBoolean) {
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "onChangedTrue", Toast.LENGTH_LONG).show();
if (mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected() && !mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected()) {
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", mAudiodetectionAndAccelerometerViewModel.getAccelerometerSensorMeanValue());
}
else if (mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected() && !mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected()) {
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Audio", (int) mAudiodetectionAndAccelerometerViewModel.getAmplitudeInDB());
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Audio", mAudiodetectionAndAccelerometerViewModel.getAmplitudeInDB());
}
else if (mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected() && mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected()) {
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "2AudioAndAccelerometer", 10);
mAudiodetectionAndAccelerometerViewModel.updateDevice(mAudiodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mAudiodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "AudioAndAccelerometer", mAudiodetectionAndAccelerometerViewModel.getAmplitudeInDB());
}
}
else {

+ 4
- 4
app/src/main/java/com/example/greenwatch/VideodetectionAndAccelerometerActivity.java View File

@@ -102,17 +102,17 @@ public class VideodetectionAndAccelerometerActivity extends AppCompatActivity im
public void onChanged(Boolean aBoolean) {
if (aBoolean) {
if (mVideodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected() && !mVideodetectionAndAccelerometerViewModel.getVideoAlarmDetected()) {
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", mVideodetectionAndAccelerometerViewModel.getAccelerometerSensorMeanValue());
}
else if (mVideodetectionAndAccelerometerViewModel.getVideoAlarmDetected() && !mVideodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected()) {
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Video", 10);
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "Video", 1.0f);
}
else if (mVideodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected() && mVideodetectionAndAccelerometerViewModel.getVideoAlarmDetected()) {
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "2VideoAndAccelerometer", 10);
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), true, "VideoAndAccelerometer", mVideodetectionAndAccelerometerViewModel.getAccelerometerSensorMeanValue());
}
}
else {
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), false, "VideoAndAccelerometer", 0);
mVideodetectionAndAccelerometerViewModel.updateDevice(mVideodetectionAndAccelerometerViewModel.getLocalDeviceUUID(), mVideodetectionAndAccelerometerViewModel.getSystemTimeStamp(), false, "VideoAndAccelerometer", 0.0f);
}
}
});

+ 4
- 4
app/src/main/java/com/example/greenwatch/models/Device.java View File

@@ -7,9 +7,9 @@ public class Device {
private String deviceID;
private boolean sensorStatus;
private String sensorType;
private int sensorMassage;
private float sensorMassage;

public Device(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage) {
public Device(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, float sensorMassage) {
this.timeStamp = timeStamp;
this.deviceID = deviceID;
this.sensorStatus = sensorStatus;
@@ -47,11 +47,11 @@ public class Device {
return sensorStatus;
}

public void setSensorMassage(int sensorMassage) {
public void setSensorMassage(float sensorMassage) {
this.sensorMassage = sensorMassage;
}

public int getSensorMassage() {
public float getSensorMassage() {
return sensorMassage;
}
}

+ 5
- 5
app/src/main/java/com/example/greenwatch/repositories/DeviceRepository.java View File

@@ -60,7 +60,7 @@ public class DeviceRepository {
return startAlarmRecording;
}

public void createNewDevice(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, int sensorMassage){
public void createNewDevice(String timeStamp, String deviceID, boolean sensorStatus, String sensorType, float sensorMassage){
Device newDevice = new Device(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
if (sensorStatus) {
setAlarmHistoryDeviceList(newDevice);
@@ -80,7 +80,7 @@ public class DeviceRepository {
String deviceID = messageString[1];
boolean sensorStatus = convertSensorStatus(messageString[2]);
String sensorType = messageString[3];
int sensorMassage = Integer.valueOf(messageString[4]);
float sensorMassage = Float.valueOf(messageString[4]);

if (deviceID.equals(checkDeviceID(localDeviceUUID))) {
return;
@@ -126,7 +126,7 @@ public class DeviceRepository {
return localDeviceUUID;
}

public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage) {
String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) {
@@ -234,7 +234,7 @@ public class DeviceRepository {
return "";
}

public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) {
@@ -244,7 +244,7 @@ public class DeviceRepository {
}
}

public int getSensorMassage(String deviceID) {
public float getSensorMassage(String deviceID) {
String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) {

+ 4
- 0
app/src/main/java/com/example/greenwatch/sensors/AccelerometerSensor.java View File

@@ -82,4 +82,8 @@ public class AccelerometerSensor {
mAccelerometerAlarmDetected.setValue(false);
}
}

public float getAccelerometerSensorMeanValue() {
return meanValue;
}
}

+ 7
- 3
app/src/main/java/com/example/greenwatch/viewmodels/AccelerometerViewModel.java View File

@@ -56,6 +56,10 @@ public class AccelerometerViewModel extends ViewModel implements ViewModelInterf
mAccelerometerSensor.checkAlarmCondition();
}

public float getAccelerometerSensorMeanValue() {
return mAccelerometerSensor.getAccelerometerSensorMeanValue();
}

public LiveData<Boolean> getAccelerometerAlarmDetected() {
return mAccelerometerAlarmDetected;
}
@@ -76,7 +80,7 @@ public class AccelerometerViewModel extends ViewModel implements ViewModelInterf
}

@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}

@@ -121,12 +125,12 @@ public class AccelerometerViewModel extends ViewModel implements ViewModelInterf
}

@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}

@Override
public int getSensorMassage(String deviceID) {
public float getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}


+ 7
- 3
app/src/main/java/com/example/greenwatch/viewmodels/AudiodetectionAndAccelerometerViewModel.java View File

@@ -74,6 +74,10 @@ public class AudiodetectionAndAccelerometerViewModel extends ViewModel implement
mAccelerometerSensor.checkAlarmCondition();
}

public float getAccelerometerSensorMeanValue() {
return mAccelerometerSensor.getAccelerometerSensorMeanValue();
}

public LiveData<Boolean> getAudiodetectionAndAccelerometerAlarmDetected() {
setMutableLiveDataMicrofondetectionAndAccelerometerAlarmDetected();
return mAudiodetectionAndAccelerometerAlarmDetected;
@@ -160,7 +164,7 @@ public class AudiodetectionAndAccelerometerViewModel extends ViewModel implement
}

@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}

@@ -205,12 +209,12 @@ public class AudiodetectionAndAccelerometerViewModel extends ViewModel implement
}

@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}

@Override
public int getSensorMassage(String deviceID) {
public float getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}


+ 3
- 3
app/src/main/java/com/example/greenwatch/viewmodels/MainActivityViewModel.java View File

@@ -75,7 +75,7 @@ public class MainActivityViewModel extends ViewModel implements ViewModelInterfa
}

@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}

@@ -120,12 +120,12 @@ public class MainActivityViewModel extends ViewModel implements ViewModelInterfa
}

@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}

@Override
public int getSensorMassage(String deviceID) {
public float getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}


+ 3
- 3
app/src/main/java/com/example/greenwatch/viewmodels/MicrofonViewModel.java View File

@@ -76,7 +76,7 @@ public class MicrofonViewModel extends ViewModel implements ViewModelInterface {
}

@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}

@@ -121,12 +121,12 @@ public class MicrofonViewModel extends ViewModel implements ViewModelInterface {
}

@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}

@Override
public int getSensorMassage(String deviceID) {
public float getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}


+ 7
- 3
app/src/main/java/com/example/greenwatch/viewmodels/VideodetectionAndAccelerometerViewModel.java View File

@@ -78,6 +78,10 @@ public class VideodetectionAndAccelerometerViewModel extends ViewModel implement
mAccelerometerSensor.checkAlarmCondition();
}

public float getAccelerometerSensorMeanValue() {
return mAccelerometerSensor.getAccelerometerSensorMeanValue();
}

public void bindImageAnalysis(ProcessCameraProvider cameraProvider, LifecycleOwner lifecycleOwner, Context context) {
mCameraSensor.bindImageAnalysis(cameraProvider, lifecycleOwner, context);
}
@@ -152,7 +156,7 @@ public class VideodetectionAndAccelerometerViewModel extends ViewModel implement
}

@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}

@@ -197,12 +201,12 @@ public class VideodetectionAndAccelerometerViewModel extends ViewModel implement
}

@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}

@Override
public int getSensorMassage(String deviceID) {
public float getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}


+ 3
- 3
app/src/main/java/com/example/greenwatch/viewmodels/VideodetectionViewModel.java View File

@@ -74,7 +74,7 @@ public class VideodetectionViewModel extends ViewModel implements ViewModelInter
}

@Override
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage) {
public void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage) {
mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
}

@@ -119,12 +119,12 @@ public class VideodetectionViewModel extends ViewModel implements ViewModelInter
}

@Override
public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
mDeviceRepository.setSensorMassage(deviceID, sensorMessage);
}

@Override
public int getSensorMassage(String deviceID) {
public float getSensorMassage(String deviceID) {
return mDeviceRepository.getSensorMassage(deviceID);
}


+ 3
- 3
app/src/main/java/com/example/greenwatch/viewmodels/ViewModelInterface.java View File

@@ -11,7 +11,7 @@ public interface ViewModelInterface {
LiveData<List<Device>> getConnectedDeviceList();
LiveData<List<Device>> getAlarmHistoryList();
LiveData<Boolean> getStartAlarmRecording();
void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, int sensorMassage);
void updateDevice(String deviceID, String timeStamp, boolean sensorStatus, String sensorType, float sensorMassage);
void setTimeStamp(String deviceID, String timeStamp);
String getTimeStamp(String deviceID);
void setDeviceID(String deviceID, String newDeviceID);
@@ -20,8 +20,8 @@ public interface ViewModelInterface {
boolean getSensorStatus(String deviceID);
void setSensorType(String deviceID, String sensorType);
String getSensorType(String deviceID);
void setSensorMassage(String deviceID, int sensorMessage);
int getSensorMassage(String deviceID);
void setSensorMassage(String deviceID, float sensorMessage);
float getSensorMassage(String deviceID);
String getLocalDeviceUUID();
String getSystemTimeStamp();
}

+ 1
- 1
app/src/main/res/values/strings.xml View File

@@ -4,5 +4,5 @@
<string name="sensor_status_placeholder">Sensorstatus: %s</string>
<string name="deviceID_placeholder">Sensor-ID: %s</string>
<string name="sensor_time_stamp_placeholder">Timestamp: %s</string>
<string name="sensor_message_placeholder">Sensormessage: %d</string>
<string name="sensor_message_placeholder">Sensormessage: %f</string>
</resources>

Loading…
Cancel
Save