Search in sources :

Example 11 with ElementParameters

use of bpsim.ElementParameters in project kie-wb-common by kiegroup.

the class Bpmn2JsonMarshaller method setSimulationProperties.

private void setSimulationProperties(String elementId, Map<String, Object> properties) {
    if (_simulationScenario != null && _simulationScenario.getElementParameters() != null) {
        for (ElementParameters eleType : _simulationScenario.getElementParameters()) {
            if (eleType.getElementRef().equals(elementId)) {
                extractTimeParamsToProperties(eleType, properties);
                extractCostParamsToProperties(eleType, properties);
                extractControlParamsToProperties(eleType, properties);
                extractResourceParamsToProperties(eleType, properties);
            }
        }
    }
}
Also used : ElementParameters(bpsim.ElementParameters)

Example 12 with ElementParameters

use of bpsim.ElementParameters in project kie-wb-common by kiegroup.

the class ProcessPropertyWriter method addChildElement.

public void addChildElement(PropertyWriter p) {
    this.childElements.put(p.getElement().getId(), p);
    process.getFlowElements().add(p.getFlowElement());
    ElementParameters simulationParameters = p.getSimulationParameters();
    if (simulationParameters != null) {
        this.simulationParameters.add(simulationParameters);
    }
    addChildShape(p.getShape());
    addChildEdge(p.getEdge());
    this.itemDefinitions.addAll(p.itemDefinitions);
    this.dataInputs.addAll(p.dataInputs);
    this.dataOutputs.addAll(p.dataOutputs);
    this.rootElements.addAll(p.rootElements);
}
Also used : ElementParameters(bpsim.ElementParameters)

Example 13 with ElementParameters

use of bpsim.ElementParameters in project jbpm by kiegroup.

the class BpsimTest method testBpsimData.

@SuppressWarnings("unchecked")
public void testBpsimData() throws Exception {
    // write
    XMLResource inResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
    inResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
    inResource.setEncoding("UTF-8");
    DocumentRoot documentRoot = BpsimFactory.eINSTANCE.createDocumentRoot();
    BPSimDataType bpsimData = BpsimFactory.eINSTANCE.createBPSimDataType();
    Scenario defaultScenario = BpsimFactory.eINSTANCE.createScenario();
    defaultScenario.setId("default");
    defaultScenario.setName("Scenario");
    ScenarioParameters scenarioParams = BpsimFactory.eINSTANCE.createScenarioParameters();
    scenarioParams.setBaseTimeUnit(TimeUnit.S);
    defaultScenario.setScenarioParameters(scenarioParams);
    ElementParameters elementParams = BpsimFactory.eINSTANCE.createElementParameters();
    TimeParameters elementTimeParams = BpsimFactory.eINSTANCE.createTimeParameters();
    Parameter processingTimeParameter = BpsimFactory.eINSTANCE.createParameter();
    UniformDistributionType uniformDistrobutionType = BpsimFactory.eINSTANCE.createUniformDistributionType();
    uniformDistrobutionType.setMin(180.0);
    uniformDistrobutionType.setMax(600.0);
    processingTimeParameter.getParameterValue().add(uniformDistrobutionType);
    elementTimeParams.setProcessingTime(processingTimeParameter);
    elementParams.setTimeParameters(elementTimeParams);
    defaultScenario.getElementParameters().add(elementParams);
    bpsimData.getScenario().add(defaultScenario);
    documentRoot.setBPSimData(bpsimData);
    inResource.getContents().add(documentRoot);
    StringWriter stringWriter = new StringWriter();
    inResource.save(stringWriter, null);
    assertNotNull(stringWriter.getBuffer().toString());
    if (stringWriter.getBuffer().toString().length() < 1) {
        fail("generated xml is empty");
    }
    // read
    XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
    outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
    outResource.setEncoding("UTF-8");
    Map<String, Object> options = new HashMap<String, Object>();
    options.put(XMLResource.OPTION_ENCODING, "UTF-8");
    InputStream is = new ByteArrayInputStream(stringWriter.getBuffer().toString().getBytes("UTF-8"));
    outResource.load(is, options);
    DocumentRoot outRoot = (DocumentRoot) outResource.getContents().get(0);
    assertNotNull(outRoot.getBPSimData());
    BPSimDataType outAnalysisData = outRoot.getBPSimData();
    assertEquals(outAnalysisData.getScenario().size(), 1);
    Scenario outScenario = outAnalysisData.getScenario().get(0);
    assertEquals(outScenario.getElementParameters().size(), 1);
    assertEquals(outScenario.getId(), "default");
    assertEquals(outScenario.getName(), "Scenario");
    assertNotNull(outScenario.getScenarioParameters());
    assertNotNull(outScenario.getElementParameters());
    assertEquals(outScenario.getElementParameters().size(), 1);
    ElementParameters outElementParamType = outScenario.getElementParameters().get(0);
    assertNotNull(outElementParamType.getTimeParameters());
    TimeParameters outTimeParams = outElementParamType.getTimeParameters();
    assertNotNull(outTimeParams.getProcessingTime());
    assertEquals(outTimeParams.getProcessingTime().getParameterValue().size(), 1);
    UniformDistributionType outDistributionType = (UniformDistributionType) outTimeParams.getProcessingTime().getParameterValue().get(0);
    assertEquals(outDistributionType.getMax(), 600.0);
    assertEquals(outDistributionType.getMin(), 180.0);
}
Also used : UniformDistributionType(bpsim.UniformDistributionType) ElementParameters(bpsim.ElementParameters) HashMap(java.util.HashMap) DocumentRoot(bpsim.DocumentRoot) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) Scenario(bpsim.Scenario) StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) ScenarioParameters(bpsim.ScenarioParameters) Parameter(bpsim.Parameter) BPSimDataType(bpsim.BPSimDataType) TimeParameters(bpsim.TimeParameters)

Aggregations

ElementParameters (bpsim.ElementParameters)13 TimeParameters (bpsim.TimeParameters)8 Parameter (bpsim.Parameter)7 UniformDistributionType (bpsim.UniformDistributionType)7 NormalDistributionType (bpsim.NormalDistributionType)6 PoissonDistributionType (bpsim.PoissonDistributionType)6 CostParameters (bpsim.CostParameters)5 ResourceParameters (bpsim.ResourceParameters)5 ParameterValue (bpsim.ParameterValue)4 Match (org.kie.workbench.common.stunner.bpmn.backend.converters.Match)4 BPSimDataType (bpsim.BPSimDataType)3 FloatingParameterType (bpsim.FloatingParameterType)3 Scenario (bpsim.Scenario)3 EList (org.eclipse.emf.common.util.EList)3 SimulationAttributeSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationAttributeSet)3 SimulationSet (org.kie.workbench.common.stunner.bpmn.definition.property.simulation.SimulationSet)3 HashMap (java.util.HashMap)2 Relationship (org.eclipse.bpmn2.Relationship)2 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)2 VoidMatch (org.kie.workbench.common.stunner.bpmn.backend.converters.VoidMatch)2