Skip to content

Commit

Permalink
feat (health): robot interpretation
Browse files Browse the repository at this point in the history
  • Loading branch information
santanche committed Oct 20, 2023
1 parent 60c5216 commit 6b6cc17
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 22 deletions.
4 changes: 2 additions & 2 deletions health/heart/integrated-prep-torax/lib/oid-full-dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 38 additions & 15 deletions health/heart/integrated/blockly-oid-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,30 +192,53 @@ blocks:

generator: {
'eletro': function (block, generator) {
const image = block.getFieldValue('image')
const estrutura = block.getFieldValue('estrutura')
const efeito = block.getFieldValue('efeito')
return `eletro ${image} ${estrutura} ${efeito}`
return JSON.stringify({
type: 'eletro',
image: block.getFieldValue('image'),
estrutura: block.getFieldValue('estrutura'),
efeito: block.getFieldValue('efeito')
})
},

'mecanico': function (block, generator) {
const image = block.getFieldValue('image')
const estrutura = block.getFieldValue('estrutura')
const efeitoMec = block.getFieldValue('efeitoMec')
const efeitoFis = block.getFieldValue('efeitoFis')
return `mec ${image} ${estrutura} ${efeitoMec} ${efeitoMec}`
return JSON.stringify({
type: 'mecanico',
image: block.getFieldValue('image'),
estrutura: block.getFieldValue('estrutura'),
efeitoMec: block.getFieldValue('efeitoMec'),
efeitoFis: block.getFieldValue('efeitoFis')
})
},

'onda': function (block, generator) {
const image = block.getFieldValue('image')
return `onda ${image}`
return JSON.stringify({
type: 'onda',
image: block.getFieldValue('image')
})
},

'sequence': function (block, generator) {
const onda = generator.statementToCode(block, 'onda')
const atvEle = generator.statementToCode(block, 'atvEle')
const atvMec = generator.statementToCode(block, 'atvMec')
return `sequence ${onda} ${atvEle} ${atvMec}`
let result = []
let onda = generator.statementToCode(block, 'onda')
onda = (onda.length == 0) ? null : JSON.parse(onda)
let atvEle = generator.statementToCode(block, 'atvEle')
atvEle = (atvEle.length == 0) ? null : JSON.parse(atvEle)
let atvMec = generator.statementToCode(block, 'atvMec')
atvMec = (atvMec.length == 0) ? null : JSON.parse(atvMec)
result = [{
type: 'sequence',
onda: onda,
atvEle: atvEle,
atvMec: atvMec
}]
const nextBlock =
block.nextConnection && block.nextConnection.targetBlock()
if (nextBlock) {
const nb = generator.blockToCode(nextBlock)
if (nb.length > 0)
result = result.concat(JSON.parse(nb))
}
return JSON.stringify(result)
}
}

Expand Down
8 changes: 6 additions & 2 deletions health/heart/integrated/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
<lively-talk-oid
custom="robot"
character="assets:images/robot.svg"
subscribe="blocks/updated~display">
subscribe="action/robot~process">
</lively-talk-oid>
<button-oid label="Simular"
value="simular"
publish="click~action/robot">
</button-oid>
</div>
<div slot="side-b">
<blockly-oid custom="heart"
publish="update~blocks/updated"
publish="update~action/robot"
subscribe="pane/resize~resize">
</blockly-oid>
</div>
Expand Down
Loading

0 comments on commit 6b6cc17

Please sign in to comment.