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

@Override @Override
public void onChanged(Boolean aBoolean) { public void onChanged(Boolean aBoolean) {
if (aBoolean) { if (aBoolean) {
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", 10);
mAccelerometerViewModel.updateDevice(mAccelerometerViewModel.getLocalDeviceUUID(), mAccelerometerViewModel.getSystemTimeStamp(), true, "Accelerometer", mAccelerometerViewModel.getAccelerometerSensorMeanValue());
} }
else { 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

@Override @Override
public void onChanged(Boolean aBoolean) { public void onChanged(Boolean aBoolean) {
if (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 { 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

if (aBoolean) { if (aBoolean) {
Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "onChangedTrue", Toast.LENGTH_LONG).show(); Toast.makeText(AudiodetectionAndAccelerometerActivity.this, "onChangedTrue", Toast.LENGTH_LONG).show();
if (mAudiodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected() && !mAudiodetectionAndAccelerometerViewModel.getMicrofonAlarmDetected()) { 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()) { 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()) { 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 { else {

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

public void onChanged(Boolean aBoolean) { public void onChanged(Boolean aBoolean) {
if (aBoolean) { if (aBoolean) {
if (mVideodetectionAndAccelerometerViewModel.getAccelerometerAlarmDetected() && !mVideodetectionAndAccelerometerViewModel.getVideoAlarmDetected()) { 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()) { 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()) { 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 { 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

private String deviceID; private String deviceID;
private boolean sensorStatus; private boolean sensorStatus;
private String sensorType; 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.timeStamp = timeStamp;
this.deviceID = deviceID; this.deviceID = deviceID;
this.sensorStatus = sensorStatus; this.sensorStatus = sensorStatus;
return sensorStatus; return sensorStatus;
} }


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


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

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

return startAlarmRecording; 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); Device newDevice = new Device(timeStamp, deviceID, sensorStatus, sensorType, sensorMassage);
if (sensorStatus) { if (sensorStatus) {
setAlarmHistoryDeviceList(newDevice); setAlarmHistoryDeviceList(newDevice);
String deviceID = messageString[1]; String deviceID = messageString[1];
boolean sensorStatus = convertSensorStatus(messageString[2]); boolean sensorStatus = convertSensorStatus(messageString[2]);
String sensorType = messageString[3]; String sensorType = messageString[3];
int sensorMassage = Integer.valueOf(messageString[4]);
float sensorMassage = Float.valueOf(messageString[4]);


if (deviceID.equals(checkDeviceID(localDeviceUUID))) { if (deviceID.equals(checkDeviceID(localDeviceUUID))) {
return; return;
return localDeviceUUID; 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); String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID); Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) { if(device != null) {
return ""; return "";
} }


public void setSensorMassage(String deviceID, int sensorMessage) {
public void setSensorMassage(String deviceID, float sensorMessage) {
String checkedDeviceID = checkDeviceID(deviceID); String checkedDeviceID = checkDeviceID(deviceID);
Device device = connectedDevicesList.get(checkedDeviceID); Device device = connectedDevicesList.get(checkedDeviceID);
if(device != null) { if(device != null) {
} }
} }


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

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

mAccelerometerAlarmDetected.setValue(false); mAccelerometerAlarmDetected.setValue(false);
} }
} }

public float getAccelerometerSensorMeanValue() {
return meanValue;
}
} }

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

mAccelerometerSensor.checkAlarmCondition(); mAccelerometerSensor.checkAlarmCondition();
} }


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

public LiveData<Boolean> getAccelerometerAlarmDetected() { public LiveData<Boolean> getAccelerometerAlarmDetected() {
return mAccelerometerAlarmDetected; return mAccelerometerAlarmDetected;
} }
} }


@Override @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); mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


} }


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


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



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

mAccelerometerSensor.checkAlarmCondition(); mAccelerometerSensor.checkAlarmCondition();
} }


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

public LiveData<Boolean> getAudiodetectionAndAccelerometerAlarmDetected() { public LiveData<Boolean> getAudiodetectionAndAccelerometerAlarmDetected() {
setMutableLiveDataMicrofondetectionAndAccelerometerAlarmDetected(); setMutableLiveDataMicrofondetectionAndAccelerometerAlarmDetected();
return mAudiodetectionAndAccelerometerAlarmDetected; return mAudiodetectionAndAccelerometerAlarmDetected;
} }


@Override @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); mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


} }


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


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



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

} }


@Override @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); mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


} }


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


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



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

} }


@Override @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); mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


} }


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


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



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

mAccelerometerSensor.checkAlarmCondition(); mAccelerometerSensor.checkAlarmCondition();
} }


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

public void bindImageAnalysis(ProcessCameraProvider cameraProvider, LifecycleOwner lifecycleOwner, Context context) { public void bindImageAnalysis(ProcessCameraProvider cameraProvider, LifecycleOwner lifecycleOwner, Context context) {
mCameraSensor.bindImageAnalysis(cameraProvider, lifecycleOwner, context); mCameraSensor.bindImageAnalysis(cameraProvider, lifecycleOwner, context);
} }
} }


@Override @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); mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


} }


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


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



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

} }


@Override @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); mDeviceRepository.updateDevice(deviceID, timeStamp, sensorStatus, sensorType, sensorMassage);
} }


} }


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


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



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

LiveData<List<Device>> getConnectedDeviceList(); LiveData<List<Device>> getConnectedDeviceList();
LiveData<List<Device>> getAlarmHistoryList(); LiveData<List<Device>> getAlarmHistoryList();
LiveData<Boolean> getStartAlarmRecording(); 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); void setTimeStamp(String deviceID, String timeStamp);
String getTimeStamp(String deviceID); String getTimeStamp(String deviceID);
void setDeviceID(String deviceID, String newDeviceID); void setDeviceID(String deviceID, String newDeviceID);
boolean getSensorStatus(String deviceID); boolean getSensorStatus(String deviceID);
void setSensorType(String deviceID, String sensorType); void setSensorType(String deviceID, String sensorType);
String getSensorType(String deviceID); 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 getLocalDeviceUUID();
String getSystemTimeStamp(); String getSystemTimeStamp();
} }

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

<string name="sensor_status_placeholder">Sensorstatus: %s</string> <string name="sensor_status_placeholder">Sensorstatus: %s</string>
<string name="deviceID_placeholder">Sensor-ID: %s</string> <string name="deviceID_placeholder">Sensor-ID: %s</string>
<string name="sensor_time_stamp_placeholder">Timestamp: %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> </resources>

Loading…
Cancel
Save