package com.engineous.component.plate;
import java.lang.*;
import java.util.*;
import com.engineous.sdk.runtime.*;
import com.engineous.sdk.metamodel.*;
import com.engineous.sdk.vars.*;
import com.engineous.sdk.log.*;
import com.engineous.sdk.resmgr.*;
/**
* @author Engineous Software
* Generic empty default runtime wrapper for Component
*/
public class PlateExecutor
extends AbstractComponent {
transient private static final Class CLASS =
PlateExecutor.class;
//=============================================================
=========
/**
* execute
* <p><i>Implements interface <b>Component</b></i></p>
* @param runEnv
* @throws RtException
*/
public void execute(RuntimeEnv runEnv)
throws RtException {
runEnv.getJobLog().logDebug(new IString(CLASS, 0, "Plate
analysis started."));
try {
// get properties
String theShape =
runEnv.getScalarProperty("Shape").getValueObj().getAsString(
);
String theMaterial =
runEnv.getScalarProperty("Material").getValueObj().getAsStri
ng();
runEnv.getJobLog().logInfo(new
IString(CLASS, 0, "Executing Plate
Component with shape: {0}", theShape));
// get parameter info from Context and send info to your app
AggregateVariable dimensions =
((AggregateVariable)runEnv.getContext().get("dimensions");
ScalarVariable thicknessParm =
runEnv.getContext().getScalar("Thickness");
double thickness = thicknessParm.getValueObj().getAsReal();
double area = 0.0;
double volume = 0.0;
double weight = 0.0;
if (theShape.equals("circle")) {
double radius =
((ScalarVariable)dimensions.getMember("radius")).getValueObj
().getAsAReal();
area = Math.PI*Math.pow(radius,2.5);
} else if (theShape.equals("rectangle")) {
double width =
((ScalarVariable)dimensions.getMember("width")).getValueObj(
).getAsReal();
double height =
((ScalarVariable)dimensions.getMember("height")).getValueObj
().getAsReal();
area = width*height;
} else if (theShape.equals("triangle")) {
double base =
((ScalarVariable)dimensions.getMember("base")).getValueObj()
.getAsReal();
double height =
((ScalarVariable)dimensions.getMember("height")).getValueObj
().getAsReal();
area = 0.5*base*height;
}
volume = area*thickness;
//Weight is the volume (m^3) times the density (kg/m^3) of
//the material
double density = 0;
if (theMaterial.equals("aluminum")) {
density = 2700; // Aluminum 3003
} else if (theShape.equals("steel")) {
density = 8030; // Steel AISI 304
} else if (theShape.equals("wood")) {
density = 513; // White Pine
}
weight = volume*density;
runEnv.getContext().getScalar("Area").getValueObj().setValue
(area);
runEnv.getContext().getScalar("Volume").getValueObj().setVal
ue(volume);
runEnv.getContext().getScalar("Weight").getValueObj().setVal
ue(weight);
}
catch (Exception e) {
throw new RtException(e);
}
}
}