Add helpers for inspecting asset states

feature/sequence-on-boot
Connor Rigby 2019-11-07 09:02:19 -08:00
parent a76f67347a
commit 12049e04ba
No known key found for this signature in database
GPG Key ID: 29A88B24B70456E0
1 changed files with 14 additions and 0 deletions

View File

@ -6,6 +6,20 @@ defmodule FarmbotCore.AssetSupervisor do
use Supervisor
alias FarmbotCore.{Asset.Repo, AssetWorker}
def get_state(%{} = asset) do
case whereis_child(asset) do
{_id, pid, _, _} -> :sys.get_state(pid)
_ -> :error
end
end
def get_pid(%{} = asset) do
case whereis_child(asset) do
{_id, pid, _, _} -> pid
_ -> :error
end
end
@doc "List all children for an asset"
def list_children(kind) do
name = Module.concat(__MODULE__, kind)