Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let default constructor initialize the GUIMetadata type #148

Open
zsoerenm opened this issue Feb 10, 2023 · 5 comments
Open

Let default constructor initialize the GUIMetadata type #148

zsoerenm opened this issue Feb 10, 2023 · 5 comments

Comments

@zsoerenm
Copy link

Something like this would be helpful e.g.

function Resistor(; name, R)
    @named oneport = OnePort()
    @unpack v, i = oneport
    pars = @parameters R = R
    eqs = [
        v ~ i * R,
    ]
    extend(ODESystem(eqs, t, [], pars; name = name, gui_metadata = GUIMetadata("Resistor")), oneport)
end

Maybe a symbol would fit better than a string?

@ChrisRackauckas
Copy link
Member

This seems misguided. Will this just be the same as the type name that would then be used for better lowering. @YingboMa should we just add that first?

@YingboMa
Copy link
Member

Should we always instantiate a component like

@component function Resistor(; name, R)
    @named oneport = OnePort()
    @unpack v, i = oneport
    pars = @parameters R = R
    eqs = [
        v ~ i * R,
    ]
    extend(ODESystem(eqs, t, [], pars; name = name), oneport)
end

?

@ChrisRackauckas
Copy link
Member

I think so. And it would make a Val(:Resistor) type information or something?

@YingboMa
Copy link
Member

We then have to assume all the components are instantiated in the same world age, but I guess it's a fair assumption.

And it would make a Val(:Resistor) type information or something?

Since it would be a very simple type system within MTK, we would use some other encoding that's independent from Julia's so that we don't take unnecessary compile time hit.

@ChrisRackauckas
Copy link
Member

oh yes no val. But yeah, let's go this route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants