@@ -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); | |||
} | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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 { |
@@ -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); | |||
} | |||
} | |||
}); |
@@ -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; | |||
} | |||
} |
@@ -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) { |
@@ -82,4 +82,8 @@ public class AccelerometerSensor { | |||
mAccelerometerAlarmDetected.setValue(false); | |||
} | |||
} | |||
public float getAccelerometerSensorMeanValue() { | |||
return meanValue; | |||
} | |||
} |
@@ -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); | |||
} | |||
@@ -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); | |||
} | |||
@@ -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); | |||
} | |||
@@ -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); | |||
} | |||
@@ -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); | |||
} | |||
@@ -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); | |||
} | |||
@@ -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(); | |||
} |
@@ -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> |