diff --git a/hunks/statemachines/dex.js b/hunks/statemachines/dex.js new file mode 100644 index 0000000000000000000000000000000000000000..33d4b04034892003c5edbacf2355a2cb4683c203 --- /dev/null +++ b/hunks/statemachines/dex.js @@ -0,0 +1,77 @@ +/* + +purpose built statemachine for the https://gitlab.cba.mit.edu/jakeread/displacementexercise +aka DEX +aka king gripper +aka the big beefy boi +etc + +*/ + +// these are ES6 modules +import { + Hunkify, + Input, + Output, + State +} from '../hunks.js' + +export default function DEX() { + Hunkify(this) + + let motorReturn = new Input('int32', 'motor return', this) + let loadcellReturn = new Input('int32', 'loadcell return', this) + this.inputs.push(motorReturn, loadcellReturn) + + let motorOut = new Output('int32', 'motor output', this) + let loadcellTrigger = new Output('boolean', 'loadcell trigger', this) + this.outputs.push(motorOut, loadcellTrigger) + + let byIncrement = (count) => { + return Math.round(count * umPerStep.value * 100) / 100 + } + + let shipIt = () => { + motorOut.put(Math.round(incrementSize.value / umPerStep.value)) + loadcellTrigger.put(true) + } + + let runState = new State('boolean', 'running', false) + let umPerStep = new State('number', 'displacement per step (um)', 4.23387) + let incrementSize = new State('number', 'increment (um)', byIncrement(5)) + this.states.push(runState, umPerStep, incrementSize) + + runState.onChange = (value) => { + if (runState.value) { + runState.set(false) + } else { + if(motorReturn.io() && loadcellReturn.io()){ + shipIt() + runState.set(true) + } else { + // nope, donot set + } + } + } + + incrementSize.onChange = (value) => { + let count = Math.ceil(value / umPerStep.value) + incrementSize.set(byIncrement(count)) + } + + this.init = () => { + // uh-uuuuh + runState.set(false) + } + + this.loop = () => { + // clear in pairs, + if(motorReturn.io() && loadcellReturn.io()){ + motorReturn.get() + loadcellReturn.get() + if(runState.value){ + shipIt() + } + } + } +} diff --git a/hunks/control/simplestep.js b/hunks/statemachines/simplestep.js similarity index 100% rename from hunks/control/simplestep.js rename to hunks/statemachines/simplestep.js diff --git a/hunks/view.js b/hunks/view.js index 1faf048ed2fc25e9f2359793595e273e36d09ca5..871bed98fefeb415a4f4da681854a40e1050db49 100644 --- a/hunks/view.js +++ b/hunks/view.js @@ -651,27 +651,6 @@ function View() { let msgbegin = msg.length MSGS.writeTo(msg, st.name, 'string') MSGS.writeTo(msg, st.type, 'string') - // course correction here: sometimes states that are numbers are saved as strings (json) - // we can unf- this here, - if (typeof st.value === 'string' && isNumType(st.type)) { - console.warn('patching num') - try { - if (isIntType(st.type)) { - st.value = parseInt(st.value) - } else { - st.value = parseFloat(st.value) - } - console.log('new num val', st.value) - } catch (err) { - console.error('mixup mashing types ... apologies for this bug / hack / etc !') - } - } else if (typeof st.value === 'string' && st.type === 'boolean'){ - // ha! use (?) for 'truthiness' - console.warn('patching bool') - if(st.value === 'true') st.value = true - if(st.value === 'false') st.value = false - console.log('new bool val', st.value) - } MSGS.writeTo(msg, st.value, st.type) if (this.interpreterName === "ponyo" && type === "link") { console.log(`STATE SER FOR: ${st.value} into ${name}`) @@ -708,7 +687,6 @@ function View() { let msg = [MK.REQSTATECHANGE] MSGS.writeTo(msg, state.parent.ind, 'uint16') MSGS.writeTo(msg, state.ind, 'uint8') - // not unlikely mess here, try { MSGS.writeTo(msg, value, state.type) } catch (err) { diff --git a/save/systems/dex-l1.json b/save/systems/dex-l1.json new file mode 100644 index 0000000000000000000000000000000000000000..0586f5d0c901efe52d0e88f8a9f11f461497748c --- /dev/null +++ b/save/systems/dex-l1.json @@ -0,0 +1,287 @@ +{ + "interpreterName": "cuttlefish", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "nrol", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "view", + "name": "tlview", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "pipes/vfptc", + "name": "pipes/vfptc_2", + "inputs": [ + { + "name": "data", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "pipe status", + "type": "string", + "value": "open" + }, + { + "name": "port", + "type": "string", + "value": "2042" + }, + { + "name": "pipe reset", + "type": "boolean", + "value": "false" + }, + { + "name": "serialport status", + "type": "string", + "value": "open" + }, + { + "name": "serial reset", + "type": "boolean", + "value": "false" + } + ] + }, + { + "type": "link", + "name": "link_3", + "inputs": [ + { + "name": "data", + "type": "byteArray" + }, + { + "name": "mgrMsgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "3" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ] + }, + { + "type": "comm/COBSerialUSB", + "name": "comm/COBSerialUSB_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + } + ] + } + }, + { + "type": "view", + "name": "view_4", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "1" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/save/systems/dex-l2-a.json b/save/systems/dex-l2-a.json new file mode 100644 index 0000000000000000000000000000000000000000..9fb5e3addfb28f916ab18a7701dfec82198481e7 --- /dev/null +++ b/save/systems/dex-l2-a.json @@ -0,0 +1,525 @@ +{ + "interpreterName": "cuttlefish", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "nrol", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "view", + "name": "tlview", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "pipes/vfptc", + "name": "pipes/vfptc_2", + "inputs": [ + { + "name": "data", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "pipe status", + "type": "string", + "value": "open" + }, + { + "name": "port", + "type": "string", + "value": "2042" + }, + { + "name": "pipe reset", + "type": "boolean", + "value": "false" + }, + { + "name": "serialport status", + "type": "string", + "value": "open" + }, + { + "name": "serial reset", + "type": "boolean", + "value": "false" + } + ] + }, + { + "type": "link", + "name": "link_3", + "inputs": [ + { + "name": "data", + "type": "byteArray" + }, + { + "name": "mgrMsgs", + "type": "byteArray" + }, + { + "name": "auto_114_2", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_110_3", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "5", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_114_2 (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_110_3 (byteArray)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + }, + { + "name": "auto_23_3_512", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_59_2_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "1" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "3" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_23_3 (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_59_2 (byteArray)" + } + ] + }, + { + "type": "comm/COBSerialUSB", + "name": "comm/COBSerialUSB_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "comm/COBSerialRJ45_E", + "name": "comm/COBSerialRJ45_E_3", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_4", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_512", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "2" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "4" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ] + }, + { + "type": "comm/COBSerialRJ45_A", + "name": "comm/COBSerialRJ45_A_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + } + ] + } + } + ] + } + }, + { + "type": "view", + "name": "view_4", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "view", + "name": "view_5", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "2" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/save/systems/dex-l2-b.json b/save/systems/dex-l2-b.json new file mode 100644 index 0000000000000000000000000000000000000000..b7dec91d6ccc14eacc9b288592cc4ce4162b2cc3 --- /dev/null +++ b/save/systems/dex-l2-b.json @@ -0,0 +1,799 @@ +{ + "interpreterName": "cuttlefish", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "nrol", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "view", + "name": "tlview", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "pipes/vfptc", + "name": "pipes/vfptc_2", + "inputs": [ + { + "name": "data", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "pipe status", + "type": "string", + "value": "open" + }, + { + "name": "port", + "type": "string", + "value": "2042" + }, + { + "name": "pipe reset", + "type": "boolean", + "value": "false" + }, + { + "name": "serialport status", + "type": "string", + "value": "open" + }, + { + "name": "serial reset", + "type": "boolean", + "value": "false" + } + ] + }, + { + "type": "link", + "name": "link_3", + "inputs": [ + { + "name": "data", + "type": "byteArray" + }, + { + "name": "mgrMsgs", + "type": "byteArray" + }, + { + "name": "auto_114_2", + "type": "byteArray" + }, + { + "name": "auto_202_3", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_110_3", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "5", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_233_4", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "6", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_114_2 (byteArray), auto_202_3 (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_110_3 (byteArray), auto_233_4 (byteArray)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + }, + { + "name": "auto_23_3_512", + "type": "byteArray" + }, + { + "name": "auto_30_4_512", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_59_2_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "1" + } + ] + }, + { + "name": "auto_175_3_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "6", + "inHunkInput": "1" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "3" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_23_3 (byteArray), auto_30_4 (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_59_2 (byteArray), auto_175_3 (byteArray)" + } + ] + }, + { + "type": "comm/COBSerialUSB", + "name": "comm/COBSerialUSB_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "comm/COBSerialRJ45_E", + "name": "comm/COBSerialRJ45_E_3", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_4", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_512", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "2" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "4" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ] + }, + { + "type": "comm/COBSerialRJ45_A", + "name": "comm/COBSerialRJ45_A_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + } + ] + } + }, + { + "type": "comm/COBSerialRJ45_A", + "name": "comm/COBSerialRJ45_A_5", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "6", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_6", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_512", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "5", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "3" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "6" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + } + ] + }, + { + "type": "comm/COBSerialRJ45_A", + "name": "comm/COBSerialRJ45_A_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "stepper", + "name": "step_driver", + "inputs": [ + { + "name": "increment", + "type": "int32" + }, + { + "name": "enable", + "type": "boolean" + } + ], + "outputs": [ + { + "name": "increment", + "type": "int32" + }, + { + "name": "stallGuard", + "type": "uint32" + } + ], + "states": [ + { + "name": "current (6-24)", + "type": "uint16", + "value": "16" + }, + { + "name": "enable", + "type": "boolean", + "value": "true" + } + ] + } + ] + } + } + ] + } + }, + { + "type": "view", + "name": "view_4", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "view", + "name": "view_5", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "2" + } + ] + } + ] + }, + { + "type": "view", + "name": "view_6", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "3" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/save/systems/dex-l2-c.json b/save/systems/dex-l2-c.json new file mode 100644 index 0000000000000000000000000000000000000000..09d33627daf1489b98aa02cc8b34c34edc46c1d8 --- /dev/null +++ b/save/systems/dex-l2-c.json @@ -0,0 +1,999 @@ +{ + "interpreterName": "cuttlefish", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "nrol", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "view", + "name": "tlview", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "pipes/vfptc", + "name": "pipes/vfptc_2", + "inputs": [ + { + "name": "data", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "pipe status", + "type": "string", + "value": "open" + }, + { + "name": "port", + "type": "string", + "value": "2042" + }, + { + "name": "pipe reset", + "type": "boolean", + "value": "false" + }, + { + "name": "serialport status", + "type": "string", + "value": "open" + }, + { + "name": "serial reset", + "type": "boolean", + "value": "false" + } + ] + }, + { + "type": "link", + "name": "link_3", + "inputs": [ + { + "name": "data", + "type": "byteArray" + }, + { + "name": "mgrMsgs", + "type": "byteArray" + }, + { + "name": "auto_114_2", + "type": "byteArray" + }, + { + "name": "auto_202_3", + "type": "byteArray" + }, + { + "name": "auto_94_4", + "type": "int32" + }, + { + "name": "auto_4_4", + "type": "boolean" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_110_3", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "5", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_233_4", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "6", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_16_3", + "type": "int32", + "connections": [ + { + "inHunkIndex": "7", + "inHunkInput": "2" + } + ] + }, + { + "name": "auto_237_3", + "type": "int32", + "connections": [ + { + "inHunkIndex": "7", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_114_2 (byteArray), auto_202_3 (byteArray), auto_94_4 (int32), auto_4_4 (boolean)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_110_3 (byteArray), auto_233_4 (byteArray), auto_16_3 (int32), auto_237_3 (int32)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + }, + { + "name": "auto_23_3_512", + "type": "byteArray" + }, + { + "name": "auto_30_4_512", + "type": "byteArray" + }, + { + "name": "auto_225_6", + "type": "int32" + }, + { + "name": "auto_165_6", + "type": "int32" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_59_2_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "1" + } + ] + }, + { + "name": "auto_175_3_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "6", + "inHunkInput": "1" + } + ] + }, + { + "name": "auto_199_4", + "type": "int32", + "connections": [ + { + "inHunkIndex": "6", + "inHunkInput": "2" + } + ] + }, + { + "name": "auto_100_5", + "type": "boolean", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "2" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "3" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_23_3 (byteArray), auto_30_4 (byteArray), auto_225_6 (int32), auto_165_6 (int32)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_59_2 (byteArray), auto_175_3 (byteArray), auto_199_4 (int32), auto_100_5 (boolean)" + } + ] + }, + { + "type": "comm/COBSerialUSB", + "name": "comm/COBSerialUSB_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "comm/COBSerialRJ45_E", + "name": "comm/COBSerialRJ45_E_3", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_4", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_512", + "type": "byteArray" + }, + { + "name": "auto_149_2", + "type": "boolean" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "2" + } + ] + }, + { + "name": "auto_165_2", + "type": "int32", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "4" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_149_2 (boolean)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_165_2 (int32)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + }, + { + "name": "auto_76_3", + "type": "int32" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_50_4", + "type": "boolean", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "4" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_76_3 (int32)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_50_4 (boolean)" + } + ] + }, + { + "type": "comm/COBSerialRJ45_A", + "name": "comm/COBSerialRJ45_A_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "loadcell", + "name": "loadcell_3", + "inputs": [ + { + "name": "read", + "type": "boolean" + }, + { + "name": "tare", + "type": "boolean" + } + ], + "outputs": [ + { + "name": "24bit", + "type": "int32", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "2" + } + ] + } + ] + } + ] + } + }, + { + "type": "comm/COBSerialRJ45_A", + "name": "comm/COBSerialRJ45_A_5", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "6", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_6", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_512", + "type": "byteArray" + }, + { + "name": "auto_237_2", + "type": "int32" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "5", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_512", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "3" + } + ] + }, + { + "name": "auto_16_2", + "type": "int32", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "5" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_237_2 (int32)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_16_2 (int32)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + }, + { + "name": "auto_231_3", + "type": "int32" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_92_4", + "type": "int32", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "6" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_231_3 (int32)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_92_4 (int32)" + } + ] + }, + { + "type": "comm/COBSerialRJ45_A", + "name": "comm/COBSerialRJ45_A_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "stepper", + "name": "step_driver", + "inputs": [ + { + "name": "increment", + "type": "int32" + }, + { + "name": "enable", + "type": "boolean" + } + ], + "outputs": [ + { + "name": "increment", + "type": "int32", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "2" + } + ] + }, + { + "name": "stallGuard", + "type": "uint32" + } + ], + "states": [ + { + "name": "current (6-24)", + "type": "uint16", + "value": "16" + }, + { + "name": "enable", + "type": "boolean", + "value": "true" + } + ] + } + ] + } + } + ] + } + }, + { + "type": "view", + "name": "view_4", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "view", + "name": "view_5", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "2" + } + ] + } + ] + }, + { + "type": "view", + "name": "view_6", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "3" + } + ] + } + ] + }, + { + "type": "control/ussm", + "name": "control/ussm_7", + "inputs": [ + { + "name": "lmReturn", + "type": "int32" + }, + { + "name": "rmReturn", + "type": "int32" + }, + { + "name": "rdReturn", + "type": "int32" + } + ], + "outputs": [ + { + "name": "lmOut", + "type": "int32", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "4" + } + ] + }, + { + "name": "rmOut", + "type": "int32" + }, + { + "name": "rdTrig", + "type": "boolean", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "5" + } + ] + } + ], + "states": [ + { + "name": "runSequence", + "type": "boolean", + "value": "false" + }, + { + "name": "stepIncrement", + "type": "number", + "value": "1" + } + ] + } + ] +} \ No newline at end of file diff --git a/save/systems/st-01.json b/save/systems/st-01.json new file mode 100644 index 0000000000000000000000000000000000000000..575406e9230ba17dc88bbb1a5391f05921b0999b --- /dev/null +++ b/save/systems/st-01.json @@ -0,0 +1,343 @@ +{ + "interpreterName": "cuttlefish", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "nrol", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "view", + "name": "tlview", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "pipes/vfptc", + "name": "pipes/vfptc_2", + "inputs": [ + { + "name": "data", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "pipe status", + "type": "string", + "value": "open" + }, + { + "name": "port", + "type": "string", + "value": "2042" + }, + { + "name": "pipe reset", + "type": "boolean", + "value": "false" + }, + { + "name": "serialport status", + "type": "string", + "value": "open" + }, + { + "name": "serial reset", + "type": "boolean", + "value": "false" + } + ] + }, + { + "type": "link", + "name": "link_3", + "inputs": [ + { + "name": "data", + "type": "byteArray" + }, + { + "name": "mgrMsgs", + "type": "byteArray" + }, + { + "name": "auto_114_2", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "4", + "inHunkInput": "0" + } + ] + }, + { + "name": "auto_110_3", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "5", + "inHunkInput": "0" + } + ] + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "1" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_114_2 (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), auto_110_3 (byteArray)" + } + ], + "contains": { + "interpreterName": "ponyo", + "interpreterVersion": "v0.1", + "hunks": [ + { + "type": "manager", + "name": "ponyo_one", + "inputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "link", + "name": "link_1", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "2", + "inHunkInput": "0" + } + ] + }, + { + "name": "mgrMsgs_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "0", + "inHunkInput": "0" + } + ] + }, + { + "name": "at114_512", + "type": "byteArray" + } + ], + "states": [ + { + "name": "isActive", + "type": "boolean", + "value": "true" + }, + { + "name": "otherLink", + "type": "uint16", + "value": "3" + }, + { + "name": "inputList", + "type": "string", + "value": "mgrMsgs (byteArray)" + }, + { + "name": "outputList", + "type": "string", + "value": "mgrMsgs (byteArray), at114 (byteArray)" + } + ] + }, + { + "type": "comm/COBSerialUSB", + "name": "comm/COBSerialUSB_2", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "1", + "inHunkInput": "0" + } + ] + } + ] + }, + { + "type": "comm/COBSerialRJ45_E", + "name": "comm/COBSerialRJ45_E_3", + "inputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "data_1024", + "type": "byteArray" + } + ] + } + ] + } + }, + { + "type": "view", + "name": "view_4", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "1" + } + ] + } + ] + }, + { + "type": "view", + "name": "view_5", + "inputs": [ + { + "name": "msgs", + "type": "byteArray" + } + ], + "outputs": [ + { + "name": "msgs", + "type": "byteArray", + "connections": [ + { + "inHunkIndex": "3", + "inHunkInput": "2" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/hunks/control/ussm.js b/scratch/ussm.js similarity index 100% rename from hunks/control/ussm.js rename to scratch/ussm.js diff --git a/typeset.js b/typeset.js index 06717bd01a3df1b0fad3b51af5dfb4dde8351e17..07a6e64c11835bb0a60b8c540055e65dbcf167df 100644 --- a/typeset.js +++ b/typeset.js @@ -31,12 +31,12 @@ const checkArray = (thing) => { } const checkUnsigned = (value, bits) => { - if(value > Math.pow(2, bits)) throw new Error('value out of byte bounds') + if (value > Math.pow(2, bits)) throw new Error('value out of byte bounds') } const checkSigned = (value, bits) => { - let comparator = Math.pow(2, bits-1) - if(value > comparator || value < -comparator) throw new Error('value out of byte bounds') + let comparator = Math.pow(2, bits - 1) + if (value > comparator || value < -comparator) throw new Error('value out of byte bounds') } const findPhy = (type) => { @@ -101,7 +101,7 @@ const TSET = [{ checkArray(value) let rtarr = writeLenBytes(value.length).concat(value) rtarr.unshift(this.key) - if(tsdebug) console.log('byteArray sanity check:', value, 'written as:', rtarr) + if (tsdebug) console.log('byteArray sanity check:', value, 'written as:', rtarr) return rtarr }, read: function(arr, start) { @@ -109,7 +109,7 @@ const TSET = [{ let lb = readLenBytes(arr, start + 1) // okey let narr = new Array() - for(let i = 0; i < lb.len; i++){ + for (let i = 0; i < lb.len; i++) { narr.push(arr[start + 1 + lb.numBytes + i]) } return { @@ -212,7 +212,7 @@ const TSET = [{ //place let rtarr = Array.from(btarr) rtarr.unshift(this.key) - if(tsdebug) console.log("UINT32 WRITES ARR: ", rtarr, "FOR: ", value) + if (tsdebug) console.log("UINT32 WRITES ARR: ", rtarr, "FOR: ", value) return rtarr }, read: function(arr, start) { @@ -229,7 +229,7 @@ const TSET = [{ if (tsdebug) console.log('bts on read of uint32', btarr) // now make uint32 view on this ... let vlarr = new Uint32Array(btarr.buffer) - if(tsdebug) console.log("UINT32 READ ARR: ", vlarr[0], "FROM: ", btarr) + if (tsdebug) console.log("UINT32 READ ARR: ", vlarr[0], "FROM: ", btarr) if (tsdebug) console.log('vlarr', vlarr) return { item: vlarr[0], @@ -254,7 +254,7 @@ const TSET = [{ //place let rtarr = Array.from(btarr) rtarr.unshift(this.key) - if(tsdebug) console.log("INT32 WRITES ARR: ", rtarr, "FOR: ", value) + if (tsdebug) console.log("INT32 WRITES ARR: ", rtarr, "FOR: ", value) return rtarr }, read: function(arr, start) { @@ -266,7 +266,7 @@ const TSET = [{ if (tsdebug) console.log('bts on read of uint32', btarr) // now make uint32 view on this ... let vlarr = new Int32Array(btarr.buffer) - if(tsdebug) console.log("UINT32 READ ARR: ", vlarr[0], "FROM: ", btarr) + if (tsdebug) console.log("UINT32 READ ARR: ", vlarr[0], "FROM: ", btarr) if (tsdebug) console.log('vlarr', vlarr) return { item: vlarr[0], @@ -317,29 +317,29 @@ let floatTypes = [ ] const isIntType = (type) => { - for(let t of intTypes){ - if(type == t) return true + for (let t of intTypes) { + if (type == t) return true } return false } const isFloatType = (type) => { - for(let t of floatTypes){ - if(type == t) return true + for (let t of floatTypes) { + if (type == t) return true } return false } const isNumType = (type) => { - if(isIntType(type)) return true - if(isFloatType(type)) return true + if (isIntType(type)) return true + if (isFloatType(type)) return true return false } const writeLenBytes = (len) => { // return array of len bytes for this number let bts = new Array() - if(len > 65536){ + if (len > 65536) { throw new Error('cannot write length bytes for len > 2^16') } else { // this is little eadian ... right ? @@ -370,9 +370,31 @@ const readLenBytes = (arr, start) => { const MSGS = { writeTo: function(bytes, thing, type, debug) { let phy = findPhy(type) + // try some js type conversion, + // course correction here: sometimes states that are numbers are saved as strings (json) + // we can unf- this here, + if (typeof thing === 'string' && isNumType(type)) { + console.warn('patching num') + if (isIntType(type)) { + thing = parseInt(thing) + } else { + thing = parseFloat(thing) + } + console.log('new num val', thing) + } else if (typeof thing === 'string' && type === 'boolean') { + // ha! use (?) for 'truthiness' + console.warn('patching bool') + if (thing == 'true') { + thing = true + } else { + thing = false + } + console.log('new bool val', thing) + } let block = phy.write(thing) if (debug) console.log(`writing for type ${type} and thing '${thing}' the following block of bytes`, block) // write-in to msg like this + // this *must be* slow AF, pls correct block.forEach((byte) => { bytes.push(byte) })