@@ -32,18 +32,27 @@ struct RegularConnector <: AbstractConnectorType end
32
32
33
33
function connector_type (sys:: AbstractSystem )
34
34
sts = get_states (sys)
35
- # TODO : check the criteria for stream connectors
36
35
n_stream = 0
37
36
n_flow = 0
37
+ n_regular = 0 # state that is not input, output, stream, or flow.
38
38
for s in sts
39
39
vtype = get_connection_type (s)
40
40
if vtype === Stream
41
41
isarray (s) && error (" Array stream variables are not supported. Got $s ." )
42
42
n_stream += 1
43
+ elseif vtype === Flow
44
+ n_flow += 1
45
+ elseif ! (isinput (s) || isoutput (s))
46
+ n_regular += 1
43
47
end
44
- vtype === Flow && (n_flow += 1 )
45
48
end
46
49
(n_stream > 0 && n_flow > 1 ) && error (" There are multiple flow variables in $(nameof (sys)) !" )
50
+ if n_flow != n_regular
51
+ @warn " $(nameof (sys)) contains $n_flow variables, yet $n_regular regular " *
52
+ " (non-flow, non-stream, non-input, non-output) variables." *
53
+ " This could lead to imbalanced model that are difficult to debug." *
54
+ " Consider marking some of the regular variables as input/output variables."
55
+ end
47
56
n_stream > 0 ? StreamConnector () : RegularConnector ()
48
57
end
49
58
@@ -97,23 +106,6 @@ instream(a) = term(instream, unwrap(a), type=symtype(a))
97
106
SymbolicUtils. promote_symtype (:: typeof (instream), _) = Real
98
107
99
108
isconnector (s:: AbstractSystem ) = has_connector_type (s) && get_connector_type (s) != = nothing
100
- isstreamconnector (s:: AbstractSystem ) = isconnector (s) && get_connector_type (s) isa StreamConnector
101
- isstreamconnection (c:: Connection ) = any (isstreamconnector, c. inners) || any (isstreamconnector, c. outers)
102
-
103
- function print_with_indent (n, x)
104
- print (" " ^ n)
105
- show (stdout , MIME " text/plain" (), x)
106
- println ()
107
- end
108
-
109
- function split_sys_var (var)
110
- var_name = string (getname (var))
111
- sidx = findlast (isequal (' ₊' ), var_name)
112
- sidx === nothing && error (" $var is not a namespaced variable" )
113
- connector_name = Symbol (var_name[1 : prevind (var_name, sidx)])
114
- streamvar_name = Symbol (var_name[nextind (var_name, sidx): end ])
115
- connector_name, streamvar_name
116
- end
117
109
118
110
function flowvar (sys:: AbstractSystem )
119
111
sts = get_states (sys)
0 commit comments