Skip to content

Zenmo/uplux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uplux

Save user-defined scenarios from AnyLogic.

Scope

This is an internal library which mostly exists to bundle dependencies.

Installation

Download the latest release and add it to your AnyLogic project dependencies.

Configuration

Set environment variables in a startup script for AnyLogic.

Windows:

set UPLUX_ACCESS_KEY=xxx
set UPLUX_SECRET_KEY=xxx
Anylogic.exe

Linux:

export UPLUX_ACCESS_KEY=xxx
export UPLUX_SECRET_KEY=xxx
export GTK_THEME=adwaita:light
./anylogic

Usage

Uplux uses the repository pattern to save and load scenarios.

Intialize repository class:

import energy.lux.uplux.UserScenarioRepository;
import java.util.UUID;

var repository = UserScenarioRepository.builder()
        // p_userIdToken is a model input parameter which is injected by the Lux.energy website
        .userIdToken(p_userIdToken)
        .modelName("Mordor")
        .build();

Save scenario:

import com.fasterxml.jackson.databind.ObjectMapper;

ObjectMapper jacksonMapper;
repository.saveUserScenario(
        "Use electric arc furnaces in the forges of Mordor",
        jacksonMapper.writeValueAsBytes(userAnyLogicScenario)
)

List saved scenarios:

var scenarioList = repository.listScenarios();
for (var scenario : scenarioList) {
    System.out.println(scenario.getName());
}

Load scenario content:

var jsonStream = repository.fetchUserScenarioContent(scenarioList.get(2).getId());
var deserializedScenario = jackson.readValue(jsonStream, MyAnyLogicScenario.class);

Delete scenario:

repository.deleteUserScenario(scenarioList.get(2).getId());

Security

Uplux currently does not verify that the user is authorized to access requested objects.

It is up to the library consumer to ensure access control and protect against user ID spoofing and ID guessing vulnerability.

About

Save user-defined scenarios from AnyLogic

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages