Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

item def

This notebook introduces item def; after running it you can declare named signal types and state, in the model itself, what each one denotes.

The previous notebook nested ApplyHeat inside ToastBread using the material flows Chapter 1 already defines (Bread, Toast) and the energy flows this chapter adds. The toasting cycle also has three named nouns Chapter 1 leaves undefined: a start, a finish, and a cancel request. This notebook declares them as item definitions and states, with each one’s own doc, that they denote signals: cycle start, cycle finish, cancel request, not the bread or toast themselves.

item def Start {
    doc /* Signal marking the start of a toasting cycle, not the bread itself. */
}

Start names a signal, not the bread entering the toaster: that material flow is already ToastBread::bread. The doc states this plainly so the model, not the surrounding prose, is the authority on what Start denotes.

item def Finish {
    doc /* Signal marking the finish of a toasting cycle, not the toast itself. */
}

Finish names the paired signal for the cycle’s end, distinct from ToastBread::toast, the toast itself.

item def Cancel {
    doc /* Signal requesting cancellation of an in-progress toasting cycle. */
}

Cancel is the third signal: a request to stop an in-progress cycle. None of the three is wired as an accepted or produced item of ApplyHeat in this chapter; each states its own meaning so a later chapter that does wire them has a fixed denotation to wire to, not an undecided one.

The three item definitions load without diagnostics. The next cell checks what happens when an item definition specializes a type that does not exist.

Expected error: unresolved reference: UndefinedBase

With the negative control confirmed, the next cell confirms all three item definitions, each carrying its own denotation as a doc, resolve in the loaded model.

ToasterDemo::Start: kind=itemDef
ToasterDemo::Finish: kind=itemDef
ToasterDemo::Cancel: kind=itemDef

item def Start { doc ... } item def Finish { doc ... } item def Cancel { doc ... }, printed above, loaded without error, and model.find() resolves each one, with each kind confirmed above.

Try the chapter exercise in exercises/ch04/exercise.ipynb: add three signal item defs (BrewStart, BrewFinish, BrewCancel) to your coffee maker model, each with a doc stating what it denotes and what it is NOT, and confirm each is findable.