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

Calling the same unit twice with different parameters leads to unwanted behavior. #2

Open
neumde opened this issue Jul 31, 2024 · 1 comment

Comments

@neumde
Copy link

neumde commented Jul 31, 2024

In the following henshin code I create two nodes in the graph with an edge to the given EventType.

// Is called by RunTransformation.java
unit doFSM(IN eventTypeName1:EString, IN eventTypeName2:EString, VAR firstState: State) {
	createEvent(eventTypeName1)
	createEvent(eventTypeName2)
}

rule createEvent(IN eventTypeName:EString){
	graph {
		preserve node runtimeState:CurrentState
		preserve node evenType: EventType {
			name = eventTypeName
		}
		
		create node event:Event {}
		edges[(create event->evenType:type),		
			(create runtimeState->event:eventQueue)]
	}
}

Since the following code sets the two parameters I would expect to create two events, one of type "E_NEXT" and one of type "E_LONG". However, due to a wrong parameter mapping, both events are of type "E_LONG" (the last parameter that is set).
This is the java file which sets the parameters and calls the unit:

	public static void main(String[] args) {
		HenshinResourceSet resourceSet=new HenshinResourceSet("./src/runTransformation");
		resourceSet.getPackageRegistry().put(HfsmPackage.eNS_URI, HfsmPackage.eINSTANCE);
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
		

		Resource resource=resourceSet.getResource(filePath);		
		EGraph eGraph=new EGraphImpl(resource);		
		Module module=resourceSet.getModule(transformationPath, true);		
		Engine engine=new EngineImpl();
		
		Unit initHFSM=module.getUnit("doFSM");		
		UnitApplication application = new UnitApplicationImpl(engine, eGraph, initHFSM, null);
				
		
		application.setParameterValue("eventTypeName1", "E_NEXT");
		application.setParameterValue("eventTypeName2", "E_LONG");
		application.execute(null);

Expected parameter mappings:

eventTypeName1 -> "E_NEXT"
eventTypeName2 -> "E_LONG"

The actual parameter mappings apparently:

eventTypeName1 -> "E_LONG"
eventTypeName2 -> "E_LONG"

Troubleshooting approaches:

  • I tried different parameter kinds but this didn't change the outcome.

This is not a problem of the textual henshin syntax, instead the problem seems to be the handling of ParameterMappings in the method createApplicationFor(Unit subUnit).
It seems like the last (fitting) ParameterMapping is selected, instead of the right one for the specific unit call.

@mtttichy
Copy link

I can confirm the problem in the code. I see two possible solutions:

  1. (the proper solution) Introduce an UnitCall-Metaclass. This UnitCall-Metaclass can store the argument for the parameter (the parameter mapping).
  2. (workaround) use the index of subUnit in the surroundung unit and use that index to use the correct parameterMapping

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

No branches or pull requests

2 participants