Skip to content
LIBRARY
Examples.TestPeriodicClock.md

Examples.TestPeriodicClock ​

Test component that validates the PeriodicClock component.

This component specifically tests the "provoker" / output formulation of the periodic clock. If it works correctly, this component should instantiate and run without error, sampling once per dt seconds.

Usage ​

DiscreteComponents.Examples.TestPeriodicClock()

Parameters: ​

NameDescriptionUnitsDefault value
dt–0.1

Behavior ​

Source ​

dyad
"""
Test component that validates the PeriodicClock component.

This component specifically tests the "provoker" / output formulation of the periodic clock.
If it works correctly, this component should instantiate and run without error, sampling once per `dt` seconds.
"""
test component TestPeriodicClock
  sine = BlockComponents.Sources.Sine(frequency = 1, amplitude = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  samplevalue = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 180, "y1": 140, "x2": 280, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = dt) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 410, "y1": 50, "x2": 510, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter dt::Real = 0.1
relations
  connect(samplevalue.u, sine.y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(periodicclockprovoker.y, samplevalue.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 350, "y": 100}, {"x": 350, "y": 190}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {"tests": {"case1": {"stop": 10, "expect": {"signals": ["samplevalue.y"]}}}}
}
end
Flattened Source
dyad
"""
Test component that validates the PeriodicClock component.

This component specifically tests the "provoker" / output formulation of the periodic clock.
If it works correctly, this component should instantiate and run without error, sampling once per `dt` seconds.
"""
test component TestPeriodicClock
  sine = BlockComponents.Sources.Sine(frequency = 1, amplitude = 1.0) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 140, "x2": 120, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  samplevalue = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 180, "y1": 140, "x2": 280, "y2": 240, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclockprovoker = DiscreteComponents.PeriodicClock(dt = dt) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 410, "y1": 50, "x2": 510, "y2": 150, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter dt::Real = 0.1
relations
  connect(samplevalue.u, sine.y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(periodicclockprovoker.y, samplevalue.y) {
    "Dyad": {
      "edges": [{"S": 1, "M": [{"x": 350, "y": 100}, {"x": 350, "y": 190}], "E": 2}],
      "renderStyle": "standard"
    }
  }
metadata {
  "Dyad": {"tests": {"case1": {"stop": 10, "expect": {"signals": ["samplevalue.y"]}}}}
}
end


Test Cases ​

Test Case case1 ​

julia
plt