{"id":1102,"date":"2022-12-28T20:35:13","date_gmt":"2022-12-28T19:35:13","guid":{"rendered":"http:\/\/heppg.de\/ikg\/wordpress\/?p=1102"},"modified":"2022-12-28T20:51:41","modified_gmt":"2022-12-28T19:51:41","slug":"snap-integration-with-scratchclient","status":"publish","type":"post","link":"https:\/\/heppg.de\/ikg\/wordpress\/?p=1102","title":{"rendered":"Snap! integration with scratchClient"},"content":{"rendered":"\n<p>Some work was performed to integrate Snap! with scratchClient. Here a preview of current results.<\/p>\n\n\n\n<p>Snap! is a viable alternative to scratch. Scratch 1.4 on raspberry pi is quite fast, but latest implementation is buggy. Full screen display for example is no longer working. Scratch 2 was based on flash and is not recommended; scratch 3 has again a different extension method and investigation is on todo-list. <\/p>\n\n\n\n<p>The complexity of Snap! blocks is a hurdle for a school environment. Can be handled partially by making blocks invisible. For the menu entries some work needs to be done to hide \/preset some of them to avoid confusion for the kids in school.<\/p>\n\n\n\n<p>Snap! sources can be downloaded from https:\/\/snap.berkeley.edu\/ . It runs from the file system; serving from a local web server as python tornado is easy.<\/p>\n\n\n\n<p>The system context is as with the legacy scratch1.4, 2 integration: have Snap! started, have scratchClient running and the config definitions from the xml config files are exported into Snap!.<\/p>\n\n\n\n<p>Current implementation is proof of concept which concentrates on communication using websocket and configuration setup. Plan is to have a dedicated snap-scratchClient implementation and not to integrate this with legacy scratchClient. This reduces test effort and allows for easier rework of event distribution and web page handling.<\/p>\n\n\n\n<p>Snap sources will be provided from a local tornado server; the data communication also goes to this tornado instance. <\/p>\n\n\n\n<p>When Snap! is started, then scratchClient library needs to be loaded. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"136\" height=\"308\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-1.png\" alt=\"\" class=\"wp-image-1104\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-1.png 136w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-1-132x300.png 132w\" sizes=\"auto, (max-width: 136px) 100vw, 136px\" \/><\/a><figcaption>Menu entries.<\/figcaption><\/figure>\n\n\n\n<p>The library list is adjusted by the server. For demonstration purpose only scratchClient- and catch-errors is provided. The server has a whitelist\/ blacklist for libraries provided. This is part of the &#8216;reduce complexity&#8217; effort.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"434\" height=\"334\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-2.png\" alt=\"\" class=\"wp-image-1105\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-2.png 434w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-2-300x231.png 300w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/a><figcaption>Library list provided by server.<\/figcaption><\/figure>\n\n\n\n<p>The initial blocks are opened in a category &#8216;scratchClient&#8217;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"219\" height=\"297\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image-3.png\" alt=\"\" class=\"wp-image-1106\"\/><\/a><figcaption>scratchClient library blocks.<\/figcaption><\/figure>\n\n\n\n<p>The command &#8216;scratchClient start&#8217; initiates the websocket communication to the server and downloads the block definition for current adapter. Based on configuration in scratchClient additional blocks are created. <br>It should be possible to start the communication with the library import; this needs further investigation.<\/p>\n\n\n\n<p>The &#8216;connected&#8217; reporter is boolean connection state; &#8216;message&#8217; is providing last raw websocket messages for debug and will be removed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchClient_palette-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"492\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchClient_palette-1.png\" alt=\"\" class=\"wp-image-1108\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchClient_palette-1.png 600w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchClient_palette-1-300x246.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption>Palette created from scratchClient configuration.<\/figcaption><\/figure>\n\n\n\n<p>Unfortunately there are no &#8216;hat&#8217;-blocks available which could react to events sent from scratchClient. Only way to handle this was to preload the broadcast-event names into the event hat message list. <\/p>\n\n\n\n<p>Technically this is achieved by creating a hidden custom block which uses do_broadcast blocks with the event names.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"124\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/image.png\" alt=\"\" class=\"wp-image-1103\"\/><\/a><figcaption>scratchClient event preloaded into the broadcast hat.<\/figcaption><\/figure>\n\n\n\n<p>Help text for the blocks is provided by the server, current implementation is generated from scratchClient xml configuration.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchclient_help.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"290\" src=\"http:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchclient_help.png\" alt=\"\" class=\"wp-image-1109\" srcset=\"https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchclient_help.png 600w, https:\/\/heppg.de\/ikg\/wordpress\/wp-content\/uploads\/2022\/12\/scratchclient_help-300x145.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><figcaption>Help Text created from adapter XML.<\/figcaption><\/figure>\n\n\n\n<p>The screenshot shows a mix of information from xml configuration and some text from the server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;adapter class='adapter.test.TestAdapter' name='TestAdapter'&gt;\n\t\t\n    &lt;description&gt;A test adapter. Provides Output update every some seconds.&lt;\/description&gt;\n    &lt;description lang=\"de\"&gt;Beispiel f\u00fcr eine Konfiguration. Der Adapter l\u00e4uft ohne externe Referenzen und versorgt Werte sporadisch.&lt;\/description&gt;\n\t\n    &lt;input name='low'&gt;\n\t&lt;broadcast name='led1_OFF'\/&gt;\n\t&lt;broadcast name='led1_AUS'\/&gt;\n\t&lt;broadcast name='led1_off'\/&gt;\n    &lt;\/input&gt;\n...<\/code><\/pre>\n\n\n\n<p>The configuration snippet shows adapter description for different languages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">New Features: I18N<\/h2>\n\n\n\n<p>Translation support is implemented from start. <\/p>\n\n\n\n<p>The adapter xml configurations can be extended with translations. Snap! block definition can be multi language and log messages of the server can be translated.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Work to be done<\/h2>\n\n\n\n<p>All the backend implementation needs to be done. scratchClient configuration loading, instantiating of the adapter. Event distribution between the scratchClient modules. Web page redesign of course. And documentation update.<\/p>\n\n\n\n<p>A schedule is not yet available.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some work was performed to integrate Snap! with scratchClient. Here a preview of current results. Snap! is a viable alternative to scratch. Scratch 1.4 on raspberry pi is quite fast, but latest implementation is buggy. Full screen display for example is no longer working. Scratch 2 was based on flash and is not recommended; scratch [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,47],"tags":[],"class_list":["post-1102","post","type-post","status-publish","format-standard","hentry","category-scratchclient","category-snap"],"_links":{"self":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1102"}],"version-history":[{"count":3,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1102\/revisions"}],"predecessor-version":[{"id":1114,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1102\/revisions\/1114"}],"wp:attachment":[{"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/heppg.de\/ikg\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}