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

Sequence Editor Ground epoch time tag #1443

Merged
merged 6 commits into from
Sep 17, 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
2 changes: 1 addition & 1 deletion src/utilities/codemirror/custom-folder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const GROUND_ACTIVITIES = [
];

const REQUEST_ACTIVITIES = [
`@GROUND_EPOCH("Name", "+0.00") @REQUEST_BEGIN("request.name")
`G+00:00:00 "Name" @REQUEST_BEGIN("request.name")
C SEQ_ECHO ""
@METADATA "Key" "Value"
@METADATA "Key1" "Value"
Expand Down
1 change: 1 addition & 0 deletions src/utilities/codemirror/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const SeqLanguage = LRLanguage.define({
TimeAbsolute: t.className,
TimeComplete: t.className,
TimeEpoch: t.className,
TimeGroundEpoch: t.className,
TimeRelative: t.className,
}),
],
Expand Down
23 changes: 5 additions & 18 deletions src/utilities/codemirror/sequence.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ HardwareCommands {
commandBlock
}

TimeTag { TimeAbsolute | TimeEpoch | TimeRelative | TimeComplete }
TimeTag { TimeAbsolute | (TimeGroundEpoch Name { String } whiteSpace) | TimeEpoch | TimeRelative | TimeComplete }

Args {
(whiteSpace (arg | RepeatArg))* whiteSpace?
Expand Down Expand Up @@ -118,20 +118,7 @@ commonGround {
}

Request {
(TimeTag | GroundEpoch {
groundEpochDirective
"("
whiteSpace?
Name { String }
whiteSpace?
","
whiteSpace?
Delta { String }
whiteSpace?
")"
// Extra properties are allowed in schema, but not supported by tool chain
whiteSpace
})
TimeTag
requestStartDirective "(" RequestName { String } ")"
whiteSpace? LineComment? newLine
// json schema requires step+, catch error in linter for cleaner message
Expand Down Expand Up @@ -190,6 +177,8 @@ Stem { !stemStart identifier }

TimeEpoch { 'E'$[+\-]?(timeSecond | timeDOY | timeHhmmss) whiteSpace}

TimeGroundEpoch { 'G'$[+\-]?(timeSecond | timeDOY | timeHhmmss) whiteSpace}

TimeComplete { 'C' whiteSpace }

String { '"' (!["\\] | "\\" _)* '"' }
Expand Down Expand Up @@ -224,7 +213,6 @@ Stem { !stemStart identifier }
loadDirective { "@LOAD" }
engineDirective { "@ENGINE" }
epochDirective { "@EPOCH" }
groundEpochDirective { "@GROUND_EPOCH" }
groundBlockDirective { "@GROUND_BLOCK" }
groundEventDirective { "@GROUND_EVENT" }
requestStartDirective { "@REQUEST_BEGIN" }
Expand All @@ -235,7 +223,7 @@ Stem { !stemStart identifier }

@precedence { newLine, whiteSpace }

@precedence{ TimeAbsolute, TimeRelative, TimeEpoch, TimeComplete, Boolean, identifier }
@precedence{ TimeAbsolute, TimeRelative, TimeEpoch, TimeComplete, TimeGroundEpoch, Boolean, identifier }

@precedence {
LoadAndGoDirective,
Expand All @@ -250,7 +238,6 @@ Stem { !stemStart identifier }
loadDirective,
groundBlockDirective,
groundEventDirective,
groundEpochDirective,
requestStartDirective,
requestEndDirective,
engineDirective,
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/sequence-editor/from-seq-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ C FSA_CMD 10 [] "USA" ["96707-898" "92604-623"]
const sequence = await seqJsonToSequence(JSON.stringify(seqJson));
const expectedSequence = `
@ID "id"
@GROUND_EPOCH("GroundEpochName", "+3:00") @REQUEST_BEGIN("request2.name")
G+3:00 "GroundEpochName" @REQUEST_BEGIN("request2.name")
C CMD_0 1 2 3
@METADATA "cmd_0_meta_name_0" "cmd_0_meta_value_0"
@MODEL "a" 1 "00:00:00"
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/sequence-editor/from-seq-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function requestToString(request: Request) {
if (request.time) {
time = seqJsonTimeToSequence(request.time);
} else if (request.ground_epoch) {
time = `@GROUND_EPOCH(${quoteEscape(request.ground_epoch.name ?? '')}, ${quoteEscape(request.ground_epoch.delta ?? '')})`;
time = `G${request.ground_epoch.delta ?? ''} ${quoteEscape(request.ground_epoch.name ?? '')}`;
}
const reqBegin = `@REQUEST_BEGIN(${quoteEscape(request.name)})`;
const description = request.description ? seqJsonDescriptionToSequence(request.description) : '';
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/sequence-editor/grammar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ A2024-321T11:22:33 @LOAD("load.name") # No Args
@EPOCH "epoch string"
R123T12:34:56 @LOAD("load2.name") "foo" 1 2 3 # A comment
@ENGINE -1
@GROUND_EPOCH("Name","+3:00") @REQUEST_BEGIN("request.name") # Description Text
G3 "Name" @REQUEST_BEGIN("request.name") # Description Text
C CMD_0 1 2 3
@METADATA "foo" "bar"
@MODEL "a" 1 "00:00:00"
Expand Down Expand Up @@ -360,7 +360,7 @@ Sequence(Commands(
Load(TimeTag(TimeAbsolute),SequenceName(String),Args,LineComment,Engine(Number),Epoch(String)),
Load(TimeTag(TimeRelative),SequenceName(String),Args(String,Number,Number,Number),LineComment,Engine(Number)),
Request(
GroundEpoch(Name(String),Delta(String)),
TimeTag(TimeGroundEpoch,Name(String)),
RequestName(String),LineComment,
Steps(
Command(TimeTag(TimeComplete),Stem,Args(Number,Number,Number),Metadata(MetaEntry(Key(String),Value(String))),Models(Model(Variable(String),Value(Number),Offset(String)))),
Expand Down
46 changes: 23 additions & 23 deletions src/utilities/sequence-editor/sequence-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { getCustomArgDef } from './extension-points';

type CursorInfo = {
isAfterActivateOrLoad: boolean;
isAfterTimeTag: boolean;
isAtLineComment: boolean;
isAtSymbolBefore: boolean;
isBeforeHDWCommands: boolean;
isBeforeImmedOrHDWCommands: boolean;
isTimeTagBefore: boolean;
position: number;
};

Expand Down Expand Up @@ -51,18 +51,18 @@ export function sequenceCompletion(

const cursor: CursorInfo = {
isAfterActivateOrLoad: nodeBefore.parent?.name === 'Activate' || nodeBefore.parent?.name === 'Load',
isAfterTimeTag: (() => {
const line = context.state.doc.lineAt(context.pos);
const node = SeqLanguage.parser.parse(line.text).resolveInner(context.pos - line.from, -1);

return node.parent?.getChild('TimeGroundEpoch') || node.parent?.getChild('TimeTag') ? true : false;
})(),
isAtLineComment: nodeCurrent.name === 'LineComment' || nodeBefore.name === 'LineComment',
isAtSymbolBefore: isAtTyped(context.state.doc.toString(), word),
isBeforeHDWCommands: context.pos < (baseNode.getChild('HardwareCommands')?.from ?? Infinity),
isBeforeImmedOrHDWCommands:
context.pos <
(baseNode.getChild('ImmediateCommands')?.from ?? baseNode.getChild('HardwareCommands')?.from ?? Infinity),
isTimeTagBefore: (() => {
const line = context.state.doc.lineAt(context.pos);
const node = SeqLanguage.parser.parse(line.text).resolveInner(context.pos - line.from, -1);

return node.parent?.getChild('GroundEpoch') || node.parent?.getChild('TimeTag') ? true : false;
})(),
position: context.pos,
};

Expand Down Expand Up @@ -112,7 +112,7 @@ export function sequenceCompletion(
},
);

if (!cursor.isTimeTagBefore) {
if (!cursor.isAfterTimeTag) {
//get the first of the year date
const date = new Date();
date.setMonth(0);
Expand Down Expand Up @@ -151,10 +151,10 @@ export function sequenceCompletion(
type: 'keyword',
},
{
apply: `${cursor.isAtSymbolBefore ? '' : '@'}GROUND_EPOCH("Name","+0.00") `,
apply: 'G1 "epoch.name" ',
info: 'Add a ground epoch to a request',
label: '@GROUND_EPOCH',
section: 'Ground Directives',
label: 'G (ground epoch)',
section: 'Time Tags',
type: 'keyword',
},
);
Expand Down Expand Up @@ -184,7 +184,7 @@ export function sequenceCompletion(

// If TimeTag has not been entered by the user wait for 2 characters before showing the command completions list
// If TimeTag has been entered show the completion list when 1 character has been entered
if (word.text.length > (cursor.isTimeTagBefore || cursor.isBeforeImmedOrHDWCommands === false ? 0 : 1)) {
if (word.text.length > (cursor.isAfterTimeTag || cursor.isBeforeImmedOrHDWCommands === false ? 0 : 1)) {
fswCommandsCompletions.push(
...generateCommandCompletions(channelDictionary, commandDictionary, cursor, parameterDictionaries),
);
Expand Down Expand Up @@ -276,7 +276,7 @@ function generateCommandCompletions(
apply = `${stem} ${argsStr} `;
}

if (!cursor.isTimeTagBefore && cursor.isBeforeImmedOrHDWCommands) {
if (!cursor.isAfterTimeTag && cursor.isBeforeImmedOrHDWCommands) {
apply = 'C ' + apply;
}

Expand Down Expand Up @@ -328,8 +328,8 @@ function generateStepCompletion(cursor: CursorInfo): Completion[] {
apply: (view, _completion, from: number, to: number) => {
view.dispatch({
changes: {
from: Math.max(0, from + (!cursor.isTimeTagBefore || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isTimeTagBefore ? 'C ' : ''}@GROUND_EVENT("ground_event.name")`,
from: Math.max(0, from + (!cursor.isAfterTimeTag || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isAfterTimeTag ? 'C ' : ''}@GROUND_EVENT("ground_event.name")`,
to,
},
});
Expand All @@ -344,8 +344,8 @@ function generateStepCompletion(cursor: CursorInfo): Completion[] {
apply: (view, _completion, from: number, to: number) => {
view.dispatch({
changes: {
from: Math.max(0, from + (!cursor.isTimeTagBefore || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isTimeTagBefore ? 'C ' : ''}@GROUND_BLOCK("ground_block.name")`,
from: Math.max(0, from + (!cursor.isAfterTimeTag || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isAfterTimeTag ? 'C ' : ''}@GROUND_BLOCK("ground_block.name")`,
to,
},
});
Expand All @@ -360,8 +360,8 @@ function generateStepCompletion(cursor: CursorInfo): Completion[] {
apply: (view, _completion, from: number, to: number) => {
view.dispatch({
changes: {
from: Math.max(0, from + (!cursor.isTimeTagBefore || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isTimeTagBefore ? 'C ' : ''}@ACTIVATE("activate.name")`,
from: Math.max(0, from + (!cursor.isAfterTimeTag || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isAfterTimeTag ? 'C ' : ''}@ACTIVATE("activate.name")`,
to,
},
});
Expand All @@ -376,8 +376,8 @@ function generateStepCompletion(cursor: CursorInfo): Completion[] {
apply: (view, _completion, from: number, to: number) => {
view.dispatch({
changes: {
from: Math.max(0, from + (!cursor.isTimeTagBefore || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isTimeTagBefore ? 'C ' : ''}@LOAD("load.name")`,
from: Math.max(0, from + (!cursor.isAfterTimeTag || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isAfterTimeTag ? 'C ' : ''}@LOAD("load.name")`,
to,
},
});
Expand Down Expand Up @@ -427,8 +427,8 @@ function generateStepCompletion(cursor: CursorInfo): Completion[] {
apply: (view, _completion, from: number, to: number) => {
view.dispatch({
changes: {
from: Math.max(0, from + (!cursor.isTimeTagBefore || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isTimeTagBefore ? 'C ' : ''}@REQUEST_BEGIN("request.name")
from: Math.max(0, from + (!cursor.isAfterTimeTag || cursor.isAtSymbolBefore ? -1 : 0)),
insert: `${!cursor.isAfterTimeTag ? 'C ' : ''}@REQUEST_BEGIN("request.name")
#Commands go here
@REQUEST_END`,
to,
Expand Down
Loading
Loading