diff --git a/examples/componentTest.ht b/examples/componentTest.ht new file mode 100644 index 0000000..865eaee --- /dev/null +++ b/examples/componentTest.ht @@ -0,0 +1,10 @@ +fun simulate(inputs) -> Map { + final result = Map() + if (inputs['A'] && inputs['B']) { + result['OUT'] = true + } else { + result['OUT'] = false + } + return result +} + diff --git a/examples/simulateTest.ht b/examples/simulateTest.ht new file mode 100644 index 0000000..c033d62 --- /dev/null +++ b/examples/simulateTest.ht @@ -0,0 +1,42 @@ +var inputsValue = 0 + +fun onLoad { + snackBar("Script loaded", "Start", start) +} + +fun getFunctions { + return ["start", "random"] +} + +fun start { + inputsValue = 0 + simSetPartiallySimulating(false) + simRestart() + tick() +} + +fun tick { + final inputs = getInputs() + final inputsLength = inputs.length + + simSetInputsBinary(inputsValue) + inputsValue += 1 + + if (inputsValue >= Math.pow(2, inputsLength)) { + inputsValue = 0 + snackBar("Finished going through all possible values", "Restart", () { + start() + }) + } + else { + setTimeout(1000, tick) + } +} + +fun random { + final inputs = getInputs() + final inputsLength = inputs.length + + simSetInputsBinary(Math.randomInt(Math.pow(2, inputsLength))) +} + diff --git a/examples/standard.lcsproj b/examples/standard.lcsproj new file mode 100644 index 0000000..fe4cc3d Binary files /dev/null and b/examples/standard.lcsproj differ