Giter VIP home page Giter VIP logo

csvm's Introduction

CircleCI Coverage Status

CSVM

Init

{:ok, pid} = Csvm.start_link(MyInteractionHandler)

Inbound Message

External Public CSVM API

The current FarmbotOS implementation expects every CeleryScript request to block. For example When a FarmEvent is ready for execution, it does:

Farmbot.CeleryScript.execute(ast)

Ideally in the new implementation, we will have one more available function:

# blocking
CSVM.schedule(ast)

# or async
ref = CSVM.async_schedule(ast)
some_other_stuff()
CSVM.await(ref) # later

Where schedule/1 == execute/1.

Example of the IOHandler behaviour and implementation.

# The behaviour definition.
defmodule CSVM.IOHandler do
  @moduledoc """
  behaviour definition for implementation specific parts of the CSVM.
  """

  @doc "Blocking move to a position."
  @callback move_absolute(vec3, spd_x, spd_y, spd_z) :: :ok | {:error, String.t}

  @doc "Get a point by it's id from some data store."
  @callback get_point(point_id) :: {:ok, vec3} | {:error, String.t}
end

# The test implementation
defmodule CSVM.TestIOHandler do
  @moduledoc "Test implementation for IOHandler"

  def fixture do
    %{
      points: %{
        100: %{x: 1, y: 2, z: 3}
      }
    }
  end

  @behaviour CSVM.IOHandler

  # simulate movement by sleeping for a random amount of time. Obviously this
  # wouldn't be used in a real test implementation
  def move_absolute(_vec3, _spd_x, _spd_y, _spd_z), do: Process.sleep(:rand.uniform(5000))

  def get_point(id), do: fixture()[:points][id]
end

defmodule CSVM.RealIOHandler do
  @moduledoc "Actual FBOS IOHandler"
  @behaviour CSVM.IOHandler

  def move_absolute(vec3, spd_x, spd_y, spd_z) do
    Farmbot.Firmware.move_absolute(vec3, spd_x, spd_y, spd_z)
  end

  def get_point(id) do
    Farmbot.Asset.get_point(id)
  end
end

csvm's People

Contributors

connorrigby avatar rickcarlino avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

rickcarlino

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.