Skip to content

Commit

Permalink
GS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dyka3773 committed Jan 17, 2024
1 parent 661fe84 commit c761c60
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Ground Station/dropstar_gui/static/js/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ function setSoundCardStatus(soundCard, status){
}

function setCameraStatus(camera, status){
if (status == false){
if (status == 0){
$(camera).html("OFF")
$(camera).removeClass()
$(camera).addClass("text-danger")
}
else if (status == true){
$(camera).html("ON")
else if (status == 2){
$(camera).html("RECORDING")
$(camera).removeClass()
$(camera).addClass("text-success")
}
Expand Down
26 changes: 20 additions & 6 deletions Ground Station/dropstar_gui/telecoms/rxsm_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import serial
import sqlite3 as sql

port = "COM6" # NOTE: This port may change depending on the computer
port = "COM5" # NOTE: This port may change depending on the computer


def receive_data():
Expand Down Expand Up @@ -44,7 +44,12 @@ def deserialize_data(data: bytes) -> tuple:
Returns:
tuple: The deserialized data.
"""
return tuple(data.decode().split(','))
deserialized_data = data.decode().split(',')

def omit_none_values(x):
return x if x != 'None' else None

return tuple(map(omit_none_values, deserialized_data))


def insert_data_in_db(data: tuple):
Expand All @@ -57,6 +62,7 @@ def insert_data_in_db(data: tuple):
cursor = db.cursor()
cursor.execute('''
INSERT INTO GS_DATA (
time,
motor_speed,
sound_card_status,
camera_status,
Expand All @@ -67,7 +73,7 @@ def insert_data_in_db(data: tuple):
SOE_signal,
SODS_signal,
error_code
) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', data)
db.commit()
logging.info(f'Inserted data: {data} in the database')
Expand All @@ -84,7 +90,7 @@ def create_db():
-- TODO: Add contraints in the values of the columns where needed
CREATE TABLE GS_DATA (
time DATETIME DEFAULT(STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')),
time DATETIME,
motor_speed INTEGER, -- The speed of the motor in (rpm?)
sound_card_status INTEGER, -- The status of the sound card. Possible values: 0 = OFF, 1 = ON, 2 = RECORDING, 3 = ERROR
camera_status INTEGER, -- The status of the camera. Possible values: 0 = OFF, 1 = ON, 2 = RECORDING, 3 = ERROR
Expand All @@ -95,9 +101,17 @@ def create_db():
LO_signal BOOLEAN, -- The status of the LO signal. Possible values: 0 = OFF, 1 = ON
SOE_signal BOOLEAN, -- The status of the SOE signal. Possible values: 0 = OFF, 1 = ON
SODS_signal BOOLEAN, -- The status of the SODS signal. Possible values: 0 = OFF, 1 = ON
error_code INTEGER, -- The error code of the system in case of an error. Possible values: TBD
PRIMARY KEY (time)
error_code INTEGER -- The error code of the system in case of an error. Possible values: TBD
);
''')
db.commit()
logging.info('Created table GS_data')


'''
-- This is the script to get the latest data from the database
SELECT TIME, MOTOR_SPEED, SOUND_CARD_STATUS, CAMERA_STATUS, TEMP_1, TEMP_2, TEMP_3, LO_SIGNAL, SOE_SIGNAL, SODS_SIGNAL, ERROR_CODE
FROM GS_DATA
ORDER BY TIME DESC
LIMIT 1;
'''

0 comments on commit c761c60

Please sign in to comment.