[UNSTABLE] First changes to the corpus in prep for new logging features
parent
e611eddbe3
commit
388899e07e
|
@ -9,10 +9,6 @@ class SequenceMigration
|
|||
@latest_version ||= self.descendants.map{ |k| k::VERSION }.max
|
||||
end
|
||||
|
||||
def self.inherited(subclass)
|
||||
@latest_version = nil
|
||||
end
|
||||
|
||||
attr_accessor :sequence
|
||||
|
||||
def initialize(sequence)
|
||||
|
|
|
@ -2,24 +2,21 @@
|
|||
# I am going to unclutter sequence.rb by sweeping CeleryScript config under
|
||||
# the rug.
|
||||
module CeleryScriptSettingsBag
|
||||
ALLOWED_PIN_MODES = [0, 1]
|
||||
ALLOWED_CHANNEL_NAMES = %w(ticker error_ticker success_toast error_toast
|
||||
warning_toast)
|
||||
ALLOWED_DATA_TYPES = %w(string integer)
|
||||
ALLOWED_OPS =%w(< > is not)
|
||||
ALLOWED_LHS = %w(x y z s busy param_version movement_timeout_x
|
||||
movement_timeout_y movement_timeout_z
|
||||
movement_invert_endpoints_x movement_invert_endpoints_y
|
||||
movement_invert_endpoints_z movement_invert_motor_x
|
||||
movement_invert_motor_y movement_invert_motor_z
|
||||
movement_steps_acc_dec_x movement_steps_acc_dec_y
|
||||
movement_steps_acc_dec_z movement_home_up_x
|
||||
movement_home_up_y movement_home_up_z movement_min_spd_x
|
||||
movement_min_spd_y movement_min_spd_z movement_max_spd_x
|
||||
movement_max_spd_y movement_max_spd_z time pin0 pin1 pin2
|
||||
pin3 pin4 pin5 pin6 pin7 pin8 pin9 pin10 pin11 pin12 pin13)
|
||||
ALLOWED_PIN_MODES = [0, 1]
|
||||
ALLOWED_MESSAGE_TYPES = %w(success busy warn error info fun)
|
||||
ALLOWED_CHANNEL_NAMES = %w(ticker toast)
|
||||
ALLOWED_DATA_TYPES = %w(string integer)
|
||||
ALLOWED_OPS = %w(< > is not)
|
||||
STEPS = %s(var_set var_get move_absolute move_relative write_pin read_pin wait
|
||||
send_message execute if_statement)
|
||||
ALLOWED_LHS = %w(x y z s busy param_version movement_timeout_x pin3 pin4 pin5
|
||||
movement_timeout_y movement_timeout_z movement_invert_endpoints_x pin6 pin7
|
||||
movement_invert_endpoints_y movement_invert_endpoints_z time pin0 pin1 pin2
|
||||
movement_invert_motor_x movement_invert_motor_y movement_invert_motor_z pin8
|
||||
movement_steps_acc_dec_x movement_steps_acc_dec_y movement_steps_acc_dec_z
|
||||
movement_home_up_x movement_home_up_y movement_home_up_z movement_min_spd_x
|
||||
movement_min_spd_y movement_min_spd_z movement_max_spd_x movement_max_spd_y
|
||||
movement_max_spd_z pin9 pin10 pin11 pin12 pin13)
|
||||
|
||||
Corpus = CeleryScript::Corpus
|
||||
.new
|
||||
|
@ -51,6 +48,12 @@ module CeleryScriptSettingsBag
|
|||
"Allowed values: #{ALLOWED_CHANNEL_NAMES.map(&:to_s).join(", ")}"
|
||||
end
|
||||
end
|
||||
.defineArg(:message_type, [String]) do |node|
|
||||
within(ALLOWED_MESSAGE_TYPES, node) do |val|
|
||||
"\"#{ val.to_s }\" is not a valid message_type. " \
|
||||
"Allowed values: #{ALLOWED_MESSAGE_TYPES.map(&:to_s).join(", ")}"
|
||||
end
|
||||
end
|
||||
.defineArg(:version, [Fixnum])
|
||||
.defineArg(:x, [Fixnum])
|
||||
.defineArg(:y, [Fixnum])
|
||||
|
@ -68,7 +71,7 @@ module CeleryScriptSettingsBag
|
|||
.defineNode(:read_pin, [:pin_number, :data_label, :pin_mode])
|
||||
.defineNode(:channel, [:channel_name])
|
||||
.defineNode(:wait, [:milliseconds])
|
||||
.defineNode(:send_message, [:message])
|
||||
.defineNode(:send_message, [:message, :message_type])
|
||||
.defineNode(:execute, [:sub_sequence_id])
|
||||
.defineNode(:if_statement, [:lhs, :op, :rhs, :sub_sequence_id])
|
||||
.defineNode(:sequence, [:version], STEPS)
|
||||
|
|
|
@ -18,7 +18,6 @@ module Sequences
|
|||
if theirs != ours
|
||||
puts "RUNNING MIGRATION ON SEQUENCE ##{sequence.id || 0}"
|
||||
SequenceMigration.generate_list(sequence).map(&:run)
|
||||
sequence.save! if save
|
||||
sequence.args["is_outdated"] = true
|
||||
end
|
||||
sequence
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"kind": "sequence",
|
||||
"comment": "Properly formatted, syntactically valid sequence.",
|
||||
"args": {
|
||||
"version": 0
|
||||
"version": 1
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
|
@ -48,8 +48,17 @@
|
|||
{
|
||||
"kind": "send_message",
|
||||
"args": {
|
||||
"message": "Bot at coord {{ x }} {{ y }} {{ z }}."
|
||||
}
|
||||
"message": "Bot at coord {{ x }} {{ y }} {{ z }}.",
|
||||
"message_type": "info"
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"kind": "channel",
|
||||
"args": {
|
||||
"channel_name": "toast"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"kind": "if_statement",
|
||||
|
|
|
@ -68,13 +68,15 @@ describe Sequences::Create do
|
|||
{
|
||||
kind: "send_message",
|
||||
args: {
|
||||
message: "Hello, world!"
|
||||
message: "Hello, world!",
|
||||
message_type: "warn"
|
||||
},
|
||||
# DOES NOT EXIST YET.
|
||||
body: [
|
||||
{
|
||||
kind: "channel",
|
||||
args: { channel_name: "success_toast"}
|
||||
args: {
|
||||
channel_name: "toast"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue