diff --git a/src/fprime_gds/flask/static/addons/commanding/argument-templates.js b/src/fprime_gds/flask/static/addons/commanding/argument-templates.js
index 0b7c6b07..3e1a9de1 100644
--- a/src/fprime_gds/flask/static/addons/commanding/argument-templates.js
+++ b/src/fprime_gds/flask/static/addons/commanding/argument-templates.js
@@ -15,6 +15,17 @@ export let command_enum_argument_template = `
`;
+/**
+ * Enum argument uses the v-select dropdown to render the various choices while providing search and match capabilities.
+ */
+export let command_bool_argument_template = `
+
+
+`;
+
/**
* Serializable arguments "flatten" the structure into a list of fields.
*/
@@ -64,8 +75,8 @@ export let command_scalar_argument_template = `
-
-
+
+
diff --git a/src/fprime_gds/flask/static/addons/commanding/arguments.js b/src/fprime_gds/flask/static/addons/commanding/arguments.js
index a957f515..1700fa3c 100644
--- a/src/fprime_gds/flask/static/addons/commanding/arguments.js
+++ b/src/fprime_gds/flask/static/addons/commanding/arguments.js
@@ -8,6 +8,7 @@
*/
import "../../third-party/js/vue-select.js"
import {
+ command_bool_argument_template,
command_enum_argument_template,
command_array_argument_template,
command_serializable_argument_template,
@@ -118,6 +119,35 @@ export function squashify_argument(argument) {
let field = argument.type.MEMBER_LIST[i][0];
value[field] = squashify_argument(argument.value[field]);
}
+ } else if (["U64Type", "U32Type", "U16Type", "U8Type"].indexOf(argument.type.name) != -1) {
+ if (argument.value.startsWith("0x")) {
+ // Hexadecimal
+ value = parseInt(argument.value, 16);
+ } else if (argument.value.startsWith("0b")) {
+ // Binary
+ value = parseInt(argument.value.slice(2), 2);
+ } else if (argument.value.startsWith("0o")) {
+ // Octal
+ value = parseInt(argument.value.slice(2), 8);
+ } else {
+ // Decimal
+ value = parseInt(argument.value, 10);
+ }
+ }
+ else if (["I64Type", "I32Type", "I16Type", "I8Type"].indexOf(argument.type.name) != -1) {
+ value = parseInt(argument.value, 10);
+ }
+ else if (["F64Type", "F32Type"].indexOf(argument.type.name) != -1) {
+ value = parseFloat(argument.value);
+ }
+ else if (argument.type.name == "BoolType") {
+ if ((typeof(value) === "string") && (["true", "yes"].indexOf(value.toLowerCase()) !== -1)) {
+ value = true;
+ } else if ((typeof(value) === "string") && (["false", "no"].indexOf(value.toLowerCase()) !== -1)) {
+ value = false;
+ } else {
+ console.assert(typeof(value) !== "boolean", "Cannot process boolean, invalid input type")
+ }
}
return value;
}
@@ -225,6 +255,14 @@ Vue.component("command-enum-argument", {
template: command_enum_argument_template,
});
+/**
+ * Special boolean processing component to render as a drop-down.
+ */
+Vue.component("command-bool-argument", {
+ ...base_argument_component_properties,
+ template: command_bool_argument_template,
+});
+
/**
* Scalar argument processing. Sets up the input type such that numbers can be input with the correct formatting.
*/
@@ -239,14 +277,14 @@ Vue.component("command-scalar-argument", {
*/
inputType() {
// Unsigned integer
- if (this.argument.type.name[0] == 'U') {
+ if (["U64Type", "U32Type", "U16Type", "U8Type"].indexOf(this.argument.type.name) != -1) {
// Supports binary, hex, octal, and digital
return ["text", "0[bB][01]+|0[oO][0-7]+|0[xX][0-9a-fA-F]+|[1-9]\\d*|0", ""];
}
- else if (this.argument.type.name[0] == 'I') {
+ else if (["I64Type", "I32Type", "I16Type", "I8Type"].indexOf(this.argument.type.name) != -1) {
return ["number", null, "1"];
}
- else if (this.argument.type.name[0] == 'F') {
+ else if (["F64Type", "F32Type"].indexOf(this.argument.type.name) != -1) {
return ["number", null, "any"];
}
return ["text", ".*", null];
diff --git a/src/fprime_gds/flask/static/js/datastore.js b/src/fprime_gds/flask/static/js/datastore.js
index 96664aaa..ee99cc16 100644
--- a/src/fprime_gds/flask/static/js/datastore.js
+++ b/src/fprime_gds/flask/static/js/datastore.js
@@ -274,6 +274,10 @@ class DataStore {
if (argument.type.ENUM_DICT) {
argument.value = Object.keys(argument.type.ENUM_DICT)[0];
}
+ // Booleans are initialized to True
+ else if (argument.type.name === "BoolType") {
+ argument.value = "True";
+ }
// Arrays expand to a set length of N pseudo-arguments
else if (argument.type.LENGTH) {
let array_length = argument.type.LENGTH;
diff --git a/src/fprime_gds/flask/static/js/validate.js b/src/fprime_gds/flask/static/js/validate.js
index 5543bd79..f2342c8d 100644
--- a/src/fprime_gds/flask/static/js/validate.js
+++ b/src/fprime_gds/flask/static/js/validate.js
@@ -116,6 +116,11 @@ export function validate_scalar_input(argument) {
argument.error = "";
return true;
}
+ // Boolean type handling
+ else if (argument.type.name === "BoolType") {
+ return (argument.value == null) ? null :
+ ["yes", "no", "true", "false"].indexOf(argument.value.toString().toLowerCase()) >= 0;
+ }
console.assert(false, "Unknown scalar type: " + argument.type.name);
argument.error = "";
return true;