### DO NOT EDIT THIS FILE
### This file is auto-generated by the Dyad command-line compiler.
### If you edit this code it is likely to get overwritten.
### Instead, update the Dyad source code and regenerate this file


@doc Markdown.doc"""
   TestPowertrain(; name)
"""
@component function TestPowertrain(; name = nothing, kwargs...)
  isnothing(name) && throw(ArgumentError("""
        The `name` keyword must be provided. Please consider using the `@named` macro,
        like so:

        @named model = TestPowertrain()
        """))
  __overrides = Dict{String, Symbolics.SymbolicT}(string(k) => v for (k, v) in kwargs)
  __params = Symbolics.SymbolicT[]
  __vars = Symbolics.SymbolicT[]
  __systems = System[]
  __guesses = Dict{Symbolics.SymbolicT, Symbolics.SymbolicT}()
  __initial_conditions = Dict{Symbolics.SymbolicT, Symbolics.SymbolicT}()
  __initialization_eqs = Equation[]
  __eqs = Equation[]
  __bindings = Dict{Symbolics.SymbolicT, Symbolics.SymbolicT}()

  ### Structural Parameters (functions)

  ### Structural Parameters (Final)

  ### Path Parameters (functions)

  ### Path Parameters (non-final)

  ### Final Parameters (declarations)

  ### Final Parameters (assignments)

  ### Deferred assignment (default values that depend on final parameters)

  ### Symbolic Parameters

  ### Final Path Parameters

  ### Variables (declarations)

  ### Variables (assignments)

  ### Constants
  __constants = Any[]

  ### Components
  # Subcomponent throttle_cmd of type BlockComponents.Sources.Step
  throttle_cmd_overrides = Dict(Symbol(replace(string(k), r"^throttle_cmd__" => "")) => v for (k, v) in __overrides if startswith(string(k), "throttle_cmd__"))
  filter!(p -> !startswith(string(first(p)), "throttle_cmd__"), __overrides)
  push!(__systems, @named throttle_cmd = BlockComponents.Sources.Step(height=-1, offset=1, start_time=25, throttle_cmd_overrides...))
  # Subcomponent powertrain of type FrictionBrakeDemo.SimplePowertrain
  powertrain_overrides = Dict(Symbol(replace(string(k), r"^powertrain__" => "")) => v for (k, v) in __overrides if startswith(string(k), "powertrain__"))
  filter!(p -> !startswith(string(first(p)), "powertrain__"), __overrides)
  push!(__systems, @named powertrain = FrictionBrakeDemo.SimplePowertrain(base_torque=150, tau=0.1, powertrain_overrides...))
  # Subcomponent load of type RotationalComponents.Components.Inertia
  load_overrides = Dict(Symbol(replace(string(k), r"^load__" => "")) => v for (k, v) in __overrides if startswith(string(k), "load__"))
  filter!(p -> !startswith(string(first(p)), "load__"), __overrides)
  push!(__systems, @named load = RotationalComponents.Components.Inertia(J=1, load_overrides...))
  # Subcomponent damper of type RotationalComponents.Components.Damper
  damper_overrides = Dict(Symbol(replace(string(k), r"^damper__" => "")) => v for (k, v) in __overrides if startswith(string(k), "damper__"))
  filter!(p -> !startswith(string(first(p)), "damper__"), __overrides)
  push!(__systems, @named damper = RotationalComponents.Components.Damper(d=5, damper_overrides...))
  # Subcomponent fixed of type RotationalComponents.Components.Fixed
  fixed_overrides = Dict(Symbol(replace(string(k), r"^fixed__" => "")) => v for (k, v) in __overrides if startswith(string(k), "fixed__"))
  filter!(p -> !startswith(string(first(p)), "fixed__"), __overrides)
  push!(__systems, @named fixed = RotationalComponents.Components.Fixed(fixed_overrides...))

  ### Check there are no unmatched overrides
  isempty(__overrides) || throw(ArgumentError("overides: [$(join(keys(__overrides), ", "))] don't match names found in model. These names may exist in the model but could have been conditionally excluded."))

  ### Guesses

  ### Initialization Equations
  push!(__initialization_eqs, load.phi ~ 0)
  push!(__initialization_eqs, load.w ~ 0)

  ### Assertions
  __assertions = []

  ### Equations
  push!(__eqs, powertrain.vehicle_speed ~ load.w * 0.15)
  push!(__eqs, connect(throttle_cmd.y, powertrain.throttle))
  push!(__eqs, connect(powertrain.drive, load.spline_a))
  push!(__eqs, connect(load.spline_b, damper.spline_a))
  push!(__eqs, connect(damper.spline_b, fixed.spline))

  # Return completely constructed System
  return System(__eqs, t, __vars, __params; systems=__systems, initial_conditions=__initial_conditions, guesses=__guesses, name, initialization_eqs=__initialization_eqs, bindings=__bindings, assertions=__assertions)
end
export TestPowertrain
