Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ConnectionInstances need to consider the modes of the endpoints #2722

Closed
AaronGreenhouse opened this issue Oct 21, 2021 · 3 comments · Fixed by #2730
Closed

ConnectionInstances need to consider the modes of the endpoints #2722

AaronGreenhouse opened this issue Oct 21, 2021 · 3 comments · Fixed by #2730
Assignees
Milestone

Comments

@AaronGreenhouse
Copy link
Contributor

Please describe the problem your proposed feature would address

When a semantic connections exists between two components, it should only exist in the system operation modes that both components exist in.

When a semantic connection exists between a component and a feature it should only exist in the system operation modes that the component exists in.

What is the impact of the problem?

Currently semantic connections (ConnectionInstance objects) between modal components do not have their InSystemOperationModes attribute set. This attribute is only set if one of the declarative connections that makes up the semantic connection is modal.

This can lead to a view of the instance model where a semantic connection exists, but the components it is connecting do not.

Furthermore, things are complicated by the fact that ConnectionInstance.isActive() does take this information into account:

        public boolean isActive(SystemOperationMode som) {
                if (getInSystemOperationModes().isEmpty() || getInSystemOperationModes().contains(som)) {
                        if (getSource().getComponentInstance().isActive(som)
                                        && getDestination().getComponentInstance().isActive(som)) {
                                return getContainingComponentInstance().isActive(som);
                        }
                }
                return false;
        }

Describe the solution you'd like

The process that applies SOMs to connection instances need to be updated to handle this situation.

@AaronGreenhouse
Copy link
Contributor Author

Here is a test package.

package test
public
	system A
		features
			f_out: out event port;
	end A;

	system implementation A.wrapper
		subcomponents 
			x: system A;
		connections
			c: port x.f_out -> f_out;
	end A.wrapper;

	system implementation A.modal_wrapper
		subcomponents 
			x: system A in modes (m1);
		connections
			c: port x.f_out -> f_out; -- implied modes m1
		modes
			m1: initial mode;
			m2: mode;			
	end A.modal_wrapper;

	system B
		features
			f_in: in event port;
	end B;
	
	system implementation B.wrapper
		subcomponents 
			y: system B;
		connections
			c: port f_in -> y.f_in;		
	end B.wrapper;

	system implementation B.modal_wrapper
		subcomponents 
			y: system B in modes (mm2);
		connections
			c: port f_in -> y.f_in; -- implied mode mm2
		modes
			mm1: initial mode;
			mm2: mode;			
	end B.modal_wrapper;
	
	system C
		features
			f_out: out event port;
			f_in: in event port;
	end C;
	
	system implementation C.no_modes
		subcomponents
			src1: system A;
			snk1: system B;
			
			src2: system A;
			snk2: system B;
			
		connections
			c1: port src1.f_out -> f_out;
			c2: port f_in -> snk1.f_in;
			
			c3: port src2.f_out -> snk2.f_in;
	end C.no_modes;
	
	system implementation C.with_modes
		subcomponents
			src1: system A in modes (m1);
			snk1: system B in modes (m2);
			
			src2: system A in modes (m1);
			snk2: system B;
			
		connections
			c1: port src1.f_out -> f_out; -- implied mode m1
			c2: port f_in -> snk1.f_in; -- implied mode m2
			
			c3: port src2.f_out -> snk2.f_in; -- implied mode m1
			
		modes
			m1: initial mode;
			m2: mode;
	end C.with_modes;

	system implementation C.wrappers
		subcomponents
			src1: system A.wrapper;
			snk1: system B.wrapper;
			
			src2: system A.wrapper;
			snk2: system B.wrapper;
			
		connections
			c1: port src1.f_out -> f_out;
			c2: port f_in -> snk1.f_in;
			
			c3: port src2.f_out -> snk2.f_in;
	end C.wrappers;


	system implementation C.modal_wrappers
		subcomponents
			src1: system A.modal_wrapper;
			snk1: system B.modal_wrapper;
			
			src2: system A.modal_wrapper;
			snk2: system B.modal_wrapper;
			
		connections
			c1: port src1.f_out -> f_out; -- implied m1
			c2: port f_in -> snk1.f_in; -- implied mm2
			
			c3: port src2.f_out -> snk2.f_in; -- implied m1 x mm2
	end C.modal_wrappers;
	
	
	
	system foo
	end foo;
	
	system implementation foo.bar
		subcomponents 
			sub1: system A in modes (a);
			sub2: system B in modes (b);
		connections
			cc: port sub1.f_out -> sub2.f_in in modes (c); -- this is nonsense!  Currently has a warning during instantiation
		modes
			a: initial mode;
			b: mode;
			c: mode;
		
	end foo.bar;
end test;

@AaronGreenhouse
Copy link
Contributor Author

FYI, the right thing seems to happen for end to end flow instances.

@lwrage lwrage added this to the 2.11.0 milestone Nov 9, 2021
@lwrage lwrage self-assigned this Nov 9, 2021
@lwrage
Copy link
Contributor

lwrage commented Nov 12, 2021

The connection SOMs are missing when a modal source/destination is the only reason for the connection instance to be modal. Otherwise source and destination modes are taken into account correctly.

lwrage added a commit that referenced this issue Nov 16, 2021
sprocter pushed a commit that referenced this issue Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants