Corpus update
parent
856e19147e
commit
bce9f4385f
|
@ -22,13 +22,14 @@
|
|||
{
|
||||
"name": "ALLOWED_MESSAGE_TYPES",
|
||||
"allowed_values": [
|
||||
"success",
|
||||
"assertion",
|
||||
"busy",
|
||||
"warn",
|
||||
"debug",
|
||||
"error",
|
||||
"info",
|
||||
"fun",
|
||||
"debug"
|
||||
"info",
|
||||
"success",
|
||||
"warn"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -55,6 +56,15 @@
|
|||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ALLOWED_ASSERTION_TYPES",
|
||||
"allowed_values": [
|
||||
"abort",
|
||||
"recover",
|
||||
"abort_recover",
|
||||
"continue"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "AllowedPinTypes",
|
||||
"allowed_values": [
|
||||
|
@ -89,6 +99,7 @@
|
|||
"name": "LegalSequenceKind",
|
||||
"allowed_values": [
|
||||
"_if",
|
||||
"assertion",
|
||||
"calibrate",
|
||||
"change_ownership",
|
||||
"check_updates",
|
||||
|
@ -109,7 +120,6 @@
|
|||
"read_status",
|
||||
"reboot",
|
||||
"remove_farmware",
|
||||
"resource_update",
|
||||
"send_message",
|
||||
"set_servo_angle",
|
||||
"set_user_env",
|
||||
|
@ -117,6 +127,7 @@
|
|||
"take_photo",
|
||||
"toggle_pin",
|
||||
"update_farmware",
|
||||
"update_resource",
|
||||
"wait",
|
||||
"write_pin",
|
||||
"zero"
|
||||
|
@ -206,7 +217,8 @@
|
|||
"planned",
|
||||
"planted",
|
||||
"harvested",
|
||||
"sprouted"
|
||||
"sprouted",
|
||||
"removed"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -214,24 +226,18 @@
|
|||
"allowed_values": [
|
||||
"GenericPointer",
|
||||
"ToolSlot",
|
||||
"Plant"
|
||||
"Plant",
|
||||
"Weed"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "resource_type",
|
||||
"allowed_values": [
|
||||
"Device",
|
||||
"FarmEvent",
|
||||
"Image",
|
||||
"Log",
|
||||
"Peripheral",
|
||||
"Plant",
|
||||
"Point",
|
||||
"Regimen",
|
||||
"Sequence",
|
||||
"Tool",
|
||||
"Plant",
|
||||
"ToolSlot",
|
||||
"User",
|
||||
"Weed",
|
||||
"GenericPointer"
|
||||
]
|
||||
},
|
||||
|
@ -261,11 +267,13 @@
|
|||
"z",
|
||||
"pin_type",
|
||||
"pointer_id",
|
||||
"point_group_id",
|
||||
"pointer_type",
|
||||
"pin_mode",
|
||||
"sequence_id",
|
||||
"lhs",
|
||||
"op",
|
||||
"priority",
|
||||
"channel_name",
|
||||
"message_type",
|
||||
"tool_id",
|
||||
|
@ -273,19 +281,22 @@
|
|||
"axis",
|
||||
"message",
|
||||
"speed",
|
||||
"resource_type"
|
||||
"resource_type",
|
||||
"assertion_type",
|
||||
"lua",
|
||||
"resource"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "LegalKindString",
|
||||
"allowed_values": [
|
||||
"Assertion",
|
||||
"If",
|
||||
"Calibrate",
|
||||
"ChangeOwnership",
|
||||
"Channel",
|
||||
"CheckUpdates",
|
||||
"Coordinate",
|
||||
"DumpInfo",
|
||||
"EmergencyLock",
|
||||
"EmergencyUnlock",
|
||||
"ExecuteScript",
|
||||
|
@ -331,7 +342,10 @@
|
|||
"MoveAbsolute",
|
||||
"WritePin",
|
||||
"ReadPin",
|
||||
"ResourceUpdate"
|
||||
"ResourceUpdate",
|
||||
"Resource",
|
||||
"UpdateResource",
|
||||
"PointGroup"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -394,6 +408,10 @@
|
|||
{
|
||||
"tag": "identifier",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"tag": "point_group",
|
||||
"name": "point_group"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -625,6 +643,15 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "point_group_id",
|
||||
"allowed_values": [
|
||||
{
|
||||
"tag": "integer",
|
||||
"name": "Integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "pointer_type",
|
||||
"allowed_values": [
|
||||
|
@ -674,6 +701,15 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "priority",
|
||||
"allowed_values": [
|
||||
{
|
||||
"tag": "integer",
|
||||
"name": "Integer"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "channel_name",
|
||||
"allowed_values": [
|
||||
|
@ -745,9 +781,53 @@
|
|||
"name": "resource_type"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "assertion_type",
|
||||
"allowed_values": [
|
||||
{
|
||||
"tag": "ALLOWED_ASSERTION_TYPES",
|
||||
"name": "ALLOWED_ASSERTION_TYPES"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "lua",
|
||||
"allowed_values": [
|
||||
{
|
||||
"tag": "string",
|
||||
"name": "String"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "resource",
|
||||
"allowed_values": [
|
||||
{
|
||||
"tag": "identifier",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"tag": "resource",
|
||||
"name": "resource"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"allowed_args": [
|
||||
"assertion_type",
|
||||
"_then",
|
||||
"lua"
|
||||
],
|
||||
"allowed_body_types": [],
|
||||
"name": "assertion",
|
||||
"tags": [
|
||||
"*"
|
||||
],
|
||||
"docs": ""
|
||||
},
|
||||
{
|
||||
"allowed_args": [
|
||||
"lhs",
|
||||
|
@ -1151,9 +1231,11 @@
|
|||
},
|
||||
{
|
||||
"allowed_args": [
|
||||
"label"
|
||||
"label",
|
||||
"priority"
|
||||
],
|
||||
"allowed_body_types": [
|
||||
"assertion",
|
||||
"calibrate",
|
||||
"change_ownership",
|
||||
"check_updates",
|
||||
|
@ -1175,7 +1257,7 @@
|
|||
"read_status",
|
||||
"reboot",
|
||||
"remove_farmware",
|
||||
"resource_update",
|
||||
"update_resource",
|
||||
"send_message",
|
||||
"set_servo_angle",
|
||||
"set_user_env",
|
||||
|
@ -1225,6 +1307,7 @@
|
|||
"locals"
|
||||
],
|
||||
"allowed_body_types": [
|
||||
"assertion",
|
||||
"calibrate",
|
||||
"change_ownership",
|
||||
"check_updates",
|
||||
|
@ -1246,7 +1329,7 @@
|
|||
"read_status",
|
||||
"reboot",
|
||||
"remove_farmware",
|
||||
"resource_update",
|
||||
"update_resource",
|
||||
"send_message",
|
||||
"set_servo_angle",
|
||||
"set_user_env",
|
||||
|
@ -1459,6 +1542,45 @@
|
|||
"network_user"
|
||||
],
|
||||
"docs": ""
|
||||
},
|
||||
{
|
||||
"allowed_args": [
|
||||
"resource_type",
|
||||
"resource_id"
|
||||
],
|
||||
"allowed_body_types": [],
|
||||
"name": "resource",
|
||||
"tags": [
|
||||
"network_user"
|
||||
],
|
||||
"docs": ""
|
||||
},
|
||||
{
|
||||
"allowed_args": [
|
||||
"resource"
|
||||
],
|
||||
"allowed_body_types": [
|
||||
"pair"
|
||||
],
|
||||
"name": "update_resource",
|
||||
"tags": [
|
||||
"function",
|
||||
"api_writer",
|
||||
"network_user"
|
||||
],
|
||||
"docs": ""
|
||||
},
|
||||
{
|
||||
"allowed_args": [
|
||||
"point_group_id"
|
||||
],
|
||||
"allowed_body_types": [],
|
||||
"name": "point_group",
|
||||
"tags": [
|
||||
"data",
|
||||
"list_like"
|
||||
],
|
||||
"docs": ""
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
defmodule FarmbotCeleryScript.Compiler.DataControl do
|
||||
alias FarmbotCeleryScript.Compiler
|
||||
|
||||
# compiles coordinate
|
||||
# Coordinate should return a vec3
|
||||
def coordinate(%{args: %{x: x, y: y, z: z}}, env) do
|
||||
quote location: :keep do
|
||||
FarmbotCeleryScript.SysCalls.coordinate(
|
||||
unquote(Compiler.compile_ast(x, env)),
|
||||
unquote(Compiler.compile_ast(y, env)),
|
||||
unquote(Compiler.compile_ast(z, env))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# compiles point
|
||||
def point(%{args: %{pointer_type: type, pointer_id: id}}, env) do
|
||||
quote location: :keep do
|
||||
FarmbotCeleryScript.SysCalls.point(
|
||||
unquote(Compiler.compile_ast(type, env)),
|
||||
unquote(Compiler.compile_ast(id, env))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# compile a named pin
|
||||
def named_pin(%{args: %{pin_id: id, pin_type: type}}, env) do
|
||||
quote location: :keep do
|
||||
FarmbotCeleryScript.SysCalls.named_pin(
|
||||
unquote(Compiler.compile_ast(type, env)),
|
||||
unquote(Compiler.compile_ast(id, env))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def tool(%{args: %{tool_id: tool_id}}, env) do
|
||||
quote location: :keep do
|
||||
FarmbotCeleryScript.SysCalls.get_toolslot_for_tool(
|
||||
unquote(Compiler.compile_ast(tool_id, env))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def resource_update(
|
||||
%{
|
||||
args: %{
|
||||
resource_type: kind,
|
||||
resource_id: id,
|
||||
label: label,
|
||||
value: value
|
||||
},
|
||||
body: body
|
||||
},
|
||||
env
|
||||
) do
|
||||
initial = %{label => value}
|
||||
# Technically now body isn't supported by this node.
|
||||
extra =
|
||||
Map.new(body, fn %{args: %{label: label, data_value: value}} ->
|
||||
{label, value}
|
||||
end)
|
||||
|
||||
# Make sure the initial stuff higher most priority
|
||||
params = Map.merge(extra, initial)
|
||||
|
||||
quote do
|
||||
FarmbotCeleryScript.SysCalls.resource_update(
|
||||
unquote(Compiler.compile_ast(kind, env)),
|
||||
unquote(Compiler.compile_ast(id, env)),
|
||||
unquote(Macro.escape(params))
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,7 +4,7 @@ defmodule FarmbotCeleryScript.Corpus.NodeTest do
|
|||
|
||||
test "inspect" do
|
||||
a =
|
||||
"Sequence(version, locals) [calibrate, change_ownership, check_updates, emergency_lock, emergency_unlock, execute, execute_script, factory_reset, find_home, flash_firmware, home, install_farmware, install_first_party_farmware, _if, move_absolute, move_relative, power_off, read_pin, read_status, reboot, remove_farmware, update_resource, send_message, set_servo_angle, set_user_env, sync, take_photo, toggle_pin, update_farmware, wait, write_pin, zero]"
|
||||
"Sequence(version, locals) [assertion, calibrate, change_ownership, check_updates, emergency_lock, emergency_unlock, execute, execute_script, factory_reset, find_home, flash_firmware, home, install_farmware, install_first_party_farmware, _if, move_absolute, move_relative, power_off, read_pin, read_status, reboot, remove_farmware, update_resource, send_message, set_servo_angle, set_user_env, sync, take_photo, toggle_pin, update_farmware, wait, write_pin, zero]"
|
||||
|
||||
b = inspect(Corpus.sequence())
|
||||
assert a == b
|
||||
|
|
Loading…
Reference in New Issue