mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Change default widget simulator to simulation model
This commit is contained in:
parent
703f4fbf6a
commit
b5fa267dc4
2 changed files with 13 additions and 13 deletions
|
@ -12,7 +12,7 @@ import WidgetSlider from './widget-slider';
|
|||
|
||||
class WidgetFactory {
|
||||
|
||||
static createWidgetOfType(type, position, defaultSimulator = null) {
|
||||
static createWidgetOfType(type, position, defaultSimulationModel = null) {
|
||||
|
||||
let widget = {
|
||||
name: 'Name',
|
||||
|
@ -28,7 +28,7 @@ class WidgetFactory {
|
|||
// set type specific properties
|
||||
switch(type) {
|
||||
case 'Lamp':
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.signal = 0;
|
||||
widget.minWidth = 5;
|
||||
widget.minHeight = 5;
|
||||
|
@ -39,7 +39,7 @@ class WidgetFactory {
|
|||
widget.threshold = 0.5;
|
||||
break;
|
||||
case 'Value':
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.signal = 0;
|
||||
widget.minWidth = 70;
|
||||
widget.minHeight = 20;
|
||||
|
@ -50,7 +50,7 @@ class WidgetFactory {
|
|||
widget.showUnit = false;
|
||||
break;
|
||||
case 'Plot':
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.signals = [ 0 ];
|
||||
widget.ylabel = '';
|
||||
widget.time = 60;
|
||||
|
@ -63,7 +63,7 @@ class WidgetFactory {
|
|||
widget.yUseMinMax = false;
|
||||
break;
|
||||
case 'Table':
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.minWidth = 200;
|
||||
widget.width = 300;
|
||||
widget.height = 200;
|
||||
|
@ -78,7 +78,7 @@ class WidgetFactory {
|
|||
widget.fontColor = 0;
|
||||
break;
|
||||
case 'PlotTable':
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.preselectedSignals = [];
|
||||
widget.signals = []; // initialize selected signals
|
||||
widget.ylabel = '';
|
||||
|
@ -105,7 +105,7 @@ class WidgetFactory {
|
|||
widget.height = 100;
|
||||
widget.background_color = 1;
|
||||
widget.font_color = 0;
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.signal = 0;
|
||||
break;
|
||||
case 'NumberInput':
|
||||
|
@ -113,7 +113,7 @@ class WidgetFactory {
|
|||
widget.minHeight = 50;
|
||||
widget.width = 200;
|
||||
widget.height = 50;
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.signal = 0;
|
||||
break;
|
||||
case 'Slider':
|
||||
|
@ -122,11 +122,11 @@ class WidgetFactory {
|
|||
widget.width = 400;
|
||||
widget.height = 50;
|
||||
widget.orientation = WidgetSlider.OrientationTypes.HORIZONTAL.value; // Assign default orientation
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.signal = 0;
|
||||
break;
|
||||
case 'Gauge':
|
||||
widget.simulator = defaultSimulator;
|
||||
widget.simulationModel = defaultSimulationModel;
|
||||
widget.signal = 0;
|
||||
widget.minWidth = 100;
|
||||
widget.minHeight = 150;
|
||||
|
|
|
@ -192,12 +192,12 @@ class Visualization extends React.Component {
|
|||
handleDrop(item, position) {
|
||||
|
||||
let widget = null;
|
||||
let defaultSimulator = null;
|
||||
let defaultSimulationModel = null;
|
||||
|
||||
if (this.state.simulation.models && this.state.simulation.models.length === 0) {
|
||||
NotificationsDataManager.addNotification(NotificationsFactory.NO_SIM_MODEL_AVAILABLE);
|
||||
} else {
|
||||
defaultSimulator = this.state.simulation.models[0].simulator;
|
||||
defaultSimulationModel = this.state.simulation.models[0];
|
||||
}
|
||||
|
||||
// snap position to grid
|
||||
|
@ -205,7 +205,7 @@ class Visualization extends React.Component {
|
|||
position.y = this.snapToGrid(position.y);
|
||||
|
||||
// create new widget
|
||||
widget = WidgetFactory.createWidgetOfType(item.name, position, defaultSimulator);
|
||||
widget = WidgetFactory.createWidgetOfType(item.name, position, defaultSimulationModel);
|
||||
|
||||
var new_widgets = this.state.visualization.widgets;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue