Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SeqJSON Import - Symbol arguments and Immediate/Hardware Commands #1302

Merged
merged 1 commit into from
May 24, 2024
Merged
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
82 changes: 80 additions & 2 deletions src/utilities/new-sequence-editor/from-seq-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,74 @@ describe('from-seq-json.ts', () => {
expect(sequence).toEqual(expectedSequence);
});

it('Symbols should not be quoted', () => {
const seqJson: SeqJson = {
id: 'testSymbol',
locals: [
{
name: 'L00UINT',
type: 'UINT',
},
{
name: 'L00INT',
type: 'INT',
},
{
name: 'L01INT',
type: 'INT',
},
],
metadata: {},

steps: [
{
args: [
{
type: 'symbol',
value: 'L00UINT',
},
{
type: 'number',
value: 10,
},
],
description: 'line argument',
stem: 'PYRO_FIRE',

time: {
type: 'COMMAND_COMPLETE',
},
type: 'command',
},
{
args: [
{
type: 'symbol',
value: 'L00INT',
},
{
type: 'symbol',
value: 'L01INT',
},
],
stem: 'DDM_BANANA',
time: {
type: 'COMMAND_COMPLETE',
},
type: 'command',
},
],
};
const sequence = seqJsonToSequence(seqJson, [], null);
const expectedSequence = `@ID "testSymbol"
@LOCALS L00UINT L00INT L01INT

C PYRO_FIRE L00UINT 10 # line argument
C DDM_BANANA L00INT L01INT
`;
expect(sequence).toEqual(expectedSequence);
});

it('converts a seq json LGO to sequence', () => {
const seqJson: SeqJson = {
id: 'test',
Expand Down Expand Up @@ -216,7 +284,7 @@ C FSW_CMD_3
const sequence = seqJsonToSequence(seqJson, [], null);
const expectedSequence = `@ID "42"

A2024-001T00:00:00 FSW_CMD_0 TRUE 0xFF "Hello" "World" [FALSE 0xAA "Foo" "BAR" TRUE 0xBB "Baz" "BAT"]
A2024-001T00:00:00 FSW_CMD_0 TRUE 0xFF "Hello" World [FALSE 0xAA "Foo" BAR TRUE 0xBB "Baz" BAT]
R00:01:00 FSW_CMD_1 22
E15:00:00 FSW_CMD_2 "Fab"
C FSW_CMD_3
Expand Down Expand Up @@ -378,6 +446,10 @@ C FSW_CMD_2 10 "ENUM" # fsw cmd 2 description
metadata: {},
stem: 'IC',
},
{
args: [],
stem: 'IC2',
},
{
args: [],
description: 'noop command, no arguments',
Expand All @@ -393,6 +465,7 @@ C FSW_CMD_2 10 "ENUM" # fsw cmd 2 description

@IMMEDIATE
IC "1" 2 3 # immediate command
IC2
NOOP # noop command, no arguments
@METADATA "processor" "VC1A"
`;
Expand All @@ -413,6 +486,9 @@ NOOP # noop command, no arguments
{
stem: 'HWC2',
},
{
stem: 'HWC3',
},
],
id: 'testHardware',
metadata: {},
Expand All @@ -425,7 +501,9 @@ NOOP # noop command, no arguments
HWC # hardware command
@METADATA "foo" "bar"
@METADATA "hardware" "HWC"
HWC2`;
HWC2
HWC3
`;
expect(sequence).toEqual(expectedSequence);
});

Expand Down
19 changes: 16 additions & 3 deletions src/utilities/new-sequence-editor/from-seq-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export function seqJsonBaseArgToSequence(
): string {
switch (arg.type) {
case 'string':
case 'symbol':
return `"${arg.value}"`;
case 'boolean':
return arg.value ? 'TRUE' : 'FALSE';
Expand Down Expand Up @@ -195,7 +194,14 @@ export function seqJsonToSequence(
const args = seqJsonArgsToSequence(icmd.args);
const description = icmd.description ? seqJsonDescriptionToSequence(icmd.description) : '';
const metadata = icmd.metadata ? seqJsonMetadataToSequence(icmd.metadata) : '';
sequence.push(`${icmd.stem}${args}${description}${metadata}`);
let immediateString = `${icmd.stem}${args}${description}`;
// add a new line if on doesn't exit at the end of the immediateString
if (!immediateString.endsWith('\n')) {
immediateString += '\n';
}
// Add metadata data if it exists
immediateString += metadata;
sequence.push(immediateString);
}
}

Expand All @@ -206,7 +212,14 @@ export function seqJsonToSequence(
for (const hdw of seqJson.hardware_commands) {
const description = hdw.description ? seqJsonDescriptionToSequence(hdw.description) : '';
const metadata = hdw.metadata ? seqJsonMetadataToSequence(hdw.metadata) : '';
sequence.push(`${hdw.stem}${description}${metadata}`);
let hardwareString = `${hdw.stem}${description}`;
// add a new line if on doesn't exit at the end of the immediateString
if (!hardwareString.endsWith('\n')) {
hardwareString += '\n';
}
// Add metadata data if it exists
hardwareString += metadata;
sequence.push(hardwareString);
}
}
}
Expand Down
Loading