Skip to the content.

Runtime Logic Flexibility in NeqSim Process Framework

Summary

YES, it is extremely easy to add new logic programmatically without pre-compilation!

The NeqSim process logic framework is designed with excellent runtime flexibility through its interface-based architecture. You can create, modify, and execute complex process logic sequences entirely at runtime without any need for pre-compilation.

Key Flexibility Features

1. Interface-Based Design

2. Runtime Logic Creation

All logic is created programmatically:

// Create ESD logic at runtime
ESDLogic esdLogic = new ESDLogic("Dynamic ESD");
esdLogic.addAction(new CloseValveAction(valve), 0.0);
esdLogic.addAction(new SetSplitterAction(splitter, new double[]{0.0, 1.0}), 0.5);

// Create startup logic with conditions
StartupLogic startup = new StartupLogic("Dynamic Startup");
startup.addPermissive(new PressureCondition(separator, 5.0, "<"));
startup.addPermissive(new ValvePositionCondition(valve, "<", 5.0));

3. Dynamic Action/Condition Creation

Create custom actions using anonymous classes or lambda expressions:

// Custom action with anonymous class
LogicAction customAction = new LogicAction() {
    private boolean executed = false;
    
    @Override
    public void execute() {
        if (!executed) {
            valve.setPercentValveOpening(75.0);
            executed = true;
        }
    }
    
    @Override
    public String getDescription() {
        return "Custom throttle to 75%";
    }
    
    @Override
    public boolean isComplete() {
        return executed && Math.abs(valve.getPercentValveOpening() - 75.0) < 1.0;
    }
    
    @Override
    public String getTargetName() {
        return valve.getName();
    }
};

4. Configuration-Based Logic

Load logic from external configuration files:

// Configuration format: ACTION_TYPE:EQUIPMENT:PARAMETER:DELAY
String[] esdConfig = {
    "VALVE_CLOSE:Control Valve:0:0.0",
    "VALVE_SET:Backup Valve:25.0:0.5", 
    "SEPARATOR_MODE:Test Separator:transient:1.0"
};

ESDLogic configuredESD = factory.createESDFromConfig("Configured ESD", esdConfig);

5. Runtime Logic Modification

Modify logic sequences during execution:

ESDLogic modifiableLogic = new ESDLogic("Modifiable Logic");
modifiableLogic.addAction(initialAction, 0.0);

// Later, based on runtime conditions:
if (emergencyCondition()) {
    modifiableLogic.addAction(emergencyAction, 2.0);
}

Demonstration Examples

1. DynamicLogicExample.java

Shows how to create logic entirely at runtime:

2. ConfigurableLogicExample.java

Demonstrates loading logic from configurations:

Implementation Patterns

Factory Pattern for Actions

private LogicAction createActionFromConfig(String config) {
    String[] parts = config.split(":");
    String actionType = parts[0];
    String equipmentName = parts[1];
    String parameter = parts[2];
    
    switch (actionType) {
        case "VALVE_CLOSE":
            return createValveCloseAction((ThrottlingValve) equipment.get(equipmentName));
        case "VALVE_SET":
            return createValveSetAction((ThrottlingValve) equipment.get(equipmentName), 
                                      Double.parseDouble(parameter));
        // ... more action types
    }
}

Adaptive Logic Creation

String scenario = determineRuntimeScenario(); // Based on process conditions
ESDLogic adaptiveLogic = createAdaptiveLogic(scenario, valve, separator);

switch (scenario) {
    case "High Pressure Response":
        adaptiveLogic.addAction(createAction("Close valve rapidly", valve, 5.0), 0.0);
        break;
    case "Fire Emergency":
        adaptiveLogic.addAction(createAction("Emergency closure", valve, 0.0), 0.0);
        break;
}

Benefits of Runtime Flexibility

1. No Recompilation Required

2. Dynamic Adaptation

3. Easy Integration

4. Rapid Development

Architecture Benefits

The framework’s interface-based design provides:

Conclusion

The NeqSim process logic framework excels at runtime flexibility. You can:

  1. ✅ Create entirely new logic sequences at runtime
  2. ✅ Load logic from configuration files or external sources
  3. ✅ Modify existing logic sequences during execution
  4. ✅ Create custom actions and conditions dynamically
  5. ✅ Adapt logic based on runtime conditions
  6. ✅ Deploy logic changes without recompilation

This makes it ideal for:

The examples demonstrate that complex process logic can be created, modified, and executed entirely at runtime with no pre-compilation requirements.