From 797e65f69a2bd674f8fc4dcc16bcd11e2cf49ca3 Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Tue, 23 Jul 2019 08:01:16 +0300 Subject: [PATCH] Support peakPower & alternative elevation in district CSV import gitlab #56 APROS-15523 Change-Id: Ic8b2b008864a03b81aaa9adabdd6e0fab76eb30e --- .../imports/ui/CSVImportWizardPage.java | 35 ++++++++++++++++++- .../scl/Simantics/District/Import.scl | 2 ++ .../district/imports/CSVImportModel.java | 18 ++++++++++ .../district/imports/DistrictImportUtils.java | 9 +++-- .../graph/DistrictNetwork.pgraph | 9 +++-- .../ontology/DistrictNetworkResource.java | 24 +++++++++++++ 6 files changed, 92 insertions(+), 5 deletions(-) diff --git a/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java b/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java index c6e1b516..268ed310 100644 --- a/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java +++ b/org.simantics.district.imports.ui/src/org/simantics/district/imports/ui/CSVImportWizardPage.java @@ -58,6 +58,7 @@ public class CSVImportWizardPage extends WizardPage { private DynamicComboFieldEditor xCoordSelector; private DynamicComboFieldEditor yCoordSelector; private DynamicComboFieldEditor zValueSelector; + private DynamicComboFieldEditor altElevationValueSelector; private DynamicComboFieldEditor supplyTempValueSelector; private DynamicComboFieldEditor returnTempValueSelector; @@ -66,6 +67,7 @@ public class CSVImportWizardPage extends WizardPage { private DynamicComboFieldEditor dpSelector; private DynamicComboFieldEditor dtSelector; private DynamicComboFieldEditor heatPowerSelector; + private DynamicComboFieldEditor peakPowerSelector; private DynamicComboFieldEditor nominalHeadMSelector; private DynamicComboFieldEditor nominalHeadBSelector; private DynamicComboFieldEditor nominalFlowSelector; @@ -388,6 +390,22 @@ public class CSVImportWizardPage extends WizardPage { validatePageComplete(); } }); + + altElevationValueSelector = new DynamicComboFieldEditor("altElevation", "Alternative Elevation", parent); + altElevationValueSelector.addComboListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + widgetDefaultSelected(e); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + model.setAltElevationIndex(Integer.parseInt(altElevationValueSelector.getValue())); + validatePageComplete(); + } + }); + supplyTempValueSelector = new DynamicComboFieldEditor("tempValue", "Supply Temperature value", parent); supplyTempValueSelector.addComboListener(new SelectionListener() { @@ -486,6 +504,20 @@ public class CSVImportWizardPage extends WizardPage { validatePageComplete(); } }); + peakPowerSelector = new DynamicComboFieldEditor("peakPowerValue", "Peak Power", parent); + peakPowerSelector.addComboListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + widgetDefaultSelected(e); + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { + model.setPeakPowerIndex(Integer.parseInt(peakPowerSelector.getValue())); + validatePageComplete(); + } + }); nominalHeadMSelector = new DynamicComboFieldEditor("nominalHeadMValue", "nominalHeadM", parent); nominalHeadMSelector.addComboListener(new SelectionListener() { @@ -925,6 +957,7 @@ public class CSVImportWizardPage extends WizardPage { xCoordSelector.updateCombo(namesAndValues); yCoordSelector.updateCombo(namesAndValues); zValueSelector.updateCombo(namesAndValues); + altElevationValueSelector.updateCombo(namesAndValues); supplyTempValueSelector.updateCombo(namesAndValues); returnTempValueSelector.updateCombo(namesAndValues); supplyPressureValueSelector.updateCombo(namesAndValues); @@ -1006,7 +1039,7 @@ public class CSVImportWizardPage extends WizardPage { if (model.isVertexImport()) setPageComplete(model.getXCoordIndex() != -1 && model.getYCoordIndex() != -1 && model.getComponentMappingIndex() != -1); else - setPageComplete(model.getStartXCoordIndex() != 1 && model.getStartYCoordIndex() != -1 && model.getEndXCoordIndex() != -1 && model.getEndYCoordIndex() != -1 && model.getComponentMappingIndex() != -1); + setPageComplete(model.getStartXCoordIndex() != -1 && model.getStartYCoordIndex() != -1 && model.getEndXCoordIndex() != -1 && model.getEndYCoordIndex() != -1 && model.getComponentMappingIndex() != -1); } } diff --git a/org.simantics.district.imports/scl/Simantics/District/Import.scl b/org.simantics.district.imports/scl/Simantics/District/Import.scl index 9e423ca4..a3d36f4c 100644 --- a/org.simantics.district.imports/scl/Simantics/District/Import.scl +++ b/org.simantics.district.imports/scl/Simantics/District/Import.scl @@ -16,8 +16,10 @@ importJava "org.simantics.district.imports.CSVImportModel" where setXCoordIndex :: CSVImportModel -> Integer -> () setYCoordIndex :: CSVImportModel -> Integer -> () setZCoordIndex :: CSVImportModel -> Integer -> () + setAltElevationIndex :: CSVImportModel -> Integer -> () setHeatLoadDsIndex :: CSVImportModel -> Integer -> () setHeatPowerIndex :: CSVImportModel -> Integer -> () + setPeakPowerIndex :: CSVImportModel -> Integer -> () // Edge setStartXCoordIndex :: CSVImportModel -> Integer -> () diff --git a/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java b/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java index 5041f1bb..9f85225f 100644 --- a/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java +++ b/org.simantics.district.imports/src/org/simantics/district/imports/CSVImportModel.java @@ -28,6 +28,7 @@ public class CSVImportModel { private int xCoordIndex = -1; private int yCoordIndex = -1; private int zCoordIndex = -1; + private int altElevationIndex = -1; // Edge import private int startXCoordIndex = -1; @@ -72,6 +73,7 @@ public class CSVImportModel { private int addressIndex = -1; private int lengthIndex = -1; private int detailedGeometryIndex = -1; + private int peakPowerIndex = -1; // Third page @@ -500,4 +502,20 @@ public class CSVImportModel { public int getDetailedGeometryIndex() { return detailedGeometryIndex; } + + public int getAlternativeElevationIndex() { + return altElevationIndex; + } + + public void setAltElevationIndex(int parseInt) { + this.altElevationIndex = parseInt; + } + + public void setPeakPowerIndex(int parseInt) { + this.peakPowerIndex = parseInt; + } + + public int getPeakPowerIndex() { + return peakPowerIndex; + } } diff --git a/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java b/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java index b3b997b3..139b63e8 100644 --- a/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java +++ b/org.simantics.district.imports/src/org/simantics/district/imports/DistrictImportUtils.java @@ -235,6 +235,7 @@ public class DistrictImportUtils { int xCoordColumnIndex = model.getXCoordIndex(); int yCoordColumnIndex = model.getYCoordIndex(); int zCoordColumnIndex = model.getZCoordIndex(); + int altElevationIndex = model.getAlternativeElevationIndex(); int supplyTempColumnIndex = model.getSupplyTempIndex(); int returnTempColumnIndex = model.getReturnTempIndex(); int supplyPressureColumnIndex = model.getSupplyPressureIndex(); @@ -242,6 +243,7 @@ public class DistrictImportUtils { int dpIndex = model.getDeltaPressureIndex(); int dtIndex = model.getDeltaTemperatureIndex(); int heatPowerIndex = model.getHeatPowerIndex(); + int peakPowerIndex = model.getPeakPowerIndex(); int valvePositionIndex = model.getValvePositionIndx(); int nominalHeadMIndex = model.getNominalHeadMIndex(); int nominalHeadBIndex = model.getNominalHeadBIndex(); @@ -303,7 +305,7 @@ public class DistrictImportUtils { } } } - + double[] coords; if (actualDoTransform) { DirectPosition2D targetPos = new DirectPosition2D(); @@ -321,6 +323,8 @@ public class DistrictImportUtils { writeStringValue(graph, row, idColumn, vertex, DN.HasId); + writeValue(graph, row, altElevationIndex, vertex, DN.Vertex_HasAltElevation); + writeValue(graph, row, supplyTempColumnIndex, vertex, DN.Vertex_HasSupplyTemperature); writeValue(graph, row, returnTempColumnIndex, vertex, DN.Vertex_HasReturnTemperature); writeValue(graph, row, supplyPressureColumnIndex, vertex, DN.Vertex_HasSupplyPressure); @@ -328,6 +332,7 @@ public class DistrictImportUtils { writeValue(graph, row, dpIndex, vertex, DN.Vertex_HasDeltaPressure); writeValue(graph, row, dtIndex, vertex, DN.Vertex_HasDeltaTemperature); writeValue(graph, row, heatPowerIndex, vertex, DN.Vertex_HasHeatPower); + writeValue(graph, row, peakPowerIndex, vertex, DN.Vertex_HasPeakPower); writeValue(graph, row, valvePositionIndex, vertex, DN.Vertex_HasValvePosition); writeValue(graph, row, nominalHeadMIndex, vertex, DN.Vertex_HasNominalHeadM); writeValue(graph, row, nominalHeadBIndex, vertex, DN.Vertex_HasNominalHeadB); @@ -549,7 +554,7 @@ public class DistrictImportUtils { double y = Double.parseDouble(p[1]); if (actualTransform != null) { DirectPosition2D targetPos = new DirectPosition2D(); - DirectPosition2D sourcePos = new DirectPosition2D(y, x); + DirectPosition2D sourcePos = new DirectPosition2D(x, y); DirectPosition res = actualTransform.transform(sourcePos, targetPos); double[] coords = res.getCoordinate(); x = coords[1]; diff --git a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph index aa801f08..2a64b3dc 100644 --- a/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph +++ b/org.simantics.district.network.ontology/graph/DistrictNetwork.pgraph @@ -39,6 +39,8 @@ DN.Element -- DN.Vertex.HasElevation @defProperty "Elevation" L0.Double + >-- DN.Vertex.HasAltElevation + @defProperty "Alternative Elevation" L0.Double >-- DN.Vertex.HasAddress @defProperty "Address" L0.String >-- DN.Vertex.HasSupplyTemperature @@ -54,7 +56,9 @@ DN.Vertex -- DN.Vertex.HasDeltaTemperature @defProperty "Delta temperature" L0.Double >-- DN.Vertex.HasHeatPower - @defProperty "Heat Power" L0.Double + @defProperty "Heat Power" L0.Double + >-- DN.Vertex.HasPeakPower + @defProperty "Peak Power" L0.Double >-- DN.Vertex.HasNominalHeadM @defProperty "NominalHeadM" L0.Double >-- DN.Vertex.HasNominalHeadB @@ -266,6 +270,7 @@ DN.Mapping.TerminalPair -- DN.Mapping.VertexMapping.ElevationAttribute --> L0.String -- DN.Mapping.VertexMapping.ElevationAltAttribute --> L0.String -- DN.Mapping.VertexMapping.SupplyTemperatureAttribute --> L0.String -- DN.Mapping.VertexMapping.ReturnTemperatureAttribute --> L0.String -- DN.Mapping.VertexMapping.SupplyPressureAttribute --> L0.String -- DN.Mapping.VertexMapping.dpAttribute --> L0.String -- DN.Mapping.VertexMapping.dtAttribute --> L0.String -- DN.Mapping.VertexMapping.HeatPowerAttribute --> L0.String -- DN.Mapping.VertexMapping.PeakPowerAttribute --> L0.String -- DN.Mapping.VertexMapping.NominalHeadMAttribute --> L0.String -- DN.Mapping.VertexMapping.NominalHeadBAttribute --> L0.String -- DN.Mapping.VertexMapping.NominalFlowAttribute --> L0.String -- DN.Mapping.EdgeMapping.TGroundAttribute --> L0.String -- DN.Mapping.EdgeMapping.ElevationAttribute --> L0.String