Skip to content

Commit

Permalink
Backend support for Speacial Volume control buttons added
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumar-laxmi committed Feb 28, 2024
1 parent 5121c78 commit 03be70d
Show file tree
Hide file tree
Showing 10 changed files with 353 additions and 130 deletions.
3 changes: 1 addition & 2 deletions app/DashApp/Bowel/borborygmus_dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,5 @@ def loadAudioData(audioPath):
Input('audio-path-input', 'value')
)
def update_audio_data(audioPath):
#audioPath = 'app/static/audio/abdomen/borborygmus.wav'
audioPath = 'app/static/audio/heart/acute_pericarditis/A/combined_audio.wav'
audioPath = 'app/static/audio/abdomen/borborygmus.wav'
return loadAudioData(audioPath)
Binary file modified app/__pycache__/views.cpython-311.pyc
Binary file not shown.
76 changes: 75 additions & 1 deletion app/templates/elements/Scripts/volumeRangeControl.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/* Tricuspid Value */
"tricuspid_valve_regurgitation_sound",
/* Pathologies */
"coarctation_of_the_aorta_sound","hypertrophic_cardiomyopathy_sound","patent_ductus_arteriosus_sound","atrial_septal_defect_sound","ventricular_septal_defect_sound","acute_myocardial_infarction_sound","congestive_heart_failure_sound","systemic_hypertension_sound","acute_pericarditis_sound","dilated_cardiomyopathy_sound","pulmonary_hypertension_sound","tetralogy_of_fallot_sound","ventricular_aneurysm_sound","ebstein_anomaly_sound",
"coarctation_of_the_aorta_sound","hypertrophic_cardiomyopathy_sound","patent_ductus_arteriosus_sound","atrial_septal_defect_sound","ventricular_septal_defect_sound","acute_myocardial_infarction_sound","congestive_heart_failure_sound","systemic_hypertension_sound","acute_pericarditis_sound","dilated_cardiomyopathy_sound","pulmonary_hypertension_sound","tetralogy_of_fallot_sound","ventricular_aneurysm_sound","ebstein_anomaly_sound"
];

const lungFrontSounds = [
Expand Down Expand Up @@ -69,6 +69,80 @@
RLL: 'Right Lower Lobe'
}

// Javascript Range IDs
const mitralRangeID = ["normal_heart_sound_mitral_valve_range","split_first_heart_sound_mitral_valve_range","split_second_heart_sound_mitral_valve_range","third_heart_sound_mitral_valve_range","fourth_heart_sound_mitral_valve_range","functional_murmur_sound_mitral_valve_range","diastolic_murmur_sound_mitral_valve_range","opening_snap_sound_mitral_valve_range","holosystolic_murmur_sound_mitral_valve_range","early_systolic_murmur_sound_mitral_valve_range","mid_systolic_murmur_sound_mitral_valve_range","continuous_murmur_sound_mitral_valve_range","austin_flint_murmur_sound_mitral_valve_range","pericardial_rub_sound_mitral_valve_range","graham_steell_murmur_sound_mitral_valve_range","aortic_valve_regurgitation_sound_mitral_valve_range","aortic_valve_stenosis_sound_mitral_valve_range","aortic_valve_stenosis_regurgitation_sound_mitral_valve_range","congenital_aortic_stenosis_sound_mitral_valve_range","mitral_valve_regurgitation_sound_mitral_valve_range","mitral_valve_stenosis_sound_mitral_valve_range","mitral_valve_prelapse_sound_mitral_valve_range","mitral_stenosis_regurgitation_sound_mitral_valve_range","mitral_stenosis_tricuspid_regurgitation_sound_mitral_valve_range","pulmonary_valve_stenosis_sound_mitral_valve_range","pulmonary_valve_regurgitation_sound_mitral_valve_range","tricuspid_valve_regurgitation_sound_mitral_valve_range","coarctation_of_the_aorta_sound_mitral_valve_range","hypertrophic_cardiomyopathy_sound_mitral_valve_range","patent_ductus_arteriosus_sound_mitral_valve_range","atrial_septal_defect_sound_mitral_valve_range","ventricular_septal_defect_sound_mitral_valve_range","acute_myocardial_infarction_sound_mitral_valve_range","congestive_heart_failure_sound_mitral_valve_range","systemic_hypertension_sound_mitral_valve_range","acute_pericarditis_sound_mitral_valve_range","dilated_cardiomyopathy_sound_mitral_valve_range","pulmonary_hypertension_sound_mitral_valve_range","tetralogy_of_fallot_sound_mitral_valve_range","ventricular_aneurysm_sound_mitral_valve_range","ebstein_anomaly_sound_mitral_valve_range"];
const aorticRangeID = ["normal_heart_sound_aortic_valve_range","split_first_heart_sound_aortic_valve_range","split_second_heart_sound_aortic_valve_range","third_heart_sound_aortic_valve_range","fourth_heart_sound_aortic_valve_range","functional_murmur_sound_aortic_valve_range","diastolic_murmur_sound_aortic_valve_range","opening_snap_sound_aortic_valve_range","holosystolic_murmur_sound_aortic_valve_range","early_systolic_murmur_sound_aortic_valve_range","mid_systolic_murmur_sound_aortic_valve_range","continuous_murmur_sound_aortic_valve_range","austin_flint_murmur_sound_aortic_valve_range","pericardial_rub_sound_aortic_valve_range","graham_steell_murmur_sound_aortic_valve_range","aortic_valve_regurgitation_sound_aortic_valve_range","aortic_valve_stenosis_sound_aortic_valve_range","aortic_valve_stenosis_regurgitation_sound_aortic_valve_range","congenital_aortic_stenosis_sound_aortic_valve_range","mitral_valve_regurgitation_sound_aortic_valve_range","mitral_valve_stenosis_sound_aortic_valve_range","mitral_valve_prelapse_sound_aortic_valve_range","mitral_stenosis_regurgitation_sound_aortic_valve_range","mitral_stenosis_tricuspid_regurgitation_sound_aortic_valve_range","pulmonary_valve_stenosis_sound_aortic_valve_range","pulmonary_valve_regurgitation_sound_aortic_valve_range","tricuspid_valve_regurgitation_sound_aortic_valve_range","coarctation_of_the_aorta_sound_aortic_valve_range","hypertrophic_cardiomyopathy_sound_aortic_valve_range","patent_ductus_arteriosus_sound_aortic_valve_range","atrial_septal_defect_sound_aortic_valve_range","ventricular_septal_defect_sound_aortic_valve_range","acute_myocardial_infarction_sound_aortic_valve_range","congestive_heart_failure_sound_aortic_valve_range","systemic_hypertension_sound_aortic_valve_range","acute_pericarditis_sound_aortic_valve_range","dilated_cardiomyopathy_sound_aortic_valve_range","pulmonary_hypertension_sound_aortic_valve_range","tetralogy_of_fallot_sound_aortic_valve_range","ventricular_aneurysm_sound_aortic_valve_range","ebstein_anomaly_sound_aortic_valve_range"];
const pulmonaryRangeID = ["normal_heart_sound_pulmonary_valve_range","split_first_heart_sound_pulmonary_valve_range","split_second_heart_sound_pulmonary_valve_range","third_heart_sound_pulmonary_valve_range","fourth_heart_sound_pulmonary_valve_range","functional_murmur_sound_pulmonary_valve_range","diastolic_murmur_sound_pulmonary_valve_range","opening_snap_sound_pulmonary_valve_range","holosystolic_murmur_sound_pulmonary_valve_range","early_systolic_murmur_sound_pulmonary_valve_range","mid_systolic_murmur_sound_pulmonary_valve_range","continuous_murmur_sound_pulmonary_valve_range","austin_flint_murmur_sound_pulmonary_valve_range","pericardial_rub_sound_pulmonary_valve_range","graham_steell_murmur_sound_pulmonary_valve_range","aortic_valve_regurgitation_sound_pulmonary_valve_range","aortic_valve_stenosis_sound_pulmonary_valve_range","aortic_valve_stenosis_regurgitation_sound_pulmonary_valve_range","congenital_aortic_stenosis_sound_pulmonary_valve_range","mitral_valve_regurgitation_sound_pulmonary_valve_range","mitral_valve_stenosis_sound_pulmonary_valve_range","mitral_valve_prelapse_sound_pulmonary_valve_range","mitral_stenosis_regurgitation_sound_pulmonary_valve_range","mitral_stenosis_tricuspid_regurgitation_sound_pulmonary_valve_range","pulmonary_valve_stenosis_sound_pulmonary_valve_range","pulmonary_valve_regurgitation_sound_pulmonary_valve_range","tricuspid_valve_regurgitation_sound_pulmonary_valve_range","coarctation_of_the_aorta_sound_pulmonary_valve_range","hypertrophic_cardiomyopathy_sound_pulmonary_valve_range","patent_ductus_arteriosus_sound_pulmonary_valve_range","atrial_septal_defect_sound_pulmonary_valve_range","ventricular_septal_defect_sound_pulmonary_valve_range","acute_myocardial_infarction_sound_pulmonary_valve_range","congestive_heart_failure_sound_pulmonary_valve_range","systemic_hypertension_sound_pulmonary_valve_range","acute_pericarditis_sound_pulmonary_valve_range","dilated_cardiomyopathy_sound_pulmonary_valve_range","pulmonary_hypertension_sound_pulmonary_valve_range","tetralogy_of_fallot_sound_pulmonary_valve_range","ventricular_aneurysm_sound_pulmonary_valve_range","ebstein_anomaly_sound_pulmonary_valve_range"];
const tricuspidRangeID = ["normal_heart_sound_tricuspid_valve_range","split_first_heart_sound_tricuspid_valve_range","split_second_heart_sound_tricuspid_valve_range","third_heart_sound_tricuspid_valve_range","fourth_heart_sound_tricuspid_valve_range","functional_murmur_sound_tricuspid_valve_range","diastolic_murmur_sound_tricuspid_valve_range","opening_snap_sound_tricuspid_valve_range","holosystolic_murmur_sound_tricuspid_valve_range","early_systolic_murmur_sound_tricuspid_valve_range","mid_systolic_murmur_sound_tricuspid_valve_range","continuous_murmur_sound_tricuspid_valve_range","austin_flint_murmur_sound_tricuspid_valve_range","pericardial_rub_sound_tricuspid_valve_range","graham_steell_murmur_sound_tricuspid_valve_range","aortic_valve_regurgitation_sound_tricuspid_valve_range","aortic_valve_stenosis_sound_tricuspid_valve_range","aortic_valve_stenosis_regurgitation_sound_tricuspid_valve_range","congenital_aortic_stenosis_sound_tricuspid_valve_range","mitral_valve_regurgitation_sound_tricuspid_valve_range","mitral_valve_stenosis_sound_tricuspid_valve_range","mitral_valve_prelapse_sound_tricuspid_valve_range","mitral_stenosis_regurgitation_sound_tricuspid_valve_range","mitral_stenosis_tricuspid_regurgitation_sound_tricuspid_valve_range","pulmonary_valve_stenosis_sound_tricuspid_valve_range","pulmonary_valve_regurgitation_sound_tricuspid_valve_range","tricuspid_valve_regurgitation_sound_tricuspid_valve_range","coarctation_of_the_aorta_sound_tricuspid_valve_range","hypertrophic_cardiomyopathy_sound_tricuspid_valve_range","patent_ductus_arteriosus_sound_tricuspid_valve_range","atrial_septal_defect_sound_tricuspid_valve_range","ventricular_septal_defect_sound_tricuspid_valve_range","acute_myocardial_infarction_sound_tricuspid_valve_range","congestive_heart_failure_sound_tricuspid_valve_range","systemic_hypertension_sound_tricuspid_valve_range","acute_pericarditis_sound_tricuspid_valve_range","dilated_cardiomyopathy_sound_tricuspid_valve_range","pulmonary_hypertension_sound_tricuspid_valve_range","tetralogy_of_fallot_sound_tricuspid_valve_range","ventricular_aneurysm_sound_tricuspid_valve_range","ebstein_anomaly_sound_tricuspid_valve_range"];
const erbRangeID = ["normal_heart_sound_erbs_point_range","split_first_heart_sound_erbs_point_range","split_second_heart_sound_erbs_point_range","third_heart_sound_erbs_point_range","fourth_heart_sound_erbs_point_range","functional_murmur_sound_erbs_point_range","diastolic_murmur_sound_erbs_point_range","opening_snap_sound_erbs_point_range","holosystolic_murmur_sound_erbs_point_range","early_systolic_murmur_sound_erbs_point_range","mid_systolic_murmur_sound_erbs_point_range","continuous_murmur_sound_erbs_point_range","austin_flint_murmur_sound_erbs_point_range","pericardial_rub_sound_erbs_point_range","graham_steell_murmur_sound_erbs_point_range","aortic_valve_regurgitation_sound_erbs_point_range","aortic_valve_stenosis_sound_erbs_point_range","aortic_valve_stenosis_regurgitation_sound_erbs_point_range","congenital_aortic_stenosis_sound_erbs_point_range","mitral_valve_regurgitation_sound_erbs_point_range","mitral_valve_stenosis_sound_erbs_point_range","mitral_valve_prelapse_sound_erbs_point_range","mitral_stenosis_regurgitation_sound_erbs_point_range","mitral_stenosis_tricuspid_regurgitation_sound_erbs_point_range","pulmonary_valve_stenosis_sound_erbs_point_range","pulmonary_valve_regurgitation_sound_erbs_point_range","tricuspid_valve_regurgitation_sound_erbs_point_range","coarctation_of_the_aorta_sound_erbs_point_range","hypertrophic_cardiomyopathy_sound_erbs_point_range","patent_ductus_arteriosus_sound_erbs_point_range","atrial_septal_defect_sound_erbs_point_range","ventricular_septal_defect_sound_erbs_point_range","acute_myocardial_infarction_sound_erbs_point_range","congestive_heart_failure_sound_erbs_point_range","systemic_hypertension_sound_erbs_point_range","acute_pericarditis_sound_erbs_point_range","dilated_cardiomyopathy_sound_erbs_point_range","pulmonary_hypertension_sound_erbs_point_range","tetralogy_of_fallot_sound_erbs_point_range","ventricular_aneurysm_sound_erbs_point_range","ebstein_anomaly_sound_erbs_point_range"];

// Javascript Ranges
const mitralRanges = mitralRangeID.map(id => document.getElementById(id));
const aorticRanges = aorticRangeID.map(id => document.getElementById(id));
const pulmonaryRanges = pulmonaryRangeID.map(id => document.getElementById(id));
const tricuspidRanges = tricuspidRangeID.map(id => document.getElementById(id));
const erbRanges = erbRangeID.map(id => document.getElementById(id));

// Range Input Synchronizer - Mitral Valve
mitralRanges.forEach(range => {
range.addEventListener('input', () => {
const value = range.value;
ranges.forEach(otherRange => {
if (otherRange !== range) {
otherRange.value = value;
}
});
});
});

// Range Input Synchronizer - Aortic Valve
aorticRanges.forEach(range => {
range.addEventListener('input', () => {
const value = range.value;
ranges.forEach(otherRange => {
if (otherRange !== range) {
otherRange.value = value;
}
});
});
});

// Range Input Synchronizer - Pulmonary Valve
pulmonaryRanges.forEach(range => {
range.addEventListener('input', () => {
const value = range.value;
ranges.forEach(otherRange => {
if (otherRange !== range) {
otherRange.value = value;
}
});
});
});

// Range Input Synchronizer - Tricuspid Valve
tricuspidRanges.forEach(range => {
range.addEventListener('input', () => {
const value = range.value;
ranges.forEach(otherRange => {
if (otherRange !== range) {
otherRange.value = value;
}
});
});
});

// Range Input Synchronizer - Erb Point
erbRanges.forEach(range => {
range.addEventListener('input', () => {
const value = range.value;
ranges.forEach(otherRange => {
if (otherRange !== range) {
otherRange.value = value;
}
});
});
});

heartSounds.forEach(sound => {
Object.keys(valveNames).forEach(valve => {
const rangeInput = document.getElementById(sound + '_' + valve + '_range');
Expand Down
72 changes: 72 additions & 0 deletions app/templates/elements/Scripts/volumeUpdate.html
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,76 @@
});
});
});

// Update Volume - Mute all Speakers
$(document).ready(function () {
const muteVolume = ["mute_volume"];

muteVolume.forEach(function (identifier) {
$('#' + identifier).on('input', function () {
// Make an AJAX POST request
$.ajax({
url: 'muteVolume/', // Replace with your backend endpoint
method: 'POST',
data: { 'csrfmiddlewaretoken': '{{ csrf_token }}'}, // Send the range value as data
success: function (response) {
// Handle success response
console.log('POST request successful for ' + identifier + ':', response);
},
error: function (error) {
// Handle error response
console.error('Error in POST request for ' + identifier + ':', error);
}
});
});
});
});

// Update Volume - Default Volume to Speakers
$(document).ready(function () {
const defaultVolume = ["default_volume"];

defaultVolume.forEach(function (identifier) {
$('#' + identifier).on('input', function () {
// Make an AJAX POST request
$.ajax({
url: 'defaultVolume/', // Replace with your backend endpoint
method: 'POST',
data: { 'csrfmiddlewaretoken': '{{ csrf_token }}'}, // Send the range value as data
success: function (response) {
// Handle success response
console.log('POST request successful for ' + identifier + ':', response);
},
error: function (error) {
// Handle error response
console.error('Error in POST request for ' + identifier + ':', error);
}
});
});
});
});

// Update Volume - Full Volume to Speakers
$(document).ready(function () {
const fullVolume = ["full_volume"];

fullVolume.forEach(function (identifier) {
$('#' + identifier).on('input', function () {
// Make an AJAX POST request
$.ajax({
url: 'fullVolume/', // Replace with your backend endpoint
method: 'POST',
data: { 'csrfmiddlewaretoken': '{{ csrf_token }}'}, // Send the range value as data
success: function (response) {
// Handle success response
console.log('POST request successful for ' + identifier + ':', response);
},
error: function (error) {
// Handle error response
console.error('Error in POST request for ' + identifier + ':', error);
}
});
});
});
});
</script>
46 changes: 46 additions & 0 deletions app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,52 @@ def bowelVolumeChange(request):
else:
return HttpResponse("Request method is not a POST")

def muteVolume(request):
if request.method == 'POST':
for i in range(3,10):
os.system('amixer -c {} set Speaker 0%'.format(i))
print('Mitral Valve\'s Volume updated to 0%')
print('Aortic Valve\'s Volume updated to 0%')
print('Pulmonary Valve\'s Volume updated to 0%')
print('Tricuspid Valve\'s Volume updated to 0%')
print('Erb\'s Point\'s Volume updated to 0%')
print('Lungs\'s Volume updates to 0%')
print('Bowel\'s Volume updates to 0%')
return JsonResponse({'message': 'Success!'})
else:
return HttpResponse("Request method is not a POST")


def defaultVolume(request):
if request.method == 'POST':
for i in range(3,10):
os.system('amixer -c {} set Speaker 50%'.format(i))
print('Mitral Valve\'s Volume updated to 50%')
print('Aortic Valve\'s Volume updated to 50%')
print('Pulmonary Valve\'s Volume updated to 50%')
print('Tricuspid Valve\'s Volume updated to 50%')
print('Erb\'s Point\'s Volume updated to 50%')
print('Lungs\'s Volume updates to 50%')
print('Bowel\'s Volume updates to 50%')
return JsonResponse({'message': 'Success!'})
else:
return HttpResponse("Request method is not a POST")

def fullVolume(request):
if request.method == 'POST':
for i in range(3,10):
os.system('amixer -c {} set Speaker 100%'.format(i))
print('Mitral Valve\'s Volume updated to 100%')
print('Aortic Valve\'s Volume updated to 100%')
print('Pulmonary Valve\'s Volume updated to 100%')
print('Tricuspid Valve\'s Volume updated to 100%')
print('Erb\'s Point\'s Volume updated to 100%')
print('Lungs\'s Volume updates to 100%')
print('Bowel\'s Volume updates to 100%')
return JsonResponse({'message': 'Success!'})
else:
return HttpResponse("Request method is not a POST")

def start_mitral_thread(sound_name):
global playing_thread_mitral, stop_flag_mitral, hr_show, current_mitral_valve_sound
if playing_thread_mitral and playing_thread_mitral.is_alive():
Expand Down
Binary file modified core/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Loading

0 comments on commit 03be70d

Please sign in to comment.