Search in sources :

Example 1 with ParseResult

use of org.yamcs.studio.commanding.CommandParser.ParseResult in project yamcs-studio by yamcs.

the class CommandParserTest method testDoubleQuotedStringArguments.

@Test
public void testDoubleQuotedStringArguments() {
    ParseResult commandType = CommandParser.parseCommand("/YSS/SIMULATOR/TestCmd(Param: \"Hello world\")");
    assertEquals("/YSS/SIMULATOR/TestCmd", commandType.getQualifiedName());
    assertEquals(1, commandType.getAssignments().size());
    Assignment arg0 = commandType.getAssignments().get(0);
    assertEquals("Param", arg0.getName());
    assertEquals("Hello world", arg0.getValue());
}
Also used : Assignment(org.yamcs.protobuf.Rest.IssueCommandRequest.Assignment) ParseResult(org.yamcs.studio.commanding.CommandParser.ParseResult) Test(org.junit.Test)

Example 2 with ParseResult

use of org.yamcs.studio.commanding.CommandParser.ParseResult in project yamcs-studio by yamcs.

the class CommandParserTest method testStringArgumentEscaping.

@Test
public void testStringArgumentEscaping() {
    // Actual test string after java interpets it: '\'Hello\' \"world\"'
    // which our parser should interpet then as: 'Hello' "world"
    ParseResult commandType = CommandParser.parseCommand("/YSS/SIMULATOR/TestCmd(Param: '\\'Hello\\' \\\"world\\\"')");
    assertEquals("/YSS/SIMULATOR/TestCmd", commandType.getQualifiedName());
    assertEquals(1, commandType.getAssignments().size());
    Assignment arg0 = commandType.getAssignments().get(0);
    assertEquals("Param", arg0.getName());
    assertEquals("'Hello' \"world\"", arg0.getValue());
}
Also used : Assignment(org.yamcs.protobuf.Rest.IssueCommandRequest.Assignment) ParseResult(org.yamcs.studio.commanding.CommandParser.ParseResult) Test(org.junit.Test)

Example 3 with ParseResult

use of org.yamcs.studio.commanding.CommandParser.ParseResult in project yamcs-studio by yamcs.

the class Yamcs method issueCommand.

public static void issueCommand(String text) {
    ParseResult parsed = CommandParser.parseCommand(text);
    IssueCommandRequest.Builder req = IssueCommandRequest.newBuilder();
    req.setSequenceNumber(CommandingCatalogue.getInstance().getNextCommandClientId());
    req.setOrigin(CommandingCatalogue.getInstance().getCommandOrigin());
    req.addAllAssignment(parsed.getAssignments());
    CommandingCatalogue catalogue = CommandingCatalogue.getInstance();
    catalogue.sendCommand("realtime", parsed.getQualifiedName(), req.build());
}
Also used : ParseResult(org.yamcs.studio.commanding.CommandParser.ParseResult) CommandingCatalogue(org.yamcs.studio.core.model.CommandingCatalogue) IssueCommandRequest(org.yamcs.protobuf.Rest.IssueCommandRequest)

Example 4 with ParseResult

use of org.yamcs.studio.commanding.CommandParser.ParseResult in project yamcs-studio by yamcs.

the class CommandParserTest method testNoArguments.

@Test
public void testNoArguments() {
    ParseResult commandType = CommandParser.parseCommand("/YSS/SIMULATOR/SWITCH_VOLTAGE_ON()");
    assertEquals("/YSS/SIMULATOR/SWITCH_VOLTAGE_ON", commandType.getQualifiedName());
    assertEquals(0, commandType.getAssignments().size());
}
Also used : ParseResult(org.yamcs.studio.commanding.CommandParser.ParseResult) Test(org.junit.Test)

Example 5 with ParseResult

use of org.yamcs.studio.commanding.CommandParser.ParseResult in project yamcs-studio by yamcs.

the class CommandParserTest method testSingleQuotedStringArguments.

@Test
public void testSingleQuotedStringArguments() {
    ParseResult commandType = CommandParser.parseCommand("/YSS/SIMULATOR/TestCmd(Param: 'Hello world')");
    assertEquals("/YSS/SIMULATOR/TestCmd", commandType.getQualifiedName());
    assertEquals(1, commandType.getAssignments().size());
    Assignment arg0 = commandType.getAssignments().get(0);
    assertEquals("Param", arg0.getName());
    assertEquals("Hello world", arg0.getValue());
}
Also used : Assignment(org.yamcs.protobuf.Rest.IssueCommandRequest.Assignment) ParseResult(org.yamcs.studio.commanding.CommandParser.ParseResult) Test(org.junit.Test)

Aggregations

ParseResult (org.yamcs.studio.commanding.CommandParser.ParseResult)6 Test (org.junit.Test)5 Assignment (org.yamcs.protobuf.Rest.IssueCommandRequest.Assignment)4 IssueCommandRequest (org.yamcs.protobuf.Rest.IssueCommandRequest)1 CommandingCatalogue (org.yamcs.studio.core.model.CommandingCatalogue)1