If a user updated a regimen (started or not by a FarmEvent) it would
take two changes to actually dispatch the change since Regimens
update their own `updated_at` without `put`ing it to the API
* preloader and reconciler no longer use a transaction
* This will prevent rolling back a failed sync, but allows farmbot to
continue operating if a sync does fail
* usage of the preloader updated to reflect this
* FarmEvents now schedule all events up front
* Executions are stored in the database
* Regimens now schedule all items up front
* Executions are stored in the database
* fix Deleting a FarmEvent with a running RegimenInstance
* `execute`int and `schedule`ing a CeleryScript are not separate things
* Everywhere `scheduling` and `executing` CeleryScript updated to use
the new API
Adds a blacklist of known asset types that FarmBot can
handle and sync/cache. This is important for when new assets are added or
assets are dispatched for the frontend to consume.
Previous system would crash the calling processes with a `MatchError`
instead of returning an error. The end result after this commit is
still the same - the auto_sync channel will attempt a resync
every 5 seconds. The log messages/user experience should just
be better now.
* Gets rid of the Preloader behaviour
* This prevents the Preloader mock from overriding the _actual_
implementation.
* Update auto_sync_channel_test to mock the API, not the Preloader
* remove old preloader_test as it didn't do anything
* Changes auto_sync_channel to no longer use `handle_continue`
* If preloading fails, retry instead of crashing.
* Make `get_changeset` return an error rather than raising an exception
* Update every use of that function to handle posibility of error
I previously misunderstood how the black magic of mox actually works.
This updates `farmbot_ext` to not require setting excess data in every
config.exs entry. Also removes calls to `Application.get_env/2`
* Test case: auto_sync is disabled.
* Test case: auto_sync of Device assets
* Test case: auto_sync of FbosConfig
* Test case: auto_sync of FbosConfig assets
* Test case: auto_sync of FarmwareInstallation assets
Test case: `cache_sync/3`
Farmware runtime seems to be working really well. The only
problem is currently the way Farmware is stored on the bot state
can not be properly serialized to the new method. This will require
a breaking change
* Fixes botstate changes being dispatched as nested lists
* Fixes jwt failing to decode `nil`. Doesn't fix token actually being`nil` though.
* Adds a syscall for read_pin
* Add/fix calibrate syscall
* tweak tty detector. This is still broken i think
This is obviously a rather large change warranting an essay describing
it.
A Brief overview
Basically the old implementation had quite a few down sides preventing
it from really working as intended, especially with the addition of the
variables feature. Here is the shortlist of things that needed
addressing:
* No scoping between sequences.
What this essentially means is that a sequence that executes another
sequence is unable to add data to the calle. This is important for using
Variables.
* Error recovery
certain nodes have a high likelyhood of failing such as anything that
interfaces the firmware. Much focus was spent ensuring that errors would
be recoverable when desired.
* Complexity of control flow asts versus action asts.
Nodes such as `if` will always work in the same way regardless of the
state of the rest of the system meaning there is no reason for it to
have a special implementation per environment. on the other hand
`move_absolute` is bound to a specific part of the system. Seperating
these concerns allows for better testing of each piece independently.
A More In Depth overview
The core of this change resolves around 1 really big change resulting in
many more small changes. This change is the CeleryScript `compiler`. The
TLDR of this system is that now CeleryScript ASTs are deterministicly
compiled to Elixir's AST and executed. Doing this has some big benifits
as described below.
1) CeleryScript "runtime" environment is now much simpiler in favor of a somewhat
complex "compile time" environment. Basically instead of EVERY single
CeleryScript AST having a custom runtime implementation, only a subset
of ASTs that require external services such as the Firmware, Database,
HTTP, etc require having a runtime implementation. This subset of ASTs
are called `SysCalls`. Also the runtime implementations are compiled to
a single function call that can be implemented instead of needing to
have a contextual environment and making decisions at runtime to
evaluate variables and the like.
2) Static analysis is now possible. This means an incorrectly crafted
sequence can be validated at compile time rather than getting half way
through a sequence before finding the error.
3) Having the "external services" separated leads to better plugability.
There is now a behaviour to be implemented for the subset of syscalls
that are system specific.
* Add bot state serializer to filesystem
* Add helper to turn ecto types into TSC types
* Add module to extract ecto changes as a list of instructions
* Add new transport for bot_state_ng
* Update CSVM Runtime to poll until `await` can complete
* This also includes changes to all Farmbot API Assets adding
a `monitor: :boolean` field. This allows tests to be run
causing minimal side effects on the rest of the systems.
Pull in new csvm implementation
Update circleci config
Implement syncing and write_pin
add migration for syncing
add saftey to write_pin
Implement read_pin
Implement set_servo_angle
Implement more ast nodes
Implement e-stop and e-unlock
Fix a bunch of stuf
Fix missing assets on boot/init
It actually works
Rename csvm -> farmbot_celery_script; fix initial sync/dispatch
Fix a bunch of small bugs
Identify problem
Fix Sqlite bug and increase performance by 10 times!!
Fix sequences inside of sequences