Possible fix for `settings saved` bug

pull/323/head
Rick Carlino 2017-04-06 13:34:55 -05:00
parent 1a1ccbff75
commit 390c1e8326
2 changed files with 9 additions and 1 deletions

View File

@ -7,6 +7,7 @@
module CeleryScriptSettingsBag
DIGITAL, ANALOG = 0, 1
ALLOWED_PIN_MODES = [DIGITAL, ANALOG]
ALLOWED_VAR_TYPES = %w(location)
ALLOWED_RPC_NODES = %w(home emergency_lock emergency_unlock read_status
sync check_updates power_off reboot toggle_pin
config_update calibrate execute move_absolute
@ -41,9 +42,14 @@ module CeleryScriptSettingsBag
BAD_TOOL_ID = 'Tool #%s does not exist.'
BAD_PACKAGE = '"%s" is not a valid package. Allowed values: %s'
BAD_AXIS = '"%s" is not a valid axis. Allowed values: %s'
BAD_VAR_TYPE = '"%s" is not a valid type. Allowed values: %s'
Corpus = CeleryScript::Corpus
.new
.defineArg(:var_type, [String]) do |node|
within(ALLOWED_VAR_TYPES, node) do |val|
BAD_VAR_TYPE % [val.to_s, ALLOWED_VAR_TYPES.inspect]
end
end
.defineArg(:pin_mode, [Fixnum]) do |node|
within(ALLOWED_PIN_MODES, node) do |val|
BAD_ALLOWED_PIN_MODES % [val.to_s, ALLOWED_PIN_MODES.inspect]
@ -147,6 +153,7 @@ module CeleryScriptSettingsBag
.defineNode(:add_point, [:location], [:pair])
.defineNode(:take_photo, [], [])
.defineNode(:data_update, [:value], [:pair])
.defineNode(:variable, [:var_type, :label], [])
# Given an array of allowed values and a CeleryScript AST node, will DETERMINE
# if the node contains a legal value. Throws exception and invalidates if not.

View File

@ -139,5 +139,6 @@ result.push(enum_type :LegalKindString, HASH[:nodes].map{ |x| x[:name] }.sort.un
result.push(enum_type :LegalSequenceKind, CeleryScriptSettingsBag::STEPS.sort)
result.push(enum_type :DataChangeType, CeleryScriptSettingsBag::ALLOWED_CHAGES)
result.push(enum_type :ResourceName, CeleryScriptSettingsBag::RESOURCE_NAME)
result.push(enum_type :BindingType, CeleryScriptSettingsBag::ALLOWED_VAR_TYPES)
puts result.join.gsub("\n\n\n", "\n")