Skip to content

Commit

Permalink
SATF/SASF/SeqN converts
Browse files Browse the repository at this point in the history
* Converts parts of SeqN to SATF/SASF
* Converts parts SATF/SASF to SeqN
  • Loading branch information
goetzrrGit committed Dec 10, 2024
1 parent c20e281 commit e032b90
Show file tree
Hide file tree
Showing 3 changed files with 998 additions and 0 deletions.
172 changes: 172 additions & 0 deletions src/utilities/codemirror/satf/satf-sasf-utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import { describe, expect, it } from 'vitest';
import { satfToSequence } from './satf-sasf-utils';

describe('satfToSequence', () => {
it('should return empty header and sequences for empty SATF string', async () => {
const satf = '';
const result = await satfToSequence(satf);
expect(result).toEqual({ header: '', sequences: [] });
});

it('should return empty for invalid SATF string', async () => {
const satf = ' invalid satf string ';

const result = await satfToSequence(satf);
expect(result).toEqual({ header: '', sequences: [] });
});

it('should parse valid SATF string with header and sequences', async () => {
const satf = `
$$EOH
CCS3ZF0000100000001NJPL3KS0L015$$MARK$$;
MISSION_NAME = TEST;
CCSD3RE00000$$MARK$$NJPL3IF0M01400000001;
$$TEST SPACECRAFT ACTIVITY TYPE FILE
************************************************************
*PROJECT TEST
*SPACECRAFT 000
*Input files used:
*File Type Last modified File name
*SC_MODEL Thu Jan 01 00:00:00 UTC 1970 /Default Sequence Project/SC_MODEL/
************************************************************
$$EOH
absolute(temp,\\temp\\)
$$EOF
`;
const result = await satfToSequence(satf);
expect(result).toHaveProperty('header');
expect(result).toHaveProperty('sequences');
expect(result.sequences).toBeInstanceOf(Array);
});

it('should return empty sequences for SATF string with missing sequences', async () => {
const satf = `
CCS3ZF0000100000001NJPL3KS0L015$$MARK$$;
MISSION_NAME = TEST;
CCSD3RE00000$$MARK$$NJPL3IF0M01400000001;
$$TEST SPACECRAFT ACTIVITY TYPE FILE
************************************************************
*PROJECT TEST
*SPACECRAFT 000
*Input files used:
*File Type Last modified File name
*SC_MODEL Thu Jan 01 00:00:00 UTC 1970 /Default Sequence Project/SC_MODEL/
************************************************************
$$EOH
$$EOF
`;
const result = await satfToSequence(satf);
expect(result).toHaveProperty('header');
expect(result.sequences).toEqual([]);
});

it('should return empty header for SATF string with missing header', async () => {
const satf = `
$$EOH
absolute(temp,\\temp\\)
$$EOF
`;
const result = await satfToSequence(satf);
expect(result).toHaveProperty('sequences');
expect(result.header).toEqual('');
});

it('should return valid sequence with models', async () => {
const satf = `
$$EOH
ABSOLUTE_SEQUENCE(test,\\testv01\\,
STEPS,
command (
3472, SCHEDULED_TIME, \\00:01:00\\, FROM_ACTIVITY_START, INCLUSION_CONDITION, \\param_rate == receive_rate\\,
DRAW, \\VERTICAL\\,
COMMENT, \\This command turns the NIMS, to correct position.\\, ASSUMED_MODEL_VALUES, \\x=1,z=1.1,y="abc"\\,
01VV (param6, 10, false, "abc"),
PROCESSORS, "PRI", end),
end
)
$$EOF
`;
const result = await satfToSequence(satf);
expect(result).toHaveProperty('sequences');
expect(result.sequences[0]).toStrictEqual(`## test
R00:01:00 01VV param6 10 false "abc" # This command turns the NIMS, to correct position.
@MODEL(x,1,"00:00:00")
@MODEL(z,1.1,"00:00:00")
@MODEL(y,"abc","00:00:00")`);
});
});

describe('sasfToSequence', () => {
it('should return empty header and sequences for empty SATF string', async () => {
const sasf = '';
const result = await satfToSequence(sasf);
expect(result).toEqual({ header: '', sequences: [] });
});

it('should return empty invalid SATF string', async () => {
const sasf = ' invalid satf string ';

const result = await satfToSequence(sasf);
expect(result).toEqual({ header: '', sequences: [] });
});

it('should parse valid SASF string with header and sequences', async () => {
const sasf = `
$$EOH
CCS3ZF0000100000001NJPL3KS0L015$$MARK$$;
MISSION_NAME = TEST;
CCSD3RE00000$$MARK$$NJPL3IF0M01400000001;
$$TEST SPACECRAFT ACTIVITY TYPE FILE
************************************************************
*PROJECT TEST
*SPACECRAFT 000
*Input files used:
*File Type Last modified File name
*SC_MODEL Thu Jan 01 00:00:00 UTC 1970 /Default Sequence Project/SC_MODEL/
************************************************************
$$EOH
$$EOD
$$EOF
`;
const result = await satfToSequence(sasf);
expect(result).toHaveProperty('header');
expect(result).toHaveProperty('sequences');
expect(result.sequences).toBeInstanceOf(Array);
});

it('should return valid request with models', async () => {
const sasf = `
$$EOH
$$EOD
request(VFT2_REQUEST_01,
START_TIME, 2024-266T19:59:57,
REQUESTOR, "me",
PROCESSOR, "VC2AB",
KEY, "No_Key")
command(1,
SCHEDULED_TIME,\\00:00:01\\,FROM_PREVIOUS_START,
COMMENT,\\"this is a comment"\\,
FILE_REMOVE("/eng/seq/awesome.abs")
),
command(2,
SCHEDULED_TIME,\\00:00:01\\,FROM_PREVIOUS_START,
COMMENT,\\"cumulative_time is 2 sec"\\,
USER_SEQ_ECHO("SEQ awesome COMPLETION IN 2 MINS")
),
end;
$$EOF
`;
const result = await satfToSequence(sasf);
expect(result).toHaveProperty('sequences');
expect(result.sequences[0]).toStrictEqual(`R2024-266T19:59:57 @REQUEST_BEGIN("VFT2_REQUEST_01")
R00:00:01 FILE_REMOVE "/eng/seq/awesome.abs" # "this is a comment"
R00:00:01 USER_SEQ_ECHO "SEQ awesome COMPLETION IN 2 MINS" # "cumulative_time is 2 sec"
@REQUEST_END
@METADATA("REQUESTOR":"me")
@METADATA("PROCESSOR":"VC2AB")
@METADATA("KEY":"No_Key")
`);
});
});
Loading

0 comments on commit e032b90

Please sign in to comment.