Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions groundstation/backend_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class Telecommands(db.Model):
'AutomatedCommands', backref='command', lazy=True)
is_dangerous = db.Column(db.Boolean)
about_info = db.Column(db.String(256))
arg_labels = db.Column(db.String(400))
return_labels = db.Column(db.String(7000))

def to_json(self):
"""Returns a dictionary of some selected model attributes
Expand All @@ -118,7 +120,9 @@ def to_json(self):
'command_name': self.command_name,
'num_arguments': self.num_arguments,
'is_dangerous': self.is_dangerous,
'about_info': self.about_info
'about_info': self.about_info,
'arg_labels': self.arg_labels,
'return_labels': self.return_labels
}


Expand Down Expand Up @@ -228,6 +232,8 @@ def to_json(self):
# This will be the table of telecommands being sent to the satellite as well as the responses
# the table will allow us to send and receive all commands transactionally allowing us to log
# them as well as their responses


class Communications(db.Model):
__tablename__ = 'communications'

Expand Down Expand Up @@ -805,7 +811,8 @@ class EpsStartupHK(db.Model):

id = db.Column(db.Integer, primary_key=True, autoincrement=True)
hk_id = db.Column(db.Integer, db.ForeignKey('housekeeping.id'))
hk = db.relationship('Housekeeping', backref=backref('eps_startup', uselist=False))
hk = db.relationship('Housekeeping', backref=backref(
'eps_startup', uselist=False))

eps_cmd_startup = db.Column(db.Integer)
eps_status_startup = db.Column(db.Integer)
Expand Down
4 changes: 2 additions & 2 deletions groundstation/backend_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def decorate(*args, **kwargs):
return decorate


def add_telecommand(command_name, num_arguments, is_dangerous, about_info=None):
def add_telecommand(command_name, num_arguments, is_dangerous, about_info=None, arg_labels=None, return_labels=None):
"""Add a new telecommand to the database
"""
# only add command if it isn't already in the database
command = Telecommands.query.filter(
Telecommands.command_name == command_name).first()
if not command:
command = Telecommands(command_name=command_name, num_arguments=num_arguments,
is_dangerous=is_dangerous, about_info=about_info)
is_dangerous=is_dangerous, about_info=about_info, arg_labels=arg_labels, return_labels=return_labels)

db.session.add(command)
db.session.commit()
Expand Down
17 changes: 11 additions & 6 deletions groundstation/static/js/components/Help.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,7 @@ const Help = () => {
</Typography>
<Typography variant="h7" style={{ marginTop: '5px' }}>
<strong>command_name</strong>
<span style={{ fontStyle: 'italic' }}>
{' (number of arguments)'}
</span>
<span style={{ fontStyle: 'italic' }}>{' (arguments)'}</span>
</Typography>
<Paper
style={{
Expand All @@ -360,12 +358,19 @@ const Help = () => {
!!command.about_info ? (
<Typography variant="body1" style={{ paddingLeft: '10px' }}>
<strong>{command.command_name.slice(4)}</strong>
<span style={{ fontStyle: 'italic' }}>
{' (' + command.num_arguments + ')'}
</span>
{command.arg_labels != null ? (
<span style={{ fontStyle: 'italic' }}>
{' (' + command.arg_labels + ')'}
</span>
) : null}
{command.about_info != null ? (
<p style={{ paddingLeft: '5%' }}>{command.about_info}</p>
) : null}
{command.return_labels != null ? (
<p style={{ paddingLeft: '5%' }}>
{'Returns: ' + command.return_labels}
</p>
) : null}
<hr></hr>
</Typography>
) : null
Expand Down
20 changes: 18 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,36 @@ def import_commands():
sub = subservice[subName]
inoutInfo = sub['inoutInfo']
info = 'Not yet available' if not 'what' in sub else sub['what']

if inoutInfo['args'] is None:
num_arguments = 0
arg_list=None
else:
num_arguments = len(inoutInfo['args'])
arg_list=''
for arg in inoutInfo['args'].keys():
arg_list = arg_list + str(arg) + ', '
arg_list = arg_list[:-2]

if inoutInfo['returns'] is None:
num_returns = 0
return_list=None
else:
num_returns = len(inoutInfo['returns'])
return_list=''
for return_item in inoutInfo['returns'].keys():
return_list = return_list + str(return_item) + ', '
return_list = return_list[:-2]

is_dangerous = False
for i, prefix in enumerate(supported_prefixes):
if i == 0:
# Only one 'copy' of a command needs the about_info
add_telecommand(command_name=(prefix + '.' + serv + '.' + subName).lower(), num_arguments=num_arguments,
is_dangerous=is_dangerous, about_info=info)
is_dangerous=is_dangerous, about_info=info, arg_labels=arg_list, return_labels=return_list)
else:
add_telecommand(command_name=(prefix + '.' + serv + '.' + subName).lower(), num_arguments=num_arguments,
is_dangerous=is_dangerous, about_info=None)
is_dangerous=is_dangerous, about_info=None, arg_labels=None, return_labels=None)

print("Added new telecommands.")

Expand Down