@@ -412,16 +412,16 @@ is below `furnace_on_threshold` and off when above `furnace_off_threshold`, whil
412412in between. To do this, we create two continuous callbacks:
413413
414414``` @example events
415- using Setfield
415+ using Accessors
416416furnace_disable = ModelingToolkit.SymbolicContinuousCallback(
417417 [temp ~ furnace_off_threshold],
418418 ModelingToolkit.ImperativeAffect(modified = (; furnace_on)) do x, o, c, i
419- @set! x.furnace_on = false
419+ @reset x.furnace_on = false
420420 end)
421421furnace_enable = ModelingToolkit.SymbolicContinuousCallback(
422422 [temp ~ furnace_on_threshold],
423423 ModelingToolkit.ImperativeAffect(modified = (; furnace_on)) do x, o, c, i
424- @set! x.furnace_on = true
424+ @reset x.furnace_on = true
425425 end)
426426```
427427
@@ -432,7 +432,7 @@ You can also write
432432``` julia
433433[temp ~ furnace_off_threshold] => ModelingToolkit. ImperativeAffect (modified = (;
434434 furnace_on)) do x, o, i, c
435- @set! x. furnace_on = false
435+ @reset x. furnace_on = false
436436end
437437```
438438
@@ -462,7 +462,7 @@ f(modified::NamedTuple, observed::NamedTuple, ctx, integrator)::NamedTuple
462462The function ` f ` will be called with ` observed ` and ` modified ` ` NamedTuple ` s that are derived from their respective ` NamedTuple ` definitions.
463463In our example, if ` furnace_on ` is ` false ` , then the value of the ` x ` that's passed in as ` modified ` will be ` (furnace_on = false) ` .
464464The modified values should be passed out in the same format: to set ` furnace_on ` to ` true ` we need to return a tuple ` (furnace_on = true) ` .
465- The examples does this with Setfield , recreating the result tuple before returning it; the returned tuple may optionally be missing values as
465+ The examples does this with Accessors , recreating the result tuple before returning it; the returned tuple may optionally be missing values as
466466well, in which case those values will not be written back to the problem.
467467
468468Accordingly, we can now interpret the ` ImperativeAffect ` definitions to mean that when ` temp = furnace_off_threshold ` we
@@ -542,18 +542,18 @@ In our encoder, we interpret this as occlusion or nonocclusion of the sensor, up
542542``` @example events
543543qAevt = ModelingToolkit.SymbolicContinuousCallback([cos(100 * theta) ~ 0],
544544 ModelingToolkit.ImperativeAffect((; qA, hA, hB, cnt), (; qB)) do x, o, c, i
545- @set! x.hA = x.qA
546- @set! x.hB = o.qB
547- @set! x.qA = 1
548- @set! x.cnt += decoder(x.hA, x.hB, x.qA, o.qB)
545+ @reset x.hA = x.qA
546+ @reset x.hB = o.qB
547+ @reset x.qA = 1
548+ @reset x.cnt += decoder(x.hA, x.hB, x.qA, o.qB)
549549 x
550550 end,
551551 affect_neg = ModelingToolkit.ImperativeAffect(
552552 (; qA, hA, hB, cnt), (; qB)) do x, o, c, i
553- @set! x.hA = x.qA
554- @set! x.hB = o.qB
555- @set! x.qA = 0
556- @set! x.cnt += decoder(x.hA, x.hB, x.qA, o.qB)
553+ @reset x.hA = x.qA
554+ @reset x.hB = o.qB
555+ @reset x.qA = 0
556+ @reset x.cnt += decoder(x.hA, x.hB, x.qA, o.qB)
557557 x
558558 end)
559559```
@@ -566,10 +566,10 @@ Instead, we can use right root finding:
566566``` @example events
567567qBevt = ModelingToolkit.SymbolicContinuousCallback([cos(100 * theta - π / 2) ~ 0],
568568 ModelingToolkit.ImperativeAffect((; qB, hA, hB, cnt), (; qA, theta)) do x, o, c, i
569- @set! x.hA = o.qA
570- @set! x.hB = x.qB
571- @set! x.qB = clamp(sign(cos(100 * o.theta - π / 2)), 0.0, 1.0)
572- @set! x.cnt += decoder(x.hA, x.hB, o.qA, x.qB)
569+ @reset x.hA = o.qA
570+ @reset x.hB = x.qB
571+ @reset x.qB = clamp(sign(cos(100 * o.theta - π / 2)), 0.0, 1.0)
572+ @reset x.cnt += decoder(x.hA, x.hB, o.qA, x.qB)
573573 x
574574 end; rootfind = SciMLBase.RightRootFind)
575575```
0 commit comments