{ "HIGHLIGHTSTROKECOLORS": [ [ "rodi", "#000000" ] ], "ARGPLUGINS": [ [ "rodisenselight", "var block = logo.blocks.blockList[blk];block.value = doRodiGetLightSensor(logo, blk);" ], [ "rodisenseleft", "var block = logo.blocks.blockList[blk];block.value = doRodiGetSensor(logo, blk, 0);" ], [ "rodisenseright", "var block = logo.blocks.blockList[blk];block.value = doRodiGetSensor(logo, blk, 1);" ], [ "rodisee", "var block = logo.blocks.blockList[blk];block.value = doRodiGetDistance(logo, blk);" ], [ "rodimovestatus", "var block = logo.blocks.blockList[blk];block.value = doRodiGetMoveStatus(logo, blk);" ] ], "GLOBALS": "RODI_BASE_URL = 'http://192.168.4.1:1234';rodiSensorsCache = null;rodiSensorsValidFor = 100;rodiSensorsCacheExpires = 0;rodiLightSensorCache = null;rodiLightSensorValidFor = 100;rodiLightSensorCacheExpires = 0;rodiMoveStatus = _('stop');rodiDistanceCache = null;rodiDistanceValidFor = 100;rodiDistanceCacheExpires = 0;doRodiGetDistance = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { if (Date.now() > rodiDistanceCacheExpires) { apiUrl = RODI_BASE_URL + '/5/'; distance = doSyncCall(logo, blk, apiUrl); if (distance != null) { rodiDistanceCacheExpires = Date.now() + rodiDistanceValidFor; rodiDistanceCache = distance; return distance; } else { return 100; } } else { return rodiDistanceCache; } }};doRodiGetMoveStatus = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { return rodiMoveStatus; }};doRodiMove = function (logo, blk, left, right) { apiUrl = RODI_BASE_URL + '/3/' + left + '/' + right + '/'; if (left === right) { if (left < 0) { rodiMoveStatus = _('back'); } else if (left > 0) { rodiMoveStatus = _('forward'); } else { rodiMoveStatus = _('stop'); } } else { if (left > right) { rodiMoveStatus = _('right'); } else { rodiMoveStatus = _('left'); } } doAsyncCall(logo, blk, apiUrl)};doRodiGetSensor = function (logo, blk, index) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { if (Date.now() > rodiSensorsCacheExpires) { apiUrl = RODI_BASE_URL + '/2/'; sensors = doSyncCall(logo, blk, apiUrl); if (sensors != null) { rodiSensorsCacheExpires = Date.now() + rodiSensorsValidFor; rodiSensorsCache = sensors; return sensors[index]; } else { return -1; } } else { return rodiSensorsCache[index]; } }};doRodiGetLightSensor = function (logo, blk) { if (logo.inStatusMatrix) { logo.statusFields.push([blk, logo.blocks.blockList[blk].name]); } else { if (Date.now() > rodiLightSensorCacheExpires) { apiUrl = RODI_BASE_URL + '/7/'; sensor = doSyncCall(logo, blk, apiUrl); if (sensor != null) { rodiLightSensorCacheExpires = Date.now() + rodiLightSensorValidFor; rodiLightSensorCache = sensor; return sensor; } else { return -1; } } else { return rodiLightSensorCache; } }};doAsyncCall = function (logo, blk, url){ console.log(url); try { request = new XMLHttpRequest(); request.open('GET', url, true); request.send(null); } catch (e) { if (logo != null) { logo.errorMsg(e, blk); } console.log(e); }};doSyncCall = function (logo, blk, url) { console.log(url); request = new XMLHttpRequest(); try { request.open('GET', url, false); request.send(null); return JSON.parse(request.responseText); } catch (e) { if (logo != null) { logo.errorMsg(e, blk); } console.log(e); return null; }};function doRodiStop(){ doRodiMove(null, null, 0, 0);};blocks.logo.stage.addEventListener('__STOP__', doRodiStop, false);", "PALETTEHIGHLIGHTCOLORS": [ [ "rodi", "#ced8f8" ] ], "FLOWPLUGINS": [ [ "rodiblink", "var block = logo.blocks.blockList[blk];var conns = block.connections;var rate = logo.parseArg(logo, turtle, conns[1]);var apiUrl = RODI_BASE_URL + '/1/' + rate + '/';doAsyncCall(logo, blk, apiUrl);" ], [ "rodising", "var block = logo.blocks.blockList[blk];var conns = block.connections;var note = logo.parseArg(logo, turtle, conns[1]);var duration = logo.parseArg(logo, turtle, conns[2]);var apiUrl = RODI_BASE_URL + '/4/' + note + '/' + duration + '/';doAsyncCall(logo, blk, apiUrl);" ], [ "rodipixel", "var block = logo.blocks.blockList[blk];var conns = block.connections;var red = logo.parseArg(logo, turtle, conns[1]);var green = logo.parseArg(logo, turtle, conns[2]);var blue = logo.parseArg(logo, turtle, conns[3]);var apiUrl = RODI_BASE_URL + '/6/' + red + '/' + green + '/' + blue + '/';doAsyncCall(logo, blk, apiUrl);" ], [ "rodiled", "var block = logo.blocks.blockList[blk];var conns = block.connections;var state = logo.parseArg(logo, turtle, conns[1]);var apiUrl = RODI_BASE_URL + '/8/' + state + '/';doAsyncCall(logo, blk, apiUrl);" ], [ "rodimove", "var block = logo.blocks.blockList[blk];var conns = block.connections;var left = logo.parseArg(logo, turtle, conns[1]);var right = logo.parseArg(logo, turtle, conns[2]);doRodiMove(logo, blk, left, right);" ], [ "rodileft", "doRodiMove(logo, blk, -100, 100);" ], [ "rodiright", "doRodiMove(logo, blk, 100, -100);" ], [ "rodiback", "doRodiMove(logo, blk, -100, -100);" ], [ "rodiforward", "doRodiMove(logo, blk, 100, 100);" ], [ "rodistop", "doRodiMove(logo, blk, 0, 0);" ] ], "PALETTEPLUGINS": [ [ "rodi", " " ] ], "BLOCKPLUGINS": [ [ "rodiblink", "var rodiBlink = new ProtoBlock('rodiblink');rodiBlink.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiblink'] = rodiBlink;rodiBlink.staticLabels.push(_('blink'));rodiBlink.adjustWidthToLabel();rodiBlink.oneArgBlock();rodiBlink.defaults.push(1000);" ], [ "rodising", "var rodiSing = new ProtoBlock('rodising');rodiSing.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodising'] = rodiSing;rodiSing.staticLabels.push(_('play'));rodiSing.staticLabels.push(_('note'));rodiSing.staticLabels.push(_('duration'));rodiSing.adjustWidthToLabel();rodiSing.twoArgBlock();rodiSing.dockTypes[1] = 'numberin';rodiSing.dockTypes[2] = 'numberin';rodiSing.defaults.push(31);rodiSing.defaults.push(250);" ], [ "rodipixel", "var rodiPixel = new ProtoBlock('rodipixel');rodiPixel.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodipixel'] = rodiPixel;rodiPixel.staticLabels.push(_('pixel color'));rodiPixel.staticLabels.push(_('red'));rodiPixel.staticLabels.push(_('green'));rodiPixel.staticLabels.push(_('blue'));rodiPixel.adjustWidthToLabel();rodiPixel.threeArgBlock();rodiPixel.dockTypes[1] = 'numberin';rodiPixel.dockTypes[2] = 'numberin';rodiPixel.dockTypes[3] = 'numberin';rodiPixel.defaults.push(0);rodiPixel.defaults.push(0);rodiPixel.defaults.push(0);" ], [ "rodiled", "var rodiLed = new ProtoBlock('rodiled');rodiLed.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiled'] = rodiLed;rodiLed.staticLabels.push(_('led'));rodiLed.adjustWidthToLabel();rodiLed.oneArgBlock();rodiLed.defaults.push(1);" ], [ "rodisenselight", "var rodiSenseLight = new ProtoBlock('rodisenselight');rodiSenseLight.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisenselight'] = rodiSenseLight;rodiSenseLight.staticLabels.push(_('light intensity'));rodiSenseLight.adjustWidthToLabel();rodiSenseLight.parameterBlock();" ], [ "rodisenseleft", "var rodiSenseLeft = new ProtoBlock('rodisenseleft');rodiSenseLeft.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisenseleft'] = rodiSenseLeft;rodiSenseLeft.staticLabels.push(_('infrared light (left)'));rodiSenseLeft.adjustWidthToLabel();rodiSenseLeft.parameterBlock();" ], [ "rodisenseright", "var rodiSenseRight = new ProtoBlock('rodisenseright');rodiSenseRight.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisenseright'] = rodiSenseRight;rodiSenseRight.staticLabels.push(_('infrared light (right)'));rodiSenseRight.adjustWidthToLabel();rodiSenseRight.parameterBlock();" ], [ "rodisee", "var rodiSee = new ProtoBlock('rodisee');rodiSee.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodisee'] = rodiSee;rodiSee.staticLabels.push(_('distance'));rodiSee.adjustWidthToLabel();rodiSee.parameterBlock();" ], [ "rodimovestatus", "var rodiMoveStatus = new ProtoBlock('rodimovestatus');rodiMoveStatus.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodimovestatus'] = rodiMoveStatus;rodiMoveStatus.staticLabels.push(_('status'));rodiMoveStatus.adjustWidthToLabel();rodiMoveStatus.parameterBlock();" ], [ "rodimove", "var rodiMove = new ProtoBlock('rodimove');rodiMove.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodimove'] = rodiMove;rodiMove.staticLabels.push(_('move'));rodiMove.staticLabels.push(_('left'));rodiMove.staticLabels.push(_('right'));rodiMove.adjustWidthToLabel();rodiMove.twoArgBlock();rodiMove.dockTypes[1] = 'numberin';rodiMove.dockTypes[2] = 'numberin';rodiMove.defaults.push(100);rodiMove.defaults.push(100);" ], [ "rodileft", "var rodiLeft = new ProtoBlock('rodileft');rodiLeft.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodileft'] = rodiLeft;rodiLeft.staticLabels.push(_('left'));rodiLeft.adjustWidthToLabel();rodiLeft.zeroArgBlock();" ], [ "rodiright", "var rodiRight = new ProtoBlock('rodiright');rodiRight.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiright'] = rodiRight;rodiRight.staticLabels.push(_('right'));rodiRight.adjustWidthToLabel();rodiRight.zeroArgBlock();" ], [ "rodiback", "var rodiBack = new ProtoBlock('rodiback');rodiBack.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiback'] = rodiBack;rodiBack.staticLabels.push(_('back'));rodiBack.adjustWidthToLabel();rodiBack.zeroArgBlock();" ], [ "rodiforward", "var rodiForward = new ProtoBlock('rodiforward');rodiForward.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodiforward'] = rodiForward;rodiForward.staticLabels.push(_('forward'));rodiForward.adjustWidthToLabel();rodiForward.zeroArgBlock();" ], [ "rodistop", "var rodiStop = new ProtoBlock('rodistop');rodiStop.palette = palettes.dict['rodi'];blocks.protoBlockDict['rodistop'] = rodiStop;rodiStop.staticLabels.push(_('stop'));rodiStop.adjustWidthToLabel();rodiStop.zeroArgBlock();" ] ], "PALETTEFILLCOLORS": [ [ "rodi", "#6a8df6" ] ], "PALETTESTROKECOLORS": [ [ "rodi", "#5a7de6" ] ] }