the Subject to observe
function to execute when a SubjectEvent is broadcast by Subject, takes a single argument of type SubjectEvent
Optional
opt_purpose: stringDescribes what this Observer does, for debugging
Private
Readonly
purpose_Describes what this Observer does, for debugging
Notifies this Observer that a change has occurred in the Subject.
contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter
Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.
For an object whose main purpose is to represent another Printable object, it is
recommended to include the result of calling toStringShort
on that other object.
For example, calling toStringShort()
on a DisplayShape might return something like
this:
DisplayShape{polygon:Polygon{'chain3'}}
a minimal string representation of this object.
Generated using TypeDoc
Observes a Subject; when the Subject broadcasts a SubjectEvent then this executes a specified function.
Example 1
Here is an example of a GenericObserver that prints any event broadcast by a Clock:
Paste that code into the Terminal command line of any application, or try this link. which contains the above code running in the pendulum simulation. Click the rewind, play, and step buttons to see events in the Terminal output area.
Use the following Terminal command to turn off the GenericObserver:
Example 2
This prints only when a particular Clock event occurs:
Paste that code into the Terminal command line of any application, or try this link which contains the above code running in the pendulum simulation. Click the pause button to see events in the Terminal output area.
Example 3
This sets color of a contact force line according to gap distance: red = zero distance, green = max distance. This is useful to study the effects of using different settings for ExtraAccel.
The above script can be entered into the Terminal command line of most applications which use ContactSim. Or try this link which contains the above code running in ContactApp. That link also sets
EXTRA_ACCEL=none
so you will see the gap distance color vary periodically.