Softata: Blockly ... The Holy Grail
softata rpipico firmata arduino csharp grove swagger asp.net blockly
As mentioned in the first blog post in this series some time ago,I wanted to make the Pico coding available with a Blockly style UI as per CodeCraft. NETCoreBlockly provides a .NET Blockly style of programming and can make an API available that is available as an ASP.NET API where functionality is wrappered in Controllers. With the implementation of the ASP.NET Core API Interface to SoftataLib, that is now possible.
The Softata Repository
SoftataWebAPI, in the Soft-ata repository, is an ASP.NET Core API app. It was previously used to provide a Swagger UI to SoftataLib through ASP.NET Core Controllers. It was modified according to the steps in the NETCoreBlockly repository. In step one a specific Nuget version was chosen that matched SoftataWebAPI. The app’s Framework version contributed to this constraint but the main constraint was the Microsoft.AspNetCore.OpenApi version.
<PackageReference Include="NetCore2Blockly" Version="7.2023.427.2025" />
Originally if you now ran SoftataWebAPI as in the repository, the Swagger for the API showed. The NETCoreBlocky has been added has been added as above.
You now get an index page at startup with links to both Blockly and Swagger (and other links), enabling selection of either.
Select NetCoreBlockly.
Expand Swaggers->MySite->API. You will see the APIs, one for each controller from SoftataWebAPI:
- Softata
- SoftataGPIOADC ← Added for single pin devices
- SoftataActuator
- SoftataDisplay
- SoftataSensor
- SoftataTelemetry
If you click on the first (Softata) you get the function blocks from the Softata Controller in SoftataWebAPI.
NetCoreBlockly Softata API
Two of those:
- [Post] /Connect and
- [Get] /Cmd
… are used in the basic app as follows:
NetCoreBlockly implementation of basic SoftataApp
Output in NetCoreBlockly:
Connected to 192.168.0.9:4242
Ready
6.20
DEVICES:sensor,actuator,communication,display,serial
End
Corresponding output in Arduino:
WiFi-Server Up.
Get next command....Is connected.
1-B
Ready.
Get next command....Is connected.
1-V
6.20
Get next command....Is connected.
1-D
DEVICES:sensor,actuator,communication,display,serial
Get next command....Is connected.
1-E
Done.
:)
Yeah!
That works! Going forward I have asked for a bit of decluttering, the optional removal of the unnecessary override Host and override Port bits in the function blocks which has been requested. The “decluttered” version would look something like:
The “Decluttered” NetCoreBlockly implementation of the basic SoftataApp
Blockly
Have modified the Softata Controller so Connect, Begin, Version and Devices is one Controller method called Start and therefore one function block in NetCoreBlockly:
The combined start functions NetCoreBlockly implementation of basic SoftataApp
This shows how the Controllers can be extended for some specific functions or for combining functionality that is reused a lot.
Samples
Some sample Softata Blockly examples are available to be loaded and run. Originally they were in the SoftatWebaAPI/Samples folder:
The Samples for NetCoreBlockly
The Sample Softata Blockly apps have been moved to:
SoftaWebAPI/wwwroot/BlocklyAutomation/↵
assests/showUsage/demoBlocks. This enables them to be loaded directly in NetCoreBlockly in the SoftWebAPI app in the top menu Examples. Also, the file type has been changed from .xml to .txt inline with NetCoreBlockly usage. This custom Examples capability was provided by Andrei Ignat ,NetCoreBlockly’s author.
The Softata Examples in NetCoreBlockly
Nb: Total number of Blockly apps is now 14 including IoT Hub and Bluetooth Telemetry. See SoftataWebAPI demoBlocks.
Topic | Subtopic | |
This Category Links | ||
Category: | Softata Index: | Softata |
Next: > | Softata | Blockly 101 |
< Prev: | Softata | Meadow ... A work in progress |