ContinuousClock
Generates a continuous time signal that starts counting from a specified time.
A clock component that outputs a continuously increasing signal starting from a specified time. The output equals the offset
value until the simulation time reaches start_time
, after which it increases linearly with time. The output value is calculated as offset
+ (time
- start_time
) when time
exceeds start_time
, otherwise it remains at the offset
value.
This component extends from Signal
Usage
ContinuousClock(start_time=0.0, offset=0.0)
Parameters:
Name | Description | Units | Default value |
---|---|---|---|
start_time | Time at which the signal starts changing from its offset value | s | 0 |
offset | Constant value added to the signal output | – | 0 |
Connectors
y
- This connector represents a real signal as an output from a component (RealOutput
)
Behavior
Source
dyad
# Generates a continuous time signal that starts counting from a specified time.
#
# A clock component that outputs a continuously increasing signal starting from a
# specified time. The output equals the `offset` value until the simulation time
# reaches `start_time`, after which it increases linearly with time. The output
# value is calculated as `offset` + (`time` - `start_time`) when `time` exceeds
# `start_time`, otherwise it remains at the `offset` value.
component ContinuousClock
extends Signal
relations
# Output equals `offset` if `time` < `start_time`, otherwise increases with time
y = if start_time<time then offset+time-start_time else offset
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/ContinuousClock.svg"}}}
end
Flattened Source
dyad
# Generates a continuous time signal that starts counting from a specified time.
#
# A clock component that outputs a continuously increasing signal starting from a
# specified time. The output equals the `offset` value until the simulation time
# reaches `start_time`, after which it increases linearly with time. The output
# value is calculated as `offset` + (`time` - `start_time`) when `time` exceeds
# `start_time`, otherwise it remains at the `offset` value.
component ContinuousClock
# Real-valued output connector for the component
y = RealOutput() [{"Dyad": {"placement": {"icon": {"x1": 950, "y1": 450, "x2": 1050, "y2": 550}}}}]
# Time at which the signal starts changing from its offset value
parameter start_time::Time = 0.0
# Constant value added to the signal output
parameter offset::Real = 0.0
relations
# Output equals `offset` if `time` < `start_time`, otherwise increases with time
y = if start_time<time then offset+time-start_time else offset
metadata {"Dyad": {"icons": {"default": "dyad://BlockComponents/ContinuousClock.svg"}}}
end
Test Cases
This is setup code, that must be run before each test case.
julia
using BlockComponents
using ModelingToolkit, OrdinaryDiffEqDefault
using Plots
using CSV, DataFrames
snapshotsdir = joinpath(dirname(dirname(pathof(BlockComponents))), "test", "snapshots")
"/home/actions-runner-10/.julia/packages/BlockComponents/77kIK/test/snapshots"
Related
Examples
Experiments
Analyses
Tests