//
// Saved by sw version: 2021.3
// Save timestamp: 21-Mar-2022 @ 06:30:04 PM
//

library "LabREI" {
    configuration {
        hil_device = "HIL604"
        hil_configuration_id = 1
        simulation_method = exact
        simulation_time_step = auto
        simulation_discret_scaling = 1.0
        dsp_timer_periods = 100e-6, 50e-3
        ss_calc_method = "systematic elimination"
        enb_pole_shift = True
        enb_gds_oversampling = True
        show_modes = False
        device_ao_limit_enable = False
        reset_analog_outputs_on_sim_stop = True
        reset_digital_outputs_on_sim_stop = True
        cpl_stb = False
        enb_dep_sw_detect = False
        code_section = "internal memory"
        data_section = "internal memory"
        sys_sp_rate_1 = 0.0001
        sys_sp_rate_2 = 0.05
        sys_real_type_precision = "default"
        user_real_type_precision = "default"
        sys_cpu_optimization = "high"
        user_cpu_optimization = "high"
        user_cpu_part_option = "default"
        matrix_based_reduction = True
        cpl_dynamics_analysis = False
        export_ss_to_pickle = False
        ground_scope_core = False
        cce_platform = "generic"
        cce_use_relative_names = False
        cce_type_mapping_real = "double"
        cce_type_mapping_uint = "unsigned int"
        cce_type_mapping_int = "int"
        cce_directory = ""
        cce_custom_type_int = ""
        cce_custom_type_uint = ""
        cce_custom_type_real = ""
        tunable_params = "component defined"
    }

    component Subsystem Root {
        component Category General {
            layout = dynamic
            component Subsystem Bus {
                layout = dynamic
                component "core/Current Measurement" Ia {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ia"
                }
                [
                    position = 7800, 7904
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ib"
                }
                [
                    position = 7800, 8072
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ic"
                }
                [
                    position = 7800, 8264
                    size = 64, 32
                ]

                component "core/Current Measurement" In {
                    bw_limit = "True"
                    frequency = "150e3"
                    signal_name = "In"
                }
                [
                    position = 7800, 8456
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Va {
                    sig_output = "True"
                    signal_name = "Va"
                }
                [
                    position = 7952, 7992
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vb {
                    sig_output = "True"
                    signal_name = "Vb"
                }
                [
                    position = 8048, 8168
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vc {
                    sig_output = "True"
                    signal_name = "Vc"
                }
                [
                    position = 8144, 8360
                    rotation = right
                    size = 64, 32
                ]

                component gen_PQ_transform "Power Meter1" {
                    enable_inst_ports = "False"
                }
                [
                    position = 8640, 7768
                ]

                component "core/Triple Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                    fb_out_type = "int"
                }
                [
                    position = 8048, 7776
                    rotation = right
                    size = 64, 256
                ]

                component gen_rms_value "RMS value1" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8104
                ]

                component gen_rms_value "RMS value2" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8168
                ]

                component gen_rms_value "RMS value3" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8232
                ]

                component gen_rms_value "RMS value4" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8296
                ]

                component gen_rms_value "RMS value5" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8360
                ]

                component gen_rms_value "RMS value6" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8424
                ]

                component gen_probe P {
                    signal_type = "power"
                }
                [
                    position = 8736, 7712
                ]

                component gen_probe Q {
                }
                [
                    position = 8736, 7768
                ]

                component gen_probe S {
                }
                [
                    position = 8736, 7832
                ]

                component gen_probe PF {
                }
                [
                    position = 8736, 7888
                ]

                component gen_probe Va_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8648, 8104
                ]

                component gen_probe Vb_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8648, 8168
                ]

                component gen_probe Vc_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8648, 8232
                ]

                component gen_probe Ia_rms {
                    signal_type = "current"
                }
                [
                    position = 8648, 8296
                ]

                component gen_probe Ib_rms {
                    signal_type = "current"
                }
                [
                    position = 8648, 8360
                ]

                component gen_probe Ic_rms {
                    signal_type = "current"
                }
                [
                    position = 8648, 8424
                ]

                port a+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7712, 7904
                ]

                port a- {
                    position = right:1
                    kind = pe
                }
                [
                    position = 8296, 7904
                    scale = -1, 1
                ]

                port b+ {
                    position = left:2
                    kind = pe
                }
                [
                    position = 7712, 8072
                ]

                port b- {
                    position = right:2
                    kind = pe
                }
                [
                    position = 8296, 8072
                    scale = -1, 1
                ]

                port c+ {
                    position = left:3
                    kind = pe
                }
                [
                    position = 7712, 8264
                ]

                port c- {
                    position = right:3
                    kind = pe
                }
                [
                    position = 8296, 8264
                    scale = -1, 1
                ]

                port n+ {
                    position = left:4
                    kind = pe
                }
                [
                    position = 7712, 8456
                ]

                port n- {
                    position = right:4
                    kind = pe
                }
                [
                    position = 8296, 8456
                    scale = -1, 1
                ]

                port a {
                    position = top:1
                    kind = pe
                }
                [
                    position = 7952, 7656
                    rotation = right
                ]

                port b {
                    position = top:2
                    kind = pe
                }
                [
                    position = 8048, 7656
                    rotation = right
                ]

                port c {
                    position = top:3
                    kind = pe
                }
                [
                    position = 8144, 7656
                    rotation = right
                ]

                port n {
                    position = top:4
                    kind = pe
                }
                [
                    position = 8240, 7656
                    rotation = right
                ]

                port SW {
                    position = bottom:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 8296, 7776
                    rotation = down
                ]

                tag Goto1 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 7864
                    size = 60, 20
                ]

                tag Goto2 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8024
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8216
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8000, 8032
                    rotation = right
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8096, 8224
                    rotation = right
                    size = 60, 20
                ]

                tag Goto7 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8192, 8408
                    rotation = right
                    size = 60, 20
                ]

                tag From1 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7728
                    size = 60, 20
                ]

                tag From2 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7792
                    size = 60, 20
                ]

                tag From3 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7856
                    size = 60, 20
                ]

                tag From4 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7920
                    size = 60, 20
                ]

                tag From5 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7984
                    size = 60, 20
                ]

                tag From6 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8048
                    size = 60, 20
                ]

                tag From7 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8104
                    size = 60, 20
                ]

                tag From8 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8168
                    size = 60, 20
                ]

                tag From9 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8232
                    size = 60, 20
                ]

                tag From10 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8296
                    size = 60, 20
                ]

                tag From11 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8360
                    size = 60, 20
                ]

                tag From12 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8424
                    size = 60, 20
                ]

                junction Junction4 pe
                [
                    position = 8240, 8456
                ]

                junction Junction8 pe
                [
                    position = 7952, 7904
                ]

                junction Junction9 pe
                [
                    position = 7952, 8456
                ]

                junction Junction10 pe
                [
                    position = 8048, 8072
                ]

                junction Junction11 pe
                [
                    position = 8048, 8456
                ]

                junction Junction12 pe
                [
                    position = 8144, 8264
                ]

                junction Junction13 pe
                [
                    position = 8144, 8456
                ]

                junction Junction22 pe
                [
                    position = 7952, 7904
                ]

                junction Junction23 pe
                [
                    position = 8048, 8072
                ]

                junction Junction24 pe
                [
                    position = 8144, 8264
                ]

                connect n- Junction4 as Connection14
                connect n Junction4 as Connection16
                connect Ia.p_node a+ as Connection43
                connect b+ Ib.p_node as Connection44
                connect Ic.p_node c+ as Connection47
                connect In.p_node n+ as Connection49
                connect Junction8 Ia.n_node as Connection51
                connect Va.p_node Junction8 as Connection52
                connect Junction9 In.n_node as Connection54
                connect Va.n_node Junction9 as Connection55
                connect Ib.n_node Junction10 as Connection56
                connect Vb.p_node Junction10 as Connection58
                connect Junction11 Junction9 as Connection60
                connect Vb.n_node Junction11 as Connection61
                connect Junction12 Ic.n_node as Connection63
                connect Vc.p_node Junction12 as Connection64
                connect Junction13 Junction11 as Connection66
                connect Vc.n_node Junction13 as Connection67
                connect Ia.out Goto1 as Connection72
                [
                    position = 0, 0
                    breakpoints = 7808, 7864
                ]
                connect Ib.out Goto2 as Connection73
                connect Ic.out Goto3 as Connection74
                connect Va.out Goto5 as Connection76
                connect Goto7 Vc.out as Connection78
                connect Goto6 Vb.out as Connection79
                connect a S1.c_in as Connection126
                connect b S1.b_in as Connection127
                connect c S1.a_in as Connection128
                connect a- Junction22 as Connection129
                connect Junction22 Junction8 as Connection130
                [
                    position = 0, 0
                    breakpoints = 7952, 7904
                ]
                connect S1.c_out Junction22 as Connection131
                connect Junction10 Junction23 as Connection132
                connect Junction23 b- as Connection133
                [
                    position = 0, 0
                    breakpoints = 8048, 8072; 8048, 8072
                ]
                connect S1.b_out Junction23 as Connection134
                connect c- Junction24 as Connection135
                connect Junction24 Junction12 as Connection136
                [
                    position = 0, 0
                    breakpoints = 8144, 8264
                ]
                connect S1.a_out Junction24 as Connection137
                connect From12 "RMS value6.in" as Connection138
                connect From11 "RMS value5.in" as Connection139
                connect From10 "RMS value4.in" as Connection140
                connect From9 "RMS value3.in" as Connection141
                connect From8 "RMS value2.in" as Connection142
                connect From7 "RMS value1.in" as Connection143
                connect From1 "Power Meter1.va" as Connection150
                connect "Power Meter1.vb" From2 as Connection151
                [
                    position = 0, 0
                    breakpoints = 8528, 7744; 8528, 7792
                ]
                connect From3 "Power Meter1.vc" as Connection152
                [
                    position = 0, 0
                    breakpoints = 8544, 7856; 8544, 7760
                ]
                connect "Power Meter1.ia" From4 as Connection153
                [
                    position = 0, 0
                    breakpoints = 8560, 7776; 8560, 7920
                ]
                connect "Power Meter1.ib" From5 as Connection154
                [
                    position = 0, 0
                    breakpoints = 8576, 7792; 8576, 7984
                ]
                connect From6 "Power Meter1.ic" as Connection155
                connect P.in "Power Meter1.Pdc" as Connection156
                connect Q.in "Power Meter1.Qdc" as Connection157
                [
                    position = 0, 0
                    breakpoints = 8704, 7768; 8704, 7728
                ]
                connect S.in "Power Meter1.apparent" as Connection158
                [
                    position = 0, 0
                    breakpoints = 8704, 7832; 8704, 7776
                ]
                connect PF.in "Power Meter1.k_factor" as Connection159
                connect "RMS value1.out" Va_rms.in as Connection160
                connect "RMS value2.out" Vb_rms.in as Connection161
                connect Vc_rms.in "RMS value3.out" as Connection162
                connect Ia_rms.in "RMS value4.out" as Connection163
                connect Ib_rms.in "RMS value5.out" as Connection164
                connect "RMS value6.out" Ic_rms.in as Connection165
                connect Junction13 Junction4 as Connection166
                [
                    position = 0, 0
                    breakpoints = 8144, 8456; 8240, 8456
                ]
                connect SW S1.ctrl_in as Connection167

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">General bus for connecting shunt loads/sources to a 4-wire, 3-phase grid.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The load/source must be connected at terminals a, b, c, and n. </p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">A contactor is utilized to switch on/off the load/source through the signal input port \"SW\".</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The grid should pass \"through\" the component by using therminals (a+-, b+-, c+-, and n+-).     </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component also provides current, voltage, active power, reactive power, apparent power, and power factor measurements.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Remark: currents and line-to-neutral voltages are measured at the grid entrace terminals (a+, b+, c+, and n+). </p></body></html>"

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE
                }
            }
            [
                position = 7152, 8432
                size = 80, 96
            ]

            component Subsystem "Bus (no switch)" {
                layout = dynamic
                component "core/Current Measurement" Ia {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ia"
                }
                [
                    position = 7800, 7904
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ib"
                }
                [
                    position = 7800, 8072
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ic"
                }
                [
                    position = 7800, 8264
                    size = 64, 32
                ]

                component "core/Current Measurement" In {
                    bw_limit = "True"
                    frequency = "150e3"
                    signal_name = "In"
                }
                [
                    position = 7800, 8456
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Va {
                    sig_output = "True"
                    signal_name = "Va"
                }
                [
                    position = 7952, 7992
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vb {
                    sig_output = "True"
                    signal_name = "Vb"
                }
                [
                    position = 8048, 8168
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vc {
                    sig_output = "True"
                    signal_name = "Vc"
                }
                [
                    position = 8144, 8360
                    rotation = right
                    size = 64, 32
                ]

                component gen_PQ_transform "Power Meter1" {
                    enable_inst_ports = "False"
                }
                [
                    position = 8640, 7768
                ]

                component gen_rms_value "RMS value1" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8104
                ]

                component gen_rms_value "RMS value2" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8168
                ]

                component gen_rms_value "RMS value3" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8232
                ]

                component gen_rms_value "RMS value4" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8296
                ]

                component gen_rms_value "RMS value5" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8360
                ]

                component gen_rms_value "RMS value6" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8552, 8424
                ]

                component gen_probe P {
                    signal_type = "power"
                }
                [
                    position = 8736, 7712
                ]

                component gen_probe Q {
                }
                [
                    position = 8736, 7768
                ]

                component gen_probe S {
                }
                [
                    position = 8736, 7832
                ]

                component gen_probe PF {
                }
                [
                    position = 8736, 7888
                ]

                component gen_probe Va_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8648, 8104
                ]

                component gen_probe Vb_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8648, 8168
                ]

                component gen_probe Vc_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8648, 8232
                ]

                component gen_probe Ia_rms {
                    signal_type = "current"
                }
                [
                    position = 8648, 8296
                ]

                component gen_probe Ib_rms {
                    signal_type = "current"
                }
                [
                    position = 8648, 8360
                ]

                component gen_probe Ic_rms {
                    signal_type = "current"
                }
                [
                    position = 8648, 8424
                ]

                port a+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7712, 7904
                ]

                port a- {
                    position = right:1
                    kind = pe
                }
                [
                    position = 8296, 7904
                    scale = -1, 1
                ]

                port b+ {
                    position = left:2
                    kind = pe
                }
                [
                    position = 7712, 8072
                ]

                port b- {
                    position = right:2
                    kind = pe
                }
                [
                    position = 8296, 8072
                    scale = -1, 1
                ]

                port c+ {
                    position = left:3
                    kind = pe
                }
                [
                    position = 7712, 8264
                ]

                port c- {
                    position = right:3
                    kind = pe
                }
                [
                    position = 8296, 8264
                    scale = -1, 1
                ]

                port n+ {
                    position = left:4
                    kind = pe
                }
                [
                    position = 7712, 8456
                ]

                port n- {
                    position = right:4
                    kind = pe
                }
                [
                    position = 8296, 8456
                    scale = -1, 1
                ]

                port a {
                    position = top:1
                    kind = pe
                }
                [
                    position = 7952, 7656
                    rotation = right
                ]

                port b {
                    position = top:2
                    kind = pe
                }
                [
                    position = 8048, 7656
                    rotation = right
                ]

                port c {
                    position = top:3
                    kind = pe
                }
                [
                    position = 8144, 7656
                    rotation = right
                ]

                port n {
                    position = top:4
                    kind = pe
                }
                [
                    position = 8240, 7656
                    rotation = right
                ]

                tag Goto1 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 7864
                    size = 60, 20
                ]

                tag Goto2 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8024
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8216
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8000, 8032
                    rotation = right
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8096, 8224
                    rotation = right
                    size = 60, 20
                ]

                tag Goto7 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8192, 8408
                    rotation = right
                    size = 60, 20
                ]

                tag From1 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7728
                    size = 60, 20
                ]

                tag From2 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7792
                    size = 60, 20
                ]

                tag From3 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7856
                    size = 60, 20
                ]

                tag From4 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7920
                    size = 60, 20
                ]

                tag From5 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 7984
                    size = 60, 20
                ]

                tag From6 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8048
                    size = 60, 20
                ]

                tag From7 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8104
                    size = 60, 20
                ]

                tag From8 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8168
                    size = 60, 20
                ]

                tag From9 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8232
                    size = 60, 20
                ]

                tag From10 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8296
                    size = 60, 20
                ]

                tag From11 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8360
                    size = 60, 20
                ]

                tag From12 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8424
                    size = 60, 20
                ]

                junction Junction4 pe
                [
                    position = 8240, 8456
                ]

                junction Junction8 pe
                [
                    position = 7952, 7904
                ]

                junction Junction9 pe
                [
                    position = 7952, 8456
                ]

                junction Junction10 pe
                [
                    position = 8048, 8072
                ]

                junction Junction11 pe
                [
                    position = 8048, 8456
                ]

                junction Junction12 pe
                [
                    position = 8144, 8264
                ]

                junction Junction13 pe
                [
                    position = 8144, 8456
                ]

                junction Junction14 pe
                [
                    position = 7952, 7912
                ]

                junction Junction15 pe
                [
                    position = 8048, 8080
                ]

                junction Junction16 pe
                [
                    position = 8144, 8264
                ]

                connect n- Junction4 as Connection14
                connect n Junction4 as Connection16
                connect Ia.p_node a+ as Connection43
                connect b+ Ib.p_node as Connection44
                connect Ic.p_node c+ as Connection47
                connect In.p_node n+ as Connection49
                connect Junction8 Ia.n_node as Connection51
                connect Junction9 In.n_node as Connection54
                connect Va.n_node Junction9 as Connection55
                connect Ib.n_node Junction10 as Connection56
                connect Junction11 Junction9 as Connection60
                connect Vb.n_node Junction11 as Connection61
                connect Junction12 Ic.n_node as Connection63
                connect Vc.p_node Junction12 as Connection64
                connect Junction13 Junction11 as Connection66
                connect Vc.n_node Junction13 as Connection67
                connect Ia.out Goto1 as Connection72
                [
                    position = 0, 0
                    breakpoints = 7808, 7864
                ]
                connect Ib.out Goto2 as Connection73
                connect Ic.out Goto3 as Connection74
                connect Va.out Goto5 as Connection76
                connect Goto7 Vc.out as Connection78
                connect Goto6 Vb.out as Connection79
                connect From12 "RMS value6.in" as Connection138
                connect From11 "RMS value5.in" as Connection139
                connect From10 "RMS value4.in" as Connection140
                connect From9 "RMS value3.in" as Connection141
                connect From8 "RMS value2.in" as Connection142
                connect From7 "RMS value1.in" as Connection143
                connect From1 "Power Meter1.va" as Connection150
                connect "Power Meter1.vb" From2 as Connection151
                [
                    position = 0, 0
                    breakpoints = 8528, 7744; 8528, 7792
                ]
                connect From3 "Power Meter1.vc" as Connection152
                [
                    position = 0, 0
                    breakpoints = 8544, 7856; 8544, 7760
                ]
                connect "Power Meter1.ia" From4 as Connection153
                [
                    position = 0, 0
                    breakpoints = 8560, 7776; 8560, 7920
                ]
                connect "Power Meter1.ib" From5 as Connection154
                [
                    position = 0, 0
                    breakpoints = 8576, 7792; 8576, 7984
                ]
                connect From6 "Power Meter1.ic" as Connection155
                connect P.in "Power Meter1.Pdc" as Connection156
                connect Q.in "Power Meter1.Qdc" as Connection157
                [
                    position = 0, 0
                    breakpoints = 8704, 7768; 8704, 7728
                ]
                connect S.in "Power Meter1.apparent" as Connection158
                [
                    position = 0, 0
                    breakpoints = 8704, 7832; 8704, 7776
                ]
                connect PF.in "Power Meter1.k_factor" as Connection159
                connect "RMS value1.out" Va_rms.in as Connection160
                connect "RMS value2.out" Vb_rms.in as Connection161
                connect Vc_rms.in "RMS value3.out" as Connection162
                connect Ia_rms.in "RMS value4.out" as Connection163
                connect Ib_rms.in "RMS value5.out" as Connection164
                connect "RMS value6.out" Ic_rms.in as Connection165
                connect Junction13 Junction4 as Connection166
                [
                    position = 0, 0
                    breakpoints = 8144, 8456; 8240, 8456
                ]
                connect Junction10 b- as Connection168
                [
                    position = 0, 0
                    breakpoints = 8048, 8072; 8048, 8072; 8048, 8072; 8048, 8072
                ]
                connect Junction8 a- as Connection169
                [
                    position = 0, 0
                    breakpoints = 7952, 7904; 7952, 7904; 7952, 7904
                ]
                connect Va.p_node Junction14 as Connection171
                connect Junction14 Junction8 as Connection172
                connect a Junction14 as Connection173
                connect Vb.p_node Junction15 as Connection174
                connect Junction15 Junction10 as Connection175
                connect b Junction15 as Connection176
                connect Junction12 Junction16 as Connection177
                connect Junction16 c- as Connection178
                [
                    position = 0, 0
                    breakpoints = 8144, 8264; 8144, 8264; 8144, 8264
                ]
                connect c Junction16 as Connection179

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">General bus for connecting shunt loads/sources to a 4-wire, 3-phase grid.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The load/source must be connected at terminals a, b, c, and n. </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The grid should pass \"through\" the component by using therminals (a+-, b+-, c+-, and n+-).     </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component also provides current, voltage, active power, reactive power, apparent power, and power factor measurements.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Remark: currents and line-to-neutral voltages are measured at the grid entrace terminals (a+, b+, c+, and n+). </p></body></html>"

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE
                }
            }
            [
                position = 7288, 8432
                size = 80, 96
            ]

            component Subsystem "Ending Bus (no switch)" {
                layout = dynamic
                component "core/Current Measurement" Ia {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ia"
                }
                [
                    position = 7800, 7904
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ib"
                }
                [
                    position = 7800, 8072
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ic"
                }
                [
                    position = 7800, 8264
                    size = 64, 32
                ]

                component "core/Current Measurement" In {
                    bw_limit = "True"
                    frequency = "150e3"
                    signal_name = "In"
                }
                [
                    position = 7800, 8456
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Va {
                    sig_output = "True"
                    signal_name = "Va"
                }
                [
                    position = 7952, 7992
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vb {
                    sig_output = "True"
                    signal_name = "Vb"
                }
                [
                    position = 8048, 8168
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vc {
                    sig_output = "True"
                    signal_name = "Vc"
                }
                [
                    position = 8144, 8360
                    rotation = right
                    size = 64, 32
                ]

                component gen_PQ_transform "Power Meter1" {
                    enable_inst_ports = "False"
                }
                [
                    position = 8672, 7936
                ]

                component gen_rms_value "RMS value1" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8312
                ]

                component gen_rms_value "RMS value2" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8376
                ]

                component gen_rms_value "RMS value3" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8440
                ]

                component gen_rms_value "RMS value4" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8504
                ]

                component gen_rms_value "RMS value5" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8568
                ]

                component gen_rms_value "RMS value6" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8632
                ]

                component gen_probe P {
                    signal_type = "power"
                }
                [
                    position = 8784, 7864
                ]

                component gen_probe Q {
                }
                [
                    position = 8840, 7912
                ]

                component gen_probe S {
                }
                [
                    position = 8784, 7944
                ]

                component gen_probe PF {
                }
                [
                    position = 8840, 7992
                ]

                component gen_probe Va_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8312
                ]

                component gen_probe Vb_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8376
                ]

                component gen_probe Vc_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8440
                ]

                component gen_probe Ia_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8504
                ]

                component gen_probe Ib_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8568
                ]

                component gen_probe Ic_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8632
                ]

                port a+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7496, 7904
                ]

                port a- {
                    position = right:1
                    kind = pe
                }
                [
                    position = 8296, 7904
                    scale = -1, 1
                ]

                port b+ {
                    position = left:2
                    kind = pe
                }
                [
                    position = 7496, 8072
                ]

                port b- {
                    position = right:2
                    kind = pe
                }
                [
                    position = 8296, 8072
                    scale = -1, 1
                ]

                port c+ {
                    position = left:3
                    kind = pe
                }
                [
                    position = 7496, 8264
                ]

                port c- {
                    position = right:3
                    kind = pe
                }
                [
                    position = 8296, 8264
                    scale = -1, 1
                ]

                port n+ {
                    position = left:4
                    kind = pe
                }
                [
                    position = 7496, 8456
                ]

                port n- {
                    position = right:4
                    kind = pe
                }
                [
                    position = 8296, 8456
                    scale = -1, 1
                ]

                tag Goto1 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 7864
                    size = 60, 20
                ]

                tag Goto2 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8024
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8216
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8000, 8032
                    rotation = right
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8096, 8224
                    rotation = right
                    size = 60, 20
                ]

                tag Goto7 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8192, 8408
                    rotation = right
                    size = 60, 20
                ]

                tag From1 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 7896
                    size = 60, 20
                ]

                tag From2 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 7960
                    size = 60, 20
                ]

                tag From3 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8024
                    size = 60, 20
                ]

                tag From4 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8088
                    size = 60, 20
                ]

                tag From5 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8152
                    size = 60, 20
                ]

                tag From6 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8216
                    size = 60, 20
                ]

                tag From7 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8312
                    size = 60, 20
                ]

                tag From8 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8376
                    size = 60, 20
                ]

                tag From9 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8440
                    size = 60, 20
                ]

                tag From10 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8504
                    size = 60, 20
                ]

                tag From11 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8568
                    size = 60, 20
                ]

                tag From12 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8632
                    size = 60, 20
                ]

                junction Junction8 pe
                [
                    position = 7952, 7904
                ]

                junction Junction9 pe
                [
                    position = 7952, 8456
                ]

                junction Junction10 pe
                [
                    position = 8048, 8072
                ]

                junction Junction11 pe
                [
                    position = 8048, 8456
                ]

                junction Junction12 pe
                [
                    position = 8144, 8264
                ]

                junction Junction13 pe
                [
                    position = 8144, 8456
                ]

                connect In.p_node n+ as Connection49
                connect Junction8 Ia.n_node as Connection51
                connect Va.p_node Junction8 as Connection52
                connect Junction9 In.n_node as Connection54
                connect Va.n_node Junction9 as Connection55
                connect Ib.n_node Junction10 as Connection56
                connect Vb.p_node Junction10 as Connection58
                connect Junction11 Junction9 as Connection60
                connect Vb.n_node Junction11 as Connection61
                connect Junction12 Ic.n_node as Connection63
                connect Vc.p_node Junction12 as Connection64
                connect Junction13 Junction11 as Connection66
                connect Vc.n_node Junction13 as Connection67
                connect Ia.out Goto1 as Connection72
                [
                    position = 0, 0
                    breakpoints = 7808, 7864
                ]
                connect Ib.out Goto2 as Connection73
                connect Ic.out Goto3 as Connection74
                connect Va.out Goto5 as Connection76
                connect Goto7 Vc.out as Connection78
                connect Goto6 Vb.out as Connection79
                connect a- Junction8 as Connection169
                [
                    position = 0, 0
                    breakpoints = 7952, 7904; 7952, 7904
                ]
                connect Junction12 c- as Connection168
                [
                    position = 0, 0
                    breakpoints = 8144, 8264; 8144, 8264; 8144, 8264
                ]
                connect Junction10 b- as Connection167
                [
                    position = 0, 0
                    breakpoints = 8048, 8072; 8048, 8072; 8048, 8072; 8048, 8072
                ]
                connect From12 "RMS value6.in" as Connection138
                connect From11 "RMS value5.in" as Connection139
                connect From10 "RMS value4.in" as Connection140
                connect From9 "RMS value3.in" as Connection141
                connect From8 "RMS value2.in" as Connection142
                connect From7 "RMS value1.in" as Connection143
                connect From1 "Power Meter1.va" as Connection150
                connect "Power Meter1.vb" From2 as Connection151
                [
                    position = 0, 0
                    breakpoints = 8560, 7912; 8560, 7960
                ]
                connect From3 "Power Meter1.vc" as Connection152
                [
                    position = 0, 0
                    breakpoints = 8576, 8024; 8576, 7928
                ]
                connect "Power Meter1.ia" From4 as Connection153
                [
                    position = 0, 0
                    breakpoints = 8592, 7944; 8592, 8088
                ]
                connect "Power Meter1.ib" From5 as Connection154
                [
                    position = 0, 0
                    breakpoints = 8608, 7960; 8608, 8152
                ]
                connect From6 "Power Meter1.ic" as Connection155
                connect P.in "Power Meter1.Pdc" as Connection156
                connect Q.in "Power Meter1.Qdc" as Connection157
                connect S.in "Power Meter1.apparent" as Connection158
                connect PF.in "Power Meter1.k_factor" as Connection159
                connect "RMS value1.out" Va_rms.in as Connection160
                connect "RMS value2.out" Vb_rms.in as Connection161
                connect Vc_rms.in "RMS value3.out" as Connection162
                connect Ia_rms.in "RMS value4.out" as Connection163
                connect Ib_rms.in "RMS value5.out" as Connection164
                connect "RMS value6.out" Ic_rms.in as Connection165
                connect Junction13 n- as Connection176
                [
                    position = 0, 0
                    breakpoints = 8144, 8456; 8240, 8456; 8240, 8456; 8240, 8456
                ]
                connect a+ Ia.p_node as Connection177
                connect b+ Ib.p_node as Connection178
                connect c+ Ic.p_node as Connection179

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">General bus for connecting loads/sources either to the right end or to the left end of a 4-wire, 3-phase grid.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The load/source must be connected at terminals a+, b+, c+, and n+.    </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component also provides current, voltage, active power, reactive power, apparent power, and power factor measurements.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Remark: currents and line-to-neutral voltages are measured at the grid entrace terminals (a+, b+, c+, and n+). </p></body></html>"

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE
                }
            }
            [
                position = 7688, 8432
                size = 80, 96
            ]

            component Subsystem "Left-end Bus" {
                layout = dynamic
                component "core/Current Measurement" Ia {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ia"
                }
                [
                    position = 7800, 7904
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ib"
                }
                [
                    position = 7800, 8072
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ic"
                }
                [
                    position = 7800, 8264
                    size = 64, 32
                ]

                component "core/Current Measurement" In {
                    bw_limit = "True"
                    frequency = "150e3"
                    signal_name = "In"
                }
                [
                    position = 7800, 8456
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Va {
                    sig_output = "True"
                    signal_name = "Va"
                }
                [
                    position = 7952, 7992
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vb {
                    sig_output = "True"
                    signal_name = "Vb"
                }
                [
                    position = 8048, 8168
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vc {
                    sig_output = "True"
                    signal_name = "Vc"
                }
                [
                    position = 8144, 8360
                    rotation = right
                    size = 64, 32
                ]

                component gen_PQ_transform "Power Meter1" {
                    enable_inst_ports = "False"
                }
                [
                    position = 8672, 7936
                ]

                component gen_rms_value "RMS value1" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8312
                ]

                component gen_rms_value "RMS value2" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8376
                ]

                component gen_rms_value "RMS value3" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8440
                ]

                component gen_rms_value "RMS value4" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8504
                ]

                component gen_rms_value "RMS value5" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8568
                ]

                component gen_rms_value "RMS value6" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8632
                ]

                component gen_probe P {
                    signal_type = "power"
                }
                [
                    position = 8784, 7864
                ]

                component gen_probe Q {
                }
                [
                    position = 8840, 7912
                ]

                component gen_probe S {
                }
                [
                    position = 8784, 7944
                ]

                component gen_probe PF {
                }
                [
                    position = 8840, 7992
                ]

                component gen_probe Va_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8312
                ]

                component gen_probe Vb_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8376
                ]

                component gen_probe Vc_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8440
                ]

                component gen_probe Ia_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8504
                ]

                component gen_probe Ib_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8568
                ]

                component gen_probe Ic_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8632
                ]

                component "core/Triple Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                }
                [
                    position = 7640, 8072
                    size = 64, 256
                ]

                port a+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7496, 7904
                ]

                port a- {
                    position = right:1
                    kind = pe
                }
                [
                    position = 8296, 7904
                    scale = -1, 1
                ]

                port b+ {
                    position = left:2
                    kind = pe
                }
                [
                    position = 7496, 8072
                ]

                port b- {
                    position = right:2
                    kind = pe
                }
                [
                    position = 8296, 8072
                    scale = -1, 1
                ]

                port c+ {
                    position = left:3
                    kind = pe
                }
                [
                    position = 7496, 8264
                ]

                port c- {
                    position = right:3
                    kind = pe
                }
                [
                    position = 8296, 8264
                    scale = -1, 1
                ]

                port n+ {
                    position = left:4
                    kind = pe
                }
                [
                    position = 7496, 8456
                ]

                port n- {
                    position = right:4
                    kind = pe
                }
                [
                    position = 8296, 8456
                    scale = -1, 1
                ]

                port SW {
                    position = bottom:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7576, 7904
                ]

                tag Goto1 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 7864
                    size = 60, 20
                ]

                tag Goto2 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8024
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7872, 8216
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8000, 8032
                    rotation = right
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8096, 8224
                    rotation = right
                    size = 60, 20
                ]

                tag Goto7 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8192, 8408
                    rotation = right
                    size = 60, 20
                ]

                tag From1 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 7896
                    size = 60, 20
                ]

                tag From2 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 7960
                    size = 60, 20
                ]

                tag From3 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8024
                    size = 60, 20
                ]

                tag From4 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8088
                    size = 60, 20
                ]

                tag From5 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8152
                    size = 60, 20
                ]

                tag From6 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8216
                    size = 60, 20
                ]

                tag From7 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8312
                    size = 60, 20
                ]

                tag From8 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8376
                    size = 60, 20
                ]

                tag From9 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8440
                    size = 60, 20
                ]

                tag From10 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8504
                    size = 60, 20
                ]

                tag From11 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8568
                    size = 60, 20
                ]

                tag From12 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8632
                    size = 60, 20
                ]

                junction Junction8 pe
                [
                    position = 7952, 7904
                ]

                junction Junction9 pe
                [
                    position = 7952, 8456
                ]

                junction Junction10 pe
                [
                    position = 8048, 8072
                ]

                junction Junction11 pe
                [
                    position = 8048, 8456
                ]

                junction Junction12 pe
                [
                    position = 8144, 8264
                ]

                junction Junction13 pe
                [
                    position = 8144, 8456
                ]

                connect In.p_node n+ as Connection49
                connect Junction8 Ia.n_node as Connection51
                connect Va.p_node Junction8 as Connection52
                connect Junction9 In.n_node as Connection54
                connect Va.n_node Junction9 as Connection55
                connect Ib.n_node Junction10 as Connection56
                connect Vb.p_node Junction10 as Connection58
                connect Junction11 Junction9 as Connection60
                connect Vb.n_node Junction11 as Connection61
                connect Junction12 Ic.n_node as Connection63
                connect Vc.p_node Junction12 as Connection64
                connect Junction13 Junction11 as Connection66
                connect Vc.n_node Junction13 as Connection67
                connect Ia.out Goto1 as Connection72
                [
                    position = 0, 0
                    breakpoints = 7808, 7864
                ]
                connect Ib.out Goto2 as Connection73
                connect Ic.out Goto3 as Connection74
                connect Va.out Goto5 as Connection76
                connect Goto7 Vc.out as Connection78
                connect Goto6 Vb.out as Connection79
                connect a- Junction8 as Connection169
                [
                    position = 0, 0
                    breakpoints = 7952, 7904; 7952, 7904
                ]
                connect Junction12 c- as Connection168
                [
                    position = 0, 0
                    breakpoints = 8144, 8264; 8144, 8264; 8144, 8264
                ]
                connect Junction10 b- as Connection167
                [
                    position = 0, 0
                    breakpoints = 8048, 8072; 8048, 8072; 8048, 8072; 8048, 8072
                ]
                connect From12 "RMS value6.in" as Connection138
                connect From11 "RMS value5.in" as Connection139
                connect From10 "RMS value4.in" as Connection140
                connect From9 "RMS value3.in" as Connection141
                connect From8 "RMS value2.in" as Connection142
                connect From7 "RMS value1.in" as Connection143
                connect From1 "Power Meter1.va" as Connection150
                connect "Power Meter1.vb" From2 as Connection151
                [
                    position = 0, 0
                    breakpoints = 8560, 7912; 8560, 7960
                ]
                connect From3 "Power Meter1.vc" as Connection152
                [
                    position = 0, 0
                    breakpoints = 8576, 8024; 8576, 7928
                ]
                connect "Power Meter1.ia" From4 as Connection153
                [
                    position = 0, 0
                    breakpoints = 8592, 7944; 8592, 8088
                ]
                connect "Power Meter1.ib" From5 as Connection154
                [
                    position = 0, 0
                    breakpoints = 8608, 7960; 8608, 8152
                ]
                connect From6 "Power Meter1.ic" as Connection155
                connect P.in "Power Meter1.Pdc" as Connection156
                connect Q.in "Power Meter1.Qdc" as Connection157
                connect S.in "Power Meter1.apparent" as Connection158
                connect PF.in "Power Meter1.k_factor" as Connection159
                connect "RMS value1.out" Va_rms.in as Connection160
                connect "RMS value2.out" Vb_rms.in as Connection161
                connect Vc_rms.in "RMS value3.out" as Connection162
                connect Ia_rms.in "RMS value4.out" as Connection163
                connect Ib_rms.in "RMS value5.out" as Connection164
                connect "RMS value6.out" Ic_rms.in as Connection165
                connect Junction13 n- as Connection176
                [
                    position = 0, 0
                    breakpoints = 8144, 8456; 8240, 8456; 8240, 8456; 8240, 8456
                ]
                connect S1.a_in a+ as Connection177
                connect S1.a_out Ia.p_node as Connection178
                connect S1.b_out Ib.p_node as Connection179
                connect S1.b_in b+ as Connection180
                connect S1.c_in c+ as Connection181
                connect S1.c_out Ic.p_node as Connection182
                connect SW S1.ctrl_in as Connection183

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">General bus for connecting loads/sources to the left-end of a 4-wire, 3-phase grid.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The load/source must be connected at terminals a+, b+, c+, and n+. </p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">A contactor is utilized to switch on/off the load/source through the signal input port \"SW\".    </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The only differece between this component and the \"Right-end Bus\" component is the contactor position.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component also provides current, voltage, active power, reactive power, apparent power, and power factor measurements.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Remark: currents and line-to-neutral voltages are measured at the grid entrace terminals (a+, b+, c+, and n+). </p></body></html>"

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE
                }
            }
            [
                position = 7424, 8432
                size = 80, 96
            ]

            component Subsystem "Rigth-end Bus" {
                layout = dynamic
                component "core/Current Measurement" Ia {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ia"
                }
                [
                    position = 7600, 7904
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ib"
                }
                [
                    position = 7600, 8072
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    bw_limit = "True"
                    frequency = "150e3"
                    sig_output = "True"
                    signal_name = "Ic"
                }
                [
                    position = 7600, 8264
                    size = 64, 32
                ]

                component "core/Current Measurement" In {
                    bw_limit = "True"
                    frequency = "150e3"
                    signal_name = "In"
                }
                [
                    position = 7600, 8456
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Va {
                    sig_output = "True"
                    signal_name = "Va"
                }
                [
                    position = 7752, 7992
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vb {
                    sig_output = "True"
                    signal_name = "Vb"
                }
                [
                    position = 7848, 8168
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vc {
                    sig_output = "True"
                    signal_name = "Vc"
                }
                [
                    position = 7944, 8360
                    rotation = right
                    size = 64, 32
                ]

                component gen_PQ_transform "Power Meter1" {
                    enable_inst_ports = "False"
                }
                [
                    position = 8672, 7936
                ]

                component gen_rms_value "RMS value1" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8312
                ]

                component gen_rms_value "RMS value2" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8376
                ]

                component gen_rms_value "RMS value3" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8440
                ]

                component gen_rms_value "RMS value4" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8504
                ]

                component gen_rms_value "RMS value5" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8568
                ]

                component gen_rms_value "RMS value6" {
                    frequency = "60"
                    op_mode = "Fixed frequency"
                }
                [
                    position = 8584, 8632
                ]

                component gen_probe P {
                    signal_type = "power"
                }
                [
                    position = 8784, 7864
                ]

                component gen_probe Q {
                }
                [
                    position = 8840, 7912
                ]

                component gen_probe S {
                }
                [
                    position = 8784, 7944
                ]

                component gen_probe PF {
                }
                [
                    position = 8840, 7992
                ]

                component gen_probe Va_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8312
                ]

                component gen_probe Vb_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8376
                ]

                component gen_probe Vc_rms {
                    signal_type = "voltage"
                }
                [
                    position = 8680, 8440
                ]

                component gen_probe Ia_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8504
                ]

                component gen_probe Ib_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8568
                ]

                component gen_probe Ic_rms {
                    signal_type = "current"
                }
                [
                    position = 8680, 8632
                ]

                component "core/Triple Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                }
                [
                    position = 8128, 8072
                    size = 64, 256
                ]

                port a+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7496, 7904
                ]

                port a- {
                    position = right:1
                    kind = pe
                }
                [
                    position = 8296, 7904
                    scale = -1, 1
                ]

                port b+ {
                    position = left:2
                    kind = pe
                }
                [
                    position = 7496, 8072
                ]

                port b- {
                    position = right:2
                    kind = pe
                }
                [
                    position = 8296, 8072
                    scale = -1, 1
                ]

                port c+ {
                    position = left:3
                    kind = pe
                }
                [
                    position = 7496, 8264
                ]

                port c- {
                    position = right:3
                    kind = pe
                }
                [
                    position = 8296, 8264
                    scale = -1, 1
                ]

                port n+ {
                    position = left:4
                    kind = pe
                }
                [
                    position = 7496, 8456
                ]

                port n- {
                    position = right:4
                    kind = pe
                }
                [
                    position = 8296, 8456
                    scale = -1, 1
                ]

                port SW {
                    position = bottom:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 8096, 7896
                ]

                tag Goto1 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7672, 7864
                    size = 60, 20
                ]

                tag Goto2 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7672, 8024
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7672, 8216
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7800, 8032
                    rotation = right
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7896, 8224
                    rotation = right
                    size = 60, 20
                ]

                tag Goto7 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7992, 8408
                    rotation = right
                    size = 60, 20
                ]

                tag From1 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 7896
                    size = 60, 20
                ]

                tag From2 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 7960
                    size = 60, 20
                ]

                tag From3 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8024
                    size = 60, 20
                ]

                tag From4 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8088
                    size = 60, 20
                ]

                tag From5 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8152
                    size = 60, 20
                ]

                tag From6 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8216
                    size = 60, 20
                ]

                tag From7 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8312
                    size = 60, 20
                ]

                tag From8 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8376
                    size = 60, 20
                ]

                tag From9 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8440
                    size = 60, 20
                ]

                tag From10 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8504
                    size = 60, 20
                ]

                tag From11 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8568
                    size = 60, 20
                ]

                tag From12 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8472, 8632
                    size = 60, 20
                ]

                junction Junction9 pe
                [
                    position = 7752, 8456
                ]

                junction Junction11 pe
                [
                    position = 7848, 8456
                ]

                junction Junction13 pe
                [
                    position = 7944, 8456
                ]

                junction Junction14 pe
                [
                    position = 7944, 8264
                ]

                junction Junction15 pe
                [
                    position = 7848, 8072
                ]

                junction Junction16 pe
                [
                    position = 7760, 7904
                ]

                connect In.p_node n+ as Connection49
                connect Junction9 In.n_node as Connection54
                connect Va.n_node Junction9 as Connection55
                connect Junction11 Junction9 as Connection60
                connect Vb.n_node Junction11 as Connection61
                connect Junction13 Junction11 as Connection66
                connect Vc.n_node Junction13 as Connection67
                connect Ia.out Goto1 as Connection72
                [
                    position = 0, 0
                    breakpoints = 7608, 7864
                ]
                connect Ib.out Goto2 as Connection73
                connect Ic.out Goto3 as Connection74
                connect Va.out Goto5 as Connection76
                connect Goto7 Vc.out as Connection78
                connect Goto6 Vb.out as Connection79
                connect a+ Ia.p_node as Connection170
                connect b+ Ib.p_node as Connection171
                connect c+ Ic.p_node as Connection172
                connect From12 "RMS value6.in" as Connection138
                connect From11 "RMS value5.in" as Connection139
                connect From10 "RMS value4.in" as Connection140
                connect From9 "RMS value3.in" as Connection141
                connect From8 "RMS value2.in" as Connection142
                connect From7 "RMS value1.in" as Connection143
                connect From1 "Power Meter1.va" as Connection150
                connect "Power Meter1.vb" From2 as Connection151
                [
                    position = 0, 0
                    breakpoints = 8560, 7912; 8560, 7960
                ]
                connect From3 "Power Meter1.vc" as Connection152
                [
                    position = 0, 0
                    breakpoints = 8576, 8024; 8576, 7928
                ]
                connect "Power Meter1.ia" From4 as Connection153
                [
                    position = 0, 0
                    breakpoints = 8592, 7944; 8592, 8088
                ]
                connect "Power Meter1.ib" From5 as Connection154
                [
                    position = 0, 0
                    breakpoints = 8608, 7960; 8608, 8152
                ]
                connect From6 "Power Meter1.ic" as Connection155
                connect P.in "Power Meter1.Pdc" as Connection156
                connect Q.in "Power Meter1.Qdc" as Connection157
                connect S.in "Power Meter1.apparent" as Connection158
                connect PF.in "Power Meter1.k_factor" as Connection159
                connect "RMS value1.out" Va_rms.in as Connection160
                connect "RMS value2.out" Vb_rms.in as Connection161
                connect Vc_rms.in "RMS value3.out" as Connection162
                connect Ia_rms.in "RMS value4.out" as Connection163
                connect Ib_rms.in "RMS value5.out" as Connection164
                connect "RMS value6.out" Ic_rms.in as Connection165
                connect Junction13 n- as Connection188
                [
                    position = 0, 0
                    breakpoints = 7944, 8456; 8040, 8456; 8240, 8456; 8240, 8456
                ]
                connect S1.a_out a- as Connection212
                connect S1.b_out b- as Connection213
                connect S1.c_out c- as Connection214
                connect Ic.n_node Junction14 as Connection215
                connect Junction14 Vc.p_node as Connection216
                [
                    position = 0, 0
                    breakpoints = 7944, 8264; 7944, 8264; 7944, 8264
                ]
                connect S1.c_in Junction14 as Connection217
                connect Ib.n_node Junction15 as Connection218
                connect Junction15 Vb.p_node as Connection219
                [
                    position = 0, 0
                    breakpoints = 7848, 8072; 7848, 8072
                ]
                connect S1.b_in Junction15 as Connection220
                connect Va.p_node Junction16 as Connection221
                [
                    position = 0, 0
                    breakpoints = 7752, 7904
                ]
                connect Junction16 Ia.n_node as Connection222
                [
                    position = 0, 0
                    breakpoints = 7760, 7904
                ]
                connect S1.a_in Junction16 as Connection223
                [
                    position = 0, 0
                    breakpoints = 7944, 7976; 7944, 7904
                ]
                connect SW S1.ctrl_in as Connection224

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">General bus for connecting loads/sources to the right-end of a 4-wire, 3-phase grid.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The load/source must be connected at terminals a+, b+, c+, and n+. </p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">A contactor is utilized to switch on/off the load/source through the signal input port \"SW\". </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The only differece between this component and the \"Left-end Bus\" component is the contactor position.    </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component also provides current, voltage, active power, reactive power, apparent power, and power factor measurements.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Remark: currents and line-to-neutral voltages are measured at the grid entrace terminals (a+, b+, c+, and n+). </p></body></html>"

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE
                }
            }
            [
                position = 7552, 8432
                size = 80, 96
            ]

            component Category Cabling {
                layout = dynamic
                component Subsystem "Three-phase Cabling" {
                    layout = dynamic
                    component pas_inductor L_a {
                        inductance = "length*L/2"
                    }
                    [
                        position = 7616, 8064
                    ]

                    component pas_resistor Rcc_a {
                        resistance = "Rcc*length"
                    }
                    [
                        position = 7728, 8064
                        rotation = down
                    ]

                    component pas_resistor Rd_a {
                        resistance = "Rdamp*length/2"
                    }
                    [
                        position = 7672, 8008
                        rotation = down
                    ]

                    component pas_inductor L_b {
                        inductance = "length*L/2"
                    }
                    [
                        position = 7624, 8224
                    ]

                    component pas_resistor Rcc_b {
                        resistance = "Rcc*length"
                    }
                    [
                        position = 7736, 8224
                        rotation = down
                    ]

                    component pas_resistor Rd_b {
                        resistance = "Rdamp*length/2"
                    }
                    [
                        position = 7680, 8176
                        rotation = down
                    ]

                    component pas_inductor L_c {
                        inductance = "length*L/2"
                    }
                    [
                        position = 7624, 8376
                    ]

                    component pas_resistor Rcc_c {
                        resistance = "Rcc*length"
                    }
                    [
                        position = 7736, 8376
                        rotation = down
                    ]

                    component pas_resistor Rd_c {
                        resistance = "Rdamp*length/2"
                    }
                    [
                        position = 7680, 8328
                        rotation = down
                    ]

                    component pas_inductor L_n {
                        inductance = "length*L/2"
                    }
                    [
                        position = 7632, 8544
                    ]

                    component pas_resistor Rcc_n {
                        resistance = "Rcc*length"
                    }
                    [
                        position = 7744, 8544
                        rotation = down
                    ]

                    component pas_resistor Rd_n {
                        resistance = "Rdamp*length/2"
                    }
                    [
                        position = 7680, 8496
                        rotation = down
                    ]

                    component pas_capacitor C3 {
                        capacitance = "3*length*C/2"
                    }
                    [
                        position = 7464, 8472
                        rotation = right
                    ]

                    component pas_capacitor C2 {
                        capacitance = "3*length*C/2"
                    }
                    [
                        position = 7384, 8304
                        rotation = right
                    ]

                    component pas_capacitor C1 {
                        capacitance = "3*length*C/2"
                    }
                    [
                        position = 7304, 8144
                        rotation = right
                    ]

                    component pas_capacitor C4 {
                        capacitance = "3*length*C/2"
                    }
                    [
                        position = 7864, 8144
                        rotation = right
                    ]

                    component pas_capacitor C5 {
                        capacitance = "3*length*C/2"
                    }
                    [
                        position = 7952, 8304
                        rotation = right
                    ]

                    component pas_capacitor C6 {
                        capacitance = "3*length*C/2"
                    }
                    [
                        position = 8032, 8464
                        rotation = right
                    ]

                    port P1 {
                        label = "a+"
                        position = left:1
                        kind = pe
                    }
                    [
                        position = 7200, 8064
                    ]

                    port P2 {
                        label = "a-"
                        position = right:1
                        kind = pe
                    }
                    [
                        position = 8160, 8064
                        scale = -1, 1
                    ]

                    port P3 {
                        label = "b+"
                        position = left:2
                        kind = pe
                    }
                    [
                        position = 7200, 8224
                    ]

                    port P4 {
                        label = "b-"
                        position = right:2
                        kind = pe
                    }
                    [
                        position = 8160, 8224
                        scale = -1, 1
                    ]

                    port P5 {
                        label = "c+"
                        position = left:3
                        kind = pe
                    }
                    [
                        position = 7200, 8376
                    ]

                    port P6 {
                        label = "c-"
                        position = right:3
                        kind = pe
                    }
                    [
                        position = 8160, 8376
                        scale = -1, 1
                    ]

                    port P7 {
                        label = "n+"
                        position = left:4
                        kind = pe
                    }
                    [
                        position = 7200, 8544
                    ]

                    port P8 {
                        label = "n-"
                        position = right:4
                        kind = pe
                    }
                    [
                        position = 8160, 8544
                        scale = -1, 1
                    ]

                    junction Junction360 pe
                    [
                        position = 7568, 8064
                    ]

                    junction Junction361 pe
                    [
                        position = 7776, 8064
                    ]

                    junction Junction364 pe
                    [
                        position = 7784, 8224
                    ]

                    junction Junction365 pe
                    [
                        position = 7568, 8224
                    ]

                    junction Junction370 pe
                    [
                        position = 7784, 8376
                    ]

                    junction Junction371 pe
                    [
                        position = 7560, 8376
                    ]

                    junction Junction378 pe
                    [
                        position = 7800, 8544
                    ]

                    junction Junction379 pe
                    [
                        position = 7568, 8544
                    ]

                    junction Junction381 pe
                    [
                        position = 7464, 8544
                    ]

                    junction Junction382 pe
                    [
                        position = 7464, 8376
                    ]

                    junction Junction385 pe
                    [
                        position = 7384, 8544
                    ]

                    junction Junction386 pe
                    [
                        position = 7384, 8224
                    ]

                    junction Junction389 pe
                    [
                        position = 7304, 8544
                    ]

                    junction Junction390 pe
                    [
                        position = 7304, 8064
                    ]

                    junction Junction392 pe
                    [
                        position = 7864, 8544
                    ]

                    junction Junction393 pe
                    [
                        position = 7864, 8064
                    ]

                    junction Junction396 pe
                    [
                        position = 7952, 8224
                    ]

                    junction Junction397 pe
                    [
                        position = 7952, 8544
                    ]

                    junction Junction400 pe
                    [
                        position = 8032, 8376
                    ]

                    junction Junction401 pe
                    [
                        position = 8032, 8544
                    ]

                    connect Rcc_a.n_node L_a.n_node as Connection2372
                    connect Rd_a.n_node Junction360 as Connection2402
                    connect Junction360 L_a.p_node as Connection2403
                    connect Rd_a.p_node Junction361 as Connection2405
                    connect Junction361 Rcc_a.p_node as Connection2406
                    connect Rcc_b.n_node L_b.n_node as Connection2408
                    connect Junction364 Rcc_b.p_node as Connection2414
                    connect Junction365 L_b.p_node as Connection2417
                    connect Rcc_c.n_node L_c.n_node as Connection2419
                    connect Junction370 Rcc_c.p_node as Connection2427
                    connect Junction371 L_c.p_node as Connection2430
                    connect Rcc_n.n_node L_n.n_node as Connection2432
                    connect Junction378 Rcc_n.p_node as Connection2442
                    connect Junction379 L_n.p_node as Connection2445
                    connect C3.n_node Junction381 as Connection2452
                    connect P5 Junction382 as Connection2453
                    connect C3.p_node Junction382 as Connection2455
                    connect C2.n_node Junction385 as Connection2464
                    connect P3 Junction386 as Connection2465
                    connect C2.p_node Junction386 as Connection2467
                    connect P7 Junction389 as Connection2474
                    connect C1.n_node Junction389 as Connection2476
                    connect P1 Junction390 as Connection2477
                    connect C1.p_node Junction390 as Connection2479
                    connect Rd_c.n_node Junction371 as Connection2486
                    [
                        position = 0, 0
                        breakpoints = 7576, 8376; 7568, 8376
                    ]
                    connect Rd_n.p_node Junction378 as Connection2487
                    [
                        position = 0, 0
                        breakpoints = 7792, 8544; 7792, 8544; 7792, 8544
                    ]
                    connect Rd_b.p_node Junction364 as Connection2484
                    [
                        position = 0, 0
                        breakpoints = 7784, 8224
                    ]
                    connect Rd_n.n_node Junction379 as Connection2485
                    [
                        position = 0, 0
                        breakpoints = 7584, 8544; 7568, 8544; 7568, 8544
                    ]
                    connect Rd_c.p_node Junction370 as Connection2483
                    [
                        position = 0, 0
                        breakpoints = 7784, 8376; 7784, 8376
                    ]
                    connect Junction365 Rd_b.n_node as Connection2488
                    [
                        position = 0, 0
                        breakpoints = 7568, 8224; 7576, 8224
                    ]
                    connect Junction392 Junction378 as Connection2490
                    connect C4.n_node Junction392 as Connection2491
                    connect Junction393 Junction361 as Connection2493
                    connect C4.p_node Junction393 as Connection2494
                    connect Junction396 Junction364 as Connection2502
                    connect C5.p_node Junction396 as Connection2503
                    connect C5.n_node Junction397 as Connection2506
                    connect Junction400 Junction370 as Connection2514
                    connect C6.p_node Junction400 as Connection2515
                    connect C6.n_node Junction401 as Connection2518
                    connect Junction360 Junction390 as Connection2525
                    connect Junction389 Junction385 as Connection2526
                    connect Junction365 Junction386 as Connection2527
                    [
                        position = 0, 0
                        breakpoints = 7568, 8224; 7376, 8224
                    ]
                    connect Junction381 Junction385 as Connection2528
                    [
                        position = 0, 0
                        breakpoints = 7464, 8544; 7376, 8544
                    ]
                    connect Junction371 Junction382 as Connection2530
                    [
                        position = 0, 0
                        breakpoints = 7560, 8376; 7528, 8376
                    ]
                    connect Junction379 Junction381 as Connection2529
                    [
                        position = 0, 0
                        breakpoints = 7568, 8544; 7528, 8544
                    ]
                    connect Junction397 Junction401 as Connection2531
                    [
                        position = 0, 0
                        breakpoints = 7952, 8544; 8016, 8544
                    ]
                    connect P4 Junction396 as Connection2532
                    [
                        position = 0, 0
                        breakpoints = 8016, 8224
                    ]
                    connect Junction392 Junction397 as Connection2534
                    [
                        position = 0, 0
                        breakpoints = 7864, 8544; 7928, 8544
                    ]
                    connect P2 Junction393 as Connection2533
                    [
                        position = 0, 0
                        breakpoints = 7928, 8064
                    ]
                    connect P6 Junction400 as Connection2536
                    [
                        position = 0, 0
                        breakpoints = 8096, 8376
                    ]
                    connect P8 Junction401 as Connection2535
                    [
                        position = 0, 0
                        breakpoints = 8096, 8544
                    ]

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Cabling model.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">It is a 4-wire, three-phase, pi-model with high-frequency power loss taken into account. </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The damping introduced for high-frequency components can be adjusted through the \"Damping resistance\" parameter.  </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">More information can be found in the E139 report. </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Suggested values:</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Inductance: 0.63e-6 H/m</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Capacitance: 40e-12 F/m</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">DC Resistance: 380e-6 Ohm/m</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Damping resistance: 0.5 Ohm/m </p></body></html>"

                        L {
                            label = "Inductance"
                            widget = edit
                            type = generic
                            default_value = "0.63e-6"
                            unit = "H/m"
                        }

                        C {
                            label = "Capacitance"
                            widget = edit
                            type = generic
                            default_value = "40e-12"
                            unit = "F/m"
                        }

                        Rcc {
                            label = "DC Resistance"
                            widget = edit
                            type = generic
                            default_value = "380e-6"
                            unit = "Ohm/m"
                        }

                        Rdamp {
                            label = "Damping resistance"
                            widget = edit
                            type = generic
                            default_value = "0.5"
                            unit = "Ohm/m"
                        }

                        length {
                            label = "Length"
                            widget = edit
                            type = generic
                            default_value = "25"
                            unit = "m"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7560, 8232
                    size = 64, 96
                ]

                component Subsystem "Single-phase Cabling" {
                    layout = dynamic
                    component pas_inductor L_a {
                        inductance = "length*L/2"
                    }
                    [
                        position = 7616, 8064
                    ]

                    component pas_resistor Rcc_a {
                        resistance = "Rcc*length"
                    }
                    [
                        position = 7728, 8064
                        rotation = down
                    ]

                    component pas_resistor Rd_a {
                        resistance = "Rdamp*length/2"
                    }
                    [
                        position = 7672, 8008
                        rotation = down
                    ]

                    component pas_capacitor C1 {
                        capacitance = "length*C/2"
                    }
                    [
                        position = 7528, 8144
                        rotation = right
                    ]

                    component pas_capacitor C4 {
                        capacitance = "length*C/2"
                    }
                    [
                        position = 7816, 8144
                        rotation = right
                    ]

                    component pas_inductor L_n {
                        inductance = "length*L/2"
                    }
                    [
                        position = 7632, 8224
                    ]

                    component pas_resistor Rcc_n {
                        resistance = "Rcc*length"
                    }
                    [
                        position = 7744, 8224
                        rotation = down
                    ]

                    component pas_resistor Rd_n {
                        resistance = "Rdamp*length/2"
                    }
                    [
                        position = 7680, 8176
                        rotation = down
                    ]

                    port P1 {
                        label = "ph1+"
                        position = left:1
                        kind = pe
                    }
                    [
                        position = 7424, 8064
                    ]

                    port P2 {
                        label = "ph1-"
                        position = right:1
                        kind = pe
                    }
                    [
                        position = 7928, 8064
                        scale = -1, 1
                    ]

                    port P7 {
                        label = "ph2+"
                        position = left:2
                        kind = pe
                    }
                    [
                        position = 7424, 8224
                    ]

                    port P8 {
                        label = "ph2-"
                        position = right:2
                        kind = pe
                    }
                    [
                        position = 7928, 8224
                        scale = -1, 1
                    ]

                    junction Junction360 pe
                    [
                        position = 7568, 8064
                    ]

                    junction Junction361 pe
                    [
                        position = 7776, 8064
                    ]

                    junction Junction390 pe
                    [
                        position = 7528, 8064
                    ]

                    junction Junction393 pe
                    [
                        position = 7816, 8064
                    ]

                    junction Junction394 pe
                    [
                        position = 7568, 8224
                    ]

                    junction Junction395 pe
                    [
                        position = 7528, 8224
                    ]

                    junction Junction396 pe
                    [
                        position = 7808, 8224
                    ]

                    junction Junction397 pe
                    [
                        position = 7792, 8224
                    ]

                    connect Junction360 Junction390 as Connection2561
                    [
                        position = 0, 0
                        breakpoints = 7568, 8064; 7528, 8064
                    ]
                    connect Junction393 P2 as Connection2562
                    [
                        position = 0, 0
                        breakpoints = 7816, 8064; 7880, 8064
                    ]
                    connect Rcc_a.n_node L_a.n_node as Connection2372
                    connect Rd_a.n_node Junction360 as Connection2402
                    connect Junction360 L_a.p_node as Connection2403
                    connect Rcc_n.n_node L_n.n_node as Connection2545
                    connect Rd_a.p_node Junction361 as Connection2405
                    connect Junction361 Rcc_a.p_node as Connection2406
                    connect L_n.p_node Junction394 as Connection2574
                    connect Junction394 Rd_n.n_node as Connection2575
                    [
                        position = 0, 0
                        breakpoints = 7568, 8224
                    ]
                    connect P7 Junction395 as Connection2577
                    connect Junction395 Junction394 as Connection2578
                    connect C1.n_node Junction395 as Connection2579
                    connect P8 Junction396 as Connection2580
                    [
                        position = 0, 0
                        breakpoints = 7880, 8224; 7880, 8224; 7880, 8224
                    ]
                    connect Junction396 C4.n_node as Connection2581
                    [
                        position = 0, 0
                        breakpoints = 7816, 8224; 7816, 8224; 7816, 8224; 7816, 8224
                    ]
                    connect Rcc_n.p_node Junction397 as Connection2583
                    connect Junction397 Junction396 as Connection2584
                    connect Rd_n.p_node Junction397 as Connection2585
                    [
                        position = 0, 0
                        breakpoints = 7792, 8176; 7792, 8200
                    ]
                    connect P1 Junction390 as Connection2477
                    connect C1.p_node Junction390 as Connection2479
                    connect Junction393 Junction361 as Connection2493
                    connect C4.p_node Junction393 as Connection2494

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Cabling model.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">It is single-phase, pi-model with high-frequency power loss taken into account. </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The damping introduced for high-frequency components can be adjusted through the \"Damping resistance\" parameter.  </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">More information can be found in the E139 report. </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Suggested values:</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Inductance: 0.63e-6 H/m</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Capacitance: 40e-12 F/m</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">DC Resistance: 380e-6 Ohm/m</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Damping resistance: 0.5 Ohm/m </p></body></html>"

                        L {
                            label = "Inductance"
                            widget = edit
                            type = generic
                            default_value = "0.63e-6"
                            unit = "H/m"
                        }

                        C {
                            label = "Capacitance"
                            widget = edit
                            type = generic
                            default_value = "40e-12"
                            unit = "F/m"
                        }

                        Rcc {
                            label = "DC Resistance"
                            widget = edit
                            type = generic
                            default_value = "380e-6"
                            unit = "Ohm/m"
                        }

                        Rdamp {
                            label = "Damping resistance"
                            widget = edit
                            type = generic
                            default_value = "0.5"
                            unit = "Ohm/m"
                        }

                        length {
                            label = "Length"
                            widget = edit
                            type = generic
                            default_value = "25"
                            unit = "m"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7560, 8064
                    size = 64, 96
                ]
            }
            [
                position = 7272, 8136
                size = 48, 48
            ]
        }
        [
            position = 4232, 4288
            size = 48, 48
        ]

        component Category "PV System" {
            layout = dynamic
            component Subsystem "1-ph PV Inverter" {
                layout = dynamic
                component "core/Single Phase Inverter" "Single Phase Inverter1" {
                    carrier_freq = "fcarr"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Ts"
                    fvd_def_method = "LUT"
                }
                [
                    position = 7632, 8088
                    size = 127, 256
                ]

                component pas_inductor Lf {
                    inductance = "Lf"
                }
                [
                    position = 7856, 7992
                ]

                component pas_resistor R0 {
                    resistance = "R0"
                }
                [
                    position = 7760, 7992
                ]

                component pas_capacitor Cf {
                    capacitance = "Cf"
                }
                [
                    position = 8032, 8088
                    rotation = right
                ]

                component "core/Voltage Measurement" Vdc {
                    execution_rate = "Ts_db"
                }
                [
                    position = 7440, 8096
                    rotation = right
                    size = 64, 32
                ]

                component "core/Current Measurement" Iinv {
                    execution_rate = "Ts_db"
                    sig_output = "True"
                }
                [
                    position = 7960, 7992
                    scale = 1, -1
                    size = 64, 32
                ]

                component gen_sum Sum1 {
                    signs = "+-"
                }
                [
                    position = 8552, 8488
                    hide_name = True
                ]

                component gen_gain Gain1 {
                    gain = "Lf*fcarr/VDC"
                }
                [
                    position = 8664, 8488
                ]

                component gen_gain Gain2 {
                    gain = "2/VDC"
                }
                [
                    position = 8624, 8672
                ]

                component gen_sum Sum2 {
                    signs = "++"
                }
                [
                    position = 8760, 8496
                    hide_name = True
                ]

                component gen_sum Sum3 {
                    signs = "+-"
                }
                [
                    position = 8856, 8504
                    hide_name = True
                ]

                component tm_delay "Unit Delay1" {
                    signal_out_type = "real"
                }
                [
                    position = 8912, 8608
                    hide_name = True
                    scale = -1, 1
                ]

                component gen_gain Gain3 {
                    gain = "-1"
                }
                [
                    position = 9144, 8568
                ]

                component "core/Rate Transition" "Rate Transition1" {
                    execution_rate = "Ts"
                }
                [
                    position = 9064, 8504
                    hide_name = True
                    size = 32, 32
                ]

                component gen_probe ma {
                }
                [
                    position = 9232, 8432
                ]

                component gen_probe mb {
                }
                [
                    position = 9232, 8648
                ]

                component gen_probe Ierror {
                }
                [
                    position = 8632, 8424
                ]

                component "core/Single phase PLL" "Single phase PLL1" {
                    offset_Hz = "60"
                }
                [
                    position = 7272, 8560
                    size = 64, 98
                ]

                component gen_probe f_PLL {
                }
                [
                    position = 7424, 8560
                ]

                component gen_terminator Termination1 {
                }
                [
                    position = 7424, 8416
                    hide_name = True
                ]

                component gen_terminator Termination2 {
                }
                [
                    position = 7424, 8448
                    hide_name = True
                ]

                component gen_terminator Termination3 {
                }
                [
                    position = 7424, 8480
                    hide_name = True
                ]

                component gen_product Product1 {
                    signs = "**"
                }
                [
                    position = 7864, 8696
                    hide_name = True
                ]

                component pas_capacitor Cdc {
                    capacitance = "10e-3"
                }
                [
                    position = 7352, 8096
                    rotation = right
                ]

                component gen_probe Iref {
                }
                [
                    position = 8048, 8776
                ]

                component "core/Current Measurement" Idc {
                    execution_rate = "Ts_db"
                }
                [
                    position = 7288, 7992
                    size = 64, 32
                ]

                component "core/Signal Controlled Voltage Source" Vs_dc {
                }
                [
                    position = 7208, 8104
                    rotation = right
                    size = 64, 32
                ]

                component src_constant Constant3 {
                    execution_rate = "Ts"
                    value = "VDC"
                }
                [
                    position = 7280, 8104
                    rotation = down
                    hide_name = True
                ]

                component gen_limiter Limit1 {
                    lower_limit = "-1"
                    upper_limit = "1"
                }
                [
                    position = 9000, 8504
                    hide_name = True
                ]

                component src_constant Constant4 {
                    execution_rate = "Ts_db"
                    value = "0"
                }
                [
                    position = 8992, 8640
                    rotation = down
                    hide_name = True
                ]

                component sys_signal_switch "Signal switch3" {
                    threshold = "0.5"
                }
                [
                    position = 8840, 8624
                    hide_name = True
                    scale = -1, 1
                ]

                component sys_signal_switch "Signal switch4" {
                    threshold = "0.5"
                }
                [
                    position = 8440, 8480
                    hide_name = True
                ]

                component sys_signal_switch "Signal switch5" {
                    threshold = "0.5"
                }
                [
                    position = 8440, 8576
                    hide_name = True
                ]

                component src_constant Constant6 {
                    execution_rate = "Ts_db"
                    value = "0"
                }
                [
                    position = 8328, 8728
                    hide_name = True
                ]

                component sys_signal_switch "Signal switch8" {
                    threshold = "0.5"
                }
                [
                    position = 8440, 8672
                    hide_name = True
                ]

                component gen_rel_op "Relational operator1" {
                    relational_op = ">="
                }
                [
                    position = 7584, 8456
                    hide_name = True
                ]

                component src_constant Constant8 {
                    execution_rate = "Ts_db"
                    value = "6.2"
                }
                [
                    position = 7512, 8488
                    hide_name = True
                ]

                component gen_logic_op "Logical operator1" {
                }
                [
                    position = 7712, 8448
                    hide_name = True
                ]

                component "core/Rate Transition" "Rate Transition13" {
                    execution_rate = "Ts_db"
                }
                [
                    position = 7624, 8400
                    hide_name = True
                    size = 32, 32
                ]

                component gen_sr_ff "SR Flip Flop1" {
                }
                [
                    position = 7800, 8464
                ]

                component gen_terminator Termination6 {
                }
                [
                    position = 7896, 8480
                    hide_name = True
                ]

                component "core/Edge Detection" "Edge Detection1" {
                    edge = "falling"
                }
                [
                    position = 7712, 8504
                    hide_name = True
                    size = 32, 32
                ]

                component sys_signal_switch "Signal switch9" {
                    threshold = "0.5"
                }
                [
                    position = 7952, 8712
                    hide_name = True
                ]

                component src_constant Constant9 {
                    execution_rate = "Ts_db"
                    value = "0"
                }
                [
                    position = 7880, 8776
                    hide_name = True
                ]

                component gen_digital_probe start {
                }
                [
                    position = 7888, 8400
                ]

                component "core/Rate Transition" "Rate Transition14" {
                    execution_rate = "Ts"
                }
                [
                    position = 7568, 7896
                    hide_name = True
                    size = 32, 32
                ]

                component "core/Double Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                    fb_out_type = "int"
                }
                [
                    position = 8120, 8088
                    size = 64, 256
                ]

                component gen_digital_probe Connected {
                }
                [
                    position = 7312, 7736
                ]

                component "core/Voltage Measurement" Vph {
                    execution_rate = "Ts_db"
                    sig_output = "True"
                }
                [
                    position = 8376, 8088
                    rotation = right
                    size = 64, 32
                ]

                component gen_probe I_amp {
                }
                [
                    position = 7768, 8776
                ]

                component gen_pid_controller "PID controller1" {
                    controller_type = "PI"
                    ki = "Ki"
                    kp = "Kp"
                    show_reset = "either"
                }
                [
                    position = 7576, 8840
                    hide_name = True
                ]

                component gen_probe P_meas {
                }
                [
                    position = 7272, 8744
                ]

                component gen_sum Sum4 {
                    signs = "-+"
                }
                [
                    position = 7464, 8832
                    hide_name = True
                ]

                component gen_limiter Limit2 {
                    lower_limit = "0"
                }
                [
                    position = 7656, 8840
                    hide_name = True
                ]

                component "core/Rate Transition" "Rate Transition15" {
                    execution_rate = "Ts_db"
                }
                [
                    position = 7504, 8904
                    hide_name = True
                    size = 32, 32
                ]

                component "core/Rate Transition" "Rate Transition16" {
                    execution_rate = "Ts_db"
                }
                [
                    position = 7360, 8840
                    hide_name = True
                    size = 32, 32
                ]

                component gen_product Product2 {
                }
                [
                    position = 7088, 8848
                    hide_name = True
                ]

                component gen_lpf "Low-Pass Filter1" {
                    execution_rate = "Ts_db"
                    frequency = "3"
                }
                [
                    position = 7160, 8848
                    hide_name = True
                ]

                component gen_probe vi {
                }
                [
                    position = 7184, 8920
                ]

                component "core/Current Measurement" Iph {
                    execution_rate = "Ts_db"
                    sig_output = "True"
                }
                [
                    position = 8272, 7992
                    scale = 1, -1
                    size = 64, 32
                ]

                port ph1 {
                    position = right:1
                    kind = pe
                }
                [
                    position = 8464, 7992
                    rotation = down
                ]

                port ph2 {
                    position = right:2
                    kind = pe
                }
                [
                    position = 8464, 8184
                    rotation = down
                ]

                port Connect {
                    position = top:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7216, 7800
                ]

                port P_ref {
                    position = top:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7296, 8840
                ]

                tag Goto2 {
                    value = "Iinv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7864, 8056
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto4 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 9264, 8504
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 9264, 8568
                    hide_name = True
                    size = 60, 20
                ]

                tag From5 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7704, 7896
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From6 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7704, 7928
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Iref"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8056, 8712
                    hide_name = True
                    size = 60, 20
                ]

                tag From17 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7544, 8400
                    hide_name = True
                    size = 60, 20
                ]

                tag From1 {
                    value = "Iref"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8464
                    hide_name = True
                    size = 60, 20
                ]

                tag From2 {
                    value = "Iinv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8560
                    hide_name = True
                    size = 60, 20
                ]

                tag From3 {
                    value = "Vph"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8656
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto8 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7368, 7800
                    hide_name = True
                    size = 60, 20
                ]

                tag From18 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8064, 7936
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto9 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7960, 8448
                    hide_name = True
                    size = 60, 20
                ]

                tag From19 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7480, 7896
                    hide_name = True
                    size = 60, 20
                ]

                tag From20 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8416
                    hide_name = True
                    size = 60, 20
                ]

                tag From21 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8880, 8568
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From22 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7872, 8640
                    hide_name = True
                    size = 60, 20
                ]

                tag From7 {
                    value = "Vph"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7176, 8560
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Vph"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8464, 8088
                    rotation = down
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag From10 {
                    value = "Vph"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7000, 8832
                    hide_name = True
                    size = 60, 20
                ]

                tag From11 {
                    value = "Iph"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7000, 8864
                    hide_name = True
                    size = 60, 20
                ]

                tag From12 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7440, 8904
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto10 {
                    value = "Iph"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8224, 8064
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                junction Junction4 pe
                [
                    position = 7440, 8184
                ]

                junction Junction10 sp
                [
                    position = 9192, 8504
                ]

                junction Junction11 sp
                [
                    position = 9192, 8568
                ]

                junction Junction12 sp
                [
                    position = 8600, 8488
                ]

                junction Junction18 pe
                [
                    position = 7352, 7992
                ]

                junction Junction23 pe
                [
                    position = 7440, 7992
                ]

                junction Junction29 pe
                [
                    position = 7352, 8184
                ]

                junction Junction36 sp
                [
                    position = 9112, 8504
                ]

                junction Junction40 sp
                [
                    position = 8960, 8504
                ]

                junction Junction38 sp
                [
                    position = 8384, 8592
                ]

                junction Junction44 sp
                [
                    position = 8384, 8688
                ]

                junction Junction45 sp
                [
                    position = 7368, 8504
                ]

                junction Junction47 sp
                [
                    position = 7664, 8440
                ]

                junction Junction48 sp
                [
                    position = 7984, 8712
                ]

                junction Junction53 sp
                [
                    position = 7840, 8448
                ]

                junction Junction58 pe
                [
                    position = 8032, 7992
                ]

                junction Junction59 pe
                [
                    position = 8032, 8184
                ]

                junction Junction60 sp
                [
                    position = 7272, 7800
                ]

                junction Junction61 sp
                [
                    position = 8440, 8416
                ]

                junction Junction62 sp
                [
                    position = 8504, 8520
                ]

                junction Junction65 pe
                [
                    position = 8376, 8184
                ]

                junction Junction67 sp
                [
                    position = 7208, 8816
                ]

                junction Junction68 sp
                [
                    position = 7128, 8848
                ]

                junction Junction69 sp
                [
                    position = 7712, 8784
                ]

                junction Junction70 pe
                [
                    position = 8376, 7992
                ]

                comment Comment1 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Deadbeat current controller </p></body></html> ENDCOMMENT 
                [
                    position = 8304, 8328
                ]

                comment Comment2 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Start power injection when the inverter is connected AND the grid voltage crosses 0 V (in order to avoid instability) </p></body></html> ENDCOMMENT 
                [
                    position = 7320, 8328
                ]

                comment Comment3 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Generate current reference from power loop</p></body></html> ENDCOMMENT 
                [
                    position = 7824, 8576
                ]

                comment Comment4 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PI for power flow control</p></body></html> ENDCOMMENT 
                [
                    position = 7424, 8768
                ]

                comment Comment5 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">AC Active power measurement</p></body></html> ENDCOMMENT 
                [
                    position = 6944, 8728
                ]

                connect R0.p_node "Single Phase Inverter1.a_in" as Connection3
                connect R0.n_node Lf.p_node as Connection4
                connect "Single Phase Inverter1.neg_out" Junction4 as Connection19
                connect Vdc.n_node Junction4 as Connection21
                connect Iinv.p_node Lf.n_node as Connection29
                connect Goto2 Iinv.out as Connection31
                connect Gain1.out Sum2.in as Connection37
                connect Sum2.in1 Gain2.out as Connection38
                [
                    position = 0, 0
                    breakpoints = 8704, 8504; 8704, 8576
                ]
                connect From5 "Single Phase Inverter1.InA" as Connection52
                connect From6 "Single Phase Inverter1.InB" as Connection53
                connect Junction10 Goto4 as Connection65
                connect ma.in Junction10 as Connection66
                connect Gain3.out Junction11 as Connection67
                connect Junction11 Goto5 as Connection68
                connect mb.in Junction11 as Connection69
                connect Gain1.in Junction12 as Connection70
                connect Junction12 Sum1.out as Connection71
                connect Ierror.in Junction12 as Connection72
                connect f_PLL.in "Single phase PLL1.f" as Connection95
                connect Termination1.in "Single phase PLL1.d" as Connection96
                connect Termination2.in "Single phase PLL1.q" as Connection97
                [
                    position = 0, 0
                    breakpoints = 7344, 8448; 7344, 8544
                ]
                connect Product1.in "Single phase PLL1.sin(wt)" as Connection105
                [
                    position = 0, 0
                    breakpoints = 7368, 8688; 7368, 8656; 7344, 8592
                ]
                connect Cdc.p_node Junction18 as Connection110
                connect Junction18 Idc.n_node as Connection135
                connect Vdc.p_node Junction23 as Connection137
                connect Junction23 Junction18 as Connection138
                [
                    position = 0, 0
                    breakpoints = 7440, 7992
                ]
                connect "Single Phase Inverter1.pos_out" Junction23 as Connection139
                connect Vs_dc.p_node Idc.p_node as Connection205
                connect Junction4 Junction29 as Connection206
                [
                    position = 0, 0
                    breakpoints = 7440, 8184
                ]
                connect Junction29 Cdc.n_node as Connection207
                [
                    position = 0, 0
                    breakpoints = 7352, 8184; 7352, 8184
                ]
                connect Vs_dc.n_node Junction29 as Connection208
                connect Constant3.out Vs_dc.in as Connection209
                connect Sum2.out Sum3.in as Connection211
                connect "Rate Transition1.in" Limit1.out as Connection286
                connect Gain3.in Junction36 as Connection320
                [
                    position = 0, 0
                    breakpoints = 9112, 8568; 9112, 8504
                ]
                connect Junction36 Junction10 as Connection321
                connect "Rate Transition1.out" Junction36 as Connection322
                connect Junction40 Sum3.out as Connection363
                [
                    position = 0, 0
                    breakpoints = 8920, 8504
                ]
                connect "Unit Delay1.in" Junction40 as Connection402
                connect "Signal switch3.out" Sum3.in1 as Connection403
                connect Constant4.out "Signal switch3.in1" as Connection404
                connect "Signal switch3.in" "Unit Delay1.out" as Connection405
                connect "Signal switch5.in1" Junction38 as Connection333
                connect "Signal switch4.in1" Junction38 as Connection335
                [
                    position = 0, 0
                    breakpoints = 8384, 8496; 8384, 8592
                ]
                connect Junction38 Junction44 as Connection396
                connect Junction44 Constant6.out as Connection397
                connect "Signal switch8.in1" Junction44 as Connection398
                connect Termination3.in Junction45 as Connection415
                [
                    position = 0, 0
                    breakpoints = 7368, 8480
                ]
                connect Junction45 "Single phase PLL1.wt" as Connection416
                [
                    position = 0, 0
                    breakpoints = 7368, 8576
                ]
                connect Constant8.out "Relational operator1.in1" as Connection421
                connect From17 "Rate Transition13.in" as Connection424
                connect Termination6.in "SR Flip Flop1.out_n" as Connection428
                connect "Rate Transition13.out" Junction47 as Connection429
                connect Junction47 "Logical operator1.in" as Connection430
                connect "Edge Detection1.In1" Junction47 as Connection431
                connect Constant9.out "Signal switch9.in1" as Connection433
                connect Iref.in Junction48 as Connection435
                connect Junction48 Goto6 as Connection436
                [
                    position = 0, 0
                    breakpoints = 7984, 8712
                ]
                connect "Signal switch9.out" Junction48 as Connection437
                connect "Signal switch9.in" Product1.out as Connection438
                connect "Signal switch4.out" Sum1.in as Connection452
                connect "Signal switch5.out" Sum1.in1 as Connection453
                connect "Signal switch8.out" Gain2.in as Connection454
                connect From1 "Signal switch4.in" as Connection455
                connect From2 "Signal switch5.in" as Connection456
                connect From3 "Signal switch8.in" as Connection457
                [
                    position = 0, 0
                    breakpoints = 8416, 8656
                ]
                connect start.in Junction53 as Connection458
                connect "Single Phase Inverter1.En" "Rate Transition14.out" as Connection473
                connect Junction58 Cf.p_node as Connection478
                [
                    position = 0, 0
                    breakpoints = 8032, 7992
                ]
                connect S1.a_in Junction58 as Connection479
                connect Cf.n_node Junction59 as Connection480
                connect S1.b_in Junction59 as Connection482
                connect Goto8 Junction60 as Connection486
                connect Junction60 Connected.in as Connection487
                [
                    position = 0, 0
                    breakpoints = 7272, 7800; 7272, 7736
                ]
                connect Connect Junction60 as Connection488
                connect From18 S1.ctrl_in as Connection489
                connect From19 "Rate Transition14.in" as Connection494
                connect Goto9 Junction53 as Connection497
                connect From20 Junction61 as Connection499
                connect Junction61 "Signal switch4.in2" as Connection500
                connect "Signal switch5.in2" Junction62 as Connection502
                connect Junction62 Junction61 as Connection503
                [
                    position = 0, 0
                    breakpoints = 8504, 8520; 8504, 8416
                ]
                connect "Signal switch8.in2" Junction62 as Connection504
                connect From21 "Signal switch3.in2" as Connection505
                connect Junction40 Limit1.in as Connection506
                [
                    position = 0, 0
                    breakpoints = 8960, 8504; 8960, 8504
                ]
                connect "Edge Detection1.Out1" "SR Flip Flop1.r_in" as Connection507
                [
                    position = 0, 0
                    breakpoints = 7744, 8504
                ]
                connect "Logical operator1.in1" "Relational operator1.out" as Connection508
                [
                    position = 0, 0
                    breakpoints = 7632, 8456
                ]
                connect "SR Flip Flop1.s_in" "Logical operator1.out" as Connection509
                [
                    position = 0, 0
                    breakpoints = 7752, 8448
                ]
                connect Junction53 "SR Flip Flop1.out" as Connection510
                [
                    position = 0, 0
                    breakpoints = 7840, 8448; 7840, 8448
                ]
                connect From22 "Signal switch9.in2" as Connection511
                connect "Relational operator1.in" Junction45 as Connection512
                [
                    position = 0, 0
                    breakpoints = 7472, 8504
                ]
                connect From7 "Single phase PLL1.In" as Connection517
                connect Junction58 Iinv.n_node as Connection520
                connect "Single Phase Inverter1.b_in" Junction59 as Connection521
                connect Goto3 Vph.out as Connection35
                connect S1.b_out Junction65 as Connection525
                connect Junction65 ph2 as Connection526
                connect Vph.n_node Junction65 as Connection527
                connect Sum4.out "PID controller1.in" as Connection304
                connect "PID controller1.out" Limit2.in as Connection544
                connect From12 "Rate Transition15.in" as Connection546
                connect "Rate Transition15.out" "PID controller1.reset" as Connection547
                connect P_ref "Rate Transition16.in" as Connection548
                connect "Rate Transition16.out" Sum4.in1 as Connection549
                connect From10 Product2.in as Connection554
                connect Product2.in1 From11 as Connection555
                connect Sum4.in Junction67 as Connection557
                [
                    position = 0, 0
                    breakpoints = 7424, 8816
                ]
                connect Junction67 P_meas.in as Connection558
                [
                    position = 0, 0
                    breakpoints = 7208, 8816
                ]
                connect "Low-Pass Filter1.out" Junction67 as Connection559
                connect Product2.out Junction68 as Connection562
                connect Junction68 "Low-Pass Filter1.in" as Connection563
                connect vi.in Junction68 as Connection564
                connect Limit2.out Junction69 as Connection565
                connect Product1.in1 Junction69 as Connection567
                connect Goto10 Iph.out as Connection553
                connect I_amp.in Junction69 as Connection569
                [
                    position = 0, 0
                    breakpoints = 7712, 8776; 7712, 8776
                ]
                connect Iph.p_node S1.a_out as Connection570
                connect Vph.p_node Junction70 as Connection571
                connect Junction70 ph1 as Connection572
                [
                    position = 0, 0
                    breakpoints = 8376, 7992
                ]
                connect Iph.n_node Junction70 as Connection573

                Cf = "30e-6"
                Ki = "0.7"
                Kp = "0.01"
                Lf = "5e-3"

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Constant dc-voltage, single-phase, current-controlled, voltage-source inverter.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component is a simplified model of a PV inverter with active power injection control. No MPPT system is present. The dc-link is considered to be a constant voltage source.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The control system is implemented in a double-loop structure: </p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The inner loop regulates the inductor current via a dead-beat, predictive controller while the outer loop regulates the power flow by means of a PI controller.   </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">I/O Description:</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- ph1/ph2: grid phase connection</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- Connect: signal command for connecting the inverter to the grid</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- P_ref: active power reference</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Parameters description:</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- General:</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Dc Voltage: DC-link nominal voltage</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Carrier frequency: PWM carrier frequency / switching frequency</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Dead-time: inverter dead-time</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Execution rate: inverter component execution rate (it is recommended to be smaller than the switching frequency)</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- LC Filter: ac-side LC-filter component values</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- PI - Power loop: proportional and integral gains for power loop PI controller</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  </p></body></html>"

                    VDC {
                        label = "Dc Voltage"
                        widget = edit
                        type = generic
                        default_value = "710"
                        unit = "V"
                        group = "General"
                    }

                    fcarr {
                        label = "Carrier frequency"
                        widget = edit
                        type = generic
                        default_value = "20e3"
                        unit = "Hz"
                        group = "General"
                    }

                    dt {
                        label = "Dead-time"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    Ts {
                        label = "Execution rate"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    Lf {
                        label = "Inductor"
                        widget = edit
                        type = generic
                        default_value = "14e-3"
                        unit = "H"
                        group = "LC Filter"
                    }

                    R0 {
                        label = "Inductor resistance"
                        widget = edit
                        type = generic
                        default_value = "1e-3"
                        unit = "Ohm"
                        group = "LC Filter"
                    }

                    Cf {
                        label = "Capacitor"
                        widget = edit
                        type = generic
                        default_value = "1.8e-6"
                        unit = "F"
                        group = "LC Filter"
                    }

                    Kp {
                        label = "Proportional gain"
                        widget = edit
                        type = generic
                        default_value = "0.2"
                        group = "PI - Power loop"
                    }

                    Ki {
                        label = "Integral gain"
                        widget = edit
                        type = generic
                        default_value = "1"
                        group = "PI - Power loop"
                    }

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE

                    CODE init
                    ENDCODE

                    CODE pre_compile
                        # HEADER START
                        VDC = mdl.get_property_value(mdl.prop(item_handle, "VDC"))
                        fcarr = mdl.get_property_value(mdl.prop(item_handle, "fcarr"))
                        dt = mdl.get_property_value(mdl.prop(item_handle, "dt"))
                        Ts = mdl.get_property_value(mdl.prop(item_handle, "Ts"))
                        Lf = mdl.get_property_value(mdl.prop(item_handle, "Lf"))
                        R0 = mdl.get_property_value(mdl.prop(item_handle, "R0"))
                        Cf = mdl.get_property_value(mdl.prop(item_handle, "Cf"))
                        Kp = mdl.get_property_value(mdl.prop(item_handle, "Kp"))
                        Ki = mdl.get_property_value(mdl.prop(item_handle, "Ki"))
                        # HEADER STOP
                        fcarr = mdl.get_property_value(mdl.prop(item_handle, "fcarr"))
                        Ts_db = 1/fcarr
                        Tslow = 0.1
                    ENDCODE
                }
            }
            [
                position = 6704, 8104
                size = 80, 136
            ]

            component Subsystem "3-ph PV Inverter" {
                layout = dynamic
                component Subsystem PLL {
                    layout = dynamic
                    component "core/Three phase PLL" "Three phase PLL1" {
                        enable_sin = "False"
                        enable_zero = "False"
                        power_form = "invariant"
                    }
                    [
                        position = 8072, 8688
                        size = 64, 128
                    ]

                    port f {
                        position = right:4
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8288, 8592
                    ]

                    port Vd {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8160, 8464
                    ]

                    port Vq {
                        position = right:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8232, 8504
                    ]

                    port wt {
                        position = right:5
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8296, 8736
                    ]

                    port B {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7936, 8688
                    ]

                    port A {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7936, 8640
                    ]

                    port C {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7936, 8736
                    ]

                    tag Goto35 {
                        value = "f"
                        scope = masked_subsystem
                        kind = sp
                        direction = in
                    }
                    [
                        position = 8376, 8688
                        hide_name = True
                        size = 0, 0
                    ]

                    junction Junction11 sp
                    [
                        position = 8224, 8688
                    ]

                    connect "Three phase PLL1.d_axis" Vd as Connection161
                    connect "Three phase PLL1.q_axis" Vq as Connection162
                    [
                        position = 0, 0
                        breakpoints = 8184, 8656; 8184, 8504
                    ]
                    connect Goto35 Junction11 as Connection163
                    connect Junction11 f as Connection164
                    [
                        position = 0, 0
                        breakpoints = 8224, 8672
                    ]
                    connect "Three phase PLL1.freq" Junction11 as Connection165
                    connect "Three phase PLL1.theta" wt as Connection166
                    connect B "Three phase PLL1.vb" as Connection167
                    connect C "Three phase PLL1.vc" as Connection168
                    connect A "Three phase PLL1.va" as Connection169
                }
                [
                    position = 7456, 8936
                    size = 64, 168
                ]

                component "core/Three Phase NPC Inverter" "Three Phase NPC Inverter1" {
                    carrier_freq = "fsw"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    fvd_def_method_g1 = "LUT"
                    fvd_def_method_g2 = "LUT"
                    fvd_def_method_g3 = "LUT"
                    ref_sig_min_max = "[-1, 1]"
                }
                [
                    position = 7760, 8136
                    size = 127, 256
                ]

                component pas_inductor L2 {
                    inductance = "L1"
                }
                [
                    position = 8016, 8136
                ]

                component pas_capacitor C1 {
                    capacitance = "C1"
                }
                [
                    position = 8344, 8392
                    rotation = right
                ]

                component pas_resistor R8 {
                    resistance = "Resr"
                }
                [
                    position = 8424, 8304
                    rotation = right
                ]

                component pas_resistor R0b {
                    resistance = "R0"
                }
                [
                    position = 8120, 8136
                ]

                component pas_resistor R0a {
                    resistance = "R0"
                }
                [
                    position = 8120, 8040
                ]

                component pas_inductor L1 {
                    inductance = "L1"
                }
                [
                    position = 8016, 8040
                ]

                component pas_capacitor C3 {
                    capacitance = "C1"
                }
                [
                    position = 8512, 8392
                    rotation = right
                ]

                component pas_inductor L3 {
                    inductance = "L1"
                }
                [
                    position = 8016, 8232
                ]

                component pas_resistor R7 {
                    resistance = "Resr"
                }
                [
                    position = 8344, 8304
                    rotation = right
                ]

                component pas_capacitor C2 {
                    capacitance = "C1"
                }
                [
                    position = 8424, 8392
                    rotation = right
                ]

                component pas_resistor R0c {
                    resistance = "R0"
                }
                [
                    position = 8120, 8232
                ]

                component pas_resistor R9 {
                    resistance = "Resr"
                }
                [
                    position = 8512, 8304
                    rotation = right
                ]

                component "core/Voltage Measurement" Vab {
                }
                [
                    position = 7880, 8080
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vdc {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 7520, 8088
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vbc1 {
                }
                [
                    position = 8576, 8184
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vab1 {
                }
                [
                    position = 8576, 8088
                    rotation = right
                    size = 64, 32
                ]

                component "core/Triple Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                }
                [
                    position = 8888, 8136
                    size = 64, 256
                ]

                component "core/Current Measurement" Iinv_in {
                }
                [
                    position = 7576, 8040
                    size = 64, 32
                ]

                component gen_terminator t {
                }
                [
                    position = 8448, 8768
                    scale = -1, 1
                ]

                component gen_terminator t1 {
                }
                [
                    position = 8464, 8960
                    scale = -1, 1
                ]

                component gen_probe iq {
                    addr = "8968"
                }
                [
                    position = 8376, 9024
                    scale = -1, 1
                ]

                component "core/Signal Controlled Voltage Source" Vdc2 {
                }
                [
                    position = 7264, 8168
                    rotation = right
                    size = 64, 32
                ]

                component gen_probe id {
                    addr = "8965"
                }
                [
                    position = 8376, 8968
                    scale = -1, 1
                ]

                component Subsystem Current_ref {
                    layout = dynamic
                    component gen_math_fnc "Mathematical function1" {
                        mathematical_fn = "sqrt"
                    }
                    [
                        position = 8096, 8264
                        scale = -1, 1
                    ]

                    component gen_product Product3 {
                    }
                    [
                        position = 8440, 8008
                        scale = -1, 1
                    ]

                    component gen_product Product1 {
                        signs = "*/"
                    }
                    [
                        position = 8120, 8080
                        scale = -1, 1
                    ]

                    component gen_product Product6 {
                    }
                    [
                        position = 8440, 8224
                        scale = -1, 1
                    ]

                    component gen_product Product2 {
                        signs = "*/"
                    }
                    [
                        position = 8120, 8168
                        scale = -1, 1
                    ]

                    component gen_product Product4 {
                    }
                    [
                        position = 8440, 8080
                        scale = -1, 1
                    ]

                    component gen_sum Sum4 {
                    }
                    [
                        position = 8232, 8160
                        scale = -1, 1
                    ]

                    component gen_sum Sum3 {
                        signs = "-+"
                    }
                    [
                        position = 8232, 8072
                        scale = -1, 1
                    ]

                    component gen_probe Et_sqr_res {
                    }
                    [
                        position = 8224, 8256
                    ]

                    component gen_product Product5 {
                    }
                    [
                        position = 8440, 8152
                        scale = -1, 1
                    ]

                    component Subsystem squared_Vt {
                        layout = dynamic
                        component gen_sum Sum3 {
                        }
                        [
                            position = 8104, 8192
                            scale = -1, 1
                        ]

                        component gen_product Product2 {
                        }
                        [
                            position = 8208, 8232
                            scale = -1, 1
                        ]

                        component gen_product Product1 {
                        }
                        [
                            position = 8208, 8160
                            scale = -1, 1
                        ]

                        port Ed {
                            label = "Ed"
                            position = right:1
                            kind = sp
                            direction =  out
                            sp_type {
                                default = auto
                                readonly = True
                            }
                        }
                        [
                            position = 8328, 8152
                            rotation = down
                        ]

                        port Eq {
                            label = "Eq"
                            position = right:3
                            kind = sp
                            direction =  out
                            sp_type {
                                default = auto
                                readonly = True
                            }
                        }
                        [
                            position = 8328, 8224
                            rotation = down
                        ]

                        port Et_p2 {
                            label = "Et^2"
                            position = left:2
                            kind = sp
                            direction =  in
                            sp_type {
                                default = inherit
                                readonly = True
                            }
                        }
                        [
                            position = 8032, 8192
                            rotation = down
                        ]

                        junction Junction136 sp
                        [
                            position = 8280, 8152
                        ]

                        junction Junction137 sp
                        [
                            position = 8280, 8224
                        ]

                        connect Junction136 Ed as Connection1
                        connect Junction136 Product1.in as Connection2
                        connect Junction137 Eq as Connection3
                        connect Product1.in1 Junction136 as Connection4
                        connect Product2.in Junction137 as Connection6
                        connect Product2.in1 Junction137 as Connection5
                        connect Sum3.out Et_p2 as Connection7
                        connect Sum3.in Product1.out as Connection8
                        connect Sum3.in1 Product2.out as Connection9
                    }
                    [
                        position = 8560, 8360
                        size = 48, 56
                    ]

                    port Xi_rd {
                        label = "Id_ref"
                        position = left:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7952, 8168
                        rotation = down
                    ]

                    port Xi_rq {
                        label = "Iq_ref"
                        position = left:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7952, 8080
                        rotation = down
                    ]

                    port P_ref {
                        label = "P_ref"
                        position = right:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8696, 8144
                        rotation = down
                    ]

                    port Q_ref {
                        label = "Q_ref"
                        position = right:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8696, 8216
                        rotation = down
                    ]

                    port Eq {
                        label = "Vq"
                        position = right:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8696, 8000
                        rotation = down
                    ]

                    port Ed {
                        label = "Vd"
                        position = right:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8696, 8072
                        rotation = down
                    ]

                    port Vt {
                        label = "Vt"
                        position = left:3
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7952, 8264
                        rotation = down
                    ]

                    junction Junction138 sp
                    [
                        position = 8160, 8176
                    ]

                    junction Junction139 sp
                    [
                        position = 8568, 8144
                    ]

                    junction Junction141 sp
                    [
                        position = 8560, 8216
                    ]

                    junction Junction142 sp
                    [
                        position = 8528, 8072
                    ]

                    junction Junction143 sp
                    [
                        position = 8544, 8000
                    ]

                    junction Junction145 sp
                    [
                        position = 8160, 8264
                    ]

                    junction Junction150 sp
                    [
                        position = 8656, 8000
                    ]

                    junction Junction151 sp
                    [
                        position = 8640, 8072
                    ]

                    junction Junction152 sp
                    [
                        position = 8160, 8328
                    ]

                    connect Junction138 Product1.in1 as Connection9
                    connect Junction139 P_ref as Connection53
                    [
                        position = 0, 0
                        breakpoints = 8568, 8144; 8600, 8144
                    ]
                    connect Junction141 Q_ref as Connection11
                    connect Junction142 Junction151 as Connection58
                    connect Junction143 Junction150 as Connection55
                    [
                        position = 0, 0
                        breakpoints = 8544, 8000; 8584, 8000
                    ]
                    connect Junction143 Product3.in as Connection13
                    connect Junction145 Junction138 as Connection15
                    connect Junction150 Eq as Connection56
                    connect Junction151 Ed as Connection59
                    connect "Mathematical function1.in" Junction145 as Connection21
                    connect Product1.in Sum3.out as Connection23
                    connect Product2.in1 Junction138 as Connection25
                    connect Product2.in Sum4.out as Connection26
                    connect Product3.in1 Junction139 as Connection27
                    connect Product3.out Sum3.in as Connection28
                    connect Product4.in1 Junction141 as Connection29
                    connect Product4.in Junction142 as Connection30
                    connect Product4.out Sum3.in1 as Connection31
                    connect Product5.in Junction139 as Connection32
                    connect Product5.in1 Junction142 as Connection33
                    connect Product5.out Sum4.in as Connection34
                    connect Product6.in Junction141 as Connection35
                    connect Product6.in1 Junction143 as Connection36
                    connect Product6.out Sum4.in1 as Connection37
                    connect Vt "Mathematical function1.out" as Connection41
                    connect squared_Vt.Eq Junction150 as Connection57
                    connect squared_Vt.Ed Junction151 as Connection60
                    connect Junction145 Junction152 as Connection70
                    [
                        position = 0, 0
                        breakpoints = 8160, 8264
                    ]
                    connect Junction152 Et_sqr_res.in as Connection71
                    [
                        position = 0, 0
                        breakpoints = 8184, 8328
                    ]
                    connect squared_Vt.Et_p2 Junction152 as Connection72
                    connect Xi_rq Product1.out as Connection73
                    connect Product2.out Xi_rd as Connection74
                }
                [
                    position = 8536, 8704
                    size = 80, 168
                ]

                component Subsystem "abc to dq" {
                    layout = dynamic
                    component "core/abc to dq" "abc to dq1" {
                        power_form = "invariant"
                    }
                    [
                        position = 7856, 8008
                        size = 48, 80
                    ]

                    port wt {
                        label = "wt"
                        position = right:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 8088
                    ]

                    port Ia {
                        label = "Ia"
                        position = right:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 7960
                    ]

                    port Ib {
                        label = "Ib"
                        position = right:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 8000
                    ]

                    port Ic {
                        label = "Ic"
                        position = right:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 8040
                    ]

                    port Id {
                        label = "Id"
                        position = left:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 7976
                    ]

                    port Iq {
                        label = "Iq"
                        position = left:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 8016
                    ]

                    port I0 {
                        label = "I0"
                        position = left:3
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 8064
                    ]

                    connect I0 "abc to dq1.zero_axis" as Connection1
                    connect Ia "abc to dq1.va" as Connection2
                    connect Ib "abc to dq1.vb" as Connection3
                    connect Ic "abc to dq1.vc" as Connection4
                    [
                        position = 0, 0
                        breakpoints = 7736, 8016; 7816, 8016
                    ]
                    connect "abc to dq1.d_axis" Id as Connection5
                    connect "abc to dq1.q_axis" Iq as Connection6
                    connect wt "abc to dq1.wt" as Connection7
                }
                [
                    position = 8544, 8904
                    size = 80, 160
                ]

                component Subsystem "Current controller dq" {
                    layout = dynamic
                    component gen_pid_controller "PID controller1" {
                        controller_type = "PI"
                        enb_anti_windup_out = "True"
                        enb_output_limit_out = "True"
                        ki = "Ki"
                        kp = "Kp"
                        show_reset = "rising"
                    }
                    [
                        position = 8184, 8072
                        scale = -1, 1
                    ]

                    component gen_product Product6 {
                    }
                    [
                        position = 8272, 7832
                        scale = -1, 1
                    ]

                    component gen_gain Gain7 {
                        gain = "2*3.14*L1"
                    }
                    [
                        position = 8432, 7824
                        scale = -1, 1
                    ]

                    component gen_product Product7 {
                        signs = "*/*"
                    }
                    [
                        position = 8016, 7856
                        scale = -1, 1
                    ]

                    component gen_sum Sum12 {
                    }
                    [
                        position = 7880, 8144
                        scale = -1, 1
                    ]

                    component gen_product Product5 {
                        signs = "*/*"
                    }
                    [
                        position = 8024, 8328
                        scale = -1, 1
                    ]

                    component gen_pid_controller "PID controller2" {
                        controller_type = "PI"
                        enb_anti_windup_out = "True"
                        enb_output_limit_out = "True"
                        ki = "Ki"
                        kp = "Kp"
                        show_reset = "rising"
                    }
                    [
                        position = 8184, 8168
                        scale = -1, 1
                    ]

                    component gen_gain Gain4 {
                        gain = "2*3.14*L1"
                    }
                    [
                        position = 8392, 8328
                        scale = -1, 1
                    ]

                    component gen_gain Gain5 {
                        gain = "0.5"
                    }
                    [
                        position = 8112, 8392
                        scale = -1, 1
                    ]

                    component gen_sum Sum13 {
                        signs = "-+"
                    }
                    [
                        position = 8128, 7840
                        scale = -1, 1
                    ]

                    component gen_sum Sum2 {
                        signs = "-+"
                    }
                    [
                        position = 8328, 8152
                        rotation = down
                    ]

                    component gen_sum Sum9 {
                    }
                    [
                        position = 7880, 8088
                        scale = -1, 1
                    ]

                    component gen_sum Sum10 {
                        signs = "++"
                    }
                    [
                        position = 8120, 8312
                        scale = -1, 1
                    ]

                    component gen_product Product1 {
                    }
                    [
                        position = 8280, 8320
                        scale = -1, 1
                    ]

                    component gen_sum Sum1 {
                        signs = "-+"
                    }
                    [
                        position = 8328, 8080
                        rotation = down
                    ]

                    component src_constant Constant1 {
                        execution_rate = "Ts"
                    }
                    [
                        position = 8008, 8448
                    ]

                    port Out4 {
                        label = "m_d"
                        position = left:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7808, 8088
                        rotation = down
                    ]

                    port Out5 {
                        label = "m_q"
                        position = left:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7808, 8144
                        rotation = down
                    ]

                    port Reset {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8184, 8000
                        rotation = down
                        scale = -1, 1
                    ]

                    port Id_ref {
                        position = right:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8072
                        rotation = down
                    ]

                    port Id {
                        position = right:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8112
                        rotation = down
                    ]

                    port Iq_ref {
                        position = right:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8160
                        rotation = down
                    ]

                    port Iq {
                        position = right:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8216
                        rotation = down
                    ]

                    port f {
                        position = right:5
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8312
                        rotation = down
                    ]

                    port VDC {
                        position = bottom:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8192, 8392
                        rotation = down
                    ]

                    port Vd {
                        position = bottom:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8216, 7904
                        rotation = down
                    ]

                    port Vq {
                        position = bottom:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8208, 8272
                        rotation = down
                    ]

                    tag Goto2 {
                        value = "Reset"
                        scope = local
                        kind = sp
                        direction = in
                    }
                    [
                        position = 8320, 8000
                        hide_name = True
                        size = 0, 0
                    ]

                    junction Junction158 sp
                    [
                        position = 8080, 8328
                    ]

                    junction Junction169 sp
                    [
                        position = 8240, 8000
                    ]

                    junction Junction170 sp
                    [
                        position = 8240, 8088
                    ]

                    junction Junction171 sp
                    [
                        position = 8064, 8344
                    ]

                    junction Junction174 sp
                    [
                        position = 8400, 8304
                    ]

                    junction Junction175 sp
                    [
                        position = 8448, 8160
                    ]

                    junction Junction176 sp
                    [
                        position = 8440, 8088
                    ]

                    connect Junction158 Gain5.out as Connection214
                    connect "PID controller1.in" Sum1.out as Connection46
                    connect "PID controller1.out" Sum9.in as Connection146
                    connect "PID controller2.in" Sum2.out as Connection48
                    connect Product1.in1 Gain4.out as Connection177
                    connect Product5.in1 Junction158 as Connection213
                    connect Product5.in Sum10.out as Connection171
                    connect Product6.in Gain7.out as Connection204
                    connect Product7.in1 Junction158 as Connection215
                    connect Product7.in Sum13.out as Connection228
                    connect Sum10.in1 Product1.out as Connection176
                    connect Sum12.out Out5 as Connection281
                    connect Sum12.in1 "PID controller2.out" as Connection195
                    [
                        position = 0, 0
                        breakpoints = 7920, 8168; 8144, 8168
                    ]
                    connect Sum13.in Product6.out as Connection229
                    connect Sum9.out Out4 as Connection279
                    connect Junction169 Reset as Connection288
                    connect "PID controller1.reset" Junction170 as Connection290
                    connect Junction170 Junction169 as Connection291
                    connect "PID controller2.reset" Junction170 as Connection292
                    connect Junction169 Goto2 as Connection293
                    [
                        position = 0, 0
                        breakpoints = 8240, 8000; 8240, 8000
                    ]
                    connect Product5.in2 Junction171 as Connection295
                    connect Junction171 Product7.in2 as Connection296
                    [
                        position = 0, 0
                        breakpoints = 8064, 8344; 8064, 8344; 8064, 8344
                    ]
                    connect Constant1.out Junction171 as Connection297
                    connect Id_ref Sum1.in1 as Connection298
                    connect Iq_ref Sum2.in1 as Connection303
                    [
                        position = 0, 0
                        breakpoints = 8544, 8144; 8368, 8144
                    ]
                    connect Product6.in1 Junction174 as Connection309
                    connect Junction174 Product1.in as Connection310
                    [
                        position = 0, 0
                        breakpoints = 8400, 8304
                    ]
                    connect f Junction174 as Connection311
                    connect VDC Gain5.in as Connection312
                    connect Vd Sum13.in1 as Connection313
                    connect Vq Sum10.in as Connection314
                    connect Sum2.in Junction175 as Connection316
                    connect Gain7.in Junction175 as Connection318
                    connect Junction175 Iq as Connection319
                    [
                        position = 0, 0
                        breakpoints = 8448, 8160; 8504, 8160
                    ]
                    connect Id Junction176 as Connection320
                    [
                        position = 0, 0
                        breakpoints = 8496, 8096; 8496, 8088
                    ]
                    connect Junction176 Sum1.in as Connection321
                    connect Gain4.in Junction176 as Connection322
                    connect Sum9.in1 Product7.out as Connection323
                    connect Product5.out Sum12.in as Connection324
                    [
                        position = 0, 0
                        breakpoints = 7936, 8328; 7936, 8136
                    ]
                }
                [
                    position = 8248, 8848
                    size = 112, 168
                ]

                component "core/SVPWM References Generator" "SVPWM References Generator2" {
                }
                [
                    position = 7976, 8800
                    hide_name = True
                    scale = -1, 1
                    size = 48, 64
                ]

                component gen_d_q2alpha_beta "dq to alpha beta2" {
                }
                [
                    position = 8072, 8808
                    hide_name = True
                    scale = -1, 1
                ]

                component src_constant Constant2 {
                    execution_rate = "Ts"
                    value = "VDC"
                }
                [
                    position = 7464, 8160
                    rotation = down
                    hide_name = True
                ]

                component "core/Edge Detection" "Edge Detection1" {
                }
                [
                    position = 8248, 8720
                    rotation = right
                    hide_name = True
                    size = 32, 32
                ]

                component gen_digital_probe connect {
                }
                [
                    position = 7360, 7832
                    rotation = left
                ]

                component gen_probe Vq {
                    addr = "8968"
                }
                [
                    position = 7616, 8896
                    rotation = down
                    scale = -1, 1
                ]

                component gen_probe Vd {
                    addr = "8965"
                }
                [
                    position = 7608, 8832
                    rotation = down
                    scale = -1, 1
                ]

                component gen_product Product1 {
                    signs = "/*"
                }
                [
                    position = 7384, 8168
                    rotation = down
                    hide_name = True
                ]

                component "core/Signal Controlled Voltage Source" Vdc1 {
                }
                [
                    position = 7264, 8080
                    rotation = right
                    size = 64, 32
                ]

                component src_constant Constant3 {
                    execution_rate = "Ts"
                    value = "2"
                }
                [
                    position = 7464, 8200
                    rotation = down
                    hide_name = True
                ]

                component "core/Voltage Measurement" Va {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8976, 8312
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vc {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 9088, 8416
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vb {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 9032, 8368
                    rotation = right
                    size = 64, 32
                ]

                component gen_probe f_meas {
                    addr = "8968"
                }
                [
                    position = 7616, 8976
                    rotation = down
                    scale = -1, 1
                ]

                component "core/Current Measurement" Ia {
                    execution_rate = "1/fsw"
                    sig_output = "True"
                }
                [
                    position = 8224, 8040
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    execution_rate = "1/fsw"
                    sig_output = "True"
                }
                [
                    position = 8224, 8136
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    execution_rate = "1/fsw"
                    sig_output = "True"
                }
                [
                    position = 8224, 8232
                    size = 64, 32
                ]

                component gen_c_function "PQ limiting with priority" {
                    global_variables = "real signQ;real signP;real Sref;"
                    init_fnc = "/*Begin code section*/
Sref = 0;
/*End code section*/"
                    input_terminals = "inherit Pref;inherit Qref;inherit Smax;"
                    input_terminals_dimensions = "inherit;inherit;inherit"
                    input_terminals_feedthrough = "True;True;True"
                    input_terminals_show_labels = "True;True;True"
                    output_fnc = "/*Begin code section*/
//-----------------------------------------------------------------------------
// Limit Power with P, Q, or pf priority
//-----------------------------------------------------------------------------
Sref = sqrt(Pref*Pref+Qref*Qref);

if (Qref>=0) signQ = 1;
else signQ = -1;
if (Pref>=0) signP = 1;
else signP = -1;

if (Sref <= Smax) {
    P = Pref;
    Q = Qref;
} else {
    // P priority
    if (fabs(Pref) > Smax) {
        P = signP*Smax;
        Q = 0;
    } else {
        P = Pref;
        Q = signQ*sqrt(Smax*Smax - Pref*Pref);
    }
}
/*End code section*/"
                    output_terminals = "inherit P;inherit Q;"
                    output_terminals_dimensions = "inherit;inherit"
                    output_terminals_feedthrough = "True;True"
                    output_terminals_show_labels = "True;True"
                }
                [
                    position = 7512, 8640
                    size = 104, 112
                ]

                component src_constant Constant4 {
                    execution_rate = "Ts"
                    value = "Sn"
                }
                [
                    position = 7392, 8720
                    hide_name = True
                ]

                component "core/Three Phase Core Coupling" "Core Coupling 1" {
                }
                [
                    position = 7936, 8136
                    size = 12, 256
                ]

                component "core/Rate Transition" "Rate Transition1" {
                    execution_rate = "Ts"
                }
                [
                    position = 8656, 8840
                    hide_name = True
                    scale = -1, 1
                    size = 32, 32
                ]

                component "core/Rate Transition" "Rate Transition2" {
                    execution_rate = "Ts"
                }
                [
                    position = 8656, 8888
                    hide_name = True
                    scale = -1, 1
                    size = 32, 32
                ]

                component "core/Rate Transition" "Rate Transition3" {
                    execution_rate = "Ts"
                }
                [
                    position = 8656, 8920
                    hide_name = True
                    scale = -1, 1
                    size = 32, 32
                ]

                port A {
                    position = right:1
                    kind = pe
                }
                [
                    position = 9192, 8040
                    rotation = down
                ]

                port B {
                    position = right:2
                    kind = pe
                }
                [
                    position = 9192, 8136
                    rotation = down
                ]

                port C {
                    position = right:3
                    kind = pe
                }
                [
                    position = 9192, 8232
                    rotation = down
                ]

                port Connect {
                    position = top:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7296, 7920
                    rotation = down
                    scale = -1, 1
                ]

                port N {
                    position = right:4
                    kind = pe
                }
                [
                    position = 9200, 8480
                    rotation = down
                ]

                port P_ref {
                    position = top:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7392, 8568
                ]

                port Q_ref {
                    position = top:3
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7392, 8640
                ]

                tag Goto12 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8288, 8000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto14 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8288, 8192
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto15 {
                    value = "Vdc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7640, 8088
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto13 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8288, 8096
                    hide_name = True
                    size = 60, 20
                ]

                tag From37 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7664, 7808
                    hide_name = True
                    size = 60, 20
                ]

                tag From38 {
                    value = "mc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7664, 7776
                    hide_name = True
                    size = 60, 20
                ]

                tag From36 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7664, 7832
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto34 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7880, 8768
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag Goto35 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7880, 8800
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag Goto36 {
                    value = "mc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7880, 8832
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag From67 {
                    value = "Vq"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8640, 8720
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From68 {
                    value = "Vd"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8640, 8768
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From75 {
                    value = "f"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8360, 8912
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From76 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8768, 8840
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From77 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8768, 8888
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From78 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8768, 8920
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From79 {
                    value = "wt"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8656, 8968
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From80 {
                    value = "Vdc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8216, 9016
                    rotation = left
                    hide_name = True
                    size = 60, 20
                ]

                tag From81 {
                    value = "Vd"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8280, 9016
                    rotation = left
                    hide_name = True
                    size = 60, 20
                ]

                tag From82 {
                    value = "Vq"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8248, 9016
                    rotation = left
                    hide_name = True
                    size = 60, 20
                ]

                tag From83 {
                    value = "Connect"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8832, 7936
                    hide_name = True
                    size = 60, 20
                ]

                tag From85 {
                    value = "wt"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8072, 8888
                    hide_name = True
                    size = 60, 20
                ]

                tag From86 {
                    value = "Connect"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8200, 8664
                    hide_name = True
                    size = 60, 20
                ]

                tag From39 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7336, 8872
                    hide_name = True
                    size = 60, 20
                ]

                tag From40 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7336, 8936
                    hide_name = True
                    size = 60, 20
                ]

                tag From41 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7336, 9000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto41 {
                    value = "Vd"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 8872
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto42 {
                    value = "Vq"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 8920
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto43 {
                    value = "f"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 8952
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto44 {
                    value = "wt"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 9000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 9184, 8416
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto1 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 9184, 8312
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto4 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 9184, 8368
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto45 {
                    value = "Connect"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 7872
                    hide_name = True
                    size = 60, 20
                ]

                tag From87 {
                    value = "Pref"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8640, 8640
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From88 {
                    value = "Qref"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8640, 8688
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto46 {
                    value = "Pref"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7632, 8608
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto47 {
                    value = "Qref"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7632, 8672
                    hide_name = True
                    size = 60, 20
                ]

                junction Junction65 pe
                [
                    position = 8576, 8136
                ]

                junction Junction70 pe
                [
                    position = 8424, 8472
                ]

                junction Junction121 pe
                [
                    position = 8344, 8040
                ]

                junction Junction123 pe
                [
                    position = 8424, 8136
                ]

                junction Junction125 pe
                [
                    position = 8512, 8232
                ]

                junction Junction191 sp
                [
                    position = 8432, 8880
                ]

                junction Junction199 sp
                [
                    position = 8416, 8848
                ]

                junction Junction200 sp
                [
                    position = 7504, 8872
                ]

                junction Junction201 sp
                [
                    position = 7504, 8920
                ]

                junction Junction205 pe
                [
                    position = 7520, 8232
                ]

                junction Junction206 pe
                [
                    position = 7520, 8040
                ]

                junction Junction207 sp
                [
                    position = 7336, 8168
                ]

                junction Junction78 pe
                [
                    position = 9032, 8480
                ]

                junction Junction198 pe
                [
                    position = 9088, 8480
                ]

                junction Junction208 pe
                [
                    position = 8976, 8040
                ]

                junction Junction209 pe
                [
                    position = 9032, 8136
                ]

                junction Junction210 pe
                [
                    position = 9088, 8232
                ]

                junction Junction211 sp
                [
                    position = 7504, 8952
                ]

                junction Junction212 sp
                [
                    position = 7360, 7920
                ]

                junction Junction213 sp
                [
                    position = 7432, 7920
                ]

                junction Junction214 pe
                [
                    position = 7880, 8136
                ]

                junction Junction215 pe
                [
                    position = 7880, 8040
                ]

                junction Junction216 pe
                [
                    position = 8576, 8224
                ]

                junction Junction217 pe
                [
                    position = 8584, 8136
                ]

                junction Junction218 pe
                [
                    position = 8576, 8040
                ]

                connect Iinv_in.n_node "Three Phase NPC Inverter1.DC+" as Connection879
                connect "Three Phase NPC Inverter1.InA" From36 as Connection899
                connect "Three Phase NPC Inverter1.InB" From37 as Connection900
                connect "Three Phase NPC Inverter1.InC" From38 as Connection901
                connect C1.p_node R7.n_node as Connection139
                connect C2.p_node R8.n_node as Connection144
                connect Goto12 Ia.out as Connection668
                connect Goto13 Ib.out as Connection800
                connect Goto14 Ic.out as Connection801
                connect Goto15 Vdc.out as Connection484
                connect Ia.n_node Junction121 as Connection802
                connect Ib.n_node Junction123 as Connection676
                connect Ic.p_node R0c.n_node as Connection803
                connect Junction121 R7.p_node as Connection809
                connect Junction123 R8.p_node as Connection677
                connect Junction125 Ic.n_node as Connection682
                connect Junction70 C2.n_node as Connection143
                connect L3.n_node R0c.p_node as Connection814
                connect R0a.n_node Ia.p_node as Connection817
                connect R0a.p_node L1.n_node as Connection818
                connect R0b.n_node Ib.p_node as Connection819
                connect R0b.p_node L2.n_node as Connection820
                connect R9.n_node C3.p_node as Connection145
                connect R9.p_node Junction125 as Connection681
                connect Vab1.n_node Junction65 as Connection119
                connect Vbc1.p_node Junction65 as Connection117
                connect Current_ref.Vt t.in as Connection297
                connect t1.in "abc to dq.I0" as Connection316
                connect "dq to alpha beta2.d" "Current controller dq.Out4" as Connection928
                connect "dq to alpha beta2.q" "Current controller dq.Out5" as Connection929
                connect "SVPWM References Generator2.alpha" "dq to alpha beta2.alpha" as Connection931
                connect "dq to alpha beta2.beta" "SVPWM References Generator2.beta" as Connection932
                connect Goto34 "SVPWM References Generator2.refA" as Connection933
                connect Goto35 "SVPWM References Generator2.refB" as Connection934
                connect Goto36 "SVPWM References Generator2.refC" as Connection935
                connect "Edge Detection1.Out1" "Current controller dq.Reset" as Connection954
                connect From67 Current_ref.Eq as Connection964
                [
                    position = 0, 0
                    breakpoints = 8592, 8720
                ]
                connect From68 Current_ref.Ed as Connection965
                connect From79 "abc to dq.wt" as Connection973
                connect From75 "Current controller dq.f" as Connection977
                connect iq.in Junction191 as Connection987
                connect Junction191 "abc to dq.Iq" as Connection988
                [
                    position = 0, 0
                    breakpoints = 8432, 8880; 8432, 8880; 8488, 8880
                ]
                connect "Current controller dq.Iq" Junction191 as Connection989
                connect From80 "Current controller dq.VDC" as Connection992
                connect From83 S1.ctrl_in as Connection998
                connect From85 "dq to alpha beta2.wt" as Connection1000
                connect From86 "Edge Detection1.In1" as Connection1001
                connect "Current controller dq.Id_ref" Current_ref.Xi_rd as Connection1030
                connect "Current controller dq.Iq_ref" Current_ref.Xi_rq as Connection1031
                [
                    position = 0, 0
                    breakpoints = 8384, 8816; 8384, 8640
                ]
                connect From82 "Current controller dq.Vq" as Connection1032
                connect From81 "Current controller dq.Vd" as Connection1033
                connect "abc to dq.Id" Junction199 as Connection1042
                [
                    position = 0, 0
                    breakpoints = 8488, 8848
                ]
                connect Junction199 id.in as Connection1043
                [
                    position = 0, 0
                    breakpoints = 8416, 8848; 8416, 8856
                ]
                connect "Current controller dq.Id" Junction199 as Connection1044
                connect C1.n_node Junction70 as Connection1063
                [
                    position = 0, 0
                    breakpoints = 8344, 8472; 8344, 8472
                ]
                connect C3.n_node Junction70 as Connection1065
                [
                    position = 0, 0
                    breakpoints = 8512, 8472
                ]
                connect From39 PLL.A as Connection1069
                [
                    position = 0, 0
                    breakpoints = 7416, 8872
                ]
                connect PLL.B From40 as Connection1070
                connect From41 PLL.C as Connection1071
                connect PLL.wt Goto44 as Connection1080
                connect Goto41 Junction200 as Connection1081
                connect Junction200 PLL.Vd as Connection1082
                connect Vd.in Junction200 as Connection1083
                connect PLL.Vq Junction201 as Connection1084
                connect Junction201 Goto42 as Connection1085
                connect Vq.in Junction201 as Connection1086
                connect "Three Phase NPC Inverter1.DC-" Junction205 as Connection1104
                connect Vdc.n_node Junction205 as Connection1106
                connect Junction205 Vdc2.n_node as Connection1112
                [
                    position = 0, 0
                    breakpoints = 7520, 8232; 7432, 8232
                ]
                connect Constant2.out Product1.in1 as Connection1113
                connect Vdc.p_node Junction206 as Connection1115
                connect Junction206 Iinv_in.p_node as Connection1116
                connect Vdc1.p_node Junction206 as Connection1117
                connect Vdc1.n_node Vdc2.p_node as Connection1118
                connect "Three Phase NPC Inverter1.DCn" Vdc2.p_node as Connection1119
                [
                    position = 0, 0
                    breakpoints = 7296, 8136; 7264, 8136
                ]
                connect Constant3.out Product1.in as Connection1120
                connect Product1.out Junction207 as Connection1121
                connect Junction207 Vdc2.in as Connection1122
                connect Vdc1.in Junction207 as Connection1123
                connect Goto1 Va.out as Connection367
                connect Goto4 Vb.out as Connection368
                connect Goto5 Vc.out as Connection369
                connect Vb.n_node Junction78 as Connection363
                connect Vc.n_node Junction198 as Connection1027
                connect Junction198 Junction78 as Connection1028
                connect N Junction198 as Connection1029
                connect Junction78 Va.n_node as Connection1064
                connect A Junction208 as Connection1127
                connect Junction208 S1.a_out as Connection1128
                connect Va.p_node Junction208 as Connection1129
                connect B Junction209 as Connection1130
                connect Junction209 S1.b_out as Connection1131
                connect Vb.p_node Junction209 as Connection1132
                connect C Junction210 as Connection1133
                connect Junction210 S1.c_out as Connection1134
                connect Vc.p_node Junction210 as Connection1135
                connect Goto43 Junction211 as Connection1136
                connect Junction211 PLL.f as Connection1137
                connect f_meas.in Junction211 as Connection1138
                connect connect.in Junction212 as Connection1144
                connect Junction212 Connect as Connection1145
                connect Goto45 Junction213 as Connection1151
                [
                    position = 0, 0
                    breakpoints = 7496, 7872
                ]
                connect Junction213 Junction212 as Connection1152
                [
                    position = 0, 0
                    breakpoints = 7432, 7920
                ]
                connect "Three Phase NPC Inverter1.En" Junction213 as Connection1153
                connect P_ref "PQ limiting with priority.Pref" as Connection1154
                connect Q_ref "PQ limiting with priority.Qref" as Connection1155
                connect From87 Current_ref.P_ref as Connection1156
                connect Current_ref.Q_ref From88 as Connection1157
                connect Goto47 "PQ limiting with priority.Q" as Connection1158
                connect "PQ limiting with priority.P" Goto46 as Connection1159
                connect Constant4.out "PQ limiting with priority.Smax" as Connection1160
                connect "Core Coupling 1.c_out" L3.p_node as Connection1184
                connect L2.p_node "Core Coupling 1.b_out" as Connection1185
                connect "Core Coupling 1.a_out" L1.p_node as Connection1186
                connect "Core Coupling 1.c_in" "Three Phase NPC Inverter1.C" as Connection1189
                connect "Three Phase NPC Inverter1.B" Junction214 as Connection1190
                connect Junction214 "Core Coupling 1.b_in" as Connection1191
                connect Vab.n_node Junction214 as Connection1192
                connect "Core Coupling 1.a_in" Junction215 as Connection1193
                connect Junction215 "Three Phase NPC Inverter1.A" as Connection1194
                connect Vab.p_node Junction215 as Connection1195
                connect Vbc1.n_node Junction216 as Connection1196
                connect Junction216 Junction125 as Connection1197
                [
                    position = 0, 0
                    breakpoints = 8576, 8232; 8576, 8232
                ]
                connect S1.c_in Junction216 as Connection1198
                connect Junction65 Junction217 as Connection1199
                connect Junction217 Junction123 as Connection1200
                [
                    position = 0, 0
                    breakpoints = 8576, 8136; 8584, 8136; 8576, 8136; 8576, 8136
                ]
                connect S1.b_in Junction217 as Connection1201
                connect Junction121 Junction218 as Connection1202
                [
                    position = 0, 0
                    breakpoints = 8344, 8040
                ]
                connect Junction218 Vab1.p_node as Connection1203
                [
                    position = 0, 0
                    breakpoints = 8576, 8040; 8576, 8040
                ]
                connect S1.a_in Junction218 as Connection1204
                connect From78 "Rate Transition3.in" as Connection1205
                connect "Rate Transition3.out" "abc to dq.Ic" as Connection1206
                connect "Rate Transition1.out" "abc to dq.Ia" as Connection1207
                connect "Rate Transition2.out" "abc to dq.Ib" as Connection1208
                connect "Rate Transition1.in" From76 as Connection1209
                connect From77 "Rate Transition2.in" as Connection1210

                Ki = "139.2"
                Kp = "0.0628"
                R0 = "0.1"
                Resr = "0.1"
                Ts = "1e-6"
                dt = "1e-6"

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Constant dc-voltage, 3-phase, current-controlled, 3-level NPC inverter.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component is a simplified model of a PV inverter with active and reactive power injection control. No MPPT system is present. The dc-link is considered to be a constant voltage source.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">The power flow is indirectly controlled via regulation of the inverter currents in the dq synchronous reference frame.   </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">I/O Description:</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- A, B, C, N: grid phase connection</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- Connect: signal command for connecting the inverter to the grid</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- P_ref: active power reference</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- Q_ref: reactive power reference</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Remark: P and Q will be limited to the rated apparent power (P has preference over Q). </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Parameters description:</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- General:</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Rated power: inverter rated power in VA </p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Dc Voltage: DC-link nominal voltage</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Carrier frequency: PWM carrier frequency / switching frequency</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Dead-time: inverter dead-time</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  - Execution rate: component execution rate </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- LC Filter: ac-side LC-filter component values</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">- PI: proportional and integral gains for direct and quadrature current controllers</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  </p></body></html>"

                    Sn {
                        label = "Rated power"
                        widget = edit
                        type = generic
                        default_value = "15000"
                        unit = "VA"
                        group = "General"
                    }

                    VDC {
                        label = "Dc voltage"
                        widget = edit
                        type = generic
                        default_value = "600"
                        unit = "V"
                        group = "General"
                    }

                    fsw {
                        label = "Carrier frequency"
                        widget = edit
                        type = generic
                        default_value = "20000"
                        unit = "Hz"
                        group = "General"
                    }

                    dt {
                        label = "Dead-time"
                        widget = edit
                        type = generic
                        default_value = "0.05e-6"
                        unit = "s"
                        group = "General"
                    }

                    Ts {
                        label = "Execution Rate"
                        widget = edit
                        type = generic
                        default_value = "Ts"
                        unit = "s"
                        group = "General"
                    }

                    L1 {
                        label = "Inductor"
                        widget = edit
                        type = generic
                        default_value = "3e-3"
                        unit = "H"
                        group = "LC Filter"
                    }

                    R0 {
                        label = "Inductor Series Resistance"
                        widget = edit
                        type = generic
                        default_value = "1e-4"
                        unit = "Ohm"
                        group = "LC Filter"
                    }

                    C1 {
                        label = "Capacitor"
                        widget = edit
                        type = generic
                        default_value = "20e-6"
                        unit = "F"
                        group = "LC Filter"
                    }

                    Resr {
                        label = "Capcitor ESR"
                        widget = edit
                        type = generic
                        default_value = "0.001"
                        unit = "Ohm"
                        group = "LC Filter"
                    }

                    Kp {
                        label = "Kp"
                        widget = edit
                        type = generic
                        default_value = "0.018"
                        group = "PI"
                    }

                    Ki {
                        label = "Ki"
                        widget = edit
                        type = generic
                        default_value = "1"
                        group = "PI"
                    }

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE
                }
            }
            [
                position = 7024, 8056
                size = 96, 232
            ]

            component Subsystem "3-ph PV Inverter (MPPT)" {
                layout = dynamic
                component Subsystem PLL {
                    layout = dynamic
                    component "core/Three phase PLL" "Three phase PLL1" {
                        enable_sin = "False"
                        enable_zero = "False"
                        power_form = "invariant"
                    }
                    [
                        position = 8072, 8688
                        size = 64, 128
                    ]

                    port f {
                        position = right:4
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8288, 8592
                    ]

                    port Vd {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8160, 8464
                    ]

                    port Vq {
                        position = right:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8232, 8504
                    ]

                    port wt {
                        position = right:5
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8296, 8736
                    ]

                    port B {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7936, 8688
                    ]

                    port A {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7936, 8640
                    ]

                    port C {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7936, 8736
                    ]

                    tag Goto35 {
                        value = "f"
                        scope = masked_subsystem
                        kind = sp
                        direction = in
                    }
                    [
                        position = 8376, 8688
                        hide_name = True
                        size = 0, 0
                    ]

                    junction Junction11 sp
                    [
                        position = 8224, 8688
                    ]

                    connect "Three phase PLL1.d_axis" Vd as Connection161
                    connect "Three phase PLL1.q_axis" Vq as Connection162
                    [
                        position = 0, 0
                        breakpoints = 8184, 8656; 8184, 8504
                    ]
                    connect Goto35 Junction11 as Connection163
                    connect Junction11 f as Connection164
                    [
                        position = 0, 0
                        breakpoints = 8224, 8672
                    ]
                    connect "Three phase PLL1.freq" Junction11 as Connection165
                    connect "Three phase PLL1.theta" wt as Connection166
                    connect B "Three phase PLL1.vb" as Connection167
                    connect C "Three phase PLL1.vc" as Connection168
                    connect A "Three phase PLL1.va" as Connection169
                }
                [
                    position = 7456, 8936
                    size = 64, 168
                ]

                component "core/Three Phase NPC Inverter" "Three Phase NPC Inverter1" {
                    carrier_freq = "fsw"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Ts"
                    fvd_def_method_g1 = "LUT"
                    fvd_def_method_g2 = "LUT"
                    fvd_def_method_g3 = "LUT"
                    ref_sig_min_max = "[-1, 1]"
                }
                [
                    position = 7832, 8136
                    size = 127, 256
                ]

                component pas_inductor L2 {
                    inductance = "L1"
                }
                [
                    position = 8016, 8136
                ]

                component pas_capacitor C1 {
                    capacitance = "C1"
                }
                [
                    position = 8344, 8392
                    rotation = right
                ]

                component pas_resistor R8 {
                    resistance = "Resr"
                }
                [
                    position = 8424, 8304
                    rotation = right
                ]

                component pas_resistor R0b {
                    resistance = "R0"
                }
                [
                    position = 8120, 8136
                ]

                component pas_resistor R0a {
                    resistance = "R0"
                }
                [
                    position = 8120, 8040
                ]

                component pas_inductor L1 {
                    inductance = "L1"
                }
                [
                    position = 8016, 8040
                ]

                component pas_capacitor C3 {
                    capacitance = "C1"
                }
                [
                    position = 8512, 8392
                    rotation = right
                ]

                component pas_inductor L3 {
                    inductance = "L1"
                }
                [
                    position = 8016, 8232
                ]

                component pas_resistor R7 {
                    resistance = "Resr"
                }
                [
                    position = 8344, 8304
                    rotation = right
                ]

                component pas_capacitor C2 {
                    capacitance = "C1"
                }
                [
                    position = 8424, 8392
                    rotation = right
                ]

                component pas_resistor R0c {
                    resistance = "R0"
                }
                [
                    position = 8120, 8232
                ]

                component pas_resistor R9 {
                    resistance = "Resr"
                }
                [
                    position = 8512, 8304
                    rotation = right
                ]

                component "core/Voltage Measurement" Vab {
                }
                [
                    position = 7944, 8088
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vdc {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 7592, 8088
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vbc1 {
                }
                [
                    position = 8576, 8184
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vab1 {
                }
                [
                    position = 8576, 8088
                    rotation = right
                    size = 64, 32
                ]

                component "core/Triple Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                }
                [
                    position = 8688, 8136
                    size = 64, 256
                ]

                component "core/Current Measurement" Iinv_in {
                }
                [
                    position = 7648, 8040
                    size = 64, 32
                ]

                component gen_probe pf {
                }
                [
                    position = 8768, 7872
                    rotation = down
                ]

                component gen_probe Q {
                }
                [
                    position = 8768, 7744
                    rotation = down
                ]

                component gen_probe S {
                }
                [
                    position = 8768, 7808
                    rotation = down
                ]

                component gen_probe P {
                }
                [
                    position = 8768, 7680
                    rotation = down
                ]

                component gen_terminator t1 {
                }
                [
                    position = 8464, 8960
                    scale = -1, 1
                ]

                component gen_probe iq {
                    addr = "8968"
                }
                [
                    position = 8376, 9024
                    scale = -1, 1
                ]

                component gen_probe id {
                    addr = "8965"
                }
                [
                    position = 8376, 8968
                    scale = -1, 1
                ]

                component Subsystem S_meas {
                    layout = dynamic
                    component gen_terminator Termination1 {
                    }
                    [
                        position = 8080, 8136
                        rotation = down
                    ]

                    component gen_PQ_transform "Power Meter1" {
                    }
                    [
                        position = 8256, 8224
                        scale = -1, 1
                    ]

                    component gen_terminator Termination2 {
                    }
                    [
                        position = 8160, 8136
                        rotation = down
                    ]

                    port Va {
                        label = "Va"
                        position = right:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8320, 8112
                        rotation = down
                    ]

                    port Vb {
                        label = "Vb"
                        position = right:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8368, 8144
                        rotation = down
                    ]

                    port Vc {
                        label = "Vc"
                        position = right:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8416, 8168
                        rotation = down
                    ]

                    port Ia {
                        label = "Ia"
                        position = right:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8544, 8232
                        rotation = down
                    ]

                    port Ib {
                        label = "Ib"
                        position = right:5
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8544, 8304
                        rotation = down
                    ]

                    port Ic {
                        label = "Ic"
                        position = right:6
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8512, 8360
                        rotation = down
                    ]

                    port P {
                        label = "P"
                        position = left:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7992, 8168
                        rotation = down
                    ]

                    port Q {
                        label = "Q"
                        position = left:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8032, 8232
                        rotation = down
                    ]

                    port S {
                        label = "S"
                        position = left:3
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8096, 8272
                        rotation = down
                    ]

                    port pf {
                        label = "pf"
                        position = left:4
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8128, 8336
                        rotation = down
                    ]

                    connect P "Power Meter1.Pdc" as Connection1
                    connect "Power Meter1.ia" Ia as Connection2
                    connect "Power Meter1.ib" Ib as Connection3
                    connect "Power Meter1.ic" Ic as Connection4
                    connect "Power Meter1.Qdc" Q as Connection5
                    connect "Power Meter1.apparent" S as Connection6
                    connect "Power Meter1.va" Va as Connection7
                    connect "Power Meter1.vb" Vb as Connection8
                    connect "Power Meter1.vc" Vc as Connection9
                    connect "Power Meter1.k_factor" pf as Connection10
                    connect Termination1.in "Power Meter1.Qac" as Connection11
                    connect Termination2.in "Power Meter1.Pac" as Connection12
                }
                [
                    position = 8896, 7776
                    size = 96, 216
                ]

                component Subsystem "abc to dq" {
                    layout = dynamic
                    component "core/abc to dq" "abc to dq1" {
                        execution_rate = "Ts"
                        power_form = "invariant"
                    }
                    [
                        position = 7856, 8008
                        size = 48, 80
                    ]

                    port wt {
                        label = "wt"
                        position = right:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 8088
                    ]

                    port Ia {
                        label = "Ia"
                        position = right:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 7960
                    ]

                    port Ib {
                        label = "Ib"
                        position = right:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 8000
                    ]

                    port Ic {
                        label = "Ic"
                        position = right:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7704, 8040
                    ]

                    port Id {
                        label = "Id"
                        position = left:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 7976
                    ]

                    port Iq {
                        label = "Iq"
                        position = left:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 8016
                    ]

                    port I0 {
                        label = "I0"
                        position = left:3
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 8064
                    ]

                    connect I0 "abc to dq1.zero_axis" as Connection1
                    connect Ia "abc to dq1.va" as Connection2
                    connect Ib "abc to dq1.vb" as Connection3
                    connect Ic "abc to dq1.vc" as Connection4
                    [
                        position = 0, 0
                        breakpoints = 7736, 8016; 7816, 8016
                    ]
                    connect "abc to dq1.d_axis" Id as Connection5
                    connect "abc to dq1.q_axis" Iq as Connection6
                    connect wt "abc to dq1.wt" as Connection7
                }
                [
                    position = 8544, 8904
                    size = 80, 160
                ]

                component Subsystem "Current controller dq" {
                    layout = dynamic
                    component gen_pid_controller "PID controller1" {
                        controller_type = "PI"
                        enb_anti_windup_out = "True"
                        enb_output_limit_out = "True"
                        ki = "Ki"
                        kp = "Kp"
                        show_reset = "rising"
                    }
                    [
                        position = 8184, 8072
                        scale = -1, 1
                    ]

                    component gen_product Product6 {
                    }
                    [
                        position = 8272, 7832
                        scale = -1, 1
                    ]

                    component gen_gain Gain7 {
                        gain = "2*3.14*L1"
                    }
                    [
                        position = 8432, 7824
                        scale = -1, 1
                    ]

                    component gen_product Product7 {
                        signs = "*/*"
                    }
                    [
                        position = 8016, 7856
                        scale = -1, 1
                    ]

                    component gen_sum Sum12 {
                    }
                    [
                        position = 7880, 8144
                        scale = -1, 1
                    ]

                    component gen_product Product5 {
                        signs = "*/*"
                    }
                    [
                        position = 8024, 8328
                        scale = -1, 1
                    ]

                    component gen_pid_controller "PID controller2" {
                        controller_type = "PI"
                        enb_anti_windup_out = "True"
                        enb_output_limit_out = "True"
                        ki = "Ki"
                        kp = "Kp"
                        show_reset = "rising"
                    }
                    [
                        position = 8184, 8168
                        scale = -1, 1
                    ]

                    component gen_gain Gain4 {
                        gain = "2*3.14*L1"
                    }
                    [
                        position = 8392, 8328
                        scale = -1, 1
                    ]

                    component gen_gain Gain5 {
                        gain = "0.5"
                    }
                    [
                        position = 8112, 8392
                        scale = -1, 1
                    ]

                    component gen_sum Sum13 {
                        signs = "-+"
                    }
                    [
                        position = 8128, 7840
                        scale = -1, 1
                    ]

                    component gen_sum Sum2 {
                        signs = "-+"
                    }
                    [
                        position = 8328, 8152
                        rotation = down
                    ]

                    component gen_sum Sum9 {
                    }
                    [
                        position = 7880, 8088
                        scale = -1, 1
                    ]

                    component gen_sum Sum10 {
                        signs = "++"
                    }
                    [
                        position = 8120, 8312
                        scale = -1, 1
                    ]

                    component gen_product Product1 {
                    }
                    [
                        position = 8280, 8320
                        scale = -1, 1
                    ]

                    component gen_sum Sum1 {
                        signs = "-+"
                    }
                    [
                        position = 8328, 8080
                        rotation = down
                    ]

                    component src_constant Constant1 {
                        execution_rate = "Ts"
                    }
                    [
                        position = 8008, 8448
                    ]

                    port Out4 {
                        label = "m_d"
                        position = left:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7808, 8088
                        rotation = down
                    ]

                    port Out5 {
                        label = "m_q"
                        position = left:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 7808, 8144
                        rotation = down
                    ]

                    port Reset {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8184, 8000
                        rotation = down
                        scale = -1, 1
                    ]

                    port Id_ref {
                        position = right:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8072
                        rotation = down
                    ]

                    port Id {
                        position = right:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8112
                        rotation = down
                    ]

                    port Iq_ref {
                        position = right:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8160
                        rotation = down
                    ]

                    port Iq {
                        position = right:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8216
                        rotation = down
                    ]

                    port f {
                        position = right:5
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8576, 8312
                        rotation = down
                    ]

                    port VDC {
                        position = bottom:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8192, 8392
                        rotation = down
                    ]

                    port Vd {
                        position = bottom:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8216, 7904
                        rotation = down
                    ]

                    port Vq {
                        position = bottom:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8208, 8272
                        rotation = down
                    ]

                    tag Goto2 {
                        value = "Reset"
                        scope = local
                        kind = sp
                        direction = in
                    }
                    [
                        position = 8320, 8000
                        hide_name = True
                        size = 60, 20
                    ]

                    junction Junction158 sp
                    [
                        position = 8080, 8328
                    ]

                    junction Junction169 sp
                    [
                        position = 8240, 8000
                    ]

                    junction Junction170 sp
                    [
                        position = 8240, 8088
                    ]

                    junction Junction171 sp
                    [
                        position = 8064, 8344
                    ]

                    junction Junction174 sp
                    [
                        position = 8400, 8304
                    ]

                    junction Junction175 sp
                    [
                        position = 8448, 8160
                    ]

                    junction Junction176 sp
                    [
                        position = 8440, 8088
                    ]

                    connect Junction158 Gain5.out as Connection214
                    connect "PID controller1.in" Sum1.out as Connection46
                    connect "PID controller1.out" Sum9.in as Connection146
                    connect "PID controller2.in" Sum2.out as Connection48
                    connect Product1.in1 Gain4.out as Connection177
                    connect Product5.in1 Junction158 as Connection213
                    connect Product5.in Sum10.out as Connection171
                    connect Product6.in Gain7.out as Connection204
                    connect Product7.in1 Junction158 as Connection215
                    connect Product7.in Sum13.out as Connection228
                    connect Sum10.in1 Product1.out as Connection176
                    connect Sum12.out Out5 as Connection281
                    connect Sum12.in1 "PID controller2.out" as Connection195
                    [
                        position = 0, 0
                        breakpoints = 7920, 8168; 8144, 8168
                    ]
                    connect Sum13.in Product6.out as Connection229
                    connect Sum9.out Out4 as Connection279
                    connect Junction169 Reset as Connection288
                    connect "PID controller1.reset" Junction170 as Connection290
                    connect Junction170 Junction169 as Connection291
                    connect "PID controller2.reset" Junction170 as Connection292
                    connect Junction169 Goto2 as Connection293
                    [
                        position = 0, 0
                        breakpoints = 8240, 8000; 8240, 8000
                    ]
                    connect Product5.in2 Junction171 as Connection295
                    connect Junction171 Product7.in2 as Connection296
                    [
                        position = 0, 0
                        breakpoints = 8064, 8344; 8064, 8344; 8064, 8344
                    ]
                    connect Constant1.out Junction171 as Connection297
                    connect Id_ref Sum1.in1 as Connection298
                    connect Iq_ref Sum2.in1 as Connection303
                    [
                        position = 0, 0
                        breakpoints = 8544, 8144; 8368, 8144
                    ]
                    connect Product6.in1 Junction174 as Connection309
                    connect Junction174 Product1.in as Connection310
                    [
                        position = 0, 0
                        breakpoints = 8400, 8304
                    ]
                    connect f Junction174 as Connection311
                    connect VDC Gain5.in as Connection312
                    connect Vd Sum13.in1 as Connection313
                    connect Vq Sum10.in as Connection314
                    connect Sum2.in Junction175 as Connection316
                    connect Gain7.in Junction175 as Connection318
                    connect Junction175 Iq as Connection319
                    [
                        position = 0, 0
                        breakpoints = 8448, 8160; 8504, 8160
                    ]
                    connect Id Junction176 as Connection320
                    [
                        position = 0, 0
                        breakpoints = 8496, 8096; 8496, 8088
                    ]
                    connect Junction176 Sum1.in as Connection321
                    connect Gain4.in Junction176 as Connection322
                    connect Sum9.in1 Product7.out as Connection323
                    connect Product5.out Sum12.in as Connection324
                    [
                        position = 0, 0
                        breakpoints = 7936, 8328; 7936, 8136
                    ]
                }
                [
                    position = 8144, 8848
                    size = 112, 168
                ]

                component "core/SVPWM References Generator" "SVPWM References Generator2" {
                }
                [
                    position = 7872, 8800
                    hide_name = True
                    scale = -1, 1
                    size = 48, 64
                ]

                component gen_d_q2alpha_beta "dq to alpha beta2" {
                }
                [
                    position = 7968, 8808
                    hide_name = True
                    scale = -1, 1
                ]

                component "core/Edge Detection" "Edge Detection1" {
                }
                [
                    position = 8144, 8720
                    rotation = right
                    hide_name = True
                    size = 32, 32
                ]

                component gen_digital_probe connect {
                }
                [
                    position = 7040, 7800
                    rotation = left
                ]

                component gen_probe Vq {
                    addr = "8968"
                }
                [
                    position = 7616, 8896
                    rotation = down
                    scale = -1, 1
                ]

                component gen_probe Vd {
                    addr = "8965"
                }
                [
                    position = 7608, 8832
                    rotation = down
                    scale = -1, 1
                ]

                component "core/Voltage Measurement" Va {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8776, 8312
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vc {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8888, 8416
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vb {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8832, 8368
                    rotation = right
                    size = 64, 32
                ]

                component gen_probe f_meas {
                    addr = "8968"
                }
                [
                    position = 7616, 8976
                    rotation = down
                    scale = -1, 1
                ]

                component "core/Current Measurement" Ia {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8224, 8040
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8224, 8136
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8224, 8232
                    size = 64, 32
                ]

                component pas_capacitor C4 {
                    capacitance = "Cdc"
                }
                [
                    position = 7488, 8088
                    rotation = right
                ]

                component pas_capacitor C5 {
                    capacitance = "Cdc"
                }
                [
                    position = 7488, 8184
                    rotation = right
                ]

                component gen_sum Sum1 {
                    signs = "-+"
                }
                [
                    position = 8528, 8752
                    rotation = down
                    hide_name = True
                    scale = 1, -1
                ]

                component src_constant Constant5 {
                    execution_rate = "Ts"
                    value = "0"
                }
                [
                    position = 8352, 8816
                    rotation = down
                    hide_name = True
                ]

                component src_constant Constant6 {
                    execution_rate = "Ts"
                    value = "VDC"
                }
                [
                    position = 8776, 8696
                    rotation = down
                    hide_name = True
                ]

                component gen_sum Sum2 {
                    execution_rate = "Ts"
                    signs = "+-"
                }
                [
                    position = 7136, 8536
                    hide_name = True
                ]

                component gen_probe Vpv_ref {
                }
                [
                    position = 7008, 8632
                    rotation = right
                ]

                component gen_probe duty {
                }
                [
                    position = 7304, 8608
                    rotation = right
                ]

                component "core/Rate Transition" "Rate Transition4" {
                    execution_rate = "Ts"
                }
                [
                    position = 7048, 8544
                    hide_name = True
                    size = 32, 32
                ]

                component "core/Rate Transition" "Rate Transition5" {
                    execution_rate = "Tmppt"
                }
                [
                    position = 6912, 8456
                    rotation = right
                    hide_name = True
                    size = 32, 32
                ]

                component "core/Boost" Boost1 {
                    carrier_freq = "fsw"
                    ctrl_src = "Internal modulator"
                    execution_rate = "Ts"
                    fvd_def_method = "LUT"
                    ref_sig_min_max = "[0, 1.0]"
                }
                [
                    position = 7304, 8136
                    size = 128, 256
                ]

                component pas_inductor Lboost {
                    inductance = "Lboost"
                }
                [
                    position = 7152, 8040
                ]

                component "core/Voltage Measurement" Vpv {
                    execution_rate = "Tmppt"
                    sig_output = "True"
                }
                [
                    position = 6784, 8144
                    rotation = right
                    size = 64, 32
                ]

                component "core/Current Measurement" Ipv {
                    execution_rate = "Tmppt"
                    sig_output = "True"
                }
                [
                    position = 6832, 8040
                    size = 64, 32
                ]

                component pas_capacitor Cin {
                    capacitance = "Cin"
                }
                [
                    position = 7064, 8144
                    rotation = right
                ]

                component Subsystem MPPT {
                    layout = dynamic
                    component gen_c_function "C function1" {
                        global_variables = "real vpv_old;real ppv_old;real dppv;"
                        init_fnc = "/*Begin code section*/
v_ref = vref_init;
vpv_old = vref_init;
ppv_old = 0;
/*End code section*/"
                        input_terminals = "inherit vpv;inherit iL;real enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True"
                        input_terminals_show_labels = "False;False;False"
                        output_fnc = "/*Begin code section*/
if (enable) {
    ppv = vpv*iL;
    dppv = ppv - ppv_old;
    if (dppv>0) {
        if (vpv>vpv_old) {
            v_ref += step;
        } else {
            v_ref -= step;
        }
    } else {
        if (vpv<vpv_old) {
            v_ref += step;
        } else {
            v_ref -= step;
        }
    }
    ppv_old = ppv;
    vpv_old = vpv;
    
} else {
    v_ref = vref_init;
    vpv_old = vref_init;
    ppv_old = 0;
}
/*End code section*/"
                        output_terminals = "real v_ref;inherit ppv;"
                        output_terminals_dimensions = "inherit;inherit"
                        output_terminals_feedthrough = "True;True"
                        output_terminals_show_labels = "False;False"
                        parameters = "real step;real vref_init;"
                    }
                    [
                        position = 8128, 8128
                        hide_name = True
                        size = 48, 64
                    ]

                    component gen_probe Ppv {
                    }
                    [
                        position = 8224, 8184
                    ]

                    port vpv {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7944, 8072
                    ]

                    port v_ref {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8232, 8112
                    ]

                    port Enable {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7944, 8192
                    ]

                    port ipv {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7944, 8128
                    ]

                    connect Enable "C function1.enable" as Connection18
                    connect v_ref "C function1.v_ref" as Connection19
                    connect Ppv.in "C function1.ppv" as Connection25
                    connect vpv "C function1.vpv" as Connection23
                    [
                        position = 0, 0
                        breakpoints = 8048, 8112
                    ]
                    connect ipv "C function1.iL" as Connection24

                    step = "vpv_step"
                    vref_init = "vpv_init"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Fixed step MPPT algorithm.</p></body></html>"

                        step {
                            label = "Voltage step"
                            widget = edit
                            type = generic
                            default_value = "10"
                            unit = "dc volts"
                        }

                        vref_init {
                            label = "Initial voltage"
                            widget = edit
                            type = generic
                            default_value = "700"
                            unit = "dc volts"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 6912, 8544
                    size = 112, 88
                ]

                component "core/Voltage Measurement" Vpv_hf {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 6984, 8144
                    rotation = right
                    scale = -1, 1
                    size = 64, 32
                ]

                component Subsystem "PI with Anti-windup" {
                    layout = dynamic
                    component gen_integrator Integrator1 {
                        show_reset = "rising"
                    }
                    [
                        position = 8168, 8192
                        hide_name = True
                    ]

                    component gen_gain Gain3 {
                        gain = "kp_boost"
                    }
                    [
                        position = 8112, 8096
                        hide_name = True
                    ]

                    component gen_gain Gain4 {
                        gain = "ki_boost"
                    }
                    [
                        position = 8096, 8192
                        hide_name = True
                    ]

                    component gen_sum Sum2 {
                    }
                    [
                        position = 8264, 8192
                        hide_name = True
                    ]

                    component gen_limiter Limit1 {
                        lower_limit = "0"
                        upper_limit = "0.98"
                    }
                    [
                        position = 8344, 8192
                        hide_name = True
                    ]

                    component gen_sum Sum3 {
                        signs = "-+"
                    }
                    [
                        position = 8240, 8288
                        rotation = down
                        hide_name = True
                    ]

                    component gen_sum Sum4 {
                        signs = "+-"
                    }
                    [
                        position = 8040, 8192
                        hide_name = True
                    ]

                    port Reset {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8088, 8248
                    ]

                    port In {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7912, 8184
                    ]

                    port Out {
                        position = auto:auto
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8456, 8192
                    ]

                    junction Junction27 sp
                    [
                        position = 7992, 8184
                    ]

                    junction Junction28 sp
                    [
                        position = 8376, 8192
                    ]

                    junction Junction26 sp
                    [
                        position = 8312, 8192
                    ]

                    connect Integrator1.reset Reset as Connection144
                    connect Sum4.in Junction27 as Connection145
                    connect Junction27 Gain3.in as Connection146
                    connect In Junction27 as Connection147
                    connect Sum3.in Junction28 as Connection148
                    connect Junction28 Limit1.out as Connection149
                    connect Out Junction28 as Connection150
                    connect Gain4.out Integrator1.in as Connection133
                    connect Sum2.in1 Integrator1.out as Connection134
                    connect Sum2.in Gain3.out as Connection135
                    connect Limit1.in Junction26 as Connection137
                    connect Junction26 Sum2.out as Connection138
                    connect Sum3.in1 Junction26 as Connection139
                    connect Sum4.out Gain4.in as Connection141
                    connect Sum3.out Sum4.in1 as Connection142
                }
                [
                    position = 7232, 8536
                    size = 80, 48
                ]

                component gen_product Product1 {
                }
                [
                    position = 8616, 8704
                    rotation = down
                    hide_name = True
                ]

                component gen_product Product2 {
                }
                [
                    position = 8616, 8768
                    rotation = down
                    hide_name = True
                ]

                component "core/Current Measurement" Ia1 {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8992, 8040
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib1 {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8992, 8136
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic1 {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 8992, 8232
                    size = 64, 32
                ]

                component gen_probe id_ref {
                    addr = "8965"
                }
                [
                    position = 8312, 8696
                    scale = -1, 1
                ]

                component Subsystem "PI with Anti-windup1" {
                    layout = dynamic
                    component gen_integrator Integrator1 {
                        show_reset = "rising"
                    }
                    [
                        position = 8168, 8200
                        hide_name = True
                    ]

                    component gen_gain Gain3 {
                        gain = "kp_dc"
                    }
                    [
                        position = 8112, 8096
                        hide_name = True
                    ]

                    component gen_gain Gain4 {
                        gain = "ki_dc"
                    }
                    [
                        position = 8096, 8192
                        hide_name = True
                    ]

                    component gen_sum Sum2 {
                    }
                    [
                        position = 8264, 8192
                        hide_name = True
                    ]

                    component gen_limiter Limit1 {
                        lower_limit = "0"
                    }
                    [
                        position = 8376, 8192
                        hide_name = True
                    ]

                    port Reset {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8088, 8248
                    ]

                    port In {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7912, 8184
                    ]

                    port Out {
                        position = auto:auto
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8456, 8192
                    ]

                    junction Junction1 sp
                    [
                        position = 7992, 8184
                    ]

                    connect Integrator1.reset Reset as Connection144
                    connect Gain4.out Integrator1.in as Connection133
                    connect Sum2.in1 Integrator1.out as Connection134
                    connect Sum2.in Gain3.out as Connection135
                    connect Limit1.out Out as Connection156
                    connect Sum2.out Limit1.in as Connection161
                    [
                        position = 0, 0
                        breakpoints = 8312, 8192
                    ]
                    connect Gain3.in Junction1 as Connection162
                    [
                        position = 0, 0
                        breakpoints = 7992, 8096
                    ]
                    connect Junction1 In as Connection163
                    [
                        position = 0, 0
                        breakpoints = 7992, 8184; 7992, 8184
                    ]
                    connect Gain4.in Junction1 as Connection164
                }
                [
                    position = 8432, 8752
                    scale = -1, 1
                    size = 80, 48
                ]

                component gen_probe ia_filt {
                    addr = "8965"
                }
                [
                    position = 8560, 9048
                    scale = -1, 1
                ]

                component "core/Single Phase Core Coupling" "Core Coupling 1" {
                }
                [
                    position = 7424, 8136
                    scale = -1, 1
                    size = 12, 256
                ]

                port A {
                    position = right:1
                    kind = pe
                }
                [
                    position = 9168, 8040
                    rotation = down
                ]

                port B {
                    position = right:2
                    kind = pe
                }
                [
                    position = 9168, 8136
                    rotation = down
                ]

                port C {
                    position = right:3
                    kind = pe
                }
                [
                    position = 9168, 8232
                    rotation = down
                ]

                port Connect {
                    position = top:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 6976, 7888
                    rotation = down
                    scale = -1, 1
                ]

                port N {
                    position = right:4
                    kind = pe
                }
                [
                    position = 9000, 8480
                    rotation = down
                ]

                port dc+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 6720, 8040
                ]

                port dc- {
                    position = left:2
                    kind = pe
                }
                [
                    position = 6720, 8232
                ]

                tag Goto12 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8288, 8000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto14 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8288, 8192
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto15 {
                    value = "Vdc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7712, 8088
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto13 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8288, 8096
                    hide_name = True
                    size = 60, 20
                ]

                tag From37 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7736, 7808
                    hide_name = True
                    size = 60, 20
                ]

                tag From38 {
                    value = "mc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7736, 7784
                    hide_name = True
                    size = 60, 20
                ]

                tag From36 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7736, 7832
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto34 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7776, 8768
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag Goto35 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7776, 8800
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag Goto36 {
                    value = "mc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7776, 8832
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag From69 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 9056, 7696
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From70 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 9056, 7728
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From71 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 9056, 7760
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From75 {
                    value = "f"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8360, 8912
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From76 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8720, 8840
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From77 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8720, 8888
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From78 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8720, 8920
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From79 {
                    value = "wt"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8656, 8968
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From80 {
                    value = "Vdc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8112, 9016
                    rotation = left
                    hide_name = True
                    size = 60, 20
                ]

                tag From81 {
                    value = "Vd"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8176, 9016
                    rotation = left
                    hide_name = True
                    size = 60, 20
                ]

                tag From82 {
                    value = "Vq"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8144, 9016
                    rotation = left
                    hide_name = True
                    size = 60, 20
                ]

                tag From85 {
                    value = "wt"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7968, 8888
                    hide_name = True
                    size = 60, 20
                ]

                tag From86 {
                    value = "connect"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8192, 8624
                    hide_name = True
                    size = 60, 20
                ]

                tag From39 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7360, 8872
                    hide_name = True
                    size = 60, 20
                ]

                tag From40 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7360, 8936
                    hide_name = True
                    size = 60, 20
                ]

                tag From41 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7360, 9000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto41 {
                    value = "Vd"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 8872
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto42 {
                    value = "Vq"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 8920
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto43 {
                    value = "f"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 8952
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto44 {
                    value = "wt"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7552, 9000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Vc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8984, 8416
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto1 {
                    value = "Va"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8984, 8312
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto4 {
                    value = "Vb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8984, 8368
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto45 {
                    value = "connect"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7184, 7832
                    hide_name = True
                    size = 60, 20
                ]

                tag From95 {
                    value = "connect"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 6768, 8408
                    hide_name = True
                    size = 60, 20
                ]

                tag From97 {
                    value = "Vdc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8736, 8760
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From98 {
                    value = "Vpv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 6776, 8520
                    hide_name = True
                    size = 60, 20
                ]

                tag From99 {
                    value = "Ipv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 6776, 8568
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto50 {
                    value = "duty"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7376, 8536
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto48 {
                    value = "Vpv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 6864, 8192
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto49 {
                    value = "Ipv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 6880, 7992
                    hide_name = True
                    size = 60, 20
                ]

                tag From100 {
                    value = "duty"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7208, 7952
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto51 {
                    value = "Vpv_hf"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 6888, 8144
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From101 {
                    value = "Vpv_hf"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7032, 8504
                    hide_name = True
                    size = 60, 20
                ]

                tag From102 {
                    value = "connect"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8624, 7976
                    hide_name = True
                    size = 60, 20
                ]

                junction Junction170 pe
                [
                    position = 7944, 8040
                ]

                junction Junction171 pe
                [
                    position = 7944, 8136
                ]

                junction Junction65 pe
                [
                    position = 8576, 8136
                ]

                junction Junction70 pe
                [
                    position = 8424, 8472
                ]

                junction Junction121 pe
                [
                    position = 8344, 8040
                ]

                junction Junction123 pe
                [
                    position = 8424, 8136
                ]

                junction Junction125 pe
                [
                    position = 8512, 8232
                ]

                junction Junction191 sp
                [
                    position = 8432, 8880
                ]

                junction Junction199 sp
                [
                    position = 8416, 8848
                ]

                junction Junction200 sp
                [
                    position = 7504, 8872
                ]

                junction Junction201 sp
                [
                    position = 7504, 8920
                ]

                junction Junction78 pe
                [
                    position = 8832, 8480
                ]

                junction Junction198 pe
                [
                    position = 8888, 8480
                ]

                junction Junction209 pe
                [
                    position = 8832, 8136
                ]

                junction Junction211 sp
                [
                    position = 7504, 8952
                ]

                junction Junction214 pe
                [
                    position = 8584, 8040
                ]

                junction Junction215 pe
                [
                    position = 8584, 8136
                ]

                junction Junction216 pe
                [
                    position = 8576, 8232
                ]

                junction Junction217 pe
                [
                    position = 7488, 8136
                ]

                junction Junction218 pe
                [
                    position = 7592, 8232
                ]

                junction Junction219 pe
                [
                    position = 7592, 8040
                ]

                junction Junction227 pe
                [
                    position = 6784, 8232
                ]

                junction Junction228 pe
                [
                    position = 6784, 8040
                ]

                junction Junction241 pe
                [
                    position = 7488, 8232
                ]

                junction Junction242 pe
                [
                    position = 7488, 8040
                ]

                junction Junction244 pe
                [
                    position = 7064, 8040
                ]

                junction Junction245 pe
                [
                    position = 7064, 8232
                ]

                junction Junction246 sp
                [
                    position = 7008, 8544
                ]

                junction Junction247 pe
                [
                    position = 6984, 8040
                ]

                junction Junction248 pe
                [
                    position = 6984, 8232
                ]

                junction Junction249 sp
                [
                    position = 6912, 8408
                ]

                junction Junction250 sp
                [
                    position = 7304, 8536
                ]

                junction Junction253 pe
                [
                    position = 8776, 8032
                ]

                junction Junction254 pe
                [
                    position = 8888, 8232
                ]

                junction Junction256 sp
                [
                    position = 8248, 8664
                ]

                junction Junction259 sp
                [
                    position = 8664, 8696
                ]

                junction Junction261 sp
                [
                    position = 8616, 8840
                ]

                junction Junction262 sp
                [
                    position = 8664, 8760
                ]

                junction Junction263 sp
                [
                    position = 7296, 7888
                ]

                junction Junction264 sp
                [
                    position = 7128, 7888
                ]

                junction Junction265 sp
                [
                    position = 7040, 7888
                ]

                junction Junction266 sp
                [
                    position = 8352, 8752
                ]

                comment Comment1 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Boost controller</p></body></html> ENDCOMMENT 
                [
                    position = 6736, 8344
                ]

                connect Iinv_in.n_node "Three Phase NPC Inverter1.DC+" as Connection879
                connect L1.p_node Junction170 as Connection880
                connect Junction170 Vab.p_node as Connection881
                [
                    position = 0, 0
                    breakpoints = 7944, 8040
                ]
                connect "Three Phase NPC Inverter1.A" Junction170 as Connection882
                connect L2.p_node Junction171 as Connection883
                connect Junction171 Vab.n_node as Connection884
                [
                    position = 0, 0
                    breakpoints = 7944, 8136
                ]
                connect "Three Phase NPC Inverter1.B" Junction171 as Connection885
                connect "Three Phase NPC Inverter1.C" L3.p_node as Connection886
                connect "Three Phase NPC Inverter1.InA" From36 as Connection899
                connect "Three Phase NPC Inverter1.InB" From37 as Connection900
                connect "Three Phase NPC Inverter1.InC" From38 as Connection901
                connect C1.p_node R7.n_node as Connection139
                connect C2.p_node R8.n_node as Connection144
                connect Goto12 Ia.out as Connection668
                connect Goto13 Ib.out as Connection800
                connect Goto14 Ic.out as Connection801
                connect Goto15 Vdc.out as Connection484
                connect Ia.n_node Junction121 as Connection802
                connect Ib.n_node Junction123 as Connection676
                connect Ic.p_node R0c.n_node as Connection803
                connect Junction121 R7.p_node as Connection809
                connect Junction123 R8.p_node as Connection677
                connect Junction125 Ic.n_node as Connection682
                connect Junction70 C2.n_node as Connection143
                connect L3.n_node R0c.p_node as Connection814
                connect R0a.n_node Ia.p_node as Connection817
                connect R0a.p_node L1.n_node as Connection818
                connect R0b.n_node Ib.p_node as Connection819
                connect R0b.p_node L2.n_node as Connection820
                connect R9.n_node C3.p_node as Connection145
                connect R9.p_node Junction125 as Connection681
                connect Vab1.n_node Junction65 as Connection119
                connect Vbc1.p_node Junction65 as Connection117
                connect P.in S_meas.P as Connection286
                connect Q.in S_meas.Q as Connection285
                connect S.in S_meas.S as Connection136
                connect pf.in S_meas.pf as Connection927
                connect t1.in "abc to dq.I0" as Connection316
                connect "dq to alpha beta2.d" "Current controller dq.Out4" as Connection928
                connect "dq to alpha beta2.q" "Current controller dq.Out5" as Connection929
                connect "SVPWM References Generator2.alpha" "dq to alpha beta2.alpha" as Connection931
                connect "dq to alpha beta2.beta" "SVPWM References Generator2.beta" as Connection932
                connect Goto34 "SVPWM References Generator2.refA" as Connection933
                connect Goto35 "SVPWM References Generator2.refB" as Connection934
                connect Goto36 "SVPWM References Generator2.refC" as Connection935
                connect "Edge Detection1.Out1" "Current controller dq.Reset" as Connection954
                connect From69 S_meas.Va as Connection966
                connect From70 S_meas.Vb as Connection967
                connect S_meas.Vc From71 as Connection968
                connect From79 "abc to dq.wt" as Connection973
                connect From75 "Current controller dq.f" as Connection977
                connect iq.in Junction191 as Connection987
                connect Junction191 "abc to dq.Iq" as Connection988
                [
                    position = 0, 0
                    breakpoints = 8432, 8880; 8432, 8880; 8488, 8880
                ]
                connect "Current controller dq.Iq" Junction191 as Connection989
                connect From85 "dq to alpha beta2.wt" as Connection1000
                connect From82 "Current controller dq.Vq" as Connection1032
                connect From81 "Current controller dq.Vd" as Connection1033
                connect "abc to dq.Id" Junction199 as Connection1042
                [
                    position = 0, 0
                    breakpoints = 8488, 8848
                ]
                connect Junction199 id.in as Connection1043
                [
                    position = 0, 0
                    breakpoints = 8416, 8848; 8416, 8856
                ]
                connect "Current controller dq.Id" Junction199 as Connection1044
                connect C1.n_node Junction70 as Connection1063
                [
                    position = 0, 0
                    breakpoints = 8344, 8472; 8344, 8472
                ]
                connect C3.n_node Junction70 as Connection1065
                [
                    position = 0, 0
                    breakpoints = 8512, 8472
                ]
                connect From39 PLL.A as Connection1069
                [
                    position = 0, 0
                    breakpoints = 7416, 8872
                ]
                connect PLL.B From40 as Connection1070
                connect From41 PLL.C as Connection1071
                connect PLL.wt Goto44 as Connection1080
                connect Goto41 Junction200 as Connection1081
                connect Junction200 PLL.Vd as Connection1082
                connect Vd.in Junction200 as Connection1083
                connect PLL.Vq Junction201 as Connection1084
                connect Junction201 Goto42 as Connection1085
                connect Vq.in Junction201 as Connection1086
                connect Goto1 Va.out as Connection367
                connect Goto4 Vb.out as Connection368
                connect Goto5 Vc.out as Connection369
                connect Vb.n_node Junction78 as Connection363
                connect Vc.n_node Junction198 as Connection1027
                connect Junction198 Junction78 as Connection1028
                connect N Junction198 as Connection1029
                connect Junction78 Va.n_node as Connection1064
                connect Junction209 S1.b_out as Connection1131
                connect Vb.p_node Junction209 as Connection1132
                connect Goto43 Junction211 as Connection1136
                connect Junction211 PLL.f as Connection1137
                connect f_meas.in Junction211 as Connection1138
                connect Junction121 Junction214 as Connection1167
                [
                    position = 0, 0
                    breakpoints = 8344, 8040
                ]
                connect Junction214 Vab1.p_node as Connection1168
                [
                    position = 0, 0
                    breakpoints = 8576, 8040
                ]
                connect S1.a_in Junction214 as Connection1169
                connect Junction123 Junction215 as Connection1170
                [
                    position = 0, 0
                    breakpoints = 8424, 8136
                ]
                connect Junction215 Junction65 as Connection1171
                [
                    position = 0, 0
                    breakpoints = 8576, 8136
                ]
                connect S1.b_in Junction215 as Connection1172
                connect Vbc1.n_node Junction216 as Connection1173
                connect Junction216 Junction125 as Connection1174
                [
                    position = 0, 0
                    breakpoints = 8576, 8232
                ]
                connect S1.c_in Junction216 as Connection1175
                connect C4.n_node Junction217 as Connection1179
                connect Junction217 C5.p_node as Connection1180
                connect "Three Phase NPC Inverter1.DCn" Junction217 as Connection1181
                connect Vdc.n_node Junction218 as Connection1182
                connect Junction218 "Three Phase NPC Inverter1.DC-" as Connection1183
                [
                    position = 0, 0
                    breakpoints = 7592, 8232
                ]
                connect Vdc.p_node Junction219 as Connection1185
                connect Junction219 Iinv_in.p_node as Connection1186
                [
                    position = 0, 0
                    breakpoints = 7592, 8040
                ]
                connect "Current controller dq.Iq_ref" Constant5.out as Connection2282
                connect Sum2.in1 "Rate Transition4.out" as Connection2353
                connect Lboost.n_node Boost1.a_in as Connection1207
                connect dc- Junction227 as Connection2294
                connect Vpv.n_node Junction227 as Connection2296
                connect dc+ Junction228 as Connection2297
                connect Junction228 Ipv.p_node as Connection2298
                connect Vpv.p_node Junction228 as Connection2299
                connect Vpv.out Goto48 as Connection2300
                connect Goto49 Ipv.out as Connection2301
                connect From100 Boost1.In as Connection2319
                connect C5.n_node Junction241 as Connection2386
                connect Junction241 Junction218 as Connection2387
                [
                    position = 0, 0
                    breakpoints = 7488, 8232; 7488, 8232
                ]
                connect C4.p_node Junction242 as Connection2389
                connect Junction242 Junction219 as Connection2390
                [
                    position = 0, 0
                    breakpoints = 7488, 8040; 7488, 8040
                ]
                connect Junction244 Lboost.p_node as Connection2409
                [
                    position = 0, 0
                    breakpoints = 7096, 8040
                ]
                connect Cin.p_node Junction244 as Connection2410
                connect Boost1.b_in Junction245 as Connection2411
                [
                    position = 0, 0
                    breakpoints = 7096, 8232
                ]
                connect Cin.n_node Junction245 as Connection2413
                connect From98 MPPT.vpv as Connection2415
                connect From99 MPPT.ipv as Connection2416
                connect "Rate Transition5.out" MPPT.Enable as Connection2417
                connect "Rate Transition4.in" Junction246 as Connection2418
                connect Junction246 Vpv_ref.in as Connection2419
                [
                    position = 0, 0
                    breakpoints = 7008, 8544
                ]
                connect MPPT.v_ref Junction246 as Connection2420
                connect Ipv.n_node Junction247 as Connection2423
                connect Junction247 Junction244 as Connection2424
                connect Vpv_hf.p_node Junction247 as Connection2425
                connect Junction245 Junction248 as Connection2426
                connect Junction248 Junction227 as Connection2427
                connect Vpv_hf.n_node Junction248 as Connection2428
                connect Goto51 Vpv_hf.out as Connection2429
                connect From101 Sum2.in as Connection2430
                connect "PI with Anti-windup.In" Sum2.out as Connection2431
                connect "Rate Transition5.in" Junction249 as Connection2432
                connect Junction249 From95 as Connection2433
                [
                    position = 0, 0
                    breakpoints = 6912, 8408
                ]
                connect "PI with Anti-windup.Reset" Junction249 as Connection2434
                connect duty.in Junction250 as Connection2435
                connect Junction250 Goto50 as Connection2436
                [
                    position = 0, 0
                    breakpoints = 7304, 8536
                ]
                connect "PI with Anti-windup.Out" Junction250 as Connection2437
                connect Product1.out Sum1.in as Connection2442
                connect Product2.out Sum1.in1 as Connection2443
                connect Ib1.p_node Junction209 as Connection2449
                connect Ia1.n_node A as Connection2452
                connect Va.p_node Junction253 as Connection2453
                connect Junction253 S1.a_out as Connection2454
                [
                    position = 0, 0
                    breakpoints = 8776, 8040
                ]
                connect Ia1.p_node Junction253 as Connection2455
                connect Ib1.n_node B as Connection2456
                connect S1.c_out Junction254 as Connection2457
                connect Junction254 Vc.p_node as Connection2458
                [
                    position = 0, 0
                    breakpoints = 8888, 8232
                ]
                connect Ic1.p_node Junction254 as Connection2459
                connect Ic1.n_node C as Connection2460
                connect Ia1.out S_meas.Ia as Connection2461
                connect Ib1.out S_meas.Ib as Connection2462
                connect Ic1.out S_meas.Ic as Connection2463
                connect "PI with Anti-windup1.In" Sum1.out as Connection2477
                connect From86 Junction256 as Connection2481
                connect Junction256 "Edge Detection1.In1" as Connection2482
                connect "PI with Anti-windup1.Reset" Junction256 as Connection2483
                connect Product1.in1 Junction259 as Connection2499
                connect Junction259 Product1.in as Connection2500
                [
                    position = 0, 0
                    breakpoints = 8656, 8696
                ]
                connect Constant6.out Junction259 as Connection2501
                connect "abc to dq.Ia" Junction261 as Connection2515
                connect Junction261 ia_filt.in as Connection2516
                [
                    position = 0, 0
                    breakpoints = 8608, 8840
                ]
                connect From76 Junction261 as Connection2517
                connect From77 "abc to dq.Ib" as Connection2518
                connect "abc to dq.Ic" From78 as Connection2519
                connect From80 "Current controller dq.VDC" as Connection2522
                connect Product2.in1 Junction262 as Connection2524
                connect Junction262 Product2.in as Connection2525
                [
                    position = 0, 0
                    breakpoints = 8664, 8760; 8664, 8760; 8664, 8760; 8664, 8760
                ]
                connect From97 Junction262 as Connection2526
                connect "Three Phase NPC Inverter1.En" Junction263 as Connection2532
                connect Junction263 Boost1.En as Connection2533
                [
                    position = 0, 0
                    breakpoints = 7296, 7888
                ]
                connect Junction264 Junction263 as Connection2536
                connect Goto45 Junction264 as Connection2537
                connect Connect Junction265 as Connection2538
                connect Junction265 Junction264 as Connection2539
                connect connect.in Junction265 as Connection2540
                connect "PI with Anti-windup1.Out" Junction266 as Connection2543
                connect Junction266 id_ref.in as Connection2544
                [
                    position = 0, 0
                    breakpoints = 8352, 8752; 8352, 8744
                ]
                connect "Current controller dq.Id_ref" Junction266 as Connection2545
                connect From102 S1.ctrl_in as Connection2546
                connect Boost1.a_out "Core Coupling 1.a_out" as Connection2547
                connect "Core Coupling 1.a_in" Junction242 as Connection2548
                connect Boost1.b_out "Core Coupling 1.b_out" as Connection2549
                connect "Core Coupling 1.b_in" Junction241 as Connection2550

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">2-stage, 3-phase, 3-level NPC PV inverter.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component contains a boost DC/DC converter responsible for the MPPT stage followed by a NPC-DC/AC stage. It is intended to be used with a PV panel at its DC terminals.   </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">  </p></body></html>"

                    Sn {
                        label = "Rated power"
                        widget = edit
                        type = generic
                        default_value = "15000"
                        unit = "VA"
                        group = "General:1"
                    }

                    VDC {
                        label = "Dc voltage"
                        widget = edit
                        type = generic
                        default_value = "1000"
                        unit = "V"
                        group = "Dc link"
                    }

                    fsw {
                        label = "Carrier frequency"
                        widget = edit
                        type = generic
                        default_value = "20000"
                        unit = "Hz"
                        group = "General"
                    }

                    dt {
                        label = "Dead-time"
                        widget = edit
                        type = generic
                        default_value = "0.5e-6"
                        unit = "s"
                        group = "General"
                    }

                    Ts {
                        label = "Execution Rate"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    L1 {
                        label = "Inductor"
                        widget = edit
                        type = generic
                        default_value = "1e-3"
                        unit = "H"
                        group = "LC Filter:2"
                    }

                    R0 {
                        label = "Inductor Series Resistance"
                        widget = edit
                        type = generic
                        default_value = "1e-4"
                        unit = "Ohm"
                        group = "LC Filter"
                    }

                    C1 {
                        label = "Capacitor"
                        widget = edit
                        type = generic
                        default_value = "20e-6"
                        unit = "F"
                        group = "LC Filter"
                    }

                    Resr {
                        label = "Capcitor ESR"
                        widget = edit
                        type = generic
                        default_value = "0.001"
                        unit = "Ohm"
                        group = "LC Filter"
                    }

                    Kp {
                        label = "Kp"
                        widget = edit
                        type = generic
                        default_value = "0.04"
                        group = "Current PI:4"
                    }

                    Ki {
                        label = "Ki"
                        widget = edit
                        type = generic
                        default_value = "13.3286"
                        group = "Current PI"
                    }

                    Cdc {
                        label = "Capacitors"
                        widget = edit
                        type = generic
                        default_value = "18e-3"
                        unit = "F"
                        group = "Dc link:5"
                    }

                    kp_dc {
                        label = "Kp (dc link)"
                        widget = edit
                        type = generic
                        default_value = "0.0066"
                        group = "Dc link"
                    }

                    ki_dc {
                        label = "Ki (dc link)"
                        widget = edit
                        type = generic
                        default_value = "0.1253"
                        group = "Dc link"
                    }

                    vpv_step {
                        label = "Voltage step"
                        widget = edit
                        type = generic
                        default_value = "2"
                        group = "Boost - MPPT:3"
                    }

                    vpv_init {
                        label = "Initial voltage"
                        widget = edit
                        type = generic
                        default_value = "700"
                        group = "Boost - MPPT"
                    }

                    Tmppt {
                        label = "Execution rate"
                        widget = edit
                        type = generic
                        default_value = "1"
                        unit = "s"
                        group = "Boost - MPPT"
                    }

                    Lboost {
                        label = "Boost inductor"
                        widget = edit
                        type = generic
                        default_value = "1.5e-3"
                        unit = "H"
                        group = "Boost - MPPT"
                    }

                    Cin {
                        label = "Input capacitor"
                        widget = edit
                        type = generic
                        default_value = "30e-6"
                        unit = "F"
                        group = "Boost - MPPT"
                    }

                    kp_boost {
                        label = "Kp (boost)"
                        widget = edit
                        type = generic
                        default_value = "7.9716e-5"
                        group = "Boost - MPPT"
                    }

                    ki_boost {
                        label = "Ki (boost)"
                        widget = edit
                        type = generic
                        default_value = "0.0188"
                        group = "Boost - MPPT"
                    }

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE
                }
            }
            [
                position = 7192, 8056
                size = 104, 232
            ]

            component Subsystem "1-ph PV Inverter (MPPT)" {
                layout = dynamic
                component "core/Single Phase Inverter" "Single Phase Inverter1" {
                    carrier_freq = "fcarr"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Ts"
                    fvd_def_method = "LUT"
                }
                [
                    position = 7504, 8032
                    size = 127, 256
                ]

                component pas_inductor Lf {
                    inductance = "Lf"
                }
                [
                    position = 7728, 7936
                ]

                component pas_resistor R0 {
                    resistance = "R0"
                }
                [
                    position = 7632, 7936
                ]

                component pas_capacitor Cf {
                    capacitance = "Cf"
                }
                [
                    position = 7904, 8032
                    rotation = right
                ]

                component "core/Voltage Measurement" Vdc {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 7352, 8040
                    rotation = right
                    size = 64, 32
                ]

                component "core/Current Measurement" Iinv {
                    execution_rate = "Ts_db"
                    sig_output = "True"
                }
                [
                    position = 7832, 7936
                    scale = 1, -1
                    size = 64, 32
                ]

                component gen_sum Sum1 {
                    signs = "+-"
                }
                [
                    position = 8552, 8488
                    hide_name = True
                ]

                component gen_gain Gain1 {
                    gain = "Lf*fcarr/VDC"
                }
                [
                    position = 8664, 8488
                ]

                component gen_gain Gain2 {
                    gain = "2/VDC"
                }
                [
                    position = 8624, 8672
                ]

                component gen_sum Sum2 {
                    signs = "++"
                }
                [
                    position = 8760, 8496
                    hide_name = True
                ]

                component gen_sum Sum3 {
                    signs = "+-"
                }
                [
                    position = 8856, 8504
                    hide_name = True
                ]

                component tm_delay "Unit Delay1" {
                    signal_out_type = "real"
                }
                [
                    position = 8912, 8608
                    hide_name = True
                    scale = -1, 1
                ]

                component gen_gain Gain3 {
                    gain = "-1"
                }
                [
                    position = 9144, 8568
                ]

                component "core/Rate Transition" "Rate Transition1" {
                    execution_rate = "Ts"
                }
                [
                    position = 9064, 8504
                    hide_name = True
                    size = 32, 32
                ]

                component gen_probe ma {
                }
                [
                    position = 9232, 8432
                ]

                component gen_probe mb {
                }
                [
                    position = 9232, 8648
                ]

                component gen_probe Ierror {
                }
                [
                    position = 8632, 8424
                ]

                component "core/Single phase PLL" "Single phase PLL1" {
                    offset_Hz = "60"
                }
                [
                    position = 7272, 8560
                    size = 64, 98
                ]

                component gen_probe f_PLL {
                }
                [
                    position = 7424, 8560
                ]

                component gen_terminator Termination1 {
                }
                [
                    position = 7424, 8416
                    hide_name = True
                ]

                component gen_terminator Termination2 {
                }
                [
                    position = 7424, 8448
                    hide_name = True
                ]

                component gen_terminator Termination3 {
                }
                [
                    position = 7424, 8480
                    hide_name = True
                ]

                component gen_product Product1 {
                    signs = "**"
                }
                [
                    position = 7864, 8696
                    hide_name = True
                ]

                component pas_capacitor Cdc {
                    capacitance = "10e-3"
                }
                [
                    position = 7288, 8040
                    rotation = right
                ]

                component gen_probe Iref {
                }
                [
                    position = 8048, 8776
                ]

                component gen_probe I_amp {
                }
                [
                    position = 7776, 8760
                ]

                component gen_limiter Limit1 {
                    lower_limit = "-1"
                    upper_limit = "1"
                }
                [
                    position = 9000, 8504
                    hide_name = True
                ]

                component "core/Rate Transition" "Rate Transition8" {
                    execution_rate = "Ts_db"
                }
                [
                    position = 7680, 8864
                    hide_name = True
                    size = 32, 32
                ]

                component src_constant Constant4 {
                    execution_rate = "Ts_db"
                    value = "0"
                }
                [
                    position = 8992, 8640
                    rotation = down
                    hide_name = True
                ]

                component sys_signal_switch "Signal switch3" {
                    threshold = "0.5"
                }
                [
                    position = 8840, 8624
                    hide_name = True
                    scale = -1, 1
                ]

                component sys_signal_switch "Signal switch4" {
                    threshold = "0.5"
                }
                [
                    position = 8440, 8480
                    hide_name = True
                ]

                component sys_signal_switch "Signal switch5" {
                    threshold = "0.5"
                }
                [
                    position = 8440, 8576
                    hide_name = True
                ]

                component src_constant Constant6 {
                    execution_rate = "Ts_db"
                    value = "0"
                }
                [
                    position = 8328, 8728
                    hide_name = True
                ]

                component sys_signal_switch "Signal switch8" {
                    threshold = "0.5"
                }
                [
                    position = 8440, 8672
                    hide_name = True
                ]

                component gen_rel_op "Relational operator1" {
                    relational_op = ">="
                }
                [
                    position = 7584, 8456
                    hide_name = True
                ]

                component src_constant Constant8 {
                    execution_rate = "Ts_db"
                    value = "6.2"
                }
                [
                    position = 7512, 8488
                    hide_name = True
                ]

                component gen_logic_op "Logical operator1" {
                }
                [
                    position = 7712, 8448
                    hide_name = True
                ]

                component "core/Rate Transition" "Rate Transition13" {
                    execution_rate = "Ts_db"
                }
                [
                    position = 7624, 8400
                    hide_name = True
                    size = 32, 32
                ]

                component gen_sr_ff "SR Flip Flop1" {
                }
                [
                    position = 7800, 8464
                ]

                component gen_terminator Termination6 {
                }
                [
                    position = 7896, 8480
                    hide_name = True
                ]

                component "core/Edge Detection" "Edge Detection1" {
                    edge = "falling"
                }
                [
                    position = 7712, 8504
                    hide_name = True
                    size = 32, 32
                ]

                component sys_signal_switch "Signal switch9" {
                    threshold = "0.5"
                }
                [
                    position = 7952, 8712
                    hide_name = True
                ]

                component src_constant Constant9 {
                    execution_rate = "Ts_db"
                    value = "0"
                }
                [
                    position = 7880, 8776
                    hide_name = True
                ]

                component gen_digital_probe start {
                }
                [
                    position = 7888, 8400
                ]

                component "core/Rate Transition" "Rate Transition14" {
                    execution_rate = "Ts"
                }
                [
                    position = 7440, 7840
                    hide_name = True
                    size = 32, 32
                ]

                component "core/Double Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                    fb_out_type = "int"
                }
                [
                    position = 7992, 8032
                    size = 64, 256
                ]

                component gen_digital_probe Connected {
                }
                [
                    position = 7184, 7680
                ]

                component "core/Voltage Measurement" Vph {
                    execution_rate = "Ts_db"
                    sig_output = "True"
                }
                [
                    position = 8144, 8032
                    rotation = right
                    size = 64, 32
                ]

                component gen_sum Sum5 {
                    execution_rate = "Ts"
                    signs = "+-"
                }
                [
                    position = 6768, 8504
                    hide_name = True
                ]

                component gen_probe Vpv_ref {
                }
                [
                    position = 6640, 8600
                    rotation = right
                ]

                component gen_probe duty {
                }
                [
                    position = 6936, 8576
                    rotation = right
                ]

                component "core/Rate Transition" "Rate Transition4" {
                    execution_rate = "Ts"
                }
                [
                    position = 6680, 8512
                    hide_name = True
                    size = 32, 32
                ]

                component "core/Rate Transition" "Rate Transition16" {
                    execution_rate = "Tmppt"
                }
                [
                    position = 6544, 8424
                    rotation = right
                    hide_name = True
                    size = 32, 32
                ]

                component "core/Boost" Boost1 {
                    carrier_freq = "fcarr"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Ts"
                    fvd_def_method = "LUT"
                    ref_sig_min_max = "[0, 1.0]"
                }
                [
                    position = 7152, 8032
                    size = 128, 256
                ]

                component pas_inductor Lboost {
                    inductance = "Lboost"
                }
                [
                    position = 7000, 7936
                ]

                component "core/Voltage Measurement" Vpv {
                    execution_rate = "Tmppt"
                    sig_output = "True"
                }
                [
                    position = 6632, 8040
                    rotation = right
                    size = 64, 32
                ]

                component "core/Current Measurement" Ipv {
                    execution_rate = "Tmppt"
                    sig_output = "True"
                }
                [
                    position = 6680, 7936
                    size = 64, 32
                ]

                component pas_capacitor Cin {
                    capacitance = "Cin"
                }
                [
                    position = 6912, 8040
                    rotation = right
                ]

                component Subsystem MPPT {
                    layout = dynamic
                    component gen_c_function "C function1" {
                        global_variables = "real vpv_old;real ppv_old;real dppv;"
                        init_fnc = "/*Begin code section*/
v_ref = vref_init;
vpv_old = vref_init;
ppv_old = 0;
/*End code section*/"
                        input_terminals = "inherit vpv;inherit iL;real enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True"
                        input_terminals_show_labels = "False;False;False"
                        output_fnc = "/*Begin code section*/
if (enable) {
    ppv = vpv*iL;
    dppv = ppv - ppv_old;
    if (dppv>0) {
        if (vpv>vpv_old) {
            v_ref += step;
        } else {
            v_ref -= step;
        }
    } else {
        if (vpv<vpv_old) {
            v_ref += step;
        } else {
            v_ref -= step;
        }
    }
    ppv_old = ppv;
    vpv_old = vpv;
    
} else {
    v_ref = vref_init;
    vpv_old = vref_init;
    ppv_old = 0;
}
/*End code section*/"
                        output_terminals = "real v_ref;inherit ppv;"
                        output_terminals_dimensions = "inherit;inherit"
                        output_terminals_feedthrough = "True;True"
                        output_terminals_show_labels = "False;False"
                        parameters = "real step;real vref_init;"
                    }
                    [
                        position = 8128, 8128
                        hide_name = True
                        size = 48, 64
                    ]

                    component gen_probe Ppv {
                    }
                    [
                        position = 8224, 8184
                    ]

                    port vpv {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7944, 8072
                    ]

                    port v_ref {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8232, 8112
                    ]

                    port Enable {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7944, 8192
                    ]

                    port ipv {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7944, 8128
                    ]

                    connect Enable "C function1.enable" as Connection18
                    connect v_ref "C function1.v_ref" as Connection19
                    connect Ppv.in "C function1.ppv" as Connection25
                    connect vpv "C function1.vpv" as Connection23
                    [
                        position = 0, 0
                        breakpoints = 8048, 8112
                    ]
                    connect ipv "C function1.iL" as Connection24

                    step = "vpv_step"
                    vref_init = "vpv_init"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Fixed step MPPT algorithm.</p></body></html>"

                        step {
                            label = "Voltage step"
                            widget = edit
                            type = generic
                            default_value = "10"
                            unit = "dc volts"
                        }

                        vref_init {
                            label = "Initial voltage"
                            widget = edit
                            type = generic
                            default_value = "700"
                            unit = "dc volts"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 6544, 8512
                    size = 112, 88
                ]

                component "core/Voltage Measurement" Vpv_hf {
                    execution_rate = "Ts"
                    sig_output = "True"
                }
                [
                    position = 6832, 8040
                    rotation = right
                    scale = -1, 1
                    size = 64, 32
                ]

                component Subsystem "PI with Anti-windup" {
                    layout = dynamic
                    component gen_integrator Integrator1 {
                        show_reset = "rising"
                    }
                    [
                        position = 8168, 8192
                        hide_name = True
                    ]

                    component gen_gain Gain3 {
                        gain = "kp_boost"
                    }
                    [
                        position = 8112, 8096
                        hide_name = True
                    ]

                    component gen_gain Gain4 {
                        gain = "ki_boost"
                    }
                    [
                        position = 8096, 8192
                        hide_name = True
                    ]

                    component gen_sum Sum2 {
                    }
                    [
                        position = 8264, 8192
                        hide_name = True
                    ]

                    component gen_limiter Limit1 {
                        lower_limit = "0"
                        upper_limit = "0.98"
                    }
                    [
                        position = 8344, 8192
                        hide_name = True
                    ]

                    component gen_sum Sum3 {
                        signs = "-+"
                    }
                    [
                        position = 8240, 8288
                        rotation = down
                        hide_name = True
                    ]

                    component gen_sum Sum4 {
                        signs = "+-"
                    }
                    [
                        position = 8040, 8192
                        hide_name = True
                    ]

                    port Reset {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8088, 8248
                    ]

                    port In {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7912, 8184
                    ]

                    port Out {
                        position = auto:auto
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8456, 8192
                    ]

                    junction Junction27 sp
                    [
                        position = 7992, 8184
                    ]

                    junction Junction28 sp
                    [
                        position = 8376, 8192
                    ]

                    junction Junction26 sp
                    [
                        position = 8312, 8192
                    ]

                    connect Integrator1.reset Reset as Connection144
                    connect Sum4.in Junction27 as Connection145
                    connect Junction27 Gain3.in as Connection146
                    connect In Junction27 as Connection147
                    connect Sum3.in Junction28 as Connection148
                    connect Junction28 Limit1.out as Connection149
                    connect Out Junction28 as Connection150
                    connect Gain4.out Integrator1.in as Connection133
                    connect Sum2.in1 Integrator1.out as Connection134
                    connect Sum2.in Gain3.out as Connection135
                    connect Limit1.in Junction26 as Connection137
                    connect Junction26 Sum2.out as Connection138
                    connect Sum3.in1 Junction26 as Connection139
                    connect Sum4.out Gain4.in as Connection141
                    connect Sum3.out Sum4.in1 as Connection142
                }
                [
                    position = 6864, 8504
                    size = 80, 48
                ]

                component gen_sum Sum6 {
                    signs = "-+"
                }
                [
                    position = 7464, 8864
                    rotation = down
                    hide_name = True
                    scale = -1, -1
                ]

                component src_constant Constant10 {
                    execution_rate = "Ts"
                    value = "VDC"
                }
                [
                    position = 7240, 8848
                    rotation = down
                    hide_name = True
                    scale = -1, 1
                ]

                component gen_product Product4 {
                }
                [
                    position = 7352, 8856
                    rotation = down
                    hide_name = True
                    scale = -1, 1
                ]

                component gen_product Product2 {
                }
                [
                    position = 7352, 8920
                    rotation = down
                    hide_name = True
                    scale = -1, 1
                ]

                component gen_probe sin_PLL {
                }
                [
                    position = 7776, 8632
                ]

                component gen_lpf "Low-Pass Filter1" {
                    execution_rate = "Ts"
                    frequency = "12"
                }
                [
                    position = 7240, 8912
                    hide_name = True
                ]

                component gen_probe Vdc_filt {
                }
                [
                    position = 7320, 8984
                ]

                component gen_limiter Limit2 {
                    lower_limit = "0"
                }
                [
                    position = 7624, 8864
                ]

                component "core/Single Phase Power Meter" "Single Phase Power Meter1" {
                    op_mode = "PLL based"
                }
                [
                    position = 8248, 7736
                    hide_name = True
                    size = 48, 48
                ]

                component "core/Current Measurement" Iph {
                    execution_rate = "Ts_db"
                    sig_output = "True"
                }
                [
                    position = 8080, 7936
                    size = 64, 32
                ]

                component gen_probe Pout {
                }
                [
                    position = 8352, 7720
                ]

                component gen_terminator Termination7 {
                }
                [
                    position = 8352, 7776
                    hide_name = True
                ]

                component gen_terminator Termination8 {
                }
                [
                    position = 8352, 7808
                    hide_name = True
                ]

                component Subsystem "PI with Anti-windup1" {
                    layout = dynamic
                    component gen_integrator Integrator1 {
                        show_reset = "rising"
                    }
                    [
                        position = 8168, 8200
                        hide_name = True
                    ]

                    component gen_gain Gain3 {
                        gain = "kp_dc"
                    }
                    [
                        position = 8112, 8096
                        hide_name = True
                    ]

                    component gen_gain Gain4 {
                        gain = "ki_dc"
                    }
                    [
                        position = 8096, 8192
                        hide_name = True
                    ]

                    component gen_sum Sum2 {
                    }
                    [
                        position = 8264, 8192
                        hide_name = True
                    ]

                    component gen_limiter Limit1 {
                        lower_limit = "0"
                    }
                    [
                        position = 8376, 8192
                        hide_name = True
                    ]

                    port Reset {
                        position = top:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8088, 8248
                    ]

                    port In {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7912, 8184
                    ]

                    port Out {
                        position = auto:auto
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8456, 8192
                    ]

                    junction Junction1 sp
                    [
                        position = 7992, 8184
                    ]

                    connect Integrator1.reset Reset as Connection144
                    connect Gain4.out Integrator1.in as Connection133
                    connect Sum2.in1 Integrator1.out as Connection134
                    connect Sum2.in Gain3.out as Connection135
                    connect Limit1.out Out as Connection156
                    connect Sum2.out Limit1.in as Connection161
                    [
                        position = 0, 0
                        breakpoints = 8312, 8192
                    ]
                    connect Gain3.in Junction1 as Connection162
                    [
                        position = 0, 0
                        breakpoints = 7992, 8096
                    ]
                    connect Junction1 In as Connection163
                    [
                        position = 0, 0
                        breakpoints = 7992, 8184; 7992, 8184
                    ]
                    connect Gain4.in Junction1 as Connection164
                }
                [
                    position = 7552, 8864
                    size = 80, 48
                ]

                component "core/Rate Transition" "Rate Transition17" {
                    execution_rate = "Ts"
                }
                [
                    position = 7520, 8784
                    hide_name = True
                    size = 32, 32
                ]

                port ph1 {
                    position = right:1
                    kind = pe
                }
                [
                    position = 8232, 7936
                    rotation = down
                ]

                port ph2 {
                    position = right:2
                    kind = pe
                }
                [
                    position = 8232, 8128
                    rotation = down
                ]

                port Connect {
                    position = top:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7088, 7744
                ]

                port dc+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 6568, 7936
                ]

                port dc- {
                    position = left:2
                    kind = pe
                }
                [
                    position = 6568, 8128
                ]

                tag Goto2 {
                    value = "Iinv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7736, 8000
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto4 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 9264, 8504
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 9264, 8568
                    hide_name = True
                    size = 60, 20
                ]

                tag From5 {
                    value = "ma"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7576, 7840
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From6 {
                    value = "mb"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7576, 7872
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Iref"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8056, 8712
                    hide_name = True
                    size = 60, 20
                ]

                tag From17 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7544, 8400
                    hide_name = True
                    size = 60, 20
                ]

                tag From1 {
                    value = "Iref"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8464
                    hide_name = True
                    size = 60, 20
                ]

                tag From2 {
                    value = "Iinv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8560
                    hide_name = True
                    size = 60, 20
                ]

                tag From3 {
                    value = "Vph"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8656
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto8 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7240, 7744
                    hide_name = True
                    size = 60, 20
                ]

                tag From18 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7936, 7880
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto9 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7960, 8448
                    hide_name = True
                    size = 60, 20
                ]

                tag From19 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7352, 7840
                    hide_name = True
                    size = 60, 20
                ]

                tag From20 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8336, 8416
                    hide_name = True
                    size = 60, 20
                ]

                tag From21 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8880, 8568
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From22 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7872, 8640
                    hide_name = True
                    size = 60, 20
                ]

                tag From7 {
                    value = "Vph"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7176, 8560
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Vph"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8232, 8032
                    rotation = down
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag From95 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 6400, 8376
                    hide_name = True
                    size = 60, 20
                ]

                tag From98 {
                    value = "Vpv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 6408, 8488
                    hide_name = True
                    size = 60, 20
                ]

                tag From99 {
                    value = "Ipv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 6408, 8536
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto50 {
                    value = "duty"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7008, 8504
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto48 {
                    value = "Vpv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 6712, 8088
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto49 {
                    value = "Ipv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 6728, 7888
                    hide_name = True
                    size = 60, 20
                ]

                tag From100 {
                    value = "duty"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7056, 7848
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto51 {
                    value = "Vpv_hf"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 6736, 8040
                    rotation = down
                    hide_name = True
                    size = 60, 20
                ]

                tag From101 {
                    value = "Vpv_hf"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 6664, 8472
                    hide_name = True
                    size = 60, 20
                ]

                tag From97 {
                    value = "Vdc"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7152, 8912
                    rotation = down
                    hide_name = True
                    scale = -1, 1
                    size = 60, 20
                ]

                tag Goto52 {
                    value = "Vdc"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7392, 8192
                    rotation = right
                    hide_name = True
                    size = 60, 20
                ]

                tag From103 {
                    value = "connected"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7056, 7880
                    hide_name = True
                    size = 60, 20
                ]

                tag From104 {
                    value = "start"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7440, 8784
                    hide_name = True
                    size = 60, 20
                ]

                junction Junction4 pe
                [
                    position = 7352, 8128
                ]

                junction Junction10 sp
                [
                    position = 9192, 8504
                ]

                junction Junction11 sp
                [
                    position = 9192, 8568
                ]

                junction Junction12 sp
                [
                    position = 8600, 8488
                ]

                junction Junction23 pe
                [
                    position = 7352, 7936
                ]

                junction Junction34 sp
                [
                    position = 7720, 8760
                ]

                junction Junction36 sp
                [
                    position = 9112, 8504
                ]

                junction Junction40 sp
                [
                    position = 8960, 8504
                ]

                junction Junction38 sp
                [
                    position = 8384, 8592
                ]

                junction Junction44 sp
                [
                    position = 8384, 8688
                ]

                junction Junction45 sp
                [
                    position = 7368, 8504
                ]

                junction Junction47 sp
                [
                    position = 7664, 8440
                ]

                junction Junction48 sp
                [
                    position = 7984, 8712
                ]

                junction Junction53 sp
                [
                    position = 7840, 8448
                ]

                junction Junction58 pe
                [
                    position = 7904, 7936
                ]

                junction Junction59 pe
                [
                    position = 7904, 8128
                ]

                junction Junction60 sp
                [
                    position = 7144, 7744
                ]

                junction Junction61 sp
                [
                    position = 8440, 8416
                ]

                junction Junction62 sp
                [
                    position = 8504, 8520
                ]

                junction Junction64 pe
                [
                    position = 8144, 7936
                ]

                junction Junction65 pe
                [
                    position = 8144, 8128
                ]

                junction Junction227 pe
                [
                    position = 6632, 8128
                ]

                junction Junction228 pe
                [
                    position = 6632, 7936
                ]

                junction Junction244 pe
                [
                    position = 6912, 7936
                ]

                junction Junction245 pe
                [
                    position = 6912, 8128
                ]

                junction Junction246 sp
                [
                    position = 6640, 8512
                ]

                junction Junction247 pe
                [
                    position = 6832, 7936
                ]

                junction Junction248 pe
                [
                    position = 6832, 8128
                ]

                junction Junction249 sp
                [
                    position = 6544, 8376
                ]

                junction Junction250 sp
                [
                    position = 6936, 8504
                ]

                junction Junction251 pe
                [
                    position = 7288, 7936
                ]

                junction Junction252 pe
                [
                    position = 7288, 8128
                ]

                junction Junction255 sp
                [
                    position = 7720, 8688
                ]

                junction Junction256 sp
                [
                    position = 7288, 8912
                ]

                junction Junction258 sp
                [
                    position = 8176, 8032
                ]

                junction Junction259 sp
                [
                    position = 7288, 8848
                ]

                junction Junction260 sp
                [
                    position = 7304, 8912
                ]

                comment Comment1 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Deadbeat current controller </p></body></html> ENDCOMMENT 
                [
                    position = 8304, 8328
                ]

                comment Comment2 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Start power injection when the inverter is connected AND the grid voltage crosses 0 V (in order to avoid instability) </p></body></html> ENDCOMMENT 
                [
                    position = 7320, 8328
                ]

                comment Comment3 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Generate current reference from dc-voltage loop </p></body></html> ENDCOMMENT 
                [
                    position = 7824, 8576
                ]

                comment Comment6 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Boost controller</p></body></html> ENDCOMMENT 
                [
                    position = 6368, 8312
                ]

                comment Comment7 START <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Arial'; font-size:12pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Dc-voltage control  </p></body></html> ENDCOMMENT 
                [
                    position = 7192, 8744
                ]

                connect R0.p_node "Single Phase Inverter1.a_in" as Connection3
                connect R0.n_node Lf.p_node as Connection4
                connect "Single Phase Inverter1.neg_out" Junction4 as Connection19
                connect Vdc.n_node Junction4 as Connection21
                connect Iinv.p_node Lf.n_node as Connection29
                connect Goto2 Iinv.out as Connection31
                connect Gain1.out Sum2.in as Connection37
                connect Sum2.in1 Gain2.out as Connection38
                [
                    position = 0, 0
                    breakpoints = 8704, 8504; 8704, 8576
                ]
                connect From5 "Single Phase Inverter1.InA" as Connection52
                connect From6 "Single Phase Inverter1.InB" as Connection53
                connect Junction10 Goto4 as Connection65
                connect ma.in Junction10 as Connection66
                connect Gain3.out Junction11 as Connection67
                connect Junction11 Goto5 as Connection68
                connect mb.in Junction11 as Connection69
                connect Gain1.in Junction12 as Connection70
                connect Junction12 Sum1.out as Connection71
                connect Ierror.in Junction12 as Connection72
                connect f_PLL.in "Single phase PLL1.f" as Connection95
                connect Termination1.in "Single phase PLL1.d" as Connection96
                connect Termination2.in "Single phase PLL1.q" as Connection97
                [
                    position = 0, 0
                    breakpoints = 7344, 8448; 7344, 8544
                ]
                connect Vdc.p_node Junction23 as Connection137
                connect "Single Phase Inverter1.pos_out" Junction23 as Connection139
                connect Sum2.out Sum3.in as Connection211
                connect Product1.in1 Junction34 as Connection267
                connect Junction34 I_amp.in as Connection268
                connect "Rate Transition1.in" Limit1.out as Connection286
                connect "Rate Transition8.out" Junction34 as Connection306
                connect Gain3.in Junction36 as Connection320
                [
                    position = 0, 0
                    breakpoints = 9112, 8568; 9112, 8504
                ]
                connect Junction36 Junction10 as Connection321
                connect "Rate Transition1.out" Junction36 as Connection322
                connect Junction40 Sum3.out as Connection363
                [
                    position = 0, 0
                    breakpoints = 8920, 8504
                ]
                connect "Unit Delay1.in" Junction40 as Connection402
                connect "Signal switch3.out" Sum3.in1 as Connection403
                connect Constant4.out "Signal switch3.in1" as Connection404
                connect "Signal switch3.in" "Unit Delay1.out" as Connection405
                connect "Signal switch5.in1" Junction38 as Connection333
                connect "Signal switch4.in1" Junction38 as Connection335
                [
                    position = 0, 0
                    breakpoints = 8384, 8496; 8384, 8592
                ]
                connect Junction38 Junction44 as Connection396
                connect Junction44 Constant6.out as Connection397
                connect "Signal switch8.in1" Junction44 as Connection398
                connect Termination3.in Junction45 as Connection415
                [
                    position = 0, 0
                    breakpoints = 7368, 8480
                ]
                connect Junction45 "Single phase PLL1.wt" as Connection416
                [
                    position = 0, 0
                    breakpoints = 7368, 8576
                ]
                connect Constant8.out "Relational operator1.in1" as Connection421
                connect From17 "Rate Transition13.in" as Connection424
                connect Termination6.in "SR Flip Flop1.out_n" as Connection428
                connect "Rate Transition13.out" Junction47 as Connection429
                connect Junction47 "Logical operator1.in" as Connection430
                connect "Edge Detection1.In1" Junction47 as Connection431
                connect Constant9.out "Signal switch9.in1" as Connection433
                connect Iref.in Junction48 as Connection435
                connect Junction48 Goto6 as Connection436
                [
                    position = 0, 0
                    breakpoints = 7984, 8712
                ]
                connect "Signal switch9.out" Junction48 as Connection437
                connect "Signal switch9.in" Product1.out as Connection438
                connect "Signal switch4.out" Sum1.in as Connection452
                connect "Signal switch5.out" Sum1.in1 as Connection453
                connect "Signal switch8.out" Gain2.in as Connection454
                connect From1 "Signal switch4.in" as Connection455
                connect From2 "Signal switch5.in" as Connection456
                connect From3 "Signal switch8.in" as Connection457
                [
                    position = 0, 0
                    breakpoints = 8416, 8656
                ]
                connect start.in Junction53 as Connection458
                connect "Single Phase Inverter1.En" "Rate Transition14.out" as Connection473
                connect Junction58 Cf.p_node as Connection478
                [
                    position = 0, 0
                    breakpoints = 7904, 7936
                ]
                connect S1.a_in Junction58 as Connection479
                connect Cf.n_node Junction59 as Connection480
                connect S1.b_in Junction59 as Connection482
                connect Goto8 Junction60 as Connection486
                connect Junction60 Connected.in as Connection487
                [
                    position = 0, 0
                    breakpoints = 7144, 7744; 7144, 7680
                ]
                connect Connect Junction60 as Connection488
                connect From18 S1.ctrl_in as Connection489
                connect From19 "Rate Transition14.in" as Connection494
                connect Goto9 Junction53 as Connection497
                connect From20 Junction61 as Connection499
                connect Junction61 "Signal switch4.in2" as Connection500
                connect "Signal switch5.in2" Junction62 as Connection502
                connect Junction62 Junction61 as Connection503
                [
                    position = 0, 0
                    breakpoints = 8504, 8520; 8504, 8416
                ]
                connect "Signal switch8.in2" Junction62 as Connection504
                connect From21 "Signal switch3.in2" as Connection505
                connect Junction40 Limit1.in as Connection506
                [
                    position = 0, 0
                    breakpoints = 8960, 8504; 8960, 8504
                ]
                connect "Edge Detection1.Out1" "SR Flip Flop1.r_in" as Connection507
                [
                    position = 0, 0
                    breakpoints = 7744, 8504
                ]
                connect "Logical operator1.in1" "Relational operator1.out" as Connection508
                [
                    position = 0, 0
                    breakpoints = 7632, 8456
                ]
                connect "SR Flip Flop1.s_in" "Logical operator1.out" as Connection509
                [
                    position = 0, 0
                    breakpoints = 7752, 8448
                ]
                connect Junction53 "SR Flip Flop1.out" as Connection510
                [
                    position = 0, 0
                    breakpoints = 7840, 8448; 7840, 8448
                ]
                connect From22 "Signal switch9.in2" as Connection511
                connect "Relational operator1.in" Junction45 as Connection512
                [
                    position = 0, 0
                    breakpoints = 7472, 8504
                ]
                connect From7 "Single phase PLL1.In" as Connection517
                connect Junction58 Iinv.n_node as Connection520
                connect "Single Phase Inverter1.b_in" Junction59 as Connection521
                connect Junction64 ph1 as Connection523
                connect Vph.p_node Junction64 as Connection524
                connect S1.b_out Junction65 as Connection525
                connect Junction65 ph2 as Connection526
                connect Vph.n_node Junction65 as Connection527
                connect Sum5.in1 "Rate Transition4.out" as Connection2353
                connect Lboost.n_node Boost1.a_in as Connection1207
                connect dc- Junction227 as Connection2294
                connect Vpv.n_node Junction227 as Connection2296
                connect dc+ Junction228 as Connection2297
                connect Junction228 Ipv.p_node as Connection2298
                connect Vpv.p_node Junction228 as Connection2299
                connect Vpv.out Goto48 as Connection2300
                connect Goto49 Ipv.out as Connection2301
                connect From100 Boost1.In as Connection2319
                connect Junction244 Lboost.p_node as Connection2409
                [
                    position = 0, 0
                    breakpoints = 6944, 7936
                ]
                connect Cin.p_node Junction244 as Connection2410
                connect Boost1.b_in Junction245 as Connection2411
                [
                    position = 0, 0
                    breakpoints = 6944, 8128
                ]
                connect Cin.n_node Junction245 as Connection2413
                connect From98 MPPT.vpv as Connection2415
                connect From99 MPPT.ipv as Connection2416
                connect "Rate Transition16.out" MPPT.Enable as Connection2417
                connect "Rate Transition4.in" Junction246 as Connection2418
                connect Junction246 Vpv_ref.in as Connection2419
                [
                    position = 0, 0
                    breakpoints = 6640, 8512
                ]
                connect MPPT.v_ref Junction246 as Connection2420
                connect Ipv.n_node Junction247 as Connection2423
                connect Junction247 Junction244 as Connection2424
                connect Vpv_hf.p_node Junction247 as Connection2425
                connect Junction245 Junction248 as Connection2426
                connect Junction248 Junction227 as Connection2427
                connect Vpv_hf.n_node Junction248 as Connection2428
                connect Goto51 Vpv_hf.out as Connection2429
                connect From101 Sum5.in as Connection2430
                connect "PI with Anti-windup.In" Sum5.out as Connection2431
                connect "Rate Transition16.in" Junction249 as Connection2432
                connect Junction249 From95 as Connection2433
                [
                    position = 0, 0
                    breakpoints = 6544, 8376
                ]
                connect "PI with Anti-windup.Reset" Junction249 as Connection2434
                connect duty.in Junction250 as Connection2435
                connect Junction250 Goto50 as Connection2436
                [
                    position = 0, 0
                    breakpoints = 6936, 8504
                ]
                connect "PI with Anti-windup.Out" Junction250 as Connection2437
                connect Junction23 Junction251 as Connection2440
                connect Junction251 Cdc.p_node as Connection2441
                connect Boost1.a_out Junction251 as Connection2442
                connect Junction4 Junction252 as Connection2443
                connect Junction252 Cdc.n_node as Connection2444
                connect Boost1.b_out Junction252 as Connection2445
                connect Product4.out Sum6.in as Connection2447
                connect Product2.out Sum6.in1 as Connection2448
                connect Goto52 Vdc.out as Connection2458
                connect From103 Boost1.En as Connection2461
                connect Product1.in Junction255 as Connection2462
                connect Junction255 "Single phase PLL1.sin(wt)" as Connection2463
                [
                    position = 0, 0
                    breakpoints = 7368, 8688; 7368, 8656; 7344, 8592
                ]
                connect sin_PLL.in Junction255 as Connection2464
                connect From97 "Low-Pass Filter1.in" as Connection2470
                connect "Low-Pass Filter1.out" Junction256 as Connection2471
                connect Limit2.out "Rate Transition8.in" as Connection2477
                connect S1.a_out Iph.p_node as Connection2478
                connect Iph.n_node Junction64 as Connection2479
                connect Iph.out "Single Phase Power Meter1.Ia" as Connection2480
                connect Goto3 Junction258 as Connection2481
                connect Junction258 Vph.out as Connection2482
                connect "Single Phase Power Meter1.Va" Junction258 as Connection2483
                connect Pout.in "Single Phase Power Meter1.P" as Connection2484
                [
                    position = 0, 0
                    breakpoints = 8288, 7720; 8288, 7704
                ]
                connect Termination7.in "Single Phase Power Meter1.Q" as Connection2485
                connect Termination8.in "Single Phase Power Meter1.S" as Connection2486
                connect "PI with Anti-windup1.In" Sum6.out as Connection2487
                connect "PI with Anti-windup1.Out" Limit2.in as Connection2488
                connect Vdc_filt.in Junction256 as Connection2490
                [
                    position = 0, 0
                    breakpoints = 7288, 8928; 7288, 8912
                ]
                connect From104 "Rate Transition17.in" as Connection2496
                connect "Rate Transition17.out" "PI with Anti-windup1.Reset" as Connection2497
                connect Constant10.out Junction259 as Connection2498
                connect Junction259 Product4.in1 as Connection2499
                [
                    position = 0, 0
                    breakpoints = 7288, 8848
                ]
                connect Product4.in Junction259 as Connection2500
                connect Product2.in1 Junction260 as Connection2501
                connect Junction260 Junction256 as Connection2502
                connect Product2.in Junction260 as Connection2503

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">2-stage, 1-phase PV inverter.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">This component contains a boost DC/DC converter responsible for the MPPT stage followed by a dead-beat controlled DC/AC stage. It is intended to be used with a PV panel at its DC terminals.   </p></body></html>"

                    fcarr {
                        label = "Carrier frequency"
                        widget = edit
                        type = generic
                        default_value = "20e3"
                        unit = "Hz"
                        group = "General"
                    }

                    dt {
                        label = "Dead-time"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    Ts {
                        label = "Execution rate"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    Lf {
                        label = "Inductor"
                        widget = edit
                        type = generic
                        default_value = "5e-3"
                        unit = "H"
                        group = "LC Filter:2"
                    }

                    R0 {
                        label = "Inductor resistance"
                        widget = edit
                        type = generic
                        default_value = "0.1"
                        unit = "Ohm"
                        group = "LC Filter"
                    }

                    Cf {
                        label = "Capacitor"
                        widget = edit
                        type = generic
                        default_value = "30e-6"
                        unit = "F"
                        group = "LC Filter"
                    }

                    vpv_step {
                        label = "Voltage step"
                        widget = edit
                        type = generic
                        default_value = "2"
                        unit = "V"
                        group = "Boost - MPPT: 3"
                    }

                    vpv_init {
                        label = "Initial voltage"
                        widget = edit
                        type = generic
                        default_value = "290"
                        unit = "V"
                        group = "Boost - MPPT"
                    }

                    Tmppt {
                        label = "Execution rate"
                        widget = edit
                        type = generic
                        default_value = "1"
                        unit = "s"
                        group = "Boost - MPPT"
                    }

                    Lboost {
                        label = "Boost inductor"
                        widget = edit
                        type = generic
                        default_value = "100e-6"
                        unit = "H"
                        group = "Boost - MPPT"
                    }

                    Cin {
                        label = "Input capacitor"
                        widget = edit
                        type = generic
                        default_value = "30e-6"
                        unit = "F"
                        group = "Boost - MPPT"
                    }

                    kp_boost {
                        label = "Kp (boost)"
                        widget = edit
                        type = generic
                        default_value = "3.4407e-5"
                        group = "Boost - MPPT"
                    }

                    ki_boost {
                        label = "Ki (boost)"
                        widget = edit
                        type = generic
                        default_value = "0.0314"
                        group = "Boost - MPPT"
                    }

                    VDC {
                        label = "Dc Voltage"
                        widget = edit
                        type = generic
                        default_value = "600"
                        unit = "V"
                        group = "Dc link:4"
                    }

                    Cdc {
                        label = "Capacitor"
                        widget = edit
                        type = generic
                        default_value = "2e-3"
                        unit = "F"
                        group = "Dc link"
                    }

                    kp_dc {
                        label = "Kp (dc link)"
                        widget = edit
                        type = generic
                        default_value = "4.8513e-4"
                        group = "Dc link"
                    }

                    ki_dc {
                        label = "Ki (dc link)"
                        widget = edit
                        type = generic
                        default_value = "0.0061"
                        group = "Dc link"
                    }

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE

                    CODE init
                    ENDCODE

                    CODE pre_compile
                        # HEADER START
                        fcarr = mdl.get_property_value(mdl.prop(item_handle, "fcarr"))
                        dt = mdl.get_property_value(mdl.prop(item_handle, "dt"))
                        Ts = mdl.get_property_value(mdl.prop(item_handle, "Ts"))
                        Lf = mdl.get_property_value(mdl.prop(item_handle, "Lf"))
                        R0 = mdl.get_property_value(mdl.prop(item_handle, "R0"))
                        Cf = mdl.get_property_value(mdl.prop(item_handle, "Cf"))
                        vpv_step = mdl.get_property_value(mdl.prop(item_handle, "vpv_step"))
                        vpv_init = mdl.get_property_value(mdl.prop(item_handle, "vpv_init"))
                        Tmppt = mdl.get_property_value(mdl.prop(item_handle, "Tmppt"))
                        Lboost = mdl.get_property_value(mdl.prop(item_handle, "Lboost"))
                        Cin = mdl.get_property_value(mdl.prop(item_handle, "Cin"))
                        kp_boost = mdl.get_property_value(mdl.prop(item_handle, "kp_boost"))
                        ki_boost = mdl.get_property_value(mdl.prop(item_handle, "ki_boost"))
                        VDC = mdl.get_property_value(mdl.prop(item_handle, "VDC"))
                        Cdc = mdl.get_property_value(mdl.prop(item_handle, "Cdc"))
                        kp_dc = mdl.get_property_value(mdl.prop(item_handle, "kp_dc"))
                        ki_dc = mdl.get_property_value(mdl.prop(item_handle, "ki_dc"))
                        # HEADER STOP
                        fcarr = mdl.get_property_value(mdl.prop(item_handle, "fcarr"))
                        Ts_db = 1/fcarr
                        Tslow = 0.1
                    ENDCODE
                }
            }
            [
                position = 6864, 8104
                size = 80, 136
            ]
        }
        [
            position = 4352, 4288
            size = 48, 48
        ]

        component Category "Supplier Inverters" {
            layout = dynamic
            component Subsystem "Supplier Inverter 3p4w" {
                layout = dynamic
                component pas_capacitor Cdc+ {
                    capacitance = "2.72e-3"
                }
                [
                    position = 7328, 8000
                    rotation = right
                ]

                component pas_capacitor Cdc- {
                    capacitance = "2.72e-3"
                }
                [
                    position = 7328, 8096
                    rotation = right
                ]

                component pas_capacitor Ca {
                    capacitance = "5e-6"
                }
                [
                    position = 8520, 8200
                    rotation = right
                ]

                component pas_capacitor Cb {
                    capacitance = "5e-6"
                }
                [
                    position = 8616, 8200
                    rotation = right
                ]

                component pas_capacitor Cc {
                    capacitance = "5e-6"
                }
                [
                    position = 8712, 8200
                    rotation = right
                ]

                component pas_inductor La {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 7952
                ]

                component pas_inductor Lb {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 8048
                ]

                component pas_inductor Lc {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 8144
                ]

                component pas_resistor R1 {
                    resistance = "Rpc"
                }
                [
                    position = 8880, 8888
                ]

                component pas_resistor R2 {
                    resistance = "Rpc"
                }
                [
                    position = 8880, 8936
                ]

                component pas_resistor R3 {
                    resistance = "Rpc"
                }
                [
                    position = 8880, 8984
                ]

                component "core/Voltage Measurement" Vdc+ {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7128, 8000
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vdc- {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7128, 8096
                    rotation = right
                    size = 64, 32
                ]

                component Subsystem Pre-charge {
                    layout = dynamic
                    component gen_c_function Pre-charge {
                        global_variables = "real contactor_count;real Fs;"
                        init_fnc = "/*Begin code section*/
Fs = 1/execution_rate;
contactor_count = 0;
/*End code section*/"
                        input_terminals = "real connect;"
                        input_terminals_dimensions = "inherit"
                        input_terminals_feedthrough = "True"
                        input_terminals_show_labels = "False"
                        output_fnc = "/*Begin code section*/
if (connect) {
    if (contactor_count == 0.) precharge_contactor = 1;

    if (contactor_count > (T1*Fs)){
        main_contactor = 1;
        precharge_contactor = 0;
    }
    contactor_count++;

    if (contactor_count > (T2*Fs)){
        inv_enable = 1;
        contactor_count = (T2*Fs+1.);
    }
} else {
    contactor_count = 0;
    main_contactor = 0;
    precharge_contactor = 0;
    inv_enable = 0;
}
/*End code section*/"
                        output_terminals = "real main_contactor;inherit precharge_contactor;inherit inv_enable;"
                        output_terminals_dimensions = "inherit;inherit;inherit"
                        output_terminals_feedthrough = "True;True;True"
                        output_terminals_show_labels = "True;True;True"
                        parameters = "real T1;real T2;"
                    }
                    [
                        position = 8192, 8192
                        size = 144, 128
                    ]

                    port main_contactor {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8352, 8088
                    ]

                    port Connect_in {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8048, 8192
                    ]

                    port precharge_contactor {
                        position = right:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8352, 8192
                    ]

                    port inv_enable {
                        position = right:3
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8360, 8280
                    ]

                    connect Pre-charge.main_contactor main_contactor as Connection1
                    connect Pre-charge.connect Connect_in as Connection2
                    connect Pre-charge.precharge_contactor precharge_contactor as Connection3
                    connect Pre-charge.inv_enable inv_enable as Connection4

                    T1 = "precharge_duration"
                    T2 = "inv_enable_time"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Pre-charging contactors logic.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> </p></body></html>"

                        T1 {
                            label = "Pre-charging duration"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "s"
                        }

                        T2 {
                            label = "Inverter enable time"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "s"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 8664, 7808
                    size = 192, 104
                ]

                component Subsystem "Current limit" {
                    layout = dynamic
                    component gen_c_function "Current limit" {
                        global_variables = "real counter;"
                        init_fnc = "/*Begin code section*/
limit_exceeded = 0;
counter =0;
/*End code section*/"
                        input_terminals = "inherit ia;inherit ib;inherit ic;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True;True"
                        input_terminals_show_labels = "True;True;True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable){
    if(ia > limit || ib > limit || ic > limit) limit_exceeded = 1;
}else{
    limit_exceeded = 0;
};
/*End code section*/"
                        output_terminals = "inherit limit_exceeded;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "real limit;"
                    }
                    [
                        position = 8176, 8176
                        size = 168, 128
                    ]

                    port limit_exceeded {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8328, 8176
                    ]

                    port sw_enable {
                        position = left:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 8208
                    ]

                    port ia_rms {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8016, 8080
                    ]

                    port ib_rms {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7968, 8128
                    ]

                    port ic_rms {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7920, 8168
                    ]

                    connect limit_exceeded "Current limit.limit_exceeded" as Connection2
                    connect sw_enable "Current limit.sw_enable" as Connection3
                    connect ia_rms "Current limit.ia" as Connection4
                    [
                        position = 0, 0
                        breakpoints = 8064, 8080; 8064, 8144
                    ]
                    connect ib_rms "Current limit.ib" as Connection5
                    [
                        position = 0, 0
                        breakpoints = 8000, 8128; 8048, 8128; 8048, 8160
                    ]
                    connect ic_rms "Current limit.ic" as Connection6
                    [
                        position = 0, 0
                        breakpoints = 8032, 8168; 8032, 8192
                    ]

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                        limit {
                            label = "Current limit"
                            widget = edit
                            type = generic
                            default_value = "curr_limit"
                            unit = "Arms"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7360, 9112
                    size = 136, 88
                ]

                component Subsystem "DC Voltage limit" {
                    layout = dynamic
                    component gen_c_function "DC Voltage limit" {
                        init_fnc = "/*Begin code section*/
limit_exceeded = 0;
/*End code section*/"
                        input_terminals = "inherit Vdc;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit"
                        input_terminals_feedthrough = "True;True"
                        input_terminals_show_labels = "True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable){
    if(Vdc > limit )
    limit_exceeded = 1;
}else{
    limit_exceeded = 0;
};
/*End code section*/"
                        output_terminals = "inherit limit_exceeded;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "real limit;"
                    }
                    [
                        position = 8176, 8176
                        size = 168, 128
                    ]

                    port limit_exceeded {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8328, 8176
                    ]

                    port sw_enable {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8032, 8224
                    ]

                    port Vdc {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8032, 8128
                    ]

                    connect limit_exceeded "DC Voltage limit.limit_exceeded" as Connection2
                    connect sw_enable "DC Voltage limit.sw_enable" as Connection3
                    connect Vdc "DC Voltage limit.Vdc" as Connection4

                    limit = "vdc_limit"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                        limit {
                            label = "DC Voltage limit"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "V"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7360, 9304
                    size = 136, 96
                ]

                component gen_sum Sum1 {
                }
                [
                    position = 7232, 9272
                    hide_name = True
                ]

                component Subsystem "Enable inverter" {
                    layout = dynamic
                    component gen_c_function "DC Voltage limit" {
                        init_fnc = "/*Begin code section*/
enable = 0;
/*End code section*/"
                        input_terminals = "inherit current_lim_exceeded;inherit vdc_lim_exceeded;inherit precharge_enable;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True;True"
                        input_terminals_show_labels = "True;True;True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable && precharge_enable){
    if(en_i_protection && current_lim_exceeded){
        enable = 0;
    }else if(en_v_protection && vdc_lim_exceeded){
        enable = 0;
    }else{
        enable =1;
    };
}else enable = 0;
/*End code section*/"
                        output_terminals = "inherit enable;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "int en_i_protection;int en_v_protection;"
                    }
                    [
                        position = 8200, 8200
                        size = 216, 176
                    ]

                    port enable {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8368, 8200
                    ]

                    port vdc_lim {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8184
                    ]

                    port precharge_en {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8248
                    ]

                    port sw_enable {
                        position = left:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8304
                    ]

                    port current_lim {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8128
                    ]

                    connect sw_enable "DC Voltage limit.sw_enable" as Connection3
                    connect enable "DC Voltage limit.enable" as Connection2
                    connect precharge_en "DC Voltage limit.precharge_enable" as Connection4
                    connect vdc_lim "DC Voltage limit.vdc_lim_exceeded" as Connection5
                    connect current_lim "DC Voltage limit.current_lim_exceeded" as Connection6
                }
                [
                    position = 7808, 9224
                    size = 144, 96
                ]

                component "core/Current Measurement" Iu {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 7952
                    size = 64, 32
                ]

                component "core/Current Measurement" Iv {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 8048
                    size = 64, 32
                ]

                component "core/Current Measurement" Iw {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 8144
                    size = 64, 32
                ]

                component gen_bus_join "Bus Join1" {
                    inputs = "3"
                }
                [
                    position = 8280, 9248
                ]

                component gen_bus_join "Bus Join2" {
                    inputs = "10"
                }
                [
                    position = 8328, 9464
                ]

                component pas_resistor R4 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 7952
                ]

                component pas_resistor R5 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 8048
                ]

                component pas_resistor R6 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 8144
                ]

                component pas_resistor R7 {
                    resistance = "0.05"
                }
                [
                    position = 8520, 8288
                    rotation = right
                ]

                component pas_resistor R8 {
                    resistance = "0.05"
                }
                [
                    position = 8616, 8288
                    rotation = right
                ]

                component pas_resistor R9 {
                    resistance = "0.05"
                }
                [
                    position = 8712, 8288
                    rotation = right
                ]

                component gen_rms_value "RMS value1" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8040, 7872
                    hide_name = True
                ]

                component gen_rms_value "RMS value2" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8128, 8008
                    hide_name = True
                ]

                component gen_rms_value "RMS value3" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8120, 8104
                    hide_name = True
                ]

                component "core/IGBT Leg" "IGBT Leg1" {
                    S_bot = "8"
                    S_top = "7"
                    carrier_freq = "fc"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Tex"
                    fvd_def_method = "LUT"
                }
                [
                    position = 7624, 8056
                    scale = -1, 1
                    size = 80, 192
                ]

                component pas_inductor Ln {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 8584
                ]

                component "core/Current Measurement" Ix {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 8584
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vu {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 8264, 8192
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vv {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 8336, 8248
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vw {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 8424, 8296
                    rotation = right
                    size = 64, 32
                ]

                component "core/Three Phase Inverter" "Three Phase Inverter1" {
                    carrier_freq = "fc"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Tex"
                    fvd_def_method = "LUT"
                }
                [
                    position = 7816, 8048
                    size = 127, 256
                ]

                component pas_resistor Rbrake {
                    resistance = "2500"
                }
                [
                    position = 7464, 8000
                    rotation = right
                ]

                component "core/Single Pole Single Throw Contactor" BrakeSW {
                    ctrl_src = "Model"
                }
                [
                    position = 7464, 8096
                    rotation = right
                    size = 64, 32
                ]

                component pas_capacitor Cn {
                    capacitance = "5e-6"
                }
                [
                    position = 8160, 8656
                    rotation = right
                ]

                component pas_resistor R10 {
                    resistance = "0.05"
                }
                [
                    position = 8160, 8744
                    rotation = right
                ]

                component pas_resistor R11 {
                    resistance = "0"
                }
                [
                    position = 8304, 8784
                    rotation = down
                ]

                component "core/Multi Pole Single Throw Contactor" "Multi Pole Single Throw Contactor1" {
                    ctrl_src = "Model"
                }
                [
                    position = 8928, 8032
                    size = 64, 207
                ]

                component "core/Multi Pole Single Throw Contactor" "Multi Pole Single Throw Contactor2" {
                    ctrl_src = "Model"
                }
                [
                    position = 9016, 8960
                    size = 64, 207
                ]

                component pas_resistor R12 {
                    resistance = "Rpc"
                }
                [
                    position = 8880, 9032
                ]

                component "core/Voltage Measurement" Vx {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 8224, 8696
                    rotation = right
                    size = 64, 32
                ]

                port DC+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7024, 7952
                ]

                port DC- {
                    position = left:5
                    kind = pe
                }
                [
                    position = 7024, 8144
                ]

                port U {
                    position = right:1
                    kind = pe
                }
                [
                    position = 9176, 7960
                    rotation = down
                ]

                port V {
                    position = right:2
                    kind = pe
                }
                [
                    position = 9176, 8008
                    rotation = down
                ]

                port W {
                    position = right:3
                    kind = pe
                }
                [
                    position = 9176, 8056
                    rotation = down
                ]

                port Connect {
                    position = bottom:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 8496, 7808
                ]

                port "Sw enable" {
                    position = bottom:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7000, 9336
                ]

                port Flags {
                    position = bottom:4
                    kind = sp
                    direction =  in
                    sp_type {
                        default = inherit
                        readonly = True
                    }
                }
                [
                    position = 8360, 9248
                ]

                port Measurements {
                    position = bottom:3
                    kind = sp
                    direction =  in
                    sp_type {
                        default = inherit
                        readonly = True
                    }
                }
                [
                    position = 8464, 9464
                ]

                port Brake {
                    position = top:5
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7536, 8096
                ]

                port N {
                    position = right:5
                    kind = pe
                }
                [
                    position = 8528, 8840
                ]

                port X {
                    position = right:4
                    kind = pe
                }
                [
                    position = 9176, 8104
                    rotation = down
                ]

                port m_u {
                    position = top:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7864
                ]

                port m_v {
                    position = top:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7800
                ]

                port m_w {
                    position = top:3
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7744
                ]

                port m_x {
                    position = top:4
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7728, 8056
                ]

                tag Goto1 {
                    value = "precharge_enable"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8856, 7840
                    hide_name = True
                    size = 115, 20
                ]

                tag Goto2 {
                    value = "Iu"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8048, 7904
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Iv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8048, 8008
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto4 {
                    value = "Iw"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8040, 8104
                    hide_name = True
                    size = 60, 20
                ]

                tag From1 {
                    value = "Iu_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7208, 9056
                    hide_name = True
                    size = 60, 20
                ]

                tag From2 {
                    value = "Iv_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7208, 9088
                    hide_name = True
                    size = 60, 20
                ]

                tag From3 {
                    value = "Iw_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7208, 9120
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7208, 8000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7208, 8096
                    hide_name = True
                    size = 60, 20
                ]

                tag From4 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7136, 9264
                    hide_name = True
                    size = 60, 20
                ]

                tag From5 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7136, 9296
                    hide_name = True
                    size = 60, 20
                ]

                tag From6 {
                    value = "precharge_enable"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7640, 9232
                    hide_name = True
                    size = 95, 20
                ]

                tag Goto7 {
                    value = "enable"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7952, 9224
                    hide_name = True
                    size = 60, 20
                ]

                tag From8 {
                    value = "Precharge_completed"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8160, 9200
                    hide_name = True
                    size = 116, 20
                ]

                tag From9 {
                    value = "Current_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8160, 9248
                    hide_name = True
                    size = 116, 20
                ]

                tag From10 {
                    value = "Vdc_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8160, 9296
                    hide_name = True
                    size = 116, 20
                ]

                tag Goto8 {
                    value = "Current_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7672, 9112
                    hide_name = True
                    size = 165, 20
                ]

                tag Goto9 {
                    value = "Vdc_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7584, 9304
                    hide_name = True
                    size = 165, 20
                ]

                tag Goto10 {
                    value = "Precharge_completed"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8856, 7880
                    hide_name = True
                    size = 111, 20
                ]

                tag From11 {
                    value = "Iu"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9352
                    hide_name = True
                    size = 60, 20
                ]

                tag From12 {
                    value = "Iv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9384
                    hide_name = True
                    size = 60, 20
                ]

                tag From13 {
                    value = "Iw"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9416
                    hide_name = True
                    size = 60, 20
                ]

                tag From14 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9608
                    hide_name = True
                    size = 60, 20
                ]

                tag From15 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9640
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto11 {
                    value = "Iu_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8176, 7904
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto12 {
                    value = "Iv_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8208, 8008
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto13 {
                    value = "Iw_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8192, 8104
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto14 {
                    value = "Ix"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8024, 8536
                    hide_name = True
                    size = 60, 20
                ]

                tag From16 {
                    value = "Ix"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9448
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto15 {
                    value = "Vu"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8296, 8400
                    rotation = right
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto16 {
                    value = "Vv"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8376, 8400
                    rotation = right
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto17 {
                    value = "Vw"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8464, 8400
                    rotation = right
                    hide_name = True
                    size = 60, 20
                ]

                tag From17 {
                    value = "Vu"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9480
                    hide_name = True
                    size = 60, 20
                ]

                tag From18 {
                    value = "Vv"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9512
                    hide_name = True
                    size = 60, 20
                ]

                tag From19 {
                    value = "Vw"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9544
                    hide_name = True
                    size = 60, 20
                ]

                tag From20 {
                    value = "Vx"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8136, 9576
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto18 {
                    value = "Vx"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8256, 8904
                    rotation = right
                    hide_name = True
                    size = 60, 20
                ]

                tag enable {
                    value = "enable"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7632, 7904
                    size = 0, 0
                ]

                junction Junction18 pe
                [
                    position = 8616, 8336
                ]

                junction Junction19 pe
                [
                    position = 7328, 8048
                ]

                junction Junction22 pe
                [
                    position = 7128, 7952
                ]

                junction Junction24 pe
                [
                    position = 7128, 8048
                ]

                junction Junction25 pe
                [
                    position = 7128, 8144
                ]

                junction Junction32 sp
                [
                    position = 7072, 9336
                ]

                junction Junction34 sp
                [
                    position = 7464, 9304
                ]

                junction Junction35 sp
                [
                    position = 8776, 7840
                ]

                junction Junction39 sp
                [
                    position = 7536, 9112
                ]

                junction Junction40 sp
                [
                    position = 7072, 9336
                ]

                junction Junction41 sp
                [
                    position = 7968, 7904
                ]

                junction Junction43 pe
                [
                    position = 8616, 8048
                ]

                junction Junction44 pe
                [
                    position = 8712, 8144
                ]

                junction Junction45 pe
                [
                    position = 8520, 7952
                ]

                junction Junction46 sp
                [
                    position = 7968, 8008
                ]

                junction Junction47 sp
                [
                    position = 7968, 8104
                ]

                junction Junction52 pe
                [
                    position = 8616, 8336
                ]

                junction Junction54 pe
                [
                    position = 7328, 7952
                ]

                junction Junction55 pe
                [
                    position = 7328, 8144
                ]

                junction Junction58 pe
                [
                    position = 8512, 8336
                ]

                junction Junction60 pe
                [
                    position = 8264, 7952
                ]

                junction Junction61 pe
                [
                    position = 8336, 8048
                ]

                junction Junction62 pe
                [
                    position = 8336, 8336
                ]

                junction Junction63 pe
                [
                    position = 8424, 8336
                ]

                junction Junction64 pe
                [
                    position = 8424, 8144
                ]

                junction Junction65 pe
                [
                    position = 7624, 7912
                ]

                junction Junction66 pe
                [
                    position = 7624, 8192
                ]

                junction Junction67 pe
                [
                    position = 7128, 8048
                ]

                junction Junction68 pe
                [
                    position = 8160, 8784
                ]

                junction Junction69 pe
                [
                    position = 8616, 8784
                ]

                junction Junction70 pe
                [
                    position = 8832, 7952
                ]

                junction Junction72 pe
                [
                    position = 8792, 8048
                ]

                junction Junction74 pe
                [
                    position = 8752, 8144
                ]

                junction Junction76 pe
                [
                    position = 8160, 8584
                ]

                junction Junction77 pe
                [
                    position = 8696, 8584
                ]

                junction Junction78 pe
                [
                    position = 9048, 7960
                ]

                junction Junction79 pe
                [
                    position = 9088, 8008
                ]

                junction Junction80 pe
                [
                    position = 9112, 8056
                ]

                junction Junction81 pe
                [
                    position = 9136, 8104
                ]

                junction Junction82 pe
                [
                    position = 8224, 8784
                ]

                junction Junction83 pe
                [
                    position = 8224, 8584
                ]

                connect Cdc-.p_node Junction19 as Connection87
                connect Junction19 Cdc+.n_node as Connection88
                [
                    position = 0, 0
                    breakpoints = 7328, 8048
                ]
                connect DC+ Junction22 as Connection96
                connect Vdc+.p_node Junction22 as Connection98
                connect Vdc+.n_node Junction24 as Connection102
                connect Vdc-.p_node Junction24 as Connection104
                connect DC- Junction25 as Connection105
                connect Vdc-.n_node Junction25 as Connection107
                connect Connect Pre-charge.Connect_in as Connection127
                connect Goto5 Vdc+.out as Connection143
                connect Goto6 Vdc-.out as Connection144
                connect Sum1.out "DC Voltage limit.Vdc" as Connection145
                connect From4 Sum1.in as Connection146
                connect From5 Sum1.in1 as Connection147
                connect From6 "Enable inverter.precharge_en" as Connection154
                connect "DC Voltage limit.sw_enable" Junction32 as Connection155
                connect "Enable inverter.sw_enable" Junction32 as Connection157
                [
                    position = 0, 0
                    breakpoints = 7720, 9248; 7720, 9408; 7720, 9408; 7272, 9408
                ]
                connect Goto7 "Enable inverter.enable" as Connection158
                connect La.p_node Iu.n_node as Connection163
                connect Iv.n_node Lb.p_node as Connection166
                connect Lc.p_node Iw.n_node as Connection167
                connect Flags "Bus Join1.out" as Connection169
                connect From8 "Bus Join1.in" as Connection170
                connect "Bus Join1.in1" From9 as Connection171
                connect From10 "Bus Join1.in2" as Connection172
                connect "DC Voltage limit.limit_exceeded" Junction34 as Connection179
                connect Junction34 "Enable inverter.vdc_lim" as Connection180
                [
                    position = 0, 0
                    breakpoints = 7464, 9304
                ]
                connect Goto9 Junction34 as Connection181
                connect Pre-charge.inv_enable Junction35 as Connection182
                connect Junction35 Goto1 as Connection183
                [
                    position = 0, 0
                    breakpoints = 8776, 7840
                ]
                connect Goto10 Junction35 as Connection184
                connect "Enable inverter.current_lim" Junction39 as Connection212
                connect Junction39 Goto8 as Connection213
                [
                    position = 0, 0
                    breakpoints = 7536, 9112
                ]
                connect "Current limit.limit_exceeded" Junction39 as Connection214
                connect Junction32 Junction40 as Connection216
                connect Junction40 "Sw enable" as Connection217
                [
                    position = 0, 0
                    breakpoints = 7072, 9336; 7072, 9336; 7072, 9336; 7072, 9336
                ]
                connect "Current limit.sw_enable" Junction40 as Connection218
                connect From11 "Bus Join2.in" as Connection234
                connect From12 "Bus Join2.in1" as Connection235
                [
                    position = 0, 0
                    breakpoints = 8256, 9384; 8256, 9416
                ]
                connect From13 "Bus Join2.in2" as Connection236
                [
                    position = 0, 0
                    breakpoints = 8240, 9416; 8240, 9432
                ]
                connect Measurements "Bus Join2.out" as Connection239
                connect La.n_node R4.p_node as Connection258
                connect Lb.n_node R5.p_node as Connection260
                connect Lc.n_node R6.p_node as Connection262
                connect Ca.n_node R7.p_node as Connection264
                connect Junction18 R8.n_node as Connection266
                connect R8.p_node Cb.n_node as Connection267
                connect Cc.n_node R9.p_node as Connection268
                connect Iu.out Junction41 as Connection298
                connect Junction41 Goto2 as Connection299
                connect "RMS value1.in" Junction41 as Connection300
                connect Junction43 Cb.p_node as Connection306
                connect Junction44 Cc.p_node as Connection309
                connect Ca.p_node Junction45 as Connection313
                [
                    position = 0, 0
                    breakpoints = 8520, 8160; 8520, 7952
                ]
                connect "RMS value2.out" Goto12 as Connection314
                [
                    position = 0, 0
                    breakpoints = 8168, 8008
                ]
                connect Iv.out Junction46 as Connection315
                connect Junction46 Goto3 as Connection316
                connect "RMS value2.in" Junction46 as Connection317
                connect "RMS value3.out" Goto13 as Connection318
                connect Iw.out Junction47 as Connection319
                connect Junction47 Goto4 as Connection320
                connect "RMS value3.in" Junction47 as Connection321
                [
                    position = 0, 0
                    breakpoints = 8088, 8088; 7968, 8088
                ]
                connect "RMS value1.out" Goto11 as Connection325
                [
                    position = 0, 0
                    breakpoints = 8128, 7872
                ]
                connect "Current limit.ia_rms" From1 as Connection335
                [
                    position = 0, 0
                    breakpoints = 7272, 9056
                ]
                connect "Current limit.ib_rms" From2 as Connection336
                [
                    position = 0, 0
                    breakpoints = 7264, 9104; 7264, 9088; 7264, 9088
                ]
                connect From3 "Current limit.ic_rms" as Connection337
                [
                    position = 0, 0
                    breakpoints = 7208, 9120; 7264, 9120
                ]
                connect R9.n_node Junction18 as Connection339
                [
                    position = 0, 0
                    breakpoints = 8712, 8336; 8616, 8336; 8616, 8328
                ]
                connect Junction52 Junction18 as Connection355
                connect Junction22 Junction54 as Connection380
                [
                    position = 0, 0
                    breakpoints = 7128, 7952
                ]
                connect Junction54 Cdc+.p_node as Connection381
                [
                    position = 0, 0
                    breakpoints = 7328, 7952
                ]
                connect Junction25 Junction55 as Connection383
                [
                    position = 0, 0
                    breakpoints = 7128, 8144
                ]
                connect Junction55 Cdc-.n_node as Connection384
                [
                    position = 0, 0
                    breakpoints = 7328, 8144
                ]
                connect Junction52 Junction58 as Connection392
                [
                    position = 0, 0
                    breakpoints = 8616, 8336; 8616, 8336
                ]
                connect Junction58 R7.n_node as Connection393
                [
                    position = 0, 0
                    breakpoints = 8520, 8336; 8520, 8336
                ]
                connect Ix.n_node Ln.p_node as Connection397
                connect Goto14 Ix.out as Connection398
                connect From16 "Bus Join2.in3" as Connection399
                connect Junction45 Junction60 as Connection413
                [
                    position = 0, 0
                    breakpoints = 8520, 7952
                ]
                connect Junction60 R4.n_node as Connection414
                [
                    position = 0, 0
                    breakpoints = 8296, 7952
                ]
                connect Vu.p_node Junction60 as Connection415
                connect R5.n_node Junction61 as Connection416
                connect Junction61 Junction43 as Connection417
                connect Vv.p_node Junction61 as Connection418
                connect Vv.n_node Junction62 as Connection421
                connect Junction62 Junction63 as Connection422
                connect Junction63 Junction58 as Connection423
                connect Vw.n_node Junction63 as Connection424
                connect R6.n_node Junction64 as Connection425
                [
                    position = 0, 0
                    breakpoints = 8208, 8144
                ]
                connect Junction64 Junction44 as Connection426
                [
                    position = 0, 0
                    breakpoints = 8448, 8144
                ]
                connect Vw.p_node Junction64 as Connection427
                connect Goto15 Vu.out as Connection428
                [
                    position = 0, 0
                    breakpoints = 8296, 8360; 8296, 8232; 8296, 8232; 8296, 8192
                ]
                connect Vv.out Goto16 as Connection429
                connect Vw.out Goto17 as Connection430
                connect From17 "Bus Join2.in4" as Connection431
                [
                    position = 0, 0
                    breakpoints = 8216, 9480; 8216, 9464
                ]
                connect From18 "Bus Join2.in5" as Connection432
                [
                    position = 0, 0
                    breakpoints = 8232, 9512; 8232, 9480
                ]
                connect From19 "Bus Join2.in6" as Connection433
                [
                    position = 0, 0
                    breakpoints = 8248, 9544; 8248, 9496
                ]
                connect "Three Phase Inverter1.c_in" Iw.p_node as Connection438
                connect "Three Phase Inverter1.b_in" Iv.p_node as Connection439
                connect "Three Phase Inverter1.a_in" Iu.p_node as Connection440
                connect Junction54 Junction65 as Connection441
                [
                    position = 0, 0
                    breakpoints = 7328, 7952; 7328, 7912
                ]
                connect Junction65 "IGBT Leg1.pos_out" as Connection442
                [
                    position = 0, 0
                    breakpoints = 7624, 7912
                ]
                connect "Three Phase Inverter1.pos_out" Junction65 as Connection443
                connect "IGBT Leg1.neg_out" Junction66 as Connection444
                connect Junction66 Junction55 as Connection445
                [
                    position = 0, 0
                    breakpoints = 7624, 8192; 7328, 8192
                ]
                connect "Three Phase Inverter1.neg_out" Junction66 as Connection446
                connect Rbrake.p_node "IGBT Leg1.pos_out" as Con1
                connect Rbrake.n_node BrakeSW.a_in as Con2
                connect "IGBT Leg1.neg_out" BrakeSW.a_out as Con3
                connect BrakeSW.ctrl_in Brake as Con4
                connect "IGBT Leg1.a_in" Ix.p_node as Connection450
                connect Junction62 Vu.n_node as Connection451
                [
                    position = 0, 0
                    breakpoints = 8336, 8336; 8296, 8336; 8264, 8336
                ]
                connect Cn.n_node R10.p_node as Connection452
                connect Junction24 Junction67 as Connection454
                connect Junction67 Junction19 as Connection455
                [
                    position = 0, 0
                    breakpoints = 7128, 8048; 7128, 8048; 7128, 8048; 7128, 8048; 7328, 8048; 7328, 8048; 7328, 8048
                ]
                connect R10.n_node Junction68 as Connection457
                connect Junction68 Junction67 as Connection458
                [
                    position = 0, 0
                    breakpoints = 6944, 8536; 6944, 8048
                ]
                connect N Junction69 as Connection460
                connect Junction69 Junction52 as Connection461
                connect R11.p_node Junction69 as Connection462
                connect Junction45 Junction70 as Connection469
                [
                    position = 0, 0
                    breakpoints = 8520, 7952
                ]
                connect Junction70 R1.p_node as Connection470
                [
                    position = 0, 0
                    breakpoints = 8832, 7952
                ]
                connect "Multi Pole Single Throw Contactor1.in_1" Junction70 as Connection471
                connect Junction43 Junction72 as Connection475
                [
                    position = 0, 0
                    breakpoints = 8616, 8048
                ]
                connect Junction72 R2.p_node as Connection476
                [
                    position = 0, 0
                    breakpoints = 8792, 8048; 8792, 8048; 8792, 8048; 8792, 8048
                ]
                connect "Multi Pole Single Throw Contactor1.in_2" Junction72 as Connection477
                connect R3.p_node Junction74 as Connection481
                connect Junction74 Junction44 as Connection482
                [
                    position = 0, 0
                    breakpoints = 8752, 8144
                ]
                connect "Multi Pole Single Throw Contactor1.in_3" Junction74 as Connection483
                connect Ln.n_node Junction76 as Connection487
                connect Junction76 Cn.p_node as Connection488
                connect Pre-charge.main_contactor "Multi Pole Single Throw Contactor1.ctrl_in" as Connection494
                connect R1.n_node "Multi Pole Single Throw Contactor2.in_1" as Connection495
                connect "Multi Pole Single Throw Contactor2.in_2" R2.n_node as Connection496
                connect R3.n_node "Multi Pole Single Throw Contactor2.in_3" as Connection497
                connect Pre-charge.precharge_contactor "Multi Pole Single Throw Contactor2.ctrl_in" as Connection498
                connect R12.n_node "Multi Pole Single Throw Contactor2.in_4" as Connection499
                connect "Multi Pole Single Throw Contactor1.in_4" Junction77 as Connection500
                [
                    position = 0, 0
                    breakpoints = 8880, 8584
                ]
                connect R12.p_node Junction77 as Connection502
                connect U Junction78 as Connection503
                connect Junction78 "Multi Pole Single Throw Contactor1.out_1" as Connection504
                connect "Multi Pole Single Throw Contactor2.out_1" Junction78 as Connection505
                connect V Junction79 as Connection506
                connect Junction79 "Multi Pole Single Throw Contactor1.out_2" as Connection507
                connect "Multi Pole Single Throw Contactor2.out_2" Junction79 as Connection508
                connect "Multi Pole Single Throw Contactor1.out_3" Junction80 as Connection509
                connect Junction80 W as Connection510
                connect "Multi Pole Single Throw Contactor2.out_3" Junction80 as Connection511
                connect "Multi Pole Single Throw Contactor1.out_4" Junction81 as Connection512
                connect Junction81 X as Connection513
                connect "Multi Pole Single Throw Contactor2.out_4" Junction81 as Connection514
                connect From14 "Bus Join2.in8" as Connection515
                connect From15 "Bus Join2.in9" as Connection516
                connect From20 "Bus Join2.in7" as Connection517
                connect Goto18 Vx.out as Connection518
                [
                    position = 0, 0
                ]
                connect R11.n_node Junction82 as Connection519
                connect Junction82 Junction68 as Connection520
                connect Vx.n_node Junction82 as Connection521
                connect Junction77 Junction83 as Connection522
                [
                    position = 0, 0
                    breakpoints = 8208, 8584
                ]
                connect Junction83 Junction76 as Connection523
                connect Vx.p_node Junction83 as Connection524
                connect m_u "Three Phase Inverter1.InA" as Con_mu
                connect m_v "Three Phase Inverter1.InB" as Con_mv
                connect m_w "Three Phase Inverter1.InC" as Con_mw
                connect m_x "IGBT Leg1.In" as Con_mx
                connect enable "Three Phase Inverter1.En" as Con_en_inv
                connect enable "IGBT Leg1.En" as Con_en_leg

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">3p4w Supplier Inverter - Hardware model.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">          Nameplate information</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Power: 30 kVA (3ph)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Dc Link: 500 Vdc (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Voltage: 0 - 220 V (Line)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Current: 79 A @ 127 V (Phase)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Frequency: 30 - 150 Hz</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Switching Frequency: 20 kHz (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Flags: 1- precharge_completed; 2- current_limit_exceeded; 3- vdc_limit_exceeded.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Measurements: 1- Iu; 2- Iv; 3- Iw; 4- Ix; 5- Vu; 6- Vv; 7- Vw; 8- Vx; 9- Vdc+; 10- Vdc- </p></body></html>"

                    curr_limit {
                        label = "Current limit"
                        widget = edit
                        type = generic
                        default_value = "87"
                        unit = "Arms"
                        group = "Protection:3"
                    }

                    vdc_limit {
                        label = "DC voltage Limit"
                        widget = edit
                        type = generic
                        default_value = "550"
                        unit = "V"
                        group = "Protection"
                    }

                    en_current_protection {
                        label = "Enable current protection"
                        widget = checkbox
                        type = bool
                        default_value = "True"
                        group = "Protection"
                        no_evaluate

                        CODE property_value_changed
                            if new_value:
                                en_i_protection = 1
                            else:
                                en_i_protection = 0
                        ENDCODE
                    }

                    en_vdc_protection {
                        label = "Enable DC voltage protection"
                        widget = checkbox
                        type = bool
                        default_value = "True"
                        group = "Protection"
                        no_evaluate

                        CODE property_value_changed
                            if new_value:
                                en_v_protection = 1
                            else:
                                en_v_protection = 0
                        ENDCODE
                    }

                    ctrl_mode {
                        label = "Control mode"
                        widget = combo
                        combo_values = "Internal modulator", "Digital input per switch"
                        type = string
                        default_value = "Internal modulator"
                        group = "General:1"
                        no_evaluate

                        CODE property_value_changed
                            control_mode(mdl, container_handle, new_value)
                        ENDCODE

                        CODE property_value_edited
                            control_mode(mdl, container_handle, new_value)
                        ENDCODE
                    }

                    fcarr {
                        label = "Carrier frequency"
                        widget = edit
                        type = generic
                        default_value = "20000"
                        unit = "Hz"
                        group = "General"
                        no_evaluate
                    }

                    dt {
                        label = "Inverter deadtime"
                        widget = combo
                        combo_values = "0.5e-6", "0.6e-6", "0.7e-6", "0.8e-6", "1.0e-6", "1.1e-6", "1.2e-6", "1.5e-6"
                        type = string
                        default_value = "0.5e-6"
                        unit = "s"
                        group = "General"
                        no_evaluate
                    }

                    Tex {
                        label = "Execution rate"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    sa_top {
                        label = "Sa top"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "1"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_top"), mdl.get_property_value(mdl.prop(container_handle, "sa_top")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_top"), mdl.get_property_value(mdl.prop(container_handle, "sa_top")))
                        ENDCODE
                    }

                    sa_bot {
                        label = "Sa bot"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "2"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_bot"), mdl.get_property_value(mdl.prop(container_handle, "sa_bot")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_bot"), mdl.get_property_value(mdl.prop(container_handle, "sa_bot")))
                        ENDCODE
                    }

                    sb_top {
                        label = "Sb top"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "3"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_top"), mdl.get_property_value(mdl.prop(container_handle, "sb_top")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_top"), mdl.get_property_value(mdl.prop(container_handle, "sb_top")))
                        ENDCODE
                    }

                    sb_bot {
                        label = "Sb bot"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "4"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_bot"), mdl.get_property_value(mdl.prop(container_handle, "sb_bot")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_bot"), mdl.get_property_value(mdl.prop(container_handle, "sb_bot")))
                        ENDCODE
                    }

                    sc_top {
                        label = "Sc top"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "5"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_top"), mdl.get_property_value(mdl.prop(container_handle, "sc_top")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_top"), mdl.get_property_value(mdl.prop(container_handle, "sc_top")))
                        ENDCODE
                    }

                    sc_bot {
                        label = "Sc bot"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "6"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_bot"), mdl.get_property_value(mdl.prop(container_handle, "sc_bot")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_bot"), mdl.get_property_value(mdl.prop(container_handle, "sc_bot")))
                        ENDCODE
                    }

                    sn_top {
                        label = "Sn top"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "7"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            igbt_leg = mdl.get_item("IGBT Leg1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(igbt_leg, "S_top"), mdl.get_property_value(mdl.prop(container_handle, "sn_top")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            igbt_leg = mdl.get_item("IGBT Leg1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(igbt_leg, "S_top"), mdl.get_property_value(mdl.prop(container_handle, "sn_top")))
                        ENDCODE
                    }

                    sn_bot {
                        label = "Sn bot"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "8"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            igbt_leg = mdl.get_item("IGBT Leg1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(igbt_leg, "S_bot"), mdl.get_property_value(mdl.prop(container_handle, "sn_bot")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            igbt_leg = mdl.get_item("IGBT Leg1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(igbt_leg, "S_bot"), mdl.get_property_value(mdl.prop(container_handle, "sn_bot")))
                        ENDCODE
                    }

                    precharge_duration {
                        label = "Pre-charge duration"
                        widget = edit
                        type = generic
                        default_value = "0.5"
                        unit = "s"
                        group = "Pre-charge:2"
                    }

                    inv_enable_time {
                        label = "Inverter enable time"
                        widget = edit
                        type = generic
                        default_value = "1"
                        unit = "s"
                        group = "Pre-charge"
                    }

                    Rpc {
                        label = "Pre-charge resistor"
                        widget = edit
                        type = generic
                        default_value = "0.5"
                        unit = "Ohm"
                        group = "Pre-charge"
                    }

                    en_brake {
                        label = "Enable brake chopper"
                        widget = checkbox
                        type = bool
                        default_value = "True"
                        group = "Brake Chopper:4"
                        no_evaluate

                        CODE property_value_changed
                            enable_chopper(mdl, container_handle, new_value)
                        ENDCODE

                        CODE property_value_edited
                            enable_chopper(mdl, container_handle, new_value)
                        ENDCODE
                    }

                    Rbr {
                        label = "Brake resistor"
                        widget = edit
                        type = generic
                        default_value = "2500"
                        unit = "Ohm"
                        group = "Brake Chopper"

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            r = mdl.get_item("Rbrake", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(r, "resistance"), mdl.get_property_value(mdl.prop(container_handle, "Rbr")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            r = mdl.get_item("Rbrake", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(r, "resistance"), mdl.get_property_value(mdl.prop(container_handle, "Rbr")))
                        ENDCODE
                    }

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE

                    CODE pre_compile
                        # HEADER START
                        curr_limit = mdl.get_property_value(mdl.prop(item_handle, "curr_limit"))
                        vdc_limit = mdl.get_property_value(mdl.prop(item_handle, "vdc_limit"))
                        en_current_protection = mdl.get_property_value(mdl.prop(item_handle, "en_current_protection"))
                        en_vdc_protection = mdl.get_property_value(mdl.prop(item_handle, "en_vdc_protection"))
                        ctrl_mode = mdl.get_property_value(mdl.prop(item_handle, "ctrl_mode"))
                        fcarr = mdl.get_property_value(mdl.prop(item_handle, "fcarr"))
                        dt = mdl.get_property_value(mdl.prop(item_handle, "dt"))
                        Tex = mdl.get_property_value(mdl.prop(item_handle, "Tex"))
                        sa_top = mdl.get_property_value(mdl.prop(item_handle, "sa_top"))
                        sa_bot = mdl.get_property_value(mdl.prop(item_handle, "sa_bot"))
                        sb_top = mdl.get_property_value(mdl.prop(item_handle, "sb_top"))
                        sb_bot = mdl.get_property_value(mdl.prop(item_handle, "sb_bot"))
                        sc_top = mdl.get_property_value(mdl.prop(item_handle, "sc_top"))
                        sc_bot = mdl.get_property_value(mdl.prop(item_handle, "sc_bot"))
                        sn_top = mdl.get_property_value(mdl.prop(item_handle, "sn_top"))
                        sn_bot = mdl.get_property_value(mdl.prop(item_handle, "sn_bot"))
                        precharge_duration = mdl.get_property_value(mdl.prop(item_handle, "precharge_duration"))
                        inv_enable_time = mdl.get_property_value(mdl.prop(item_handle, "inv_enable_time"))
                        Rpc = mdl.get_property_value(mdl.prop(item_handle, "Rpc"))
                        en_brake = mdl.get_property_value(mdl.prop(item_handle, "en_brake"))
                        Rbr = mdl.get_property_value(mdl.prop(item_handle, "Rbr"))
                        # HEADER STOP
                        fc = int(mdl.get_property_value(mdl.prop(item_handle, "fcarr")))
                        if fc > 20000: 
                            fc = 20000
                    ENDCODE

                    CODE init
                        def enable_chopper(mdl, musk_handle, new_value):
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT, ITEM_CONNECTION, ITEM_PORT, KIND_SP, DIRECTION_IN
                            
                            comp_handle = mdl.get_sub_level_handle(musk_handle)
                            leg = mdl.get_item("IGBT Leg1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            
                            if new_value:
                                mdl.enable_property(mdl.prop(musk_handle, "Rbr"))
                                r_br = mdl.get_item("Rbrake", parent=comp_handle, item_type=ITEM_COMPONENT)
                                sw_br = mdl.get_item("BrakeSW", parent=comp_handle, item_type=ITEM_COMPONENT)
                                port_br = mdl.get_item("Brake", parent=comp_handle, item_type=ITEM_PORT)
                                if not r_br:
                                    r_br = mdl.create_component("Resistor", parent=comp_handle, name="Rbrake", position=(7465,7999), rotation="right")
                                    mdl.set_property_value(mdl.prop(r_br, "resistance"), mdl.get_property_value(mdl.prop(item_handle, "Rbr")))
                                if not sw_br:
                                    sw_br = mdl.create_component("Single Pole Single Throw Contactor", parent=comp_handle, name="BrakeSW", position=(7465,8094), rotation="right")
                                    mdl.set_property_value(mdl.prop(sw_br, "ctrl_src"), "Model")
                                if not port_br:
                                    port_br = mdl.create_port(name="Brake", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 5), position=(7535,8094))
                                
                                con1 = mdl.get_item("Con1", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con2 = mdl.get_item("Con2", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con3 = mdl.get_item("Con3", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con4 = mdl.get_item("Con4", parent=comp_handle, item_type=ITEM_CONNECTION)
                                if not con1:
                                    con1 = mdl.create_connection(mdl.term(r_br, "p_node"), mdl.term(leg, "pos_out"), name="Con1")
                                if not con2:
                                    con2 = mdl.create_connection(mdl.term(r_br, "n_node"), mdl.term(sw_br, "a_in"), name="Con2")
                                if not con3:
                                    con3 = mdl.create_connection(mdl.term(leg, "neg_out"), mdl.term(sw_br, "a_out"), name="Con3")
                                if not con4:
                                    con4 = mdl.create_connection(mdl.term(sw_br, "ctrl_in"), port_br, name="Con4")
                            else:
                                mdl.disable_property(mdl.prop(musk_handle, "Rbr"))
                                r_br = mdl.get_item("Rbrake", parent=comp_handle, item_type=ITEM_COMPONENT)
                                sw_br = mdl.get_item("BrakeSW", parent=comp_handle, item_type=ITEM_COMPONENT)
                                port_br = mdl.get_item("Brake", parent=comp_handle, item_type=ITEM_PORT)
                                con1 = mdl.get_item("Con1", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con2 = mdl.get_item("Con2", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con3 = mdl.get_item("Con3", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con4 = mdl.get_item("Con4", parent=comp_handle, item_type=ITEM_CONNECTION)
                                if con1:
                                    mdl.delete_item(con1)
                                if con2:
                                    mdl.delete_item(con2)
                                if con3:
                                    mdl.delete_item(con3)
                                if con4:
                                    mdl.delete_item(con4)
                                if r_br:
                                    mdl.delete_item(r_br)
                                if sw_br:
                                    mdl.delete_item(sw_br)
                                if port_br:
                                    mdl.delete_item(port_br)
                        
                        def control_mode(mdl, musk_handle, new_value):
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT, ITEM_CONNECTION, ITEM_PORT, KIND_SP, DIRECTION_IN, DIRECTION_OUT, ITEM_TAG, TAG_SCOPE_LOCAL
                            
                            comp_handle = mdl.get_sub_level_handle(musk_handle)
                            leg = mdl.get_item("IGBT Leg1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            inv = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            
                            if new_value == "Internal modulator":
                                mdl.enable_property(mdl.prop(musk_handle, "fcarr"))
                                mdl.enable_property(mdl.prop(musk_handle, "dt"))
                                mdl.enable_property(mdl.prop(musk_handle, "Tex"))
                                mdl.show_property(mdl.prop(musk_handle, "fcarr"))
                                mdl.show_property(mdl.prop(musk_handle, "dt"))
                                mdl.show_property(mdl.prop(musk_handle, "Tex"))
                                mdl.disable_property(mdl.prop(musk_handle,"sa_top"))
                                mdl.disable_property(mdl.prop(musk_handle,"sa_bot"))
                                mdl.disable_property(mdl.prop(musk_handle,"sb_top"))
                                mdl.disable_property(mdl.prop(musk_handle,"sb_bot"))
                                mdl.disable_property(mdl.prop(musk_handle,"sc_top"))
                                mdl.disable_property(mdl.prop(musk_handle,"sc_bot"))
                                mdl.disable_property(mdl.prop(musk_handle,"sn_top"))
                                mdl.disable_property(mdl.prop(musk_handle,"sn_bot"))
                                mdl.hide_property(mdl.prop(musk_handle,"sa_top"))
                                mdl.hide_property(mdl.prop(musk_handle,"sa_bot"))
                                mdl.hide_property(mdl.prop(musk_handle,"sb_top"))
                                mdl.hide_property(mdl.prop(musk_handle,"sb_bot"))
                                mdl.hide_property(mdl.prop(musk_handle,"sc_top"))
                                mdl.hide_property(mdl.prop(musk_handle,"sc_bot"))
                                mdl.hide_property(mdl.prop(musk_handle,"sn_top"))
                                mdl.hide_property(mdl.prop(musk_handle,"sn_bot"))
                                
                                mdl.set_property_value(mdl.prop(inv, "ctrl_src"), new_value)
                                mdl.set_property_value(mdl.prop(leg, "ctrl_src"), new_value)
                                
                                mu = mdl.get_item("m_u", parent=comp_handle, item_type=ITEM_PORT)
                                mv = mdl.get_item("m_v", parent=comp_handle, item_type=ITEM_PORT)
                                mw = mdl.get_item("m_w", parent=comp_handle, item_type=ITEM_PORT)
                                mx = mdl.get_item("m_x", parent=comp_handle, item_type=ITEM_PORT)
                                enable_tag = mdl.get_item("enable", parent=comp_handle, item_type=ITEM_TAG)
                                if not mu:
                                    mu = mdl.create_port(name="m_u", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 1), position=(7775, 7862))
                                if not mv:
                                    mv = mdl.create_port(name="m_v", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 2), position=(7775, 7801))
                                if not mw:
                                    mw = mdl.create_port(name="m_w", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 3), position=(7775, 7740))
                                if not mx:
                                    mx = mdl.create_port(name="m_x", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 4), position=(7727, 8057))
                                if not enable_tag:
                                    enable_tag = mdl.create_tag(name="enable", value="enable", parent=comp_handle, scope=TAG_SCOPE_LOCAL, kind=KIND_SP, direction=DIRECTION_OUT, position=(7630,7904))
                            
                                con_mu = mdl.get_item("Con_mu", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mv = mdl.get_item("Con_mv", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mw = mdl.get_item("Con_mw", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mx = mdl.get_item("Con_mx", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_en_inv = mdl.get_item("Con_en_inv", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_en_leg = mdl.get_item("Con_en_leg", parent=comp_handle, item_type=ITEM_CONNECTION)
                                if not con_mu:
                                    con_mu = mdl.create_connection(mu, mdl.term(inv, "InA"), name="Con_mu")
                                if not con_mv:
                                    con_mv = mdl.create_connection(mv, mdl.term(inv, "InB"), name="Con_mv")
                                if not con_mw:
                                    con_mw = mdl.create_connection(mw, mdl.term(inv, "InC"), name="Con_mw")
                                if not con_mx:
                                    con_mx = mdl.create_connection(mx, mdl.term(leg, "In"), name="Con_mx")
                                if not con_en_inv:
                                    con_en_inv = mdl.create_connection(enable_tag, mdl.term(inv, "En"), name="Con_en_inv")
                                if not con_en_leg:
                                    con_en_leg = mdl.create_connection(enable_tag, mdl.term(leg, "En"), name="Con_en_leg")
                                
                            else:
                                mdl.disable_property(mdl.prop(musk_handle, "fcarr"))
                                mdl.disable_property(mdl.prop(musk_handle, "dt"))
                                mdl.enable_property(mdl.prop(musk_handle, "Tex"))
                                mdl.hide_property(mdl.prop(musk_handle, "fcarr"))
                                mdl.hide_property(mdl.prop(musk_handle, "dt"))
                                mdl.show_property(mdl.prop(musk_handle, "Tex"))
                                
                                mdl.enable_property(mdl.prop(musk_handle,"sa_top"))
                                mdl.enable_property(mdl.prop(musk_handle,"sa_bot"))
                                mdl.enable_property(mdl.prop(musk_handle,"sb_top"))
                                mdl.enable_property(mdl.prop(musk_handle,"sb_bot"))
                                mdl.enable_property(mdl.prop(musk_handle,"sc_top"))
                                mdl.enable_property(mdl.prop(musk_handle,"sc_bot"))
                                mdl.enable_property(mdl.prop(musk_handle,"sn_top"))
                                mdl.enable_property(mdl.prop(musk_handle,"sn_bot"))
                                mdl.show_property(mdl.prop(musk_handle,"sa_top"))
                                mdl.show_property(mdl.prop(musk_handle,"sa_bot"))
                                mdl.show_property(mdl.prop(musk_handle,"sb_top"))
                                mdl.show_property(mdl.prop(musk_handle,"sb_bot"))
                                mdl.show_property(mdl.prop(musk_handle,"sc_top"))
                                mdl.show_property(mdl.prop(musk_handle,"sc_bot"))
                                mdl.show_property(mdl.prop(musk_handle,"sn_top"))
                                mdl.show_property(mdl.prop(musk_handle,"sn_bot"))
                                
                                # Set default values
                                mdl.set_property_value(mdl.prop(musk_handle, "sa_top"), 1)
                                mdl.set_property_value(mdl.prop(musk_handle, "sa_bot"), 2)
                                mdl.set_property_value(mdl.prop(musk_handle, "sb_top"), 3)
                                mdl.set_property_value(mdl.prop(musk_handle, "sb_bot"), 4)
                                mdl.set_property_value(mdl.prop(musk_handle, "sc_top"), 5)
                                mdl.set_property_value(mdl.prop(musk_handle, "sc_bot"), 6)
                                mdl.set_property_value(mdl.prop(musk_handle, "sn_top"), 7)
                                mdl.set_property_value(mdl.prop(musk_handle, "sn_bot"), 8)
                        
                                mu = mdl.get_item("m_u", parent=comp_handle, item_type=ITEM_PORT)
                                mv = mdl.get_item("m_v", parent=comp_handle, item_type=ITEM_PORT)
                                mw = mdl.get_item("m_w", parent=comp_handle, item_type=ITEM_PORT)
                                mx = mdl.get_item("m_x", parent=comp_handle, item_type=ITEM_PORT)
                                enable_tag = mdl.get_item("enable", parent=comp_handle, item_type=ITEM_TAG)
                                con_mu = mdl.get_item("Con_mu", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mv = mdl.get_item("Con_mv", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mw = mdl.get_item("Con_mw", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mx = mdl.get_item("Con_mx", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_en_inv = mdl.get_item("Con_en_inv", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_en_leg = mdl.get_item("Con_en_leg", parent=comp_handle, item_type=ITEM_CONNECTION)
                                
                                if con_mu:
                                    mdl.delete_item(con_mu)
                                if con_mv:
                                    mdl.delete_item(con_mv)
                                if con_mw:
                                    mdl.delete_item(con_mw)
                                if con_mx:
                                    mdl.delete_item(con_mx)
                                if con_en_inv:
                                    mdl.delete_item(con_en_inv)
                                if con_en_leg:
                                    mdl.delete_item(con_en_leg)
                                if mu:
                                    mdl.delete_item(mu)
                                if mv:
                                    mdl.delete_item(mv)
                                if mw:
                                    mdl.delete_item(mw)
                                if mx:
                                    mdl.delete_item(mx)
                                if enable_tag:
                                    mdl.delete_item(enable_tag)
                                
                                mdl.set_property_value(mdl.prop(inv, "ctrl_src"), new_value)
                                mdl.set_property_value(mdl.prop(leg, "ctrl_src"), new_value)
                    ENDCODE

                    CODE post_resolve
                    ENDCODE

                    CODE define_icon
                        image('Figures\supplier_3p3w.png')
                    ENDCODE
                }
            }
            [
                position = 6240, 7912
                size = 248, 296
            ]

            component Subsystem "Supplier Inverter 3p3w" {
                layout = dynamic
                component pas_capacitor Cdc+ {
                    capacitance = "2.72e-3"
                }
                [
                    position = 7520, 8000
                    rotation = right
                ]

                component pas_capacitor Cdc- {
                    capacitance = "2.72e-3"
                }
                [
                    position = 7520, 8096
                    rotation = right
                ]

                component pas_capacitor Ca {
                    capacitance = "5e-6"
                }
                [
                    position = 8520, 8200
                    rotation = right
                ]

                component pas_capacitor Cb {
                    capacitance = "5e-6"
                }
                [
                    position = 8616, 8200
                    rotation = right
                ]

                component pas_capacitor Cc {
                    capacitance = "5e-6"
                }
                [
                    position = 8712, 8200
                    rotation = right
                ]

                component pas_inductor La {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 7952
                ]

                component pas_inductor Lb {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 8048
                ]

                component pas_inductor Lc {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 8144
                ]

                component "core/Triple Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                }
                [
                    position = 8928, 8048
                    size = 64, 256
                ]

                component "core/Triple Pole Single Throw Contactor" S2 {
                    ctrl_src = "Model"
                }
                [
                    position = 9016, 8336
                    size = 64, 256
                ]

                component pas_resistor R1 {
                    resistance = "Rpc"
                }
                [
                    position = 8888, 8240
                ]

                component pas_resistor R2 {
                    resistance = "Rpc"
                }
                [
                    position = 8888, 8336
                ]

                component pas_resistor R3 {
                    resistance = "Rpc"
                }
                [
                    position = 8888, 8432
                ]

                component "core/Voltage Measurement" Vdc+ {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7320, 8000
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vdc- {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7320, 8096
                    rotation = right
                    size = 64, 32
                ]

                component Subsystem Pre-charge {
                    layout = dynamic
                    component gen_c_function Pre-charge {
                        global_variables = "real contactor_count;real Fs;"
                        init_fnc = "/*Begin code section*/
Fs = 1/execution_rate;
contactor_count = 0;
/*End code section*/"
                        input_terminals = "real connect;"
                        input_terminals_dimensions = "inherit"
                        input_terminals_feedthrough = "True"
                        input_terminals_show_labels = "False"
                        output_fnc = "/*Begin code section*/
if (connect) {
    if (contactor_count == 0.) precharge_contactor = 1;

    if (contactor_count > (T1*Fs)){
        main_contactor = 1;
        precharge_contactor = 0;
    }
    contactor_count++;

    if (contactor_count > (T2*Fs)){
        inv_enable = 1;
        contactor_count = (T2*Fs+1.);
    }
} else {
    contactor_count = 0;
    main_contactor = 0;
    precharge_contactor = 0;
    inv_enable = 0;
}
/*End code section*/"
                        output_terminals = "real main_contactor;inherit precharge_contactor;inherit inv_enable;"
                        output_terminals_dimensions = "inherit;inherit;inherit"
                        output_terminals_feedthrough = "True;True;True"
                        output_terminals_show_labels = "True;True;True"
                        parameters = "real T1;real T2;"
                    }
                    [
                        position = 8192, 8192
                        size = 144, 128
                    ]

                    port main_contactor {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8352, 8088
                    ]

                    port Connect_in {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8048, 8192
                    ]

                    port precharge_contactor {
                        position = right:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8352, 8192
                    ]

                    port inv_enable {
                        position = right:3
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8360, 8280
                    ]

                    connect Pre-charge.main_contactor main_contactor as Connection1
                    connect Pre-charge.connect Connect_in as Connection2
                    connect Pre-charge.precharge_contactor precharge_contactor as Connection3
                    connect Pre-charge.inv_enable inv_enable as Connection4

                    T1 = "precharge_duration"
                    T2 = "inv_enable_time"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Pre-charging contactors logic.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> </p></body></html>"

                        T1 {
                            label = "Pre-charging duration"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "s"
                        }

                        T2 {
                            label = "Inverter enable time"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "s"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 8664, 7808
                    size = 192, 104
                ]

                component Subsystem "Current limit" {
                    layout = dynamic
                    component gen_c_function "Current limit" {
                        global_variables = "real counter;"
                        init_fnc = "/*Begin code section*/
limit_exceeded = 0;
counter =0;
/*End code section*/"
                        input_terminals = "inherit ia;inherit ib;inherit ic;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True;True"
                        input_terminals_show_labels = "True;True;True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable){
    if(ia > limit || ib > limit || ic > limit) limit_exceeded = 1;
}else{
    limit_exceeded = 0;
};
/*End code section*/"
                        output_terminals = "inherit limit_exceeded;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "real limit;"
                    }
                    [
                        position = 8176, 8176
                        size = 168, 128
                    ]

                    port limit_exceeded {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8328, 8176
                    ]

                    port sw_enable {
                        position = left:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 8208
                    ]

                    port ia_rms {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8016, 8080
                    ]

                    port ib_rms {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7968, 8128
                    ]

                    port ic_rms {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7920, 8168
                    ]

                    connect limit_exceeded "Current limit.limit_exceeded" as Connection2
                    connect sw_enable "Current limit.sw_enable" as Connection3
                    connect ia_rms "Current limit.ia" as Connection4
                    [
                        position = 0, 0
                        breakpoints = 8064, 8080; 8064, 8144
                    ]
                    connect ib_rms "Current limit.ib" as Connection5
                    [
                        position = 0, 0
                        breakpoints = 8000, 8128; 8048, 8128; 8048, 8160
                    ]
                    connect ic_rms "Current limit.ic" as Connection6
                    [
                        position = 0, 0
                        breakpoints = 8032, 8168; 8032, 8192
                    ]

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                        limit {
                            label = "Current limit"
                            widget = edit
                            type = generic
                            default_value = "curr_limit"
                            unit = "Arms"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7672, 8472
                    size = 136, 88
                ]

                component Subsystem "DC Voltage limit" {
                    layout = dynamic
                    component gen_c_function "DC Voltage limit" {
                        init_fnc = "/*Begin code section*/
limit_exceeded = 0;
/*End code section*/"
                        input_terminals = "inherit Vdc;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit"
                        input_terminals_feedthrough = "True;True"
                        input_terminals_show_labels = "True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable){
    if(Vdc > limit )
    limit_exceeded = 1;
}else{
    limit_exceeded = 0;
};
/*End code section*/"
                        output_terminals = "inherit limit_exceeded;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "real limit;"
                    }
                    [
                        position = 8176, 8176
                        size = 168, 128
                    ]

                    port limit_exceeded {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8328, 8176
                    ]

                    port sw_enable {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8032, 8224
                    ]

                    port Vdc {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8032, 8128
                    ]

                    connect limit_exceeded "DC Voltage limit.limit_exceeded" as Connection2
                    connect sw_enable "DC Voltage limit.sw_enable" as Connection3
                    connect Vdc "DC Voltage limit.Vdc" as Connection4

                    limit = "vdc_limit"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                        limit {
                            label = "DC Voltage limit"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "V"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7672, 8664
                    size = 136, 96
                ]

                component gen_sum Sum1 {
                }
                [
                    position = 7544, 8632
                    hide_name = True
                ]

                component Subsystem "Enable inverter" {
                    layout = dynamic
                    component gen_c_function "DC Voltage limit" {
                        init_fnc = "/*Begin code section*/
enable = 0;
/*End code section*/"
                        input_terminals = "inherit current_lim_exceeded;inherit vdc_lim_exceeded;inherit precharge_enable;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True;True"
                        input_terminals_show_labels = "True;True;True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable && precharge_enable){
    if(en_i_protection && current_lim_exceeded){
        enable = 0;
    }else if(en_v_protection && vdc_lim_exceeded){
        enable = 0;
    }else{
        enable =1;
    };
}else enable = 0;
/*End code section*/"
                        output_terminals = "inherit enable;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "int en_i_protection;int en_v_protection;"
                    }
                    [
                        position = 8200, 8200
                        size = 216, 176
                    ]

                    port enable {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8368, 8200
                    ]

                    port vdc_lim {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8184
                    ]

                    port precharge_en {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8248
                    ]

                    port sw_enable {
                        position = left:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8304
                    ]

                    port current_lim {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8128
                    ]

                    connect sw_enable "DC Voltage limit.sw_enable" as Connection3
                    connect enable "DC Voltage limit.enable" as Connection2
                    connect precharge_en "DC Voltage limit.precharge_enable" as Connection4
                    connect vdc_lim "DC Voltage limit.vdc_lim_exceeded" as Connection5
                    connect current_lim "DC Voltage limit.current_lim_exceeded" as Connection6
                }
                [
                    position = 8120, 8584
                    size = 144, 96
                ]

                component "core/Current Measurement" Ia {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 7952
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 8048
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 8144
                    size = 64, 32
                ]

                component gen_bus_join "Bus Join1" {
                    inputs = "3"
                }
                [
                    position = 8584, 8600
                ]

                component gen_bus_join "Bus Join2" {
                    inputs = "5"
                }
                [
                    position = 8632, 8816
                ]

                component pas_resistor R4 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 7952
                ]

                component pas_resistor R5 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 8048
                ]

                component pas_resistor R6 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 8144
                ]

                component pas_resistor R7 {
                    resistance = "0.05"
                }
                [
                    position = 8520, 8288
                    rotation = right
                ]

                component pas_resistor R8 {
                    resistance = "0.05"
                }
                [
                    position = 8616, 8288
                    rotation = right
                ]

                component pas_resistor R9 {
                    resistance = "0.05"
                }
                [
                    position = 8712, 8288
                    rotation = right
                ]

                component gen_rms_value "RMS value1" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8040, 7872
                    hide_name = True
                ]

                component gen_rms_value "RMS value2" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8128, 8008
                    hide_name = True
                ]

                component gen_rms_value "RMS value3" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8120, 8104
                    hide_name = True
                ]

                component pas_resistor SC {
                    resistance = "0"
                }
                [
                    position = 8296, 8336
                    rotation = down
                ]

                component "core/Three Phase Inverter" "Three Phase Inverter1" {
                    carrier_freq = "fc"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Tex"
                    fvd_def_method = "LUT"
                }
                [
                    position = 7832, 8048
                    size = 127, 256
                ]

                port DC+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7216, 7952
                ]

                port N {
                    position = right:4
                    kind = pe
                }
                [
                    position = 8568, 8392
                ]

                port DC- {
                    position = left:3
                    kind = pe
                }
                [
                    position = 7216, 8144
                ]

                port A {
                    position = right:1
                    kind = pe
                }
                [
                    position = 9272, 7952
                    rotation = down
                ]

                port B {
                    position = right:2
                    kind = pe
                }
                [
                    position = 9272, 8048
                    rotation = down
                ]

                port C {
                    position = right:3
                    kind = pe
                }
                [
                    position = 9272, 8144
                    rotation = down
                ]

                port Connect {
                    position = bottom:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 8496, 7808
                ]

                port "Sw enable" {
                    position = bottom:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7312, 8696
                ]

                port Flags {
                    position = bottom:4
                    kind = sp
                    direction =  in
                    sp_type {
                        default = inherit
                        readonly = True
                    }
                }
                [
                    position = 8664, 8600
                ]

                port Measurements {
                    position = bottom:3
                    kind = sp
                    direction =  in
                    sp_type {
                        default = inherit
                        readonly = True
                    }
                }
                [
                    position = 8768, 8816
                ]

                port m_a {
                    position = top:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7864
                ]

                port m_b {
                    position = top:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7800
                ]

                port m_c {
                    position = top:3
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7744
                ]

                tag Goto1 {
                    value = "precharge_enable"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8856, 7840
                    hide_name = True
                    size = 115, 20
                ]

                tag Goto2 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8048, 7904
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8048, 8008
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto4 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8040, 8104
                    hide_name = True
                    size = 60, 20
                ]

                tag From1 {
                    value = "Ia_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7520, 8416
                    hide_name = True
                    size = 60, 20
                ]

                tag From2 {
                    value = "Ib_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7520, 8448
                    hide_name = True
                    size = 60, 20
                ]

                tag From3 {
                    value = "Ic_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7520, 8480
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7400, 8000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7400, 8096
                    hide_name = True
                    size = 60, 20
                ]

                tag From4 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7448, 8624
                    hide_name = True
                    size = 60, 20
                ]

                tag From5 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7448, 8656
                    hide_name = True
                    size = 60, 20
                ]

                tag From6 {
                    value = "precharge_enable"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7952, 8592
                    hide_name = True
                    size = 95, 20
                ]

                tag Goto7 {
                    value = "enable"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8264, 8584
                    hide_name = True
                    size = 60, 20
                ]

                tag From8 {
                    value = "Precharge_completed"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8464, 8552
                    hide_name = True
                    size = 116, 20
                ]

                tag From9 {
                    value = "Current_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8464, 8600
                    hide_name = True
                    size = 116, 20
                ]

                tag From10 {
                    value = "Vdc_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8464, 8648
                    hide_name = True
                    size = 116, 20
                ]

                tag Goto8 {
                    value = "Current_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7984, 8472
                    hide_name = True
                    size = 165, 20
                ]

                tag Goto9 {
                    value = "Vdc_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7896, 8664
                    hide_name = True
                    size = 165, 20
                ]

                tag Goto10 {
                    value = "Precharge_completed"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8856, 7880
                    hide_name = True
                    size = 111, 20
                ]

                tag From11 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8704
                    hide_name = True
                    size = 60, 20
                ]

                tag From12 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8736
                    hide_name = True
                    size = 60, 20
                ]

                tag From13 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8768
                    hide_name = True
                    size = 60, 20
                ]

                tag From14 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8824
                    hide_name = True
                    size = 60, 20
                ]

                tag From15 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8856
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto11 {
                    value = "Ia_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8176, 7904
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto12 {
                    value = "Ib_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8208, 8008
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto13 {
                    value = "Ic_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8192, 8104
                    hide_name = True
                    size = 60, 20
                ]

                tag enable {
                    value = "enable"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7632, 7904
                    size = 0, 0
                ]

                junction Junction8 pe
                [
                    position = 8792, 8048
                ]

                junction Junction9 pe
                [
                    position = 8752, 8144
                ]

                junction Junction15 pe
                [
                    position = 9144, 8144
                ]

                junction Junction16 pe
                [
                    position = 9104, 8048
                ]

                junction Junction17 pe
                [
                    position = 9064, 7952
                ]

                junction Junction18 pe
                [
                    position = 8616, 8336
                ]

                junction Junction19 pe
                [
                    position = 7520, 8048
                ]

                junction Junction22 pe
                [
                    position = 7320, 7952
                ]

                junction Junction24 pe
                [
                    position = 7320, 8048
                ]

                junction Junction25 pe
                [
                    position = 7320, 8144
                ]

                junction Junction32 sp
                [
                    position = 7384, 8696
                ]

                junction Junction34 sp
                [
                    position = 7776, 8664
                ]

                junction Junction35 sp
                [
                    position = 8776, 7840
                ]

                junction Junction39 sp
                [
                    position = 7848, 8472
                ]

                junction Junction40 sp
                [
                    position = 7384, 8696
                ]

                junction Junction41 sp
                [
                    position = 7968, 7904
                ]

                junction Junction42 pe
                [
                    position = 8832, 7952
                ]

                junction Junction43 pe
                [
                    position = 8616, 8048
                ]

                junction Junction44 pe
                [
                    position = 8712, 8144
                ]

                junction Junction45 pe
                [
                    position = 8520, 7952
                ]

                junction Junction46 sp
                [
                    position = 7968, 8008
                ]

                junction Junction47 sp
                [
                    position = 7968, 8104
                ]

                junction Junction52 pe
                [
                    position = 8616, 8336
                ]

                junction Junction56 pe
                [
                    position = 8504, 8336
                ]

                junction Junction57 pe
                [
                    position = 7520, 8048
                ]

                junction Junction54 pe
                [
                    position = 7520, 7952
                ]

                junction Junction55 pe
                [
                    position = 7520, 8144
                ]

                connect R1.n_node S2.a_in as Connection32
                connect S1.b_in Junction8 as Connection36
                connect S1.c_in Junction9 as Connection39
                connect S2.b_in R2.n_node as Connection42
                connect R2.p_node Junction8 as Connection43
                connect S2.c_in R3.n_node as Connection44
                connect R3.p_node Junction9 as Connection45
                connect S1.c_out Junction15 as Connection70
                connect Junction15 S2.c_out as Connection71
                [
                    position = 0, 0
                    breakpoints = 9144, 8144; 9144, 8432
                ]
                connect C Junction15 as Connection72
                connect S1.b_out Junction16 as Connection73
                connect Junction16 S2.b_out as Connection74
                [
                    position = 0, 0
                    breakpoints = 9104, 8048; 9104, 8336
                ]
                connect B Junction16 as Connection75
                connect S2.a_out Junction17 as Connection76
                connect Junction17 S1.a_out as Connection77
                connect A Junction17 as Connection78
                connect Cdc-.p_node Junction19 as Connection87
                connect Junction19 Cdc+.n_node as Connection88
                [
                    position = 0, 0
                    breakpoints = 7520, 8048
                ]
                connect DC+ Junction22 as Connection96
                connect Vdc+.p_node Junction22 as Connection98
                connect Vdc+.n_node Junction24 as Connection102
                connect Vdc-.p_node Junction24 as Connection104
                connect DC- Junction25 as Connection105
                connect Vdc-.n_node Junction25 as Connection107
                connect Connect Pre-charge.Connect_in as Connection127
                connect Pre-charge.precharge_contactor S2.ctrl_in as Connection128
                connect Pre-charge.main_contactor S1.ctrl_in as Connection129
                connect Goto5 Vdc+.out as Connection143
                connect Goto6 Vdc-.out as Connection144
                connect Sum1.out "DC Voltage limit.Vdc" as Connection145
                connect From4 Sum1.in as Connection146
                connect From5 Sum1.in1 as Connection147
                connect From6 "Enable inverter.precharge_en" as Connection154
                connect "DC Voltage limit.sw_enable" Junction32 as Connection155
                connect "Enable inverter.sw_enable" Junction32 as Connection157
                [
                    position = 0, 0
                    breakpoints = 8032, 8608; 8032, 8768; 8032, 8768; 7584, 8768
                ]
                connect Goto7 "Enable inverter.enable" as Connection158
                connect La.p_node Ia.n_node as Connection163
                connect Ib.n_node Lb.p_node as Connection166
                connect Lc.p_node Ic.n_node as Connection167
                connect Flags "Bus Join1.out" as Connection169
                connect From8 "Bus Join1.in" as Connection170
                connect "Bus Join1.in1" From9 as Connection171
                connect From10 "Bus Join1.in2" as Connection172
                connect "DC Voltage limit.limit_exceeded" Junction34 as Connection179
                connect Junction34 "Enable inverter.vdc_lim" as Connection180
                [
                    position = 0, 0
                    breakpoints = 7776, 8664
                ]
                connect Goto9 Junction34 as Connection181
                connect Pre-charge.inv_enable Junction35 as Connection182
                connect Junction35 Goto1 as Connection183
                [
                    position = 0, 0
                    breakpoints = 8776, 7840
                ]
                connect Goto10 Junction35 as Connection184
                connect "Enable inverter.current_lim" Junction39 as Connection212
                connect Junction39 Goto8 as Connection213
                [
                    position = 0, 0
                    breakpoints = 7848, 8472
                ]
                connect "Current limit.limit_exceeded" Junction39 as Connection214
                connect Junction32 Junction40 as Connection216
                connect Junction40 "Sw enable" as Connection217
                [
                    position = 0, 0
                    breakpoints = 7384, 8696; 7384, 8696; 7384, 8696; 7384, 8696
                ]
                connect "Current limit.sw_enable" Junction40 as Connection218
                connect From11 "Bus Join2.in" as Connection234
                connect From12 "Bus Join2.in1" as Connection235
                [
                    position = 0, 0
                    breakpoints = 8560, 8736; 8560, 8768
                ]
                connect From13 "Bus Join2.in2" as Connection236
                [
                    position = 0, 0
                    breakpoints = 8544, 8768; 8544, 8784
                ]
                connect Measurements "Bus Join2.out" as Connection239
                connect La.n_node R4.p_node as Connection258
                connect Lb.n_node R5.p_node as Connection260
                connect Lc.n_node R6.p_node as Connection262
                connect Ca.n_node R7.p_node as Connection264
                connect Junction18 R8.n_node as Connection266
                connect R8.p_node Cb.n_node as Connection267
                connect Cc.n_node R9.p_node as Connection268
                connect Ia.out Junction41 as Connection298
                connect Junction41 Goto2 as Connection299
                connect "RMS value1.in" Junction41 as Connection300
                connect R1.p_node Junction42 as Connection302
                connect Junction42 S1.a_in as Connection303
                [
                    position = 0, 0
                    breakpoints = 8832, 7952
                ]
                connect Junction8 Junction43 as Connection305
                [
                    position = 0, 0
                    breakpoints = 8792, 8048; 8792, 8048; 8792, 8048
                ]
                connect Junction43 Cb.p_node as Connection306
                connect Junction9 Junction44 as Connection308
                connect Junction44 Cc.p_node as Connection309
                connect Junction45 Junction42 as Connection312
                connect Ca.p_node Junction45 as Connection313
                [
                    position = 0, 0
                    breakpoints = 8520, 8160; 8520, 7952
                ]
                connect "RMS value2.out" Goto12 as Connection314
                [
                    position = 0, 0
                    breakpoints = 8168, 8008
                ]
                connect Ib.out Junction46 as Connection315
                connect Junction46 Goto3 as Connection316
                connect "RMS value2.in" Junction46 as Connection317
                connect "RMS value3.out" Goto13 as Connection318
                connect Ic.out Junction47 as Connection319
                connect Junction47 Goto4 as Connection320
                connect "RMS value3.in" Junction47 as Connection321
                [
                    position = 0, 0
                    breakpoints = 8088, 8088; 7968, 8088
                ]
                connect "RMS value1.out" Goto11 as Connection325
                [
                    position = 0, 0
                    breakpoints = 8128, 7872
                ]
                connect "Current limit.ia_rms" From1 as Connection335
                [
                    position = 0, 0
                    breakpoints = 7584, 8416
                ]
                connect "Current limit.ib_rms" From2 as Connection336
                [
                    position = 0, 0
                    breakpoints = 7576, 8464; 7576, 8448; 7576, 8448
                ]
                connect From3 "Current limit.ic_rms" as Connection337
                [
                    position = 0, 0
                    breakpoints = 7520, 8480; 7576, 8480
                ]
                connect R9.n_node Junction18 as Connection339
                [
                    position = 0, 0
                    breakpoints = 8712, 8336; 8616, 8336; 8616, 8328
                ]
                connect Junction52 Junction18 as Connection355
                connect N Junction52 as Connection356
                connect Junction43 R5.n_node as Connection439
                [
                    position = 0, 0
                    breakpoints = 8616, 8048; 8336, 8048
                ]
                connect R4.n_node Junction45 as Connection438
                [
                    position = 0, 0
                    breakpoints = 8296, 7952; 8264, 7952; 8520, 7952
                ]
                connect R6.n_node Junction44 as Connection437
                [
                    position = 0, 0
                    breakpoints = 8208, 8144; 8424, 8144; 8448, 8144
                ]
                connect From14 "Bus Join2.in3" as Connection441
                connect From15 "Bus Join2.in4" as Connection442
                connect Junction54 "Three Phase Inverter1.pos_out" as Connection443
                connect "Three Phase Inverter1.neg_out" Junction55 as Connection444
                connect Junction52 Junction56 as Connection446
                [
                    position = 0, 0
                    breakpoints = 8616, 8336; 8616, 8336; 8616, 8336
                ]
                connect Junction56 R7.n_node as Connection447
                [
                    position = 0, 0
                    breakpoints = 8512, 8336; 8520, 8336; 8520, 8336
                ]
                connect SC.p_node Junction56 as Connection448
                connect Junction19 Junction57 as Connection449
                connect Junction57 Junction24 as Connection450
                [
                    position = 0, 0
                    breakpoints = 7520, 8048; 7520, 8048; 7520, 8048; 7520, 8048; 7320, 8048; 7320, 8048; 7320, 8048
                ]
                connect SC.n_node Junction57 as Connection451
                [
                    position = 0, 0
                    breakpoints = 7640, 8336; 7640, 8048
                ]
                connect "Three Phase Inverter1.a_in" Ia.p_node as Connection377
                connect Ib.p_node "Three Phase Inverter1.b_in" as Connection378
                connect "Three Phase Inverter1.c_in" Ic.p_node as Connection379
                connect Junction22 Junction54 as Connection380
                [
                    position = 0, 0
                    breakpoints = 7320, 7952
                ]
                connect Junction54 Cdc+.p_node as Connection381
                [
                    position = 0, 0
                    breakpoints = 7520, 7952
                ]
                connect Junction25 Junction55 as Connection383
                [
                    position = 0, 0
                    breakpoints = 7320, 8144
                ]
                connect Junction55 Cdc-.n_node as Connection384
                [
                    position = 0, 0
                    breakpoints = 7520, 8144
                ]
                connect m_a "Three Phase Inverter1.InA" as Con_ma
                connect m_b "Three Phase Inverter1.InB" as Con_mb
                connect m_c "Three Phase Inverter1.InC" as Con_mc
                connect enable "Three Phase Inverter1.En" as Con_en_inv

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">3p3w Supplier Inverter - Hardware model.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">          Nameplate information</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Power: 7.5 kVA (3ph)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Dc Link: 500 Vdc (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Voltage: 0 - 380 V (Line)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Current: 20 A (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Frequency: 30 - 150 Hz</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Switching Frequency: 20 kHz (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Flags: 1- precharge_completed; 2- current_limit_exceeded; 3- vdc_limit_exceeded.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Measurements: 1- Ia; 2- Ib; 3- Ic; 4- In; 5- Va; 6- Vb; 7- Vc; 8- Vdc+; 9- Vdc- </p></body></html>"

                    curr_limit {
                        label = "Current limit"
                        widget = edit
                        type = generic
                        default_value = "20"
                        unit = "Arms"
                        group = "Protection:3"
                    }

                    vdc_limit {
                        label = "DC voltage Limit"
                        widget = edit
                        type = generic
                        default_value = "550"
                        unit = "V"
                        group = "Protection"
                    }

                    en_current_protection {
                        label = "Enable current protection"
                        widget = checkbox
                        type = bool
                        default_value = "True"
                        group = "Protection"
                        no_evaluate

                        CODE property_value_changed
                            if new_value:
                                en_i_protection = 1
                            else:
                                en_i_protection = 0
                        ENDCODE
                    }

                    en_vdc_protection {
                        label = "Enable DC voltage protection"
                        widget = checkbox
                        type = bool
                        default_value = "True"
                        group = "Protection"
                        no_evaluate

                        CODE property_value_changed
                            if new_value:
                                en_v_protection = 1
                            else:
                                en_v_protection = 0
                        ENDCODE
                    }

                    ctrl_mode {
                        label = "Control mode"
                        widget = combo
                        combo_values = "Internal modulator", "Digital input per switch"
                        type = string
                        default_value = "Internal modulator"
                        group = "General:1"
                        no_evaluate

                        CODE property_value_changed
                            control_mode(mdl, container_handle, new_value)
                        ENDCODE

                        CODE property_value_edited
                            control_mode(mdl, container_handle, new_value)
                        ENDCODE
                    }

                    fcarr {
                        label = "Carrier frequency"
                        widget = edit
                        type = generic
                        default_value = "20000"
                        unit = "Hz"
                        group = "General"
                        no_evaluate
                    }

                    dt {
                        label = "Inverter deadtime"
                        widget = combo
                        combo_values = "0.5e-6", "0.6e-6", "0.7e-6", "0.8e-6", "1.0e-6", "1.1e-6", "1.2e-6", "1.5e-6"
                        type = string
                        default_value = "0.5e-6"
                        unit = "s"
                        group = "General"
                        no_evaluate
                    }

                    Tex {
                        label = "Execution rate"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    sa_top {
                        label = "Sa top"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "1"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_top"), mdl.get_property_value(mdl.prop(container_handle, "sa_top")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_top"), mdl.get_property_value(mdl.prop(container_handle, "sa_top")))
                        ENDCODE
                    }

                    sa_bot {
                        label = "Sa bot"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "2"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_bot"), mdl.get_property_value(mdl.prop(container_handle, "sa_bot")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sa_bot"), mdl.get_property_value(mdl.prop(container_handle, "sa_bot")))
                        ENDCODE
                    }

                    sb_top {
                        label = "Sb top"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "3"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_top"), mdl.get_property_value(mdl.prop(container_handle, "sb_top")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_top"), mdl.get_property_value(mdl.prop(container_handle, "sb_top")))
                        ENDCODE
                    }

                    sb_bot {
                        label = "Sb bot"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "4"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_bot"), mdl.get_property_value(mdl.prop(container_handle, "sb_bot")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sb_bot"), mdl.get_property_value(mdl.prop(container_handle, "sb_bot")))
                        ENDCODE
                    }

                    sc_top {
                        label = "Sc top"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "5"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_top"), mdl.get_property_value(mdl.prop(container_handle, "sc_top")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_top"), mdl.get_property_value(mdl.prop(container_handle, "sc_top")))
                        ENDCODE
                    }

                    sc_bot {
                        label = "Sc bot"
                        widget = combo
                        combo_values = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64"
                        type = string
                        default_value = "6"
                        group = "General"
                        nonvisible
                        disabled
                        no_evaluate

                        CODE property_value_changed
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_bot"), mdl.get_property_value(mdl.prop(container_handle, "sc_bot")))
                        ENDCODE

                        CODE property_value_edited
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT
                            comp_handle = mdl.get_sub_level_handle(container_handle)
                            inverter = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            mdl.set_property_value(mdl.prop(inverter, "Sc_bot"), mdl.get_property_value(mdl.prop(container_handle, "sc_bot")))
                        ENDCODE
                    }

                    precharge_duration {
                        label = "Pre-charge duration"
                        widget = edit
                        type = generic
                        default_value = "0.5"
                        unit = "s"
                        group = "Pre-charge:2"
                    }

                    inv_enable_time {
                        label = "Inverter enable time"
                        widget = edit
                        type = generic
                        default_value = "1"
                        unit = "s"
                        group = "Pre-charge"
                    }

                    Rpc {
                        label = "Pre-charge resistor"
                        widget = edit
                        type = generic
                        default_value = "0.5"
                        unit = "Ohm"
                        group = "Pre-charge"
                    }

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE

                    CODE pre_compile
                        # HEADER START
                        curr_limit = mdl.get_property_value(mdl.prop(item_handle, "curr_limit"))
                        vdc_limit = mdl.get_property_value(mdl.prop(item_handle, "vdc_limit"))
                        en_current_protection = mdl.get_property_value(mdl.prop(item_handle, "en_current_protection"))
                        en_vdc_protection = mdl.get_property_value(mdl.prop(item_handle, "en_vdc_protection"))
                        ctrl_mode = mdl.get_property_value(mdl.prop(item_handle, "ctrl_mode"))
                        fcarr = mdl.get_property_value(mdl.prop(item_handle, "fcarr"))
                        dt = mdl.get_property_value(mdl.prop(item_handle, "dt"))
                        Tex = mdl.get_property_value(mdl.prop(item_handle, "Tex"))
                        sa_top = mdl.get_property_value(mdl.prop(item_handle, "sa_top"))
                        sa_bot = mdl.get_property_value(mdl.prop(item_handle, "sa_bot"))
                        sb_top = mdl.get_property_value(mdl.prop(item_handle, "sb_top"))
                        sb_bot = mdl.get_property_value(mdl.prop(item_handle, "sb_bot"))
                        sc_top = mdl.get_property_value(mdl.prop(item_handle, "sc_top"))
                        sc_bot = mdl.get_property_value(mdl.prop(item_handle, "sc_bot"))
                        precharge_duration = mdl.get_property_value(mdl.prop(item_handle, "precharge_duration"))
                        inv_enable_time = mdl.get_property_value(mdl.prop(item_handle, "inv_enable_time"))
                        Rpc = mdl.get_property_value(mdl.prop(item_handle, "Rpc"))
                        # HEADER STOP
                        fc = int(mdl.get_property_value(mdl.prop(item_handle, "fcarr")))
                        if fc > 20000: 
                            fc = 20000
                    ENDCODE

                    CODE init
                        def control_mode(mdl, mask_handle, new_value):
                            from typhoon.api.schematic_editor.const import ITEM_COMPONENT, ITEM_CONNECTION, ITEM_PORT, KIND_SP, DIRECTION_IN, DIRECTION_OUT, ITEM_TAG, TAG_SCOPE_LOCAL
                            
                            comp_handle = mdl.get_sub_level_handle(mask_handle)
                            inv = mdl.get_item("Three Phase Inverter1", parent=comp_handle, item_type=ITEM_COMPONENT)
                            
                            if new_value == "Internal modulator":
                                mdl.enable_property(mdl.prop(mask_handle, "fcarr"))
                                mdl.enable_property(mdl.prop(mask_handle, "dt"))
                                mdl.enable_property(mdl.prop(mask_handle, "Tex"))
                                mdl.show_property(mdl.prop(mask_handle, "fcarr"))
                                mdl.show_property(mdl.prop(mask_handle, "dt"))
                                mdl.show_property(mdl.prop(mask_handle, "Tex"))
                                mdl.disable_property(mdl.prop(mask_handle,"sa_top"))
                                mdl.disable_property(mdl.prop(mask_handle,"sa_bot"))
                                mdl.disable_property(mdl.prop(mask_handle,"sb_top"))
                                mdl.disable_property(mdl.prop(mask_handle,"sb_bot"))
                                mdl.disable_property(mdl.prop(mask_handle,"sc_top"))
                                mdl.disable_property(mdl.prop(mask_handle,"sc_bot"))
                                mdl.hide_property(mdl.prop(mask_handle,"sa_top"))
                                mdl.hide_property(mdl.prop(mask_handle,"sa_bot"))
                                mdl.hide_property(mdl.prop(mask_handle,"sb_top"))
                                mdl.hide_property(mdl.prop(mask_handle,"sb_bot"))
                                mdl.hide_property(mdl.prop(mask_handle,"sc_top"))
                                mdl.hide_property(mdl.prop(mask_handle,"sc_bot"))
                                
                                mdl.set_property_value(mdl.prop(inv, "ctrl_src"), new_value)
                                
                                ma = mdl.get_item("m_a", parent=comp_handle, item_type=ITEM_PORT)
                                mb = mdl.get_item("m_b", parent=comp_handle, item_type=ITEM_PORT)
                                mc = mdl.get_item("m_c", parent=comp_handle, item_type=ITEM_PORT)
                                enable_tag = mdl.get_item("enable", parent=comp_handle, item_type=ITEM_TAG)
                                if not ma:
                                    ma = mdl.create_port(name="m_a", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 1), position=(7775, 7862))
                                if not mb:
                                    mb = mdl.create_port(name="m_b", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 2), position=(7775, 7801))
                                if not mc:
                                    mc = mdl.create_port(name="m_c", parent=comp_handle, kind=KIND_SP, direction=DIRECTION_IN, terminal_position=('top', 3), position=(7775, 7740))
                                if not enable_tag:
                                    enable_tag = mdl.create_tag(name="enable", value="enable", parent=comp_handle, scope=TAG_SCOPE_LOCAL, kind=KIND_SP, direction=DIRECTION_OUT, position=(7630,7904))
                            
                                con_ma = mdl.get_item("Con_ma", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mb = mdl.get_item("Con_mb", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mc = mdl.get_item("Con_mc", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_en_inv = mdl.get_item("Con_en_inv", parent=comp_handle, item_type=ITEM_CONNECTION)
                                if not con_ma:
                                    con_ma = mdl.create_connection(ma, mdl.term(inv, "InA"), name="Con_ma")
                                if not con_mb:
                                    con_mb = mdl.create_connection(mb, mdl.term(inv, "InB"), name="Con_mb")
                                if not con_mc:
                                    con_mc = mdl.create_connection(mc, mdl.term(inv, "InC"), name="Con_mc")
                                if not con_en_inv:
                                    con_en_inv = mdl.create_connection(enable_tag, mdl.term(inv, "En"), name="Con_en_inv")
                                
                            else:
                                mdl.disable_property(mdl.prop(mask_handle, "fcarr"))
                                mdl.disable_property(mdl.prop(mask_handle, "dt"))
                                #mdl.disable_property(mdl.prop(mask_handle, "Tex"))
                                mdl.hide_property(mdl.prop(mask_handle, "fcarr"))
                                mdl.hide_property(mdl.prop(mask_handle, "dt"))
                                #mdl.hide_property(mdl.prop(mask_handle, "Tex"))
                                
                                mdl.enable_property(mdl.prop(mask_handle,"sa_top"))
                                mdl.enable_property(mdl.prop(mask_handle,"sa_bot"))
                                mdl.enable_property(mdl.prop(mask_handle,"sb_top"))
                                mdl.enable_property(mdl.prop(mask_handle,"sb_bot"))
                                mdl.enable_property(mdl.prop(mask_handle,"sc_top"))
                                mdl.enable_property(mdl.prop(mask_handle,"sc_bot"))
                                mdl.show_property(mdl.prop(mask_handle,"sa_top"))
                                mdl.show_property(mdl.prop(mask_handle,"sa_bot"))
                                mdl.show_property(mdl.prop(mask_handle,"sb_top"))
                                mdl.show_property(mdl.prop(mask_handle,"sb_bot"))
                                mdl.show_property(mdl.prop(mask_handle,"sc_top"))
                                mdl.show_property(mdl.prop(mask_handle,"sc_bot"))
                                
                                # Set default values
                                mdl.set_property_value(mdl.prop(mask_handle, "sa_top"), 1)
                                mdl.set_property_value(mdl.prop(mask_handle, "sa_bot"), 2)
                                mdl.set_property_value(mdl.prop(mask_handle, "sb_top"), 3)
                                mdl.set_property_value(mdl.prop(mask_handle, "sb_bot"), 4)
                                mdl.set_property_value(mdl.prop(mask_handle, "sc_top"), 5)
                                mdl.set_property_value(mdl.prop(mask_handle, "sc_bot"), 6)
                        
                                ma = mdl.get_item("m_a", parent=comp_handle, item_type=ITEM_PORT)
                                mb = mdl.get_item("m_b", parent=comp_handle, item_type=ITEM_PORT)
                                mc = mdl.get_item("m_c", parent=comp_handle, item_type=ITEM_PORT)
                                enable_tag = mdl.get_item("enable", parent=comp_handle, item_type=ITEM_TAG)
                                con_ma = mdl.get_item("Con_ma", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mb = mdl.get_item("Con_mb", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_mc = mdl.get_item("Con_mc", parent=comp_handle, item_type=ITEM_CONNECTION)
                                con_en_inv = mdl.get_item("Con_en_inv", parent=comp_handle, item_type=ITEM_CONNECTION)
                                
                                if con_ma:
                                    mdl.delete_item(con_ma)
                                if con_mb:
                                    mdl.delete_item(con_mb)
                                if con_mc:
                                    mdl.delete_item(con_mc)
                                if con_en_inv:
                                    mdl.delete_item(con_en_inv)
                                if ma:
                                    mdl.delete_item(ma)
                                if mb:
                                    mdl.delete_item(mb)
                                if mc:
                                    mdl.delete_item(mc)
                                if enable_tag:
                                    mdl.delete_item(enable_tag)
                                
                                mdl.set_property_value(mdl.prop(inv, "ctrl_src"), new_value)
                    ENDCODE

                    CODE post_resolve
                    ENDCODE

                    CODE define_icon
                        image('Figures\supplier_3p3w.png')
                    ENDCODE
                }
            }
            [
                position = 5760, 7912
                size = 248, 296
            ]
        }
        [
            position = 4456, 4288
            size = 48, 48
        ]

        component Subsystem JUNXY {
            layout = dynamic
            component pas_resistor RA {
                resistance = "52900.0"
            }
            [
                position = 7744, 8192
                rotation = right
            ]

            component pas_resistor RB {
                resistance = "52900.0"
            }
            [
                position = 8088, 8192
                rotation = right
            ]

            component pas_resistor RC {
                resistance = "52900.0"
            }
            [
                position = 8440, 8192
                rotation = right
            ]

            port A {
                position = right:1
                kind = pe
            }
            [
                position = 7744, 8096
                rotation = right
            ]

            port B {
                position = right:2
                kind = pe
            }
            [
                position = 8184, 8096
                rotation = right
            ]

            port C {
                position = right:3
                kind = pe
            }
            [
                position = 8536, 8096
                rotation = right
            ]

            port N {
                position = right:4
                kind = pe
            }
            [
                position = 8184, 8296
                rotation = left
            ]

            connect RA.p_node A as con_RA_ph
            connect RA.n_node N as con_RA_n
            connect RB.p_node B as con_RB_ph
            connect RB.n_node N as con_RB_n
            connect RC.p_node C as con_RC_ph
            connect RC.n_node N as con_RC_n

            mask {
                description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">15-kW 15-kVA Passive Load.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Parameter values can be entered either in terms of power or impedance. In power mode, 230Vrms (phase) and 50Hz are considered for R, L and C calculations.  </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Power values must be limited to 5kW / 5kVA per phase.  </p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                mode {
                    label = "Parameters mode"
                    widget = combo
                    combo_values = "Power mode", "Impedance mode"
                    type = string
                    default_value = "Power mode"
                    group = "General:1"
                    no_evaluate

                    CODE property_value_changed
                        select_mode_set_balanced(mdl, container_handle)
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE

                    CODE property_value_edited
                        select_mode_set_balanced(mdl, container_handle)
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                balanced {
                    label = "Balanced 3ph"
                    widget = checkbox
                    type = bool
                    default_value = "True"
                    group = "General"
                    no_evaluate

                    CODE property_value_changed
                        select_mode_set_balanced(mdl, container_handle)
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE

                    CODE property_value_edited
                        select_mode_set_balanced(mdl, container_handle)
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                R_a_pow {
                    label = "R"
                    widget = edit
                    type = generic
                    default_value = "1"
                    unit = "W"
                    group = "Phase A:2"

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                L_a_pow {
                    label = "L"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "VAr"
                    group = "Phase A"

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                C_a_pow {
                    label = "C"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "VAr"
                    group = "Phase A"

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                R_a_imp {
                    label = "R"
                    widget = edit
                    type = generic
                    default_value = "1"
                    unit = "Ohm"
                    group = "Phase A"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                L_a_imp {
                    label = "L"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "H"
                    group = "Phase A"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                C_a_imp {
                    label = "C"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "F"
                    group = "Phase A"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                R_b_pow {
                    label = "R"
                    widget = edit
                    type = generic
                    default_value = "1"
                    unit = "W"
                    group = "Phase B:3"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                L_b_pow {
                    label = "L"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "VAr"
                    group = "Phase B"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                C_b_pow {
                    label = "C"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "VAr"
                    group = "Phase B"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                R_b_imp {
                    label = "R"
                    widget = edit
                    type = generic
                    default_value = "1"
                    unit = "Ohm"
                    group = "Phase B"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                L_b_imp {
                    label = "L"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "H"
                    group = "Phase B"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                C_b_imp {
                    label = "C"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "F"
                    group = "Phase B"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                R_c_pow {
                    label = "R"
                    widget = edit
                    type = generic
                    default_value = "1"
                    unit = "W"
                    group = "Phase C:4"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                L_c_pow {
                    label = "L"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "VAr"
                    group = "Phase C"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                C_c_pow {
                    label = "C"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "VAr"
                    group = "Phase C"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                R_c_imp {
                    label = "R"
                    widget = edit
                    type = generic
                    default_value = "1"
                    unit = "Ohm"
                    group = "Phase C"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                L_c_imp {
                    label = "L"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "H"
                    group = "Phase C"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                C_c_imp {
                    label = "C"
                    widget = edit
                    type = generic
                    default_value = "0"
                    unit = "F"
                    group = "Phase C"
                    disabled

                    CODE property_value_changed
                        nom_voltage = 230
                        nom_freq = 50
                        value = set_values(mdl, container_handle, nom_voltage, nom_freq)
                        create_circuit(mdl, container_handle, value)
                    ENDCODE
                }

                CODE open
                    from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                
                    dialog = RegularComponentPropertiesDialog(
                        component=component,
                        property_container=component.masks[-1],
                        current_diagram=current_diagram
                    )
                    dialog.exec_()
                    
                ENDCODE

                CODE init
                    def select_mode_set_balanced(mdl, mask_handle):
                        balanced = mdl.get_property_disp_value(mdl.prop(mask_handle, "balanced"))
                        mode = mdl.get_property_disp_value(mdl.prop(mask_handle, "mode"))
                        
                        if balanced and mode == "Impedance mode":
                            mdl.disable_property(mdl.prop(mask_handle, "R_a_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_a_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_a_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_c_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_c_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_c_pow"))
                            
                            mdl.enable_property(mdl.prop(mask_handle, "R_a_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_a_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_a_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_c_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_c_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_c_imp"))
                        
                        if balanced and mode == "Power mode":
                            mdl.disable_property(mdl.prop(mask_handle, "R_a_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_a_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_a_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_c_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_c_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_c_imp"))
                            
                            mdl.enable_property(mdl.prop(mask_handle, "R_a_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_a_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_a_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_c_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_c_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_c_pow"))
                            
                        if not balanced and mode == "Impedance mode":
                            mdl.disable_property(mdl.prop(mask_handle, "R_a_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_a_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_a_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_b_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_c_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_c_pow"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_c_pow"))
                            
                            mdl.enable_property(mdl.prop(mask_handle, "R_a_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_a_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_a_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "R_b_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_b_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_b_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "R_c_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_c_imp"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_c_imp"))
                            
                        if not balanced and mode == "Power mode":
                            mdl.enable_property(mdl.prop(mask_handle, "R_a_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_a_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_a_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "R_b_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_b_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_b_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "R_c_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "L_c_pow"))
                            mdl.enable_property(mdl.prop(mask_handle, "C_c_pow"))
                            
                            mdl.disable_property(mdl.prop(mask_handle, "R_a_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_a_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_a_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_b_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "R_c_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "L_c_imp"))
                            mdl.disable_property(mdl.prop(mask_handle, "C_c_imp"))
                            
                    def set_values(mdl, mask_handle, nominal_voltage, nominal_frequency):
                        
                        balanced = mdl.get_property_disp_value(mdl.prop(mask_handle, "balanced"))
                        mode = mdl.get_property_disp_value(mdl.prop(mask_handle, "mode"))
                        
                        if balanced and mode == "Impedance mode":
                            Ra = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "R_a_imp")))
                            Rb = Ra
                            Rc = Ra
                            La = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "L_a_imp")))
                            Lb = La
                            Lc = La
                            Ca = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "C_a_imp")))
                            Cb = Ca
                            Cc = Ca
                        if balanced and mode == "Power mode":
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_a_pow")))):
                                Ra = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_a_pow"))))
                            else:
                                Ra = 0
                            Rb = Ra
                            Rc = Ra
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_a_pow")))):
                                La = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_a_pow"))))/2/np.pi/nominal_frequency
                            else:
                                La = 0
                            Lb = La
                            Lc = La
                            Ca = int((mdl.get_property_disp_value(mdl.prop(mask_handle, "C_a_pow"))))/2/np.pi/nominal_frequency/(nominal_voltage**2)
                            Cb = Ca
                            Cc = Ca
                        if not balanced and mode == "Impedance mode":
                            Ra = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "R_a_imp")))
                            Rb = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "R_b_imp")))
                            Rc = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "R_c_imp")))
                            La = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "L_a_imp")))
                            Lb = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "L_b_imp")))
                            Lc = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "L_c_imp")))
                            Ca = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "C_a_imp")))
                            Cb = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "C_b_imp")))
                            Cc = int(mdl.get_property_disp_value(mdl.prop(mask_handle, "C_c_imp")))
                        if not balanced and mode == "Power mode":
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_a_pow")))):
                                Ra = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_a_pow"))))
                            else: 
                                Ra = 0
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_b_pow")))):
                                Rb = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_b_pow"))))
                            else:
                                Rb = 0
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_c_pow")))):
                                Rc = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "R_c_pow"))))
                            else:
                                Rc = 0
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_a_pow")))):
                                La = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_a_pow"))))/2/np.pi/nominal_frequency
                            else:
                                La = 0
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_b_pow")))):
                                Lb = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_b_pow"))))/2/np.pi/nominal_frequency
                            else:
                                Lb = 0
                            if int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_c_pow")))):
                                Lc = (nominal_voltage**2)/int((mdl.get_property_disp_value(mdl.prop(mask_handle, "L_c_pow"))))/2/np.pi/nominal_frequency
                            else: 
                                Lc = 0
                            Ca = int((mdl.get_property_disp_value(mdl.prop(mask_handle, "C_a_pow"))))/2/np.pi/nominal_frequency/(nominal_voltage**2)
                            Cb = int((mdl.get_property_disp_value(mdl.prop(mask_handle, "C_b_pow"))))/2/np.pi/nominal_frequency/(nominal_voltage**2)
                            Cc = int((mdl.get_property_disp_value(mdl.prop(mask_handle, "C_c_pow"))))/2/np.pi/nominal_frequency/(nominal_voltage**2)
                        
                        return [Ra, Rb, Rc, La, Lb, Lc, Ca, Cb, Cc]
                        
                    def create_circuit(mdl, mask_handle, values):
                        from typhoon.api.schematic_editor.const import ITEM_COMPONENT, ITEM_CONNECTION, ITEM_PORT, KIND_SP, DIRECTION_IN
                        
                        comp_handle = mdl.get_sub_level_handle(mask_handle)
                        RA = mdl.get_item(name="RA", parent=comp_handle, item_type=ITEM_COMPONENT)
                        RB = mdl.get_item(name="RB", parent=comp_handle, item_type=ITEM_COMPONENT)
                        RC = mdl.get_item(name="RC", parent=comp_handle, item_type=ITEM_COMPONENT)
                        LA = mdl.get_item(name="LA", parent=comp_handle, item_type=ITEM_COMPONENT)
                        LB = mdl.get_item(name="LB", parent=comp_handle, item_type=ITEM_COMPONENT)
                        LC = mdl.get_item(name="LC", parent=comp_handle, item_type=ITEM_COMPONENT)
                        CA = mdl.get_item(name="CA", parent=comp_handle, item_type=ITEM_COMPONENT)
                        CB = mdl.get_item(name="CB", parent=comp_handle, item_type=ITEM_COMPONENT)
                        CC = mdl.get_item(name="CC", parent=comp_handle, item_type=ITEM_COMPONENT)
                        port_A = mdl.get_item(name="A", parent=comp_handle, item_type=ITEM_PORT)
                        port_B = mdl.get_item(name="B", parent=comp_handle, item_type=ITEM_PORT)
                        port_C = mdl.get_item(name="C", parent=comp_handle, item_type=ITEM_PORT)
                        port_N = mdl.get_item(name="N", parent=comp_handle, item_type=ITEM_PORT)
                        con_RA_ph = mdl.get_item(name="con_RA_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_RA_n = mdl.get_item(name="con_RA_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_RB_ph = mdl.get_item(name="con_RB_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_RB_n = mdl.get_item(name="con_RB_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_RC_ph = mdl.get_item(name="con_RC_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_RC_n = mdl.get_item(name="con_RC_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_LA_ph = mdl.get_item(name="con_LA_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_LA_n = mdl.get_item(name="con_LA_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_LB_ph = mdl.get_item(name="con_LB_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_LB_n = mdl.get_item(name="con_LB_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_LC_ph = mdl.get_item(name="con_LC_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_LC_n = mdl.get_item(name="con_LC_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_CA_ph = mdl.get_item(name="con_CA_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_CA_n = mdl.get_item(name="con_CA_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_CB_ph = mdl.get_item(name="con_CB_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_CB_n = mdl.get_item(name="con_CB_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_CC_ph = mdl.get_item(name="con_CC_ph", parent=comp_handle, item_type=ITEM_CONNECTION)
                        con_CC_n = mdl.get_item(name="con_CC_n", parent=comp_handle, item_type=ITEM_CONNECTION)
                        
                        if values[0]:
                            if not RA:
                                RA = mdl.create_component("Resistor", parent=comp_handle, name="RA", rotation="right", position=(7744,8193))
                                mdl.set_property_value(mdl.prop(RA, "resistance"), values[0])
                                con_RA_ph = mdl.create_connection(mdl.term(RA, "p_node"),port_A, name="con_RA_ph"),
                                con_RA_n = mdl.create_connection(mdl.term(RA, "n_node"),port_N, name="con_RA_n")
                            else:
                                mdl.set_property_value(mdl.prop(RA, "resistance"), values[0]) 
                        else:
                            if con_RA_ph:
                                mdl.delete_item(con_RA_ph)
                            if con_RA_n:
                                mdl.delete_item(con_RA_n)
                            if RA:
                                mdl.delete_item(RA)
                                
                        if values[1]:
                            if not RB:
                                RB = mdl.create_component("Resistor", parent=comp_handle, name="RB", rotation="right", position=(8089,8193))
                                mdl.set_property_value(mdl.prop(RB, "resistance"), values[1])
                                con_RB_ph = mdl.create_connection(mdl.term(RB, "p_node"),port_B, name="con_RB_ph")
                                con_RB_n = mdl.create_connection(mdl.term(RB, "n_node"),port_N, name="con_RB_n")
                            else:
                                mdl.set_property_value(mdl.prop(RB, "resistance"), values[1]) 
                        else:
                            if con_RB_ph:
                                mdl.delete_item(con_RB_ph)
                            if con_RB_n:
                                mdl.delete_item(con_RB_n)
                            if RB:
                                mdl.delete_item(RB)
                                
                        if values[2]:
                            if not RC:
                                RC = mdl.create_component("Resistor", parent=comp_handle, name="RC", rotation="right", position=(8440,8193))
                                mdl.set_property_value(mdl.prop(RC, "resistance"), values[2])
                                con_RC_ph = mdl.create_connection(mdl.term(RC, "p_node"),port_C, name="con_RC_ph")
                                con_RC_n = mdl.create_connection(mdl.term(RC, "n_node"),port_N, name="con_RC_n")
                            else:
                                mdl.set_property_value(mdl.prop(RC, "resistance"), values[2]) 
                        else:
                            if con_RC_ph:
                                mdl.delete_item(con_RC_ph)
                            if con_RC_n:
                                mdl.delete_item(con_RC_n)
                            if RC:
                                mdl.delete_item(RC)
                                
                        if values[3]:
                            if not LA:
                                LA = mdl.create_component("Inductor", parent=comp_handle, name="LA", rotation="right", position=(7841,8193))
                                mdl.set_property_value(mdl.prop(LA, "inductance"), values[3])
                                con_LA_ph = mdl.create_connection(mdl.term(LA, "p_node"),port_A, name="con_LA_ph")
                                con_LA_n = mdl.create_connection(mdl.term(LA, "n_node"),port_N, name="con_LA_n")
                            else:
                                mdl.set_property_value(mdl.prop(LA, "inductance"), values[3]) 
                        else:
                            if con_LA_ph:
                                mdl.delete_item(con_LA_ph)
                            if con_LA_n:
                                mdl.delete_item(con_LA_n)
                            if LA:
                                mdl.delete_item(LA)
                        
                        if values[4]:
                            if not LB:
                                LB = mdl.create_component("Inductor", parent=comp_handle, name="LB", rotation="right", position=(8184,8193))
                                mdl.set_property_value(mdl.prop(LB, "inductance"), values[4])
                                con_LB_ph = mdl.create_connection(mdl.term(LB, "p_node"),port_B, name="con_LB_ph")
                                con_LB_n = mdl.create_connection(mdl.term(LB, "n_node"),port_N, name="con_LB_n")
                            else:
                                mdl.set_property_value(mdl.prop(LB, "inductance"), values[4]) 
                        else:
                            if con_LB_ph:
                                mdl.delete_item(con_LB_ph)
                            if con_LB_n:
                                mdl.delete_item(con_LB_n)
                            if LB:
                                mdl.delete_item(LB)
                                
                        if values[5]:
                            if not LC:
                                LC = mdl.create_component("Inductor", parent=comp_handle, name="LC", rotation="right", position=(8535,8193))
                                mdl.set_property_value(mdl.prop(LC, "inductance"), values[5])
                                con_LC_ph = mdl.create_connection(mdl.term(LC, "p_node"),port_C, name="con_LC_ph")
                                con_LC_n = mdl.create_connection(mdl.term(LC, "n_node"),port_N, name="con_LC_n")
                            else:
                                mdl.set_property_value(mdl.prop(LC, "inductance"), values[5]) 
                        else:
                            if con_LC_ph:
                                mdl.delete_item(con_LC_ph)
                            if con_LC_n:
                                mdl.delete_item(con_LC_n)
                            if LC:
                                mdl.delete_item(LC)
                                
                        if values[6]:
                            if not CA:
                                CA = mdl.create_component("Capacitor", parent=comp_handle, name="CA", rotation="right", position=(7944,8193))
                                mdl.set_property_value(mdl.prop(CA, "capacitance"), values[6])
                                con_CA_ph = mdl.create_connection(mdl.term(CA, "p_node"),port_A, name="con_CA_ph")
                                con_CA_n = mdl.create_connection(mdl.term(CA, "n_node"),port_N, name="con_CA_n")
                            else:
                                mdl.set_property_value(mdl.prop(CA, "capacitance"), values[6]) 
                        else:
                            if con_CA_ph:
                                mdl.delete_item(con_CA_ph)
                            if con_CA_n:
                                mdl.delete_item(con_CA_n)
                            if CA:
                                mdl.delete_item(CA)
                                
                        if values[7]:
                            if not CB:
                                CB = mdl.create_component("Capacitor", parent=comp_handle, name="CB", rotation="right", position=(8287,8193))
                                mdl.set_property_value(mdl.prop(CB, "capacitance"), values[7])
                                con_CB_ph = mdl.create_connection(mdl.term(CB, "p_node"),port_B, name="con_CB_ph")
                                con_CB_n = mdl.create_connection(mdl.term(CB, "n_node"),port_N, name="con_CB_n")
                            else:
                                mdl.set_property_value(mdl.prop(CB, "capacitance"), values[7]) 
                        else:
                            if con_CB_ph:
                                mdl.delete_item(con_CB_ph)
                            if con_CB_n:
                                mdl.delete_item(con_CB_n)
                            if CB:
                                mdl.delete_item(CB)
                                
                        if values[8]:
                            if not CC:
                                CC = mdl.create_component("Capacitor", parent=comp_handle, name="CC", rotation="right", position=(8641,8193))
                                mdl.set_property_value(mdl.prop(CC, "capacitance"), values[8])
                                con_CC_ph = mdl.create_connection(mdl.term(CC, "p_node"),port_C, name="con_CC_ph")
                                con_CC_n = mdl.create_connection(mdl.term(CC, "n_node"),port_N, name="con_CC_n")
                            else:
                                mdl.set_property_value(mdl.prop(CC, "capacitance"), values[8]) 
                        else:
                            if con_CC_ph:
                                mdl.delete_item(con_CC_ph)
                            if con_CC_n:
                                mdl.delete_item(con_CC_n)
                            if CC:
                                mdl.delete_item(CC)
                ENDCODE

                CODE pre_compile
                ENDCODE

                CODE define_icon
                    image('Figures\junxy.png')
                ENDCODE
            }
        }
        [
            position = 4608, 4392
            size = 144, 256
        ]

        component Category Legacy {
            layout = dynamic
            component Subsystem "Supplier Inverter 3p3w (legacy)" {
                layout = dynamic
                component "core/Three Phase Inverter" "Three Phase Inverter1" {
                    carrier_freq = "fc"
                    ctrl_src = "Internal modulator"
                    d_time = "dt"
                    execution_rate = "Tex"
                    fvd_def_method = "LUT"
                }
                [
                    position = 7824, 8048
                    size = 127, 256
                ]

                component pas_capacitor Cdc+ {
                    capacitance = "2.72e-3"
                }
                [
                    position = 7568, 8000
                    rotation = right
                ]

                component pas_capacitor Cdc- {
                    capacitance = "2.72e-3"
                }
                [
                    position = 7568, 8096
                    rotation = right
                ]

                component pas_capacitor Ca {
                    capacitance = "5e-6"
                }
                [
                    position = 8336, 8200
                    rotation = right
                ]

                component pas_capacitor Cb {
                    capacitance = "5e-6"
                }
                [
                    position = 8432, 8200
                    rotation = right
                ]

                component pas_capacitor Cc {
                    capacitance = "5e-6"
                }
                [
                    position = 8528, 8200
                    rotation = right
                ]

                component pas_inductor La {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 7952
                ]

                component pas_inductor Lb {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 8048
                ]

                component pas_inductor Lc {
                    inductance = "625e-6"
                }
                [
                    position = 8064, 8144
                ]

                component "core/Triple Pole Single Throw Contactor" S1 {
                    ctrl_src = "Model"
                }
                [
                    position = 8744, 8048
                    size = 64, 256
                ]

                component "core/Triple Pole Single Throw Contactor" S2 {
                    ctrl_src = "Model"
                }
                [
                    position = 8832, 8336
                    size = 64, 256
                ]

                component pas_resistor R1 {
                    resistance = "Rpc"
                }
                [
                    position = 8704, 8240
                ]

                component pas_resistor R2 {
                    resistance = "Rpc"
                }
                [
                    position = 8704, 8336
                ]

                component pas_resistor R3 {
                    resistance = "Rpc"
                }
                [
                    position = 8704, 8432
                ]

                component pas_resistor SC {
                    resistance = "0"
                }
                [
                    position = 8072, 8336
                ]

                component "core/Voltage Measurement" Vdc+ {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7368, 8000
                    rotation = right
                    size = 64, 32
                ]

                component "core/Voltage Measurement" Vdc- {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7368, 8096
                    rotation = right
                    size = 64, 32
                ]

                component Subsystem Pre-charge {
                    layout = dynamic
                    component gen_c_function Pre-charge {
                        global_variables = "real contactor_count;real Fs;"
                        init_fnc = "/*Begin code section*/
Fs = 1/execution_rate;
contactor_count = 0;
/*End code section*/"
                        input_terminals = "real connect;"
                        input_terminals_dimensions = "inherit"
                        input_terminals_feedthrough = "True"
                        input_terminals_show_labels = "False"
                        output_fnc = "/*Begin code section*/
if (connect) {
    if (contactor_count == 0.) precharge_contactor = 1;

    if (contactor_count > (T1*Fs)){
        main_contactor = 1;
        precharge_contactor = 0;
    }
    contactor_count++;

    if (contactor_count > (T2*Fs)){
        inv_enable = 1;
        contactor_count = (T2*Fs+1.);
    }
} else {
    contactor_count = 0;
    main_contactor = 0;
    precharge_contactor = 0;
    inv_enable = 0;
}
/*End code section*/"
                        output_terminals = "real main_contactor;inherit precharge_contactor;inherit inv_enable;"
                        output_terminals_dimensions = "inherit;inherit;inherit"
                        output_terminals_feedthrough = "True;True;True"
                        output_terminals_show_labels = "True;True;True"
                        parameters = "real T1;real T2;"
                    }
                    [
                        position = 8192, 8192
                        size = 144, 128
                    ]

                    port main_contactor {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8352, 8088
                    ]

                    port Connect_in {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8048, 8192
                    ]

                    port precharge_contactor {
                        position = right:2
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8352, 8192
                    ]

                    port inv_enable {
                        position = right:3
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8360, 8280
                    ]

                    connect Pre-charge.main_contactor main_contactor as Connection1
                    connect Pre-charge.connect Connect_in as Connection2
                    connect Pre-charge.precharge_contactor precharge_contactor as Connection3
                    connect Pre-charge.inv_enable inv_enable as Connection4

                    T1 = "precharge_duration"
                    T2 = "inv_enable_time"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Pre-charging contactors logic.</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"> </p></body></html>"

                        T1 {
                            label = "Pre-charging duration"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "s"
                        }

                        T2 {
                            label = "Inverter enable time"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "s"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 8480, 7808
                    size = 192, 104
                ]

                component Subsystem "Current limit" {
                    layout = dynamic
                    component gen_c_function "Current limit" {
                        global_variables = "real counter;"
                        init_fnc = "/*Begin code section*/
limit_exceeded = 0;
counter =0;
/*End code section*/"
                        input_terminals = "inherit ia;inherit ib;inherit ic;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True;True"
                        input_terminals_show_labels = "True;True;True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable){
    if(ia > limit || ib > limit || ic > limit) limit_exceeded = 1;
}else{
    limit_exceeded = 0;
};
/*End code section*/"
                        output_terminals = "inherit limit_exceeded;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "real limit;"
                    }
                    [
                        position = 8176, 8176
                        size = 168, 128
                    ]

                    port limit_exceeded {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8328, 8176
                    ]

                    port sw_enable {
                        position = left:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8008, 8208
                    ]

                    port ia_rms {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8016, 8080
                    ]

                    port ib_rms {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7968, 8128
                    ]

                    port ic_rms {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 7920, 8168
                    ]

                    connect limit_exceeded "Current limit.limit_exceeded" as Connection2
                    connect sw_enable "Current limit.sw_enable" as Connection3
                    connect ia_rms "Current limit.ia" as Connection4
                    [
                        position = 0, 0
                        breakpoints = 8064, 8080; 8064, 8144
                    ]
                    connect ib_rms "Current limit.ib" as Connection5
                    [
                        position = 0, 0
                        breakpoints = 8000, 8128; 8048, 8128; 8048, 8160
                    ]
                    connect ic_rms "Current limit.ic" as Connection6
                    [
                        position = 0, 0
                        breakpoints = 8032, 8168; 8032, 8192
                    ]

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                        limit {
                            label = "Current limit"
                            widget = edit
                            type = generic
                            default_value = "curr_limit"
                            unit = "Arms"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7672, 8472
                    size = 136, 88
                ]

                component Subsystem "DC Voltage limit" {
                    layout = dynamic
                    component gen_c_function "DC Voltage limit" {
                        init_fnc = "/*Begin code section*/
limit_exceeded = 0;
/*End code section*/"
                        input_terminals = "inherit Vdc;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit"
                        input_terminals_feedthrough = "True;True"
                        input_terminals_show_labels = "True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable){
    if(Vdc > limit )
    limit_exceeded = 1;
}else{
    limit_exceeded = 0;
};
/*End code section*/"
                        output_terminals = "inherit limit_exceeded;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "real limit;"
                    }
                    [
                        position = 8176, 8176
                        size = 168, 128
                    ]

                    port limit_exceeded {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8328, 8176
                    ]

                    port sw_enable {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8032, 8224
                    ]

                    port Vdc {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8032, 8128
                    ]

                    connect limit_exceeded "DC Voltage limit.limit_exceeded" as Connection2
                    connect sw_enable "DC Voltage limit.sw_enable" as Connection3
                    connect Vdc "DC Voltage limit.Vdc" as Connection4

                    limit = "vdc_limit"

                    mask {
                        description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                        limit {
                            label = "DC Voltage limit"
                            widget = edit
                            type = generic
                            default_value = "0"
                            unit = "V"
                        }

                        CODE open
                            from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                        
                            dialog = RegularComponentPropertiesDialog(
                                component=component,
                                property_container=component.masks[-1],
                                current_diagram=current_diagram
                            )
                            dialog.exec_()
                            
                        ENDCODE
                    }
                }
                [
                    position = 7672, 8664
                    size = 136, 96
                ]

                component gen_sum Sum1 {
                }
                [
                    position = 7544, 8632
                    hide_name = True
                ]

                component Subsystem "Enable inverter" {
                    layout = dynamic
                    component gen_c_function "DC Voltage limit" {
                        init_fnc = "/*Begin code section*/
enable = 0;
/*End code section*/"
                        input_terminals = "inherit current_lim_exceeded;inherit vdc_lim_exceeded;inherit precharge_enable;inherit sw_enable;"
                        input_terminals_dimensions = "inherit;inherit;inherit;inherit"
                        input_terminals_feedthrough = "True;True;True;True"
                        input_terminals_show_labels = "True;True;True;True"
                        output_fnc = "/*Begin code section*/
if(sw_enable && precharge_enable){
    if(en_i_protection && current_lim_exceeded){
        enable = 0;
    }else if(en_v_protection && vdc_lim_exceeded){
        enable = 0;
    }else{
        enable =1;
    };
}else enable = 0;
/*End code section*/"
                        output_terminals = "inherit enable;"
                        output_terminals_dimensions = "inherit"
                        output_terminals_feedthrough = "True"
                        output_terminals_show_labels = "True"
                        parameters = "int en_i_protection;int en_v_protection;"
                    }
                    [
                        position = 8200, 8200
                        size = 216, 176
                    ]

                    port enable {
                        position = right:1
                        kind = sp
                        direction =  in
                        sp_type {
                            default = inherit
                            readonly = True
                        }
                    }
                    [
                        position = 8368, 8200
                    ]

                    port vdc_lim {
                        position = left:2
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8184
                    ]

                    port precharge_en {
                        position = left:3
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8248
                    ]

                    port sw_enable {
                        position = left:4
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8304
                    ]

                    port current_lim {
                        position = left:1
                        kind = sp
                        direction =  out
                        sp_type {
                            default = auto
                            readonly = True
                        }
                    }
                    [
                        position = 8000, 8128
                    ]

                    connect sw_enable "DC Voltage limit.sw_enable" as Connection3
                    connect enable "DC Voltage limit.enable" as Connection2
                    connect precharge_en "DC Voltage limit.precharge_enable" as Connection4
                    connect vdc_lim "DC Voltage limit.vdc_lim_exceeded" as Connection5
                    connect current_lim "DC Voltage limit.current_lim_exceeded" as Connection6
                }
                [
                    position = 8120, 8584
                    size = 144, 96
                ]

                component "core/Current Measurement" Ia {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 7952
                    size = 64, 32
                ]

                component "core/Current Measurement" Ib {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 8048
                    size = 64, 32
                ]

                component "core/Current Measurement" Ic {
                    execution_rate = "Tex"
                    sig_output = "True"
                }
                [
                    position = 7968, 8144
                    size = 64, 32
                ]

                component gen_bus_join "Bus Join1" {
                    inputs = "3"
                }
                [
                    position = 8584, 8600
                ]

                component gen_bus_join "Bus Join2" {
                    inputs = "5"
                }
                [
                    position = 8600, 8752
                ]

                component pas_resistor R4 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 7952
                ]

                component pas_resistor R5 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 8048
                ]

                component pas_resistor R6 {
                    resistance = "0.1"
                }
                [
                    position = 8160, 8144
                ]

                component pas_resistor R7 {
                    resistance = "0.05"
                }
                [
                    position = 8336, 8288
                    rotation = right
                ]

                component pas_resistor R8 {
                    resistance = "0.05"
                }
                [
                    position = 8432, 8288
                    rotation = right
                ]

                component pas_resistor R9 {
                    resistance = "0.05"
                }
                [
                    position = 8528, 8288
                    rotation = right
                ]

                component gen_rms_value "RMS value1" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8040, 7872
                    hide_name = True
                ]

                component gen_rms_value "RMS value2" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8128, 8008
                    hide_name = True
                ]

                component gen_rms_value "RMS value3" {
                    filter_en = "True"
                    lpf_cutoff = "600"
                    period_deadband = "0.006"
                    period_timeout = "0.05"
                }
                [
                    position = 8120, 8104
                    hide_name = True
                ]

                port DC+ {
                    position = left:1
                    kind = pe
                }
                [
                    position = 7264, 7952
                ]

                port N {
                    position = right:4
                    kind = pe
                }
                [
                    position = 7264, 8048
                ]

                port DC- {
                    position = left:3
                    kind = pe
                }
                [
                    position = 7264, 8144
                ]

                port A {
                    position = right:1
                    kind = pe
                }
                [
                    position = 9088, 7952
                    rotation = down
                ]

                port B {
                    position = right:2
                    kind = pe
                }
                [
                    position = 9088, 8048
                    rotation = down
                ]

                port C {
                    position = right:3
                    kind = pe
                }
                [
                    position = 9088, 8144
                    rotation = down
                ]

                port Connect {
                    position = bottom:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 8312, 7808
                ]

                port m_a {
                    position = top:1
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7864
                ]

                port m_b {
                    position = top:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7800
                ]

                port m_c {
                    position = top:3
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7776, 7736
                ]

                port "Sw enable" {
                    position = bottom:2
                    kind = sp
                    direction =  out
                    sp_type {
                        default = auto
                        readonly = True
                    }
                }
                [
                    position = 7312, 8696
                ]

                port Flags {
                    position = bottom:4
                    kind = sp
                    direction =  in
                    sp_type {
                        default = inherit
                        readonly = True
                    }
                }
                [
                    position = 8664, 8600
                ]

                port Measurements {
                    position = bottom:3
                    kind = sp
                    direction =  in
                    sp_type {
                        default = inherit
                        readonly = True
                    }
                }
                [
                    position = 8672, 8752
                ]

                tag Goto1 {
                    value = "precharge_enable"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8672, 7840
                    hide_name = True
                    size = 115, 20
                ]

                tag Goto2 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8048, 7904
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto3 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8048, 8008
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto4 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8040, 8104
                    hide_name = True
                    size = 60, 20
                ]

                tag From1 {
                    value = "Ia_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7472, 8416
                    hide_name = True
                    size = 60, 20
                ]

                tag From2 {
                    value = "Ib_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7472, 8448
                    hide_name = True
                    size = 60, 20
                ]

                tag From3 {
                    value = "Ic_rms"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7472, 8480
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto5 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7448, 8000
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto6 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7448, 8096
                    hide_name = True
                    size = 60, 20
                ]

                tag From4 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7448, 8624
                    hide_name = True
                    size = 60, 20
                ]

                tag From5 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7448, 8656
                    hide_name = True
                    size = 60, 20
                ]

                tag From6 {
                    value = "precharge_enable"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7952, 8592
                    hide_name = True
                    size = 95, 20
                ]

                tag Goto7 {
                    value = "enable"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8264, 8584
                    hide_name = True
                    size = 60, 20
                ]

                tag From7 {
                    value = "enable"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 7704, 7904
                    hide_name = True
                    size = 60, 20
                ]

                tag From8 {
                    value = "Precharge_completed"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8464, 8552
                    hide_name = True
                    size = 116, 20
                ]

                tag From9 {
                    value = "Current_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8464, 8600
                    hide_name = True
                    size = 116, 20
                ]

                tag From10 {
                    value = "Vdc_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8464, 8648
                    hide_name = True
                    size = 116, 20
                ]

                tag Goto8 {
                    value = "Current_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7984, 8472
                    hide_name = True
                    size = 165, 20
                ]

                tag Goto9 {
                    value = "Vdc_limit_exceeded"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 7896, 8664
                    hide_name = True
                    size = 165, 20
                ]

                tag Goto10 {
                    value = "Precharge_completed"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8672, 7880
                    hide_name = True
                    size = 111, 20
                ]

                tag From11 {
                    value = "Ia"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8704
                    hide_name = True
                    size = 60, 20
                ]

                tag From12 {
                    value = "Ib"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8736
                    hide_name = True
                    size = 60, 20
                ]

                tag From13 {
                    value = "Ic"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8768
                    hide_name = True
                    size = 60, 20
                ]

                tag From14 {
                    value = "Vdc+"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8800
                    hide_name = True
                    size = 60, 20
                ]

                tag From15 {
                    value = "Vdc-"
                    scope = local
                    kind = sp
                    direction = out
                }
                [
                    position = 8440, 8832
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto11 {
                    value = "Ia_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8176, 7904
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto12 {
                    value = "Ib_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8208, 8008
                    hide_name = True
                    size = 60, 20
                ]

                tag Goto13 {
                    value = "Ic_rms"
                    scope = local
                    kind = sp
                    direction = in
                }
                [
                    position = 8192, 8104
                    hide_name = True
                    size = 60, 20
                ]

                junction Junction8 pe
                [
                    position = 8608, 8048
                ]

                junction Junction9 pe
                [
                    position = 8568, 8144
                ]

                junction Junction12 pe
                [
                    position = 7568, 7952
                ]

                junction Junction14 pe
                [
                    position = 7568, 8144
                ]

                junction Junction15 pe
                [
                    position = 8960, 8144
                ]

                junction Junction16 pe
                [
                    position = 8920, 8048
                ]

                junction Junction17 pe
                [
                    position = 8880, 7952
                ]

                junction Junction18 pe
                [
                    position = 8432, 8336
                ]

                junction Junction19 pe
                [
                    position = 7568, 8048
                ]

                junction Junction20 pe
                [
                    position = 8432, 8328
                ]

                junction Junction21 pe
                [
                    position = 7568, 8048
                ]

                junction Junction22 pe
                [
                    position = 7368, 7952
                ]

                junction Junction23 pe
                [
                    position = 7368, 8048
                ]

                junction Junction24 pe
                [
                    position = 7368, 8048
                ]

                junction Junction25 pe
                [
                    position = 7368, 8144
                ]

                junction Junction32 sp
                [
                    position = 7384, 8696
                ]

                junction Junction34 sp
                [
                    position = 7776, 8664
                ]

                junction Junction35 sp
                [
                    position = 8592, 7840
                ]

                junction Junction39 sp
                [
                    position = 7848, 8472
                ]

                junction Junction40 sp
                [
                    position = 7384, 8696
                ]

                junction Junction41 sp
                [
                    position = 7968, 7904
                ]

                junction Junction42 pe
                [
                    position = 8648, 7952
                ]

                junction Junction43 pe
                [
                    position = 8432, 8048
                ]

                junction Junction44 pe
                [
                    position = 8528, 8144
                ]

                junction Junction45 pe
                [
                    position = 8336, 7952
                ]

                junction Junction46 sp
                [
                    position = 7968, 8008
                ]

                junction Junction47 sp
                [
                    position = 7968, 8104
                ]

                connect R1.n_node S2.a_in as Connection32
                connect S1.b_in Junction8 as Connection36
                connect S1.c_in Junction9 as Connection39
                connect S2.b_in R2.n_node as Connection42
                connect R2.p_node Junction8 as Connection43
                connect S2.c_in R3.n_node as Connection44
                connect R3.p_node Junction9 as Connection45
                connect Cdc+.p_node Junction12 as Connection61
                connect Junction12 "Three Phase Inverter1.pos_out" as Connection62
                connect Cdc-.n_node Junction14 as Connection67
                connect Junction14 "Three Phase Inverter1.neg_out" as Connection68
                connect S1.c_out Junction15 as Connection70
                connect Junction15 S2.c_out as Connection71
                [
                    position = 0, 0
                    breakpoints = 8960, 8144; 8960, 8432
                ]
                connect C Junction15 as Connection72
                connect S1.b_out Junction16 as Connection73
                connect Junction16 S2.b_out as Connection74
                [
                    position = 0, 0
                    breakpoints = 8920, 8048; 8920, 8336
                ]
                connect B Junction16 as Connection75
                connect S2.a_out Junction17 as Connection76
                connect Junction17 S1.a_out as Connection77
                connect A Junction17 as Connection78
                connect Cdc-.p_node Junction19 as Connection87
                connect Junction19 Cdc+.n_node as Connection88
                [
                    position = 0, 0
                    breakpoints = 7568, 8048
                ]
                connect Junction20 Junction18 as Connection91
                connect SC.n_node Junction20 as Connection92
                connect Junction21 Junction19 as Connection94
                [
                    position = 0, 0
                    breakpoints = 7568, 8048
                ]
                connect SC.p_node Junction21 as Connection95
                [
                    position = 0, 0
                    breakpoints = 7672, 8328; 7672, 8048
                ]
                connect DC+ Junction22 as Connection96
                connect Junction22 Junction12 as Connection97
                connect Vdc+.p_node Junction22 as Connection98
                connect N Junction23 as Connection99
                connect Junction23 Junction21 as Connection100
                connect Vdc+.n_node Junction24 as Connection102
                connect Junction24 Junction23 as Connection103
                connect Vdc-.p_node Junction24 as Connection104
                connect DC- Junction25 as Connection105
                connect Junction25 Junction14 as Connection106
                connect Vdc-.n_node Junction25 as Connection107
                connect Connect Pre-charge.Connect_in as Connection127
                connect Pre-charge.precharge_contactor S2.ctrl_in as Connection128
                connect Pre-charge.main_contactor S1.ctrl_in as Connection129
                connect Goto5 Vdc+.out as Connection143
                connect Goto6 Vdc-.out as Connection144
                connect Sum1.out "DC Voltage limit.Vdc" as Connection145
                connect From4 Sum1.in as Connection146
                connect From5 Sum1.in1 as Connection147
                connect From6 "Enable inverter.precharge_en" as Connection154
                connect "DC Voltage limit.sw_enable" Junction32 as Connection155
                connect "Enable inverter.sw_enable" Junction32 as Connection157
                [
                    position = 0, 0
                    breakpoints = 8032, 8608; 8032, 8768; 8032, 8768; 7584, 8768
                ]
                connect Goto7 "Enable inverter.enable" as Connection158
                connect La.p_node Ia.n_node as Connection163
                connect Ia.p_node "Three Phase Inverter1.a_in" as Connection164
                connect "Three Phase Inverter1.b_in" Ib.p_node as Connection165
                connect Ib.n_node Lb.p_node as Connection166
                connect Lc.p_node Ic.n_node as Connection167
                connect Ic.p_node "Three Phase Inverter1.c_in" as Connection168
                connect Flags "Bus Join1.out" as Connection169
                connect From8 "Bus Join1.in" as Connection170
                connect "Bus Join1.in1" From9 as Connection171
                connect From10 "Bus Join1.in2" as Connection172
                connect "DC Voltage limit.limit_exceeded" Junction34 as Connection179
                connect Junction34 "Enable inverter.vdc_lim" as Connection180
                [
                    position = 0, 0
                    breakpoints = 7776, 8664
                ]
                connect Goto9 Junction34 as Connection181
                connect Pre-charge.inv_enable Junction35 as Connection182
                connect Junction35 Goto1 as Connection183
                [
                    position = 0, 0
                    breakpoints = 8592, 7840
                ]
                connect Goto10 Junction35 as Connection184
                connect "Enable inverter.current_lim" Junction39 as Connection212
                connect Junction39 Goto8 as Connection213
                [
                    position = 0, 0
                    breakpoints = 7848, 8472
                ]
                connect "Current limit.limit_exceeded" Junction39 as Connection214
                connect Junction32 Junction40 as Connection216
                connect Junction40 "Sw enable" as Connection217
                [
                    position = 0, 0
                    breakpoints = 7384, 8696; 7384, 8696; 7384, 8696; 7384, 8696
                ]
                connect "Current limit.sw_enable" Junction40 as Connection218
                connect From11 "Bus Join2.in" as Connection234
                connect From12 "Bus Join2.in1" as Connection235
                connect From13 "Bus Join2.in2" as Connection236
                connect From14 "Bus Join2.in3" as Connection237
                connect From15 "Bus Join2.in4" as Connection238
                connect Measurements "Bus Join2.out" as Connection239
                connect m_a "Three Phase Inverter1.InA" as Connection254
                connect m_b "Three Phase Inverter1.InB" as Connection255
                connect m_c "Three Phase Inverter1.InC" as Connection256
                connect From7 "Three Phase Inverter1.En" as Connection257
                connect La.n_node R4.p_node as Connection258
                connect Lb.n_node R5.p_node as Connection260
                connect Lc.n_node R6.p_node as Connection262
                connect Ca.n_node R7.p_node as Connection264
                connect R7.n_node Junction18 as Connection265
                connect Junction18 R8.n_node as Connection266
                connect R8.p_node Cb.n_node as Connection267
                connect Cc.n_node R9.p_node as Connection268
                connect R9.n_node Junction20 as Connection269
                [
                    position = 0, 0
                    breakpoints = 8528, 8336; 8432, 8336
                ]
                connect Ia.out Junction41 as Connection298
                connect Junction41 Goto2 as Connection299
                connect "RMS value1.in" Junction41 as Connection300
                connect R1.p_node Junction42 as Connection302
                connect Junction42 S1.a_in as Connection303
                [
                    position = 0, 0
                    breakpoints = 8648, 7952
                ]
                connect Junction8 Junction43 as Connection305
                [
                    position = 0, 0
                    breakpoints = 8608, 8048; 8608, 8048; 8608, 8048
                ]
                connect Junction43 Cb.p_node as Connection306
                connect R5.n_node Junction43 as Connection307
                connect Junction9 Junction44 as Connection308
                connect Junction44 Cc.p_node as Connection309
                connect R6.n_node Junction44 as Connection310
                [
                    position = 0, 0
                    breakpoints = 8208, 8144; 8448, 8144
                ]
                connect R4.n_node Junction45 as Connection311
                connect Junction45 Junction42 as Connection312
                connect Ca.p_node Junction45 as Connection313
                [
                    position = 0, 0
                    breakpoints = 8328, 8160; 8328, 7952
                ]
                connect "RMS value2.out" Goto12 as Connection314
                [
                    position = 0, 0
                    breakpoints = 8168, 8008
                ]
                connect Ib.out Junction46 as Connection315
                connect Junction46 Goto3 as Connection316
                connect "RMS value2.in" Junction46 as Connection317
                connect "RMS value3.out" Goto13 as Connection318
                connect Ic.out Junction47 as Connection319
                connect Junction47 Goto4 as Connection320
                connect "RMS value3.in" Junction47 as Connection321
                [
                    position = 0, 0
                    breakpoints = 8088, 8088; 7968, 8088
                ]
                connect "RMS value1.out" Goto11 as Connection325
                [
                    position = 0, 0
                    breakpoints = 8128, 7872
                ]
                connect From1 "Current limit.ia_rms" as Connection336
                [
                    position = 0, 0
                    breakpoints = 7520, 8416; 7584, 8416
                ]
                connect "Current limit.ib_rms" From2 as Connection335
                [
                    position = 0, 0
                    breakpoints = 7576, 8464; 7576, 8448; 7576, 8448
                ]
                connect From3 "Current limit.ic_rms" as Connection337
                [
                    position = 0, 0
                    breakpoints = 7520, 8480; 7576, 8480
                ]

                mask {
                    description = "<html><head><meta name=\"qrichtext\" content=\"1\"></meta><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\"\"><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">SPMIT 750-50-20 ESPECIAL Supplier Inverter - Hardware model.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">It is a 3-phase, 3-wire, half-bridge inverter with LC-output filter.</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">          Nameplate information</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Power: 7.5 kVA (3ph)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Dc Link: 500 Vdc (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Voltage: 0 - 380 V (Line)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Current: 20 A (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Output Frequency: 30 - 150 Hz</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Switching Frequency: 20 kHz (max)</p><p style=\"margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">------------------------------------------</p><p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br></br></p></body></html>"

                    curr_limit {
                        label = "Current limit"
                        widget = edit
                        type = generic
                        default_value = "20"
                        unit = "Arms"
                        group = "Protection"
                    }

                    vdc_limit {
                        label = "DC voltage Limit"
                        widget = edit
                        type = generic
                        default_value = "550"
                        unit = "V"
                        group = "Protection"
                    }

                    en_current_protection {
                        label = "Enable current protection"
                        widget = checkbox
                        type = bool
                        default_value = "True"
                        group = "Protection"
                        no_evaluate

                        CODE property_value_changed
                            if new_value:
                                en_i_protection = 1
                            else:
                                en_i_protection = 0
                        ENDCODE
                    }

                    en_vdc_protection {
                        label = "Enable DC voltage protection"
                        widget = checkbox
                        type = bool
                        default_value = "True"
                        group = "Protection"
                        no_evaluate

                        CODE property_value_changed
                            if new_value:
                                en_v_protection = 1
                            else:
                                en_v_protection = 0
                        ENDCODE
                    }

                    fcarr {
                        label = "Carrier frequency"
                        widget = edit
                        type = generic
                        default_value = "20000"
                        unit = "Hz"
                        group = "General"
                        no_evaluate
                    }

                    dt {
                        label = "Inverter deadtime"
                        widget = combo
                        combo_values = "0.5e-6", "0.6e-6", "0.7e-6", "0.8e-6", "1.0e-6", "1.1e-6", "1.2e-6", "1.5e-6"
                        type = string
                        default_value = "0.5e-6"
                        unit = "s"
                        group = "General"
                        no_evaluate
                    }

                    Tex {
                        label = "Execution rate"
                        widget = edit
                        type = generic
                        default_value = "1e-6"
                        unit = "s"
                        group = "General"
                    }

                    precharge_duration {
                        label = "Pre-charge duration"
                        widget = edit
                        type = generic
                        default_value = "0.5"
                        unit = "s"
                        group = "Pre-charge"
                    }

                    inv_enable_time {
                        label = "Inverter enable time"
                        widget = edit
                        type = generic
                        default_value = "1"
                        unit = "s"
                        group = "Pre-charge"
                    }

                    Rpc {
                        label = "Pre-charge resistor"
                        widget = edit
                        type = generic
                        default_value = "0.5"
                        unit = "Ohm"
                        group = "Pre-charge"
                    }

                    CODE open
                        from typhoon.apps.schematic_editor.dialogs.component_property_dialogs.general import RegularComponentPropertiesDialog
                    
                        dialog = RegularComponentPropertiesDialog(
                            component=component,
                            property_container=component.masks[-1],
                            current_diagram=current_diagram
                        )
                        dialog.exec_()
                        
                    ENDCODE

                    CODE pre_compile
                        # HEADER START
                        curr_limit = mdl.get_property_value(mdl.prop(item_handle, "curr_limit"))
                        vdc_limit = mdl.get_property_value(mdl.prop(item_handle, "vdc_limit"))
                        en_current_protection = mdl.get_property_value(mdl.prop(item_handle, "en_current_protection"))
                        en_vdc_protection = mdl.get_property_value(mdl.prop(item_handle, "en_vdc_protection"))
                        fcarr = mdl.get_property_value(mdl.prop(item_handle, "fcarr"))
                        dt = mdl.get_property_value(mdl.prop(item_handle, "dt"))
                        Tex = mdl.get_property_value(mdl.prop(item_handle, "Tex"))
                        precharge_duration = mdl.get_property_value(mdl.prop(item_handle, "precharge_duration"))
                        inv_enable_time = mdl.get_property_value(mdl.prop(item_handle, "inv_enable_time"))
                        Rpc = mdl.get_property_value(mdl.prop(item_handle, "Rpc"))
                        # HEADER STOP
                        fc = int(mdl.get_property_value(mdl.prop(item_handle, "fcarr")))
                        if fc > 20000: 
                            fc = 20000
                    ENDCODE

                    CODE init
                        #mdl.set_property_display_value(mdl.prop(item_handle, "en_current_protection"), True)
                        #mdl.set_property_display_value(mdl.prop(item_handle, "en_vdc_protection"), True)
                    ENDCODE

                    CODE post_resolve
                    ENDCODE

                    CODE define_icon
                        image('Figures\supplier_3p3w.png')
                    ENDCODE
                }
            }
            [
                position = 7904, 8264
                size = 248, 296
            ]
        }
        [
            position = 4768, 4288
            size = 48, 48
        ]

        comment Comment1 START Consider using the Category component to better organize your library items in the tree. ENDCOMMENT 
        [
            position = 4192, 4192
        ]
    }

    default {
        pas_resistor {
            resistance = "1"
            param_set = ""
        }
    }
}
