2019-03-05 11:09:15 -07:00
|
|
|
defmodule FarmbotCore.Asset.Point do
|
2018-10-29 10:33:52 -06:00
|
|
|
@moduledoc """
|
|
|
|
Points are data around an x,y,z
|
|
|
|
"""
|
2019-03-05 11:09:15 -07:00
|
|
|
use FarmbotCore.Asset.Schema, path: "/api/points"
|
2018-10-29 10:33:52 -06:00
|
|
|
|
|
|
|
schema "points" do
|
|
|
|
field(:id, :id)
|
|
|
|
|
2019-03-05 11:09:15 -07:00
|
|
|
has_one(:local_meta, FarmbotCore.Asset.Private.LocalMeta,
|
2018-10-29 10:33:52 -06:00
|
|
|
on_delete: :delete_all,
|
|
|
|
references: :local_id,
|
|
|
|
foreign_key: :asset_local_id
|
|
|
|
)
|
|
|
|
|
2020-04-12 11:47:10 -06:00
|
|
|
field(:discarded_at, :utc_datetime)
|
|
|
|
field(:gantry_mounted, :boolean)
|
2018-10-29 10:33:52 -06:00
|
|
|
field(:meta, :map)
|
2020-04-12 11:47:10 -06:00
|
|
|
field(:monitor, :boolean, default: true)
|
2018-10-29 10:33:52 -06:00
|
|
|
field(:name, :string)
|
2020-02-24 13:50:57 -07:00
|
|
|
field(:openfarm_slug, :string)
|
2018-10-29 10:33:52 -06:00
|
|
|
field(:plant_stage, :string)
|
|
|
|
field(:planted_at, :utc_datetime)
|
|
|
|
field(:pointer_type, :string)
|
2020-04-12 11:47:10 -06:00
|
|
|
field(:pullout_direction, :integer)
|
2018-10-29 10:33:52 -06:00
|
|
|
field(:radius, :float)
|
2020-04-12 11:47:10 -06:00
|
|
|
field(:tool_id, :integer)
|
2018-10-29 10:33:52 -06:00
|
|
|
field(:x, :float)
|
|
|
|
field(:y, :float)
|
|
|
|
field(:z, :float)
|
|
|
|
timestamps()
|
|
|
|
end
|
|
|
|
|
|
|
|
view point do
|
|
|
|
%{
|
|
|
|
id: point.id,
|
|
|
|
meta: point.meta,
|
2019-06-03 14:41:32 -06:00
|
|
|
name: point.name,
|
2018-10-29 10:33:52 -06:00
|
|
|
plant_stage: point.plant_stage,
|
2020-04-28 13:09:16 -06:00
|
|
|
created_at: point.created_at,
|
2019-06-03 14:41:32 -06:00
|
|
|
planted_at: point.planted_at,
|
2018-10-29 10:33:52 -06:00
|
|
|
pointer_type: point.pointer_type,
|
2019-06-03 14:41:32 -06:00
|
|
|
radius: point.radius,
|
2018-12-04 13:20:09 -07:00
|
|
|
tool_id: point.tool_id,
|
2019-09-26 11:05:53 -06:00
|
|
|
discarded_at: point.discarded_at,
|
2020-02-20 13:52:00 -07:00
|
|
|
gantry_mounted: point.gantry_mounted,
|
2020-04-12 18:42:57 -06:00
|
|
|
openfarm_slug: point.openfarm_slug,
|
2020-04-12 11:47:10 -06:00
|
|
|
pullout_direction: point.pullout_direction,
|
2018-10-29 10:33:52 -06:00
|
|
|
x: point.x,
|
|
|
|
y: point.y,
|
|
|
|
z: point.z
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def changeset(point, params \\ %{}) do
|
|
|
|
point
|
|
|
|
|> cast(params, [
|
2020-04-12 18:42:57 -06:00
|
|
|
:created_at,
|
|
|
|
:discarded_at,
|
|
|
|
:gantry_mounted,
|
2018-10-29 10:33:52 -06:00
|
|
|
:id,
|
|
|
|
:meta,
|
2020-04-12 18:42:57 -06:00
|
|
|
:monitor,
|
2018-10-29 10:33:52 -06:00
|
|
|
:name,
|
|
|
|
:plant_stage,
|
|
|
|
:planted_at,
|
|
|
|
:pointer_type,
|
2020-04-12 18:42:57 -06:00
|
|
|
:pullout_direction,
|
|
|
|
:openfarm_slug,
|
2018-10-29 10:33:52 -06:00
|
|
|
:radius,
|
2020-04-12 18:42:57 -06:00
|
|
|
:tool_id,
|
|
|
|
:updated_at,
|
2018-10-29 10:33:52 -06:00
|
|
|
:x,
|
|
|
|
:y,
|
|
|
|
:z,
|
|
|
|
])
|
|
|
|
|> validate_required([])
|
|
|
|
end
|
|
|
|
end
|