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

Add immediate commands to the eDSL #827

Merged
merged 6 commits into from
Mar 31, 2023
Merged

Conversation

goetzrrGit
Copy link
Contributor

@goetzrrGit goetzrrGit commented Mar 29, 2023

Description

We had to make a change to how we define FSWCommands in the CommandTypescriptLib.ts file. Previously, FSWCommands in the Command Dictionary were defined as a single interface (CommandStem), but we now generate two interfaces: one for ImmediateStems and one for CommandStems in the eDSL.

ImmediateStem implants ImmediateCommand //from the TS Spec
CommandStem implements Command // from the TS Spec

When a user writes out a command in the editor, ex. Bake_Banana the IntelliSense presented a list of commands that are immediateCommand type. However, immediateCommand types cannot be added to the step[] in the Sequence as defined by the TS Spec, which includes [Command, Ground_Event, Ground_Block, Activate, Load].

To add an FSWCommand to the step[], you will have to use time literal methods, such as C.Bake_Banana. This will present the users with a list of commands that are of Command type. The aim of this change is to enable the editor to ensure that you are not passing a command with time attributes into an immediate_command[] unnecessarily, and vice versa.

Furthermore, this change enables us to detect potential issues with invalid seqJSON that may be generated, which could adversely impact downstream processes. By restricting the types of commands that can be added to the step[] and immediate_commands, we can catch any potential problems earlier.

We are currently in discussions with the SeqJSON Spec team to add a type: immediate for the ImmediateCommand type. Within the immediate_command[] array, the editor is not flagging C.<Command>. In TypeScript, an object literal can be used as a value of an interface if the object has all the same properties, and optionally some more, with compatible types as specified in the interface. However, adding type: immediate will resolve this issue. I have included a check in the generation of SeqJSON to notify the user, but we also want the editor to notify the user earlier.

Ex. with immediate commands

export default () =>
  Sequence.new({
    seqId: '',
    metadata: {},
    steps: [C.ADD_WATER],
    immediate_commands : [ADD_WATER]
  });

Ex. Invalid

export default () =>
  Sequence.new({
    seqId: '',
    metadata: {},
    steps: [ADD_WATER],
  });

// or

export default () =>
  Sequence.new({
    seqId: '',
    metadata: {},
    immediate_commands : [C.ADD_WATER]
  });

Verification

Updated and ran e2e test

@goetzrrGit goetzrrGit added the sequencing Anything related to the sequencing domain label Mar 29, 2023
@goetzrrGit goetzrrGit requested a review from a team as a code owner March 29, 2023 21:31
@goetzrrGit goetzrrGit requested a review from cohansen March 29, 2023 21:31
@goetzrrGit goetzrrGit force-pushed the add_immediate_commands branch from 2eaf178 to cab3a6e Compare March 29, 2023 21:41
@goetzrrGit goetzrrGit changed the title Add immediate commands Add immediate commands to the eDSL Mar 29, 2023
@goetzrrGit goetzrrGit force-pushed the add_immediate_commands branch from cab3a6e to d64f701 Compare March 29, 2023 22:30
@goetzrrGit goetzrrGit temporarily deployed to e2e-test March 29, 2023 22:30 — with GitHub Actions Inactive
@camargo camargo added the feature A new feature or feature request label Mar 30, 2023
A FSWCommand from the command dictionary was a Command STEP from the spec we can't use it as a immediate command. To get around this we are creating double interfaces and methods for the FSWCommand as both a Command STEP and Immediate Command.
…mand>, A.<command>, and E.<command> are added to the immediate_command section of a sequence.

Currently, there is an issue with typechecking that permits the addition of C.<command>, A.<command>, and E.<command> to the immediate_command section of a sequence. Although this is invalid, TypeScript (TS) is unable to perform a type check due to the immediate type being a subset of the command type. To resolve this, a possible solution is to incorporate "type: immediate" to the Immediate type. However, the SeqJSON team does not want to include this redundancy in the JSON specification. Thus, as a workaround, an error is generated in SeqJSON to alert the user of this invalid action.
@goetzrrGit goetzrrGit force-pushed the add_immediate_commands branch from d64f701 to d997307 Compare March 30, 2023 20:46
@goetzrrGit goetzrrGit temporarily deployed to e2e-test March 30, 2023 20:46 — with GitHub Actions Inactive
Copy link
Member

@camargo camargo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Tested locally and ran UI e2e tests against it.

@goetzrrGit goetzrrGit merged commit 717360f into develop Mar 31, 2023
@goetzrrGit goetzrrGit deleted the add_immediate_commands branch March 31, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature or feature request sequencing Anything related to the sequencing domain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Only allow FSW commands as immediate commands in the sequencing EDSL
2 participants