Playground
Write an SCChart, see its diagram and run it tick by tick in your browser.
The playground runs the guide's own reimplementation of KIELER. For work you hand in, confirm the result in SCCharts Lab or KIELER. About the simulatorThe guide's own simulator, not KIELER. How it is checked
Examples
Showcase
Start here
Learn
Thinking in ticks
Your first SCChart
- Dimmerdimmer-states.sctx
- Dimmerdimmer.sctx
- Dimmerdimmer-held.sctx
- Dimmererr-semicolon.sctxRejected
- Dimmererr-no-initial.sctxRejected
- Lamplamp-broken.sctxExercise
- Turnstileturnstile-start.sctxExercise
- Dimmerdimmer-interface.sctx
- Dimmererr-case.sctxRejected
- Dimmererr-goto.sctxRejected
- Dimmererr-keyword.sctxRejected
- Dimmererr-order.sctxRejected
- Dimmererr-two-initial.sctxRejected
- Dimmererr-undeclared.sctxRejected
Triggers, effects and priority
- Thermostatthermostat.sctxExercise
- Samplersampler.sctx
- SamplerSwappedsampler-swapped.sctx
- Pumppump.sctx
- PumpStartFirstpump-start-first.sctx
- Stopwatchstopwatch.sctxExercise
- Stopwatchstopwatch-unreachable.sctx
- Stopwatchstopwatch-predict.sctx
- Effectseffects-order.sctx
- Thermostaterr-assign-trigger.sctxRejected
- Samplererr-comma.sctxRejected
- Samplererr-trailing-semicolon.sctxRejected
- Shadowedshadowed.sctx
- Staystay.sctx
Delayed and immediate transitions
Variables, types and expressions
Signals
Superstates
Concurrent regions
Aborts
- WeakCancelweak.sctxExercise
- StrongCancelstrong.sctx
- DelayedAbortdelayed-abort.sctx
- ImmediateAbortimmediate-abort.sctx
- TrayWeaktray-weak.sctx
- TrayStrongtray-strong.sctx
- WrongOrderorder-error.sctxRejected
- TwoPagestwo-pages.sctx
- TwoPagesJoinFirsttwo-pages-join-first.sctx
- ABROabro.sctx
- ABROWeakabro-weak.sctx
- TwoPagesStrongtwo-pages-strong.sctx
Entry, during and exit actions
- Fridgefridge.sctx
- FridgeAlarmfridge-alarm.sctx
- DuringCountduring.sctx
- ImmediateDuringCountimmediate-during.sctx
- ActionOrderorder.sctx
- NestedOrdernested-order.sctx
- SelfLoopself-loop.sctx
- Staystay.sctx
- Machineemergency.sctx
- CourtesyLightcourtesy-light.sctx
- FridgeLabelslabels.sctx
- PlainExitexit-plain.sctx
- WeakExitexit-weak.sctx
- Alarmalarm-start.sctxExercise
- Stopwatchstopwatch-start.sctxExercise
The previous tick
- Changechange.sctx
- Tanktank.sctx
- Edgesedges.sctx
- Toggletoggle.sctx
- EdgeToggleedge-toggle.sctx
- Doorbelldoorbell.sctx
- LongPressheld.sctx
- Knockknock.sctxExercise
- Knockknock-held.sctx
- KnockByHandknock-by-hand.sctx
- ImmediateCountimmediate-count.sctx
- KnockRestartknock-restart.sctxRejected
- KnockRestartByHandknock-restart-by-hand.sctx
- Pressespresses-start.sctxExercise
Why the compiler says no
- ExclusiveConflictlight-exclusive.sctxRejected
- OneOwnerlight-one-owner.sctx
- UpdateStylesupdate-styles.sctxRejected
- OldUpdatesold-updates.sctx
- OldUpdatesSwappedold-updates-swapped.sctx
- Passagepassage.sctxRejected
- PassagePrioritypassage-priority.sctx
- PassagePrepassage-pre.sctx
- Claimclaim.sctx
- ClaimBothclaim-both.sctxRejected
- Retryretry.sctxRejected
- RetryFixedretry-fixed.sctx
- SharedAlarmshared-alarm-start.sctxExercise
- Kettlekettle-start.sctxExercise
- TwoHandPresspress-start.sctxExercise
Going further
Suspension
- Microwavemicrowave.sctx
- RateOfChangepre-not-frozen.sctx
- CancelTrapcancel-trap.sctx
- CancelFixedcancel-fixed.sctx
- CancelRejectedabort-rejected.sctxRejected
- SessionCounterlost-entry.sctxExercise
- PreheatPlainjoin-plain.sctx
- PreheatSuspendjoin-suspend.sctx
- StartDelayeddelayed-suspend.sctx
- StartImmediateimmediate-suspend.sctx
- Previewweak-suspend.sctx
- Metronomemetronome-starter.sctxExercise
History and deferred transitions
- PlayerRestartplayer-restart.sctx
- PlayerHistoryplayer-history.sctx
- ResumeLocalslocals-reset.sctx
- MenuDeepmenu-deep.sctx
- MenuShallowmenu-shallow.sctx
- MenuNestednested-ignored.sctx
- MenuNestedFixednested-fixed.sctx
- ArriveDeferredarrive-deferred.sctx
- FillerNormalfiller-normal.sctx
- FillerDeferredfiller-deferred.sctx
- DeferredOnlydeferred-super-only.sctx
- DeferredMixeddeferred-super-mixed.sctx
- HouseDeferredhouse-deferred.sctx
- HouseDeephouse-deep.sctx
- RoomsHistoryhistory-deferred.sctx
- Kioskkiosk-starter.sctxExercise
- ArriveNormalarrive-normal.sctx
Connector states
Reusing charts
Arrays and for regions
- Seatbeltsseatbelts.sctx
- SeatLampsseat-lamps.sctx
- CopyOrdercopy-order.sctx
- ForSharedLocalshared-local.sctxRejected
- ForLocalPerCopylocal-per-copy.sctx
- LaunchKeyskeys-starter.sctxExercise
- ConstEndconst-end.sctxRejected
- ForCounterInitialisercounter-initialiser.sctxRejected
- ForGridgrid.sctx
- NestedFornested.sctxRejected
Dataflow regions
- Alarmalarm.sctx
- Celsiuscelsius.sctx
- Feedbackfeedback.sctxRejected
- FeedbackFixedfeedback-fixed.sctx
- Delaysdelays.sctx
- Countcount.sctx
- MixedTypesmixed-types.sctxRejected
- Clampclamp.sctx
- FullAdderfull-adder.sctx
- FridgeMonitorfridge-monitor.sctx
- FbyTerminationfby-termination.sctx
- Changedchanged-start.sctxExercise
- Highesthighest-start.sctxExercise
- ClampConcurrentclamp-concurrent.sctxRejected
- SfbyChainsfby-chain.sctx
Time
- EggTimeregg-timer.sctx
- EggTimeregg-timer-coarse.sctx
- EggTimerEqualegg-timer-equal.sctx
- StairLightstair-light.sctx
- Blinkblink.sctx
- BlinkForgetfulblink-forgetful.sctx
- StairLightLocalstair-light-local.sctx
- TwoTimerstwo-timers.sctxRejected
- BlinkSleepblink-sleep.sctx
- Samplersampler.sctx
- SamplerHardsampler-hard.sctx
- PulseTimerpulse-timer.sctx
- HandDryerhand-dryer-start.sctxExercise
- PeriodLeaveperiod-leave.sctxRejected
- PeriodLeaveFixedperiod-leave-fixed.sctx
- TwoTimersFixedtwo-timers-fixed.sctx
Methods and code effects
Enums, structs and classes
Comments and annotations
Host code
Patterns
ABRO
- ABROabro.sctx
- ABROBoolabro-bool.sctx
- ABROResetInsideabro-reset-inside.sctx
- ABRONoFinalabro-no-final.sctx
- ABROOffSwitchabro-off-switch.sctxRejected
- ABROImmediateabro-immediate.sctx
- ABROImmediateFlagsabro-immediate-flags.sctx
- ABThenCab-then-c-starter.sctxExercise
- ABORepeatabo-repeat-starter.sctxExercise
- ABROabro-predict.sctx
Edges and pulses
Debouncing
- BouncyTogglebouncy-toggle.sctx
- DebounceNaivedebounce-naive.sctx
- Debouncedebounce.sctx
- DebounceCounterdebounce-counter.sctx
- DebouncedToggledebounced-toggle.sctx
- Debouncedebounce-asym-starter.sctxExercise
- TwoButtonstwo-buttons-starter.sctxExercise
- Debouncedebounce-predict.sctx
- CountNeedsLiteralcount-literal-only.sctxRejected
Counters and timeouts
Latches
- CallButtoncall-button.sctx
- CallButtonFixedcall-button-fixed.sctx
- AlarmResetWinsalarm-reset-wins.sctx
- AlarmSetWinsalarm-set-wins.sctx
- TwoWriterstwo-writers.sctxRejected
- OneOwnerone-owner.sctx
- LatchEquationlatch-equation.sctx
- LatchEquationSetlatch-equation-set.sctx
- TwoFloorstwo-floors-starter.sctxExercise
- TicketQueuequeue-starter.sctxExercise
- CallButtonFixedcall-button-predict.sctx
Mode switching
Handshakes
Watchdogs
- Watchdogwatchdog.sctx
- WatchdogCounterwatchdog-counter.sctx
- Supervisorsupervisor.sctx
- SupervisorWeaksupervisor-weak.sctx
- WatchdogInsidewatchdog-inside.sctxRejected
- WatchdogInsideCounterwatchdog-inside-counter.sctx
- EarlyWarningearly-warning-starter.sctxExercise
- TwoSensorstwo-sensors-starter.sctxExercise
- Watchdogwatchdog-predict.sctx
Sharing a resource
Reference
Diagram notation
Operators
Compiler messages
- UnknownStateunknown-state.sctxRejected
- StrongAfterWeakstrong-after-weak.sctxRejected
- InstantLoopinstant-loop.sctxRejected
- WriteConflictwrite-conflict.sctxRejected
- SignalCyclesignal-cycle.sctxRejected
- ResetLoopWarningreset-loop-warning.sctx
- TimedWarningtimed-warning.sctx
- UnreachableTransitionunreachable-transition.sctx
- RegionsFinalMismatchregions-final-mismatch.sctx
- AbortNoTriggerabort-no-trigger.sctx
- ArrayScalarInitarray-scalar-init.sctxRejected
- ArraySizearray-size.sctxRejected
- AssignConstassign-const.sctxRejected
- AssignSignalassign-signal.sctxRejected
- BindingUnboundbinding-unbound.sctxRejected
- BrokenImportbroken-import.sctx
- CKeywordNamec-keyword-name.sctxRejected
- ClockSharedclock-shared.sctxRejected
- CodeSemicoloncode-semicolon.sctxRejected
- CombineMaxcombine-max.sctx
- ConnectorDeadEndconnector-dead-end.sctxRejected
- ConnectorNoDefaultconnector-no-default.sctx
- ConnectorNotImmediateconnector-not-immediate.sctx
- ConstNoInitconst-no-init.sctxRejected
- CountDelayComparecount-delay-compare.sctxRejected
- CountUnarycount-unary.sctx
- CountZerocount-zero.sctxRejected
- DeclSemicolondecl-semicolon.sctxRejected
- Lampduplicate-chart-names.sctx
- DuplicateDeclduplicate-decl.sctxRejected
- DuplicateRegionNamesduplicate-region-names.sctx
- DuringCountDelayduring-count-delay.sctx
- EmitValuedInputemit-valued-input.sctx
- EmitVariableemit-variable.sctxRejected
- empty-fileempty-file.sctxRejected
- ExtraBraceextra-brace.sctxRejected
- FloatCombinefloat-combine.sctxRejected
- FloatTriggerfloat-trigger.sctxRejected
- HistoryWarninghistory-warning.sctx
- ImplicitBindingimplicit-binding.sctx
- IntTooLargeint-too-large.sctxRejected
- JoinNoFinaljoin-no-final.sctxRejected
- JoinSimplejoin-simple.sctxRejected
- LayoutAnnotationlayout-annotation.sctx
- MissingBracemissing-brace.sctxRejected
- MissingDomissing-do.sctxRejected
- MissingTomissing-to.sctxRejected
- NoInitialno-initial.sctxRejected
- OutsideChartoutside-chart.sctxRejected
- PrintCalculationprint-calculation.sctx
- PureVariablepure-variable.sctxRejected
- ReferenceNoTerminationreference-no-termination.sctx
- RegionActionregion-action.sctx
- RelativeWriterelative-write.sctx
- ReservedNamereserved-name.sctxRejected
- StatesAndRegionsstates-and-regions.sctxRejected
- StaticNoInitstatic-no-init.sctx
- TwoInitialtwo-initial.sctxRejected
- UnclosedCommentunclosed-comment.sctxRejected
- UnknownChartunknown-chart.sctxRejected
- UnknownVariableunknown-variable.sctxRejected
- UnreachableStateunreachable-state.sctx
- UnsignedShiftunsigned-shift.sctxRejected
My chart does not do what I expect
Landing
No chart matches.
Compare with the model solutionCompare
About the simulator
The playground runs the guide's own reimplementation of KIELER's compiler and simulator, checked against KIELER. For work you hand in, confirm the result in SCCharts Lab or KIELER. More about the simulator
Keyboard shortcuts
- Ctrl+Enter
- Step one tick
- Ctrl+Shift+Enter
- Rebuild the simulation after an edit
- Ctrl+Space
- Complete a name, a keyword or a target state
- F12
- Go to the declaration of the name under the cursor (or Ctrl-click or ⌘-click it)
- Ctrl+/
- Comment or uncomment the selected lines
- Ctrl+F
- Find and replace
- F8
- Go to the next problem (with Shift: the previous one)
- Ctrl+S
- Download the chart as a .sctx file
- Ctrl+O
- Open a .sctx file (or drop one on the editor)
- Ctrl+Shift+S
- Copy a link to this chart
- EscthenTab
- Leave the editor (Tab alone indents)
- ?
- Show this help (outside the editor)
In the diagram
Drag to pan; Ctrl and the mouse wheel, or a pinch, zoom. With the diagram focused: the arrow keys pan, + and − zoom, 0 fits, 1 shows it at 100 %. The picture button downloads the diagram as an SVG file, in the light colours, for a report or a slide.
Press Tab once more to reach the chart's states and transitions: the arrow keys move between them in the order they are written, and Enter finds one in the source.
Click a state or a transition to find it in the source; the element under the cursor in the editor is outlined in the diagram. Hover over a name or a keyword in the editor to see what it is.
The list button shows the chart as an outline, every region, state and transition, for the keyboard and screen readers: moving through it marks the element in the diagram, and Enter selects its source.
In the simulation
Variables chooses what the timing diagram shows; the playground remembers it for each chart. Under the check boxes, Watch shows the value of an expression over the chart's inputs, outputs and variables in the tick shown (count >= 3 && !done, pre(x) != x; a variable of an inner state as Outer.count, a member as home.count, an enum value as Speed.HIGH), and Run until steps until the watch holds or a state is active (at most 1000 ticks). Copy link to this run copies a link with the inputs of every tick you ran: whoever opens it can step through the same run.
When a chart misbehaves
Troubleshooting goes from what you see (a transition that fires a tick late, an output that stays true, a chart that never terminates) to its cause and the fix. Compiler messages explains each error and warning; every problem in the list under the editor links to its entry.
This is still the starter
Back toEditor
1/*2 * ABRO, the "hello world" of synchronous3 * languages: emit O as soon as both A and4 * B have happened (in any order, or in the5 * same tick), then wait for R, which6 * starts it all over.7 */8scchart ABRO {9 input signal A, B, R10 output signal O11 12 initial state ABO {13 initial state WaitAB {14 region HandleA:15 initial state WaitA16 if A go to DoneA17 final state DoneA18 19 region HandleB:20 initial state WaitB21 if B go to DoneB22 final state DoneB23 }24 do O join to Done25 26 state Done27 }28 if R abort to ABO29}Diagram
ABROShowing the last diagram that parsed
Drawing the diagram
There is no scchart to draw yet.
Simulation
Loading the simulator.Turn on JavaScript to run the chart.