From 10575a6a72d24bc4e575c4a6410b6645f0cfe8a7 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Mon, 28 Nov 2016 13:36:37 +0100 Subject: [PATCH 1/6] Add convenient method to get temporary limit value --- .../eu/itesla_project/iidm/network/CurrentLimits.java | 8 ++++++++ .../iidm/network/impl/CurrentLimitsImpl.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java index c6699ed9..7580083c 100644 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java +++ b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java @@ -82,4 +82,12 @@ interface TemporaryLimit { * @return the temporary limit */ TemporaryLimit getTemporaryLimit(int acceptableDuration); + + /** + * Get a temporary limit value from its acceptable duration. Return NaN if there is non temporay limit with this + * acceptable duration. + * @param acceptableDuration acceptable duration in second + * @return the temporary limit value or NaN if there is no temporary limit for this acceptable duration + */ + float getTemporaryLimitValue(int acceptableDuration); } diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java index 66aeb904..7d034f97 100644 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java +++ b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java @@ -78,4 +78,10 @@ public Collection getTemporaryLimits() { public TemporaryLimit getTemporaryLimit(int acceptableDuration) { return temporaryLimits.get(acceptableDuration); } + + @Override + public float getTemporaryLimitValue(int acceptableDuration) { + TemporaryLimit tl = getTemporaryLimit(acceptableDuration); + return tl != null ? tl.getValue() : Float.NaN; + } } From 7a5047088f9eac94658a99f953511b15e0056719 Mon Sep 17 00:00:00 2001 From: Mathieu Bague Date: Tue, 29 Nov 2016 12:42:20 +0100 Subject: [PATCH 2/6] Remove core components forked to ipst-core repository --- CMakeLists.txt | 4 - README.md | 14 +- ampl-export/pom.xml | 8 +- case-repository/pom.xml | 44 - .../itesla_project/cases/CaseRepository.java | 44 - .../cases/CaseRepositoryFactory.java | 18 - .../eu/itesla_project/cases/CaseType.java | 16 - cim1-import/pom.xml | 15 +- cmake/FindLibArchive.cmake | 70 - cmake/FindProtobuf.cmake | 66 - commons/pom.xml | 120 - .../eu/itesla_project/commons/Version.java | 85 - .../commons/ITeslaException.java | 25 - .../itesla_project/commons/Versionable.java | 19 - .../commons/collect/Downcast.java | 22 - .../config/ComponentDefaultConfig.java | 59 - .../config/InMemoryPlatformConfig.java | 55 - .../commons/config/MapModuleConfig.java | 236 - .../commons/config/ModuleConfig.java | 72 - .../commons/config/PlatformConfig.java | 99 - .../config/PropertiesPlatformConfig.java | 119 - .../commons/config/XmlPlatformConfig.java | 72 - .../commons/io/BufferedLineParser.java | 41 - .../commons/io/CacheManager.java | 182 - .../itesla_project/commons/io/FileUtil.java | 40 - .../commons/io/ForwardingInputStream.java | 68 - .../commons/io/ForwardingOutputStream.java | 53 - .../itesla_project/commons/io/MathUtil.java | 44 - .../commons/io/SystemOutStreamWriter.java | 25 - .../commons/io/WorkingDirectory.java | 37 - .../io/table/AbstractTableFormatter.java | 64 - .../commons/io/table/AsciiTableFormatter.java | 60 - .../io/table/AsciiTableFormatterFactory.java | 21 - .../commons/io/table/Column.java | 25 - .../commons/io/table/CsvTableFormatter.java | 98 - .../io/table/CsvTableFormatterFactory.java | 21 - .../commons/io/table/TableFormatter.java | 33 - .../io/table/TableFormatterConfig.java | 100 - .../io/table/TableFormatterFactory.java | 19 - .../commons/jaxb/IntervalAdapter.java | 28 - .../commons/jaxb/JaxbContextCache.java | 42 - .../itesla_project/commons/jaxb/JaxbUtil.java | 106 - .../commons/net/ConnectionParameters.java | 46 - .../itesla_project/commons/tools/Command.java | 62 - .../eu/itesla_project/commons/tools/Main.java | 104 - .../eu/itesla_project/commons/tools/Tool.java | 30 - .../commons/tools/VersionTool.java | 61 - .../commons/util/IntCounter.java | 17 - .../commons/util/ServiceLoaderCache.java | 36 - .../commons/util/StringToIntMapper.java | 136 - .../commons/ConverterBaseTest.java | 103 - .../config/ComponentDefaultConfigTest.java | 74 - .../commons/config/XmlPlatformConfigTest.java | 156 - .../commons/io/table/TableFormatterTest.java | 66 - computation-local/pom.xml | 32 - .../local/LocalComputationConfig.java | 67 - .../local/LocalComputationManager.java | 375 - .../LocalComputationResourcesStatus.java | 61 - computation-mpi-util/pom.xml | 36 - ...tiStateNetworkAwareMpiExecutorContext.java | 72 - ...NetworkAwareMpiExecutorContextFactory.java | 20 - computation-mpi/pom.xml | 75 - .../computation/mpi/CommonFile.java | 46 - .../itesla_project/computation/mpi/Core.java | 29 - .../computation/mpi/CorePool.java | 73 - .../computation/mpi/CsvMpiStatistics.java | 617 -- .../mpi/CsvMpiStatisticsFactory.java | 22 - .../mpi/DefaultMpiExecutorContext.java | 51 - .../mpi/DefaultMpiExecutorContextFactory.java | 18 - .../mpi/ExportTasksStatisticsCommand.java | 66 - .../mpi/ExportTasksStatisticsTool.java | 43 - .../computation/mpi/JniMpiNativeServices.java | 34 - .../mpi/MpiComputationManager.java | 336 - .../mpi/MpiComputationResourcesStatus.java | 52 - .../computation/mpi/MpiExecutorContext.java | 31 - .../mpi/MpiExecutorContextFactory.java | 15 - .../computation/mpi/MpiJob.java | 104 - .../computation/mpi/MpiJobScheduler.java | 34 - .../computation/mpi/MpiJobSchedulerImpl.java | 631 -- .../computation/mpi/MpiNativeServices.java | 30 - .../computation/mpi/MpiRank.java | 31 - .../computation/mpi/MpiResources.java | 106 - .../computation/mpi/MpiStatistics.java | 79 - .../computation/mpi/MpiStatisticsFactory.java | 19 - .../computation/mpi/MpiTask.java | 83 - .../computation/mpi/NoMpiStatistics.java | 48 - .../mpi/NoMpiStatisticsFactory.java | 22 - .../mpi/ProfiledExecutionListener.java | 69 - .../computation/mpi/messages/Messages.java | 8665 ----------------- computation-mpi/src/main/proto/messages.proto | 91 - .../computation/mpi/CorePoolTest.java | 95 - .../mpi/MpiComputationManagerTest.java | 269 - computation/pom.xml | 39 - .../computation/AbstractCommand.java | 66 - .../computation/AbstractCommandBuilder.java | 51 - .../AbstractExecutionListener.java | 27 - .../itesla_project/computation/Command.java | 34 - .../computation/CommandExecution.java | 60 - .../computation/CommandExecutor.java | 27 - .../computation/CommandType.java | 16 - .../computation/ComputationManager.java | 36 - .../ComputationResourcesStatus.java | 26 - .../computation/DefaultExecutionHandler.java | 36 - .../computation/ExecutionEnvironment.java | 44 - .../computation/ExecutionError.java | 50 - .../computation/ExecutionHandler.java | 25 - .../computation/ExecutionListener.java | 21 - .../computation/ExecutionReport.java | 42 - .../computation/FilePostProcessor.java | 15 - .../computation/FilePreProcessor.java | 16 - .../computation/GroupCommand.java | 33 - .../computation/GroupCommandBuilder.java | 74 - .../computation/GroupCommandImpl.java | 92 - .../itesla_project/computation/InputFile.java | 68 - .../computation/OutputFile.java | 56 - .../computation/SimpleCommand.java | 23 - .../computation/SimpleCommandBuilder.java | 61 - .../computation/SimpleCommandImpl.java | 67 - .../computation/util/AbstractExecutor.java | 85 - config/logback-cmdline.xml | 20 - contingency-api/pom.xml | 32 - .../contingency/ContingenciesProvider.java | 20 - .../ContingenciesProviderFactory.java | 15 - .../contingency/Contingency.java | 25 - .../contingency/ContingencyElement.java | 23 - .../contingency/ContingencyElementType.java | 15 - .../contingency/ContingencyImpl.java | 58 - .../contingency/GeneratorContingency.java | 39 - .../contingency/LineContingency.java | 39 - .../ContingenciesProviderFactoryMock.java | 21 - .../mock/ContingenciesProviderMock.java | 25 - .../contingency/tasks/BranchTripping.java | 53 - .../tasks/CompoundModificationTask.java | 36 - .../contingency/tasks/GeneratorTripping.java | 34 - .../contingency/tasks/ModificationTask.java | 19 - distribution/pom.xml | 6 - .../src/main/resources/assemblies/full.xml | 11 +- entsoe-util/pom.xml | 13 +- eurostag-ech-export/pom.xml | 22 +- eurostag-step-up-transformer/pom.xml | 31 +- graph/pom.xml | 45 - .../eu/itesla_project/graph/GraphUtil.java | 108 - .../itesla_project/graph/TraverseResult.java | 16 - .../eu/itesla_project/graph/Traverser.java | 16 - .../itesla_project/graph/UndirectedGraph.java | 68 - .../graph/UndirectedGraphImpl.java | 461 - .../graph/UndirectedGraphListener.java | 16 - .../graph/UndirectedGraphImplTest.java | 148 - iidm-converter-api/pom.xml | 63 - .../AbstractDataSourceObserver.java | 25 - .../iidm/datasource/Bzip2FileDataSource.java | 76 - .../ClassLoaderZipFileDataSource.java | 61 - .../iidm/datasource/DataSource.java | 19 - .../iidm/datasource/DataSourceObserver.java | 20 - .../iidm/datasource/DataSourceUtil.java | 21 - .../iidm/datasource/FileDataSource.java | 78 - .../datasource/GenericReadOnlyDataSource.java | 76 - .../iidm/datasource/GzFileDataSource.java | 77 - .../iidm/datasource/MemDataSource.java | 108 - .../datasource/ObservableInputStream.java | 40 - .../datasource/ObservableOutputStream.java | 42 - .../iidm/datasource/ReadOnlyDataSource.java | 26 - .../datasource/ReadOnlyDataSourceFactory.java | 18 - .../iidm/datasource/ZipFileDataSource.java | 136 - .../itesla_project/iidm/export/Exporter.java | 46 - .../itesla_project/iidm/export/Exporters.java | 89 - .../iidm/import_/ImportConfig.java | 58 - .../iidm/import_/ImportPostProcessor.java | 22 - .../itesla_project/iidm/import_/Importer.java | 75 - .../iidm/import_/Importers.java | 399 - .../iidm/import_/ImportersLoader.java | 20 - .../iidm/import_/ImportersServiceLoader.java | 31 - .../iidm/import_/JavaScriptPostProcessor.java | 59 - .../iidm/parameters/Parameter.java | 49 - .../ParameterDefaultValueConfig.java | 54 - .../iidm/parameters/ParameterType.java | 28 - .../iidm/tools/ConversionCommand.java | 87 - .../iidm/tools/ConversionTool.java | 69 - .../iidm-ddb-eurostag-import-export/pom.xml | 38 +- iidm-network-api/pom.xml | 59 - .../iidm/network/AbstractNetworkListener.java | 24 - .../iidm/network/AbstractTopologyVisitor.java | 54 - .../eu/itesla_project/iidm/network/Bus.java | 114 - .../itesla_project/iidm/network/BusAdder.java | 17 - .../iidm/network/BusbarSection.java | 20 - .../iidm/network/BusbarSectionAdder.java | 18 - .../iidm/network/ChangeType.java | 16 - .../iidm/network/Connectable.java | 30 - .../iidm/network/ConnectableType.java | 24 - .../iidm/network/ConnectedComponent.java | 35 - .../iidm/network/Container.java | 15 - .../iidm/network/ContainerType.java | 16 - .../itesla_project/iidm/network/Country.java | 275 - .../iidm/network/CurrentLimits.java | 93 - .../iidm/network/CurrentLimitsAdder.java | 34 - .../iidm/network/DanglingLine.java | 105 - .../iidm/network/DanglingLineAdder.java | 45 - .../iidm/network/EnergySource.java | 32 - .../network/EquipmentTopologyVisitor.java | 61 - .../iidm/network/Equipments.java | 63 - .../iidm/network/Generator.java | 127 - .../iidm/network/GeneratorAdder.java | 51 - .../iidm/network/HvdcConverterStation.java | 32 - .../itesla_project/iidm/network/HvdcLine.java | 113 - .../iidm/network/HvdcLineAdder.java | 32 - .../iidm/network/Identifiable.java | 76 - .../iidm/network/IdentifiableAdder.java | 21 - .../iidm/network/LccConverterStation.java | 60 - .../network/LccConverterStationAdder.java | 20 - .../iidm/network/LccFilter.java | 44 - .../iidm/network/LccFilterAdder.java | 20 - .../eu/itesla_project/iidm/network/Line.java | 25 - .../iidm/network/LineAdder.java | 42 - .../iidm/network/LineCharasteristics.java | 74 - .../eu/itesla_project/iidm/network/Load.java | 53 - .../iidm/network/LoadAdder.java | 37 - .../itesla_project/iidm/network/LoadType.java | 16 - .../iidm/network/MinMaxReactiveLimits.java | 21 - .../network/MinMaxReactiveLimitsAdder.java | 21 - .../itesla_project/iidm/network/Network.java | 403 - .../iidm/network/NetworkFactory.java | 35 - .../iidm/network/NetworkFactoryService.java | 16 - .../iidm/network/NetworkListener.java | 20 - .../iidm/network/PhaseTapChanger.java | 53 - .../iidm/network/PhaseTapChangerAdder.java | 47 - .../iidm/network/PhaseTapChangerHolder.java | 28 - .../iidm/network/PhaseTapChangerStep.java | 25 - .../iidm/network/RatioTapChanger.java | 37 - .../iidm/network/RatioTapChangerAdder.java | 46 - .../iidm/network/RatioTapChangerHolder.java | 28 - .../iidm/network/RatioTapChangerStep.java | 15 - .../iidm/network/ReactiveCapabilityCurve.java | 72 - .../network/ReactiveCapabilityCurveAdder.java | 29 - .../iidm/network/ReactiveLimits.java | 32 - .../iidm/network/ReactiveLimitsHolder.java | 32 - .../iidm/network/ReactiveLimitsKind.java | 16 - .../iidm/network/ShuntCompensator.java | 81 - .../iidm/network/ShuntCompensatorAdder.java | 37 - .../network/SingleTerminalConnectable.java | 21 - .../SingleTerminalConnectableAdder.java | 21 - .../iidm/network/StateManager.java | 85 - .../iidm/network/StaticVarCompensator.java | 97 - .../network/StaticVarCompensatorAdder.java | 25 - .../iidm/network/Substation.java | 80 - .../iidm/network/SubstationAdder.java | 36 - .../itesla_project/iidm/network/Switch.java | 50 - .../iidm/network/SwitchKind.java | 18 - .../iidm/network/TapChanger.java | 97 - .../iidm/network/TapChangerStep.java | 65 - .../itesla_project/iidm/network/Terminal.java | 163 - .../iidm/network/TerminalTopologyVisitor.java | 89 - .../network/ThreeWindingsTransformer.java | 144 - .../ThreeWindingsTransformerAdder.java | 54 - .../itesla_project/iidm/network/TieLine.java | 58 - .../iidm/network/TieLineAdder.java | 38 - .../iidm/network/TopologyKind.java | 17 - .../iidm/network/TopologyVisitor.java | 34 - .../iidm/network/TwoTerminalsConnectable.java | 77 - .../network/TwoTerminalsConnectableAdder.java | 31 - .../iidm/network/TwoWindingsTransformer.java | 123 - .../network/TwoWindingsTransformerAdder.java | 29 - .../iidm/network/VoltageLevel.java | 803 -- .../iidm/network/VoltageLevelAdder.java | 26 - .../iidm/network/VscConverterStation.java | 55 - .../network/VscConverterStationAdder.java | 24 - .../network/util/ConnectedComponents.java | 32 - .../network/util/GraphvizConnectivity.java | 142 - .../iidm/network/util/Identifiables.java | 34 - .../iidm/network/util/Networks.java | 437 - .../itesla_project/iidm/network/util/SV.java | 129 - .../iidm/network/util/ShortIdDictionary.java | 59 - .../network/doc-files/busBreakerTopology.svg | 395 - .../iidm/network/doc-files/busTopology.svg | 334 - .../iidm/network/doc-files/currentLimits.svg | 255 - .../iidm/network/doc-files/danglingLine.svg | 306 - .../iidm/network/doc-files/line.svg | 288 - .../network/doc-files/nodeBreakerTopology.svg | 675 -- .../doc-files/nodeBreakerTopologyGraph.svg | 1116 --- .../doc-files/threeWindingsTransformer.svg | 552 -- .../doc-files/twoWindingsTransformer.svg | 357 - .../iidm/network/util/NetworksTest.java | 49 - iidm-network-impl/pom.xml | 69 - .../iidm/network/impl/AbstractBus.java | 231 - .../iidm/network/impl/AbstractTerminal.java | 154 - .../impl/AbstractTwoTerminalsConnectable.java | 220 - .../network/impl/AbstractVoltageLevel.java | 268 - .../iidm/network/impl/Boundary.java | 45 - .../iidm/network/impl/BusAdderImpl.java | 42 - .../network/impl/BusBreakerVoltageLevel.java | 855 -- .../iidm/network/impl/BusExt.java | 23 - .../iidm/network/impl/BusTerminal.java | 172 - .../network/impl/BusbarSectionAdderImpl.java | 54 - .../iidm/network/impl/BusbarSectionImpl.java | 46 - .../iidm/network/impl/CalculatedBus.java | 17 - .../iidm/network/impl/CalculatedBusImpl.java | 188 - .../iidm/network/impl/ConfiguredBus.java | 25 - .../iidm/network/impl/ConfiguredBusImpl.java | 163 - .../iidm/network/impl/ConnectableImpl.java | 87 - .../network/impl/ConnectedComponentImpl.java | 53 - .../network/impl/CurrentLimitsAdderImpl.java | 148 - .../iidm/network/impl/CurrentLimitsImpl.java | 87 - .../iidm/network/impl/CurrentLimitsOwner.java | 17 - .../network/impl/DanglingLineAdderImpl.java | 109 - .../iidm/network/impl/DanglingLineImpl.java | 208 - .../iidm/network/impl/GeneratorAdderImpl.java | 133 - .../iidm/network/impl/GeneratorImpl.java | 282 - .../impl/HvdcConverterStationImpl.java | 33 - .../iidm/network/impl/HvdcLineAdderImpl.java | 117 - .../iidm/network/impl/HvdcLineImpl.java | 195 - .../network/impl/IdentifiableAdderImpl.java | 74 - .../iidm/network/impl/IdentifiableImpl.java | 91 - .../impl/LccConverterStationAdderImpl.java | 57 - .../network/impl/LccConverterStationImpl.java | 101 - .../iidm/network/impl/LccFilterAdderImpl.java | 54 - .../iidm/network/impl/LccFilterImpl.java | 97 - .../iidm/network/impl/LineAdderImpl.java | 112 - .../iidm/network/impl/LineImpl.java | 139 - .../iidm/network/impl/LoadAdderImpl.java | 73 - .../iidm/network/impl/LoadImpl.java | 133 - .../iidm/network/impl/MergedBus.java | 260 - .../impl/MinMaxReactiveLimitsAdderImpl.java | 56 - .../impl/MinMaxReactiveLimitsImpl.java | 52 - .../iidm/network/impl/MultiStateContext.java | 40 - .../iidm/network/impl/MultiStateObject.java | 19 - .../impl/NetworkFactoryServiceImpl.java | 23 - .../iidm/network/impl/NetworkImpl.java | 840 -- .../network/impl/NetworkListenerList.java | 66 - .../network/impl/NodeBreakerVoltageLevel.java | 1157 --- .../iidm/network/impl/NodeTerminal.java | 195 - .../iidm/network/impl/ObjectStore.java | 167 - .../impl/PhaseTapChangerAdderImpl.java | 184 - .../network/impl/PhaseTapChangerImpl.java | 113 - .../network/impl/PhaseTapChangerStepImpl.java | 36 - .../impl/RatioTapChangerAdderImpl.java | 174 - .../network/impl/RatioTapChangerImpl.java | 110 - .../network/impl/RatioTapChangerParent.java | 19 - .../network/impl/RatioTapChangerStepImpl.java | 21 - .../ReactiveCapabilityCurveAdderImpl.java | 91 - .../impl/ReactiveCapabilityCurveImpl.java | 132 - .../network/impl/ReactiveLimitsOwner.java | 17 - .../impl/ShuntCompensatorAdderImpl.java | 74 - .../network/impl/ShuntCompensatorImpl.java | 142 - .../SingleTerminalConnectableAdderImpl.java | 43 - .../iidm/network/impl/State.java | 17 - .../iidm/network/impl/StateArray.java | 71 - .../iidm/network/impl/StateContext.java | 21 - .../iidm/network/impl/StateFactory.java | 17 - .../iidm/network/impl/StateManagerImpl.java | 248 - .../iidm/network/impl/Stateful.java | 52 - .../impl/StaticVarCompensatorAdderImpl.java | 92 - .../impl/StaticVarCompensatorImpl.java | 166 - .../network/impl/SubstationAdderImpl.java | 75 - .../iidm/network/impl/SubstationImpl.java | 151 - .../iidm/network/impl/Substations.java | 48 - .../iidm/network/impl/SwitchImpl.java | 98 - .../iidm/network/impl/TapChangerImpl.java | 150 - .../iidm/network/impl/TapChangerParent.java | 20 - .../iidm/network/impl/TapChangerStepImpl.java | 78 - .../iidm/network/impl/TerminalBuilder.java | 63 - .../iidm/network/impl/TerminalExt.java | 48 - .../impl/ThreadLocalMultiStateContext.java | 46 - .../ThreeWindingsTransformerAdderImpl.java | 270 - .../impl/ThreeWindingsTransformerImpl.java | 350 - .../iidm/network/impl/TieLineAdderImpl.java | 192 - .../iidm/network/impl/TieLineImpl.java | 232 - .../TwoTerminalsConnectableAdderImpl.java | 111 - .../impl/TwoWindingsTransformerAdderImpl.java | 125 - .../impl/TwoWindingsTransformerImpl.java | 235 - .../iidm/network/impl/Validable.java | 17 - .../network/impl/ValidationException.java | 21 - .../iidm/network/impl/ValidationUtil.java | 338 - .../network/impl/VoltageLevelAdderImpl.java | 99 - .../iidm/network/impl/VoltageLevelExt.java | 65 - .../impl/VscConverterStationAdderImpl.java | 72 - .../network/impl/VscConverterStationImpl.java | 166 - .../util/MultiStateNetworkAwareExecutors.java | 84 - .../iidm/network/impl/util/Ref.java | 17 - .../iidm/network/impl/util/RefChain.java | 30 - .../iidm/network/impl/util/RefObj.java | 29 - ...project.iidm.network.NetworkFactoryService | 1 - .../ConnectedComponentWithTieLineBugTest.java | 95 - .../iidm/network/impl/CurrentLimitsTest.java | 106 - ...emoveStateAndWorkingStateIsNotSetTest.java | 44 - .../impl/IdentifiableExtensionTest.java | 57 - .../iidm/network/impl/LccTest.java | 89 - .../network/impl/MultiStateNetworkTest.java | 157 - .../iidm/network/impl/NetworkRemoveTest.java | 138 - .../iidm/network/impl/NetworkTest.java | 125 - .../NodeBreakerConnectDisconnectTest.java | 97 - ...BreakerDisconnectionDoublePathBugTest.java | 83 - ...lPointerWhenRemovingMergedLineBugTest.java | 83 - .../impl/ReactiveCapabilityCurveImplTest.java | 52 - .../network/impl/StateManagerImplTest.java | 170 - .../impl/StaticVarCompensatorTest.java | 104 - .../SwitchOpenCloseNodeBreakerTopoTest.java | 98 - .../network/impl/TopologyTraverserTest.java | 224 - .../iidm/network/impl/VscTest.java | 54 - .../MultiStateNetworkAwareExecutorsTest.java | 51 - iidm-network-test/pom.xml | 32 - .../test/EurostagTutorialExample1Factory.java | 192 - .../iidm/network/test/HvdcTestNetwork.java | 168 - .../iidm/network/test/LoadZipModel.java | 110 - .../network/test/NetworkTest1Factory.java | 107 - .../test/PhaseShifterTestCaseFactory.java | 166 - .../iidm/network/test/SvcTestCaseFactory.java | 97 - iidm-xml-converter/pom.xml | 100 - .../itesla_project/iidm/xml/Anonymizer.java | 30 - .../iidm/xml/BusBreakerViewSwitchXml.java | 47 - .../eu/itesla_project/iidm/xml/BusFilter.java | 97 - .../eu/itesla_project/iidm/xml/BusXml.java | 64 - .../iidm/xml/BusbarSectionXml.java | 72 - .../iidm/xml/ConnectableXml.java | 224 - .../iidm/xml/DanglingLineXml.java | 94 - .../itesla_project/iidm/xml/ExtensionXml.java | 35 - .../iidm/xml/FakeAnonymizer.java | 45 - .../itesla_project/iidm/xml/GeneratorXml.java | 107 - .../itesla_project/iidm/xml/HvdcLineXml.java | 78 - .../iidm/xml/IdentifiableXml.java | 84 - .../iidm/xml/LccConverterStationXml.java | 84 - .../eu/itesla_project/iidm/xml/LineXml.java | 104 - .../eu/itesla_project/iidm/xml/LoadXml.java | 73 - .../itesla_project/iidm/xml/NetworkXml.java | 445 - .../iidm/xml/NodeBreakerViewSwitchXml.java | 49 - .../iidm/xml/ReactiveLimitsXml.java | 83 - .../eu/itesla_project/iidm/xml/ShuntXml.java | 71 - .../iidm/xml/SimpleAnonymizer.java | 99 - .../iidm/xml/StaticVarCompensatorXml.java | 76 - .../iidm/xml/SubstationXml.java | 110 - .../eu/itesla_project/iidm/xml/SwitchXml.java | 48 - .../iidm/xml/ThreeWindingsTransformerXml.java | 98 - .../itesla_project/iidm/xml/TieLineXml.java | 131 - .../iidm/xml/TransformerXml.java | 177 - .../iidm/xml/TwoWindingsTransformerXml.java | 121 - .../iidm/xml/VoltageLevelXml.java | 240 - .../iidm/xml/VscConverterStationXml.java | 83 - .../iidm/xml/XMLExportOptions.java | 90 - .../itesla_project/iidm/xml/XMLExporter.java | 111 - .../itesla_project/iidm/xml/XMLImporter.java | 143 - .../itesla_project/iidm/xml/XmlConstants.java | 31 - .../itesla_project/iidm/xml/XmlContext.java | 23 - .../iidm/xml/XmlImportConfig.java | 31 - .../iidm/xml/XmlReaderContext.java | 35 - .../eu/itesla_project/iidm/xml/XmlUtil.java | 94 - .../iidm/xml/XmlWriterContext.java | 38 - .../src/main/resources/icons/itesla16x16.png | Bin 1072 -> 0 bytes .../src/main/resources/xsd/iidm.xsd | 523 - .../itesla_project/iidm/xml/HvdcXmlTest.java | 35 - .../xml/IdentifiableExtensionXmlTest.java | 55 - .../iidm/xml/LoadZipModelXml.java | 75 - .../iidm/xml/NetworkXmlTest.java | 57 - .../iidm/xml/OptionalLoadTypeBugTest.java | 20 - .../iidm/xml/PhaseShifterXmlTest.java | 27 - .../iidm/xml/ReactiveLimitsXmlTest.java | 86 - .../iidm/xml/SimpleAnonymizerTest.java | 58 - .../iidm/xml/StaticVarCompensatorXmlTest.java | 27 - .../src/test/resources/LccRoundTripRef.xml | 28 - .../src/test/resources/VscRoundTripRef.xml | 29 - .../eurostag-tutorial-example1-anonymized.xml | 42 - .../eurostag-tutorial-example1-mapping.csv | 19 - .../resources/eurostag-tutorial-example1.xml | 42 - .../test/resources/optionalLoadTypeBug.xml | 11 - .../resources/phaseShifterRoundTripRef.xml | 36 - .../resources/reactiveLimitsRoundTripRef.xml | 19 - .../staticVarCompensatorRoundTripRef.xml | 23 - .../src/test/resources/xsd/loadZipModel.xsd | 25 - loadflow-api/pom.xml | 37 - .../itesla_project/loadflow/api/LoadFlow.java | 27 - .../loadflow/api/LoadFlowFactory.java | 20 - .../loadflow/api/LoadFlowParameters.java | 136 - .../loadflow/api/LoadFlowResult.java | 23 - .../api/mock/LoadFlowFactoryMock.java | 23 - .../loadflow/api/mock/LoadFlowMock.java | 62 - mmap-offline-db/pom.xml | 7 +- modelica-events-adder/pom.xml | 4 + modelica-export/pom.xml | 9 +- modules/pom.xml | 16 +- mpi-communication/CMakeLists.txt | 49 - mpi-communication/src/ioutil.cpp | 302 - mpi-communication/src/ioutil.hpp | 40 - mpi-communication/src/jniutil.cpp | 72 - mpi-communication/src/jniutil.hpp | 132 - mpi-communication/src/master.cpp | 508 - mpi-communication/src/messages.pb.cc | 3433 ------- mpi-communication/src/messages.pb.h | 2602 ----- mpi-communication/src/mpitags.cpp | 66 - mpi-communication/src/mpitags.hpp | 38 - mpi-communication/src/mpiutil.cpp | 52 - mpi-communication/src/mpiutil.hpp | 26 - mpi-communication/src/slave.cpp | 981 -- network-merge/pom.xml | 20 +- offline-workflow/pom.xml | 7 +- pom.xml | 285 +- scripts/itools | 43 - security-analysis/pom.xml | 77 - .../security/LimitViolation.java | 81 - .../security/LimitViolationFilter.java | 93 - .../security/LimitViolationType.java | 16 - .../security/LimitViolationsResult.java | 40 - .../security/PostContingencyResult.java | 35 - .../security/PreContingencyResult.java | 25 - .../eu/itesla_project/security/Security.java | 356 - .../security/SecurityAnalysis.java | 24 - .../security/SecurityAnalysisFactory.java | 19 - .../security/SecurityAnalysisFactoryImpl.java | 24 - .../security/SecurityAnalysisImpl.java | 132 - .../security/SecurityAnalysisResult.java | 33 - .../security/SecurityAnalysisTool.java | 135 - .../security/LimitViolationFilterTest.java | 73 - simulation-api/pom.xml | 56 - .../simulation/ImpactAnalysis.java | 32 - .../simulation/ImpactAnalysisCommand.java | 63 - .../ImpactAnalysisProgressListener.java | 16 - .../simulation/ImpactAnalysisResult.java | 46 - .../simulation/ImpactAnalysisTool.java | 257 - .../SimulationDetailedParameters.java | 193 - .../simulation/SimulationParameters.java | 233 - .../simulation/SimulationState.java | 17 - .../simulation/SimulatorFactory.java | 23 - .../simulation/Stabilization.java | 25 - .../simulation/StabilizationResult.java | 23 - .../simulation/StabilizationStatus.java | 16 - .../AbstractSecurityIndex.java | 69 - .../MultiCriteriaVoltageStabilityIndex.java | 174 - .../MultiCriteriaVoltageStabilityIndex2.java | 197 - .../OverloadSecurityIndex.java | 77 - .../securityindexes/SecurityIndex.java | 34 - .../securityindexes/SecurityIndexId.java | 95 - .../securityindexes/SecurityIndexParser.java | 93 - .../securityindexes/SecurityIndexType.java | 58 - .../SmallSignalSecurityIndex.java | 332 - .../TransientSecurityIndex.java | 77 - .../TsoDisconnectedGenerator.java | 99 - .../TsoFrequencySecurityIndex.java | 78 - .../TsoGeneratorSpeedAutomaton.java | 124 - .../TsoGeneratorVoltageAutomaton.java | 124 - .../TsoOverloadSecurityIndex.java | 127 - .../TsoOvervoltageSecurityIndex.java | 99 - .../TsoSynchroLossSecurityIndex.java | 117 - .../TsoUndervoltageSecurityIndex.java | 100 - .../UnderOverVoltageSecurityIndex.java | 76 - .../OverloadSecurityIndexTest.java | 44 - .../SmallSignalSecurityIndexTest.java | 47 - .../TransientSecurityIndexTest.java | 44 - .../TsoFrequencySecurityIndexTest.java | 44 - .../TsoGeneratorSpeedAutomatonTest.java | 44 - .../TsoGeneratorVoltageAutomatonTest.java | 43 - .../TsoOverloadSecurityIndexTest.java | 44 - .../TsoOvervoltageSecurityIndexTest.java | 44 - .../TsoSynchroLossSecurityIndexTest.java | 44 - .../TsoUndervoltageSecurityIndexTest.java | 44 - .../UnderOverVoltageSecurityIndexTest.java | 44 - ucte-import/pom.xml | 7 +- 552 files changed, 316 insertions(+), 65198 deletions(-) delete mode 100644 case-repository/pom.xml delete mode 100644 case-repository/src/main/java/eu/itesla_project/cases/CaseRepository.java delete mode 100644 case-repository/src/main/java/eu/itesla_project/cases/CaseRepositoryFactory.java delete mode 100644 case-repository/src/main/java/eu/itesla_project/cases/CaseType.java delete mode 100644 cmake/FindLibArchive.cmake delete mode 100644 cmake/FindProtobuf.cmake delete mode 100644 commons/pom.xml delete mode 100644 commons/src/main/java-templates/eu/itesla_project/commons/Version.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/ITeslaException.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/Versionable.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/collect/Downcast.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/config/ComponentDefaultConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/config/InMemoryPlatformConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/config/MapModuleConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/config/ModuleConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/config/PlatformConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/config/PropertiesPlatformConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/config/XmlPlatformConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/BufferedLineParser.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/CacheManager.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/FileUtil.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/ForwardingInputStream.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/ForwardingOutputStream.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/MathUtil.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/SystemOutStreamWriter.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/WorkingDirectory.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/AbstractTableFormatter.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatter.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatterFactory.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/Column.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatter.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatterFactory.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatter.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterConfig.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterFactory.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/jaxb/IntervalAdapter.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbContextCache.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbUtil.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/net/ConnectionParameters.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/tools/Command.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/tools/Main.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/tools/Tool.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/tools/VersionTool.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/util/IntCounter.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/util/ServiceLoaderCache.java delete mode 100644 commons/src/main/java/eu/itesla_project/commons/util/StringToIntMapper.java delete mode 100644 commons/src/test/java/eu/itesla_project/commons/ConverterBaseTest.java delete mode 100644 commons/src/test/java/eu/itesla_project/commons/config/ComponentDefaultConfigTest.java delete mode 100644 commons/src/test/java/eu/itesla_project/commons/config/XmlPlatformConfigTest.java delete mode 100644 commons/src/test/java/eu/itesla_project/commons/io/table/TableFormatterTest.java delete mode 100644 computation-local/pom.xml delete mode 100644 computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationConfig.java delete mode 100644 computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationManager.java delete mode 100644 computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationResourcesStatus.java delete mode 100644 computation-mpi-util/pom.xml delete mode 100644 computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContext.java delete mode 100644 computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContextFactory.java delete mode 100644 computation-mpi/pom.xml delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CommonFile.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/Core.java delete mode 100755 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CorePool.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatistics.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatisticsFactory.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContext.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContextFactory.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsCommand.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsTool.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/JniMpiNativeServices.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationManager.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationResourcesStatus.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContext.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContextFactory.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJob.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobScheduler.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobSchedulerImpl.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiNativeServices.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiRank.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiResources.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatistics.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatisticsFactory.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiTask.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatistics.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatisticsFactory.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ProfiledExecutionListener.java delete mode 100644 computation-mpi/src/main/java/eu/itesla_project/computation/mpi/messages/Messages.java delete mode 100644 computation-mpi/src/main/proto/messages.proto delete mode 100755 computation-mpi/src/test/java/eu/itesla_project/computation/mpi/CorePoolTest.java delete mode 100644 computation-mpi/src/test/java/eu/itesla_project/computation/mpi/MpiComputationManagerTest.java delete mode 100644 computation/pom.xml delete mode 100644 computation/src/main/java/eu/itesla_project/computation/AbstractCommand.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/AbstractCommandBuilder.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/AbstractExecutionListener.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/Command.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/CommandExecution.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/CommandExecutor.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/CommandType.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/ComputationManager.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/ComputationResourcesStatus.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/DefaultExecutionHandler.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/ExecutionEnvironment.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/ExecutionError.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/ExecutionHandler.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/ExecutionListener.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/ExecutionReport.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/FilePostProcessor.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/FilePreProcessor.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/GroupCommand.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/GroupCommandBuilder.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/GroupCommandImpl.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/InputFile.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/OutputFile.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/SimpleCommand.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/SimpleCommandBuilder.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/SimpleCommandImpl.java delete mode 100644 computation/src/main/java/eu/itesla_project/computation/util/AbstractExecutor.java delete mode 100644 config/logback-cmdline.xml delete mode 100644 contingency-api/pom.xml delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProvider.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProviderFactory.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/Contingency.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElement.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElementType.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyImpl.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/GeneratorContingency.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/LineContingency.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderFactoryMock.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderMock.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/tasks/BranchTripping.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/tasks/CompoundModificationTask.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/tasks/GeneratorTripping.java delete mode 100644 contingency-api/src/main/java/eu/itesla_project/contingency/tasks/ModificationTask.java delete mode 100644 graph/pom.xml delete mode 100644 graph/src/main/java/eu/itesla_project/graph/GraphUtil.java delete mode 100644 graph/src/main/java/eu/itesla_project/graph/TraverseResult.java delete mode 100644 graph/src/main/java/eu/itesla_project/graph/Traverser.java delete mode 100644 graph/src/main/java/eu/itesla_project/graph/UndirectedGraph.java delete mode 100644 graph/src/main/java/eu/itesla_project/graph/UndirectedGraphImpl.java delete mode 100644 graph/src/main/java/eu/itesla_project/graph/UndirectedGraphListener.java delete mode 100644 graph/src/test/java/eu/itesla_project/graph/UndirectedGraphImplTest.java delete mode 100644 iidm-converter-api/pom.xml delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/AbstractDataSourceObserver.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/Bzip2FileDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ClassLoaderZipFileDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceObserver.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceUtil.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/FileDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GenericReadOnlyDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GzFileDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/MemDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableInputStream.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableOutputStream.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSourceFactory.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ZipFileDataSource.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporter.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporters.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportConfig.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportPostProcessor.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importer.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importers.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersLoader.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersServiceLoader.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/JavaScriptPostProcessor.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/Parameter.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterDefaultValueConfig.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterType.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionCommand.java delete mode 100644 iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionTool.java delete mode 100644 iidm-network-api/pom.xml delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractNetworkListener.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractTopologyVisitor.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Bus.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSection.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSectionAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ChangeType.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Connectable.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectableType.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectedComponent.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Container.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ContainerType.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Country.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimitsAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLine.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLineAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EnergySource.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EquipmentTopologyVisitor.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Equipments.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Generator.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/GeneratorAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcConverterStation.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLine.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLineAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Identifiable.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/IdentifiableAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStation.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStationAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilter.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilterAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Line.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineCharasteristics.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Load.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadType.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimits.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimitsAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Network.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactory.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactoryService.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkListener.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChanger.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerHolder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerStep.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChanger.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerHolder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerStep.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurve.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurveAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimits.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsHolder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsKind.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensator.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensatorAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectable.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectableAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StateManager.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensator.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensatorAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Substation.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SubstationAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Switch.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SwitchKind.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChanger.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChangerStep.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Terminal.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TerminalTopologyVisitor.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformer.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformerAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLine.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLineAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyKind.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyVisitor.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectable.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectableAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformer.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformerAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevel.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevelAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStation.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStationAdder.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ConnectedComponents.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/GraphvizConnectivity.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Identifiables.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Networks.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/SV.java delete mode 100644 iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ShortIdDictionary.java delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busBreakerTopology.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busTopology.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/currentLimits.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/danglingLine.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/line.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopology.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopologyGraph.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/threeWindingsTransformer.svg delete mode 100644 iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/twoWindingsTransformer.svg delete mode 100644 iidm-network-api/src/test/java/eu/itesla_project/iidm/network/util/NetworksTest.java delete mode 100644 iidm-network-impl/pom.xml delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractBus.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTerminal.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTwoTerminalsConnectable.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractVoltageLevel.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Boundary.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusBreakerVoltageLevel.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusExt.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusTerminal.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBus.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBusImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBus.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBusImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectableImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectedComponentImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsOwner.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcConverterStationImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MergedBus.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateContext.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateObject.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkFactoryServiceImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkListenerList.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeBreakerVoltageLevel.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeTerminal.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ObjectStore.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerStepImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerParent.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerStepImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveLimitsOwner.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SingleTerminalConnectableAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/State.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateArray.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateContext.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateFactory.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateManagerImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Stateful.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Substations.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SwitchImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerParent.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerStepImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalBuilder.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalExt.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreadLocalMultiStateContext.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoTerminalsConnectableAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Validable.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationException.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationUtil.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelExt.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationAdderImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationImpl.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutors.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/Ref.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefChain.java delete mode 100644 iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefObj.java delete mode 100644 iidm-network-impl/src/main/resources/META-INF/services/eu.itesla_project.iidm.network.NetworkFactoryService delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ConnectedComponentWithTieLineBugTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/CurrentLimitsTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ExceptionIsThrownWhenRemoveStateAndWorkingStateIsNotSetTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/IdentifiableExtensionTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/LccTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/MultiStateNetworkTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkRemoveTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerConnectDisconnectTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerDisconnectionDoublePathBugTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NullPointerWhenRemovingMergedLineBugTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImplTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StateManagerImplTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/SwitchOpenCloseNodeBreakerTopoTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/TopologyTraverserTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/VscTest.java delete mode 100644 iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutorsTest.java delete mode 100644 iidm-network-test/pom.xml delete mode 100644 iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/EurostagTutorialExample1Factory.java delete mode 100644 iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/HvdcTestNetwork.java delete mode 100644 iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/LoadZipModel.java delete mode 100644 iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/NetworkTest1Factory.java delete mode 100644 iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/PhaseShifterTestCaseFactory.java delete mode 100644 iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/SvcTestCaseFactory.java delete mode 100644 iidm-xml-converter/pom.xml delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/Anonymizer.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusBreakerViewSwitchXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusFilter.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusbarSectionXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ConnectableXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/DanglingLineXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ExtensionXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/FakeAnonymizer.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/GeneratorXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/HvdcLineXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/IdentifiableXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LccConverterStationXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LineXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LoadXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NetworkXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NodeBreakerViewSwitchXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ReactiveLimitsXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ShuntXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SimpleAnonymizer.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SubstationXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SwitchXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ThreeWindingsTransformerXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TieLineXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TransformerXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TwoWindingsTransformerXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VoltageLevelXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VscConverterStationXml.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExportOptions.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExporter.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLImporter.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlConstants.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlContext.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlImportConfig.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlReaderContext.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlUtil.java delete mode 100644 iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlWriterContext.java delete mode 100644 iidm-xml-converter/src/main/resources/icons/itesla16x16.png delete mode 100644 iidm-xml-converter/src/main/resources/xsd/iidm.xsd delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/HvdcXmlTest.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/IdentifiableExtensionXmlTest.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/LoadZipModelXml.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/NetworkXmlTest.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/OptionalLoadTypeBugTest.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/PhaseShifterXmlTest.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/ReactiveLimitsXmlTest.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/SimpleAnonymizerTest.java delete mode 100644 iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXmlTest.java delete mode 100644 iidm-xml-converter/src/test/resources/LccRoundTripRef.xml delete mode 100644 iidm-xml-converter/src/test/resources/VscRoundTripRef.xml delete mode 100644 iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-anonymized.xml delete mode 100644 iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-mapping.csv delete mode 100644 iidm-xml-converter/src/test/resources/eurostag-tutorial-example1.xml delete mode 100644 iidm-xml-converter/src/test/resources/optionalLoadTypeBug.xml delete mode 100644 iidm-xml-converter/src/test/resources/phaseShifterRoundTripRef.xml delete mode 100644 iidm-xml-converter/src/test/resources/reactiveLimitsRoundTripRef.xml delete mode 100644 iidm-xml-converter/src/test/resources/staticVarCompensatorRoundTripRef.xml delete mode 100644 iidm-xml-converter/src/test/resources/xsd/loadZipModel.xsd delete mode 100644 loadflow-api/pom.xml delete mode 100644 loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlow.java delete mode 100644 loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowFactory.java delete mode 100644 loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowParameters.java delete mode 100644 loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowResult.java delete mode 100644 loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowFactoryMock.java delete mode 100644 loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowMock.java delete mode 100644 mpi-communication/CMakeLists.txt delete mode 100644 mpi-communication/src/ioutil.cpp delete mode 100644 mpi-communication/src/ioutil.hpp delete mode 100644 mpi-communication/src/jniutil.cpp delete mode 100644 mpi-communication/src/jniutil.hpp delete mode 100644 mpi-communication/src/master.cpp delete mode 100644 mpi-communication/src/messages.pb.cc delete mode 100644 mpi-communication/src/messages.pb.h delete mode 100644 mpi-communication/src/mpitags.cpp delete mode 100644 mpi-communication/src/mpitags.hpp delete mode 100644 mpi-communication/src/mpiutil.cpp delete mode 100644 mpi-communication/src/mpiutil.hpp delete mode 100644 mpi-communication/src/slave.cpp delete mode 100755 scripts/itools delete mode 100644 security-analysis/pom.xml delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/LimitViolation.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/LimitViolationFilter.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/LimitViolationType.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/LimitViolationsResult.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/PostContingencyResult.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/PreContingencyResult.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/Security.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysis.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactory.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactoryImpl.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisImpl.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisResult.java delete mode 100644 security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisTool.java delete mode 100644 security-analysis/src/test/java/eu/itesla_project/security/LimitViolationFilterTest.java delete mode 100644 simulation-api/pom.xml delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysis.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisCommand.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisProgressListener.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisResult.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisTool.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/SimulationDetailedParameters.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/SimulationParameters.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/SimulationState.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/SimulatorFactory.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/Stabilization.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationResult.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationStatus.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/AbstractSecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex2.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndex.java delete mode 100755 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexId.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexParser.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexType.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TransientSecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoDisconnectedGenerator.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomaton.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomaton.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndex.java delete mode 100644 simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndex.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TransientSecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomatonTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomatonTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndexTest.java delete mode 100644 simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndexTest.java diff --git a/CMakeLists.txt b/CMakeLists.txt index 5aef4fe5..b2e9a32a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,6 @@ if (DEFINED thirdparty_prefix AND IS_DIRECTORY "${thirdparty_prefix}") else() message(FATAL_ERROR "Thirdparty libraries not found. The variable thirdparty_prefix is NOT set or is NOT a valid directory.") endif() -set(PROTOBUF_HOME ${thirdparty_prefix}/protobuf) -set(LIBARCHIVE_HOME ${thirdparty_prefix}/libarchive) set(BOOST_ROOT ${thirdparty_prefix}/boost) set(LOG4CPP_HOME ${thirdparty_prefix}/log4cpp) set(SZIP_HOME ${thirdparty_prefix}/szip) @@ -40,8 +38,6 @@ set(ZLIB_HOME ${thirdparty_prefix}/zlib) set(HDF5_HOME ${thirdparty_prefix}/hdf5) set(MATIO_HOME ${thirdparty_prefix}/matio) -add_subdirectory(mpi-communication) - if(BUILD_EUROSTAG) message(STATUS "Eurostag based components (eurostag-indexes and wp43adapter) will be compiled.") add_subdirectory(eurostag-indexes) diff --git a/README.md b/README.md index fad76def..00843169 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ In order to build iPST you need: * Maven * CMake *(2.6 or greater)* * Recent C++ compiler (GNU g++ or Clang) - * OpenMPI *(1.8.3 or greater)* + * [ipst-core](https://github.com/itesla/ipst-core) Optional C++ modules requires: * Intel Fortran Compiler @@ -21,17 +21,6 @@ Optional C++ modules requires: * Dymola * Eurostag -### OpenMPI (required) -In order to support the MPI modules, you need to compile and install the [OpenMPI](https://www.open-mpi.org/) library. -``` -$> wget http://www.open-mpi.org/software/ompi/v1.8/downloads/openmpi-1.8.3.tar.bz2 -$> tar xjf openmpi-1.8.3.tar.bz2 -$> cd openmpi-1.8.3 -$> ./configure --prefix= --enable-mpi-thread-multiple -$> make install -$> export PATH=$PATH:/bin -``` - ### Intel Fortran Compiler To compile Eurostag dependant modules, you have to set your INTEL_HOME environment variable to the root of the Intel Fortran Compiler installation. @@ -115,3 +104,4 @@ thirdparty_packs=$HOME/itesla_packs ## License https://www.mozilla.org/en-US/MPL/2.0/ + diff --git a/ampl-export/pom.xml b/ampl-export/pom.xml index b4308864..f952715f 100644 --- a/ampl-export/pom.xml +++ b/ampl-export/pom.xml @@ -28,7 +28,6 @@ ${project.groupId} iidm-converter-api - ${project.version} ${project.groupId} @@ -48,13 +47,16 @@ eu.itesla_project iidm-network-test - ${project.version} test eu.itesla_project iidm-network-impl - ${project.version} + test + + + eu.itesla_project + graph test diff --git a/case-repository/pom.xml b/case-repository/pom.xml deleted file mode 100644 index ab9c36af..00000000 --- a/case-repository/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - 4.0.0 - - case-repository - Case repository - - - - org.slf4j - slf4j-api - - - joda-time - joda-time - - - ${project.groupId} - iidm-converter-api - ${project.version} - - - ${project.groupId} - computation - ${project.version} - - - - \ No newline at end of file diff --git a/case-repository/src/main/java/eu/itesla_project/cases/CaseRepository.java b/case-repository/src/main/java/eu/itesla_project/cases/CaseRepository.java deleted file mode 100644 index 00487ed3..00000000 --- a/case-repository/src/main/java/eu/itesla_project/cases/CaseRepository.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.cases; - -import eu.itesla_project.iidm.network.Country; -import eu.itesla_project.iidm.network.Network; -import org.joda.time.DateTime; -import org.joda.time.Interval; - -import java.util.List; -import java.util.Set; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface CaseRepository { - - /** - * Load a case from the repository. - * - * @param date date of the case - * @param type type of the case, snapshot (SN) or forecast (FO) - * @param country case perimeter, merge if null - * @return a case - */ - List load(DateTime date, CaseType type, Country country); - - /** - * Check if the all the data of a case is available - * - * @param date date of the case - * @param type type of the case, snapshot (SN) or forecast (FO) - * @param country case perimeter, merge if null - * @return true if all the data of a case is available, false otherwise - */ - boolean isDataAvailable(DateTime date, CaseType type, Country country); - - Set dataAvailable(CaseType type, Set countries, Interval interval); -} diff --git a/case-repository/src/main/java/eu/itesla_project/cases/CaseRepositoryFactory.java b/case-repository/src/main/java/eu/itesla_project/cases/CaseRepositoryFactory.java deleted file mode 100644 index 59238921..00000000 --- a/case-repository/src/main/java/eu/itesla_project/cases/CaseRepositoryFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.cases; - -import eu.itesla_project.computation.ComputationManager; - -/** - * @author Geoffroy Jamgotchian - */ -public interface CaseRepositoryFactory { - - CaseRepository create(ComputationManager computationManager); - -} diff --git a/case-repository/src/main/java/eu/itesla_project/cases/CaseType.java b/case-repository/src/main/java/eu/itesla_project/cases/CaseType.java deleted file mode 100644 index a50850fb..00000000 --- a/case-repository/src/main/java/eu/itesla_project/cases/CaseType.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.cases; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum CaseType { - SN, - FO -} diff --git a/cim1-import/pom.xml b/cim1-import/pom.xml index d0186bcf..43841b5e 100644 --- a/cim1-import/pom.xml +++ b/cim1-import/pom.xml @@ -23,6 +23,10 @@ CIM ENTSO-E V1 import + + com.google.auto.service + auto-service + org.slf4j slf4j-api @@ -35,19 +39,18 @@ org.jgrapht jgrapht-core - - eu.itesla_project - cim1-model - ${project.version} - ${project.groupId} iidm-converter-api - ${project.version} ${project.groupId} iidm-network-api + + + + eu.itesla_project + cim1-model ${project.version} diff --git a/cmake/FindLibArchive.cmake b/cmake/FindLibArchive.cmake deleted file mode 100644 index 61fd7ddf..00000000 --- a/cmake/FindLibArchive.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# - Find LibArchive -# -# LibArchive_FOUND True if LibArchive exists, false otherwise -# LibArchive_INCLUDE_DIRS Include path -# LibArchive_LIBRARIES LibArchive libraries -# LibArchive_VERSION_STRING Library version -# LibArchive_VERSION_MAJOR Library version (major version) -# LibArchive_VERSION_MINOR Library version (minor version) -# LibArchive_VERSION_PATCH Library version (patch level) -# -# ============================================================================= -# Copyright (c) 2016, RTE (http://www.rte-france.com) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# ============================================================================= - -if (NOT LIBARCHIVE_HOME AND NOT $ENV{LIBARCHIVE_HOME} STREQUAL "") - set(LIBARCHIVE_HOME $ENV{LIBARCHIVE_HOME}) -endif() - -if (NOT LIBARCHIVE_HOME AND NOT $ENV{LIBARCHIVE_ROOT} STREQUAL "") - set(LIBARCHIVE_HOME $ENV{LIBARCHIVE_ROOT}) -endif() - -if (NOT LIBARCHIVE_HOME) - message(FATAL_ERROR "LibArchive libraries not found. The variable LIBARCHIVE_HOME is NOT set or is NOT a valid directory") -endif() - -find_path(LibArchive_INCLUDE_DIR NAME archive.h archive_entry.h HINTS ${LIBARCHIVE_HOME}/include) -if (USE_STATIC_LIBS) - find_library(LibArchive_LIBRARY libarchive.a HINTS ${LIBARCHIVE_HOME}/lib) -else() - find_library(LibArchive_LIBRARY archive HINTS ${LIBARCHIVE_HOME}/lib) -endif() - -mark_as_advanced(LibArchive_INCLUDE_DIR LibArchive_LIBRARY) - -if (LibArchive_INCLUDE_DIR AND EXISTS "${LibArchive_INCLUDE_DIR}/archive.h") - # The version string appears in one of two known formats in the header: - # #define ARCHIVE_LIBRARY_VERSION "libarchive 2.4.12" - # #define ARCHIVE_VERSION_STRING "libarchive 2.8.4" - # Match either format. - set(_LibArchive_VERSION_REGEX "^#define[ \t]+ARCHIVE[_A-Z]+VERSION[_A-Z]*[ \t]+\"libarchive +([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*\".*$") - file(STRINGS "${LibArchive_INCLUDE_DIR}/archive.h" _LibArchive_VERSION_STRING LIMIT_COUNT 1 REGEX "${_LibArchive_VERSION_REGEX}") - if(_LibArchive_VERSION_STRING) - string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\1.\\2.\\3" LibArchive_VERSION_STRING "${_LibArchive_VERSION_STRING}") - string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\1" LibArchive_VERSION_MAJOR "${_LibArchive_VERSION_STRING}") - string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\2" LibArchive_VERSION_MINOR "${_LibArchive_VERSION_STRING}") - string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\3" LibArchive_VERSION_PATCH "${_LibArchive_VERSION_STRING}") - endif() - unset(_LibArchive_VERSION_REGEX) - unset(_LibArchive_VERSION_STRING) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(LibArchive DEFAULT_MSG LibArchive_LIBRARY LibArchive_INCLUDE_DIR) -if (LIBARCHIVE_FOUND) - if (DEFINED LibArchive_FIND_VERSION) - if (${LibArchive_FIND_VERSION} VERSION_GREATER ${LibArchive_VERSION_STRING}) - message(FATAL_ERROR "LibArchive ${LibArchive_VERSION_STRING} found but ${LibArchive_FIND_VERSION} is required") - endif() - endif() - - set(LibArchive_FOUND ${LIBARCHIVE_FOUND}) - set(LibArchive_INCLUDE_DIRS ${LibArchive_INCLUDE_DIR}) - set(LibArchive_LIBRARIES ${LibArchive_LIBRARY}) - - message(STATUS "LibArchive version: ${LibArchive_VERSION_STRING}") -endif() diff --git a/cmake/FindProtobuf.cmake b/cmake/FindProtobuf.cmake deleted file mode 100644 index 56363b78..00000000 --- a/cmake/FindProtobuf.cmake +++ /dev/null @@ -1,66 +0,0 @@ -# - Find Protobuf -# -# Protobuf_FOUND True if Protobuf exists, false otherwise -# Protobuf_INCLUDE_DIRS Include path -# Protobuf_LIBRARIES Protobuf libraries -# Protobuf_VERSION_STRING Library version -# Protobuf_VERSION_MAJOR Library version (major version) -# Protobuf_VERSION_MINOR Library version (minor version) -# Protobuf_VERSION_PATCH Library version (patch level) -# -# ============================================================================= -# Copyright (c) 2016, RTE (http://www.rte-france.com) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# ============================================================================= - -if (NOT PROTOBUF_HOME AND NOT $ENV{PROTOBUF_HOME} STREQUAL "") - set(PROTOBUF_HOME $ENV{PROTOBUF_HOME}) -endif() - -if (NOT PROTOBUF_HOME AND NOT $ENV{PROTOBUF_ROOT} STREQUAL "") - set(PROTOBUF_HOME $ENV{PROTOBUF_ROOT}) -endif() - -if (NOT PROTOBUF_HOME) - message(FATAL_ERROR "Protobuf libraries not found. The variable PROTOBUF_HOME is NOT set or is NOT a valid directory") -endif() - -find_path(Protobuf_INCLUDE_DIR NAME google/protobuf/service.h HINTS ${PROTOBUF_HOME}/include) -if (USE_STATIC_LIBS) - find_library(Protobuf_LIBRARY libprotobuf.a HINTS ${PROTOBUF_HOME}/lib) -else() - find_library(Protobuf_LIBRARY protobuf HINTS ${PROTOBUF_HOME}/lib) -endif() - -mark_as_advanced(Protobuf_INCLUDE_DIR Protobuf_LIBRARY) - -if (Protobuf_INCLUDE_DIR AND EXISTS "${Protobuf_INCLUDE_DIR}/google/protobuf/stubs/common.h") - set(_Protobuf_VERSION_REGEX "^#define[ \t]+GOOGLE_PROTOBUF_VERSION[ \t]+([0-9]+).*$") - file(STRINGS "${Protobuf_INCLUDE_DIR}/google/protobuf/stubs/common.h" _Protobuf_VERSION_STRING LIMIT_COUNT 1 REGEX "${_Protobuf_VERSION_REGEX}") - if(_Protobuf_VERSION_STRING) - math(EXPR Protobuf_VERSION_MAJOR "${_Protobuf_VERSION_STRING} / 1000000") - math(EXPR Protobuf_VERSION_MINOR "${_Protobuf_VERSION_STRING} / 1000 % 1000") - math(EXPR Protobuf_VERSION_PATCH "${_Protobuf_VERSION_STRING} % 1000") - set(Protobuf_VERSION_STRING "${Protobuf_VERSION_MAJOR}.${Protobuf_VERSION_MINOR}.${Protobuf_VERSION_PATCH}") - endif() - unset(_Protobuf_VERSION_REGEX) - unset(_Protobuf_VERSION_STRING) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Protobuf DEFAULT_MSG Protobuf_LIBRARY Protobuf_INCLUDE_DIR) -if (PROTOBUF_FOUND) - if (DEFINED Protobuf_FIND_VERSION) - if (Protobuf_FIND_VERSION VERSION_GREATER ${Protobuf_VERSION_STRING}) - message(FATAL_ERROR "Protobuf ${Protobuf_VERSION_STRING} found but ${Protobuf_FIND_VERSION} is required") - endif() - endif() - - set(Protobuf_FOUND ${PROTOBUF_FOUND}) - set(Protobuf_INCLUDE_DIRS ${Protobuf_INCLUDE_DIR}) - set(Protobuf_LIBRARIES ${Protobuf_LIBRARY}) - - message(STATUS "Protobuf version: ${Protobuf_VERSION_STRING}") -endif() diff --git a/commons/pom.xml b/commons/pom.xml deleted file mode 100644 index 70fe13ef..00000000 --- a/commons/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - 4.0.0 - - - eu.itesla_project - itesla-parent - 0.1-SNAPSHOT - - - commons - - Commons - This is a library for miscellaneous utility classes - - - - - org.codehaus.mojo - templating-maven-plugin - - - org.codehaus.mojo - buildnumber-maven-plugin - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - - - - com.google.guava - guava - - - org.slf4j - slf4j-api - - - net.sf.supercsv - super-csv - - - commons-cli - commons-cli - - - joda-time - joda-time - - - com.google.auto.service - auto-service - - - org.ow2.sirocco - sirocco-text-table-formatter - - - org.slf4j - log4j-over-slf4j - test - - - junit - junit - test - - - org.jboss.shrinkwrap - shrinkwrap-api - test - - - org.jboss.shrinkwrap - shrinkwrap-api-nio2 - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-base - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-nio2 - test - - - org.slf4j - slf4j-simple - test - - - org.xmlunit - xmlunit-core - test - - - - diff --git a/commons/src/main/java-templates/eu/itesla_project/commons/Version.java b/commons/src/main/java-templates/eu/itesla_project/commons/Version.java deleted file mode 100644 index 9e41897c..00000000 --- a/commons/src/main/java-templates/eu/itesla_project/commons/Version.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons; - -import com.google.common.collect.ImmutableMap; - -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Objects; -import java.util.Map; -import org.joda.time.DateTime; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class Version { - - public static final Version VERSION = new Version(); - - private final String projectVersion; - - private final String gitVersion; - - private final String gitBranch; - - private final long buildTimestamp; - - public Version() { - this("${project.version}", "${buildNumber}", "${scmBranch}", Long.parseLong("${timestamp}")); - } - - public Version(String projectVersion, String gitVersion, String gitBranch, long buildTimestamp) { - this.projectVersion = Objects.requireNonNull(projectVersion); - this.gitVersion = Objects.requireNonNull(gitVersion); - this.gitBranch = Objects.requireNonNull(gitBranch); - this.buildTimestamp = buildTimestamp; - } - - public String getGitVersion() { - return gitVersion; - } - - public String getProjectVersion() { - return projectVersion; - } - - public String getGitBranch() { - return gitBranch; - } - - public long getBuildTimestamp() { - return buildTimestamp; - } - - public Map toMap() { - return ImmutableMap.of("projectVersion", projectVersion, - "gitVersion", gitVersion, - "gitBranch", gitBranch, - "buildTimestamp", new DateTime(buildTimestamp).toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Version) { - Version other = (Version) obj; - return projectVersion.equals(other.projectVersion) - && gitVersion.equals(other.gitVersion) - && gitBranch.equals(other.gitBranch) - && buildTimestamp == other.buildTimestamp; - } - return false; - } - - @Override - public String toString() { - return toMap().toString(); - } - -} \ No newline at end of file diff --git a/commons/src/main/java/eu/itesla_project/commons/ITeslaException.java b/commons/src/main/java/eu/itesla_project/commons/ITeslaException.java deleted file mode 100644 index 180fc1ed..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/ITeslaException.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ITeslaException extends RuntimeException { - - public ITeslaException() { - } - - public ITeslaException(String msg) { - super(msg); - } - - public ITeslaException(Throwable throwable) { - super(throwable); - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/Versionable.java b/commons/src/main/java/eu/itesla_project/commons/Versionable.java deleted file mode 100644 index 76c95f02..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/Versionable.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Versionable { - - String getName(); - - String getVersion(); - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/collect/Downcast.java b/commons/src/main/java/eu/itesla_project/commons/collect/Downcast.java deleted file mode 100644 index cd2624ec..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/collect/Downcast.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.collect; - -import com.google.common.base.Function; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class Downcast implements Function { - - @Override - public V apply(U f) { - return f; - } - -} \ No newline at end of file diff --git a/commons/src/main/java/eu/itesla_project/commons/config/ComponentDefaultConfig.java b/commons/src/main/java/eu/itesla_project/commons/config/ComponentDefaultConfig.java deleted file mode 100644 index 82780de9..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/config/ComponentDefaultConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class ComponentDefaultConfig { - - public static ComponentDefaultConfig load() { - return new ComponentDefaultConfig(PlatformConfig.defaultConfig().getModuleConfigIfExists("componentDefaultConfig")); - } - - private final ModuleConfig config; - - ComponentDefaultConfig(ModuleConfig config) { - this.config = config; - } - - public Class findFactoryImplClass(Class factoryBaseClass) { - Objects.requireNonNull(factoryBaseClass); - String propertyName = factoryBaseClass.getSimpleName(); - if (config == null) { - throw new RuntimeException("Property " + propertyName + " is not set"); - } - return config.getClassProperty(propertyName, factoryBaseClass); - } - - public Class findFactoryImplClass(Class factoryBaseClass, Class defaultFactoryImplClass) { - Objects.requireNonNull(factoryBaseClass); - Objects.requireNonNull(defaultFactoryImplClass); - String propertyName = factoryBaseClass.getSimpleName(); - return config != null ? config.getClassProperty(propertyName, factoryBaseClass, defaultFactoryImplClass) - : defaultFactoryImplClass; - } - - public T newFactoryImpl(Class factoryBaseClass) { - try { - return findFactoryImplClass(factoryBaseClass).newInstance(); - } catch (IllegalAccessException|InstantiationException e) { - throw new RuntimeException(e); - } - } - - public T newFactoryImpl(Class factoryBaseClass, Class defaultFactoryImplClass) { - try { - return findFactoryImplClass(factoryBaseClass, defaultFactoryImplClass).newInstance(); - } catch (IllegalAccessException|InstantiationException e) { - throw new RuntimeException(e); - } - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/config/InMemoryPlatformConfig.java b/commons/src/main/java/eu/itesla_project/commons/config/InMemoryPlatformConfig.java deleted file mode 100644 index e0c86234..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/config/InMemoryPlatformConfig.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.nio.file.FileSystem; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class InMemoryPlatformConfig extends PlatformConfig { - - protected FileSystem fs; - - protected final Map configs = new HashMap<>(); - - public InMemoryPlatformConfig(FileSystem fs) { - this.fs = Objects.requireNonNull(fs); - } - - @Override - public boolean moduleExists(String name) { - return configs.containsKey(name); - } - - @Override - public ModuleConfig getModuleConfig(String name) { - ModuleConfig config = configs.get(name); - if (config == null) { - throw new RuntimeException("Module " + name + " not found"); - } - return config; - } - - @Override - public ModuleConfig getModuleConfigIfExists(String name) { - return configs.get(name); - } - - public MapModuleConfig createModuleConfig(String name) { - MapModuleConfig config = configs.get(name); - if (config != null) { - throw new RuntimeException("Module " + name + " already exists"); - } - config = new MapModuleConfig(fs); - configs.put(name, config); - return config; - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/config/MapModuleConfig.java b/commons/src/main/java/eu/itesla_project/commons/config/MapModuleConfig.java deleted file mode 100644 index a9943491..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/config/MapModuleConfig.java +++ /dev/null @@ -1,236 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Path; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import com.google.common.base.Joiner; -import org.joda.time.DateTime; -import org.joda.time.Interval; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class MapModuleConfig implements ModuleConfig { - - private static final Pattern VAR_PATTERN = Pattern.compile("\\$\\{(\\w+)\\}|\\$(\\w+)"); // match ${ENV_VAR_NAME} or $ENV_VAR_NAME - - private final Map properties; - - private final FileSystem fs; - - public MapModuleConfig(FileSystem fs) { - this(new HashMap<>(), fs); - } - - public MapModuleConfig(Map properties) { - this(properties, FileSystems.getDefault()); - } - - public MapModuleConfig(Map properties, FileSystem fs) { - this.properties = properties; - this.fs = fs; - } - - /* - * Environment variables substitution - */ - private static String substitureEnvVar(String str) { - if (str == null) { - return null; - } - Matcher m = VAR_PATTERN.matcher(str); - StringBuffer sb = new StringBuffer(); - while (m.find()) { - String envVarName = m.group(1) == null ? m.group(2) : m.group(1); - String envVarValue = System.getenv(envVarName); - m.appendReplacement(sb, envVarValue == null ? "" : envVarValue); - } - m.appendTail(sb); - return sb.toString(); - } - - @Override - public String getStringProperty(String name) { - String value = (String) properties.get(name); - if (value == null || value.trim().isEmpty()) { - throw new RuntimeException("Property " + name + " is not set"); - } - return substitureEnvVar(value); - } - - @Override - public String getStringProperty(String name, String defaultValue) { - Object value = properties.get(name); - return substitureEnvVar(value == null ? defaultValue : (String) value); - } - - public void setStringProperty(String name, String value) { - properties.put(name, Objects.requireNonNull(value)); - } - - @Override - public List getStringListProperty(String name) { - return new ArrayList<>(Arrays.asList(getStringProperty(name).split("[:,]"))); - } - - @Override - public List getStringListProperty(String name, List defaultValue) { - String str = getStringProperty(name, null); - if (str == null) { - return defaultValue; - } - return str.isEmpty() ? Collections.emptyList() : new ArrayList<>(Arrays.asList(str.split("[:,]"))); - } - - public void setStringListProperty(String name, List stringList) { - properties.put(name, Joiner.on(",").join(stringList).toString()); - } - - @Override - public > E getEnumProperty(String name, Class clazz) { - return Enum.valueOf(clazz, getStringProperty(name)); - } - - @Override - public > E getEnumProperty(String name, Class clazz, E defaultValue) { - return Enum.valueOf(clazz, getStringProperty(name, Objects.requireNonNull(defaultValue).name())); - } - - @Override - public > Set getEnumSetProperty(String name, Class clazz) { - List strings = getStringListProperty(name); - return strings.stream().map(s -> Enum.valueOf(clazz, s)).collect(Collectors.toSet()); - } - - @Override - public > Set getEnumSetProperty(String name, Class clazz, Set defaultValue) { - List strings = getStringListProperty(name, null); - if (strings == null) { - return defaultValue; - } - return strings.stream().map(s -> Enum.valueOf(clazz, s)).collect(Collectors.toSet()); - } - - @Override - public int getIntProperty(String name) { - return Integer.parseInt(getStringProperty(name)); - } - - @Override - public Integer getOptionalIntProperty(String name) { - String value = getStringProperty(name, null); - return value != null ? Integer.parseInt(value) : null; - } - - @Override - public int getIntProperty(String name, int defaultValue) { - return Integer.parseInt(getStringProperty(name, Integer.toString(defaultValue))); - } - - @Override - public float getFloatProperty(String name) { - return Float.parseFloat(getStringProperty(name)); - } - - @Override - public float getFloatProperty(String name, float defaultValue) { - return Float.parseFloat(getStringProperty(name, Float.toString(defaultValue))); - } - - @Override - public double getDoubleProperty(String name) { - return Double.parseDouble(getStringProperty(name)); - } - - @Override - public double getDoubleProperty(String name, double defaultValue) { - return Double.parseDouble(getStringProperty(name, Double.toString(defaultValue))); - } - - @Override - public boolean getBooleanProperty(String name) { - return Boolean.parseBoolean(getStringProperty(name)); - } - - @Override - public boolean getBooleanProperty(String name, boolean defaultValue) { - return Boolean.parseBoolean(getStringProperty(name, Boolean.toString(defaultValue))); - } - - @Override - public Boolean getOptinalBooleanProperty(String name) { - String value = getStringProperty(name, null); - return value != null ? Boolean.parseBoolean(value) : null; - } - - @Override - public Path getPathProperty(String name) { - return fs.getPath(getStringProperty(name)); - } - - @Override - public Path getPathProperty(String name, Path defaultValue) { - String value = getStringProperty(name, defaultValue != null ? defaultValue.toString() : null); - return value != null ? fs.getPath(value) : null; - } - - public void setPathProperty(String name, Path path) { - properties.put(name, path.toAbsolutePath().toString()); - } - - @Override - public List getPathListProperty(String name) { - List strings = getStringListProperty(name); - List paths = new ArrayList<>(strings.size()); - for (String s : strings) { - paths.add(fs.getPath(s)); - } - return paths; - } - - @Override - public Class getClassProperty(String name, Class subClass) { - try { - return Class.forName(getStringProperty(name)).asSubclass(subClass); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - @Override - public Class getClassProperty(String name, Class subClass, Class defaultValue) { - try { - Object value = properties.get(name); - if (value == null) { - return defaultValue; - } else { - return Class.forName((String) value).asSubclass(subClass); - } - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - @Override - public DateTime getDateTimeProperty(String name) { - return DateTime.parse(getStringProperty(name)); - } - - @Override - public Interval getIntervalProperty(String name) { - return Interval.parse(getStringProperty(name)); - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/config/ModuleConfig.java b/commons/src/main/java/eu/itesla_project/commons/config/ModuleConfig.java deleted file mode 100644 index ed687a4f..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/config/ModuleConfig.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.nio.file.Path; -import java.util.List; -import java.util.Set; - -import org.joda.time.DateTime; -import org.joda.time.Interval; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ModuleConfig { - - String getStringProperty(String name); - - String getStringProperty(String name, String defaultValue); - - List getStringListProperty(String name); - - List getStringListProperty(String name, List defaultValue); - - > E getEnumProperty(String name, Class clazz); - - > E getEnumProperty(String name, Class clazz, E defaultValue); - - > Set getEnumSetProperty(String name, Class clazz); - - > Set getEnumSetProperty(String name, Class clazz, Set defaultValue); - - int getIntProperty(String name); - - Integer getOptionalIntProperty(String name); - - int getIntProperty(String name, int defaultValue); - - float getFloatProperty(String name); - - float getFloatProperty(String name, float defaultValue); - - double getDoubleProperty(String name); - - double getDoubleProperty(String name, double defaultValue); - - boolean getBooleanProperty(String name); - - boolean getBooleanProperty(String name, boolean defaultValue); - - Boolean getOptinalBooleanProperty(String name); - - Path getPathProperty(String name); - - Path getPathProperty(String name, Path defaultValue); - - List getPathListProperty(String name); - - Class getClassProperty(String name, Class subClass); - - Class getClassProperty(String name, Class subClass, Class defaultValue); - - DateTime getDateTimeProperty(String name); - - Interval getIntervalProperty(String name); - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/config/PlatformConfig.java b/commons/src/main/java/eu/itesla_project/commons/config/PlatformConfig.java deleted file mode 100644 index 830def92..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/config/PlatformConfig.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import javax.xml.parsers.ParserConfigurationException; - -import eu.itesla_project.commons.io.CacheManager; -import org.xml.sax.SAXException; - -/** - * - * @author Geoffroy Jamgotchian - */ -public abstract class PlatformConfig { - - public static final Path CONFIG_DIR; - - public static final Path CACHE_DIR; - - private static final String CONFIG_NAME; - - private static PlatformConfig defaultConfig; - - private static CacheManager defaultCacheManager; - - static { - String iteslaConfigDir = System.getProperty("itesla.config.dir"); - if (iteslaConfigDir != null) { - CONFIG_DIR = Paths.get(iteslaConfigDir); - } else { - CONFIG_DIR = Paths.get(System.getProperty("user.home"), ".itesla"); - } - try { - if (! (Files.isDirectory(CONFIG_DIR))) - Files.createDirectories(CONFIG_DIR); - } catch (IOException e) { - throw new RuntimeException(e); - } - - CONFIG_NAME = System.getProperty("itesla.config.name"); - - String iteslaCacheDir = System.getProperty("itesla.cache.dir"); - if (iteslaCacheDir != null) { - CACHE_DIR = Paths.get(iteslaCacheDir); - } else { - CACHE_DIR = Paths.get(System.getProperty("user.home"), ".cache", "itesla"); - } - try { - Files.createDirectories(CACHE_DIR); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static synchronized void setDefaultConfig(PlatformConfig defaultConfig) { - PlatformConfig.defaultConfig = defaultConfig; - } - - public static synchronized PlatformConfig defaultConfig() { - if (defaultConfig == null) { - if (CONFIG_NAME != null) { - try { - defaultConfig = new XmlPlatformConfig(CONFIG_DIR, CONFIG_NAME, FileSystems.getDefault()); - } catch (IOException | ParserConfigurationException | SAXException e) { - throw new RuntimeException(e); - } - } else { - defaultConfig = new PropertiesPlatformConfig(CONFIG_DIR, FileSystems.getDefault()); - } - } - return defaultConfig; - } - - public static synchronized void setDefaultCacheManager(CacheManager defaultCacheManager) { - PlatformConfig.defaultCacheManager = defaultCacheManager; - } - - public static synchronized CacheManager defaultCacheManager() { - if (defaultCacheManager == null) { - defaultCacheManager = new CacheManager(CACHE_DIR); - } - return defaultCacheManager; - } - - public abstract boolean moduleExists(String name); - - public abstract ModuleConfig getModuleConfig(String name); - - public abstract ModuleConfig getModuleConfigIfExists(String name); -} diff --git a/commons/src/main/java/eu/itesla_project/commons/config/PropertiesPlatformConfig.java b/commons/src/main/java/eu/itesla_project/commons/config/PropertiesPlatformConfig.java deleted file mode 100644 index 9cfe341a..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/config/PropertiesPlatformConfig.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.DirectoryStream; -import java.nio.file.FileSystem; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Properties; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class PropertiesPlatformConfig extends PlatformConfig { - - private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesPlatformConfig.class); - - private final Path configDir; - - private final FileSystem fs; - - public PropertiesPlatformConfig(Path configDir, FileSystem fs) { - this.configDir = configDir; - this.fs = fs; - LOGGER.info("Platform configuration defined by .properties files of directory {}", configDir); - } - - private Path getModulePath(String name) { - return configDir.resolve(name + ".properties"); - } - - @Override - public boolean moduleExists(String name) { - Path path = getModulePath(name); - return Files.exists(path); - } - - @Override - public ModuleConfig getModuleConfig(String name) { - ModuleConfig moduleConfig = getModuleConfigIfExists(name); - if (moduleConfig == null) { - throw new RuntimeException("Module " + name + " not found"); - } - return moduleConfig; - } - - @Override - public ModuleConfig getModuleConfigIfExists(String name) { - Path path = getModulePath(name); - if (!Files.exists(path)) { - return null; - } - LOGGER.info("Reading property file {}", path); - Properties properties = new Properties(); - try { - try (InputStream is = Files.newInputStream(path)) { - properties.load(is); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - return new MapModuleConfig(properties, fs); - } - - public static void writeXml(Path configDir, Path xmlFile) throws IOException, XMLStreamException { - XMLOutputFactory output = XMLOutputFactory.newInstance(); - try (Writer writer = Files.newBufferedWriter(xmlFile, StandardCharsets.UTF_8)) { - XMLStreamWriter xmlWriter = output.createXMLStreamWriter(writer); - try { - xmlWriter.writeStartDocument(StandardCharsets.UTF_8.toString(), "1.0"); - xmlWriter.writeStartElement("config"); - try (DirectoryStream ds = Files.newDirectoryStream(configDir, entry -> Files.isRegularFile(entry) && entry.getFileName().toString().endsWith(".properties"))) { - for (Path file : ds) { - String fileName = file.getFileName().toString(); - String fileNameWithoutExtension = fileName.substring(0, fileName.length() - 11); - xmlWriter.writeStartElement(fileNameWithoutExtension); - Properties properties = new Properties(); - try (Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { - properties.load(reader); - } - for (String name : properties.stringPropertyNames()) { - String value = properties.getProperty(name); - xmlWriter.writeStartElement(name); - xmlWriter.writeCharacters(value); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - } - } - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } finally { - xmlWriter.close(); - } - } - } - - public static void main(String[] args) throws IOException, XMLStreamException { - writeXml(CONFIG_DIR, CONFIG_DIR.resolve("config.xml")); - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/config/XmlPlatformConfig.java b/commons/src/main/java/eu/itesla_project/commons/config/XmlPlatformConfig.java deleted file mode 100644 index 4f258441..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/config/XmlPlatformConfig.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.FileSystem; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class XmlPlatformConfig extends InMemoryPlatformConfig { - - private static final Logger LOGGER = LoggerFactory.getLogger(XmlPlatformConfig.class); - - public XmlPlatformConfig(Path configDir, String configName, FileSystem fs) throws IOException, SAXException, ParserConfigurationException { - super(fs); - Path file = configDir.resolve(configName + ".xml"); - if (Files.exists(file)) { - LOGGER.info("Platform configuration defined by XML file {}", file); - try (InputStream is = Files.newInputStream(file)) { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.parse(is); - Element root = doc.getDocumentElement(); - root.normalize(); - NodeList moduleNodes = root.getChildNodes(); - for (int i = 0; i < moduleNodes.getLength(); i++) { - Node moduleNode = moduleNodes.item(i); - if (moduleNode.getNodeType() == Node.ELEMENT_NODE) { - String moduleName = moduleNode.getLocalName(); - Map properties = new HashMap<>(); - NodeList propertyNodes = moduleNode.getChildNodes(); - for (int j = 0; j < propertyNodes.getLength(); j++) { - Node propertyNode = propertyNodes.item(j); - if (propertyNode.getNodeType() == Node.ELEMENT_NODE) { - String propertyName = propertyNode.getLocalName(); - Node child = propertyNode.getFirstChild(); - String propertyValue = child != null ? child.getTextContent() : ""; - properties.put(propertyName, propertyValue); - } - } - configs.put(moduleName, new MapModuleConfig(properties, fs)); - } - } - } - } else { - LOGGER.info("Platform configuration XML file {} not found", file); - } - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/BufferedLineParser.java b/commons/src/main/java/eu/itesla_project/commons/io/BufferedLineParser.java deleted file mode 100644 index 5a56e2b3..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/BufferedLineParser.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import java.io.BufferedReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; - -/** - * @author Geoffroy Jamgotchian - */ -public class BufferedLineParser { - - private final BufferedReader reader; - - private int bufferSize; - - public BufferedLineParser(BufferedReader reader, int bufferSize) { - this.reader = reader; - this.bufferSize = bufferSize; - } - - public void parse(Consumer> consumer) throws IOException { - List lineBuffer = new ArrayList<>(); - String line; - while ((line = reader.readLine()) != null) { - lineBuffer.add(0, line); - if (lineBuffer.size() > bufferSize) { - lineBuffer.remove(lineBuffer.size()-1); - } - consumer.accept(lineBuffer); - } - } - -} \ No newline at end of file diff --git a/commons/src/main/java/eu/itesla_project/commons/io/CacheManager.java b/commons/src/main/java/eu/itesla_project/commons/io/CacheManager.java deleted file mode 100644 index d5886a7c..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/CacheManager.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import com.google.common.base.Charsets; -import com.google.common.hash.HashCode; -import com.google.common.hash.HashFunction; -import com.google.common.hash.Hasher; -import com.google.common.hash.Hashing; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.concurrent.Semaphore; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * @author Geoffroy Jamgotchian - */ -public class CacheManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(CacheManager.class); - - private final Path cacheDir; - - private final Lock cacheEntriesLock = new ReentrantLock(); - - private final Map cacheEntries = new HashMap<>(); - - public static class CacheEntry { - - private final Path path; - - private final List keys; - - private final Semaphore semaphore = new Semaphore(1); - - public CacheEntry(Path path, List keys) { - this.path = Objects.requireNonNull(path); - this.keys = Objects.requireNonNull(keys); - } - - public Path toPath() { - return path; - } - - public List getKeys() { - return keys; - } - - public boolean exists() { - return Files.exists(path) && Files.isDirectory(path); - } - - private Path getMetadataFile() { - return path.resolve(".metadata"); - } - - public Path create() { - try { - if (Files.exists(path)) { - List otherKeys; - try (Stream stream = Files.lines(getMetadataFile(), StandardCharsets.UTF_8)) { - otherKeys = stream.collect(Collectors.toList()); - } - if (!keys.equals(otherKeys)) { - throw new RuntimeException("Inconsistent cache hash code"); - } - } else { - Files.createDirectories(path); - try (BufferedWriter writer = Files.newBufferedWriter(getMetadataFile(), StandardCharsets.UTF_8)) { - for (String key : keys) { - writer.write(key); - writer.newLine(); - } - } - } - } catch (IOException e) { - throw new RuntimeException(e); - } - return path; - } - - public void remove() { - if (exists()) { - try { - FileUtil.removeDir(path); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - public void lock() { - try { - semaphore.acquire(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - - public void unlock() { - semaphore.release(); - } - - @Override - public String toString() { - return path.toString(); - } - } - - public class CacheEntryBuilder { - - private final String name; - - private final List keys = new ArrayList<>(); - - public CacheEntryBuilder(String name) { - this.name = Objects.requireNonNull(name); - } - - public CacheEntryBuilder withKey(String key) { - keys.add(key); - return this; - } - - public CacheEntryBuilder withKeys(List keys) { - this.keys.addAll(keys); - return this; - } - - public CacheEntry build() { - Path baseDir = cacheDir.resolve(name); - if (keys.size() > 0) { - HashFunction hf = Hashing.md5(); - Hasher h = hf.newHasher(); - for (String key : keys) { - h.putString(key, Charsets.UTF_8); - } - HashCode hc = h.hash(); - baseDir = baseDir.resolve(hc.toString()); - } - cacheEntriesLock.lock(); - try { - CacheEntry cacheEntry = cacheEntries.get(baseDir.toString()); - if (cacheEntry != null) { - if (!cacheEntry.getKeys().equals(keys)) { - throw new RuntimeException("Inconsistent hash"); - } - } else { - cacheEntry = new CacheEntry(baseDir, keys); - cacheEntries.put(baseDir.toString(), cacheEntry); - } - return cacheEntry; - } finally { - cacheEntriesLock.unlock(); - } - } - } - - public CacheManager(Path cacheDir) { - this.cacheDir = Objects.requireNonNull(cacheDir); - LOGGER.info("Use cache directory {}", cacheDir); - } - - public CacheEntryBuilder newCacheEntry(String name) { - return new CacheEntryBuilder(name); - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/FileUtil.java b/commons/src/main/java/eu/itesla_project/commons/io/FileUtil.java deleted file mode 100644 index cf7e0c8a..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/FileUtil.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; - -/** - * @author Geoffroy Jamgotchian - */ -public class FileUtil { - - private FileUtil() { - } - - public static void removeDir(Path dir) throws IOException { - Files.walkFileTree(dir, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file); - return super.visitFile(file, attrs); - } - - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - Files.delete(dir); - return super.postVisitDirectory(dir, exc); - } - }); - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/ForwardingInputStream.java b/commons/src/main/java/eu/itesla_project/commons/io/ForwardingInputStream.java deleted file mode 100644 index b50fd685..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/ForwardingInputStream.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class ForwardingInputStream extends InputStream { - - private final I delegate; - - public ForwardingInputStream(I delegate) { - this.delegate = Objects.requireNonNull(delegate); - } - - @Override - public int available() throws IOException { - return delegate.available(); - } - - @Override - public void close() throws IOException { - delegate.close(); - } - - @Override - public void mark(int readlimit) { - delegate.mark(readlimit); - } - - @Override - public boolean markSupported() { - return delegate.markSupported(); - } - - @Override - public int read() throws IOException { - return delegate.read(); - } - - @Override - public int read(byte[] b) throws IOException { - return delegate.read(b); - } - - @Override - public int read(byte[] b, int off, int len) throws IOException { - return delegate.read(b, off, len); - } - - @Override - public void reset() throws IOException { - delegate.reset(); - } - - @Override - public long skip(long n) throws IOException { - return delegate.skip(n); - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/ForwardingOutputStream.java b/commons/src/main/java/eu/itesla_project/commons/io/ForwardingOutputStream.java deleted file mode 100644 index fbdf45fe..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/ForwardingOutputStream.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * Forwards calls to a given output stream. Subclasses of this class might - * override some of these methods. - * - * @param the kind of output stream forwarded - * - * @author Geoffroy Jamgotchian - */ -public class ForwardingOutputStream extends OutputStream { - - protected final O os; - - public ForwardingOutputStream(O os) { - this.os = os; - } - - @Override - public void write(byte[] b, int off, int len) throws IOException { - os.write(b, off, len); - } - - @Override - public void write(byte[] b) throws IOException { - os.write(b); - } - - @Override - public void write(int b) throws IOException { - os.write(b); - } - - @Override - public void flush() throws IOException { - os.flush(); - } - - @Override - public void close() throws IOException { - os.close(); - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/MathUtil.java b/commons/src/main/java/eu/itesla_project/commons/io/MathUtil.java deleted file mode 100644 index 8411d1bb..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/MathUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Table; -import java.io.IOException; -import java.io.Reader; -import java.util.List; -import org.supercsv.io.CsvListReader; -import org.supercsv.io.ICsvListReader; -import org.supercsv.prefs.CsvPreference; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class MathUtil { - - private MathUtil() { - } - - public static Table parseMatrix(Reader reader) throws IOException { - Table table = HashBasedTable.create(); - try (ICsvListReader csvReader = new CsvListReader(reader, CsvPreference.STANDARD_PREFERENCE)) { - List columnHeaders = csvReader.read(); - List row; - while ((row = csvReader.read()) != null) { - String rowHeader = row.get(0); - for (int i = 1; i < row.size(); i++) { - String columnHeader = columnHeaders.get(i); - String value = row.get(i); - table.put(rowHeader, columnHeader, value == null ? Float.NaN : Float.valueOf(value)); - } - } - } - return table; - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/SystemOutStreamWriter.java b/commons/src/main/java/eu/itesla_project/commons/io/SystemOutStreamWriter.java deleted file mode 100644 index e1b7ccb9..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/SystemOutStreamWriter.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import java.io.IOException; -import java.io.OutputStreamWriter; - -/** - * A System.out to writer adapter that does not close the stream. - * @author Geoffroy Jamgotchian - */ -public class SystemOutStreamWriter extends OutputStreamWriter { - - public SystemOutStreamWriter() { - super(System.out); - } - @Override - public void close() throws IOException { - flush(); - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/WorkingDirectory.java b/commons/src/main/java/eu/itesla_project/commons/io/WorkingDirectory.java deleted file mode 100644 index 0ee3a8f1..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/WorkingDirectory.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -/** - * @author Geoffroy Jamgotchian - */ -public class WorkingDirectory implements AutoCloseable { - - private final Path path; - - private final boolean debug; - - public WorkingDirectory(Path parentDir, String prefix, boolean debug) throws IOException { - path = Files.createTempDirectory(parentDir, prefix); - this.debug = debug; - } - - public Path toPath() { - return path; - } - - @Override - public void close() throws IOException { - if (!debug) { - FileUtil.removeDir(path); - } - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/AbstractTableFormatter.java b/commons/src/main/java/eu/itesla_project/commons/io/table/AbstractTableFormatter.java deleted file mode 100644 index 9b5e862d..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/AbstractTableFormatter.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import java.io.IOException; -import java.util.Locale; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public abstract class AbstractTableFormatter implements TableFormatter { - - protected final Locale locale; - - protected final String invalidString; - - protected AbstractTableFormatter(Locale locale, String invalidString) { - this.locale = Objects.requireNonNull(locale); - this.invalidString = Objects.requireNonNull(invalidString); - } - - protected abstract TableFormatter write(String value) throws IOException; - - @Override - public TableFormatter writeCell(String s) throws IOException { - return write(s); - } - - @Override - public TableFormatter writeEmptyCell() throws IOException { - return writeCell(""); - } - - @Override - public TableFormatter writeCell(char c) throws IOException { - return write(Character.toString(c)); - } - - @Override - public TableFormatter writeCell(int i) throws IOException { - return write(Integer.toString(i)); - } - - @Override - public TableFormatter writeCell(float f) throws IOException { - return write(Float.isNaN(f) ? invalidString : String.format(locale, "%g", f)); - } - - @Override - public TableFormatter writeCell(double d) throws IOException { - return write(Double.isNaN(d) ? invalidString : String.format(locale, "%g", d)); - } - - @Override - public TableFormatter writeCell(boolean b) throws IOException { - return write(Boolean.toString(b)); - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatter.java b/commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatter.java deleted file mode 100644 index 04e090a3..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatter.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import org.nocrala.tools.texttablefmt.BorderStyle; -import org.nocrala.tools.texttablefmt.Table; - -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.util.Locale; - -/** - * @author Geoffroy Jamgotchian - */ -public class AsciiTableFormatter extends AbstractTableFormatter { - - private final String title; - - private final Writer writer; - - private final Table table ; - - public AsciiTableFormatter(Writer writer, String title, TableFormatterConfig config, Column... columns) { - super(config.getLocale(), config.getInvalidString()); - this.writer = writer; - this.title = title; - this.table = new Table(columns.length, BorderStyle.CLASSIC_WIDE); - for (Column column : columns) { - table.addCell(column.getName()); - } - } - - public AsciiTableFormatter(String title, Column... columns) { - this(new OutputStreamWriter(System.out), title, TableFormatterConfig.load(), columns); - } - - @Override - public TableFormatter writeComment(String comment) throws IOException { - // not supported - return this; - } - - @Override - protected TableFormatter write(String value) throws IOException { - table.addCell(value); - return this; - } - - @Override - public void close() throws IOException { - writer.write(title + ":" + System.lineSeparator()); - writer.write(table.render() + System.lineSeparator()); - writer.close(); - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatterFactory.java b/commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatterFactory.java deleted file mode 100644 index 2c65410f..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/AsciiTableFormatterFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import java.io.Writer; -import java.util.Locale; - -/** - * @author Geoffroy Jamgotchian - */ -public class AsciiTableFormatterFactory implements TableFormatterFactory { - - @Override - public TableFormatter create(Writer writer, String title, TableFormatterConfig config, Column... columns) { - return new AsciiTableFormatter(writer, title, config, columns); - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/Column.java b/commons/src/main/java/eu/itesla_project/commons/io/table/Column.java deleted file mode 100644 index 5c8548e1..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/Column.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class Column { - - private final String name; - - public Column(String name) { - this.name = name; - } - - public String getName() { - return name; - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatter.java b/commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatter.java deleted file mode 100644 index 6a783696..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatter.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import java.io.IOException; -import java.io.Writer; -import java.util.Locale; -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CsvTableFormatter extends AbstractTableFormatter { - - protected final Writer writer; - - protected final String title; - - protected final char separator; - - protected final Column[] columns; - - protected boolean headerDone = false; - - protected int column = 0; - - protected final boolean writeTitle; - - public CsvTableFormatter(Writer writer, String title, TableFormatterConfig config, Column... columns) { - this(writer, title, config.getCsvSeparator(), config.getInvalidString(), config.getPrintHeader(), config.getPrintTitle(), config.getLocale(), columns); - } - - public CsvTableFormatter(Writer writer, String title, char separator, String invalidString, boolean writeHeader, Locale locale, Column... columns) { - this(writer, title, separator, invalidString, writeHeader, true, locale, columns); - } - - public CsvTableFormatter(Writer writer, String title, char separator, String invalidString, boolean writeHeader, boolean writeTitle, Locale locale, Column... columns) { - super(locale, invalidString); - this.writer = Objects.requireNonNull(writer); - this.title = Objects.requireNonNull(title); - this.separator = separator; - this.columns = Objects.requireNonNull(columns); - headerDone = !writeHeader; - this.writeTitle = writeTitle; - } - - private void writeHeaderIfNotDone() throws IOException { - if (headerDone) { - return; - } - writeHeader(); - headerDone = true; - } - - protected void writeHeader() throws IOException { - if (writeTitle) { - writer.append(title).append(System.lineSeparator()); - } - for (int i = 0; i < columns.length; i++) { - writer.append(columns[i].getName()); - if (i < columns.length-1) { - writer.append(separator); - } - } - writer.append(System.lineSeparator()); - } - - @Override - public TableFormatter writeComment(String comment) throws IOException { - return this; - } - - @Override - protected TableFormatter write(String value) throws IOException { - writeHeaderIfNotDone(); - writer.append(value); - if (column < columns.length-1) { - writer.append(separator); - } - column++; - if (column == columns.length) { - writer.write(System.lineSeparator()); - column = 0; - } - return this; - } - - @Override - public void close() throws IOException { - writeHeaderIfNotDone(); - writer.close(); - } -} \ No newline at end of file diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatterFactory.java b/commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatterFactory.java deleted file mode 100644 index f0d0feb8..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/CsvTableFormatterFactory.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import java.io.Writer; -import java.util.Locale; - -/** - * @author Geoffroy Jamgotchian - */ -public class CsvTableFormatterFactory implements TableFormatterFactory { - - @Override - public TableFormatter create(Writer writer, String title, TableFormatterConfig config, Column... columns) { - return new CsvTableFormatter(writer, title, config, columns); - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatter.java b/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatter.java deleted file mode 100644 index 64fb9445..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatter.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import java.io.IOException; - -/** - * @author Geoffroy Jamgotchian - */ -public interface TableFormatter extends AutoCloseable { - - TableFormatter writeComment(String comment) throws IOException; - - TableFormatter writeCell(String s) throws IOException; - - TableFormatter writeEmptyCell() throws IOException; - - TableFormatter writeCell(char c) throws IOException; - - TableFormatter writeCell(int i) throws IOException; - - TableFormatter writeCell(float f) throws IOException; - - TableFormatter writeCell(double d) throws IOException; - - TableFormatter writeCell(boolean b) throws IOException; - - @Override void close() throws IOException; -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterConfig.java b/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterConfig.java deleted file mode 100644 index 6e8e01f0..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterConfig.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; - -import java.util.Locale; - -/** - * @author c.biasuzzi@techrain.it - */ -public class TableFormatterConfig { - - private static final String CONFIG_MODULE_NAME = "table-formatter"; - private static final Locale DEFAULT_LOCALE = Locale.getDefault(); - private static final String DEFAULT_LANGUAGE = DEFAULT_LOCALE.getLanguage(); - private static final char DEFAULT_CSV_SEPARATOR = ';'; - private static final String DEFAULT_INVALID_STRING = "inv"; - private static final Boolean DEFAULT_PRINT_HEADER = true; - private static final Boolean DEFAULT_PRINT_TITLE = true; - - private final Locale locale; - private final char csvSeparator; - private final String invalidString; - private final Boolean printHeader; - private final Boolean printTitle; - - public static TableFormatterConfig load() { - String language = DEFAULT_LANGUAGE; - String separator = DEFAULT_CSV_SEPARATOR + ""; - String invalidString = DEFAULT_INVALID_STRING; - Boolean printHeader = DEFAULT_PRINT_HEADER; - Boolean printTitle = DEFAULT_PRINT_TITLE; - if (PlatformConfig.defaultConfig().moduleExists(CONFIG_MODULE_NAME)) { - ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig(CONFIG_MODULE_NAME); - language = config.getStringProperty("language", DEFAULT_LANGUAGE); - separator = config.getStringProperty("separator", DEFAULT_CSV_SEPARATOR + ""); - invalidString = config.getStringProperty("invalid-string", DEFAULT_INVALID_STRING); - printHeader = config.getBooleanProperty("print-header", DEFAULT_PRINT_HEADER); - printTitle = config.getBooleanProperty("print-title", DEFAULT_PRINT_TITLE); - } - Locale locale= Locale.forLanguageTag(language); - return new TableFormatterConfig(locale,separator.charAt(0),invalidString,printHeader,printTitle); - } - - public TableFormatterConfig(Locale locale, char csvSeparator, String invalidString, Boolean printHeader, Boolean printTitle) { - this.locale = locale; - this.csvSeparator = csvSeparator; - this.invalidString = invalidString; - this.printHeader = printHeader; - this.printTitle = printTitle; - } - - public TableFormatterConfig(Locale locale, String invalidString, Boolean printHeader, Boolean printTitle) { - this(locale, DEFAULT_CSV_SEPARATOR, invalidString, printHeader,printTitle); - } - - public TableFormatterConfig(Locale locale, String invalidString) { - this(locale, DEFAULT_CSV_SEPARATOR, invalidString, DEFAULT_PRINT_HEADER, DEFAULT_PRINT_TITLE); - } - - public TableFormatterConfig() { - this(DEFAULT_LOCALE, DEFAULT_CSV_SEPARATOR, DEFAULT_INVALID_STRING, DEFAULT_PRINT_HEADER, DEFAULT_PRINT_TITLE); - } - - public Locale getLocale() { - return locale; - } - - public char getCsvSeparator() { - return csvSeparator; - } - - public String getInvalidString() { - return invalidString; - } - - public Boolean getPrintHeader() { - return printHeader; - } - - public Boolean getPrintTitle() { - return printTitle; - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [locale=" + locale + - ", csvSeparator=" + csvSeparator + - ", invalidString=" + invalidString + - ", printHeader=" + printHeader + - ", printTitle=" + printTitle + - "]"; - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterFactory.java b/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterFactory.java deleted file mode 100644 index 730c11de..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/io/table/TableFormatterFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import java.io.Writer; -import java.util.Locale; - -/** - * @author Geoffroy Jamgotchian - */ -public interface TableFormatterFactory { - - TableFormatter create(Writer writer, String title, TableFormatterConfig config, Column... columns); - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/jaxb/IntervalAdapter.java b/commons/src/main/java/eu/itesla_project/commons/jaxb/IntervalAdapter.java deleted file mode 100644 index 5af1c022..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/jaxb/IntervalAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.jaxb; - -import javax.xml.bind.annotation.adapters.XmlAdapter; -import org.joda.time.Interval; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class IntervalAdapter extends XmlAdapter { - - @Override - public Interval unmarshal(String v) throws Exception { - return Interval.parse(v); - } - - @Override - public String marshal(Interval v) throws Exception { - return v.toString(); - } - -} \ No newline at end of file diff --git a/commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbContextCache.java b/commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbContextCache.java deleted file mode 100644 index 3f0c2ceb..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbContextCache.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.jaxb; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Geoffroy Jamgotchian - */ -public class JaxbContextCache { - - public static final JaxbContextCache DEFAULT = new JaxbContextCache(); - - private final Map, JAXBContext> cache = new HashMap<>(); - - public JAXBContext createContext(Class aClass) { - // creation of the jaxb context is very slow and could be cached - // for next runs (JAXBContext is thread safe but not Marshaller) - JAXBContext jaxbContext = cache.get(aClass); - if (jaxbContext == null) { - try { - jaxbContext = JAXBContext.newInstance(aClass); - cache.put(aClass, jaxbContext); - } catch (JAXBException e) { - throw new RuntimeException(e); - } - } - return jaxbContext; - } - - public void clear() { - cache.clear(); - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbUtil.java b/commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbUtil.java deleted file mode 100644 index 200d231e..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/jaxb/JaxbUtil.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.jaxb; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.util.JAXBResult; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamSource; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; - -/** - * @author Geoffroy Jamgotchian - */ -public class JaxbUtil { - - private final static Supplier TRANSFORMER_FACTORY_SUPPLIER = Suppliers.memoize(TransformerFactory::newInstance); - - private JaxbUtil() { - } - - public static void marshallElement(JAXBContext jaxbContext, Object jaxbElement, Writer writer) { - try { - Marshaller marshaller = jaxbContext.createMarshaller(); - // output pretty printed - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - marshaller.marshal(jaxbElement, writer); - } catch (JAXBException e) { - throw new RuntimeException(e); - } - } - - public static void marshallElement(Class aClass, Object jaxbElement, Writer writer) { - marshallElement(JaxbContextCache.DEFAULT.createContext(aClass), jaxbElement, writer); - } - - public static void marshallFile(Class aClass, Object jaxbElement, Path file) { - try (Writer writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) { - marshallElement(aClass, jaxbElement, writer); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static void marshallElement(JAXBContext jaxbContext, Object jaxbElement, Path file) { - try (BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) { - marshallElement(jaxbContext, jaxbElement, writer); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static void marshallElement(Class aClass, Object jaxbElement, Path file) { - marshallElement(JaxbContextCache.DEFAULT.createContext(aClass), jaxbElement, file); - } - - public static U unmarchallReader(JAXBContext jaxbContext, Reader reader, Reader xslReader) { - try { - if (xslReader != null) { - JAXBResult result = new JAXBResult(jaxbContext); - TransformerFactory tf = TRANSFORMER_FACTORY_SUPPLIER.get(); - Transformer t = tf.newTransformer(new StreamSource(xslReader)); - t.transform(new StreamSource(reader), result); - return (U) result.getResult(); - } else { - Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); - return (U) unmarshaller.unmarshal(reader); - } - } catch (JAXBException|TransformerException e) { - throw new RuntimeException(e); - } - } - - public static U unmarchallReader(Class aClass, Reader reader, Reader xslReader) { - return unmarchallReader(JaxbContextCache.DEFAULT.createContext(aClass), reader, xslReader); - } - - public static U unmarchallReader(Class aClass, Reader reader) { - return unmarchallReader(JaxbContextCache.DEFAULT.createContext(aClass), reader, null); - } - - public static U unmarchallFile(Class aClass, Path file) { - try (Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { - return unmarchallReader(JaxbContextCache.DEFAULT.createContext(aClass), reader, null); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/net/ConnectionParameters.java b/commons/src/main/java/eu/itesla_project/commons/net/ConnectionParameters.java deleted file mode 100644 index e7efc668..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/net/ConnectionParameters.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.net; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ConnectionParameters { - - private final String host; - - private final int port; - - private final String userName; - - private final String password; - - public ConnectionParameters(String host, int port, String userName, String password) { - this.host = host; - this.port = port; - this.userName = userName; - this.password = password; - } - - public String getHost() { - return host; - } - - public int getPort() { - return port; - } - - public String getUserName() { - return userName; - } - - public String getPassword() { - return password; - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/tools/Command.java b/commons/src/main/java/eu/itesla_project/commons/tools/Command.java deleted file mode 100644 index 18231334..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/tools/Command.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.tools; - -import org.apache.commons.cli.Options; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Command { - - /** - * Get the name of the command. - * - * @return the name of the command - */ - String getName(); - - /** - * Get the command theme used to group in the help usage commands with the - * same theme. - * - * @return the command theme - */ - String getTheme(); - - /** - * Get a description of the command. - * - * @return a description of the command - */ - String getDescription(); - - /** - * Get the command options. - * - * @return the command options - */ - Options getOptions(); - - /** - * Get a foot text that will be displayed in the command usage. - * - * @return a usage foot text - */ - String getUsageFooter(); - - /** - * Check if the command must be visible in the help. - * - * @return true if the command has to be hidden, false otherwise - */ - default boolean isHidden() { - return false; - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/tools/Main.java b/commons/src/main/java/eu/itesla_project/commons/tools/Main.java deleted file mode 100644 index c3e53f57..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/tools/Main.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.tools; - -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import java.io.IOException; -import java.util.*; -import java.util.stream.Collectors; - -import com.google.common.collect.TreeMultimap; -import org.apache.commons.cli.*; - -/** - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class Main { - - private static final String TOOL_NAME = "itools"; - - private Main() { - } - - private static void printUsage() { - StringBuilder usage = new StringBuilder(); - usage.append("usage: " + TOOL_NAME + " COMMAND [ARGS]\n\nAvailable commands are:\n\n"); - - List allTools = Lists.newArrayList(ServiceLoader.load(Tool.class)).stream() - .filter(t -> !t.getCommand().isHidden()).collect(Collectors.toList()); - - // group commands by theme - Map> toolsByTheme = new TreeMap<>(Multimaps.index(allTools, tool -> tool.getCommand().getTheme()).asMap()); - for (Map.Entry> entry : toolsByTheme.entrySet()) { - String theme = entry.getKey(); - List tools = new ArrayList<>(entry.getValue()); - Collections.sort(tools, (t1, t2) -> t1.getCommand().getName().compareTo(t2.getCommand().getName())); - usage.append(theme != null ? theme : "Others").append(":\n"); - for (Tool tool : tools) { - usage.append(String.format(" %-40s %s", tool.getCommand().getName(), tool.getCommand().getDescription())).append("\n"); - } - usage.append("\n"); - } - - System.err.print(usage); - System.exit(1); - } - - private static Options getOptionsWithHelp(Options options) { - Options optionsWithHelp = new Options(); - options.getOptions().forEach(optionsWithHelp::addOption); - optionsWithHelp.addOption(Option.builder().longOpt("help") - .desc("display the help and quit") - .build()); - return optionsWithHelp; - } - - private static void printCommandUsage(Command command) { - HelpFormatter formatter = new HelpFormatter(); - formatter.printHelp(80, TOOL_NAME + " " + command.getName(), "", - getOptionsWithHelp(command.getOptions()), "\n" + Objects.toString(command.getUsageFooter(), ""), true); - } - - private static Tool findTool(String commandName) { - for (Tool tool : ServiceLoader.load(Tool.class)) { - if (tool.getCommand().getName().equals(commandName)) { - return tool; - } - } - return null; - } - - public static void main(String[] args) throws IOException { - if (args.length < 1) { - printUsage(); - } - - Tool tool = findTool(args[0]); - if (tool == null) { - printUsage(); - } - - try { - CommandLineParser parser = new DefaultParser(); - CommandLine line = parser.parse(getOptionsWithHelp(tool.getCommand().getOptions()), Arrays.copyOfRange(args, 1, args.length)); - if (line.hasOption("help")) { - printCommandUsage(tool.getCommand()); - } else { - tool.run(line); - } - } catch (ParseException e) { - System.err.println("error: " + e.getMessage()); - printCommandUsage(tool.getCommand()); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/tools/Tool.java b/commons/src/main/java/eu/itesla_project/commons/tools/Tool.java deleted file mode 100644 index 554873ff..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/tools/Tool.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.tools; - -import org.apache.commons.cli.CommandLine; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Tool { - - /** - * Get the command of the tool. - */ - Command getCommand(); - - /** - * Run the tool. - * - * @param line the command line arguments - * @throws Exception if the command fails - */ - void run(CommandLine line) throws Exception; - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/tools/VersionTool.java b/commons/src/main/java/eu/itesla_project/commons/tools/VersionTool.java deleted file mode 100644 index c4d14514..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/tools/VersionTool.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.tools; - -import com.google.auto.service.AutoService; -import eu.itesla_project.commons.Version; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.Options; - -/** - * @author Geoffroy Jamgotchian - */ -@AutoService(Tool.class) -public class VersionTool implements Tool { - - private static final Command COMMAND = new Command() { - @Override - public String getName() { - return "version"; - } - - @Override - public String getTheme() { - throw new UnsupportedOperationException(); - } - - @Override - public String getDescription() { - throw new UnsupportedOperationException(); - } - - @Override - public Options getOptions() { - return new Options(); - } - - @Override - public String getUsageFooter() { - return null; - } - - @Override - public boolean isHidden() { - return true; - } - }; - - @Override - public Command getCommand() { - return COMMAND; - } - - @Override - public void run(CommandLine line) throws Exception { - System.out.println(Version.VERSION); - } -} diff --git a/commons/src/main/java/eu/itesla_project/commons/util/IntCounter.java b/commons/src/main/java/eu/itesla_project/commons/util/IntCounter.java deleted file mode 100644 index 60af4fea..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/util/IntCounter.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.util; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface IntCounter { - - int getInitialValue(); - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/util/ServiceLoaderCache.java b/commons/src/main/java/eu/itesla_project/commons/util/ServiceLoaderCache.java deleted file mode 100644 index e61f50d4..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/util/ServiceLoaderCache.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.util; - -import com.google.common.collect.Lists; -import java.util.List; -import java.util.Objects; -import java.util.ServiceLoader; - -/** - * A thread safe service loader. - * - * @author Geoffroy Jamgotchian - */ -public class ServiceLoaderCache { - - private final Class serviceClass; - - private List services; - - public ServiceLoaderCache(Class serviceClass) { - this.serviceClass = Objects.requireNonNull(serviceClass); - } - - public synchronized List getServices() { - if (services == null) { - services = Lists.newArrayList(ServiceLoader.load(serviceClass)); - } - return services; - } - -} diff --git a/commons/src/main/java/eu/itesla_project/commons/util/StringToIntMapper.java b/commons/src/main/java/eu/itesla_project/commons/util/StringToIntMapper.java deleted file mode 100644 index ee97d81a..00000000 --- a/commons/src/main/java/eu/itesla_project/commons/util/StringToIntMapper.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.util; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.Writer; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.EnumMap; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class StringToIntMapper & IntCounter> { - - private final Class clazz; - - private final Map> id2num; - - private final Map counter; - - private boolean modified = false; - - public StringToIntMapper(Class clazz) { - this.clazz = clazz; - id2num = new EnumMap<>(clazz); - counter = new EnumMap<>(clazz); - for (SUBSET s : clazz.getEnumConstants()) { - id2num.put(s, HashBiMap.create()); - counter.put(s, s.getInitialValue()); - } - } - - public synchronized int newInt(SUBSET subset, String id) { - if (subset == null) { - throw new IllegalArgumentException("subset is null"); - } - if (id == null) { - throw new IllegalArgumentException("id is null"); - } - Integer num = id2num.get(subset).get(id); - if (num == null) { - num = counter.get(subset); - counter.put(subset, num + 1); - id2num.get(subset).put(id, num); - modified = true; - } - return num; - } - - public synchronized int getInt(SUBSET subset, String id) { - if (subset == null) { - throw new IllegalArgumentException("subset is null"); - } - if (id == null) { - throw new IllegalArgumentException("id is null"); - } - Integer num = id2num.get(subset).get(id); - if (num == null) { - throw new IllegalStateException("No mapping found for id '" + id + "'"); - } - return num; - } - - public synchronized String getId(SUBSET subset, int num) { - if (subset == null) { - throw new IllegalArgumentException("subset is null"); - } - if (num < subset.getInitialValue() || num >= counter.get(subset)) { - throw new IllegalArgumentException("invalid num " + num); - } - return id2num.get(subset).inverse().get(num); - } - - public synchronized boolean isMapped(SUBSET subset, String id) { - Map numbers = id2num.get(subset); - return numbers.containsKey(id); - } - - public synchronized boolean isModified() { - return modified; - } - - public synchronized void dump(Writer writer) throws IOException { - for (Map.Entry> entry : id2num.entrySet()) { - SUBSET subset = entry.getKey(); - for (Map.Entry entry1 : entry.getValue().entrySet()) { - String id = entry1.getKey(); - Integer num = entry1.getValue(); - writer.write(subset + ";" + id + ";" + num + "\n"); - } - } - } - - public void dump(Path file) throws IOException { - try (BufferedWriter writer = Files.newBufferedWriter(file, Charset.forName("UTF-8"))) { - dump(writer); - } - } - - public synchronized void load(BufferedReader reader) throws IOException { - String line; - while ((line = reader.readLine()) != null) { - if (line.trim().isEmpty()) { - continue; - } - String[] tokens = line.split(";"); - if (tokens.length != 3) { - throw new RuntimeException("Bad format: " + line); - } - SUBSET subset = Enum.valueOf(clazz, tokens[0]); - String id = tokens[1]; - int num = Integer.valueOf(tokens[2]); - id2num.get(subset).put(id, num); - counter.put(subset, Math.max(counter.get(subset), num) + 1); - } - } - - public void load(Path file) throws IOException { - try (BufferedReader reader = Files.newBufferedReader(file, Charset.forName("UTF-8"))) { - load(reader); - } - } - -} diff --git a/commons/src/test/java/eu/itesla_project/commons/ConverterBaseTest.java b/commons/src/test/java/eu/itesla_project/commons/ConverterBaseTest.java deleted file mode 100644 index 2467b31d..00000000 --- a/commons/src/test/java/eu/itesla_project/commons/ConverterBaseTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons; - -import com.google.common.io.ByteStreams; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.nio.file.ShrinkWrapFileSystems; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.After; -import org.junit.Before; -import org.xmlunit.builder.DiffBuilder; -import org.xmlunit.builder.Input; -import org.xmlunit.diff.Diff; - -import javax.xml.transform.Source; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.FileSystem; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.function.BiConsumer; -import java.util.function.Function; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public abstract class ConverterBaseTest { - - private FileSystem fileSystem; - protected Path tmpDir; - - @Before - public void setUp() throws IOException { - JavaArchive archive = ShrinkWrap.create(JavaArchive.class); - fileSystem = ShrinkWrapFileSystems.newFileSystem(archive); - tmpDir = fileSystem.getPath("tmp"); - } - - @After - public void tearDown() throws IOException { - fileSystem.close(); - } - - protected static void compareXml(InputStream expected, InputStream actual) { - Source control = Input.fromStream(expected).build(); - Source test = Input.fromStream(actual).build(); - Diff myDiff= DiffBuilder.compare(control).withTest(test).ignoreWhitespace().build(); - boolean hasDiff = myDiff.hasDifferences(); - if (hasDiff) { - System.err.println(myDiff.toString()); - } - assertFalse(hasDiff); - } - - protected static void compareTxt(InputStream expected, InputStream actual) { - try { - assertEquals(new String(ByteStreams.toByteArray(expected), StandardCharsets.UTF_8), - new String(ByteStreams.toByteArray(actual), StandardCharsets.UTF_8)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - protected T roundTripXmlTest(T data, BiConsumer out, Function in, String ref) throws IOException { - return roundTripTest(data, out, in, ConverterBaseTest::compareXml, ref); - } - - protected T roundTripTest(T data, BiConsumer out, Function in, String ref) throws IOException { - return roundTripTest(data, out, in, ConverterBaseTest::compareTxt, ref); - } - - protected Path writeXmlTest(T data, BiConsumer out, String ref) throws IOException { - return writeTest(data, out, ConverterBaseTest::compareXml, ref); - } - - protected Path writeTest(T data, BiConsumer out, BiConsumer compare, String ref) throws IOException { - Path xmlFile = tmpDir.resolve("data"); - out.accept(data, xmlFile); - try (InputStream is = Files.newInputStream(xmlFile)) { - compare.accept(getClass().getResourceAsStream(ref), is); - } - return xmlFile; - } - - protected T roundTripTest(T data, BiConsumer out, Function in, BiConsumer compare, String ref) throws IOException { - Path xmlFile = writeTest(data, out, compare, ref); - T data2 = in.apply(xmlFile); - Path xmlFile2 = tmpDir.resolve("data2"); - out.accept(data2, xmlFile2); - try (InputStream is = Files.newInputStream(xmlFile2)) { - compare.accept(getClass().getResourceAsStream(ref), is); - } - return data2; - } - -} diff --git a/commons/src/test/java/eu/itesla_project/commons/config/ComponentDefaultConfigTest.java b/commons/src/test/java/eu/itesla_project/commons/config/ComponentDefaultConfigTest.java deleted file mode 100644 index 041c125f..00000000 --- a/commons/src/test/java/eu/itesla_project/commons/config/ComponentDefaultConfigTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.nio.file.ShrinkWrapFileSystems; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.nio.file.FileSystem; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -interface A { -} - -class B implements A { -} - -/** - * @author Mathieu Bague - * @author Geoffroy Jamgotchian - */ -public class ComponentDefaultConfigTest { - - private FileSystem fileSystem; - private MapModuleConfig moduleConfig; - private ComponentDefaultConfig config; - - @Before - public void setUp() throws IOException { - JavaArchive archive = ShrinkWrap.create(JavaArchive.class); - fileSystem = ShrinkWrapFileSystems.newFileSystem(archive); - InMemoryPlatformConfig platformConfig = new InMemoryPlatformConfig(fileSystem); - moduleConfig = platformConfig.createModuleConfig("componentDefaultConfig"); - config = new ComponentDefaultConfig(moduleConfig); - } - - @After - public void tearDown() throws IOException { - fileSystem.close(); - } - - @Test - public void findFactoryImplClassTest() throws IOException { - moduleConfig.setStringProperty(A.class.getSimpleName(), B.class.getName()); - assertEquals(B.class, config.findFactoryImplClass(A.class)); - } - - @Test - public void findFactoryImplClassDefaultTest() throws IOException { - assertEquals(B.class, config.findFactoryImplClass(A.class, B.class)); - } - - @Test - public void newFactoryImplTest() throws IOException { - moduleConfig.setStringProperty(A.class.getSimpleName(), B.class.getName()); - assertTrue(config.newFactoryImpl(A.class) instanceof B); - } - - @Test - public void newFactoryImplDefaultTest() throws IOException { - assertTrue(config.newFactoryImpl(A.class, B.class) instanceof B); - } -} diff --git a/commons/src/test/java/eu/itesla_project/commons/config/XmlPlatformConfigTest.java b/commons/src/test/java/eu/itesla_project/commons/config/XmlPlatformConfigTest.java deleted file mode 100644 index 2d313aa1..00000000 --- a/commons/src/test/java/eu/itesla_project/commons/config/XmlPlatformConfigTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.config; - -import java.io.IOException; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.FileSystem; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.*; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLStreamException; - -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.nio.file.ShrinkWrapFileSystems; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Assert; -import org.junit.Test; -import org.xml.sax.SAXException; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class XmlPlatformConfigTest { - - public XmlPlatformConfigTest() { - } - - @Test - public void moduleConfigTest() throws IOException, XMLStreamException, SAXException, ParserConfigurationException { - JavaArchive archive = ShrinkWrap.create(JavaArchive.class); - try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) { - Path cfgDir = fileSystem.getPath("config"); - Properties prop1 = new Properties(); - prop1.setProperty("s", "hello"); - prop1.setProperty("i", Integer.toString(3)); - prop1.setProperty("b", Boolean.FALSE.toString()); - prop1.setProperty("d", Double.toString(2.3)); - prop1.setProperty("c", ArrayList.class.getName()); - prop1.setProperty("sl1", "a,b,c"); - prop1.setProperty("sl2", "a:b:c"); - prop1.setProperty("e", StandardOpenOption.APPEND.name()); - prop1.setProperty("el", StandardOpenOption.APPEND + "," + StandardOpenOption.CREATE); - Path p = fileSystem.getPath("/tmp"); - Path p2 = fileSystem.getPath("/home"); - prop1.setProperty("p", p.toString()); - prop1.setProperty("pl", p.toString() + ":" + p2.toString()); - prop1.setProperty("pl2", p.toString() + "," + p2.toString()); - try (Writer w = Files.newBufferedWriter(cfgDir.resolve("mod.properties"), StandardCharsets.UTF_8)) { - prop1.store(w, null); - } - PropertiesPlatformConfig propsConfig = new PropertiesPlatformConfig(cfgDir, fileSystem); - ModuleConfig modConfig = propsConfig.getModuleConfig("mod"); - Assert.assertTrue(modConfig.getStringProperty("s").equals("hello")); - Assert.assertTrue(modConfig.getStringProperty("s2", "oups").equals("oups")); - try { - modConfig.getStringProperty("s2"); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getIntProperty("i") == 3); - try { - modConfig.getIntProperty("i2"); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getOptionalIntProperty("i2") == null); - Assert.assertTrue(modConfig.getIntProperty("i2", 4) == 4); - Assert.assertFalse(modConfig.getBooleanProperty("b")); - try { - modConfig.getBooleanProperty("b2"); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getBooleanProperty("b2", true)); - Assert.assertTrue(modConfig.getDoubleProperty("d") == 2.3); - try { - modConfig.getDoubleProperty("d2"); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getDoubleProperty("d2", 4.5) == 4.5); - Assert.assertTrue(modConfig.getClassProperty("c", List.class) == ArrayList.class); - Assert.assertTrue(modConfig.getStringListProperty("sl1").equals(Arrays.asList("a", "b", "c"))); - Assert.assertTrue(modConfig.getStringListProperty("sl2").equals(Arrays.asList("a", "b", "c"))); - try { - modConfig.getStringListProperty("sl3"); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getEnumProperty("e", StandardOpenOption.class) == StandardOpenOption.APPEND); - try { - modConfig.getEnumProperty("e2", StandardOpenOption.class); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getEnumSetProperty("el", StandardOpenOption.class).equals(EnumSet.of(StandardOpenOption.APPEND, StandardOpenOption.CREATE))); - try { - modConfig.getEnumSetProperty("el2", StandardOpenOption.class); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getPathProperty("p").equals(p)); - try { - modConfig.getPathProperty("p2"); - Assert.fail(); - } catch (Exception e) { - } - Assert.assertTrue(modConfig.getPathListProperty("pl").equals(Arrays.asList(p, p2))); - Assert.assertTrue(modConfig.getPathListProperty("pl2").equals(Arrays.asList(p, p2))); - try { - modConfig.getPathListProperty("pl3"); - Assert.fail(); - } catch (Exception e) { - } - } - } - - @Test - public void properties2XmlConvertionTest() throws IOException, XMLStreamException, SAXException, ParserConfigurationException { - JavaArchive archive = ShrinkWrap.create(JavaArchive.class); - try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) { - Path cfgDir = fileSystem.getPath("config"); - Properties prop1 = new Properties(); - prop1.setProperty("a", "hello"); - prop1.setProperty("b", "bye"); - try (Writer w = Files.newBufferedWriter(cfgDir.resolve("mod1.properties"), StandardCharsets.UTF_8)) { - prop1.store(w, null); - } - Properties prop2 = new Properties(); - prop2.setProperty("c", "thanks"); - try (Writer w = Files.newBufferedWriter(cfgDir.resolve("mod2.properties"), StandardCharsets.UTF_8)) { - prop2.store(w, null); - } - PropertiesPlatformConfig propsConfig = new PropertiesPlatformConfig(cfgDir, fileSystem); - Assert.assertTrue(propsConfig.getModuleConfig("mod1").getStringProperty("a").equals("hello")); - Assert.assertTrue(propsConfig.getModuleConfig("mod1").getStringProperty("b").equals("bye")); - Assert.assertTrue(propsConfig.getModuleConfig("mod2").getStringProperty("c").equals("thanks")); - String xmlConfigName = "config"; - PropertiesPlatformConfig.writeXml(cfgDir, cfgDir.resolve(xmlConfigName + ".xml")); - - XmlPlatformConfig xmlConfig = new XmlPlatformConfig(cfgDir, xmlConfigName, fileSystem); - Assert.assertTrue(xmlConfig.getModuleConfig("mod1").getStringProperty("a").equals("hello")); - Assert.assertTrue(xmlConfig.getModuleConfig("mod1").getStringProperty("b").equals("bye")); - Assert.assertTrue(xmlConfig.getModuleConfig("mod2").getStringProperty("c").equals("thanks")); - } - } - -} diff --git a/commons/src/test/java/eu/itesla_project/commons/io/table/TableFormatterTest.java b/commons/src/test/java/eu/itesla_project/commons/io/table/TableFormatterTest.java deleted file mode 100644 index e52a7cd5..00000000 --- a/commons/src/test/java/eu/itesla_project/commons/io/table/TableFormatterTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.commons.io.table; - -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.nio.charset.StandardCharsets; -import java.util.Locale; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class TableFormatterTest { - - private static final Column[] COLUMNS = { - new Column("int"), - new Column("float"), - new Column("bool"), - new Column("string") - }; - - private static void write(TableFormatter formatter) throws IOException { - formatter.writeCell(2).writeCell(1.3).writeCell(true).writeCell("aaa") - .writeCell(3).writeCell(4.2).writeCell(false).writeCell("bbb"); - } - - @Test - public void testCsv() throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - TableFormatterConfig config = new TableFormatterConfig(Locale.US, ';', "inv", true, true); - try (TableFormatter formatter = new CsvTableFormatter(new OutputStreamWriter(bos), "csv test", config, COLUMNS)) { - write(formatter); - } - assertEquals(new String(bos.toByteArray(), StandardCharsets.UTF_8), - "csv test\n" + - "int;float;bool;string\n" + - "2;1.30000;true;aaa\n" + - "3;4.20000;false;bbb\n"); - } - - @Test - public void testAcsii() throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - TableFormatterConfig config = new TableFormatterConfig(Locale.US, "inv"); - try (TableFormatter formatter = new AsciiTableFormatter(new OutputStreamWriter(bos), "ascii test", config, COLUMNS)) { - write(formatter); - } - assertEquals(new String(bos.toByteArray(), StandardCharsets.UTF_8), - "ascii test:\n" + - "+-----+---------+-------+--------+\n" + - "| int | float | bool | string |\n" + - "+-----+---------+-------+--------+\n" + - "| 2 | 1.30000 | true | aaa |\n" + - "| 3 | 4.20000 | false | bbb |\n" + - "+-----+---------+-------+--------+\n"); - } -} \ No newline at end of file diff --git a/computation-local/pom.xml b/computation-local/pom.xml deleted file mode 100644 index 0928493f..00000000 --- a/computation-local/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - 4.0.0 - - eu.itesla_project - itesla-parent - 0.1-SNAPSHOT - - computation-local - Local computation - - - ${project.groupId} - commons - ${project.version} - - - ${project.groupId} - computation - ${project.version} - - - diff --git a/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationConfig.java b/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationConfig.java deleted file mode 100644 index 8c0b0a94..00000000 --- a/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationConfig.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.local; - -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; - -import java.nio.file.Path; -import java.nio.file.Paths; - -/** - * @author Geoffroy Jamgotchian - */ -public class LocalComputationConfig { - - private static final String CONFIG_MODULE_NAME = "computation-local"; - - private static final Path DEFAULT_LOCAL_DIR = Paths.get(System.getProperty("java.io.tmpdir")); - - private static final int DEFAULT_AVAILABLE_CORE = 1; - - private final Path localDir; - - private final int availableCore; - - public static LocalComputationConfig load() { - Path localDir = DEFAULT_LOCAL_DIR; - int availableCore = DEFAULT_AVAILABLE_CORE; - if (PlatformConfig.defaultConfig().moduleExists(CONFIG_MODULE_NAME)) { - ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig(CONFIG_MODULE_NAME); - localDir = config.getPathProperty("tmpDir", DEFAULT_LOCAL_DIR); - availableCore = config.getIntProperty("availableCore", DEFAULT_AVAILABLE_CORE); - } - if (availableCore <= 0) { - availableCore = Runtime.getRuntime().availableProcessors(); - } - return new LocalComputationConfig(localDir, availableCore); - } - - public LocalComputationConfig(Path localDir) { - this(localDir, DEFAULT_AVAILABLE_CORE); - } - - public LocalComputationConfig(Path localDir, int availableCore) { - this.localDir = localDir; - this.availableCore = availableCore; - } - - public Path getLocalDir() { - return localDir; - } - - public int getAvailableCore() { - return availableCore; - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [localDir=" + localDir + - ", availableCore=" + availableCore + - "]"; - } -} diff --git a/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationManager.java b/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationManager.java deleted file mode 100644 index 03f31b56..00000000 --- a/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationManager.java +++ /dev/null @@ -1,375 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.local; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.io.ByteStreams; -import eu.itesla_project.commons.io.WorkingDirectory; -import eu.itesla_project.computation.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.Semaphore; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class LocalComputationManager implements ComputationManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(LocalComputationManager.class); - - private final LocalComputationConfig config; - - private final WorkingDirectory commonDir; - - private final LocalComputationResourcesStatus status; - - private final Semaphore permits; - - private static final Lock LOCK = new ReentrantLock(); - - private static LocalComputationManager DEFAULT; - - public static ComputationManager getDefault() { - LOCK.lock(); - try { - if (DEFAULT == null) { - try { - DEFAULT = new LocalComputationManager(); - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - try { - DEFAULT.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - }); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return DEFAULT; - } finally { - LOCK.unlock(); - } - } - - public LocalComputationManager() throws IOException { - this(LocalComputationConfig.load()); - } - - public LocalComputationManager(Path localDir) throws IOException { - this(new LocalComputationConfig(localDir)); - } - - public LocalComputationManager(LocalComputationConfig config) throws IOException { - this.config = Objects.requireNonNull(config, "config is null"); - status = new LocalComputationResourcesStatus(config.getAvailableCore()); - permits = new Semaphore(config.getAvailableCore()); - //make sure the localdir exists - Files.createDirectories(config.getLocalDir()); - commonDir = new WorkingDirectory(config.getLocalDir(), "itesla_common_", false); - LOGGER.info(config.toString()); - } - - @Override - public String getVersion() { - return "none (local mode)"; - } - - @Override - public Path getLocalDir() { - return config.getLocalDir(); - } - - @Override - public OutputStream newCommonFile(String fileName) throws IOException { - return Files.newOutputStream(commonDir.toPath().resolve(fileName)); - } - - @Override - public CommandExecutor newCommandExecutor(Map env, String workingDirPrefix, boolean debug) throws Exception { - Objects.requireNonNull(env); - Objects.requireNonNull(workingDirPrefix); - - WorkingDirectory workingDir = new WorkingDirectory(config.getLocalDir(), workingDirPrefix, debug); - return new CommandExecutor() { - @Override - public Path getWorkingDir() { - return workingDir.toPath(); - } - - @Override - public void start(CommandExecution execution, ExecutionListener listener) throws Exception { - enter(); - try { - if (listener != null) { - listener.onExecutionStart(0, execution.getExecutionCount() - 1); - } - ExecutionReport report = execute(workingDir.toPath(), Arrays.asList(execution), env, (execution1, executionIndex) -> { - if (listener != null) { - listener.onExecutionCompletion(executionIndex); - } - }); - if (listener != null) { - listener.onEnd(report); - } - } finally { - exit(); - } - } - - @Override - public ExecutionReport start(CommandExecution execution) throws Exception { - enter(); - try { - return execute(workingDir.toPath(), Arrays.asList(execution), env, null); - } finally { - exit(); - } - } - - @Override - public void close() throws Exception { - workingDir.close(); - } - }; - } - - private int execute(String program, List args, File out, Path workingDir, Map env) throws IOException, InterruptedException { - StringBuilder internalCmd = new StringBuilder(); - for (Map.Entry entry : env.entrySet()) { - String name = entry.getKey(); - String value = entry.getValue(); - internalCmd.append("export ").append(name).append("=").append(value); - if (name.endsWith("PATH")) { - internalCmd.append(":").append("$").append(name); - } - internalCmd.append("; "); - } - internalCmd.append(program); - for (String arg : args) { - internalCmd.append(" ").append(arg); - } - - List cmdLs = ImmutableList.builder() - .add("bash") - .add("-c") - .add(internalCmd.toString()) - .build(); - ProcessBuilder.Redirect redirect = ProcessBuilder.Redirect.appendTo(out); - Process process = new ProcessBuilder(cmdLs) - .directory(workingDir.toFile()) - .redirectOutput(redirect) - .redirectError(redirect) - .start(); - int exitValue = process.waitFor(); - - // to avoid 'two many open files' exception - process.getInputStream().close(); - process.getOutputStream().close(); - process.getErrorStream().close(); - - if (exitValue != 0) { - LOGGER.debug("Command '{}' has failed (exitValue={})", cmdLs, exitValue); - } - return exitValue; - } - - private interface ExecutionMonitor { - - void onProgress(CommandExecution execution, int executionIndex); - - } - - private ExecutionReport execute(Path workingDir, List commandExecutionList, Map variables, ExecutionMonitor monitor) - throws IOException, InterruptedException { - List errors = new ArrayList<>(); - - // set TMPDIR to working dir to avoid issue with /tmp - ImmutableMap variables2 = ImmutableMap.builder() - .putAll(variables) - .put("TMPDIR", workingDir.toAbsolutePath().toString()) - .build(); - - for (CommandExecution commandExecution : commandExecutionList) { - Command command = commandExecution.getCommand(); - - for (int executionIndex = 0; executionIndex < commandExecution.getExecutionCount(); executionIndex++) { - LOGGER.debug("Executing command {} in working directory {}", - command.toString(Integer.toString(executionIndex)), workingDir); - - // pre-processing - for (InputFile file : command.getInputFiles(Integer.toString(executionIndex))) { - // first check if the file exists in the working directory - Path path = workingDir.resolve(file.getName()); - if (!Files.exists(path)) { - // if not check if the file exists in the common directory - path = commonDir.toPath().resolve(file.getName()); - if (!Files.exists(path)) { - throw new RuntimeException("Input file '" + file.getName() + "' not found in the working and common directory"); - } - if (file.getPreProcessor() == null) { - Files.copy(path, workingDir.resolve(path.getFileName())); - } - } - if (file.getPreProcessor() != null) { - switch (file.getPreProcessor()) { - case FILE_GUNZIP: - // gunzip the file - try (InputStream is = new GZIPInputStream(Files.newInputStream(path)); - OutputStream os = Files.newOutputStream(workingDir.resolve(file.getName().substring(0, file.getName().length() - 3)))) { - ByteStreams.copy(is, os); - } - break; - case ARCHIVE_UNZIP: - // extract the archive - try (ZipFile zipFile = new ZipFile(path.toFile())) { - for (ZipEntry ze : Collections.list(zipFile.entries())) { - Files.copy(zipFile.getInputStream(ze), workingDir.resolve(ze.getName()), REPLACE_EXISTING); - } - } - break; - - default: - throw new InternalError(); - } - } - } - - int exitValue = 0; - File out = workingDir.resolve(command.getId() + "_" + executionIndex + ".out").toFile(); - switch (command.getType()) { - case SIMPLE: - SimpleCommand simpleCmd = (SimpleCommand) command; - exitValue = execute(simpleCmd.getProgram(), - simpleCmd.getArgs(Integer.toString(executionIndex)), - out, - workingDir, - variables2); - break; - case GROUP: - for (GroupCommand.SubCommand subCmd : ((GroupCommand) command).getSubCommands()) { - exitValue = execute(subCmd.getProgram(), - subCmd.getArgs(Integer.toString(executionIndex)), - out, - workingDir, - variables2); - if (exitValue != 0) { - break; - } - } - break; - default: - throw new InternalError(); - } - - if (exitValue != 0) { - errors.add(new ExecutionError(command, executionIndex, exitValue)); - } else { - // post processing - for (OutputFile file : command.getOutputFiles(Integer.toString(executionIndex))) { - Path path = workingDir.resolve(file.getName()); - if (file.getPostProcessor() != null && Files.isRegularFile(path)) { - switch (file.getPostProcessor()) { - case FILE_GZIP: - // gzip the file - try (InputStream is = Files.newInputStream(path); - OutputStream os = new GZIPOutputStream(Files.newOutputStream(workingDir.resolve(file.getName() + ".gz")))) { - ByteStreams.copy(is, os); - } - break; - - default: - throw new InternalError(); - } - } - } - } - - if (monitor != null) { - monitor.onProgress(commandExecution, executionIndex); - } - } - } - return new ExecutionReport(errors); - } - - private void enter() throws InterruptedException { - permits.acquire(); - status.incrementNumberOfBusyCores(); - } - - private void exit() { - status.decrementNumberOfBusyCores(); - permits.release(); - } - - @Override - public CompletableFuture execute(ExecutionEnvironment environment, ExecutionHandler handler) { - Objects.requireNonNull(environment); - Objects.requireNonNull(handler); - CompletableFuture f = new CompletableFuture<>(); - getExecutor().execute(() -> { - try { - try (WorkingDirectory workingDir = new WorkingDirectory(config.getLocalDir(), environment.getWorkingDirPrefix(), environment.isDebug())) { - List commandExecutionList = handler.before(workingDir.toPath()); - ExecutionReport report = null; - enter(); - try { - report = execute(workingDir.toPath(), commandExecutionList, environment.getVariables(), (execution, executionIndex) -> handler.onProgress(execution, executionIndex)); - } finally { - exit(); - } - R result = handler.after(workingDir.toPath(), report); - f.complete(result); - } - } catch (Exception e) { - f.completeExceptionally(e); - } - }); - return f; - } - - @Override - public ComputationResourcesStatus getResourcesStatus() { - return status; - } - - @Override - public Executor getExecutor() { - return ForkJoinPool.commonPool(); - } - - @Override - public void close() throws IOException { - commonDir.close(); - } - -} diff --git a/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationResourcesStatus.java b/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationResourcesStatus.java deleted file mode 100644 index 1d032d54..00000000 --- a/computation-local/src/main/java/eu/itesla_project/computation/local/LocalComputationResourcesStatus.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.local; - -import eu.itesla_project.computation.ComputationResourcesStatus; -import org.joda.time.DateTime; - -import java.util.Collections; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -class LocalComputationResourcesStatus implements ComputationResourcesStatus { - - private final int availableCores; - - private DateTime date; - - private int busyCores = 0; - - LocalComputationResourcesStatus(int availableCores) { - this.availableCores = availableCores; - } - - @Override - public synchronized DateTime getDate() { - return date; - } - - @Override - public int getAvailableCores() { - return availableCores; - } - - @Override - public synchronized int getBusyCores() { - return busyCores; - } - - @Override - public synchronized Map getBusyCoresPerApp() { - return Collections.singletonMap("all", busyCores); - } - - synchronized void incrementNumberOfBusyCores() { - date = new DateTime(); - busyCores++; - } - - synchronized void decrementNumberOfBusyCores() { - date = new DateTime(); - busyCores--; - } - -} diff --git a/computation-mpi-util/pom.xml b/computation-mpi-util/pom.xml deleted file mode 100644 index 5f75c440..00000000 --- a/computation-mpi-util/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - 4.0.0 - - computation-mpi-util - MPI Computation utilities - - - - eu.itesla_project - computation-mpi - ${project.version} - - - eu.itesla_project - iidm-network-impl - ${project.version} - - - - \ No newline at end of file diff --git a/computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContext.java b/computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContext.java deleted file mode 100644 index 0f1ab18e..00000000 --- a/computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContext.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi.util; - -import eu.itesla_project.computation.mpi.MpiExecutorContext; -import eu.itesla_project.iidm.network.impl.util.MultiStateNetworkAwareExecutors; - -import java.util.concurrent.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class MultiStateNetworkAwareMpiExecutorContext implements MpiExecutorContext { - - private final ScheduledExecutorService monitorExecutorService; - private final ExecutorService schedulerExecutorService; - private final ExecutorService computationExecutorService; - private final ExecutorService applicationExecutorService; - - public MultiStateNetworkAwareMpiExecutorContext() { - monitorExecutorService = Executors.newScheduledThreadPool(1); - schedulerExecutorService = Executors.newCachedThreadPool(); - computationExecutorService = MultiStateNetworkAwareExecutors.newSizeLimitedThreadPool("COMPUTATION_POOL", 100); - applicationExecutorService = MultiStateNetworkAwareExecutors.newSizeLimitedThreadPool("APPLICATION_POOL", 100); - } - - @Override - public ScheduledExecutorService getMonitorExecutor() { - return monitorExecutorService; - } - - @Override - public ExecutorService getSchedulerExecutor() { - return schedulerExecutorService; - } - - @Override - public ExecutorService getBeforeExecutor() { - return computationExecutorService; - } - - @Override - public ExecutorService getCommandExecutor() { - return computationExecutorService; - } - - @Override - public ExecutorService getAfterExecutor() { - return computationExecutorService; - } - - @Override - public ExecutorService getApplicationExecutor() { - return applicationExecutorService; - } - - @Override - public void shutdown() throws InterruptedException { - monitorExecutorService.shutdown(); - schedulerExecutorService.shutdown(); - computationExecutorService.shutdown(); - applicationExecutorService.shutdown(); - monitorExecutorService.awaitTermination(15, TimeUnit.MINUTES); - schedulerExecutorService.awaitTermination(15, TimeUnit.MINUTES); - computationExecutorService.awaitTermination(15, TimeUnit.MINUTES); - applicationExecutorService.awaitTermination(15, TimeUnit.MINUTES); - } -} diff --git a/computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContextFactory.java b/computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContextFactory.java deleted file mode 100644 index 2ed85e81..00000000 --- a/computation-mpi-util/src/main/java/eu/itesla_project/computation/mpi/util/MultiStateNetworkAwareMpiExecutorContextFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi.util; - -import eu.itesla_project.computation.mpi.MpiExecutorContext; -import eu.itesla_project.computation.mpi.MpiExecutorContextFactory; - -/** - * @author Geoffroy Jamgotchian - */ -public class MultiStateNetworkAwareMpiExecutorContextFactory implements MpiExecutorContextFactory { - @Override - public MpiExecutorContext create() { - return new MultiStateNetworkAwareMpiExecutorContext(); - } -} diff --git a/computation-mpi/pom.xml b/computation-mpi/pom.xml deleted file mode 100644 index 48c4b6cc..00000000 --- a/computation-mpi/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - 4.0.0 - - eu.itesla_project - itesla-parent - 0.1-SNAPSHOT - - computation-mpi - MPI computation - - - com.google.protobuf - protobuf-java - 2.5.0 - - - joda-time - joda-time - - - com.google.auto.service - auto-service - - - ${project.groupId} - computation - ${project.version} - - - ${project.groupId} - commons - ${project.version} - - - junit - junit - test - - - org.jboss.shrinkwrap - shrinkwrap-api - test - - - org.jboss.shrinkwrap - shrinkwrap-api-nio2 - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-base - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-nio2 - test - - - org.slf4j - slf4j-simple - test - - - diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CommonFile.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CommonFile.java deleted file mode 100644 index 31c5c836..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CommonFile.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -/** - * - * @author Geoffroy Jamgotchian - */ -class CommonFile { - - private final String name; - - private final byte[] data; - - private final int chunk; - - private final boolean last; - - CommonFile(String name, byte[] data, int chunk, boolean last) { - this.name = name; - this.data = data; - this.chunk = chunk; - this.last = last; - } - - String getName() { - return name; - } - - byte[] getData() { - return data; - } - - public int getChunk() { - return chunk; - } - - public boolean isLast() { - return last; - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/Core.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/Core.java deleted file mode 100644 index 40332948..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/Core.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -/** - * - * @author Geoffroy Jamgotchian - */ -class Core { - - MpiRank rank; - - int thread; - - Core(MpiRank rank, int thread) { - this.rank = rank; - this.thread = thread; - } - - @Override - public String toString() { - return rank + "_" + thread; - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CorePool.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CorePool.java deleted file mode 100755 index 64b8efe0..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CorePool.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Deque; -import java.util.List; -import java.util.Set; - -/** - * - * @author Geoffroy Jamgotchian - */ -class CorePool { - - private final Deque cores = new ArrayDeque<>(); - - private final Multimap coresPerRank = HashMultimap.create(); - - List borrowCores(int n) { - return borrowCores(n, null); - } - - synchronized List borrowCores(int n, Set preferedRanks) { - if (n > cores.size()) { - throw new IllegalArgumentException("Not enough cores"); - } - List borrowedCores = new ArrayList<>(n); - if (preferedRanks != null && preferedRanks.size() > 0) { - END: for (int preferedRank : preferedRanks) { - for (Core preferedCore : coresPerRank.get(preferedRank)) { - if (borrowedCores.size() >= n) { - break END; - } - borrowedCores.add(preferedCore); - } - } - for (Core borrowedCore : borrowedCores) { - cores.remove(borrowedCore); - coresPerRank.remove(borrowedCore.rank, borrowedCore); - } - } - while (borrowedCores.size() < n) { - Core borrowedCore = cores.poll(); - borrowedCores.add(borrowedCore); - coresPerRank.remove(borrowedCore.rank, borrowedCore); - } - return borrowedCores; - } - - synchronized void returnCore(Core borrowedCore) { - cores.push(borrowedCore); - coresPerRank.put(borrowedCore.rank.num, borrowedCore); - } - - void returnCores(List borrowedCores) { - for (Core borrowedCore : borrowedCores) { - returnCore(borrowedCore); - } - } - - synchronized int availableCores() { - return cores.size(); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatistics.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatistics.java deleted file mode 100644 index c2317bf8..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatistics.java +++ /dev/null @@ -1,617 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import com.google.common.base.Joiner; -import com.google.common.base.Joiner.MapJoiner; -import com.google.common.base.Splitter; -import com.google.common.base.Splitter.MapSplitter; -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.atomic.AtomicLong; -import org.joda.time.DateTime; -import org.joda.time.Duration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CsvMpiStatistics implements MpiStatistics { - - private static final Logger LOGGER = LoggerFactory.getLogger(CsvMpiStatistics.class); - - private static final String COMMON_FILE_TRANSFER_KEY = "COMMON_FILE_TRANSFER"; - private static final String JOB_START_KEY = "JOB_START"; - private static final String JOB_END_KEY = "JOB_END"; - private static final String TASK_START_KEY = "TASK_START"; - private static final String TASK_END_KEY = "TASK_END"; - - private static final String CSV_SEPARATOR = ";"; - - private final Path dbDir; - private final String dbName; - private final BufferedWriter internalWriter; - - private final Joiner blankJoiner = Joiner.on(' '); - private final MapJoiner mapJoiner = blankJoiner.withKeyValueSeparator("="); - - private static class StatisticsReader implements AutoCloseable { - - private final BufferedReader reader; - - Map tasks = new HashMap<>(); - - Map jobs = new HashMap<>(); - - private static class JobExecution { - final int jobId; - final String commandId; - final Map tags; - private JobExecution(int jobId, String commandId, Map tags) { - this.jobId = jobId; - this.commandId = commandId; - this.tags = tags; - } - } - - private static class TaskExecution { - final int taskId ; - final int jobId; - final int taskIndex; - - final DateTime startTime; - final int slaveRank; - final int slaveThread; - final long inputMessageSize; - Long taskDuration; - List commandsDuration; - Long dataTransferDuration; - Long outputMessageSize; - Long workingDataSize; - Integer exitCode; - private TaskExecution(int taskId, int jobId, int taskIndex, DateTime startTime, int slaveRank, int slaveThread, long inputMessageSize) { - this.taskId = taskId; - this.jobId = jobId; - this.taskIndex = taskIndex; - this.startTime = startTime; - this.slaveRank = slaveRank; - this.slaveThread = slaveThread; - this.inputMessageSize = inputMessageSize; - } - } - - private static class CommonFileTransfer { - String fileName; - long size; - long duration; - CommonFileTransfer(String fileName, long size, long duration) { - this.fileName = fileName; - this.size = size; - this.duration = duration; - } - } - - private static interface Handler { - - void onTaskEnd(TaskExecution task, JobExecution job); - - void onCommonFileTransfer(CommonFileTransfer commonFileTransfer); - - } - - private static abstract class AbstractHandler implements Handler { - - @Override - public void onTaskEnd(TaskExecution task, JobExecution job) { - } - - @Override - public void onCommonFileTransfer(CommonFileTransfer commonFileTransfer) { - } - - } - - private StatisticsReader(Path tasksCsv) throws IOException { - reader = Files.newBufferedReader(tasksCsv, StandardCharsets.UTF_8); - } - - private void read(Handler handler) throws IOException { - Splitter blankSplitter = Splitter.on(' '); - MapSplitter mapSplitter = blankSplitter.withKeyValueSeparator('='); - String line; - while ((line = reader.readLine()) != null) { - if (line.trim().isEmpty()) { - continue; - } - String[] tokens = line.split(CSV_SEPARATOR); - if (tokens.length < 1) { - throw new RuntimeException("Cannot detect line key"); - } - String key = tokens[0]; - switch (key) { - case COMMON_FILE_TRANSFER_KEY: - { - if (tokens.length != 4) { - throw new RuntimeException("Incorrect " + COMMON_FILE_TRANSFER_KEY + " line '" + line + "'"); - } - String fileName = tokens[1]; - long size = Long.parseLong(tokens[2]); - long duration = Long.parseLong(tokens[3]); - handler.onCommonFileTransfer(new CommonFileTransfer(fileName, size, duration)); - } - break; - case JOB_START_KEY: - { - if (tokens.length != 3 && tokens.length != 4) { - throw new RuntimeException("Incorrect " + JOB_START_KEY + " line '" + line + "'"); - } - int jobId = Integer.parseInt(tokens[1]); - String commandId = tokens[2]; - Map tags = null; - if (tokens.length == 4) { - tags = mapSplitter.split(tokens[3]); - } - jobs.put(jobId, new JobExecution(jobId, commandId, tags)); - } - break; - case JOB_END_KEY: - { - if (tokens.length != 2) { - throw new RuntimeException("Incorrect " + JOB_END_KEY + " line '" + line + "'"); - } - int jobId = Integer.parseInt(tokens[1]); - jobs.remove(jobId); - } - break; - case TASK_START_KEY: - { - if (tokens.length != 8) { - throw new RuntimeException("Incorrect " + TASK_START_KEY + " line '" + line + "'"); - } - int taskId = Integer.parseInt(tokens[1]); - int jobId = Integer.parseInt(tokens[2]); - int taskIndex = Integer.parseInt(tokens[3]); - DateTime startTime = DateTime.parse(tokens[4]); - int slaveRank = Integer.parseInt(tokens[5]); - int slaveThread = Integer.parseInt(tokens[6]); - long inputMessageSize = Long.parseLong(tokens[7]); - tasks.put(taskId, new TaskExecution(taskId, jobId, taskIndex, startTime, slaveRank, slaveThread, inputMessageSize)); - } - break; - case TASK_END_KEY: - { - if (tokens.length != 8) { - throw new RuntimeException("Incorrect " + TASK_END_KEY + " line '" + line + "'"); - } - int taskId = Integer.parseInt(tokens[1]); - TaskExecution task = tasks.get(taskId); - task.taskDuration = Long.parseLong(tokens[2]); - task.commandsDuration = new ArrayList<>(); - for (String s : blankSplitter.split(tokens[3])) { - task.commandsDuration.add(Long.parseLong(s)); - } - task.dataTransferDuration = Long.parseLong(tokens[4]); - task.outputMessageSize = Long.parseLong(tokens[5]); - task.workingDataSize = Long.parseLong(tokens[6]); - task.exitCode = Integer.parseInt(tokens[7]); - - JobExecution job = jobs.get(task.jobId); - - handler.onTaskEnd(task, job); - - tasks.remove(taskId); - } - break; - default: - throw new RuntimeException("Unknown key " + key); - } - } - } - - @Override - public void close() throws IOException { - reader.close(); - } - - } - - public CsvMpiStatistics(Path dbDir, String dbName) throws IOException { - Objects.requireNonNull(dbDir); - Objects.requireNonNull(dbName); - this.dbDir = dbDir; - this.dbName = dbName; - Path csvFile = dbDir.resolve(dbName + ".csv"); - // if file already exists, create a backup - if (Files.exists(csvFile)) { - int i = 1; - Path savCsvFile; - do { - savCsvFile = csvFile.getParent().resolve(csvFile.getFileName() + "." + i++); - } while (Files.exists(savCsvFile)); - Files.move(csvFile, savCsvFile); - } - internalWriter = Files.newBufferedWriter(csvFile, StandardCharsets.UTF_8); - } - - @Override - public void logCommonFileTransfer(String fileName, int chunk, long size, long duration) { - try { - internalWriter.write(COMMON_FILE_TRANSFER_KEY); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(fileName); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Long.toString(size)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Long.toString(duration)); - internalWriter.newLine(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void logJobStart(int jobId, String commandId, Map tags) { - try { - internalWriter.write(JOB_START_KEY); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(jobId)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(commandId); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(tags != null ? mapJoiner.join(tags) : ""); - internalWriter.newLine(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void logJobEnd(int jobId) { - try { - internalWriter.write(JOB_END_KEY); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(jobId)); - internalWriter.newLine(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void logTaskStart(int taskId, int jobId, int taskIndex, DateTime startTime, int slaveRank, int slaveThread, long inputMessageSize) { - try { - internalWriter.write(TASK_START_KEY); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(taskId)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(jobId)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(taskIndex)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(startTime.toString()); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(slaveRank)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(slaveThread)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Long.toString(inputMessageSize)); - internalWriter.newLine(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void logTaskEnd(int taskId, long taskDuration, List commandsDuration, long dataTransferDuration, long outputMessageSize, long workingDataSize, int exitCode) { - try { - internalWriter.write(TASK_END_KEY); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(taskId)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Long.toString(taskDuration)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(blankJoiner.join(commandsDuration)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Long.toString(dataTransferDuration)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Long.toString(outputMessageSize)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Long.toString(workingDataSize)); - internalWriter.write(CSV_SEPARATOR); - internalWriter.write(Integer.toString(exitCode)); - internalWriter.newLine(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void exportTasksToCsv(final Writer writer) { - try { - Path csv = dbDir.resolve(dbName + ".csv"); - - writer.write("Task Id " + CSV_SEPARATOR + - "Job Id" + CSV_SEPARATOR + - "Task index" + CSV_SEPARATOR + - "Command Id" + CSV_SEPARATOR + - "Tags" + CSV_SEPARATOR + - "Start time" + CSV_SEPARATOR + - "Slave rank" + CSV_SEPARATOR + - "Slave thread" + CSV_SEPARATOR + - "Input message size (bytes)" + CSV_SEPARATOR + - "Task duration (ms)" + CSV_SEPARATOR + - "Commands duration (ms)" + CSV_SEPARATOR + - "Data transfer duration (ms)" + CSV_SEPARATOR + - "Output message size (bytes)" + CSV_SEPARATOR + - "Working data size (bytes)" + CSV_SEPARATOR + - "Exit code"); - writer.write("\n"); - - try (StatisticsReader reader = new StatisticsReader(csv)) { - reader.read(new StatisticsReader.AbstractHandler() { - - @Override - public void onTaskEnd(StatisticsReader.TaskExecution task, StatisticsReader.JobExecution job) { - try { - String taskDuration = ""; - if (task.taskDuration != null) { - taskDuration = task.taskDuration.toString(); - } - String commandsDuration = ""; - if (task.commandsDuration != null) { - commandsDuration = blankJoiner.join(task.commandsDuration); - } - String dataTransferDuration = ""; - if (task.dataTransferDuration != null) { - dataTransferDuration = task.dataTransferDuration.toString(); - } - String outputMessageSize = ""; - if (task.outputMessageSize != null) { - outputMessageSize = task.outputMessageSize.toString(); - } - String workingDataSize = ""; - if (task.workingDataSize != null) { - workingDataSize = task.workingDataSize.toString(); - } - String exitCode = ""; - if (task.exitCode != null) { - exitCode = task.exitCode.toString(); - } - writer.write(task.taskId + CSV_SEPARATOR + - task.jobId + CSV_SEPARATOR + - task.taskIndex + CSV_SEPARATOR + - job.commandId + CSV_SEPARATOR + - (job.tags != null ? mapJoiner.join(job.tags) : "") + CSV_SEPARATOR + - task.startTime.toString("dd/MM/YYYY HH:mm:ss") + CSV_SEPARATOR + - task.slaveRank + CSV_SEPARATOR + - task.slaveThread + CSV_SEPARATOR + - task.inputMessageSize + CSV_SEPARATOR + - taskDuration + CSV_SEPARATOR + - commandsDuration + CSV_SEPARATOR + - dataTransferDuration + CSV_SEPARATOR + - outputMessageSize + CSV_SEPARATOR + - workingDataSize + CSV_SEPARATOR + - exitCode); - writer.write("\n"); - } catch (IOException e) { - LOGGER.error(e.toString(), e); - } - } - }); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static void exportCommonFileTransferDuration(Path dbDir, String dbName) throws IOException { - Objects.requireNonNull(dbDir); - Objects.requireNonNull(dbName); - - Path csv = dbDir.resolve(dbName + ".csv"); - - Path commonFilesTransferCsv = dbDir.resolve("common-files-transfer.csv"); - - LOGGER.info("Writing " + commonFilesTransferCsv); - - try (BufferedWriter commonFilesTransferWriter = Files.newBufferedWriter(commonFilesTransferCsv, StandardCharsets.UTF_8)) { - commonFilesTransferWriter.write("File name" + CSV_SEPARATOR + "File size (bytes)" + CSV_SEPARATOR + "Transfer duration (ms)"); - commonFilesTransferWriter.newLine(); - - try (StatisticsReader reader = new StatisticsReader(csv)) { - reader.read(new StatisticsReader.AbstractHandler() { - - @Override - public void onCommonFileTransfer(StatisticsReader.CommonFileTransfer transfer) { - try { - commonFilesTransferWriter.write(transfer.fileName + CSV_SEPARATOR + transfer.size + CSV_SEPARATOR + transfer.duration); - commonFilesTransferWriter.newLine(); - } catch (IOException e) { - LOGGER.error(e.toString(), e); - } - } - }); - } - } - } - - public static void exportTaskCount(Path dbDir, String dbName) throws IOException { - Objects.requireNonNull(dbDir); - Objects.requireNonNull(dbName); - - Path csv = dbDir.resolve(dbName + ".csv"); - - class CommandStats { - int count = 0; - int ok = 0; - } - - Path tasksCountCsv = dbDir.resolve("tasks-count.csv"); - LOGGER.info("Writing " + tasksCountCsv); - - final Map tasksPerCommandId = new HashMap<>(); - try (StatisticsReader reader = new StatisticsReader(csv)) { - reader.read(new StatisticsReader.AbstractHandler() { - - @Override - public void onTaskEnd(StatisticsReader.TaskExecution task, StatisticsReader.JobExecution job) { - CommandStats stats = tasksPerCommandId.get(job.commandId); - if (stats == null) { - stats = new CommandStats(); - tasksPerCommandId.put(job.commandId, stats); - } - stats.count++; - if (task.exitCode == 0) { - stats.ok++; - } - } - - }); - } - - try (BufferedWriter writer = Files.newBufferedWriter(tasksCountCsv, StandardCharsets.UTF_8)) { - writer.write("Command Id" + CSV_SEPARATOR + "Executions" + CSV_SEPARATOR + "OK rate"); - writer.newLine(); - for (Map.Entry entry : tasksPerCommandId.entrySet()) { - String commandId = entry.getKey(); - CommandStats stats = entry.getValue(); - writer.write(commandId + CSV_SEPARATOR + stats.count + CSV_SEPARATOR + ((float) stats.ok / stats.count)); - writer.newLine(); - } - } - } - - public static void exportBusyCores(Path dbDir, String dbName) throws IOException { - Objects.requireNonNull(dbDir); - Objects.requireNonNull(dbName); - - Path csv = dbDir.resolve(dbName + ".csv"); - - Path busyCoresCsv = dbDir.resolve("busy-cores.csv"); - LOGGER.info("Writing " + busyCoresCsv); - - final DateTime[] min = new DateTime[1]; - final DateTime[] max = new DateTime[1]; - try (StatisticsReader reader = new StatisticsReader(csv)) { - reader.read(new StatisticsReader.AbstractHandler() { - - @Override - public void onTaskEnd(StatisticsReader.TaskExecution task, StatisticsReader.JobExecution job) { - if (min[0] == null || task.startTime.compareTo(min[0]) < 0) { - min[0] = task.startTime; - } - if (task.taskDuration != null) { - DateTime endTime = task.startTime.plusMillis((int) (long) task.taskDuration); - if (max[0] == null || endTime.compareTo(max[0]) > 0) { - max[0] = endTime; - } - } - } - - }); - } - - final int secs = (int) new Duration(min[0], max[0]).getStandardSeconds() + 1; - final int[] busyCores = new int[secs]; - Arrays.fill(busyCores, 0); - try (StatisticsReader reader = new StatisticsReader(csv)) { - reader.read(new StatisticsReader.AbstractHandler() { - - @Override - public void onTaskEnd(StatisticsReader.TaskExecution task, StatisticsReader.JobExecution job) { - int s1 = (int) new Duration(min[0], task.startTime).getStandardSeconds(); - int s2; - if (task.taskDuration != null) { - s2 = s1 + (int) ((float) task.taskDuration / 1000); - } else { - s2 = secs - 1; - } - for (int s = s1; s <= s2; s++) { - busyCores[s]++; - } - } - - }); - } - try (BufferedWriter writer = Files.newBufferedWriter(busyCoresCsv, StandardCharsets.UTF_8)) { - writer.write("Second" + CSV_SEPARATOR + "Busy cores"); - writer.newLine(); - for (int s = 0; s < busyCores.length; s++) { - writer.write(Integer.toString(s)); - writer.write(CSV_SEPARATOR); - writer.write(Integer.toString(busyCores[s])); - writer.newLine(); - } - } - } - - public static void exportWorkingDataSize(Path dbDir, String dbName) throws IOException { - Objects.requireNonNull(dbDir); - Objects.requireNonNull(dbName); - - Path csv = dbDir.resolve(dbName + ".csv"); - - Path workingDataSizeCsv = dbDir.resolve("working-data-size.csv"); - LOGGER.info("Writing " + workingDataSizeCsv); - - final Map workingDataSizePerSlave = new HashMap<>(); - final long[] totalWorkingDataSize = new long[1]; - try (StatisticsReader reader = new StatisticsReader(csv)) { - reader.read(new StatisticsReader.AbstractHandler() { - - @Override - public void onTaskEnd(StatisticsReader.TaskExecution task, StatisticsReader.JobExecution job) { - if (task.workingDataSize != null) { - String slaveId = task.slaveRank + "_" + task.slaveThread; - AtomicLong workingDataSize = workingDataSizePerSlave.get(slaveId); - if (workingDataSize == null) { - workingDataSize = new AtomicLong(); - workingDataSizePerSlave.put(slaveId, workingDataSize); - } - workingDataSize.addAndGet(task.workingDataSize); - totalWorkingDataSize[0] += task.workingDataSize; - } - } - - }); - } - - try (BufferedWriter writer = Files.newBufferedWriter(workingDataSizeCsv, StandardCharsets.UTF_8)) { - writer.write("Slave" + CSV_SEPARATOR + "Working data size (bytes)"); - writer.newLine(); - for (Map.Entry entry : workingDataSizePerSlave.entrySet()) { - String slaveId = entry.getKey(); - long workingDataSize = entry.getValue().get(); - writer.write(slaveId + CSV_SEPARATOR + workingDataSize); - writer.newLine(); - } - writer.write("Total" + CSV_SEPARATOR + totalWorkingDataSize[0]); - writer.newLine(); - } - } - - @Override - public void close() throws Exception { - internalWriter.close(); - } - -} - diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatisticsFactory.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatisticsFactory.java deleted file mode 100644 index ddfebdd4..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/CsvMpiStatisticsFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.nio.file.Path; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CsvMpiStatisticsFactory implements MpiStatisticsFactory { - - @Override - public MpiStatistics create(Path dbDir, String dbName) throws Exception { - return new CsvMpiStatistics(dbDir, dbName); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContext.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContext.java deleted file mode 100644 index 39929fc6..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContext.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ScheduledExecutorService; - -/** - * @author Geoffroy Jamgotchian - */ -public class DefaultMpiExecutorContext implements MpiExecutorContext { - - @Override - public ScheduledExecutorService getMonitorExecutor() { - return null; - } - - @Override - public ExecutorService getSchedulerExecutor() { - return ForkJoinPool.commonPool(); - } - - @Override - public ExecutorService getAfterExecutor() { - return ForkJoinPool.commonPool(); - } - - @Override - public ExecutorService getApplicationExecutor() { - return ForkJoinPool.commonPool(); - } - - @Override - public ExecutorService getBeforeExecutor() { - return ForkJoinPool.commonPool(); - } - - @Override - public ExecutorService getCommandExecutor() { - return ForkJoinPool.commonPool(); - } - - @Override - public void shutdown() throws InterruptedException { - } -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContextFactory.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContextFactory.java deleted file mode 100644 index 3ad91162..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/DefaultMpiExecutorContextFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -/** - * @author Geoffroy Jamgotchian - */ -public class DefaultMpiExecutorContextFactory implements MpiExecutorContextFactory { - - @Override - public MpiExecutorContext create() { - return new DefaultMpiExecutorContext(); - } -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsCommand.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsCommand.java deleted file mode 100644 index 42f22466..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsCommand.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import eu.itesla_project.commons.tools.Command; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ExportTasksStatisticsCommand implements Command { - - public static final ExportTasksStatisticsCommand INSTANCE = new ExportTasksStatisticsCommand(); - - @Override - public String getName() { - return "export-tasks-statistics"; - } - - @Override - public String getTheme() { - return "MPI statistics"; - } - - @Override - public String getDescription() { - return "export tasks statistics to CSV"; - } - - @Override - @SuppressWarnings("static-access") - public Options getOptions() { - Options options = new Options(); - options.addOption(Option.builder().longOpt("statistics-db-dir") - .desc("statistics db directory") - .hasArg() - .argName("DIR") - .required() - .build()); - options.addOption(Option.builder().longOpt("statistics-db-name") - .desc("statistics db name") - .hasArg() - .argName("NAME") - .required() - .build()); - options.addOption(Option.builder().longOpt("output-file") - .desc("CSV output file") - .hasArg() - .argName("FILE") - .required() - .build()); - return options; - } - - @Override - public String getUsageFooter() { - return null; - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsTool.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsTool.java deleted file mode 100644 index bc59c6b2..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ExportTasksStatisticsTool.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import eu.itesla_project.commons.tools.Tool; -import eu.itesla_project.commons.tools.Command; -import com.google.auto.service.AutoService; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import org.apache.commons.cli.CommandLine; - -/** - * - * @author Geoffroy Jamgotchian - */ -@AutoService(Tool.class) -public class ExportTasksStatisticsTool implements Tool { - - @Override - public Command getCommand() { - return ExportTasksStatisticsCommand.INSTANCE; - } - - @Override - public void run(CommandLine line) throws Exception { - Path statisticsDbDir = Paths.get(line.getOptionValue("statistics-db-dir")); - String statisticsDbName = line.getOptionValue("statistics-db-name"); - Path outputFile = Paths.get(line.getOptionValue("output-file")); - try (MpiStatistics statistics = new CsvMpiStatistics(statisticsDbDir, statisticsDbName)) { - try (Writer writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) { - statistics.exportTasksToCsv(writer); - } - } - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/JniMpiNativeServices.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/JniMpiNativeServices.java deleted file mode 100644 index 51296cda..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/JniMpiNativeServices.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - */ -public class JniMpiNativeServices implements MpiNativeServices { - - static { - System.loadLibrary("master"); - } - - public native void initMpi(int coresPerRank, boolean verbose); - - public native void terminateMpi(); - - public native String getMpiVersion(); - - public native int getMpiCommSize(); - - public native void sendCommonFile(byte[] message); - - public native void startTasks(List tasks); - - public native void checkTasksCompletion(List runningTasks, List completedTasks); - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationManager.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationManager.java deleted file mode 100644 index 5898afce..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationManager.java +++ /dev/null @@ -1,336 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import eu.itesla_project.commons.io.FileUtil; -import eu.itesla_project.commons.io.WorkingDirectory; -import eu.itesla_project.computation.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.*; -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class MpiComputationManager implements ComputationManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(MpiComputationManager.class); - - private static final int LOG_DELAY = 10; // 10 s - - private static final int CHUNK_MAX_SIZE = (int) (100 * Math.pow(2, 20)); // 100 Mb - - private final Path localDir; - - private final MpiStatistics statistics; - - private final MpiExecutorContext executorContext; - - private final MpiJobScheduler scheduler; - - private Future busyCoresPrintTask; - - public MpiComputationManager(Path localDir, MpiJobScheduler scheduler) throws IOException, InterruptedException { - this(localDir, scheduler, new NoMpiStatistics(), new DefaultMpiExecutorContext()); - } - - public MpiComputationManager(Path localDir, MpiNativeServices nativeServices) throws IOException, InterruptedException { - this(localDir, nativeServices, new NoMpiStatistics(), new DefaultMpiExecutorContext(), 1, false, null); - } - - public MpiComputationManager(Path localDir, MpiStatistics statistics, MpiExecutorContext executorContext, - int coresPerRank, boolean verbose, Path stdOutArchive) throws IOException, InterruptedException { - this(localDir, new JniMpiNativeServices(), statistics, executorContext, coresPerRank, verbose, stdOutArchive); - } - - public MpiComputationManager(Path localDir, MpiNativeServices nativeServices, MpiStatistics statistics, - MpiExecutorContext executorContext, int coresPerRank, boolean verbose, Path stdOutArchive) throws IOException, InterruptedException { - this(localDir, new MpiJobSchedulerImpl(nativeServices, statistics, coresPerRank, verbose, executorContext.getSchedulerExecutor(), stdOutArchive), statistics, executorContext); - } - - public MpiComputationManager(Path localDir, MpiJobScheduler scheduler, MpiStatistics statistics, MpiExecutorContext executorContext) throws IOException, InterruptedException { - this.localDir = Objects.requireNonNull(localDir); - this.statistics = Objects.requireNonNull(statistics); - this.executorContext = Objects.requireNonNull(executorContext); - this.scheduler = scheduler; - if (executorContext.getMonitorExecutor() != null) { - busyCoresPrintTask = executorContext.getMonitorExecutor().scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - LOGGER.info("Busy cores {}/{}, {} tasks/s", - scheduler.getResources().getBusyCores(), - scheduler.getResources().getAvailableCores(), - ((float) scheduler.getStartedTasksAndReset()) / LOG_DELAY); - } - }, 0, LOG_DELAY, TimeUnit.SECONDS); - } - } - - @Override - public String getVersion() { - return "MPI " + scheduler.getVersion(); - } - - @Override - public Path getLocalDir() { - return localDir; - } - - @Override - public OutputStream newCommonFile(final String fileName) throws IOException { - // transfer the common file in fixed size chunks - return new OutputStream() { - - private final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - - private int chunk = 0; - - private void checkSize(boolean last) throws IOException { - if (last || buffer.size() > CHUNK_MAX_SIZE) { - scheduler.sendCommonFile(new CommonFile(fileName, buffer.toByteArray(), chunk++, last)); - buffer.reset(); - } - } - - @Override - public void write(int b) throws IOException { - buffer.write(b); - checkSize(false); - } - - @Override - public void write(byte[] b) throws IOException { - buffer.write(b); - checkSize(false); - } - - @Override - public void write(byte[] b, int off, int len) throws IOException { - buffer.write(b, off, len); - checkSize(false); - } - - @Override - public void flush() throws IOException { - buffer.flush(); - } - - @Override - public void close() throws IOException { - buffer.close(); - checkSize(true); - } - }; - } - - @Override - public CommandExecutor newCommandExecutor(Map env, String workingDirPrefix, boolean debug) throws Exception { - Objects.requireNonNull(env); - Objects.requireNonNull(workingDirPrefix); - Path workingDir = Files.createTempDirectory(localDir, workingDirPrefix); - return new CommandExecutor() { - @Override - public Path getWorkingDir() { - return workingDir; - } - - @Override - public void start(CommandExecution execution, ExecutionListener listener) throws Exception { - Objects.requireNonNull(execution); - final int[] startCounter = new int[1]; - final Lock startLock = new ReentrantLock(); - final Condition zero = startLock.newCondition(); - scheduler.execute(execution, workingDir, env, new ExecutionListener() { - - @Override - public void onExecutionStart(int fromExecutionIndex, int toExecutionIndex) { - if (listener != null) { - listener.onExecutionStart(fromExecutionIndex, toExecutionIndex); - } - } - - @Override - public void onExecutionCompletion(int executionIndex) { - if (listener != null) { - listener.onExecutionCompletion(executionIndex); - } - } - - @Override - public void onEnd(ExecutionReport report) { - startLock.lock(); - try { - startCounter[0]--; - if (startCounter[0] == 0) { - zero.signal(); - } - } finally { - startLock.unlock(); - } - if (listener != null) { - listener.onEnd(report); - } - } - - }); - startLock.lock(); - try { - startCounter[0]++; - } finally { - startLock.unlock(); - } - } - - @Override - public ExecutionReport start(CommandExecution execution) throws Exception { - final CountDownLatch latch = new CountDownLatch(1); - final ExecutionReport[] reports = new ExecutionReport[1]; - start(execution, new AbstractExecutionListener() { - - @Override - public void onEnd(ExecutionReport report) { - reports[0] = report; - latch.countDown(); - } - }); - latch.await(); - return reports[0]; - } - - @Override - public void close() throws Exception { - if (!debug) { - FileUtil.removeDir(workingDir); - } - } - }; - } - - @Override - public CompletableFuture execute(final ExecutionEnvironment environment, - final ExecutionHandler handler) { - Objects.requireNonNull(environment); - Objects.requireNonNull(handler); - - class AsyncContext { - - WorkingDirectory workingDir; - - List parametersList; - - ExecutionReport report; - - } - - return CompletableFuture - .completedFuture(new AsyncContext()) - .thenApplyAsync(ctxt -> { - try { - ctxt.workingDir = new WorkingDirectory(localDir, environment.getWorkingDirPrefix(), environment.isDebug()); - } catch (IOException e) { - throw new RuntimeException(e); - } - try { - ctxt.parametersList = handler.before(ctxt.workingDir.toPath()); - } catch (Throwable t) { - try { - ctxt.workingDir.close(); - } catch (IOException e2) { - throw new RuntimeException(e2); - } - throw new RuntimeException(t); - } - return ctxt; - }, executorContext.getBeforeExecutor()) - .thenComposeAsync(ctxt -> { - if (ctxt.parametersList.isEmpty()) { - ctxt.report = new ExecutionReport(Collections.emptyList()); - return CompletableFuture.completedFuture(ctxt); - } else { - CompletableFuture last = null; - for (CommandExecution execution : ctxt.parametersList) { - - ExecutionListener l = new AbstractExecutionListener() { - - @Override - public void onExecutionCompletion(int executionIndex) { - try { - handler.onProgress(execution, executionIndex); - } catch (Exception e) { - LOGGER.error(e.toString(), e); - } - } - }; - - if (last == null) { - last = scheduler.execute(execution, ctxt.workingDir.toPath(), environment.getVariables(), l); - } else { - last = last.thenCompose(report -> { - if (report.getErrors().isEmpty()) { - return scheduler.execute(execution, ctxt.workingDir.toPath(), environment.getVariables(), l); - } else { - return CompletableFuture.completedFuture(report); - } - }); - } - } - - return last.thenApply(report -> { - ctxt.report = report; - return ctxt; - }); - } - }, executorContext.getCommandExecutor()) - .thenApplyAsync(ctxt -> { - try { - return handler.after(ctxt.workingDir.toPath(), ctxt.report); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - try { - ctxt.workingDir.close(); - } catch (IOException e2) { - throw new RuntimeException(e2); - } - } - }, executorContext.getAfterExecutor()); - } - - @Override - public ComputationResourcesStatus getResourcesStatus() { - return new MpiComputationResourcesStatus(scheduler.getResources()); - } - - @Override - public Executor getExecutor() { - return executorContext.getApplicationExecutor(); - } - - @Override - public void close() throws Exception { - scheduler.shutdown(); - statistics.close(); - if (busyCoresPrintTask != null) { - busyCoresPrintTask.cancel(true); - } - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationResourcesStatus.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationResourcesStatus.java deleted file mode 100644 index afbda4d1..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiComputationResourcesStatus.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import com.google.common.collect.ImmutableMap; -import eu.itesla_project.computation.ComputationResourcesStatus; -import java.util.Map; -import org.joda.time.DateTime; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MpiComputationResourcesStatus implements ComputationResourcesStatus { - - private final DateTime date; - - private int availableCores = 0; - - private int busyCores = 0; - - MpiComputationResourcesStatus(MpiResources resources) { - date = new DateTime(); - availableCores = resources.getAvailableCores(); - busyCores = resources.getBusyCores(); - } - - @Override - public DateTime getDate() { - return date; - } - - @Override - public int getAvailableCores() { - return availableCores; - } - - @Override - public int getBusyCores() { - return busyCores; - } - - @Override - public Map getBusyCoresPerApp() { - return ImmutableMap.of("all", busyCores); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContext.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContext.java deleted file mode 100644 index 3ffb569d..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContext.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.ScheduledExecutorService; - -/** - * @author Geoffroy Jamgotchian - */ -public interface MpiExecutorContext { - - ExecutorService getSchedulerExecutor(); - - ScheduledExecutorService getMonitorExecutor(); - - ExecutorService getBeforeExecutor(); - - ExecutorService getCommandExecutor(); - - ExecutorService getAfterExecutor(); - - ExecutorService getApplicationExecutor(); - - void shutdown() throws InterruptedException ; -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContextFactory.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContextFactory.java deleted file mode 100644 index 40801fe2..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiExecutorContextFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -/** - * @author Geoffroy Jamgotchian - */ -public interface MpiExecutorContextFactory { - - MpiExecutorContext create(); -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJob.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJob.java deleted file mode 100644 index 69bacbdb..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJob.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import eu.itesla_project.computation.ExecutionListener; -import eu.itesla_project.computation.CommandExecution; -import eu.itesla_project.computation.ExecutionError; -import eu.itesla_project.computation.ExecutionReport; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class MpiJob { - - private final int id; - - private final CommandExecution execution; - - private final ExecutionListener listener; - - private final CompletableFuture future; - - private final Path workingDir; - - private final Map env; - - private int taskIndex = 0; - - private final List runningTasks = new ArrayList<>(); - - private final List errors = new ArrayList<>(); - - private final Set usedRanks = new HashSet<>(); - - MpiJob(int id, CommandExecution execution, Path workingDir, Map env, ExecutionListener listener, CompletableFuture future) { - this.id = id; - this.execution = execution; - this.workingDir = workingDir; - this.env = env; - this.listener = new ProfiledExecutionListener(listener); - this.future = future; - } - - CommandExecution getExecution() { - return execution; - } - - int getId() { - return id; - } - - Path getWorkingDir() { - return workingDir; - } - - Map getEnv() { - return env; - } - - ExecutionListener getListener() { - return listener; - } - - CompletableFuture getFuture() { - return future; - } - - int getTaskIndex() { - return taskIndex; - } - - void setTaskIndex(int taskIndex) { - this.taskIndex = taskIndex; - } - - List getRunningTasks() { - return runningTasks; - } - - List getErrors() { - return errors; - } - - Set getUsedRanks() { - return usedRanks; - } - - boolean isCompleted() { - return taskIndex >= execution.getExecutionCount() && runningTasks.isEmpty(); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobScheduler.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobScheduler.java deleted file mode 100644 index b33c1cc9..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobScheduler.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import eu.itesla_project.computation.CommandExecution; -import eu.itesla_project.computation.ExecutionListener; -import eu.itesla_project.computation.ExecutionReport; - -import java.nio.file.Path; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -/** - * @author Geoffroy Jamgotchian - */ -public interface MpiJobScheduler { - - MpiResources getResources(); - - String getVersion(); - - int getStartedTasksAndReset(); - - void sendCommonFile(CommonFile commonFile); - - CompletableFuture execute(CommandExecution execution, Path workingDir, Map env, ExecutionListener listener); - - void shutdown() throws Exception; - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobSchedulerImpl.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobSchedulerImpl.java deleted file mode 100644 index 61022b62..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiJobSchedulerImpl.java +++ /dev/null @@ -1,631 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import com.google.common.collect.ImmutableMap; -import com.google.common.io.ByteStreams; -import com.google.protobuf.ByteString; -import eu.itesla_project.computation.*; -import eu.itesla_project.computation.mpi.messages.Messages; -import org.joda.time.DateTime; -import org.joda.time.Duration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; -import java.util.stream.Collectors; -import java.util.zip.GZIPInputStream; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MpiJobSchedulerImpl implements MpiJobScheduler { - - private static final Logger LOGGER = LoggerFactory.getLogger(MpiJobSchedulerImpl.class); - - private static final int TIMEOUT = 10; // ms - - private static final Map ZIP_FS_ENV = ImmutableMap.of("create", "true"); - - private final MpiNativeServices nativeServices; - - private final MpiStatistics statistics; - - private final Future future; - - private final List newCommonFiles = new ArrayList<>(); - - private final Lock newCommonFileLock = new ReentrantLock(); - - private final Set commonFiles = new HashSet<>(); - - private final List newJobs = new ArrayList<>(); - - private final Lock newJobsLock = new ReentrantLock(); - - // active contexts ordered by priority - private final Set jobs = new TreeSet<>(new Comparator() { - @Override - public int compare(MpiJob c1, MpiJob c2) { - if (c1.getExecution().getPriority() != c2.getExecution().getPriority()) { - return c1.getExecution().getPriority() - c2.getExecution().getPriority(); - } else { - return System.identityHashCode(c1) - System.identityHashCode(c2); - } - } - }); - - private volatile boolean stopRequested = false; - - private String mpiVersion; - - private MpiResources resources; - - private final AtomicInteger startedTasks = new AtomicInteger(); - - private int taskId = 0; - - private int jobId = 0; - - private final Path stdOutArchive; - - // profiling - private long startTasksTime; - private long startTasksJniTime; - private long processCompletedTasksTime; - private long checkTaskCompletionTime; - - MpiJobSchedulerImpl(MpiNativeServices nativeServices, MpiStatistics statistics, final int coresPerRank, boolean verbose, ExecutorService executor, Path stdOutArchive) throws InterruptedException, IOException { - this.nativeServices = Objects.requireNonNull(nativeServices); - this.statistics = Objects.requireNonNull(statistics); - if (stdOutArchive != null) { - if (Files.exists(stdOutArchive)) { - if (!Files.isRegularFile(stdOutArchive)) { - throw new IllegalArgumentException("Bad standard output archive file"); - } - Files.deleteIfExists(stdOutArchive); - } - LOGGER.info("Standard output of failed commands will be archived {}", stdOutArchive); - } - this.stdOutArchive = stdOutArchive; - final CountDownLatch initialized = new CountDownLatch(1); - future = executor.submit(new Runnable() { - - @Override - public void run() { - LOGGER.trace("Job scheduler started"); - try { - nativeServices.initMpi(coresPerRank, verbose); - - mpiVersion = nativeServices.getMpiVersion(); - resources = new MpiResources(nativeServices.getMpiCommSize(), coresPerRank); - - initialized.countDown(); - - long time = System.currentTimeMillis(); - - List completedTasks = new ArrayList<>(); - while (!stopRequested || jobs.size() > 0) { - boolean sleep = true; - - // check performances - long oldTime = time; - time = System.currentTimeMillis(); - long diff = time - oldTime; - if (diff > 1000) { // 1s - LOGGER.warn("Slowness ({} ms) has been detected in the job scheduler (startTasksTime={}, startTasksJniTime={}, processCompletedTasksTime={}, checkTaskCompletionTime={})", - diff, startTasksTime, startTasksJniTime, processCompletedTasksTime, checkTaskCompletionTime); - } - startTasksTime = 0; - startTasksJniTime = 0; - processCompletedTasksTime = 0; - checkTaskCompletionTime = 0; - - newCommonFileLock.lock(); - try { - for (CommonFile commonFile : newCommonFiles) { - LOGGER.info("Sending chunk {} of common file '{}' (last={})", - commonFile.getChunk(), commonFile.getName(), commonFile.isLast()); - List allCores = resources.reserveAllCoresOrFail(); - try { - try (ByteArrayInputStream is = new ByteArrayInputStream(commonFile.getData())) { - // no pre-processor let it as it is - Messages.CommonFile message = Messages.CommonFile.newBuilder() - .setName(commonFile.getName()) - .setChunk(commonFile.getChunk()) - .setLast(commonFile.isLast()) - .setData(ByteString.readFrom(is)) - .build(); - long t1 = System.currentTimeMillis(); - nativeServices.sendCommonFile(message.toByteArray()); - long t2 = System.currentTimeMillis(); - commonFiles.add(commonFile.getName()); - MpiJobSchedulerImpl.this.statistics.logCommonFileTransfer(commonFile.getName(), commonFile.getChunk(), commonFile.getData().length, t2 - t1); - } - } finally { - resources.releaseCores(allCores); - } - } - newCommonFiles.clear(); - } finally { - newCommonFileLock.unlock(); - } - - // add new context - newJobsLock.lock(); - try { - jobs.addAll(newJobs); - newJobs.clear(); - } finally { - newJobsLock.unlock(); - } - - for (Iterator it = jobs.iterator(); it.hasNext(); ) { - MpiJob job = it.next(); - - sleep = startTasks(job); - - long t0 = System.currentTimeMillis(); - try { - nativeServices.checkTasksCompletion(job.getRunningTasks(), completedTasks); - } finally { - checkTaskCompletionTime += (System.currentTimeMillis() - t0); - } - if (completedTasks.size() > 0) { - DateTime endTime = DateTime.now(); - - // release cores as fast as possible - for (MpiTask tasks : completedTasks) { - MpiJobSchedulerImpl.this.resources.releaseCore(tasks.getCore()); - tasks.setEndTime(endTime); - } - - // ...and re-use immediatly free cores - startTasks(job); - - // ...and then post process terminated tasks - processCompletedTasks(job, completedTasks); - - // ...no more tasks to start or running, we can remove the context - if (job.isCompleted()) { - // remove the job - it.remove(); - - ExecutionReport report = new ExecutionReport(job.getErrors()); - try { - job.getListener().onEnd(report); - } catch (Exception e) { - LOGGER.error(e.toString(), e); - } - job.getFuture().complete(report); - - MpiJobSchedulerImpl.this.statistics.logJobEnd(job.getId()); - } - - sleep = false; - } - } - - // just sleep in the case nothing has been done in the loop - if (sleep) { - TimeUnit.MILLISECONDS.sleep(TIMEOUT); - } - } - - nativeServices.terminateMpi(); - - } catch (Throwable t) { - LOGGER.error(t.toString(), t); - System.exit(-1); - } - - LOGGER.trace("Job scheduler stopped"); - } - }); - - initialized.await(); - } - - @Override - public MpiResources getResources() { - return resources; - } - - @Override - public String getVersion() { - return mpiVersion; - } - - @Override - public int getStartedTasksAndReset() { - return startedTasks.getAndSet(0); - } - - private static Messages.Task.InputFile.PreProcessor createPreProcessor(FilePreProcessor preProcessor) { - return preProcessor != null ? Messages.Task.InputFile.PreProcessor.valueOf(preProcessor.name()) : Messages.Task.InputFile.PreProcessor.NONE; - } - - private static Messages.Task.OutputFile.PostProcessor createPostProcessor(FilePostProcessor postProcessor) { - return postProcessor != null ? Messages.Task.OutputFile.PostProcessor.valueOf(postProcessor.name()) : Messages.Task.OutputFile.PostProcessor.NONE; - } - - private static Messages.Task.Environment createEnvMessage(Map env) { - Messages.Task.Environment.Builder builder = Messages.Task.Environment.newBuilder(); - for (Map.Entry var : env.entrySet()) { - builder.addVariable(Messages.Task.Variable.newBuilder() - .setName(var.getKey()) - .setValue(var.getValue()) - .build()); - } - return builder.build(); - } - - private static Messages.Task.Command createCommand(SimpleCommand command, int taskIndex) { - Messages.Task.Command.Builder builder = Messages.Task.Command.newBuilder() - .setProgram(command.getProgram()) - .addAllArgument(command.getArgs(Integer.toString(taskIndex))); - if (command.getTimeout() != -1) { - builder.setTimeout(command.getTimeout()); - } - return builder.build(); - } - - private static Messages.Task.Command createCommand(GroupCommand.SubCommand subCmd, int taskIndex) { - Messages.Task.Command.Builder builder = Messages.Task.Command.newBuilder() - .setProgram(subCmd.getProgram()) - .addAllArgument(subCmd.getArgs(Integer.toString(taskIndex))); - if (subCmd.getTimeout() != -1) { - builder.setTimeout(subCmd.getTimeout()); - } - return builder.build(); - } - - private Messages.Task createTaskMessage(MpiJob job, MpiRank rank, Command command, int taskIndex) throws IOException { - - // job scoped file will be sent only one time to each slave - boolean initJob = rank.jobs.add(job); - - Messages.Task.Builder builder = Messages.Task.newBuilder() - .setJobId(job.getId()) - .setIndex(taskIndex) - .setCmdId(command.getId()) - .setInitJob(initJob); - - // - // select which files have to be send with the message - // - for (InputFile file : command.getInputFiles()) { - if (file.dependsOnExecutionNumber()) { - // - // case 1: the file name depends on the execution instance, it has - // to be sent with the message - // - InputFile instFile = file.instanciate(Integer.toString(taskIndex)); - Path path = job.getWorkingDir().resolve(instFile.getName()); - if (Files.exists(path)) { - try (InputStream is = Files.newInputStream(path)) { - builder.addInputFile(Messages.Task.InputFile.newBuilder() - .setName(instFile.getName()) - .setScope(Messages.Task.InputFile.Scope.TASK) - .setPreProcessor(createPreProcessor(instFile.getPreProcessor())) - .setData(ByteString.readFrom(is)) - .build()); - } - } else { - if (commonFiles.contains(instFile.getName())) { - builder.addInputFile(Messages.Task.InputFile.newBuilder() - .setName(instFile.getName()) - .setScope(Messages.Task.InputFile.Scope.RUN) - .setPreProcessor(createPreProcessor(instFile.getPreProcessor())) - .build()); - } else { - throw new RuntimeException("Input file " + instFile.getName() - + " not found in the working directory nor in the common file list"); - } - } - } else { - - Path path = job.getWorkingDir().resolve(file.getName()); - if (Files.exists(path)) { - // - // case 2: the file name does not depend on the execution instance - // and exists in the working directory - // - if (initJob) { - // - // case 2-1: this is the first task of the job executed by - // the slave with specified rank, we pack the file with - // the message - // - try (InputStream is = Files.newInputStream(path)) { - builder.addInputFile(Messages.Task.InputFile.newBuilder() - .setName(file.getName()) - .setScope(Messages.Task.InputFile.Scope.JOB) - .setPreProcessor(createPreProcessor(file.getPreProcessor())) - .setData(ByteString.readFrom(is)) - .build()); - } - } else { - // - // case 2-2: another task of the job has already been - // handled by the slave with the specified rank, so the file - // is already cached on the slave node and there is no need - // the pack it with the message - // - builder.addInputFile(Messages.Task.InputFile.newBuilder() - .setName(file.getName()) - .setScope(Messages.Task.InputFile.Scope.JOB) - .setPreProcessor(createPreProcessor(file.getPreProcessor())) - .build()); - } - } else { - // - // case 3: the file name does not depend on the execution instance - // and belongs to the common file list, it has already been - // sent to all slave so no need to pack it in the message - // - if (commonFiles.contains(file.getName())) { - builder.addInputFile(Messages.Task.InputFile.newBuilder() - .setName(file.getName()) - .setScope(Messages.Task.InputFile.Scope.RUN) - .setPreProcessor(createPreProcessor(file.getPreProcessor())) - .build()); - } else { - throw new RuntimeException("Input file " + file.getName() - + " not found in the common file list"); - } - } - } - } - - builder.setEnv(createEnvMessage(job.getEnv())); - - switch (command.getType()) { - case SIMPLE: - builder.addCommand(createCommand((SimpleCommand) command, taskIndex)); - break; - - case GROUP: - for (GroupCommand.SubCommand subCmd : ((GroupCommand) command).getSubCommands()) { - builder.addCommand(createCommand(subCmd, taskIndex)); - } - break; - - default: - throw new InternalError(); - } - - for (OutputFile outputFile : command.getOutputFiles(Integer.toString(taskIndex))) { - builder.addOutputFile(Messages.Task.OutputFile.newBuilder() - .setName(outputFile.getName()) - .setPostProcessor(createPostProcessor(outputFile.getPostProcessor())) - .build()); - } - - for (Iterator it = rank.jobs.iterator(); it.hasNext();) { - MpiJob otherJob = it.next(); - if (otherJob.isCompleted()) { - it.remove(); - builder.addCompletedJobId(otherJob.getId()); - } - } - - return builder.build(); - } - - private boolean startTasks(MpiJob job) throws IOException, InterruptedException { - long t0 = System.currentTimeMillis(); - try { - CommandExecution execution = job.getExecution(); - Command command = execution.getCommand(); - - int taskIndex = job.getTaskIndex(); - - if (taskIndex < execution.getExecutionCount()) { - // reserve one core for each of the execution instances - List allocatedCores = resources.reserveCores(execution.getExecutionCount() - taskIndex, job.getUsedRanks()); - if (allocatedCores != null && allocatedCores.size() > 0) { - - if (taskIndex == 0) { - statistics.logJobStart(job.getId(), command.getId(), execution.getTags()); - } - - LOGGER.debug("Sending commands {} to slaves {} using working directory {}", - command.toString("*"), allocatedCores, job.getWorkingDir()); - - DateTime startTime = DateTime.now(); - - // encode task messages - int oldTaskIndex = taskIndex; - List tasks = new ArrayList<>(allocatedCores.size()); - for (Core core : allocatedCores) { - byte[] message = createTaskMessage(job, core.rank, command, taskIndex).toByteArray(); - - MpiTask task = new MpiTask(taskId++, core, taskIndex, message, startTime); - tasks.add(task); - - statistics.logTaskStart(task.getId(), - job.getId(), - taskIndex, - startTime, - core.rank.num, - core.thread, - message.length); - - taskIndex++; - - // update used ranks - // TODO c'est completement bugge, ne pas reactiver!!!! -// job.getUsedRanks().add(core.rank.num); - } - - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Starting tasks {} of job {}", - tasks.stream().map(MpiTask::getIndex).collect(Collectors.toList()), job.getId()); - } - - // run tasks on slaves nodes - long t1 = System.currentTimeMillis(); - try { - nativeServices.startTasks(tasks); - } finally { - startTasksJniTime += (System.currentTimeMillis() - t1); - } - - startedTasks.addAndGet(allocatedCores.size()); - - job.setTaskIndex(taskIndex); - job.getRunningTasks().addAll(tasks); - - // notify execution start - try { - job.getListener().onExecutionStart(oldTaskIndex, taskIndex); - } catch (Exception e) { - LOGGER.error(e.toString(), e); - } - return false; - } - } - return true; - } finally { - startTasksTime += (System.currentTimeMillis() - t0); - } - } - - private void processCompletedTasks(MpiJob job, List completedTasks) throws IOException { - long t0 = System.currentTimeMillis(); - try { - CommandExecution execution = job.getExecution(); - Command command = execution.getCommand(); - - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Tasks {} of job {} completed", - completedTasks.stream().map(MpiTask::getIndex).collect(Collectors.toList()), job.getId()); - } - - for (MpiTask task : completedTasks) { - // duration of the task seen by the master in ms - long taskDurationSeenByMaster = new Duration(task.getStartTime(), task.getEndTime()).getMillis(); - - // decode task result messages - Messages.TaskResult message = Messages.TaskResult.parseFrom(task.getResultMessage()); - - // duration of the task seen by the slave in ms - long taskDurationSeenBySlave = message.getTaskDuration(); // number of ms - - // write output files to working dir - String stdOutGzFileName = job.getExecution().getCommand().getId() + "_" + task.getIndex() + ".out.gz"; - for (Messages.TaskResult.OutputFile outputFile : message.getOutputFileList()) { - // std out file special case directly unzip it on working dir - if (outputFile.getName().equals(stdOutGzFileName)) { - Path path = job.getWorkingDir().resolve(outputFile.getName().substring(0, outputFile.getName().length() - 3)); - try (InputStream is = new GZIPInputStream(outputFile.getData().newInput()); - OutputStream os = Files.newOutputStream(path)) { - ByteStreams.copy(is, os); - } - } else { - Path path = job.getWorkingDir().resolve(outputFile.getName()); - try (InputStream is = outputFile.getData().newInput(); - OutputStream os = Files.newOutputStream(path)) { - ByteStreams.copy(is, os); - } - } - - // archive standard output of problematic tasks - if (stdOutArchive != null) { - if (message.getExitCode() != 0) { - if (outputFile.getName().equals(stdOutGzFileName)) { - try (FileSystem archiveFileSystem = FileSystems.newFileSystem(URI.create("jar:file:" + stdOutArchive.toUri().getPath()), ZIP_FS_ENV)) { - Path dir = archiveFileSystem.getPath("/").resolve("job-" + job.getId()); - Files.createDirectories(dir); - try (InputStream is = outputFile.getData().newInput(); - OutputStream os = Files.newOutputStream(dir.resolve(outputFile.getName()))) { - ByteStreams.copy(is, os); - } - } - } - } - } - } - - if (message.getExitCode() != 0) { - job.getErrors().add(new ExecutionError(command, - task.getIndex(), - message.getExitCode())); - } - - // notify execution completion - try { - job.getListener().onExecutionCompletion(task.getIndex()); - } catch (Exception e) { - LOGGER.error(e.toString(), e); - } - - // update execution statistics - statistics.logTaskEnd(task.getId(), - taskDurationSeenByMaster, - message.getCommandDurationList(), - taskDurationSeenByMaster - taskDurationSeenBySlave, - task.getResultMessage().length, - message.getWorkingDataSize(), - message.getExitCode()); - } - - job.getRunningTasks().removeAll(completedTasks); - completedTasks.clear(); - } finally { - processCompletedTasksTime += (System.currentTimeMillis() - t0); - } - } - - @Override - public void sendCommonFile(CommonFile commonFile) { - newCommonFileLock.lock(); - try { - newCommonFiles.add(commonFile); - } finally { - newCommonFileLock.unlock(); - } - } - - @Override - public CompletableFuture execute(CommandExecution execution, Path workingDir, Map env, ExecutionListener listener) { - CompletableFuture future = new CompletableFuture<>(); - newJobsLock.lock(); - try { - MpiJob job = new MpiJob(jobId++, execution, workingDir, env, listener, future); - newJobs.add(job); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Job {} scheduled ({} tasks)", job.getId(), job.getExecution().getExecutionCount()); - } - } finally { - newJobsLock.unlock(); - } - return future; - } - - @Override - public void shutdown() throws Exception { - stopRequested = true; - future.get(); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiNativeServices.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiNativeServices.java deleted file mode 100644 index 662cfe6c..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiNativeServices.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - */ -public interface MpiNativeServices { - - void initMpi(int coresPerRank, boolean verbose); - - void terminateMpi(); - - String getMpiVersion(); - - int getMpiCommSize(); - - void sendCommonFile(byte[] message); - - void startTasks(List tasks); - - void checkTasksCompletion(List runningTasks, List completedTasks); - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiRank.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiRank.java deleted file mode 100644 index 6bd89d7c..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiRank.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.util.HashSet; -import java.util.Set; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MpiRank { - - final int num; - - final Set jobs = new HashSet<>(); - - MpiRank(int num) { - this.num = num; - } - - @Override - public String toString() { - return Integer.toString(num); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiResources.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiResources.java deleted file mode 100644 index e61536ba..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiResources.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.util.List; -import java.util.Set; -import java.util.concurrent.Semaphore; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MpiResources { - - private static final Logger LOGGER = LoggerFactory.getLogger(MpiResources.class); - - private final int availableCores; - private final Semaphore semaphore; - private final CorePool idleCores = new CorePool(); - - MpiResources(int communicatorSize, int coresPerRank) { - if (communicatorSize < 2) { - throw new IllegalArgumentException("MPI communicator size must be >= 2"); - } - if (coresPerRank < 1) { - throw new IllegalArgumentException("Cores per rank must be > 1"); - } - this.availableCores = (communicatorSize - 1) * coresPerRank; - semaphore = new Semaphore(availableCores, true); - // skip rank 0 which is the master - for (int i = 1; i < communicatorSize; i++) { - MpiRank rank = new MpiRank(i); - for (int thread = 0; thread < coresPerRank; thread++) { - idleCores.returnCore(new Core(rank, thread)); - } - } - LOGGER.info("Slaves: {}, coresPerSlave: {}, availableCores: {}", - communicatorSize - 1, coresPerRank, availableCores); - } - - List reserveAllCoresOrFail() { - if (semaphore.tryAcquire(availableCores)) { - List reservedCores = idleCores.borrowCores(availableCores); - LOGGER.debug("MPI cores {} reserved", reservedCores); - return reservedCores; - } else { - throw new RuntimeException("Fail to reserve all cores"); - } - } - - List reserveCores(int required, Set preferedRanks) throws InterruptedException { - int provided; - if (semaphore.tryAcquire(required)) { - provided = required; - } else { - // try to get all permits - int all = semaphore.drainPermits(); - if (all == 0) { - // not permits availables - return null; - } else { - if (all > required) { - // all is too many, release unnecessary ones - semaphore.release(all - required); - provided = required; - } else { - provided = all; - } - } - } - List reservedCores = idleCores.borrowCores(provided, preferedRanks); - LOGGER.debug("MPI cores {} reserved", reservedCores); - return reservedCores; - } - - void releaseCore(Core reservedCore) { - idleCores.returnCore(reservedCore); - semaphore.release(); - LOGGER.debug("MPI core {} released", reservedCore); - } - - void releaseCores(List reservedCores) { - idleCores.returnCores(reservedCores); - semaphore.release(reservedCores.size()); - LOGGER.debug("MPI cores {} released", reservedCores); - } - - int getAvailableCores() { - return availableCores; - } - - int getIdleCores() { - return semaphore.availablePermits(); - } - - int getBusyCores() { - return availableCores - semaphore.availablePermits(); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatistics.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatistics.java deleted file mode 100644 index e9fc8321..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatistics.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.io.Writer; -import java.util.List; -import java.util.Map; -import org.joda.time.DateTime; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface MpiStatistics extends AutoCloseable { - - /** - * Log a common file transfer. - * - * @param fileName the file name - * @param chunk chunk number - * @param size file size in bytes - * @param duration duration of the transfer in ms - */ - void logCommonFileTransfer(String fileName, int chunk, long size, long duration); - - /** - * Log a job start. - * - * @param jobId the job id - * @param commandId the command id - * @param tags tags associated to the job - */ - void logJobStart(int jobId, String commandId, Map tags); - - /** - * Log a job end. - * - * @param jobId the job id - */ - void logJobEnd(int jobId); - - /** - * Log a task start. - * - * @param taskId the task id - * @param jobId the job id - * @param taskIndex index of the task in the job - * @param startTime task start time - * @param slaveRank slave rank that has managed the task - * @param slaveThread slave thread that has managed the task - * @param inputMessageSize input message size in bytes - */ - void logTaskStart(int taskId, int jobId, int taskIndex, DateTime startTime, int slaveRank, int slaveThread, long inputMessageSize); - - /** - * Log a task end. - * - * @param taskId the task id - * @param taskDuration task duration in ms - * @param commandsDuration duration in ms of all commands of the task - * @param dataTransferDuration part of the task duration corresponding to data transfer in ms - * @param outputMessageSize output message size in bytes - * @param workingDataSize working data size in bytes on slave side - * @param exitCode exit code of the command - */ - void logTaskEnd(int taskId, long taskDuration, List commandsDuration, long dataTransferDuration, long outputMessageSize, long workingDataSize, int exitCode); - - /** - * Export tasks statistics to CSV. - * - * @param writer - */ - void exportTasksToCsv(Writer writer); - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatisticsFactory.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatisticsFactory.java deleted file mode 100644 index 25323195..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiStatisticsFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.nio.file.Path; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface MpiStatisticsFactory { - - MpiStatistics create(Path dbDir, String dbName) throws Exception; - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiTask.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiTask.java deleted file mode 100644 index 17ebeda2..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/MpiTask.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import org.joda.time.DateTime; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MpiTask { - - private final int id; - - private final Core core; - - private final int index; - - private final byte[] message; - - private final DateTime startTime; - - private DateTime endTime; - - private byte[] resultMessage; - - MpiTask(int id, Core core, int index, byte[] message, DateTime startTime) { - this.id = id; - this.core = core; - this.index = index; - this.message = message; - this.startTime = startTime; - } - - int getId() { - return id; - } - - Core getCore() { - return core; - } - - int getRank() { - return core.rank.num; - } - - int getThread() { - return core.thread; - } - - int getIndex() { - return index; - } - - byte[] getMessage() { - return message; - } - - DateTime getStartTime() { - return startTime; - } - - DateTime getEndTime() { - return endTime; - } - - void setEndTime(DateTime endTime) { - this.endTime = endTime; - } - - void setResultMessage(byte[] resultMessage) { - this.resultMessage = resultMessage; - } - - byte[] getResultMessage() { - return resultMessage; - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatistics.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatistics.java deleted file mode 100644 index 40eedae1..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatistics.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.io.Writer; -import java.util.List; -import java.util.Map; -import org.joda.time.DateTime; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class NoMpiStatistics implements MpiStatistics { - - @Override - public void logCommonFileTransfer(String fileName, int chunk, long size, long duration) { - } - - @Override - public void logJobStart(int jobId, String commandId, Map tags) { - } - - @Override - public void logJobEnd(int jobId) { - } - - @Override - public void logTaskStart(int taskId, int jobId, int taskIndex, DateTime startTime, int slaveRank, int slaveThread, long inputMessageSize) { - } - - @Override - public void logTaskEnd(int taskId, long taskDuration, List commandsDuration, long dataTransferDuration, long outputMessageSize, long workingDataSize, int exitCode) { - } - - @Override - public void exportTasksToCsv(Writer writer) { - } - - @Override - public void close() throws Exception { - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatisticsFactory.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatisticsFactory.java deleted file mode 100644 index 6e475805..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/NoMpiStatisticsFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.nio.file.Path; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class NoMpiStatisticsFactory implements MpiStatisticsFactory { - - @Override - public MpiStatistics create(Path dbDir, String dbName) throws Exception { - return new NoMpiStatistics(); - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ProfiledExecutionListener.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ProfiledExecutionListener.java deleted file mode 100644 index 78881d4f..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/ProfiledExecutionListener.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import eu.itesla_project.computation.ExecutionListener; -import eu.itesla_project.computation.ExecutionReport; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ProfiledExecutionListener implements ExecutionListener { - - private static final Logger LOGGER = LoggerFactory.getLogger(ProfiledExecutionListener.class); - - private static final int WARNING_THRESHOLD = 10; // ms - - private final ExecutionListener delegate; - - ProfiledExecutionListener(ExecutionListener delegate) { - this.delegate = delegate; - } - - @Override - public void onExecutionStart(int fromExecutionIndex, int toExecutionIndex) { - long start = System.currentTimeMillis(); - try { - delegate.onExecutionStart(fromExecutionIndex, toExecutionIndex); - } finally { - long end = System.currentTimeMillis(); - if (end - start > WARNING_THRESHOLD) { - LOGGER.warn("Slowness detected in ExecutionListener.onExecutionStart ({} ms)", end - start); - } - } - } - - @Override - public void onExecutionCompletion(int executionIndex) { - long start = System.currentTimeMillis(); - try { - delegate.onExecutionCompletion(executionIndex); - } finally { - long end = System.currentTimeMillis(); - if (end - start > WARNING_THRESHOLD) { - LOGGER.warn("Slowness detected in ExecutionListener.onExecutionCompletion ({} ms)", end - start); - } - } - } - - @Override - public void onEnd(ExecutionReport report) { - long start = System.currentTimeMillis(); - try { - delegate.onEnd(report); - } finally { - long end = System.currentTimeMillis(); - if (end - start > WARNING_THRESHOLD) { - LOGGER.warn("Slowness detected in ExecutionListener.onEnd ({} ms)", end - start); - } - } - } - -} diff --git a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/messages/Messages.java b/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/messages/Messages.java deleted file mode 100644 index d2005704..00000000 --- a/computation-mpi/src/main/java/eu/itesla_project/computation/mpi/messages/Messages.java +++ /dev/null @@ -1,8665 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: messages.proto - -package eu.itesla_project.computation.mpi.messages; - -public final class Messages { - private Messages() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - public interface CommonFileOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required string name = 1; - /** - * required string name = 1; - */ - boolean hasName(); - /** - * required string name = 1; - */ - java.lang.String getName(); - /** - * required string name = 1; - */ - com.google.protobuf.ByteString - getNameBytes(); - - // required int32 chunk = 2; - /** - * required int32 chunk = 2; - */ - boolean hasChunk(); - /** - * required int32 chunk = 2; - */ - int getChunk(); - - // required bool last = 3; - /** - * required bool last = 3; - */ - boolean hasLast(); - /** - * required bool last = 3; - */ - boolean getLast(); - - // required bytes data = 4; - /** - * required bytes data = 4; - */ - boolean hasData(); - /** - * required bytes data = 4; - */ - com.google.protobuf.ByteString getData(); - } - /** - * Protobuf type {@code messages.CommonFile} - */ - public static final class CommonFile extends - com.google.protobuf.GeneratedMessage - implements CommonFileOrBuilder { - // Use CommonFile.newBuilder() to construct. - private CommonFile(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private CommonFile(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final CommonFile defaultInstance; - public static CommonFile getDefaultInstance() { - return defaultInstance; - } - - public CommonFile getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private CommonFile( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - name_ = input.readBytes(); - break; - } - case 16: { - bitField0_ |= 0x00000002; - chunk_ = input.readInt32(); - break; - } - case 24: { - bitField0_ |= 0x00000004; - last_ = input.readBool(); - break; - } - case 34: { - bitField0_ |= 0x00000008; - data_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_CommonFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_CommonFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.CommonFile.class, eu.itesla_project.computation.mpi.messages.Messages.CommonFile.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public CommonFile parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new CommonFile(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // required string name = 1; - public static final int NAME_FIELD_NUMBER = 1; - private java.lang.Object name_; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // required int32 chunk = 2; - public static final int CHUNK_FIELD_NUMBER = 2; - private int chunk_; - /** - * required int32 chunk = 2; - */ - public boolean hasChunk() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required int32 chunk = 2; - */ - public int getChunk() { - return chunk_; - } - - // required bool last = 3; - public static final int LAST_FIELD_NUMBER = 3; - private boolean last_; - /** - * required bool last = 3; - */ - public boolean hasLast() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required bool last = 3; - */ - public boolean getLast() { - return last_; - } - - // required bytes data = 4; - public static final int DATA_FIELD_NUMBER = 4; - private com.google.protobuf.ByteString data_; - /** - * required bytes data = 4; - */ - public boolean hasData() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * required bytes data = 4; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - private void initFields() { - name_ = ""; - chunk_ = 0; - last_ = false; - data_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasName()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasChunk()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasLast()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasData()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt32(2, chunk_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBool(3, last_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(4, data_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, chunk_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(3, last_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, data_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.CommonFile parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.CommonFile prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.CommonFile} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.CommonFileOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_CommonFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_CommonFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.CommonFile.class, eu.itesla_project.computation.mpi.messages.Messages.CommonFile.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.CommonFile.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - name_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - chunk_ = 0; - bitField0_ = (bitField0_ & ~0x00000002); - last_ = false; - bitField0_ = (bitField0_ & ~0x00000004); - data_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000008); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_CommonFile_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.CommonFile getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.CommonFile.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.CommonFile build() { - eu.itesla_project.computation.mpi.messages.Messages.CommonFile result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.CommonFile buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.CommonFile result = new eu.itesla_project.computation.mpi.messages.Messages.CommonFile(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.name_ = name_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.chunk_ = chunk_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.last_ = last_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.data_ = data_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.CommonFile) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.CommonFile)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.CommonFile other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.CommonFile.getDefaultInstance()) return this; - if (other.hasName()) { - bitField0_ |= 0x00000001; - name_ = other.name_; - onChanged(); - } - if (other.hasChunk()) { - setChunk(other.getChunk()); - } - if (other.hasLast()) { - setLast(other.getLast()); - } - if (other.hasData()) { - setData(other.getData()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasName()) { - - return false; - } - if (!hasChunk()) { - - return false; - } - if (!hasLast()) { - - return false; - } - if (!hasData()) { - - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.CommonFile parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.CommonFile) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required string name = 1; - private java.lang.Object name_ = ""; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string name = 1; - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000001); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - - // required int32 chunk = 2; - private int chunk_ ; - /** - * required int32 chunk = 2; - */ - public boolean hasChunk() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required int32 chunk = 2; - */ - public int getChunk() { - return chunk_; - } - /** - * required int32 chunk = 2; - */ - public Builder setChunk(int value) { - bitField0_ |= 0x00000002; - chunk_ = value; - onChanged(); - return this; - } - /** - * required int32 chunk = 2; - */ - public Builder clearChunk() { - bitField0_ = (bitField0_ & ~0x00000002); - chunk_ = 0; - onChanged(); - return this; - } - - // required bool last = 3; - private boolean last_ ; - /** - * required bool last = 3; - */ - public boolean hasLast() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required bool last = 3; - */ - public boolean getLast() { - return last_; - } - /** - * required bool last = 3; - */ - public Builder setLast(boolean value) { - bitField0_ |= 0x00000004; - last_ = value; - onChanged(); - return this; - } - /** - * required bool last = 3; - */ - public Builder clearLast() { - bitField0_ = (bitField0_ & ~0x00000004); - last_ = false; - onChanged(); - return this; - } - - // required bytes data = 4; - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - /** - * required bytes data = 4; - */ - public boolean hasData() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * required bytes data = 4; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - /** - * required bytes data = 4; - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - data_ = value; - onChanged(); - return this; - } - /** - * required bytes data = 4; - */ - public Builder clearData() { - bitField0_ = (bitField0_ & ~0x00000008); - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:messages.CommonFile) - } - - static { - defaultInstance = new CommonFile(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.CommonFile) - } - - public interface TaskOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required int32 jobId = 1; - /** - * required int32 jobId = 1; - */ - boolean hasJobId(); - /** - * required int32 jobId = 1; - */ - int getJobId(); - - // required int32 index = 2; - /** - * required int32 index = 2; - */ - boolean hasIndex(); - /** - * required int32 index = 2; - */ - int getIndex(); - - // required .messages.Task.Environment env = 3; - /** - * required .messages.Task.Environment env = 3; - */ - boolean hasEnv(); - /** - * required .messages.Task.Environment env = 3; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment getEnv(); - /** - * required .messages.Task.Environment env = 3; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.EnvironmentOrBuilder getEnvOrBuilder(); - - // required string cmdId = 4; - /** - * required string cmdId = 4; - */ - boolean hasCmdId(); - /** - * required string cmdId = 4; - */ - java.lang.String getCmdId(); - /** - * required string cmdId = 4; - */ - com.google.protobuf.ByteString - getCmdIdBytes(); - - // repeated .messages.Task.Command command = 5; - /** - * repeated .messages.Task.Command command = 5; - */ - java.util.List - getCommandList(); - /** - * repeated .messages.Task.Command command = 5; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.Command getCommand(int index); - /** - * repeated .messages.Task.Command command = 5; - */ - int getCommandCount(); - /** - * repeated .messages.Task.Command command = 5; - */ - java.util.List - getCommandOrBuilderList(); - /** - * repeated .messages.Task.Command command = 5; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.CommandOrBuilder getCommandOrBuilder( - int index); - - // repeated .messages.Task.InputFile inputFile = 6; - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - java.util.List - getInputFileList(); - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile getInputFile(int index); - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - int getInputFileCount(); - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - java.util.List - getInputFileOrBuilderList(); - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFileOrBuilder getInputFileOrBuilder( - int index); - - // repeated .messages.Task.OutputFile outputFile = 7; - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - java.util.List - getOutputFileList(); - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile getOutputFile(int index); - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - int getOutputFileCount(); - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - java.util.List - getOutputFileOrBuilderList(); - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFileOrBuilder getOutputFileOrBuilder( - int index); - - // required bool initJob = 8; - /** - * required bool initJob = 8; - */ - boolean hasInitJob(); - /** - * required bool initJob = 8; - */ - boolean getInitJob(); - - // repeated int32 completedJobId = 9; - /** - * repeated int32 completedJobId = 9; - * - *
-     * for cleanup
-     * 
- */ - java.util.List getCompletedJobIdList(); - /** - * repeated int32 completedJobId = 9; - * - *
-     * for cleanup
-     * 
- */ - int getCompletedJobIdCount(); - /** - * repeated int32 completedJobId = 9; - * - *
-     * for cleanup
-     * 
- */ - int getCompletedJobId(int index); - } - /** - * Protobuf type {@code messages.Task} - */ - public static final class Task extends - com.google.protobuf.GeneratedMessage - implements TaskOrBuilder { - // Use Task.newBuilder() to construct. - private Task(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Task(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Task defaultInstance; - public static Task getDefaultInstance() { - return defaultInstance; - } - - public Task getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Task( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - jobId_ = input.readInt32(); - break; - } - case 16: { - bitField0_ |= 0x00000002; - index_ = input.readInt32(); - break; - } - case 26: { - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder subBuilder = null; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - subBuilder = env_.toBuilder(); - } - env_ = input.readMessage(eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(env_); - env_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000004; - break; - } - case 34: { - bitField0_ |= 0x00000008; - cmdId_ = input.readBytes(); - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - command_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - command_.add(input.readMessage(eu.itesla_project.computation.mpi.messages.Messages.Task.Command.PARSER, extensionRegistry)); - break; - } - case 50: { - if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - inputFile_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000020; - } - inputFile_.add(input.readMessage(eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PARSER, extensionRegistry)); - break; - } - case 58: { - if (!((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - outputFile_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000040; - } - outputFile_.add(input.readMessage(eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PARSER, extensionRegistry)); - break; - } - case 64: { - bitField0_ |= 0x00000010; - initJob_ = input.readBool(); - break; - } - case 72: { - if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) { - completedJobId_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000100; - } - completedJobId_.add(input.readInt32()); - break; - } - case 74: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000100) == 0x00000100) && input.getBytesUntilLimit() > 0) { - completedJobId_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000100; - } - while (input.getBytesUntilLimit() > 0) { - completedJobId_.add(input.readInt32()); - } - input.popLimit(limit); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - command_ = java.util.Collections.unmodifiableList(command_); - } - if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) { - inputFile_ = java.util.Collections.unmodifiableList(inputFile_); - } - if (((mutable_bitField0_ & 0x00000040) == 0x00000040)) { - outputFile_ = java.util.Collections.unmodifiableList(outputFile_); - } - if (((mutable_bitField0_ & 0x00000100) == 0x00000100)) { - completedJobId_ = java.util.Collections.unmodifiableList(completedJobId_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Task parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Task(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public interface InputFileOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required string name = 1; - /** - * required string name = 1; - */ - boolean hasName(); - /** - * required string name = 1; - */ - java.lang.String getName(); - /** - * required string name = 1; - */ - com.google.protobuf.ByteString - getNameBytes(); - - // required .messages.Task.InputFile.Scope scope = 2; - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - boolean hasScope(); - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope getScope(); - - // optional bytes data = 3; - /** - * optional bytes data = 3; - */ - boolean hasData(); - /** - * optional bytes data = 3; - */ - com.google.protobuf.ByteString getData(); - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - boolean hasPreProcessor(); - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor getPreProcessor(); - } - /** - * Protobuf type {@code messages.Task.InputFile} - */ - public static final class InputFile extends - com.google.protobuf.GeneratedMessage - implements InputFileOrBuilder { - // Use InputFile.newBuilder() to construct. - private InputFile(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private InputFile(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final InputFile defaultInstance; - public static InputFile getDefaultInstance() { - return defaultInstance; - } - - public InputFile getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private InputFile( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - name_ = input.readBytes(); - break; - } - case 16: { - int rawValue = input.readEnum(); - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope value = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(2, rawValue); - } else { - bitField0_ |= 0x00000002; - scope_ = value; - } - break; - } - case 26: { - bitField0_ |= 0x00000004; - data_ = input.readBytes(); - break; - } - case 32: { - int rawValue = input.readEnum(); - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor value = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(4, rawValue); - } else { - bitField0_ |= 0x00000008; - preProcessor_ = value; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_InputFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_InputFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.class, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public InputFile parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new InputFile(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - /** - * Protobuf enum {@code messages.Task.InputFile.PreProcessor} - */ - public enum PreProcessor - implements com.google.protobuf.ProtocolMessageEnum { - /** - * NONE = 1; - */ - NONE(0, 1), - /** - * ARCHIVE_UNZIP = 2; - */ - ARCHIVE_UNZIP(1, 2), - /** - * FILE_GUNZIP = 3; - */ - FILE_GUNZIP(2, 3), - ; - - /** - * NONE = 1; - */ - public static final int NONE_VALUE = 1; - /** - * ARCHIVE_UNZIP = 2; - */ - public static final int ARCHIVE_UNZIP_VALUE = 2; - /** - * FILE_GUNZIP = 3; - */ - public static final int FILE_GUNZIP_VALUE = 3; - - - public final int getNumber() { return value; } - - public static PreProcessor valueOf(int value) { - switch (value) { - case 1: return NONE; - case 2: return ARCHIVE_UNZIP; - case 3: return FILE_GUNZIP; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public PreProcessor findValueByNumber(int number) { - return PreProcessor.valueOf(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.getDescriptor().getEnumTypes().get(0); - } - - private static final PreProcessor[] VALUES = values(); - - public static PreProcessor valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private PreProcessor(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:messages.Task.InputFile.PreProcessor) - } - - /** - * Protobuf enum {@code messages.Task.InputFile.Scope} - */ - public enum Scope - implements com.google.protobuf.ProtocolMessageEnum { - /** - * RUN = 1; - */ - RUN(0, 1), - /** - * JOB = 2; - */ - JOB(1, 2), - /** - * TASK = 3; - */ - TASK(2, 3), - ; - - /** - * RUN = 1; - */ - public static final int RUN_VALUE = 1; - /** - * JOB = 2; - */ - public static final int JOB_VALUE = 2; - /** - * TASK = 3; - */ - public static final int TASK_VALUE = 3; - - - public final int getNumber() { return value; } - - public static Scope valueOf(int value) { - switch (value) { - case 1: return RUN; - case 2: return JOB; - case 3: return TASK; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public Scope findValueByNumber(int number) { - return Scope.valueOf(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.getDescriptor().getEnumTypes().get(1); - } - - private static final Scope[] VALUES = values(); - - public static Scope valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private Scope(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:messages.Task.InputFile.Scope) - } - - private int bitField0_; - // required string name = 1; - public static final int NAME_FIELD_NUMBER = 1; - private java.lang.Object name_; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // required .messages.Task.InputFile.Scope scope = 2; - public static final int SCOPE_FIELD_NUMBER = 2; - private eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope scope_; - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - public boolean hasScope() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope getScope() { - return scope_; - } - - // optional bytes data = 3; - public static final int DATA_FIELD_NUMBER = 3; - private com.google.protobuf.ByteString data_; - /** - * optional bytes data = 3; - */ - public boolean hasData() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes data = 3; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - public static final int PREPROCESSOR_FIELD_NUMBER = 4; - private eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor preProcessor_; - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - public boolean hasPreProcessor() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor getPreProcessor() { - return preProcessor_; - } - - private void initFields() { - name_ = ""; - scope_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope.RUN; - data_ = com.google.protobuf.ByteString.EMPTY; - preProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor.NONE; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasName()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasScope()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasPreProcessor()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeEnum(2, scope_.getNumber()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeBytes(3, data_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeEnum(4, preProcessor_.getNumber()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(2, scope_.getNumber()); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(3, data_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(4, preProcessor_.getNumber()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.Task.InputFile} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.Task.InputFileOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_InputFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_InputFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.class, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - name_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - scope_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope.RUN; - bitField0_ = (bitField0_ & ~0x00000002); - data_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000004); - preProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor.NONE; - bitField0_ = (bitField0_ & ~0x00000008); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_InputFile_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile build() { - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile result = new eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.name_ = name_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.scope_ = scope_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.data_ = data_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.preProcessor_ = preProcessor_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.getDefaultInstance()) return this; - if (other.hasName()) { - bitField0_ |= 0x00000001; - name_ = other.name_; - onChanged(); - } - if (other.hasScope()) { - setScope(other.getScope()); - } - if (other.hasData()) { - setData(other.getData()); - } - if (other.hasPreProcessor()) { - setPreProcessor(other.getPreProcessor()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasName()) { - - return false; - } - if (!hasScope()) { - - return false; - } - if (!hasPreProcessor()) { - - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required string name = 1; - private java.lang.Object name_ = ""; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string name = 1; - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000001); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - - // required .messages.Task.InputFile.Scope scope = 2; - private eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope scope_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope.RUN; - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - public boolean hasScope() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope getScope() { - return scope_; - } - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - public Builder setScope(eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - scope_ = value; - onChanged(); - return this; - } - /** - * required .messages.Task.InputFile.Scope scope = 2; - */ - public Builder clearScope() { - bitField0_ = (bitField0_ & ~0x00000002); - scope_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Scope.RUN; - onChanged(); - return this; - } - - // optional bytes data = 3; - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes data = 3; - */ - public boolean hasData() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional bytes data = 3; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - /** - * optional bytes data = 3; - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000004; - data_ = value; - onChanged(); - return this; - } - /** - * optional bytes data = 3; - */ - public Builder clearData() { - bitField0_ = (bitField0_ & ~0x00000004); - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - private eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor preProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor.NONE; - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - public boolean hasPreProcessor() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor getPreProcessor() { - return preProcessor_; - } - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - public Builder setPreProcessor(eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - preProcessor_ = value; - onChanged(); - return this; - } - /** - * required .messages.Task.InputFile.PreProcessor preProcessor = 4; - */ - public Builder clearPreProcessor() { - bitField0_ = (bitField0_ & ~0x00000008); - preProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.PreProcessor.NONE; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:messages.Task.InputFile) - } - - static { - defaultInstance = new InputFile(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.Task.InputFile) - } - - public interface OutputFileOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required string name = 1; - /** - * required string name = 1; - */ - boolean hasName(); - /** - * required string name = 1; - */ - java.lang.String getName(); - /** - * required string name = 1; - */ - com.google.protobuf.ByteString - getNameBytes(); - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - boolean hasPostProcessor(); - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor getPostProcessor(); - } - /** - * Protobuf type {@code messages.Task.OutputFile} - */ - public static final class OutputFile extends - com.google.protobuf.GeneratedMessage - implements OutputFileOrBuilder { - // Use OutputFile.newBuilder() to construct. - private OutputFile(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private OutputFile(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final OutputFile defaultInstance; - public static OutputFile getDefaultInstance() { - return defaultInstance; - } - - public OutputFile getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private OutputFile( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - name_ = input.readBytes(); - break; - } - case 16: { - int rawValue = input.readEnum(); - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor value = eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(2, rawValue); - } else { - bitField0_ |= 0x00000002; - postProcessor_ = value; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_OutputFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_OutputFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.class, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public OutputFile parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new OutputFile(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - /** - * Protobuf enum {@code messages.Task.OutputFile.PostProcessor} - */ - public enum PostProcessor - implements com.google.protobuf.ProtocolMessageEnum { - /** - * NONE = 1; - */ - NONE(0, 1), - /** - * FILE_GZIP = 2; - */ - FILE_GZIP(1, 2), - ; - - /** - * NONE = 1; - */ - public static final int NONE_VALUE = 1; - /** - * FILE_GZIP = 2; - */ - public static final int FILE_GZIP_VALUE = 2; - - - public final int getNumber() { return value; } - - public static PostProcessor valueOf(int value) { - switch (value) { - case 1: return NONE; - case 2: return FILE_GZIP; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static com.google.protobuf.Internal.EnumLiteMap - internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public PostProcessor findValueByNumber(int number) { - return PostProcessor.valueOf(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(index); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.getDescriptor().getEnumTypes().get(0); - } - - private static final PostProcessor[] VALUES = values(); - - public static PostProcessor valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - private final int index; - private final int value; - - private PostProcessor(int index, int value) { - this.index = index; - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:messages.Task.OutputFile.PostProcessor) - } - - private int bitField0_; - // required string name = 1; - public static final int NAME_FIELD_NUMBER = 1; - private java.lang.Object name_; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - public static final int POSTPROCESSOR_FIELD_NUMBER = 2; - private eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor postProcessor_; - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - public boolean hasPostProcessor() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor getPostProcessor() { - return postProcessor_; - } - - private void initFields() { - name_ = ""; - postProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor.NONE; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasName()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasPostProcessor()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeEnum(2, postProcessor_.getNumber()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(2, postProcessor_.getNumber()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.Task.OutputFile} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFileOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_OutputFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_OutputFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.class, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - name_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - postProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor.NONE; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_OutputFile_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile build() { - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile result = new eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.name_ = name_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.postProcessor_ = postProcessor_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.getDefaultInstance()) return this; - if (other.hasName()) { - bitField0_ |= 0x00000001; - name_ = other.name_; - onChanged(); - } - if (other.hasPostProcessor()) { - setPostProcessor(other.getPostProcessor()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasName()) { - - return false; - } - if (!hasPostProcessor()) { - - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required string name = 1; - private java.lang.Object name_ = ""; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string name = 1; - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000001); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - private eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor postProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor.NONE; - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - public boolean hasPostProcessor() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor getPostProcessor() { - return postProcessor_; - } - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - public Builder setPostProcessor(eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - postProcessor_ = value; - onChanged(); - return this; - } - /** - * required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - */ - public Builder clearPostProcessor() { - bitField0_ = (bitField0_ & ~0x00000002); - postProcessor_ = eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.PostProcessor.NONE; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:messages.Task.OutputFile) - } - - static { - defaultInstance = new OutputFile(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.Task.OutputFile) - } - - public interface VariableOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required string name = 1; - /** - * required string name = 1; - */ - boolean hasName(); - /** - * required string name = 1; - */ - java.lang.String getName(); - /** - * required string name = 1; - */ - com.google.protobuf.ByteString - getNameBytes(); - - // required string value = 2; - /** - * required string value = 2; - */ - boolean hasValue(); - /** - * required string value = 2; - */ - java.lang.String getValue(); - /** - * required string value = 2; - */ - com.google.protobuf.ByteString - getValueBytes(); - } - /** - * Protobuf type {@code messages.Task.Variable} - */ - public static final class Variable extends - com.google.protobuf.GeneratedMessage - implements VariableOrBuilder { - // Use Variable.newBuilder() to construct. - private Variable(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Variable(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Variable defaultInstance; - public static Variable getDefaultInstance() { - return defaultInstance; - } - - public Variable getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Variable( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - name_ = input.readBytes(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - value_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Variable_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Variable_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Variable parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Variable(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // required string name = 1; - public static final int NAME_FIELD_NUMBER = 1; - private java.lang.Object name_; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // required string value = 2; - public static final int VALUE_FIELD_NUMBER = 2; - private java.lang.Object value_; - /** - * required string value = 2; - */ - public boolean hasValue() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required string value = 2; - */ - public java.lang.String getValue() { - java.lang.Object ref = value_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - value_ = s; - } - return s; - } - } - /** - * required string value = 2; - */ - public com.google.protobuf.ByteString - getValueBytes() { - java.lang.Object ref = value_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - value_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - private void initFields() { - name_ = ""; - value_ = ""; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasName()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasValue()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, getValueBytes()); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, getValueBytes()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.Task.Variable prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.Task.Variable} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.Task.VariableOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Variable_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Variable_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - name_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - value_ = ""; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Variable_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable build() { - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable result = new eu.itesla_project.computation.mpi.messages.Messages.Task.Variable(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.name_ = name_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.value_ = value_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.Task.Variable) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.Task.Variable)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.Task.Variable other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.getDefaultInstance()) return this; - if (other.hasName()) { - bitField0_ |= 0x00000001; - name_ = other.name_; - onChanged(); - } - if (other.hasValue()) { - bitField0_ |= 0x00000002; - value_ = other.value_; - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasName()) { - - return false; - } - if (!hasValue()) { - - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.Task.Variable) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required string name = 1; - private java.lang.Object name_ = ""; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string name = 1; - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000001); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - - // required string value = 2; - private java.lang.Object value_ = ""; - /** - * required string value = 2; - */ - public boolean hasValue() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required string value = 2; - */ - public java.lang.String getValue() { - java.lang.Object ref = value_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - value_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string value = 2; - */ - public com.google.protobuf.ByteString - getValueBytes() { - java.lang.Object ref = value_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - value_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string value = 2; - */ - public Builder setValue( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - value_ = value; - onChanged(); - return this; - } - /** - * required string value = 2; - */ - public Builder clearValue() { - bitField0_ = (bitField0_ & ~0x00000002); - value_ = getDefaultInstance().getValue(); - onChanged(); - return this; - } - /** - * required string value = 2; - */ - public Builder setValueBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - value_ = value; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:messages.Task.Variable) - } - - static { - defaultInstance = new Variable(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.Task.Variable) - } - - public interface EnvironmentOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // repeated .messages.Task.Variable variable = 1; - /** - * repeated .messages.Task.Variable variable = 1; - */ - java.util.List - getVariableList(); - /** - * repeated .messages.Task.Variable variable = 1; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable getVariable(int index); - /** - * repeated .messages.Task.Variable variable = 1; - */ - int getVariableCount(); - /** - * repeated .messages.Task.Variable variable = 1; - */ - java.util.List - getVariableOrBuilderList(); - /** - * repeated .messages.Task.Variable variable = 1; - */ - eu.itesla_project.computation.mpi.messages.Messages.Task.VariableOrBuilder getVariableOrBuilder( - int index); - } - /** - * Protobuf type {@code messages.Task.Environment} - */ - public static final class Environment extends - com.google.protobuf.GeneratedMessage - implements EnvironmentOrBuilder { - // Use Environment.newBuilder() to construct. - private Environment(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Environment(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Environment defaultInstance; - public static Environment getDefaultInstance() { - return defaultInstance; - } - - public Environment getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Environment( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - variable_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000001; - } - variable_.add(input.readMessage(eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.PARSER, extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { - variable_ = java.util.Collections.unmodifiableList(variable_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Environment_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Environment_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Environment parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Environment(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - // repeated .messages.Task.Variable variable = 1; - public static final int VARIABLE_FIELD_NUMBER = 1; - private java.util.List variable_; - /** - * repeated .messages.Task.Variable variable = 1; - */ - public java.util.List getVariableList() { - return variable_; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public java.util.List - getVariableOrBuilderList() { - return variable_; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public int getVariableCount() { - return variable_.size(); - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable getVariable(int index) { - return variable_.get(index); - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.VariableOrBuilder getVariableOrBuilder( - int index) { - return variable_.get(index); - } - - private void initFields() { - variable_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - for (int i = 0; i < getVariableCount(); i++) { - if (!getVariable(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - for (int i = 0; i < variable_.size(); i++) { - output.writeMessage(1, variable_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - for (int i = 0; i < variable_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(1, variable_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.Task.Environment prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.Task.Environment} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.Task.EnvironmentOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Environment_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Environment_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getVariableFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - if (variableBuilder_ == null) { - variable_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - } else { - variableBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Environment_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Environment getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Environment build() { - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Environment buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment result = new eu.itesla_project.computation.mpi.messages.Messages.Task.Environment(this); - int from_bitField0_ = bitField0_; - if (variableBuilder_ == null) { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - variable_ = java.util.Collections.unmodifiableList(variable_); - bitField0_ = (bitField0_ & ~0x00000001); - } - result.variable_ = variable_; - } else { - result.variable_ = variableBuilder_.build(); - } - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.Task.Environment) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.Task.Environment)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.Task.Environment other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.getDefaultInstance()) return this; - if (variableBuilder_ == null) { - if (!other.variable_.isEmpty()) { - if (variable_.isEmpty()) { - variable_ = other.variable_; - bitField0_ = (bitField0_ & ~0x00000001); - } else { - ensureVariableIsMutable(); - variable_.addAll(other.variable_); - } - onChanged(); - } - } else { - if (!other.variable_.isEmpty()) { - if (variableBuilder_.isEmpty()) { - variableBuilder_.dispose(); - variableBuilder_ = null; - variable_ = other.variable_; - bitField0_ = (bitField0_ & ~0x00000001); - variableBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getVariableFieldBuilder() : null; - } else { - variableBuilder_.addAllMessages(other.variable_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - for (int i = 0; i < getVariableCount(); i++) { - if (!getVariable(i).isInitialized()) { - - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.Task.Environment) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // repeated .messages.Task.Variable variable = 1; - private java.util.List variable_ = - java.util.Collections.emptyList(); - private void ensureVariableIsMutable() { - if (!((bitField0_ & 0x00000001) == 0x00000001)) { - variable_ = new java.util.ArrayList(variable_); - bitField0_ |= 0x00000001; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.VariableOrBuilder> variableBuilder_; - - /** - * repeated .messages.Task.Variable variable = 1; - */ - public java.util.List getVariableList() { - if (variableBuilder_ == null) { - return java.util.Collections.unmodifiableList(variable_); - } else { - return variableBuilder_.getMessageList(); - } - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public int getVariableCount() { - if (variableBuilder_ == null) { - return variable_.size(); - } else { - return variableBuilder_.getCount(); - } - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable getVariable(int index) { - if (variableBuilder_ == null) { - return variable_.get(index); - } else { - return variableBuilder_.getMessage(index); - } - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder setVariable( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable value) { - if (variableBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureVariableIsMutable(); - variable_.set(index, value); - onChanged(); - } else { - variableBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder setVariable( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder builderForValue) { - if (variableBuilder_ == null) { - ensureVariableIsMutable(); - variable_.set(index, builderForValue.build()); - onChanged(); - } else { - variableBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder addVariable(eu.itesla_project.computation.mpi.messages.Messages.Task.Variable value) { - if (variableBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureVariableIsMutable(); - variable_.add(value); - onChanged(); - } else { - variableBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder addVariable( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable value) { - if (variableBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureVariableIsMutable(); - variable_.add(index, value); - onChanged(); - } else { - variableBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder addVariable( - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder builderForValue) { - if (variableBuilder_ == null) { - ensureVariableIsMutable(); - variable_.add(builderForValue.build()); - onChanged(); - } else { - variableBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder addVariable( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder builderForValue) { - if (variableBuilder_ == null) { - ensureVariableIsMutable(); - variable_.add(index, builderForValue.build()); - onChanged(); - } else { - variableBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder addAllVariable( - java.lang.Iterable values) { - if (variableBuilder_ == null) { - ensureVariableIsMutable(); - super.addAll(values, variable_); - onChanged(); - } else { - variableBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder clearVariable() { - if (variableBuilder_ == null) { - variable_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000001); - onChanged(); - } else { - variableBuilder_.clear(); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public Builder removeVariable(int index) { - if (variableBuilder_ == null) { - ensureVariableIsMutable(); - variable_.remove(index); - onChanged(); - } else { - variableBuilder_.remove(index); - } - return this; - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder getVariableBuilder( - int index) { - return getVariableFieldBuilder().getBuilder(index); - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.VariableOrBuilder getVariableOrBuilder( - int index) { - if (variableBuilder_ == null) { - return variable_.get(index); } else { - return variableBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public java.util.List - getVariableOrBuilderList() { - if (variableBuilder_ != null) { - return variableBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(variable_); - } - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder addVariableBuilder() { - return getVariableFieldBuilder().addBuilder( - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.getDefaultInstance()); - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder addVariableBuilder( - int index) { - return getVariableFieldBuilder().addBuilder( - index, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.getDefaultInstance()); - } - /** - * repeated .messages.Task.Variable variable = 1; - */ - public java.util.List - getVariableBuilderList() { - return getVariableFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.VariableOrBuilder> - getVariableFieldBuilder() { - if (variableBuilder_ == null) { - variableBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Variable, eu.itesla_project.computation.mpi.messages.Messages.Task.Variable.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.VariableOrBuilder>( - variable_, - ((bitField0_ & 0x00000001) == 0x00000001), - getParentForChildren(), - isClean()); - variable_ = null; - } - return variableBuilder_; - } - - // @@protoc_insertion_point(builder_scope:messages.Task.Environment) - } - - static { - defaultInstance = new Environment(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.Task.Environment) - } - - public interface CommandOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required string program = 1; - /** - * required string program = 1; - */ - boolean hasProgram(); - /** - * required string program = 1; - */ - java.lang.String getProgram(); - /** - * required string program = 1; - */ - com.google.protobuf.ByteString - getProgramBytes(); - - // repeated string argument = 2; - /** - * repeated string argument = 2; - */ - java.util.List - getArgumentList(); - /** - * repeated string argument = 2; - */ - int getArgumentCount(); - /** - * repeated string argument = 2; - */ - java.lang.String getArgument(int index); - /** - * repeated string argument = 2; - */ - com.google.protobuf.ByteString - getArgumentBytes(int index); - - // optional int32 timeout = 3; - /** - * optional int32 timeout = 3; - */ - boolean hasTimeout(); - /** - * optional int32 timeout = 3; - */ - int getTimeout(); - } - /** - * Protobuf type {@code messages.Task.Command} - */ - public static final class Command extends - com.google.protobuf.GeneratedMessage - implements CommandOrBuilder { - // Use Command.newBuilder() to construct. - private Command(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private Command(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final Command defaultInstance; - public static Command getDefaultInstance() { - return defaultInstance; - } - - public Command getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Command( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - program_ = input.readBytes(); - break; - } - case 18: { - if (!((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - argument_ = new com.google.protobuf.LazyStringArrayList(); - mutable_bitField0_ |= 0x00000002; - } - argument_.add(input.readBytes()); - break; - } - case 24: { - bitField0_ |= 0x00000002; - timeout_ = input.readInt32(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000002) == 0x00000002)) { - argument_ = new com.google.protobuf.UnmodifiableLazyStringList(argument_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Command_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Command_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.Command.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public Command parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Command(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // required string program = 1; - public static final int PROGRAM_FIELD_NUMBER = 1; - private java.lang.Object program_; - /** - * required string program = 1; - */ - public boolean hasProgram() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string program = 1; - */ - public java.lang.String getProgram() { - java.lang.Object ref = program_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - program_ = s; - } - return s; - } - } - /** - * required string program = 1; - */ - public com.google.protobuf.ByteString - getProgramBytes() { - java.lang.Object ref = program_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - program_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // repeated string argument = 2; - public static final int ARGUMENT_FIELD_NUMBER = 2; - private com.google.protobuf.LazyStringList argument_; - /** - * repeated string argument = 2; - */ - public java.util.List - getArgumentList() { - return argument_; - } - /** - * repeated string argument = 2; - */ - public int getArgumentCount() { - return argument_.size(); - } - /** - * repeated string argument = 2; - */ - public java.lang.String getArgument(int index) { - return argument_.get(index); - } - /** - * repeated string argument = 2; - */ - public com.google.protobuf.ByteString - getArgumentBytes(int index) { - return argument_.getByteString(index); - } - - // optional int32 timeout = 3; - public static final int TIMEOUT_FIELD_NUMBER = 3; - private int timeout_; - /** - * optional int32 timeout = 3; - */ - public boolean hasTimeout() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional int32 timeout = 3; - */ - public int getTimeout() { - return timeout_; - } - - private void initFields() { - program_ = ""; - argument_ = com.google.protobuf.LazyStringArrayList.EMPTY; - timeout_ = 0; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasProgram()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getProgramBytes()); - } - for (int i = 0; i < argument_.size(); i++) { - output.writeBytes(2, argument_.getByteString(i)); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt32(3, timeout_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getProgramBytes()); - } - { - int dataSize = 0; - for (int i = 0; i < argument_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeBytesSizeNoTag(argument_.getByteString(i)); - } - size += dataSize; - size += 1 * getArgumentList().size(); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, timeout_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task.Command parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.Task.Command prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.Task.Command} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.Task.CommandOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Command_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Command_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.Command.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.Task.Command.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - program_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - argument_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - timeout_ = 0; - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_Command_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.Command.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command build() { - eu.itesla_project.computation.mpi.messages.Messages.Task.Command result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.Task.Command result = new eu.itesla_project.computation.mpi.messages.Messages.Task.Command(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.program_ = program_; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - argument_ = new com.google.protobuf.UnmodifiableLazyStringList( - argument_); - bitField0_ = (bitField0_ & ~0x00000002); - } - result.argument_ = argument_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000002; - } - result.timeout_ = timeout_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.Task.Command) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.Task.Command)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.Task.Command other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.Task.Command.getDefaultInstance()) return this; - if (other.hasProgram()) { - bitField0_ |= 0x00000001; - program_ = other.program_; - onChanged(); - } - if (!other.argument_.isEmpty()) { - if (argument_.isEmpty()) { - argument_ = other.argument_; - bitField0_ = (bitField0_ & ~0x00000002); - } else { - ensureArgumentIsMutable(); - argument_.addAll(other.argument_); - } - onChanged(); - } - if (other.hasTimeout()) { - setTimeout(other.getTimeout()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasProgram()) { - - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.Task.Command parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.Task.Command) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required string program = 1; - private java.lang.Object program_ = ""; - /** - * required string program = 1; - */ - public boolean hasProgram() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string program = 1; - */ - public java.lang.String getProgram() { - java.lang.Object ref = program_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - program_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string program = 1; - */ - public com.google.protobuf.ByteString - getProgramBytes() { - java.lang.Object ref = program_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - program_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string program = 1; - */ - public Builder setProgram( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - program_ = value; - onChanged(); - return this; - } - /** - * required string program = 1; - */ - public Builder clearProgram() { - bitField0_ = (bitField0_ & ~0x00000001); - program_ = getDefaultInstance().getProgram(); - onChanged(); - return this; - } - /** - * required string program = 1; - */ - public Builder setProgramBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - program_ = value; - onChanged(); - return this; - } - - // repeated string argument = 2; - private com.google.protobuf.LazyStringList argument_ = com.google.protobuf.LazyStringArrayList.EMPTY; - private void ensureArgumentIsMutable() { - if (!((bitField0_ & 0x00000002) == 0x00000002)) { - argument_ = new com.google.protobuf.LazyStringArrayList(argument_); - bitField0_ |= 0x00000002; - } - } - /** - * repeated string argument = 2; - */ - public java.util.List - getArgumentList() { - return java.util.Collections.unmodifiableList(argument_); - } - /** - * repeated string argument = 2; - */ - public int getArgumentCount() { - return argument_.size(); - } - /** - * repeated string argument = 2; - */ - public java.lang.String getArgument(int index) { - return argument_.get(index); - } - /** - * repeated string argument = 2; - */ - public com.google.protobuf.ByteString - getArgumentBytes(int index) { - return argument_.getByteString(index); - } - /** - * repeated string argument = 2; - */ - public Builder setArgument( - int index, java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureArgumentIsMutable(); - argument_.set(index, value); - onChanged(); - return this; - } - /** - * repeated string argument = 2; - */ - public Builder addArgument( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - ensureArgumentIsMutable(); - argument_.add(value); - onChanged(); - return this; - } - /** - * repeated string argument = 2; - */ - public Builder addAllArgument( - java.lang.Iterable values) { - ensureArgumentIsMutable(); - super.addAll(values, argument_); - onChanged(); - return this; - } - /** - * repeated string argument = 2; - */ - public Builder clearArgument() { - argument_ = com.google.protobuf.LazyStringArrayList.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; - } - /** - * repeated string argument = 2; - */ - public Builder addArgumentBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - ensureArgumentIsMutable(); - argument_.add(value); - onChanged(); - return this; - } - - // optional int32 timeout = 3; - private int timeout_ ; - /** - * optional int32 timeout = 3; - */ - public boolean hasTimeout() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * optional int32 timeout = 3; - */ - public int getTimeout() { - return timeout_; - } - /** - * optional int32 timeout = 3; - */ - public Builder setTimeout(int value) { - bitField0_ |= 0x00000004; - timeout_ = value; - onChanged(); - return this; - } - /** - * optional int32 timeout = 3; - */ - public Builder clearTimeout() { - bitField0_ = (bitField0_ & ~0x00000004); - timeout_ = 0; - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:messages.Task.Command) - } - - static { - defaultInstance = new Command(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.Task.Command) - } - - private int bitField0_; - // required int32 jobId = 1; - public static final int JOBID_FIELD_NUMBER = 1; - private int jobId_; - /** - * required int32 jobId = 1; - */ - public boolean hasJobId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int32 jobId = 1; - */ - public int getJobId() { - return jobId_; - } - - // required int32 index = 2; - public static final int INDEX_FIELD_NUMBER = 2; - private int index_; - /** - * required int32 index = 2; - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required int32 index = 2; - */ - public int getIndex() { - return index_; - } - - // required .messages.Task.Environment env = 3; - public static final int ENV_FIELD_NUMBER = 3; - private eu.itesla_project.computation.mpi.messages.Messages.Task.Environment env_; - /** - * required .messages.Task.Environment env = 3; - */ - public boolean hasEnv() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required .messages.Task.Environment env = 3; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Environment getEnv() { - return env_; - } - /** - * required .messages.Task.Environment env = 3; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.EnvironmentOrBuilder getEnvOrBuilder() { - return env_; - } - - // required string cmdId = 4; - public static final int CMDID_FIELD_NUMBER = 4; - private java.lang.Object cmdId_; - /** - * required string cmdId = 4; - */ - public boolean hasCmdId() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * required string cmdId = 4; - */ - public java.lang.String getCmdId() { - java.lang.Object ref = cmdId_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - cmdId_ = s; - } - return s; - } - } - /** - * required string cmdId = 4; - */ - public com.google.protobuf.ByteString - getCmdIdBytes() { - java.lang.Object ref = cmdId_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - cmdId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // repeated .messages.Task.Command command = 5; - public static final int COMMAND_FIELD_NUMBER = 5; - private java.util.List command_; - /** - * repeated .messages.Task.Command command = 5; - */ - public java.util.List getCommandList() { - return command_; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public java.util.List - getCommandOrBuilderList() { - return command_; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public int getCommandCount() { - return command_.size(); - } - /** - * repeated .messages.Task.Command command = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command getCommand(int index) { - return command_.get(index); - } - /** - * repeated .messages.Task.Command command = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.CommandOrBuilder getCommandOrBuilder( - int index) { - return command_.get(index); - } - - // repeated .messages.Task.InputFile inputFile = 6; - public static final int INPUTFILE_FIELD_NUMBER = 6; - private java.util.List inputFile_; - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public java.util.List getInputFileList() { - return inputFile_; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public java.util.List - getInputFileOrBuilderList() { - return inputFile_; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public int getInputFileCount() { - return inputFile_.size(); - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile getInputFile(int index) { - return inputFile_.get(index); - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFileOrBuilder getInputFileOrBuilder( - int index) { - return inputFile_.get(index); - } - - // repeated .messages.Task.OutputFile outputFile = 7; - public static final int OUTPUTFILE_FIELD_NUMBER = 7; - private java.util.List outputFile_; - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public java.util.List getOutputFileList() { - return outputFile_; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public java.util.List - getOutputFileOrBuilderList() { - return outputFile_; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public int getOutputFileCount() { - return outputFile_.size(); - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile getOutputFile(int index) { - return outputFile_.get(index); - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFileOrBuilder getOutputFileOrBuilder( - int index) { - return outputFile_.get(index); - } - - // required bool initJob = 8; - public static final int INITJOB_FIELD_NUMBER = 8; - private boolean initJob_; - /** - * required bool initJob = 8; - */ - public boolean hasInitJob() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * required bool initJob = 8; - */ - public boolean getInitJob() { - return initJob_; - } - - // repeated int32 completedJobId = 9; - public static final int COMPLETEDJOBID_FIELD_NUMBER = 9; - private java.util.List completedJobId_; - /** - * repeated int32 completedJobId = 9; - * - *
-     * for cleanup
-     * 
- */ - public java.util.List - getCompletedJobIdList() { - return completedJobId_; - } - /** - * repeated int32 completedJobId = 9; - * - *
-     * for cleanup
-     * 
- */ - public int getCompletedJobIdCount() { - return completedJobId_.size(); - } - /** - * repeated int32 completedJobId = 9; - * - *
-     * for cleanup
-     * 
- */ - public int getCompletedJobId(int index) { - return completedJobId_.get(index); - } - - private void initFields() { - jobId_ = 0; - index_ = 0; - env_ = eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.getDefaultInstance(); - cmdId_ = ""; - command_ = java.util.Collections.emptyList(); - inputFile_ = java.util.Collections.emptyList(); - outputFile_ = java.util.Collections.emptyList(); - initJob_ = false; - completedJobId_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasJobId()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasIndex()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasEnv()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasCmdId()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasInitJob()) { - memoizedIsInitialized = 0; - return false; - } - if (!getEnv().isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - for (int i = 0; i < getCommandCount(); i++) { - if (!getCommand(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - for (int i = 0; i < getInputFileCount(); i++) { - if (!getInputFile(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - for (int i = 0; i < getOutputFileCount(); i++) { - if (!getOutputFile(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt32(1, jobId_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt32(2, index_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeMessage(3, env_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeBytes(4, getCmdIdBytes()); - } - for (int i = 0; i < command_.size(); i++) { - output.writeMessage(5, command_.get(i)); - } - for (int i = 0; i < inputFile_.size(); i++) { - output.writeMessage(6, inputFile_.get(i)); - } - for (int i = 0; i < outputFile_.size(); i++) { - output.writeMessage(7, outputFile_.get(i)); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeBool(8, initJob_); - } - for (int i = 0; i < completedJobId_.size(); i++) { - output.writeInt32(9, completedJobId_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, jobId_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(2, index_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, env_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(4, getCmdIdBytes()); - } - for (int i = 0; i < command_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, command_.get(i)); - } - for (int i = 0; i < inputFile_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, inputFile_.get(i)); - } - for (int i = 0; i < outputFile_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, outputFile_.get(i)); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(8, initJob_); - } - { - int dataSize = 0; - for (int i = 0; i < completedJobId_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeInt32SizeNoTag(completedJobId_.get(i)); - } - size += dataSize; - size += 1 * getCompletedJobIdList().size(); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.Task parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.Task prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.Task} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.TaskOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.Task.class, eu.itesla_project.computation.mpi.messages.Messages.Task.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.Task.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getEnvFieldBuilder(); - getCommandFieldBuilder(); - getInputFileFieldBuilder(); - getOutputFileFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - jobId_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - index_ = 0; - bitField0_ = (bitField0_ & ~0x00000002); - if (envBuilder_ == null) { - env_ = eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.getDefaultInstance(); - } else { - envBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - cmdId_ = ""; - bitField0_ = (bitField0_ & ~0x00000008); - if (commandBuilder_ == null) { - command_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - } else { - commandBuilder_.clear(); - } - if (inputFileBuilder_ == null) { - inputFile_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - } else { - inputFileBuilder_.clear(); - } - if (outputFileBuilder_ == null) { - outputFile_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - } else { - outputFileBuilder_.clear(); - } - initJob_ = false; - bitField0_ = (bitField0_ & ~0x00000080); - completedJobId_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000100); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_Task_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.Task.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task build() { - eu.itesla_project.computation.mpi.messages.Messages.Task result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.Task buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.Task result = new eu.itesla_project.computation.mpi.messages.Messages.Task(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.jobId_ = jobId_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.index_ = index_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - if (envBuilder_ == null) { - result.env_ = env_; - } else { - result.env_ = envBuilder_.build(); - } - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.cmdId_ = cmdId_; - if (commandBuilder_ == null) { - if (((bitField0_ & 0x00000010) == 0x00000010)) { - command_ = java.util.Collections.unmodifiableList(command_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.command_ = command_; - } else { - result.command_ = commandBuilder_.build(); - } - if (inputFileBuilder_ == null) { - if (((bitField0_ & 0x00000020) == 0x00000020)) { - inputFile_ = java.util.Collections.unmodifiableList(inputFile_); - bitField0_ = (bitField0_ & ~0x00000020); - } - result.inputFile_ = inputFile_; - } else { - result.inputFile_ = inputFileBuilder_.build(); - } - if (outputFileBuilder_ == null) { - if (((bitField0_ & 0x00000040) == 0x00000040)) { - outputFile_ = java.util.Collections.unmodifiableList(outputFile_); - bitField0_ = (bitField0_ & ~0x00000040); - } - result.outputFile_ = outputFile_; - } else { - result.outputFile_ = outputFileBuilder_.build(); - } - if (((from_bitField0_ & 0x00000080) == 0x00000080)) { - to_bitField0_ |= 0x00000010; - } - result.initJob_ = initJob_; - if (((bitField0_ & 0x00000100) == 0x00000100)) { - completedJobId_ = java.util.Collections.unmodifiableList(completedJobId_); - bitField0_ = (bitField0_ & ~0x00000100); - } - result.completedJobId_ = completedJobId_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.Task) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.Task)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.Task other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.Task.getDefaultInstance()) return this; - if (other.hasJobId()) { - setJobId(other.getJobId()); - } - if (other.hasIndex()) { - setIndex(other.getIndex()); - } - if (other.hasEnv()) { - mergeEnv(other.getEnv()); - } - if (other.hasCmdId()) { - bitField0_ |= 0x00000008; - cmdId_ = other.cmdId_; - onChanged(); - } - if (commandBuilder_ == null) { - if (!other.command_.isEmpty()) { - if (command_.isEmpty()) { - command_ = other.command_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensureCommandIsMutable(); - command_.addAll(other.command_); - } - onChanged(); - } - } else { - if (!other.command_.isEmpty()) { - if (commandBuilder_.isEmpty()) { - commandBuilder_.dispose(); - commandBuilder_ = null; - command_ = other.command_; - bitField0_ = (bitField0_ & ~0x00000010); - commandBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getCommandFieldBuilder() : null; - } else { - commandBuilder_.addAllMessages(other.command_); - } - } - } - if (inputFileBuilder_ == null) { - if (!other.inputFile_.isEmpty()) { - if (inputFile_.isEmpty()) { - inputFile_ = other.inputFile_; - bitField0_ = (bitField0_ & ~0x00000020); - } else { - ensureInputFileIsMutable(); - inputFile_.addAll(other.inputFile_); - } - onChanged(); - } - } else { - if (!other.inputFile_.isEmpty()) { - if (inputFileBuilder_.isEmpty()) { - inputFileBuilder_.dispose(); - inputFileBuilder_ = null; - inputFile_ = other.inputFile_; - bitField0_ = (bitField0_ & ~0x00000020); - inputFileBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getInputFileFieldBuilder() : null; - } else { - inputFileBuilder_.addAllMessages(other.inputFile_); - } - } - } - if (outputFileBuilder_ == null) { - if (!other.outputFile_.isEmpty()) { - if (outputFile_.isEmpty()) { - outputFile_ = other.outputFile_; - bitField0_ = (bitField0_ & ~0x00000040); - } else { - ensureOutputFileIsMutable(); - outputFile_.addAll(other.outputFile_); - } - onChanged(); - } - } else { - if (!other.outputFile_.isEmpty()) { - if (outputFileBuilder_.isEmpty()) { - outputFileBuilder_.dispose(); - outputFileBuilder_ = null; - outputFile_ = other.outputFile_; - bitField0_ = (bitField0_ & ~0x00000040); - outputFileBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getOutputFileFieldBuilder() : null; - } else { - outputFileBuilder_.addAllMessages(other.outputFile_); - } - } - } - if (other.hasInitJob()) { - setInitJob(other.getInitJob()); - } - if (!other.completedJobId_.isEmpty()) { - if (completedJobId_.isEmpty()) { - completedJobId_ = other.completedJobId_; - bitField0_ = (bitField0_ & ~0x00000100); - } else { - ensureCompletedJobIdIsMutable(); - completedJobId_.addAll(other.completedJobId_); - } - onChanged(); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasJobId()) { - - return false; - } - if (!hasIndex()) { - - return false; - } - if (!hasEnv()) { - - return false; - } - if (!hasCmdId()) { - - return false; - } - if (!hasInitJob()) { - - return false; - } - if (!getEnv().isInitialized()) { - - return false; - } - for (int i = 0; i < getCommandCount(); i++) { - if (!getCommand(i).isInitialized()) { - - return false; - } - } - for (int i = 0; i < getInputFileCount(); i++) { - if (!getInputFile(i).isInitialized()) { - - return false; - } - } - for (int i = 0; i < getOutputFileCount(); i++) { - if (!getOutputFile(i).isInitialized()) { - - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.Task parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.Task) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required int32 jobId = 1; - private int jobId_ ; - /** - * required int32 jobId = 1; - */ - public boolean hasJobId() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int32 jobId = 1; - */ - public int getJobId() { - return jobId_; - } - /** - * required int32 jobId = 1; - */ - public Builder setJobId(int value) { - bitField0_ |= 0x00000001; - jobId_ = value; - onChanged(); - return this; - } - /** - * required int32 jobId = 1; - */ - public Builder clearJobId() { - bitField0_ = (bitField0_ & ~0x00000001); - jobId_ = 0; - onChanged(); - return this; - } - - // required int32 index = 2; - private int index_ ; - /** - * required int32 index = 2; - */ - public boolean hasIndex() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required int32 index = 2; - */ - public int getIndex() { - return index_; - } - /** - * required int32 index = 2; - */ - public Builder setIndex(int value) { - bitField0_ |= 0x00000002; - index_ = value; - onChanged(); - return this; - } - /** - * required int32 index = 2; - */ - public Builder clearIndex() { - bitField0_ = (bitField0_ & ~0x00000002); - index_ = 0; - onChanged(); - return this; - } - - // required .messages.Task.Environment env = 3; - private eu.itesla_project.computation.mpi.messages.Messages.Task.Environment env_ = eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.getDefaultInstance(); - private com.google.protobuf.SingleFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment, eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.EnvironmentOrBuilder> envBuilder_; - /** - * required .messages.Task.Environment env = 3; - */ - public boolean hasEnv() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required .messages.Task.Environment env = 3; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Environment getEnv() { - if (envBuilder_ == null) { - return env_; - } else { - return envBuilder_.getMessage(); - } - } - /** - * required .messages.Task.Environment env = 3; - */ - public Builder setEnv(eu.itesla_project.computation.mpi.messages.Messages.Task.Environment value) { - if (envBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - env_ = value; - onChanged(); - } else { - envBuilder_.setMessage(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * required .messages.Task.Environment env = 3; - */ - public Builder setEnv( - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder builderForValue) { - if (envBuilder_ == null) { - env_ = builderForValue.build(); - onChanged(); - } else { - envBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * required .messages.Task.Environment env = 3; - */ - public Builder mergeEnv(eu.itesla_project.computation.mpi.messages.Messages.Task.Environment value) { - if (envBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004) && - env_ != eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.getDefaultInstance()) { - env_ = - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.newBuilder(env_).mergeFrom(value).buildPartial(); - } else { - env_ = value; - } - onChanged(); - } else { - envBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000004; - return this; - } - /** - * required .messages.Task.Environment env = 3; - */ - public Builder clearEnv() { - if (envBuilder_ == null) { - env_ = eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.getDefaultInstance(); - onChanged(); - } else { - envBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000004); - return this; - } - /** - * required .messages.Task.Environment env = 3; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder getEnvBuilder() { - bitField0_ |= 0x00000004; - onChanged(); - return getEnvFieldBuilder().getBuilder(); - } - /** - * required .messages.Task.Environment env = 3; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.EnvironmentOrBuilder getEnvOrBuilder() { - if (envBuilder_ != null) { - return envBuilder_.getMessageOrBuilder(); - } else { - return env_; - } - } - /** - * required .messages.Task.Environment env = 3; - */ - private com.google.protobuf.SingleFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment, eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.EnvironmentOrBuilder> - getEnvFieldBuilder() { - if (envBuilder_ == null) { - envBuilder_ = new com.google.protobuf.SingleFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Environment, eu.itesla_project.computation.mpi.messages.Messages.Task.Environment.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.EnvironmentOrBuilder>( - env_, - getParentForChildren(), - isClean()); - env_ = null; - } - return envBuilder_; - } - - // required string cmdId = 4; - private java.lang.Object cmdId_ = ""; - /** - * required string cmdId = 4; - */ - public boolean hasCmdId() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * required string cmdId = 4; - */ - public java.lang.String getCmdId() { - java.lang.Object ref = cmdId_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - cmdId_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string cmdId = 4; - */ - public com.google.protobuf.ByteString - getCmdIdBytes() { - java.lang.Object ref = cmdId_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - cmdId_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string cmdId = 4; - */ - public Builder setCmdId( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - cmdId_ = value; - onChanged(); - return this; - } - /** - * required string cmdId = 4; - */ - public Builder clearCmdId() { - bitField0_ = (bitField0_ & ~0x00000008); - cmdId_ = getDefaultInstance().getCmdId(); - onChanged(); - return this; - } - /** - * required string cmdId = 4; - */ - public Builder setCmdIdBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000008; - cmdId_ = value; - onChanged(); - return this; - } - - // repeated .messages.Task.Command command = 5; - private java.util.List command_ = - java.util.Collections.emptyList(); - private void ensureCommandIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - command_ = new java.util.ArrayList(command_); - bitField0_ |= 0x00000010; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Command, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.CommandOrBuilder> commandBuilder_; - - /** - * repeated .messages.Task.Command command = 5; - */ - public java.util.List getCommandList() { - if (commandBuilder_ == null) { - return java.util.Collections.unmodifiableList(command_); - } else { - return commandBuilder_.getMessageList(); - } - } - /** - * repeated .messages.Task.Command command = 5; - */ - public int getCommandCount() { - if (commandBuilder_ == null) { - return command_.size(); - } else { - return commandBuilder_.getCount(); - } - } - /** - * repeated .messages.Task.Command command = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command getCommand(int index) { - if (commandBuilder_ == null) { - return command_.get(index); - } else { - return commandBuilder_.getMessage(index); - } - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder setCommand( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Command value) { - if (commandBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCommandIsMutable(); - command_.set(index, value); - onChanged(); - } else { - commandBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder setCommand( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder builderForValue) { - if (commandBuilder_ == null) { - ensureCommandIsMutable(); - command_.set(index, builderForValue.build()); - onChanged(); - } else { - commandBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder addCommand(eu.itesla_project.computation.mpi.messages.Messages.Task.Command value) { - if (commandBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCommandIsMutable(); - command_.add(value); - onChanged(); - } else { - commandBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder addCommand( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Command value) { - if (commandBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureCommandIsMutable(); - command_.add(index, value); - onChanged(); - } else { - commandBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder addCommand( - eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder builderForValue) { - if (commandBuilder_ == null) { - ensureCommandIsMutable(); - command_.add(builderForValue.build()); - onChanged(); - } else { - commandBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder addCommand( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder builderForValue) { - if (commandBuilder_ == null) { - ensureCommandIsMutable(); - command_.add(index, builderForValue.build()); - onChanged(); - } else { - commandBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder addAllCommand( - java.lang.Iterable values) { - if (commandBuilder_ == null) { - ensureCommandIsMutable(); - super.addAll(values, command_); - onChanged(); - } else { - commandBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder clearCommand() { - if (commandBuilder_ == null) { - command_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - onChanged(); - } else { - commandBuilder_.clear(); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public Builder removeCommand(int index) { - if (commandBuilder_ == null) { - ensureCommandIsMutable(); - command_.remove(index); - onChanged(); - } else { - commandBuilder_.remove(index); - } - return this; - } - /** - * repeated .messages.Task.Command command = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder getCommandBuilder( - int index) { - return getCommandFieldBuilder().getBuilder(index); - } - /** - * repeated .messages.Task.Command command = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.CommandOrBuilder getCommandOrBuilder( - int index) { - if (commandBuilder_ == null) { - return command_.get(index); } else { - return commandBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .messages.Task.Command command = 5; - */ - public java.util.List - getCommandOrBuilderList() { - if (commandBuilder_ != null) { - return commandBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(command_); - } - } - /** - * repeated .messages.Task.Command command = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder addCommandBuilder() { - return getCommandFieldBuilder().addBuilder( - eu.itesla_project.computation.mpi.messages.Messages.Task.Command.getDefaultInstance()); - } - /** - * repeated .messages.Task.Command command = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder addCommandBuilder( - int index) { - return getCommandFieldBuilder().addBuilder( - index, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.getDefaultInstance()); - } - /** - * repeated .messages.Task.Command command = 5; - */ - public java.util.List - getCommandBuilderList() { - return getCommandFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Command, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.CommandOrBuilder> - getCommandFieldBuilder() { - if (commandBuilder_ == null) { - commandBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.Command, eu.itesla_project.computation.mpi.messages.Messages.Task.Command.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.CommandOrBuilder>( - command_, - ((bitField0_ & 0x00000010) == 0x00000010), - getParentForChildren(), - isClean()); - command_ = null; - } - return commandBuilder_; - } - - // repeated .messages.Task.InputFile inputFile = 6; - private java.util.List inputFile_ = - java.util.Collections.emptyList(); - private void ensureInputFileIsMutable() { - if (!((bitField0_ & 0x00000020) == 0x00000020)) { - inputFile_ = new java.util.ArrayList(inputFile_); - bitField0_ |= 0x00000020; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFileOrBuilder> inputFileBuilder_; - - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public java.util.List getInputFileList() { - if (inputFileBuilder_ == null) { - return java.util.Collections.unmodifiableList(inputFile_); - } else { - return inputFileBuilder_.getMessageList(); - } - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public int getInputFileCount() { - if (inputFileBuilder_ == null) { - return inputFile_.size(); - } else { - return inputFileBuilder_.getCount(); - } - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile getInputFile(int index) { - if (inputFileBuilder_ == null) { - return inputFile_.get(index); - } else { - return inputFileBuilder_.getMessage(index); - } - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder setInputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile value) { - if (inputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureInputFileIsMutable(); - inputFile_.set(index, value); - onChanged(); - } else { - inputFileBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder setInputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder builderForValue) { - if (inputFileBuilder_ == null) { - ensureInputFileIsMutable(); - inputFile_.set(index, builderForValue.build()); - onChanged(); - } else { - inputFileBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder addInputFile(eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile value) { - if (inputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureInputFileIsMutable(); - inputFile_.add(value); - onChanged(); - } else { - inputFileBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder addInputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile value) { - if (inputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureInputFileIsMutable(); - inputFile_.add(index, value); - onChanged(); - } else { - inputFileBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder addInputFile( - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder builderForValue) { - if (inputFileBuilder_ == null) { - ensureInputFileIsMutable(); - inputFile_.add(builderForValue.build()); - onChanged(); - } else { - inputFileBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder addInputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder builderForValue) { - if (inputFileBuilder_ == null) { - ensureInputFileIsMutable(); - inputFile_.add(index, builderForValue.build()); - onChanged(); - } else { - inputFileBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder addAllInputFile( - java.lang.Iterable values) { - if (inputFileBuilder_ == null) { - ensureInputFileIsMutable(); - super.addAll(values, inputFile_); - onChanged(); - } else { - inputFileBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder clearInputFile() { - if (inputFileBuilder_ == null) { - inputFile_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000020); - onChanged(); - } else { - inputFileBuilder_.clear(); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public Builder removeInputFile(int index) { - if (inputFileBuilder_ == null) { - ensureInputFileIsMutable(); - inputFile_.remove(index); - onChanged(); - } else { - inputFileBuilder_.remove(index); - } - return this; - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder getInputFileBuilder( - int index) { - return getInputFileFieldBuilder().getBuilder(index); - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFileOrBuilder getInputFileOrBuilder( - int index) { - if (inputFileBuilder_ == null) { - return inputFile_.get(index); } else { - return inputFileBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public java.util.List - getInputFileOrBuilderList() { - if (inputFileBuilder_ != null) { - return inputFileBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(inputFile_); - } - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder addInputFileBuilder() { - return getInputFileFieldBuilder().addBuilder( - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.getDefaultInstance()); - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder addInputFileBuilder( - int index) { - return getInputFileFieldBuilder().addBuilder( - index, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.getDefaultInstance()); - } - /** - * repeated .messages.Task.InputFile inputFile = 6; - */ - public java.util.List - getInputFileBuilderList() { - return getInputFileFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFileOrBuilder> - getInputFileFieldBuilder() { - if (inputFileBuilder_ == null) { - inputFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.InputFileOrBuilder>( - inputFile_, - ((bitField0_ & 0x00000020) == 0x00000020), - getParentForChildren(), - isClean()); - inputFile_ = null; - } - return inputFileBuilder_; - } - - // repeated .messages.Task.OutputFile outputFile = 7; - private java.util.List outputFile_ = - java.util.Collections.emptyList(); - private void ensureOutputFileIsMutable() { - if (!((bitField0_ & 0x00000040) == 0x00000040)) { - outputFile_ = new java.util.ArrayList(outputFile_); - bitField0_ |= 0x00000040; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFileOrBuilder> outputFileBuilder_; - - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public java.util.List getOutputFileList() { - if (outputFileBuilder_ == null) { - return java.util.Collections.unmodifiableList(outputFile_); - } else { - return outputFileBuilder_.getMessageList(); - } - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public int getOutputFileCount() { - if (outputFileBuilder_ == null) { - return outputFile_.size(); - } else { - return outputFileBuilder_.getCount(); - } - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile getOutputFile(int index) { - if (outputFileBuilder_ == null) { - return outputFile_.get(index); - } else { - return outputFileBuilder_.getMessage(index); - } - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder setOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile value) { - if (outputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOutputFileIsMutable(); - outputFile_.set(index, value); - onChanged(); - } else { - outputFileBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder setOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder builderForValue) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.set(index, builderForValue.build()); - onChanged(); - } else { - outputFileBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder addOutputFile(eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile value) { - if (outputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOutputFileIsMutable(); - outputFile_.add(value); - onChanged(); - } else { - outputFileBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder addOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile value) { - if (outputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOutputFileIsMutable(); - outputFile_.add(index, value); - onChanged(); - } else { - outputFileBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder addOutputFile( - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder builderForValue) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.add(builderForValue.build()); - onChanged(); - } else { - outputFileBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder addOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder builderForValue) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.add(index, builderForValue.build()); - onChanged(); - } else { - outputFileBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder addAllOutputFile( - java.lang.Iterable values) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - super.addAll(values, outputFile_); - onChanged(); - } else { - outputFileBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder clearOutputFile() { - if (outputFileBuilder_ == null) { - outputFile_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000040); - onChanged(); - } else { - outputFileBuilder_.clear(); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public Builder removeOutputFile(int index) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.remove(index); - onChanged(); - } else { - outputFileBuilder_.remove(index); - } - return this; - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder getOutputFileBuilder( - int index) { - return getOutputFileFieldBuilder().getBuilder(index); - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFileOrBuilder getOutputFileOrBuilder( - int index) { - if (outputFileBuilder_ == null) { - return outputFile_.get(index); } else { - return outputFileBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public java.util.List - getOutputFileOrBuilderList() { - if (outputFileBuilder_ != null) { - return outputFileBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(outputFile_); - } - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder addOutputFileBuilder() { - return getOutputFileFieldBuilder().addBuilder( - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.getDefaultInstance()); - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder addOutputFileBuilder( - int index) { - return getOutputFileFieldBuilder().addBuilder( - index, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.getDefaultInstance()); - } - /** - * repeated .messages.Task.OutputFile outputFile = 7; - */ - public java.util.List - getOutputFileBuilderList() { - return getOutputFileFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFileOrBuilder> - getOutputFileFieldBuilder() { - if (outputFileBuilder_ == null) { - outputFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.Task.OutputFileOrBuilder>( - outputFile_, - ((bitField0_ & 0x00000040) == 0x00000040), - getParentForChildren(), - isClean()); - outputFile_ = null; - } - return outputFileBuilder_; - } - - // required bool initJob = 8; - private boolean initJob_ ; - /** - * required bool initJob = 8; - */ - public boolean hasInitJob() { - return ((bitField0_ & 0x00000080) == 0x00000080); - } - /** - * required bool initJob = 8; - */ - public boolean getInitJob() { - return initJob_; - } - /** - * required bool initJob = 8; - */ - public Builder setInitJob(boolean value) { - bitField0_ |= 0x00000080; - initJob_ = value; - onChanged(); - return this; - } - /** - * required bool initJob = 8; - */ - public Builder clearInitJob() { - bitField0_ = (bitField0_ & ~0x00000080); - initJob_ = false; - onChanged(); - return this; - } - - // repeated int32 completedJobId = 9; - private java.util.List completedJobId_ = java.util.Collections.emptyList(); - private void ensureCompletedJobIdIsMutable() { - if (!((bitField0_ & 0x00000100) == 0x00000100)) { - completedJobId_ = new java.util.ArrayList(completedJobId_); - bitField0_ |= 0x00000100; - } - } - /** - * repeated int32 completedJobId = 9; - * - *
-       * for cleanup
-       * 
- */ - public java.util.List - getCompletedJobIdList() { - return java.util.Collections.unmodifiableList(completedJobId_); - } - /** - * repeated int32 completedJobId = 9; - * - *
-       * for cleanup
-       * 
- */ - public int getCompletedJobIdCount() { - return completedJobId_.size(); - } - /** - * repeated int32 completedJobId = 9; - * - *
-       * for cleanup
-       * 
- */ - public int getCompletedJobId(int index) { - return completedJobId_.get(index); - } - /** - * repeated int32 completedJobId = 9; - * - *
-       * for cleanup
-       * 
- */ - public Builder setCompletedJobId( - int index, int value) { - ensureCompletedJobIdIsMutable(); - completedJobId_.set(index, value); - onChanged(); - return this; - } - /** - * repeated int32 completedJobId = 9; - * - *
-       * for cleanup
-       * 
- */ - public Builder addCompletedJobId(int value) { - ensureCompletedJobIdIsMutable(); - completedJobId_.add(value); - onChanged(); - return this; - } - /** - * repeated int32 completedJobId = 9; - * - *
-       * for cleanup
-       * 
- */ - public Builder addAllCompletedJobId( - java.lang.Iterable values) { - ensureCompletedJobIdIsMutable(); - super.addAll(values, completedJobId_); - onChanged(); - return this; - } - /** - * repeated int32 completedJobId = 9; - * - *
-       * for cleanup
-       * 
- */ - public Builder clearCompletedJobId() { - completedJobId_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000100); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:messages.Task) - } - - static { - defaultInstance = new Task(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.Task) - } - - public interface TaskResultOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required int32 exitCode = 1; - /** - * required int32 exitCode = 1; - */ - boolean hasExitCode(); - /** - * required int32 exitCode = 1; - */ - int getExitCode(); - - // required int64 taskDuration = 2; - /** - * required int64 taskDuration = 2; - * - *
-     * in ms 
-     * 
- */ - boolean hasTaskDuration(); - /** - * required int64 taskDuration = 2; - * - *
-     * in ms 
-     * 
- */ - long getTaskDuration(); - - // repeated int64 commandDuration = 3; - /** - * repeated int64 commandDuration = 3; - * - *
-     * in ms 
-     * 
- */ - java.util.List getCommandDurationList(); - /** - * repeated int64 commandDuration = 3; - * - *
-     * in ms 
-     * 
- */ - int getCommandDurationCount(); - /** - * repeated int64 commandDuration = 3; - * - *
-     * in ms 
-     * 
- */ - long getCommandDuration(int index); - - // required int64 workingDataSize = 4; - /** - * required int64 workingDataSize = 4; - * - *
-     * in bytes
-     * 
- */ - boolean hasWorkingDataSize(); - /** - * required int64 workingDataSize = 4; - * - *
-     * in bytes
-     * 
- */ - long getWorkingDataSize(); - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - java.util.List - getOutputFileList(); - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile getOutputFile(int index); - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - int getOutputFileCount(); - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - java.util.List - getOutputFileOrBuilderList(); - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFileOrBuilder getOutputFileOrBuilder( - int index); - } - /** - * Protobuf type {@code messages.TaskResult} - */ - public static final class TaskResult extends - com.google.protobuf.GeneratedMessage - implements TaskResultOrBuilder { - // Use TaskResult.newBuilder() to construct. - private TaskResult(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private TaskResult(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final TaskResult defaultInstance; - public static TaskResult getDefaultInstance() { - return defaultInstance; - } - - public TaskResult getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private TaskResult( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 8: { - bitField0_ |= 0x00000001; - exitCode_ = input.readInt32(); - break; - } - case 16: { - bitField0_ |= 0x00000002; - taskDuration_ = input.readInt64(); - break; - } - case 24: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - commandDuration_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - commandDuration_.add(input.readInt64()); - break; - } - case 26: { - int length = input.readRawVarint32(); - int limit = input.pushLimit(length); - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004) && input.getBytesUntilLimit() > 0) { - commandDuration_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - while (input.getBytesUntilLimit() > 0) { - commandDuration_.add(input.readInt64()); - } - input.popLimit(limit); - break; - } - case 32: { - bitField0_ |= 0x00000004; - workingDataSize_ = input.readInt64(); - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - outputFile_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - outputFile_.add(input.readMessage(eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.PARSER, extensionRegistry)); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - commandDuration_ = java.util.Collections.unmodifiableList(commandDuration_); - } - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - outputFile_ = java.util.Collections.unmodifiableList(outputFile_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.class, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public TaskResult parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new TaskResult(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public interface OutputFileOrBuilder - extends com.google.protobuf.MessageOrBuilder { - - // required string name = 1; - /** - * required string name = 1; - */ - boolean hasName(); - /** - * required string name = 1; - */ - java.lang.String getName(); - /** - * required string name = 1; - */ - com.google.protobuf.ByteString - getNameBytes(); - - // optional bytes data = 2; - /** - * optional bytes data = 2; - */ - boolean hasData(); - /** - * optional bytes data = 2; - */ - com.google.protobuf.ByteString getData(); - } - /** - * Protobuf type {@code messages.TaskResult.OutputFile} - */ - public static final class OutputFile extends - com.google.protobuf.GeneratedMessage - implements OutputFileOrBuilder { - // Use OutputFile.newBuilder() to construct. - private OutputFile(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - this.unknownFields = builder.getUnknownFields(); - } - private OutputFile(boolean noInit) { this.unknownFields = com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - - private static final OutputFile defaultInstance; - public static OutputFile getDefaultInstance() { - return defaultInstance; - } - - public OutputFile getDefaultInstanceForType() { - return defaultInstance; - } - - private final com.google.protobuf.UnknownFieldSet unknownFields; - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private OutputFile( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - initFields(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField(input, unknownFields, - extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - bitField0_ |= 0x00000001; - name_ = input.readBytes(); - break; - } - case 18: { - bitField0_ |= 0x00000002; - data_ = input.readBytes(); - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e.getMessage()).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_OutputFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_OutputFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.class, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder.class); - } - - public static com.google.protobuf.Parser PARSER = - new com.google.protobuf.AbstractParser() { - public OutputFile parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new OutputFile(input, extensionRegistry); - } - }; - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - private int bitField0_; - // required string name = 1; - public static final int NAME_FIELD_NUMBER = 1; - private java.lang.Object name_; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - // optional bytes data = 2; - public static final int DATA_FIELD_NUMBER = 2; - private com.google.protobuf.ByteString data_; - /** - * optional bytes data = 2; - */ - public boolean hasData() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes data = 2; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - - private void initFields() { - name_ = ""; - data_ = com.google.protobuf.ByteString.EMPTY; - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasName()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeBytes(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeBytes(2, data_); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(1, getNameBytes()); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(2, data_); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.TaskResult.OutputFile} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFileOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_OutputFile_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_OutputFile_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.class, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - name_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - data_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_OutputFile_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile build() { - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile result = new eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.name_ = name_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.data_ = data_; - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.getDefaultInstance()) return this; - if (other.hasName()) { - bitField0_ |= 0x00000001; - name_ = other.name_; - onChanged(); - } - if (other.hasData()) { - setData(other.getData()); - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasName()) { - - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required string name = 1; - private java.lang.Object name_ = ""; - /** - * required string name = 1; - */ - public boolean hasName() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required string name = 1; - */ - public java.lang.String getName() { - java.lang.Object ref = name_; - if (!(ref instanceof java.lang.String)) { - java.lang.String s = ((com.google.protobuf.ByteString) ref) - .toStringUtf8(); - name_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * required string name = 1; - */ - public com.google.protobuf.ByteString - getNameBytes() { - java.lang.Object ref = name_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - name_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * required string name = 1; - */ - public Builder setName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000001); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * required string name = 1; - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - name_ = value; - onChanged(); - return this; - } - - // optional bytes data = 2; - private com.google.protobuf.ByteString data_ = com.google.protobuf.ByteString.EMPTY; - /** - * optional bytes data = 2; - */ - public boolean hasData() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * optional bytes data = 2; - */ - public com.google.protobuf.ByteString getData() { - return data_; - } - /** - * optional bytes data = 2; - */ - public Builder setData(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - data_ = value; - onChanged(); - return this; - } - /** - * optional bytes data = 2; - */ - public Builder clearData() { - bitField0_ = (bitField0_ & ~0x00000002); - data_ = getDefaultInstance().getData(); - onChanged(); - return this; - } - - // @@protoc_insertion_point(builder_scope:messages.TaskResult.OutputFile) - } - - static { - defaultInstance = new OutputFile(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.TaskResult.OutputFile) - } - - private int bitField0_; - // required int32 exitCode = 1; - public static final int EXITCODE_FIELD_NUMBER = 1; - private int exitCode_; - /** - * required int32 exitCode = 1; - */ - public boolean hasExitCode() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int32 exitCode = 1; - */ - public int getExitCode() { - return exitCode_; - } - - // required int64 taskDuration = 2; - public static final int TASKDURATION_FIELD_NUMBER = 2; - private long taskDuration_; - /** - * required int64 taskDuration = 2; - * - *
-     * in ms 
-     * 
- */ - public boolean hasTaskDuration() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required int64 taskDuration = 2; - * - *
-     * in ms 
-     * 
- */ - public long getTaskDuration() { - return taskDuration_; - } - - // repeated int64 commandDuration = 3; - public static final int COMMANDDURATION_FIELD_NUMBER = 3; - private java.util.List commandDuration_; - /** - * repeated int64 commandDuration = 3; - * - *
-     * in ms 
-     * 
- */ - public java.util.List - getCommandDurationList() { - return commandDuration_; - } - /** - * repeated int64 commandDuration = 3; - * - *
-     * in ms 
-     * 
- */ - public int getCommandDurationCount() { - return commandDuration_.size(); - } - /** - * repeated int64 commandDuration = 3; - * - *
-     * in ms 
-     * 
- */ - public long getCommandDuration(int index) { - return commandDuration_.get(index); - } - - // required int64 workingDataSize = 4; - public static final int WORKINGDATASIZE_FIELD_NUMBER = 4; - private long workingDataSize_; - /** - * required int64 workingDataSize = 4; - * - *
-     * in bytes
-     * 
- */ - public boolean hasWorkingDataSize() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * required int64 workingDataSize = 4; - * - *
-     * in bytes
-     * 
- */ - public long getWorkingDataSize() { - return workingDataSize_; - } - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - public static final int OUTPUTFILE_FIELD_NUMBER = 5; - private java.util.List outputFile_; - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public java.util.List getOutputFileList() { - return outputFile_; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public java.util.List - getOutputFileOrBuilderList() { - return outputFile_; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public int getOutputFileCount() { - return outputFile_.size(); - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile getOutputFile(int index) { - return outputFile_.get(index); - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFileOrBuilder getOutputFileOrBuilder( - int index) { - return outputFile_.get(index); - } - - private void initFields() { - exitCode_ = 0; - taskDuration_ = 0L; - commandDuration_ = java.util.Collections.emptyList(); - workingDataSize_ = 0L; - outputFile_ = java.util.Collections.emptyList(); - } - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized != -1) return isInitialized == 1; - - if (!hasExitCode()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasTaskDuration()) { - memoizedIsInitialized = 0; - return false; - } - if (!hasWorkingDataSize()) { - memoizedIsInitialized = 0; - return false; - } - for (int i = 0; i < getOutputFileCount(); i++) { - if (!getOutputFile(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - getSerializedSize(); - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeInt32(1, exitCode_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeInt64(2, taskDuration_); - } - for (int i = 0; i < commandDuration_.size(); i++) { - output.writeInt64(3, commandDuration_.get(i)); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeInt64(4, workingDataSize_); - } - for (int i = 0; i < outputFile_.size(); i++) { - output.writeMessage(5, outputFile_.get(i)); - } - getUnknownFields().writeTo(output); - } - - private int memoizedSerializedSize = -1; - public int getSerializedSize() { - int size = memoizedSerializedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(1, exitCode_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, taskDuration_); - } - { - int dataSize = 0; - for (int i = 0; i < commandDuration_.size(); i++) { - dataSize += com.google.protobuf.CodedOutputStream - .computeInt64SizeNoTag(commandDuration_.get(i)); - } - size += dataSize; - size += 1 * getCommandDurationList().size(); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, workingDataSize_); - } - for (int i = 0; i < outputFile_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, outputFile_.get(i)); - } - size += getUnknownFields().getSerializedSize(); - memoizedSerializedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - @java.lang.Override - protected java.lang.Object writeReplace() - throws java.io.ObjectStreamException { - return super.writeReplace(); - } - - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseDelimitedFrom(input, extensionRegistry); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return PARSER.parseFrom(input); - } - public static eu.itesla_project.computation.mpi.messages.Messages.TaskResult parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return PARSER.parseFrom(input, extensionRegistry); - } - - public static Builder newBuilder() { return Builder.create(); } - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder(eu.itesla_project.computation.mpi.messages.Messages.TaskResult prototype) { - return newBuilder().mergeFrom(prototype); - } - public Builder toBuilder() { return newBuilder(this); } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code messages.TaskResult} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder - implements eu.itesla_project.computation.mpi.messages.Messages.TaskResultOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_fieldAccessorTable - .ensureFieldAccessorsInitialized( - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.class, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.Builder.class); - } - - // Construct using eu.itesla_project.computation.mpi.messages.Messages.TaskResult.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getOutputFileFieldBuilder(); - } - } - private static Builder create() { - return new Builder(); - } - - public Builder clear() { - super.clear(); - exitCode_ = 0; - bitField0_ = (bitField0_ & ~0x00000001); - taskDuration_ = 0L; - bitField0_ = (bitField0_ & ~0x00000002); - commandDuration_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - workingDataSize_ = 0L; - bitField0_ = (bitField0_ & ~0x00000008); - if (outputFileBuilder_ == null) { - outputFile_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - } else { - outputFileBuilder_.clear(); - } - return this; - } - - public Builder clone() { - return create().mergeFrom(buildPartial()); - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return eu.itesla_project.computation.mpi.messages.Messages.internal_static_messages_TaskResult_descriptor; - } - - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult getDefaultInstanceForType() { - return eu.itesla_project.computation.mpi.messages.Messages.TaskResult.getDefaultInstance(); - } - - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult build() { - eu.itesla_project.computation.mpi.messages.Messages.TaskResult result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult buildPartial() { - eu.itesla_project.computation.mpi.messages.Messages.TaskResult result = new eu.itesla_project.computation.mpi.messages.Messages.TaskResult(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.exitCode_ = exitCode_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.taskDuration_ = taskDuration_; - if (((bitField0_ & 0x00000004) == 0x00000004)) { - commandDuration_ = java.util.Collections.unmodifiableList(commandDuration_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.commandDuration_ = commandDuration_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000004; - } - result.workingDataSize_ = workingDataSize_; - if (outputFileBuilder_ == null) { - if (((bitField0_ & 0x00000010) == 0x00000010)) { - outputFile_ = java.util.Collections.unmodifiableList(outputFile_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.outputFile_ = outputFile_; - } else { - result.outputFile_ = outputFileBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof eu.itesla_project.computation.mpi.messages.Messages.TaskResult) { - return mergeFrom((eu.itesla_project.computation.mpi.messages.Messages.TaskResult)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(eu.itesla_project.computation.mpi.messages.Messages.TaskResult other) { - if (other == eu.itesla_project.computation.mpi.messages.Messages.TaskResult.getDefaultInstance()) return this; - if (other.hasExitCode()) { - setExitCode(other.getExitCode()); - } - if (other.hasTaskDuration()) { - setTaskDuration(other.getTaskDuration()); - } - if (!other.commandDuration_.isEmpty()) { - if (commandDuration_.isEmpty()) { - commandDuration_ = other.commandDuration_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureCommandDurationIsMutable(); - commandDuration_.addAll(other.commandDuration_); - } - onChanged(); - } - if (other.hasWorkingDataSize()) { - setWorkingDataSize(other.getWorkingDataSize()); - } - if (outputFileBuilder_ == null) { - if (!other.outputFile_.isEmpty()) { - if (outputFile_.isEmpty()) { - outputFile_ = other.outputFile_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensureOutputFileIsMutable(); - outputFile_.addAll(other.outputFile_); - } - onChanged(); - } - } else { - if (!other.outputFile_.isEmpty()) { - if (outputFileBuilder_.isEmpty()) { - outputFileBuilder_.dispose(); - outputFileBuilder_ = null; - outputFile_ = other.outputFile_; - bitField0_ = (bitField0_ & ~0x00000010); - outputFileBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getOutputFileFieldBuilder() : null; - } else { - outputFileBuilder_.addAllMessages(other.outputFile_); - } - } - } - this.mergeUnknownFields(other.getUnknownFields()); - return this; - } - - public final boolean isInitialized() { - if (!hasExitCode()) { - - return false; - } - if (!hasTaskDuration()) { - - return false; - } - if (!hasWorkingDataSize()) { - - return false; - } - for (int i = 0; i < getOutputFileCount(); i++) { - if (!getOutputFile(i).isInitialized()) { - - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - eu.itesla_project.computation.mpi.messages.Messages.TaskResult parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (eu.itesla_project.computation.mpi.messages.Messages.TaskResult) e.getUnfinishedMessage(); - throw e; - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - // required int32 exitCode = 1; - private int exitCode_ ; - /** - * required int32 exitCode = 1; - */ - public boolean hasExitCode() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * required int32 exitCode = 1; - */ - public int getExitCode() { - return exitCode_; - } - /** - * required int32 exitCode = 1; - */ - public Builder setExitCode(int value) { - bitField0_ |= 0x00000001; - exitCode_ = value; - onChanged(); - return this; - } - /** - * required int32 exitCode = 1; - */ - public Builder clearExitCode() { - bitField0_ = (bitField0_ & ~0x00000001); - exitCode_ = 0; - onChanged(); - return this; - } - - // required int64 taskDuration = 2; - private long taskDuration_ ; - /** - * required int64 taskDuration = 2; - * - *
-       * in ms 
-       * 
- */ - public boolean hasTaskDuration() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * required int64 taskDuration = 2; - * - *
-       * in ms 
-       * 
- */ - public long getTaskDuration() { - return taskDuration_; - } - /** - * required int64 taskDuration = 2; - * - *
-       * in ms 
-       * 
- */ - public Builder setTaskDuration(long value) { - bitField0_ |= 0x00000002; - taskDuration_ = value; - onChanged(); - return this; - } - /** - * required int64 taskDuration = 2; - * - *
-       * in ms 
-       * 
- */ - public Builder clearTaskDuration() { - bitField0_ = (bitField0_ & ~0x00000002); - taskDuration_ = 0L; - onChanged(); - return this; - } - - // repeated int64 commandDuration = 3; - private java.util.List commandDuration_ = java.util.Collections.emptyList(); - private void ensureCommandDurationIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - commandDuration_ = new java.util.ArrayList(commandDuration_); - bitField0_ |= 0x00000004; - } - } - /** - * repeated int64 commandDuration = 3; - * - *
-       * in ms 
-       * 
- */ - public java.util.List - getCommandDurationList() { - return java.util.Collections.unmodifiableList(commandDuration_); - } - /** - * repeated int64 commandDuration = 3; - * - *
-       * in ms 
-       * 
- */ - public int getCommandDurationCount() { - return commandDuration_.size(); - } - /** - * repeated int64 commandDuration = 3; - * - *
-       * in ms 
-       * 
- */ - public long getCommandDuration(int index) { - return commandDuration_.get(index); - } - /** - * repeated int64 commandDuration = 3; - * - *
-       * in ms 
-       * 
- */ - public Builder setCommandDuration( - int index, long value) { - ensureCommandDurationIsMutable(); - commandDuration_.set(index, value); - onChanged(); - return this; - } - /** - * repeated int64 commandDuration = 3; - * - *
-       * in ms 
-       * 
- */ - public Builder addCommandDuration(long value) { - ensureCommandDurationIsMutable(); - commandDuration_.add(value); - onChanged(); - return this; - } - /** - * repeated int64 commandDuration = 3; - * - *
-       * in ms 
-       * 
- */ - public Builder addAllCommandDuration( - java.lang.Iterable values) { - ensureCommandDurationIsMutable(); - super.addAll(values, commandDuration_); - onChanged(); - return this; - } - /** - * repeated int64 commandDuration = 3; - * - *
-       * in ms 
-       * 
- */ - public Builder clearCommandDuration() { - commandDuration_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - return this; - } - - // required int64 workingDataSize = 4; - private long workingDataSize_ ; - /** - * required int64 workingDataSize = 4; - * - *
-       * in bytes
-       * 
- */ - public boolean hasWorkingDataSize() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * required int64 workingDataSize = 4; - * - *
-       * in bytes
-       * 
- */ - public long getWorkingDataSize() { - return workingDataSize_; - } - /** - * required int64 workingDataSize = 4; - * - *
-       * in bytes
-       * 
- */ - public Builder setWorkingDataSize(long value) { - bitField0_ |= 0x00000008; - workingDataSize_ = value; - onChanged(); - return this; - } - /** - * required int64 workingDataSize = 4; - * - *
-       * in bytes
-       * 
- */ - public Builder clearWorkingDataSize() { - bitField0_ = (bitField0_ & ~0x00000008); - workingDataSize_ = 0L; - onChanged(); - return this; - } - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - private java.util.List outputFile_ = - java.util.Collections.emptyList(); - private void ensureOutputFileIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - outputFile_ = new java.util.ArrayList(outputFile_); - bitField0_ |= 0x00000010; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFileOrBuilder> outputFileBuilder_; - - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public java.util.List getOutputFileList() { - if (outputFileBuilder_ == null) { - return java.util.Collections.unmodifiableList(outputFile_); - } else { - return outputFileBuilder_.getMessageList(); - } - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public int getOutputFileCount() { - if (outputFileBuilder_ == null) { - return outputFile_.size(); - } else { - return outputFileBuilder_.getCount(); - } - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile getOutputFile(int index) { - if (outputFileBuilder_ == null) { - return outputFile_.get(index); - } else { - return outputFileBuilder_.getMessage(index); - } - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder setOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile value) { - if (outputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOutputFileIsMutable(); - outputFile_.set(index, value); - onChanged(); - } else { - outputFileBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder setOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder builderForValue) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.set(index, builderForValue.build()); - onChanged(); - } else { - outputFileBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder addOutputFile(eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile value) { - if (outputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOutputFileIsMutable(); - outputFile_.add(value); - onChanged(); - } else { - outputFileBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder addOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile value) { - if (outputFileBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureOutputFileIsMutable(); - outputFile_.add(index, value); - onChanged(); - } else { - outputFileBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder addOutputFile( - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder builderForValue) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.add(builderForValue.build()); - onChanged(); - } else { - outputFileBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder addOutputFile( - int index, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder builderForValue) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.add(index, builderForValue.build()); - onChanged(); - } else { - outputFileBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder addAllOutputFile( - java.lang.Iterable values) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - super.addAll(values, outputFile_); - onChanged(); - } else { - outputFileBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder clearOutputFile() { - if (outputFileBuilder_ == null) { - outputFile_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - onChanged(); - } else { - outputFileBuilder_.clear(); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public Builder removeOutputFile(int index) { - if (outputFileBuilder_ == null) { - ensureOutputFileIsMutable(); - outputFile_.remove(index); - onChanged(); - } else { - outputFileBuilder_.remove(index); - } - return this; - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder getOutputFileBuilder( - int index) { - return getOutputFileFieldBuilder().getBuilder(index); - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFileOrBuilder getOutputFileOrBuilder( - int index) { - if (outputFileBuilder_ == null) { - return outputFile_.get(index); } else { - return outputFileBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public java.util.List - getOutputFileOrBuilderList() { - if (outputFileBuilder_ != null) { - return outputFileBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(outputFile_); - } - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder addOutputFileBuilder() { - return getOutputFileFieldBuilder().addBuilder( - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.getDefaultInstance()); - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder addOutputFileBuilder( - int index) { - return getOutputFileFieldBuilder().addBuilder( - index, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.getDefaultInstance()); - } - /** - * repeated .messages.TaskResult.OutputFile outputFile = 5; - */ - public java.util.List - getOutputFileBuilderList() { - return getOutputFileFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFileOrBuilder> - getOutputFileFieldBuilder() { - if (outputFileBuilder_ == null) { - outputFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFile.Builder, eu.itesla_project.computation.mpi.messages.Messages.TaskResult.OutputFileOrBuilder>( - outputFile_, - ((bitField0_ & 0x00000010) == 0x00000010), - getParentForChildren(), - isClean()); - outputFile_ = null; - } - return outputFileBuilder_; - } - - // @@protoc_insertion_point(builder_scope:messages.TaskResult) - } - - static { - defaultInstance = new TaskResult(true); - defaultInstance.initFields(); - } - - // @@protoc_insertion_point(class_scope:messages.TaskResult) - } - - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_CommonFile_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_CommonFile_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_Task_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_Task_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_Task_InputFile_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_Task_InputFile_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_Task_OutputFile_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_Task_OutputFile_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_Task_Variable_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_Task_Variable_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_Task_Environment_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_Task_Environment_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_Task_Command_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_Task_Command_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_TaskResult_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_TaskResult_fieldAccessorTable; - private static com.google.protobuf.Descriptors.Descriptor - internal_static_messages_TaskResult_OutputFile_descriptor; - private static - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_messages_TaskResult_OutputFile_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\016messages.proto\022\010messages\"E\n\nCommonFile" + - "\022\014\n\004name\030\001 \002(\t\022\r\n\005chunk\030\002 \002(\005\022\014\n\004last\030\003 " + - "\002(\010\022\014\n\004data\030\004 \002(\014\"\254\006\n\004Task\022\r\n\005jobId\030\001 \002(" + - "\005\022\r\n\005index\030\002 \002(\005\022\'\n\003env\030\003 \002(\0132\032.messages" + - ".Task.Environment\022\r\n\005cmdId\030\004 \002(\t\022\'\n\007comm" + - "and\030\005 \003(\0132\026.messages.Task.Command\022+\n\tinp" + - "utFile\030\006 \003(\0132\030.messages.Task.InputFile\022-" + - "\n\noutputFile\030\007 \003(\0132\031.messages.Task.Outpu" + - "tFile\022\017\n\007initJob\030\010 \002(\010\022\026\n\016completedJobId" + - "\030\t \003(\005\032\366\001\n\tInputFile\022\014\n\004name\030\001 \002(\t\022-\n\005sc", - "ope\030\002 \002(\0162\036.messages.Task.InputFile.Scop" + - "e\022\014\n\004data\030\003 \001(\014\022;\n\014preProcessor\030\004 \002(\0162%." + - "messages.Task.InputFile.PreProcessor\"<\n\014" + - "PreProcessor\022\010\n\004NONE\020\001\022\021\n\rARCHIVE_UNZIP\020" + - "\002\022\017\n\013FILE_GUNZIP\020\003\"#\n\005Scope\022\007\n\003RUN\020\001\022\007\n\003" + - "JOB\020\002\022\010\n\004TASK\020\003\032\204\001\n\nOutputFile\022\014\n\004name\030\001" + - " \002(\t\022>\n\rpostProcessor\030\002 \002(\0162\'.messages.T" + - "ask.OutputFile.PostProcessor\"(\n\rPostProc" + - "essor\022\010\n\004NONE\020\001\022\r\n\tFILE_GZIP\020\002\032\'\n\010Variab" + - "le\022\014\n\004name\030\001 \002(\t\022\r\n\005value\030\002 \002(\t\0328\n\013Envir", - "onment\022)\n\010variable\030\001 \003(\0132\027.messages.Task" + - ".Variable\032=\n\007Command\022\017\n\007program\030\001 \002(\t\022\020\n" + - "\010argument\030\002 \003(\t\022\017\n\007timeout\030\003 \001(\005\"\305\001\n\nTas" + - "kResult\022\020\n\010exitCode\030\001 \002(\005\022\024\n\014taskDuratio" + - "n\030\002 \002(\003\022\027\n\017commandDuration\030\003 \003(\003\022\027\n\017work" + - "ingDataSize\030\004 \002(\003\0223\n\noutputFile\030\005 \003(\0132\037." + - "messages.TaskResult.OutputFile\032(\n\nOutput" + - "File\022\014\n\004name\030\001 \002(\t\022\014\n\004data\030\002 \001(\014B6\n*eu.i" + - "tesla_project.computation.mpi.messagesB\010" + - "Messages" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - internal_static_messages_CommonFile_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_messages_CommonFile_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_CommonFile_descriptor, - new java.lang.String[] { "Name", "Chunk", "Last", "Data", }); - internal_static_messages_Task_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_messages_Task_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_Task_descriptor, - new java.lang.String[] { "JobId", "Index", "Env", "CmdId", "Command", "InputFile", "OutputFile", "InitJob", "CompletedJobId", }); - internal_static_messages_Task_InputFile_descriptor = - internal_static_messages_Task_descriptor.getNestedTypes().get(0); - internal_static_messages_Task_InputFile_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_Task_InputFile_descriptor, - new java.lang.String[] { "Name", "Scope", "Data", "PreProcessor", }); - internal_static_messages_Task_OutputFile_descriptor = - internal_static_messages_Task_descriptor.getNestedTypes().get(1); - internal_static_messages_Task_OutputFile_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_Task_OutputFile_descriptor, - new java.lang.String[] { "Name", "PostProcessor", }); - internal_static_messages_Task_Variable_descriptor = - internal_static_messages_Task_descriptor.getNestedTypes().get(2); - internal_static_messages_Task_Variable_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_Task_Variable_descriptor, - new java.lang.String[] { "Name", "Value", }); - internal_static_messages_Task_Environment_descriptor = - internal_static_messages_Task_descriptor.getNestedTypes().get(3); - internal_static_messages_Task_Environment_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_Task_Environment_descriptor, - new java.lang.String[] { "Variable", }); - internal_static_messages_Task_Command_descriptor = - internal_static_messages_Task_descriptor.getNestedTypes().get(4); - internal_static_messages_Task_Command_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_Task_Command_descriptor, - new java.lang.String[] { "Program", "Argument", "Timeout", }); - internal_static_messages_TaskResult_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_messages_TaskResult_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_TaskResult_descriptor, - new java.lang.String[] { "ExitCode", "TaskDuration", "CommandDuration", "WorkingDataSize", "OutputFile", }); - internal_static_messages_TaskResult_OutputFile_descriptor = - internal_static_messages_TaskResult_descriptor.getNestedTypes().get(0); - internal_static_messages_TaskResult_OutputFile_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_messages_TaskResult_OutputFile_descriptor, - new java.lang.String[] { "Name", "Data", }); - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/computation-mpi/src/main/proto/messages.proto b/computation-mpi/src/main/proto/messages.proto deleted file mode 100644 index 3459906f..00000000 --- a/computation-mpi/src/main/proto/messages.proto +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. -package messages; - -// Author: Geoffroy Jamgotchian - -option java_package = "eu.itesla_project.computation.mpi.messages"; -option java_outer_classname = "Messages"; - -message CommonFile { - required string name = 1; - required int32 chunk = 2; - required bool last = 3; - required bytes data = 4; -} - -message Task { - - message InputFile { - enum PreProcessor { - NONE = 1; - ARCHIVE_UNZIP = 2; - FILE_GUNZIP = 3; - } - - enum Scope { - RUN = 1; - JOB = 2; - TASK = 3; - } - - required string name = 1; - required Scope scope = 2; - optional bytes data = 3; - required PreProcessor preProcessor = 4; - } - - message OutputFile { - enum PostProcessor { - NONE = 1; - FILE_GZIP = 2; - } - - required string name = 1; - required PostProcessor postProcessor = 2; - } - - message Variable { - required string name = 1; - required string value = 2; - } - - message Environment { - repeated Variable variable = 1; - } - - message Command { - required string program = 1; - repeated string argument = 2; - optional int32 timeout = 3; - } - - required int32 jobId = 1; - required int32 index = 2; - required Environment env = 3; - required string cmdId = 4; - repeated Command command = 5; - repeated InputFile inputFile = 6; - repeated OutputFile outputFile = 7; - - required bool initJob = 8; - - // for cleanup - repeated int32 completedJobId = 9; -} - -message TaskResult { - message OutputFile { - required string name = 1; - optional bytes data = 2; - } - - required int32 exitCode = 1; - required int64 taskDuration = 2; // in ms - repeated int64 commandDuration = 3; // in ms - required int64 workingDataSize = 4; // in bytes - repeated OutputFile outputFile = 5; -} - diff --git a/computation-mpi/src/test/java/eu/itesla_project/computation/mpi/CorePoolTest.java b/computation-mpi/src/test/java/eu/itesla_project/computation/mpi/CorePoolTest.java deleted file mode 100755 index de319ba2..00000000 --- a/computation-mpi/src/test/java/eu/itesla_project/computation/mpi/CorePoolTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import java.util.Collections; -import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CorePoolTest { - - public CorePoolTest() { - } - - private CorePool pool; - - @Before - public void setUp() { - pool = new CorePool(); - MpiRank rank0 = new MpiRank(0); - MpiRank rank1 = new MpiRank(1); - pool.returnCore(new Core(rank0, 0)); - pool.returnCore(new Core(rank0, 1)); - pool.returnCore(new Core(rank1, 0)); - pool.returnCore(new Core(rank1, 1)); - } - - @After - public void tearDown() { - pool = null; - } - - @Test - public void testBorrowReturn() { - assertTrue(pool.availableCores() == 4); - List cores = pool.borrowCores(1); - assertTrue(cores.size() == 1); - assertTrue(pool.availableCores() == 3); - pool.returnCore(cores.get(0)); - assertTrue(pool.availableCores() == 4); - } - - @Test - public void testBorrowAll() { - assertTrue(pool.availableCores() == 4); - List allCores = pool.borrowCores(4); - assertTrue(allCores.size() == 4); - assertTrue(pool.availableCores() == 0); - pool.returnCores(allCores); - assertTrue(pool.availableCores() == 4); - } - - @Test - public void testBorrowMoreThanSizePool() { - assertTrue(pool.availableCores() == 4); - try { - pool.borrowCores(5); - } catch (Exception e) { - assertTrue(true); - } - } - - @Test - public void testPreferedCores() { - assertTrue(pool.availableCores() == 4); - List cores = pool.borrowCores(1, Collections.singleton(0)); - assertTrue(cores.size() == 1); - assertTrue(pool.availableCores() == 3); - pool.returnCore(cores.get(0)); - assertTrue(pool.availableCores() == 4); - } - - @Test - public void testPreferedCoresMixed() { - assertTrue(pool.availableCores() == 4); - List cores = pool.borrowCores(3, Collections.singleton(0)); - assertTrue(cores.size() == 3); - assertTrue(cores.get(0).rank.num == 0); - assertTrue(cores.get(1).rank.num == 0); - assertTrue(cores.get(2).rank.num == 1); - assertTrue(pool.availableCores() == 1); - pool.returnCores(cores); - assertTrue(pool.availableCores() == 4); - } -} diff --git a/computation-mpi/src/test/java/eu/itesla_project/computation/mpi/MpiComputationManagerTest.java b/computation-mpi/src/test/java/eu/itesla_project/computation/mpi/MpiComputationManagerTest.java deleted file mode 100644 index f3935777..00000000 --- a/computation-mpi/src/test/java/eu/itesla_project/computation/mpi/MpiComputationManagerTest.java +++ /dev/null @@ -1,269 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.mpi; - -import com.google.protobuf.ByteString; -import com.google.protobuf.InvalidProtocolBufferException; -import eu.itesla_project.computation.*; -import eu.itesla_project.computation.mpi.messages.Messages; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.nio.file.ShrinkWrapFileSystems; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.After; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.FileSystem; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class MpiComputationManagerTest { - - private static final String ID_CMD_1 = "cmd1"; - private static final String INPUT_FILE_NAME_1 = "in1.txt"; - private static final String INPUT_FILE_CONTENT_1 = "inputcontent1"; - private static final String OUTPUT_FILE_NAME_1 = "out1.txt"; - private static final String OUTPUT_FILE_CONTENT_1 = "outputcontent1"; - private static final String ID_CMD_2 = "cmd2"; - private static final String OUTPUT_FILE_NAME_2 = "out2.txt"; - private static final String OUTPUT_FILE_CONTENT_2 = "outputcontent2"; - - static class MpiNativeServicesMock implements MpiNativeServices { - - private static Messages.TaskResult createResultMessage(String fileName, String fileContent) { - return Messages.TaskResult.newBuilder() - .setExitCode(0) - .setTaskDuration(0) - .addCommandDuration(0) - .setWorkingDataSize(0) - .addOutputFile(Messages.TaskResult.OutputFile.newBuilder() - .setName(fileName) - .setData(ByteString.copyFromUtf8(fileContent)) - .build()) - .build(); - } - - @Override - public void checkTasksCompletion(List runningTasks, List completedTasks) { - for (MpiTask runningTask : runningTasks) { - try { - Messages.Task message = Messages.Task.parseFrom(runningTask.getMessage()); - switch (message.getCmdId()) { - case ID_CMD_1: - runningTask.setResultMessage(createResultMessage(OUTPUT_FILE_NAME_1, OUTPUT_FILE_CONTENT_1).toByteArray()); - completedTasks.add(runningTask); - break; - case ID_CMD_2: - runningTask.setResultMessage(createResultMessage(OUTPUT_FILE_NAME_2, OUTPUT_FILE_CONTENT_2).toByteArray()); - completedTasks.add(runningTask); - break; - } - } catch (InvalidProtocolBufferException e) { - e.printStackTrace(); - } - } - } - - @Override - public void initMpi(int coresPerRank, boolean verbose) { - } - - @Override - public void terminateMpi() { - } - - @Override - public String getMpiVersion() { - return "Mpi mock"; - } - - @Override - public int getMpiCommSize() { - return 2; - } - - @Override - public void sendCommonFile(byte[] message) { - } - - @Override - public void startTasks(List tasks) { - } - } - - private ComputationManager cm; - private FileSystem fileSystem; - - @Before - public void setUp() throws Exception { - JavaArchive archive = ShrinkWrap.create(JavaArchive.class); - fileSystem = ShrinkWrapFileSystems.newFileSystem(archive); - Path tmpDir = fileSystem.getPath("/tmp"); - Files.createDirectory(tmpDir); - cm = new MpiComputationManager(tmpDir, new MpiNativeServicesMock()); - } - - @After - public void tearDown() throws Exception { - cm.close(); - cm = null; - fileSystem.close(); - fileSystem = null; - } - - private static CommandExecution createParams1() { - return new CommandExecution(new SimpleCommandBuilder() - .id(ID_CMD_1) - .program("exec1") - .inputFiles(new InputFile(INPUT_FILE_NAME_1)) - .args(INPUT_FILE_NAME_1, OUTPUT_FILE_NAME_1) - .outputFiles(new OutputFile(OUTPUT_FILE_NAME_1)) - .build(), - 1); - } - - private static CommandExecution createParams2() { - return new CommandExecution(new SimpleCommandBuilder() - .id(ID_CMD_2) - .program("exec2") - .inputFiles(new InputFile(OUTPUT_FILE_NAME_1)) - .args(OUTPUT_FILE_NAME_1, OUTPUT_FILE_NAME_2) - .outputFiles(new OutputFile(OUTPUT_FILE_NAME_2)) - .build(), - 1); - } - - private static void writeInput1(Path workingDir) throws IOException { - try (BufferedWriter writer = Files.newBufferedWriter(workingDir.resolve(INPUT_FILE_NAME_1), StandardCharsets.UTF_8)) { - writer.write(INPUT_FILE_CONTENT_1); - writer.newLine(); - } - } - - private static String readOutput1(Path workingDir) throws IOException { - return new String(Files.readAllBytes(workingDir.resolve(OUTPUT_FILE_NAME_1)), StandardCharsets.UTF_8); - } - - private static String readOutput2(Path workingDir) throws IOException { - return new String(Files.readAllBytes(workingDir.resolve(OUTPUT_FILE_NAME_2)), StandardCharsets.UTF_8); - } - - private class ExecutionHandlerTest1 extends DefaultExecutionHandler { - @Override - public List before(Path workingDir) throws IOException { - writeInput1(workingDir); - return Arrays.asList(createParams1()); - } - - @Override - public String after(Path workingDir, ExecutionReport report) throws IOException { - report.log(); - return readOutput1(workingDir); - } - } - - private class ExecutionHandlerTest2 extends DefaultExecutionHandler { - @Override - public List before(Path workingDir) throws IOException { - writeInput1(workingDir); - return Arrays.asList(createParams1(), - createParams2()); - } - - @Override - public String after(Path workingDir, ExecutionReport report) throws IOException { - report.log(); - return readOutput2(workingDir); - } - } - - @Test - public void testExecute() throws Exception { - final Path[] workingDirSav = new Path[1]; - String result = cm.execute(ExecutionEnvironment.DEFAULT, new ExecutionHandlerTest1() { - @Override - public List before(Path workingDir) throws IOException { - workingDirSav[0] = workingDir; - return super.before(workingDir); - } - }).join(); - assertTrue(OUTPUT_FILE_CONTENT_1.equals(result)); - assertTrue(Files.notExists(workingDirSav[0])); - } - - @Test - public void testExecute2() throws Exception { - final Path[] workingDirSav = new Path[1]; - try { - cm.execute(ExecutionEnvironment.DEFAULT, new ExecutionHandlerTest1() { - @Override - public List before(Path workingDir) throws IOException { - workingDirSav[0] = workingDir; - throw new RuntimeException("test error"); - } - }).join(); - fail(); - } catch (Exception e) { - } - assertTrue(Files.notExists(workingDirSav[0])); - } - - @Test - public void testExecute3() throws Exception { - final Path[] workingDirSav = new Path[1]; - try { - cm.execute(ExecutionEnvironment.DEFAULT, new ExecutionHandlerTest1() { - @Override - public List before(Path workingDir) throws IOException { - workingDirSav[0] = workingDir; - return super.before(workingDir); - } - - @Override - public String after(Path workingDir, ExecutionReport report) throws IOException { - throw new RuntimeException("test error"); - } - }).join(); - fail(); - } catch (Exception e) { - } - assertTrue(Files.notExists(workingDirSav[0])); - } - - @Test - public void testExecute4() throws Exception { - final Path[] workingDirSav = new Path[1]; - String result = cm.execute(ExecutionEnvironment.DEFAULT, new ExecutionHandlerTest2() { - @Override - public List before(Path workingDir) throws IOException { - workingDirSav[0] = workingDir; - return super.before(workingDir); - } - - @Override - public String after(Path workingDir, ExecutionReport report) throws IOException { - String result = super.after(workingDir, report); - assertTrue(Files.exists(workingDir.resolve(OUTPUT_FILE_NAME_1))); - assertTrue(Files.exists(workingDir.resolve(OUTPUT_FILE_NAME_2))); - return result; - } - }).join(); - assertTrue(OUTPUT_FILE_CONTENT_2.equals(result)); - assertTrue(Files.notExists(workingDirSav[0])); - } - -} \ No newline at end of file diff --git a/computation/pom.xml b/computation/pom.xml deleted file mode 100644 index be9bd234..00000000 --- a/computation/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - 4.0.0 - - - eu.itesla_project - itesla-parent - 0.1-SNAPSHOT - - - computation - - Computation API - - - - org.slf4j - slf4j-api - - - com.google.guava - guava - - - joda-time - joda-time - - - diff --git a/computation/src/main/java/eu/itesla_project/computation/AbstractCommand.java b/computation/src/main/java/eu/itesla_project/computation/AbstractCommand.java deleted file mode 100644 index dcd792d8..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/AbstractCommand.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import com.google.common.base.Function; -import com.google.common.collect.Lists; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class AbstractCommand implements Command { - - protected final String id; - - protected final List inputFiles; - - protected final List outputFiles; - - protected AbstractCommand(String id, List inputFiles, List outputFiles) { - this.id = id; - this.inputFiles = inputFiles; - this.outputFiles = outputFiles; - } - - @Override - public String getId() { - return id; - } - - @Override - public List getInputFiles() { - return inputFiles; - } - - @Override - public List getInputFiles(final String executionNumber) { - return Lists.transform(inputFiles, new Function() { - @Override - public InputFile apply(InputFile file) { - return file.instanciate(executionNumber); - } - }); - } - - @Override - public List getOutputFiles() { - return outputFiles; - } - - @Override - public List getOutputFiles(final String executionNumber) { - return Lists.transform(outputFiles, new Function() { - @Override - public OutputFile apply(OutputFile file) { - return file.instanciate(executionNumber); - } - }); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/AbstractCommandBuilder.java b/computation/src/main/java/eu/itesla_project/computation/AbstractCommandBuilder.java deleted file mode 100644 index 8f907209..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/AbstractCommandBuilder.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class AbstractCommandBuilder> { - - protected String id; - - protected List inputFiles = Collections.emptyList(); - - protected List outputFiles = Collections.emptyList(); - - protected AbstractCommandBuilder() { - } - - public T id(String id) { - this.id = id; - return (T) this; - } - - public T inputFiles(List inputFiles) { - this.inputFiles = inputFiles; - return (T) this; - } - - public T inputFiles(InputFile... inputFiles) { - return inputFiles(Arrays.asList(inputFiles)); - } - - public T outputFiles(List outputFiles) { - this.outputFiles = outputFiles; - return (T) this; - } - - public T outputFiles(OutputFile... outputFiles) { - return outputFiles(Arrays.asList(outputFiles)); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/AbstractExecutionListener.java b/computation/src/main/java/eu/itesla_project/computation/AbstractExecutionListener.java deleted file mode 100644 index db2bdf48..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/AbstractExecutionListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class AbstractExecutionListener implements ExecutionListener { - - @Override - public void onExecutionStart(int fromExecutionIndex, int toExecutionIndex) { - } - - @Override - public void onExecutionCompletion(int executionIndex) { - } - - @Override - public void onEnd(ExecutionReport report) { - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/Command.java b/computation/src/main/java/eu/itesla_project/computation/Command.java deleted file mode 100644 index 7afbcf7e..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/Command.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Command { - - public static final String EXECUTION_NUMBER_PATTERN = "${EXEC_NUM}"; - - String getId(); - - CommandType getType(); - - List getInputFiles(); - - List getInputFiles(String executionNumber); - - List getOutputFiles(); - - List getOutputFiles(String executionNumber); - - // only used for display - String toString(String executionNumber); - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/CommandExecution.java b/computation/src/main/java/eu/itesla_project/computation/CommandExecution.java deleted file mode 100644 index 1d22bccd..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/CommandExecution.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.Map; -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CommandExecution { - - private final Command command; - - private final int executionCount; - - private final int priority; - - private final Map tags; - - public CommandExecution(Command command, int executionCount) { - this(command, executionCount, Integer.MAX_VALUE); - } - - public CommandExecution(Command command, int executionCount, int priority) { - this(command, executionCount, priority, null); - } - - public CommandExecution(Command command, int executionCount, int priority, Map tags) { - this.command = Objects.requireNonNull(command, "command is null"); - if (executionCount < 1) { - throw new IllegalArgumentException("execution count must be > 0"); - } - this.executionCount = executionCount; - this.priority = priority; - this.tags = tags; - } - - public Command getCommand() { - return command; - } - - public int getExecutionCount() { - return executionCount; - } - - public int getPriority() { - return priority; - } - - public Map getTags() { - return tags; - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/CommandExecutor.java b/computation/src/main/java/eu/itesla_project/computation/CommandExecutor.java deleted file mode 100644 index 5dd56395..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/CommandExecutor.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.nio.file.Path; - -/** - * - * @author Geoffroy Jamgotchian - */ -@Deprecated -public interface CommandExecutor extends AutoCloseable { - - @Deprecated - Path getWorkingDir(); - - @Deprecated - void start(CommandExecution execution, ExecutionListener listener) throws Exception; - - @Deprecated - ExecutionReport start(CommandExecution execution) throws Exception; - -} \ No newline at end of file diff --git a/computation/src/main/java/eu/itesla_project/computation/CommandType.java b/computation/src/main/java/eu/itesla_project/computation/CommandType.java deleted file mode 100644 index bfbb4cf4..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/CommandType.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum CommandType { - SIMPLE, - GROUP -} diff --git a/computation/src/main/java/eu/itesla_project/computation/ComputationManager.java b/computation/src/main/java/eu/itesla_project/computation/ComputationManager.java deleted file mode 100644 index a7954942..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/ComputationManager.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Path; -import java.util.Map; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.Executor; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ComputationManager extends AutoCloseable { - - String getVersion(); - - OutputStream newCommonFile(String fileName) throws IOException; - - @Deprecated - CommandExecutor newCommandExecutor(Map env, String workingDirPrefix, boolean debug) throws Exception; - - CompletableFuture execute(ExecutionEnvironment environment, ExecutionHandler handler); - - ComputationResourcesStatus getResourcesStatus(); - - Executor getExecutor(); - - Path getLocalDir(); -} diff --git a/computation/src/main/java/eu/itesla_project/computation/ComputationResourcesStatus.java b/computation/src/main/java/eu/itesla_project/computation/ComputationResourcesStatus.java deleted file mode 100644 index cc39d774..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/ComputationResourcesStatus.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.Map; -import org.joda.time.DateTime; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ComputationResourcesStatus { - - DateTime getDate(); - - int getAvailableCores(); - - int getBusyCores(); - - Map getBusyCoresPerApp(); - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/DefaultExecutionHandler.java b/computation/src/main/java/eu/itesla_project/computation/DefaultExecutionHandler.java deleted file mode 100644 index 7d1db42d..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/DefaultExecutionHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - * @param - */ -public abstract class DefaultExecutionHandler implements ExecutionHandler { - - @Override - public abstract List before(Path workingDir) throws IOException; - - @Override - public void onProgress(CommandExecution execution, int executionIndex) { - } - - @Override - public R after(Path workingDir, ExecutionReport report) throws IOException { - if (report.getErrors().size() > 0) { - report.log(); - throw new RuntimeException("Execution error"); - } - return null; - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/ExecutionEnvironment.java b/computation/src/main/java/eu/itesla_project/computation/ExecutionEnvironment.java deleted file mode 100644 index 68f4dea1..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/ExecutionEnvironment.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.Collections; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ExecutionEnvironment { - - public static final ExecutionEnvironment DEFAULT = new ExecutionEnvironment(Collections.emptyMap(), "itesla", false); - - private final Map variables; - - private final String workingDirPrefix; - - private final boolean debug; - - public ExecutionEnvironment(Map variables, String workingDirPrefix, boolean debug) { - this.variables = variables; - this.workingDirPrefix = workingDirPrefix; - this.debug = debug; - } - - public Map getVariables() { - return variables; - } - - public String getWorkingDirPrefix() { - return workingDirPrefix; - } - - public boolean isDebug() { - return debug; - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/ExecutionError.java b/computation/src/main/java/eu/itesla_project/computation/ExecutionError.java deleted file mode 100644 index 168208dd..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/ExecutionError.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ExecutionError { - - private final Command command; - - private final int index; - - private final int exitCode; - - public ExecutionError(Command command, int index, int exitCode) { - Objects.requireNonNull(command); - if (index < 0) { - throw new IllegalArgumentException("index < 1"); - } - this.command = command; - this.index = index; - this.exitCode = exitCode; - } - - public Command getCommand() { - return command; - } - - public int getIndex() { - return index; - } - - public int getExitCode() { - return exitCode; - } - - @Override - public String toString() { - return command.getId() + "[" + index + "]=" + exitCode; - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/ExecutionHandler.java b/computation/src/main/java/eu/itesla_project/computation/ExecutionHandler.java deleted file mode 100644 index 1c0b1858..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/ExecutionHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.io.IOException; -import java.nio.file.Path; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ExecutionHandler { - - List before(Path workingDir) throws IOException; - - void onProgress(CommandExecution execution, int executionIndex); - - R after(Path workingDir, ExecutionReport report) throws IOException; - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/ExecutionListener.java b/computation/src/main/java/eu/itesla_project/computation/ExecutionListener.java deleted file mode 100644 index 150f2d55..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/ExecutionListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ExecutionListener { - - void onExecutionStart(int fromExecutionIndex, int toExecutionIndex); - - void onExecutionCompletion(int executionIndex); - - void onEnd(ExecutionReport report); - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/ExecutionReport.java b/computation/src/main/java/eu/itesla_project/computation/ExecutionReport.java deleted file mode 100644 index 0f141762..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/ExecutionReport.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ExecutionReport { - - private static final Logger LOGGER = LoggerFactory.getLogger(ExecutionReport.class); - - private final List errors; - - public ExecutionReport(List errors) { - this.errors = errors; - } - - public List getErrors() { - return errors; - } - - public void log() { - if (errors.size() > 0) { - LOGGER.error("{} commands have failed: {}", errors.size(), errors); - if (LOGGER.isTraceEnabled()) { - for (ExecutionError error : errors) { - LOGGER.trace("Command {} exits with code {}", error.getCommand().toString(Integer.toString(error.getIndex())), error.getExitCode()); - } - } - } - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/FilePostProcessor.java b/computation/src/main/java/eu/itesla_project/computation/FilePostProcessor.java deleted file mode 100644 index d3e96d7c..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/FilePostProcessor.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum FilePostProcessor { - FILE_GZIP -} diff --git a/computation/src/main/java/eu/itesla_project/computation/FilePreProcessor.java b/computation/src/main/java/eu/itesla_project/computation/FilePreProcessor.java deleted file mode 100644 index d947d82e..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/FilePreProcessor.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum FilePreProcessor { - ARCHIVE_UNZIP, - FILE_GUNZIP -} diff --git a/computation/src/main/java/eu/itesla_project/computation/GroupCommand.java b/computation/src/main/java/eu/itesla_project/computation/GroupCommand.java deleted file mode 100644 index 6fc30547..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/GroupCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.List; - -/** - * Commands to be executed sequentially on a single computation node. - * - * @author Geoffroy Jamgotchian - */ -public interface GroupCommand extends Command { - - public interface SubCommand { - - String getProgram(); - - List getArgs(String executionNumber); - - int getTimeout(); - - // only used for display - String toString(String executionNumber); - - } - - List getSubCommands(); - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/GroupCommandBuilder.java b/computation/src/main/java/eu/itesla_project/computation/GroupCommandBuilder.java deleted file mode 100644 index 05e43f8b..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/GroupCommandBuilder.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import eu.itesla_project.computation.GroupCommand.SubCommand; -import eu.itesla_project.computation.GroupCommandImpl.SubCommandImpl; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class GroupCommandBuilder extends AbstractCommandBuilder { - - private final List subCommands = new ArrayList<>(); - - public class SubCommandBuilder { - - private String program; - - private List args = Collections.emptyList(); - - private int timeout = -1; - - public SubCommandBuilder program(String program) { - this.program = program; - return this; - } - - public SubCommandBuilder args(String... args) { - this.args = Arrays.asList(args); - return this; - } - - public SubCommandBuilder timeout(int timeout) { - if (timeout < -1 || timeout == 0) { - throw new RuntimeException("invalid timeout"); - } - this.timeout = timeout; - return this; - } - - public GroupCommandBuilder add() { - if (program == null) { - throw new RuntimeException("program is not set"); - } - subCommands.add(new SubCommandImpl(program, args, timeout)); - return GroupCommandBuilder.this; - } - - } - - public GroupCommandBuilder() { - } - - public SubCommandBuilder subCommand() { - return new SubCommandBuilder(); - } - - public GroupCommand build() { - if (id == null) { - throw new RuntimeException("id is not set"); - } - return new GroupCommandImpl(id, subCommands, inputFiles, outputFiles); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/GroupCommandImpl.java b/computation/src/main/java/eu/itesla_project/computation/GroupCommandImpl.java deleted file mode 100644 index 9d80216e..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/GroupCommandImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -class GroupCommandImpl extends AbstractCommand implements GroupCommand { - - private final List subCommands; - - static class SubCommandImpl implements SubCommand { - - private final String program; - - private final List args; - - private final int timeout; - - SubCommandImpl(String program, List args, int timeout) { - this.program = program; - this.args = args; - this.timeout = timeout; - } - - @Override - public String getProgram() { - return program; - } - - @Override - public List getArgs(final String executionNumber) { - return Lists.transform(args, new Function() { - @Override - public String apply(String args) { - return args.replace(EXECUTION_NUMBER_PATTERN, executionNumber); - } - }); - } - - @Override - public int getTimeout() { - return timeout; - } - - @Override - public String toString(String executionNumber) { - return ImmutableList.builder() - .add(program) - .addAll(getArgs(executionNumber)) - .build().toString(); - } - - } - - GroupCommandImpl(String id, List subCommands, - List inputFiles, List outputFiles) { - super(id, inputFiles, outputFiles); - this.subCommands = subCommands; - } - - @Override - public List getSubCommands() { - return subCommands; - } - - @Override - public CommandType getType() { - return CommandType.GROUP; - } - - @Override - public String toString(final String executionNumber) { - return Lists.transform(subCommands, new Function() { - @Override - public String apply(SubCommand subCommand) { - return subCommand.toString(executionNumber); - } - }).toString(); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/InputFile.java b/computation/src/main/java/eu/itesla_project/computation/InputFile.java deleted file mode 100644 index 46e9dbfe..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/InputFile.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.io.File; -import java.util.Objects; - -/** - * Command input file. - * - * @author Geoffroy Jamgotchian - */ -public class InputFile { - - private final String name; - - private final FilePreProcessor preProcessor; - - public InputFile(String name) { - this(name, null); - } - - public InputFile(String name, FilePreProcessor preProcessor) { - Objects.requireNonNull(name, "name is null"); - if (name.contains(File.separator)) { - throw new IllegalArgumentException("input file name must not contain directory path"); - } - if (preProcessor != null) { - switch (preProcessor) { - case FILE_GUNZIP: - if (!name.endsWith(".gz")) { - throw new IllegalArgumentException(name + " is exptected to end with .gz"); - } - break; - case ARCHIVE_UNZIP: - if (!name.endsWith(".zip")) { - throw new IllegalArgumentException(name + " is exptected to end with .zip"); - } - break; - default: - throw new InternalError(); - } - } - this.name = name; - this.preProcessor = preProcessor; - } - - public String getName() { - return name; - } - - public FilePreProcessor getPreProcessor() { - return preProcessor; - } - - public boolean dependsOnExecutionNumber() { - return name.contains(Command.EXECUTION_NUMBER_PATTERN); - } - - public InputFile instanciate(String executionNumber) { - return new InputFile(name.replace(Command.EXECUTION_NUMBER_PATTERN, executionNumber), preProcessor); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/OutputFile.java b/computation/src/main/java/eu/itesla_project/computation/OutputFile.java deleted file mode 100644 index 37c6aee4..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/OutputFile.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.ArrayList; -import java.util.List; - -/** - * Command output file. - * - * @author Geoffroy Jamgotchian - */ -public class OutputFile { - - private final String name; - - private final FilePostProcessor postProcessor; - - public static List of(String... fileNames) { - List outputFiles = new ArrayList<>(fileNames.length); - for (String fileName : fileNames) { - outputFiles.add(new OutputFile(fileName)); - } - return outputFiles; - } - - public OutputFile(String name) { - this(name, null); - } - - public OutputFile(String name, FilePostProcessor postProcessor) { - this.name = name; - this.postProcessor = postProcessor; - } - - public String getName() { - return name; - } - - public FilePostProcessor getPostProcessor() { - return postProcessor; - } - - public boolean dependsOnExecutionNumber() { - return name.contains(Command.EXECUTION_NUMBER_PATTERN); - } - - public OutputFile instanciate(String executionNumber) { - return new OutputFile(name.replace(Command.EXECUTION_NUMBER_PATTERN, executionNumber), postProcessor); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/SimpleCommand.java b/computation/src/main/java/eu/itesla_project/computation/SimpleCommand.java deleted file mode 100644 index a1f8bc6a..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/SimpleCommand.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface SimpleCommand extends Command { - - String getProgram(); - - List getArgs(String executionNumber); - - int getTimeout(); - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/SimpleCommandBuilder.java b/computation/src/main/java/eu/itesla_project/computation/SimpleCommandBuilder.java deleted file mode 100644 index cba076f0..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/SimpleCommandBuilder.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class SimpleCommandBuilder extends AbstractCommandBuilder { - - private String program; - - private List args = Collections.emptyList(); - - private int timeout = -1; - - public SimpleCommandBuilder() { - } - - public SimpleCommandBuilder program(String program) { - this.program = program; - return this; - } - - public SimpleCommandBuilder args(List args) { - this.args = args; - return this; - } - - public SimpleCommandBuilder args(String... args) { - this.args = Arrays.asList(args); - return this; - } - - public SimpleCommandBuilder timeout(int timeout) { - this.timeout = timeout; - if (timeout < -1 || timeout == 0) { - throw new RuntimeException("invalid timeout"); - } - return this; - } - - public SimpleCommand build() { - if (id == null) { - throw new RuntimeException("id is not set"); - } - if (program == null) { - throw new RuntimeException("program is not set"); - } - return new SimpleCommandImpl(id, program, args, timeout, inputFiles, outputFiles); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/SimpleCommandImpl.java b/computation/src/main/java/eu/itesla_project/computation/SimpleCommandImpl.java deleted file mode 100644 index 0d2c64fc..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/SimpleCommandImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation; - -import com.google.common.base.Function; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -class SimpleCommandImpl extends AbstractCommand implements SimpleCommand { - - private final String program; - - private final List args; - - private final int timeout; - - SimpleCommandImpl(String id, String program, List args, int timeout, - List inputFiles, List outputFiles) { - super(id, inputFiles, outputFiles); - this.program = program; - this.args = args; - this.timeout = timeout; - } - - @Override - public CommandType getType() { - return CommandType.SIMPLE; - } - - @Override - public String getProgram() { - return program; - } - - @Override - public List getArgs(final String executionNumber) { - return Lists.transform(args, new Function() { - @Override - public String apply(String args) { - return args.replace(EXECUTION_NUMBER_PATTERN, executionNumber); - } - }); - } - - @Override - public int getTimeout() { - return timeout; - } - - @Override - public String toString(String executionNumber) { - return ImmutableList.builder() - .add(program) - .addAll(getArgs(executionNumber)) - .build().toString(); - } - -} diff --git a/computation/src/main/java/eu/itesla_project/computation/util/AbstractExecutor.java b/computation/src/main/java/eu/itesla_project/computation/util/AbstractExecutor.java deleted file mode 100644 index 1855a243..00000000 --- a/computation/src/main/java/eu/itesla_project/computation/util/AbstractExecutor.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.computation.util; - -import java.util.concurrent.locks.ReentrantLock; - -/** - * - * @author Geoffroy Jamgotchian - */ -public abstract class AbstractExecutor { - - private final ReentrantLock runLock = new ReentrantLock(); - - private boolean initialized = false; - - private boolean shutdownRequested = false; - - private int runCounter = 0; - - protected void startInit() throws Exception { - runLock.lock(); - try { - if (initialized) { - throw new IllegalStateException("Module is already initialized"); - } - } finally { - runLock.unlock(); - } - } - - protected void endInit() throws Exception { - runLock.lock(); - try { - initialized = true; - } finally { - runLock.unlock(); - } - } - - abstract protected void clean() throws Exception; - - protected void startRun() throws Exception { - runLock.lock(); - try { - if (!initialized) { - throw new IllegalStateException("Module is not initialized"); - } - if (shutdownRequested) { - throw new IllegalStateException("Module has been shutdown"); - } - runCounter++; - } finally { - runLock.unlock(); - } - } - - protected void endRun() throws Exception { - runLock.lock(); - try { - runCounter--; - if (shutdownRequested && runCounter == 0) { - clean(); - } - } finally { - runLock.unlock(); - } - } - - public void close() throws Exception { - runLock.lock(); - try { - shutdownRequested = true; - if (runCounter == 0) { - clean(); - } - } finally { - runLock.unlock(); - } - } -} diff --git a/config/logback-cmdline.xml b/config/logback-cmdline.xml deleted file mode 100644 index 16d141e3..00000000 --- a/config/logback-cmdline.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - %d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - diff --git a/contingency-api/pom.xml b/contingency-api/pom.xml deleted file mode 100644 index 72737616..00000000 --- a/contingency-api/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - 4.0.0 - - contingency-api - - Contingency API - - - - eu.itesla_project - iidm-network-api - ${project.version} - - - - \ No newline at end of file diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProvider.java b/contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProvider.java deleted file mode 100644 index e585b3f2..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -import eu.itesla_project.iidm.network.Network; - -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - */ -public interface ContingenciesProvider { - - List getContingencies(Network network); - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProviderFactory.java b/contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProviderFactory.java deleted file mode 100644 index 347b3608..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingenciesProviderFactory.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -/** - * @author Geoffroy Jamgotchian - */ -public interface ContingenciesProviderFactory { - - T create(); -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/Contingency.java b/contingency-api/src/main/java/eu/itesla_project/contingency/Contingency.java deleted file mode 100644 index 59586ded..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/Contingency.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -import java.util.Collection; - -import eu.itesla_project.contingency.tasks.ModificationTask; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Contingency { - - String getId(); - - Collection getElements(); - - ModificationTask toTask(); - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElement.java b/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElement.java deleted file mode 100644 index b36d6d21..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElement.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -import eu.itesla_project.contingency.tasks.ModificationTask; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ContingencyElement { - - String getId(); - - ContingencyElementType getType(); - - ModificationTask toTask(); - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElementType.java b/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElementType.java deleted file mode 100644 index f9c3f8ff..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyElementType.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -/** - * @author Geoffroy Jamgotchian - */ -public enum ContingencyElementType { - LINE, - GENERATOR -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyImpl.java b/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyImpl.java deleted file mode 100644 index 5b61ec16..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/ContingencyImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import eu.itesla_project.contingency.tasks.CompoundModificationTask; -import eu.itesla_project.contingency.tasks.ModificationTask; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ContingencyImpl implements Contingency { - - private final String id; - - private final List elements; - - public ContingencyImpl(String id, ContingencyElement elements) { - this(id, Arrays.asList(elements)); - } - - public ContingencyImpl(String id, List elements) { - this.id = id; - this.elements = elements; - } - - @Override - public String getId() { - return id; - } - - @Override - public Collection getElements() { - return elements; - } - - @Override - public ModificationTask toTask() { - List subTasks = new ArrayList<>(elements.size()); - for (ContingencyElement element : elements) { - subTasks.add(element.toTask()); - } - return new CompoundModificationTask(subTasks); - } - - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/GeneratorContingency.java b/contingency-api/src/main/java/eu/itesla_project/contingency/GeneratorContingency.java deleted file mode 100644 index 9e651855..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/GeneratorContingency.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -import eu.itesla_project.contingency.tasks.GeneratorTripping; -import eu.itesla_project.contingency.tasks.ModificationTask; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class GeneratorContingency implements ContingencyElement { - - private final String id; - - public GeneratorContingency(String id) { - this.id = id; - } - - @Override - public String getId() { - return id; - } - - @Override - public ContingencyElementType getType() { - return ContingencyElementType.GENERATOR; - } - - @Override - public ModificationTask toTask() { - return new GeneratorTripping(id); - } - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/LineContingency.java b/contingency-api/src/main/java/eu/itesla_project/contingency/LineContingency.java deleted file mode 100644 index 40a0aba5..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/LineContingency.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency; - -import eu.itesla_project.contingency.tasks.BranchTripping; -import eu.itesla_project.contingency.tasks.ModificationTask; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class LineContingency implements ContingencyElement { - - private final String id; - - public LineContingency(String id) { - this.id = id; - } - - @Override - public String getId() { - return id; - } - - @Override - public ContingencyElementType getType() { - return ContingencyElementType.LINE; - } - - @Override - public ModificationTask toTask() { - return new BranchTripping(id); - } - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderFactoryMock.java b/contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderFactoryMock.java deleted file mode 100644 index 890afe01..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderFactoryMock.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency.mock; - -import eu.itesla_project.contingency.ContingenciesProvider; -import eu.itesla_project.contingency.ContingenciesProviderFactory; - -/** - * @author Mathieu Bague - */ -public class ContingenciesProviderFactoryMock implements ContingenciesProviderFactory { - - @Override - public ContingenciesProvider create() { - return new ContingenciesProviderMock(); - } -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderMock.java b/contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderMock.java deleted file mode 100644 index c4507d35..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/mock/ContingenciesProviderMock.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency.mock; - -import eu.itesla_project.contingency.ContingenciesProvider; -import eu.itesla_project.contingency.Contingency; -import eu.itesla_project.iidm.network.Network; - -import java.util.Collections; -import java.util.List; - -/** - * @author Mathieu Bague - */ -class ContingenciesProviderMock implements ContingenciesProvider { - - @Override - public List getContingencies(Network network) { - return Collections.emptyList(); - } -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/BranchTripping.java b/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/BranchTripping.java deleted file mode 100644 index 56bcc589..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/BranchTripping.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency.tasks; - -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.TwoTerminalsConnectable; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class BranchTripping implements ModificationTask { - - private final String branchId; - private String substationId = null; - - public BranchTripping(String branchId) { - this.branchId = branchId; - } - - public BranchTripping(String branchId, String substationId) { - this.branchId = branchId; - this.substationId = substationId; - } - - @Override - public void modify(Network network) { - TwoTerminalsConnectable branch = network.getLine(branchId); - if (branch == null) { - branch = network.getTwoWindingsTransformer(branchId); - if (branch == null) { - throw new ITeslaException("Branch '" + branchId + "' not found"); - } - } - if ( substationId != null ) { - if ( substationId.equalsIgnoreCase(branch.getTerminal1().getVoltageLevel().getSubstation().getId()) ) - branch.getTerminal1().disconnect(); - else if ( substationId.equalsIgnoreCase(branch.getTerminal2().getVoltageLevel().getSubstation().getId()) ) - branch.getTerminal2().disconnect(); - else - throw new ITeslaException("Substation '" + substationId + "' not connected to branch '" + branchId + "'"); - } else { - branch.getTerminal1().disconnect(); - branch.getTerminal2().disconnect(); - } - } - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/CompoundModificationTask.java b/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/CompoundModificationTask.java deleted file mode 100644 index 2becd65a..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/CompoundModificationTask.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency.tasks; - -import eu.itesla_project.iidm.network.Network; -import java.util.Arrays; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CompoundModificationTask implements ModificationTask { - - private final List subTasks; - - public CompoundModificationTask(List subTasks) { - this.subTasks = subTasks; - } - - public CompoundModificationTask(ModificationTask... subTasks) { - this(Arrays.asList(subTasks)); - } - - @Override - public void modify(Network network) { - for (ModificationTask subTask : subTasks) { - subTask.modify(network); - } - } - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/GeneratorTripping.java b/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/GeneratorTripping.java deleted file mode 100644 index 59a3c4e8..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/GeneratorTripping.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency.tasks; - -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.Generator; -import eu.itesla_project.iidm.network.Network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class GeneratorTripping implements ModificationTask { - - private final String generatorId; - - public GeneratorTripping(String generatorId) { - this.generatorId = generatorId; - } - - @Override - public void modify(Network network) { - Generator g = network.getGenerator(generatorId); - if (g == null) { - throw new ITeslaException("Generator '" + generatorId + "' not found"); - } - g.getTerminal().disconnect(); - } - -} diff --git a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/ModificationTask.java b/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/ModificationTask.java deleted file mode 100644 index 0e222a5a..00000000 --- a/contingency-api/src/main/java/eu/itesla_project/contingency/tasks/ModificationTask.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.contingency.tasks; - -import eu.itesla_project.iidm.network.Network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ModificationTask { - - void modify(Network network); - -} diff --git a/distribution/pom.xml b/distribution/pom.xml index 658b54de..38deb6a0 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -48,11 +48,6 @@ ucte-import ${project.version}
- - eu.itesla_project - iidm-xml-converter - ${project.version} - @@ -159,7 +154,6 @@ ${project.version} -
diff --git a/distribution/src/main/resources/assemblies/full.xml b/distribution/src/main/resources/assemblies/full.xml index 75a29e74..1c3f82b9 100644 --- a/distribution/src/main/resources/assemblies/full.xml +++ b/distribution/src/main/resources/assemblies/full.xml @@ -66,16 +66,6 @@ 0644 - - - ${project.basedir}/../iidm-xml-import-export/src/main/resources - etc - - xsd/iidm.xsd - - 0644 - - ${project.basedir}/../target/site/apidocs @@ -92,3 +82,4 @@ + diff --git a/entsoe-util/pom.xml b/entsoe-util/pom.xml index 9e64f072..406cdbca 100644 --- a/entsoe-util/pom.xml +++ b/entsoe-util/pom.xml @@ -24,14 +24,25 @@ Utilities for working with ENTSO-E data + + com.google.guava + guava + + + joda-time + joda-time + org.apache.poi poi-ooxml + + ${project.groupId} + commons + ${project.groupId} iidm-network-api - ${project.version} junit diff --git a/eurostag-ech-export/pom.xml b/eurostag-ech-export/pom.xml index a5a387ff..c3078caf 100644 --- a/eurostag-ech-export/pom.xml +++ b/eurostag-ech-export/pom.xml @@ -21,20 +21,25 @@ Eurostag ech export + + org.slf4j + slf4j-api + + + ${project.groupId} + commons + ${project.groupId} iidm-network-api - ${project.version} + ${project.groupId} eurostag-network ${project.version} - - org.slf4j - slf4j-api - + junit junit @@ -48,13 +53,16 @@ eu.itesla_project iidm-network-impl - ${project.version} + test + + + eu.itesla_project + graph test eu.itesla_project iidm-network-test - ${project.version} test diff --git a/eurostag-step-up-transformer/pom.xml b/eurostag-step-up-transformer/pom.xml index c56976f8..1fcce634 100644 --- a/eurostag-step-up-transformer/pom.xml +++ b/eurostag-step-up-transformer/pom.xml @@ -24,12 +24,12 @@ - junit - junit + com.google.auto.service + auto-service - org.slf4j - slf4j-api + org.apache.commons + commons-math3 org.jboss.shrinkwrap @@ -40,29 +40,36 @@ shrinkwrap-api - ${project.groupId} - iidm-network-api - ${project.version} + org.slf4j + slf4j-api + + + eu.itesla_project + commons ${project.groupId} iidm-converter-api - ${project.version} ${project.groupId} loadflow-api - ${project.version} ${project.groupId} - iidm-network-impl - ${project.version} - test + iidm-network-api org.slf4j slf4j-simple + + + junit + junit + + + ${project.groupId} + iidm-network-impl test diff --git a/graph/pom.xml b/graph/pom.xml deleted file mode 100644 index 8b8dc827..00000000 --- a/graph/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - 4.0.0 - - - eu.itesla_project - itesla-parent - 0.1-SNAPSHOT - - - graph - 0.1-SNAPSHOT - - Graph - This is a library that provides mathematical graph models and algorithms - - - - com.google.guava - guava - - - net.sf.trove4j - trove4j - - - junit - junit - - - ${project.groupId} - commons - ${project.version} - - - diff --git a/graph/src/main/java/eu/itesla_project/graph/GraphUtil.java b/graph/src/main/java/eu/itesla_project/graph/GraphUtil.java deleted file mode 100644 index 0372ee12..00000000 --- a/graph/src/main/java/eu/itesla_project/graph/GraphUtil.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.graph; - -import gnu.trove.list.array.TIntArrayList; -import java.util.Arrays; -import java.util.Comparator; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class GraphUtil { - - private GraphUtil() { - } - - private static class ConnectedComponent { - - private final int size; - - private int orderedNumber; - - private ConnectedComponent(int size) { - this.size = size; - } - - } - - public static class ConnectedComponentsComputationResult { - - private final int[] componentNumber; - - private final int[] componentSize; - - public ConnectedComponentsComputationResult(int[] componentNumber, int[] orderedComponents) { - this.componentNumber = componentNumber; - this.componentSize = orderedComponents; - } - - public int[] getComponentNumber() { - return componentNumber; - } - - public int[] getComponentSize() { - return componentSize; - } - - } - - private static void computeConnectedComponents(int v1, int c, int[] componentSize, TIntArrayList[] adjacencyList, int[] componentNumber) { - componentNumber[v1] = c; - ++componentSize[c]; - TIntArrayList ls = adjacencyList[v1]; - for (int i = 0; i < ls.size(); i++) { - int v2 = ls.getQuick(i); - if (componentNumber[v2] == -1) { - computeConnectedComponents(v2, c, componentSize, adjacencyList, componentNumber); - } - } - } - - public static ConnectedComponentsComputationResult computeConnectedComponents(TIntArrayList[] adjacencyList) { - int[] componentNumber = new int[adjacencyList.length]; - Arrays.fill(componentNumber, -1); - int c = 0; - int[] componentSize = new int[adjacencyList.length]; - Arrays.fill(componentSize, 0); - for (int v = 0; v < adjacencyList.length; v++) { - if (componentNumber[v] == -1) { - computeConnectedComponents(v, c++, componentSize, adjacencyList, componentNumber); - } - } - - // sort components by size - ConnectedComponent[] components = new ConnectedComponent[c]; - ConnectedComponent[] orderedComponents = new ConnectedComponent[c]; - for (int i = 0; i < c; i++) { - ConnectedComponent comp = new ConnectedComponent(componentSize[i]); - components[i] = comp; - orderedComponents[i] = comp; - } - Arrays.sort(orderedComponents, new Comparator() { - @Override - public int compare(ConnectedComponent o1, ConnectedComponent o2) { - return o2.size - o1.size; - } - }); - for (int i = 0; i < orderedComponents.length; i++) { - orderedComponents[i].orderedNumber = i; - } - - componentSize = new int[orderedComponents.length]; - for (ConnectedComponent cc : orderedComponents) { - componentSize[cc.orderedNumber] = cc.size; - } - for (int i = 0; i < componentNumber.length; i++) { - ConnectedComponent cc = components[componentNumber[i]]; - componentNumber[i] = cc.orderedNumber; - } - - return new ConnectedComponentsComputationResult(componentNumber, componentSize); - } -} diff --git a/graph/src/main/java/eu/itesla_project/graph/TraverseResult.java b/graph/src/main/java/eu/itesla_project/graph/TraverseResult.java deleted file mode 100644 index 3c70253f..00000000 --- a/graph/src/main/java/eu/itesla_project/graph/TraverseResult.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.graph; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum TraverseResult { - CONTINUE, - TERMINATE -} diff --git a/graph/src/main/java/eu/itesla_project/graph/Traverser.java b/graph/src/main/java/eu/itesla_project/graph/Traverser.java deleted file mode 100644 index a83ce625..00000000 --- a/graph/src/main/java/eu/itesla_project/graph/Traverser.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.graph; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Traverser { - - TraverseResult traverse(int v1, int e, int v2); -} diff --git a/graph/src/main/java/eu/itesla_project/graph/UndirectedGraph.java b/graph/src/main/java/eu/itesla_project/graph/UndirectedGraph.java deleted file mode 100644 index 692d2eea..00000000 --- a/graph/src/main/java/eu/itesla_project/graph/UndirectedGraph.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.graph; - -import com.google.common.base.Function; -import gnu.trove.list.array.TIntArrayList; - -import java.io.PrintStream; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface UndirectedGraph { - - int addVertex(); - - V removeVertex(int v); - - int getVertexCount(); - - int addEdge(int v1, int v2, E obj); - - E removeEdge(int e); - - void removeAllEdges(); - - int getEdgeCount(); - - int[] getVertices(); - - int getMaxVertex(); - - Iterable getVerticesObj(); - - V getVertexObject(int v); - - void setVertexObject(int v, V obj); - - int getEdgeVertex1(int e); - - int getEdgeVertex2(int e); - - void removeAllVertices(); - - Iterable getEdgesObject(); - - E getEdgeObject(int e); - - List getEdgeObjects(int v1, int v2); - - void traverse(int v, Traverser traverser, boolean[] encountered); - - void traverse(int v, Traverser traverser); - - List findAllPaths(int from, Function pathComplete, Function pathCanceled); - - void addListener(UndirectedGraphListener l); - - void removeListener(UndirectedGraphListener l); - - void print(PrintStream out, Function vertexToString, Function edgeToString); -} diff --git a/graph/src/main/java/eu/itesla_project/graph/UndirectedGraphImpl.java b/graph/src/main/java/eu/itesla_project/graph/UndirectedGraphImpl.java deleted file mode 100644 index 244911e1..00000000 --- a/graph/src/main/java/eu/itesla_project/graph/UndirectedGraphImpl.java +++ /dev/null @@ -1,461 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.graph; - -import com.google.common.base.Function; -import com.google.common.base.Predicates; -import com.google.common.collect.FluentIterable; -import eu.itesla_project.commons.ITeslaException; -import gnu.trove.list.array.TIntArrayList; -import gnu.trove.list.linked.TIntLinkedList; - -import java.io.PrintStream; -import java.util.*; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class UndirectedGraphImpl implements UndirectedGraph { - - private static final int VERTICES_CAPACITY = 10; - - private static final int EDGES_CAPACITY = 15; - - private static final int NEIGHBORS_CAPACITY = 2; - - private static class Vertex { - - private E object; - - public E getObject() { - return object; - } - - public void setObject(E object) { - this.object = object; - } - - } - - private static class Edge { - - private final int v1; - - private final int v2; - - private E object; - - private Edge(int v1, int v2, E object) { - this.v1 = v1; - this.v2 = v2; - this.object = object; - } - - public int getV1() { - return v1; - } - - public int getV2() { - return v2; - } - - public E getObject() { - return object; - } - - public void setObject(E object) { - this.object = object; - } - - @Override - public String toString() { - return object.toString(); - } - - } - - /* vertices */ - private final List> vertices = new ArrayList<>(VERTICES_CAPACITY); - - /* edges */ - private final List> edges = new ArrayList<>(EDGES_CAPACITY); - - /* cached adjacency list */ - private TIntArrayList[] adjacencyListCache; - - private final Lock adjacencyListCacheLock = new ReentrantLock(); - - private final TIntLinkedList removedVertices = new TIntLinkedList(); - - private final TIntLinkedList removedEdges = new TIntLinkedList(); - - private final List listeners = new CopyOnWriteArrayList<>(); - - public UndirectedGraphImpl() { - } - - private void checkVertex(int v) { - if (v < 0 || v >= vertices.size() || vertices.get(v) == null) { - throw new ITeslaException("Vertex " + v + " not found"); - } - } - - private void checkEdge(int e) { - if (e < 0 || e >= edges.size() || edges.get(e) == null) { - throw new ITeslaException("Edge " + e + " not found"); - } - } - - @Override - public int addVertex() { - int v; - if (removedVertices.isEmpty()) { - v = vertices.size(); - vertices.add(new Vertex()); - } else { - v = removedVertices.removeAt(0); - } - invalidateAdjacencyList(); - notifyListener(); - return v; - } - - @Override - public V removeVertex(int v) { - checkVertex(v); - for (Edge e : edges) { - if (e.getV1() == v || e.getV2() == v) { - throw new RuntimeException("An edge is connected to vertex " + v); - } - } - V obj = vertices.get(v).getObject(); - if (v == vertices.size()-1) { - vertices.remove((int) v); - } else { - vertices.set(v, null); - removedVertices.add(v); - } - invalidateAdjacencyList(); - notifyListener(); - return obj; - } - - @Override - public int getVertexCount() { - return vertices.size() - removedVertices.size(); - } - - @Override - public void removeAllVertices() { - if (edges.size() > 0) { - throw new RuntimeException("Cannot remove all vertices because there is still some edges in the graph"); - } - vertices.clear(); - invalidateAdjacencyList(); - notifyListener(); - } - - @Override - public int addEdge(int v1, int v2, E obj) { - checkVertex(v1); - checkVertex(v2); - int e; - Edge edge = new Edge<>(v1, v2, obj); - if (removedEdges.isEmpty()) { - e = edges.size(); - edges.add(edge); - } else { - e = removedEdges.removeAt(0); - edges.set(e, edge); - } - invalidateAdjacencyList(); - notifyListener(); - return e; - } - - @Override - public E removeEdge(int e) { - checkEdge(e); - E obj = edges.get(e).getObject(); - if (e == edges.size()-1) { - edges.remove((int) e); - } else { - edges.set(e, null); - removedEdges.add(e); - } - invalidateAdjacencyList(); - notifyListener(); - return obj; - } - - @Override - public void removeAllEdges() { - edges.clear(); - removedEdges.clear(); - invalidateAdjacencyList(); - notifyListener(); - } - - @Override - public int getEdgeCount() { - return edges.size() - removedEdges.size(); - } - - @Override - public int[] getVertices() { - TIntArrayList t = new TIntArrayList(vertices.size()); - for (int i = 0; i < vertices.size(); i++) { - if (vertices.get(i) != null) { - t.add(i); - } - } - return t.toArray(); - } - - @Override - public int getMaxVertex() { - return vertices.size(); - } - - @Override - public Iterable getVerticesObj() { - return FluentIterable.from(vertices) - .filter(Predicates.notNull()) - .transform(Vertex::getObject); - } - - @Override - public V getVertexObject(int v) { - checkVertex(v); - return vertices.get(v).getObject(); - } - - @Override - public void setVertexObject(int v, V obj) { - checkVertex(v); - vertices.get(v).setObject(obj); - } - - @Override - public int getEdgeVertex1(int e) { - checkEdge(e); - return edges.get(e).getV1(); - } - - @Override - public int getEdgeVertex2(int e) { - checkEdge(e); - return edges.get(e).getV2(); - } - - @Override - public Iterable getEdgesObject() { - return FluentIterable.from(edges) - .filter(Predicates.notNull()) - .transform(Edge::getObject); - } - - @Override - public E getEdgeObject(int e) { - checkEdge(e); - return edges.get(e).getObject(); - } - - @Override - public List getEdgeObjects(int v1, int v2) { - checkVertex(v1); - checkVertex(v2); - List edgeObjects = new ArrayList<>(1); - TIntArrayList[] adjacencyList = getAdjacencyList(); - TIntArrayList adjacentEdges = adjacencyList[v1]; - for (int i = 0; i < adjacentEdges.size(); i++) { - int e = adjacentEdges.getQuick(i); - Edge edge = edges.get(e); - if ((edge.getV1() == v1 && edge.getV2() == v2) - || (edge.getV1() == v2 && edge.getV2() == v1)) { - edgeObjects.add(edge.getObject()); - } - } - return edgeObjects; - } - - private TIntArrayList[] getAdjacencyList() { - adjacencyListCacheLock.lock(); - try { - if (adjacencyListCache == null) { - adjacencyListCache = new TIntArrayList[vertices.size()]; - for (int v = 0; v < vertices.size(); v++) { - Vertex vertex = vertices.get(v); - if (vertex != null) { - adjacencyListCache[v] = new TIntArrayList(NEIGHBORS_CAPACITY); - } - } - for (int e = 0; e < edges.size(); e++) { - Edge edge = edges.get(e); - if (edge != null) { - int v1 = edge.getV1(); - int v2 = edge.getV2(); - adjacencyListCache[v1].add(e); - adjacencyListCache[v2].add(e); - } - } - } - return adjacencyListCache; - } finally { - adjacencyListCacheLock.unlock(); - } - } - - private void invalidateAdjacencyList() { - adjacencyListCache = null; - } - - @Override - public void traverse(int v, Traverser traverser, boolean[] encountered) { - checkVertex(v); - TIntArrayList[] adjacencyList = getAdjacencyList(); - TIntArrayList adjacentEdges = adjacencyList[v]; - encountered[v] = true; - for (int i = 0; i < adjacentEdges.size(); i++) { - int e = adjacentEdges.getQuick(i); - Edge edge = edges.get(e); - int v1 = edge.getV1(); - int v2 = edge.getV2(); - if (!encountered[v1]) { - if (traverser.traverse(v2, e, v1) == TraverseResult.CONTINUE) { - encountered[v1] = true; - traverse(v1, traverser, encountered); - } - } else if (!encountered[v2]) { - if (traverser.traverse(v1, e, v2) == TraverseResult.CONTINUE) { - encountered[v2] = true; - traverse(v2, traverser, encountered); - } - } - } - } - - @Override - public void traverse(int v, Traverser traverser) { - boolean[] encountered = new boolean[vertices.size()]; - Arrays.fill(encountered, false); - traverse(v, traverser, encountered); - } - - @Override - public List findAllPaths(int from, Function pathComplete, Function pathCanceled) { - Objects.requireNonNull(pathComplete); - List paths = new ArrayList<>(); - BitSet encountered = new BitSet(vertices.size()); - TIntArrayList path = new TIntArrayList(1); - findAllPaths(from, pathComplete, pathCanceled, path, encountered, paths); - // sort paths by size - paths.sort((o1, o2) -> o1.size() - o2.size()); - return paths; - } - - private boolean findAllPaths(int e, int v1or2, Function pathComplete, Function pathCanceled, - TIntArrayList adjacentEdges, int i, TIntArrayList path, BitSet encountered, - List paths) { - if (encountered.get(v1or2)) { - return false; - } - Vertex obj1or2 = vertices.get(v1or2); - path.add(e); - if (pathComplete.apply(obj1or2.getObject())) { - paths.add(path); - return true; - } else { - findAllPaths(v1or2, pathComplete, pathCanceled, path, encountered, paths); - return false; - } - } - - private void findAllPaths(int v, Function pathComplete, Function pathCanceled, - TIntArrayList path, BitSet encountered, List paths) { - checkVertex(v); - encountered.set(v, true); - TIntArrayList[] adjacencyList = getAdjacencyList(); - TIntArrayList adjacentEdges = adjacencyList[v]; - for (int i = 0; i < adjacentEdges.size(); i++) { - int e = adjacentEdges.getQuick(i); - Edge edge = edges.get(e); - if (pathCanceled != null && pathCanceled.apply(edge.getObject())) { - continue; - } - int v1 = edge.getV1(); - int v2 = edge.getV2(); - TIntArrayList path2; - BitSet encountered2; - if (i < adjacentEdges.size () - 1) { - path2 = new TIntArrayList(path); - encountered2 = new BitSet(vertices.size()); - encountered2.or(encountered); - } else { - path2 = path; - encountered2 = encountered; - } - if (v == v2) { - if (findAllPaths(e, v1, pathComplete, pathCanceled, adjacentEdges, i, path2, encountered2, paths)) { - continue; - } - } else if (v == v1) { - if (findAllPaths(e, v2, pathComplete, pathCanceled, adjacentEdges, i, path2, encountered2, paths)) { - continue; - } - } else { - throw new AssertionError(); - } - } - } - - @Override - public void addListener(UndirectedGraphListener l) { - listeners.add(l); - } - - @Override - public void removeListener(UndirectedGraphListener l) { - listeners.remove(l); - } - - private void notifyListener() { - for (UndirectedGraphListener l : listeners) { - l.graphChanged(); - } - } - - @Override - public void print(PrintStream out, Function vertexToString, Function edgeToString) { - out.append("Vertices:\n"); - for (int v = 0; v < vertices.size(); v++) { - Vertex vertex = vertices.get(v); - if (vertex != null) { - String str = (vertexToString == null ? Objects.toString(vertex.getObject()) : vertexToString.apply(vertex.getObject())); - out.append(Integer.toString(v)).append(": ") - .append(str) - .append("\n"); - } - } - out.append("Edges:\n"); - for (int e = 0; e < edges.size(); e++) { - Edge edge = edges.get(e); - if (edge != null) { - String str = (edgeToString == null ? Objects.toString(edge.getObject()) : edgeToString.apply(edge.getObject())); - out.append(Integer.toString(e)).append(": ") - .append(Integer.toString(edge.getV1())).append("<->") - .append(Integer.toString(edge.getV2())).append(" ") - .append(str).append("\n"); - } - } - } - -} diff --git a/graph/src/main/java/eu/itesla_project/graph/UndirectedGraphListener.java b/graph/src/main/java/eu/itesla_project/graph/UndirectedGraphListener.java deleted file mode 100644 index 35bad960..00000000 --- a/graph/src/main/java/eu/itesla_project/graph/UndirectedGraphListener.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.graph; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface UndirectedGraphListener { - - void graphChanged(); -} diff --git a/graph/src/test/java/eu/itesla_project/graph/UndirectedGraphImplTest.java b/graph/src/test/java/eu/itesla_project/graph/UndirectedGraphImplTest.java deleted file mode 100644 index bfd6123c..00000000 --- a/graph/src/test/java/eu/itesla_project/graph/UndirectedGraphImplTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.graph; - -import gnu.trove.list.array.TIntArrayList; -import org.junit.After; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertTrue; -import org.junit.Before; -import org.junit.Test; - -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class UndirectedGraphImplTest { - - private static class Vertex { - - private final String name; - - private Vertex(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } - - } - - private UndirectedGraph graph; - - public UndirectedGraphImplTest() { - } - - @Before - public void setUp() { - graph = new UndirectedGraphImpl<>(); - } - - @After - public void tearDown() { - graph = null; - } - - @Test - public void testConstructor() { - assertTrue(graph.getVertexCount() == 0); - assertTrue(graph.getEdgeCount() == 0); - } - - @Test - public void testAddVertex() { - graph.addVertex(); - assertTrue(graph.getVertexCount() == 1); - } - - @Test - public void testAddEdge() { - graph.addVertex(); - graph.addVertex(); - int e = graph.addEdge(0, 1, null); - assertTrue(graph.getVertexCount() == 2); - assertTrue(e == 0); - assertTrue(graph.getEdgeCount() == 1); - } - - @Test - public void testRemoveEdge() { - graph.addVertex(); - graph.addVertex(); - graph.addVertex(); - int e = graph.addEdge(0, 1, null); - graph.removeEdge(e); - assertTrue(graph.getEdgeCount() == 0); - e = graph.addEdge(0, 1, null); - assertTrue(e == 0); - int e2 = graph.addEdge(1, 2, null); - graph.removeEdge(e); - assertTrue(graph.getEdgeCount() == 1); - e = graph.addEdge(0, 1, null); - assertTrue(e == 0); - graph.removeEdge(e); - graph.removeEdge(e2); - assertTrue(graph.getEdgeCount() == 0); - } - - /** - * 0 - * | - * --------- - * | | | - * 1 2 3 - * | | | - * ----- | - * | | - * 4 | - * | | - * ------- - * | - * 5 - * - * edges: - * 0 <-> 1 : 0 - * 0 <-> 2 : 1 - * 0 <-> 3 : 2 - * 1 <-> 4 : 3 - * 2 <-> 4 : 4 - * 4 <-> 5 : 5 - * 3 <-> 5 : 6 - * - * all paths (edge numbers) between vertex 0 and 5: - * 0, 3, 5 - * 1, 4, 5 - * 2, 6 - */ - @Test - public void testFindAllPaths() { - graph.addVertex(); - graph.addVertex(); - graph.addVertex(); - graph.addVertex(); - graph.addVertex(); - graph.addVertex(); - graph.setVertexObject(5, new Vertex("end")); - graph.addEdge(0, 1, null); // 0 - graph.addEdge(0, 2, null); // 1 - graph.addEdge(0, 3, null); // 2 - graph.addEdge(1, 4, null); // 3 - graph.addEdge(2, 4, null); // 4 - graph.addEdge(4, 5, null); // 5 - graph.addEdge(3, 5, null); // 6 - List paths = graph.findAllPaths(0, vertex -> vertex != null && "end".equals(vertex.name), null); - assertTrue(paths.size() == 3); - assertArrayEquals(paths.get(0).toArray(), new int[] {2, 6}); - assertArrayEquals(paths.get(1).toArray(), new int[] {0, 3, 5}); - assertArrayEquals(paths.get(2).toArray(), new int[] {1, 4, 5}); - } -} diff --git a/iidm-converter-api/pom.xml b/iidm-converter-api/pom.xml deleted file mode 100644 index a9a3ada0..00000000 --- a/iidm-converter-api/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - 4.0.0 - - - eu.itesla_project - itesla-parent - 0.1-SNAPSHOT - - - iidm-converter-api - - IIDM converter API - This is the API for IIDM importers and exporters - - - - org.slf4j - slf4j-api - - - com.google.auto.service - auto-service - - - org.jboss.shrinkwrap - shrinkwrap-api - - - org.jboss.shrinkwrap - shrinkwrap-impl-base - runtime - - - ${project.groupId} - iidm-network-api - ${project.version} - - - ${project.groupId} - computation - ${project.version} - - - ${project.groupId} - computation-local - ${project.version} - - - org.apache.commons - commons-compress - - - diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/AbstractDataSourceObserver.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/AbstractDataSourceObserver.java deleted file mode 100644 index 23509c6a..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/AbstractDataSourceObserver.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -/** - * This class provides a default empty implementation for the - * DataSourceObserver interface. - * - * @author Geoffroy Jamgotchian - */ -public class AbstractDataSourceObserver implements DataSourceObserver { - - @Override - public void opened(String streamName) { - } - - @Override - public void closed(String streamName) { - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/Bzip2FileDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/Bzip2FileDataSource.java deleted file mode 100644 index 6ee2d179..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/Bzip2FileDataSource.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.Objects; -import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; -import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; - - -/** - * @author Christian Biasuzzi - */ -public class Bzip2FileDataSource implements DataSource { - - private final Path directory; - - private final String baseName; - - private final DataSourceObserver observer; - - public Bzip2FileDataSource(Path directory, String baseName, DataSourceObserver observer) { - this.directory = Objects.requireNonNull(directory); - this.baseName = Objects.requireNonNull(baseName); - this.observer = observer; - } - - public Bzip2FileDataSource(Path directory, String baseName) { - this(directory, baseName, null); - } - - @Override - public String getBaseName() { - return baseName; - } - - private Path getPath(String suffix, String ext) { - return directory.resolve(DataSourceUtil.getFileName(baseName, suffix, ext + ".bz2")); - } - - @Override - public OutputStream newOutputStream(String suffix, String ext, boolean append) throws IOException { - Path path = getPath(suffix, ext); - OutputStream os = new BZip2CompressorOutputStream(new BufferedOutputStream(Files.newOutputStream(path, append ? StandardOpenOption.APPEND : StandardOpenOption.CREATE))); - return observer != null ? new ObservableOutputStream(os, path.toString(), observer) : os; - } - - @Override - public boolean exists(String suffix, String ext) { - Path path = getPath(suffix, ext); - return Files.isRegularFile(path); - } - - @Override - public boolean exists(String fileName) throws IOException { - Path path = directory.resolve(fileName + ".bz2"); - return Files.isRegularFile(path); - } - - @Override - public InputStream newInputStream(String suffix, String ext) throws IOException { - return new BZip2CompressorInputStream(new BufferedInputStream(Files.newInputStream(getPath(suffix, ext)))); - } - - @Override - public InputStream newInputStream(String fileName) throws IOException { - return new BZip2CompressorInputStream(new BufferedInputStream(Files.newInputStream(directory.resolve(fileName + ".bz2")))); - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ClassLoaderZipFileDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ClassLoaderZipFileDataSource.java deleted file mode 100644 index d071786d..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ClassLoaderZipFileDataSource.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import org.jboss.shrinkwrap.api.GenericArchive; -import org.jboss.shrinkwrap.api.Node; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.importer.ZipImporter; - -import java.io.InputStream; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class ClassLoaderZipFileDataSource implements ReadOnlyDataSource { - - private final String baseName; - - private final GenericArchive archive; - - public ClassLoaderZipFileDataSource(Class aClass, String dirName, String baseName) { - this.baseName = Objects.requireNonNull(baseName); - archive = ShrinkWrap.create(ZipImporter.class).importFrom(aClass.getResourceAsStream(dirName + "/" + baseName + ".zip")) - .as(GenericArchive.class); - } - - @Override - public boolean exists(String suffix, String ext) { - return exists(DataSourceUtil.getFileName(baseName, suffix, ext)); - } - - @Override - public boolean exists(String fileName) { - return archive.get(fileName) != null; - } - - @Override - public String getBaseName() { - return baseName; - } - - @Override - public InputStream newInputStream(String suffix, String ext) { - String fileName = DataSourceUtil.getFileName(baseName, suffix, ext); - return newInputStream(fileName); - } - - @Override - public InputStream newInputStream(String fileName) { - Node node = archive.get(fileName); - if (node == null) { - throw new RuntimeException(fileName + " does not exist"); - } - return node.getAsset().openStream(); - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSource.java deleted file mode 100644 index 09b4207f..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSource.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.io.IOException; -import java.io.OutputStream; - -/** - * @author Geoffroy Jamgotchian - */ -public interface DataSource extends ReadOnlyDataSource { - - OutputStream newOutputStream(String suffix, String ext, boolean append) throws IOException; - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceObserver.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceObserver.java deleted file mode 100644 index 8b50377e..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceObserver.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -/** - * An observer to be notified when a stream is opened or closed. - * - * @author Geoffroy Jamgotchian - */ -public interface DataSourceObserver { - - void opened(String streamName); - - void closed(String streamName); - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceUtil.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceUtil.java deleted file mode 100644 index f3e853ad..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/DataSourceUtil.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -/** - * @author Geoffroy Jamgotchian - */ -public class DataSourceUtil { - - private DataSourceUtil() { - } - - static String getFileName(String baseName, String suffix, String ext) { - return baseName + (suffix != null ? suffix : "") + (ext != null ? "." + ext : ""); - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/FileDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/FileDataSource.java deleted file mode 100644 index 67545f00..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/FileDataSource.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.OpenOption; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class FileDataSource implements DataSource { - - private static final OpenOption[] DEFAULT_OPEN_OPTIONS = { StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING }; - private static final OpenOption[] APPEND_OPEN_OPTIONS = { StandardOpenOption.APPEND }; - - private final Path directory; - - private final String baseName; - - private final DataSourceObserver observer; - - public FileDataSource(Path directory, String baseName) { - this(directory, baseName, null); - } - - public FileDataSource(Path directory, String baseName, DataSourceObserver observer) { - this.directory = Objects.requireNonNull(directory); - this.baseName = Objects.requireNonNull(baseName); - this.observer = observer; - } - - @Override - public String getBaseName() { - return baseName; - } - - private Path getPath(String suffix, String ext) { - return directory.resolve(DataSourceUtil.getFileName(baseName, suffix, ext)); - } - - @Override - public OutputStream newOutputStream(String suffix, String ext, boolean append) throws IOException { - Path path = getPath(suffix, ext); - OutputStream os = Files.newOutputStream(path, append ? APPEND_OPEN_OPTIONS : DEFAULT_OPEN_OPTIONS); - return observer != null ? new ObservableOutputStream(os, path.toString(), observer) : os; - } - - @Override - public boolean exists(String suffix, String ext) { - Path path = getPath(suffix, ext); - return Files.exists(path) && Files.isRegularFile(path); - } - - @Override - public boolean exists(String fileName) throws IOException { - return Files.exists(directory.resolve(fileName)); - } - - @Override - public InputStream newInputStream(String suffix, String ext) throws IOException { - return Files.newInputStream(getPath(suffix, ext)); - } - - @Override - public InputStream newInputStream(String fileName) throws IOException { - return Files.newInputStream(directory.resolve(fileName)); - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GenericReadOnlyDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GenericReadOnlyDataSource.java deleted file mode 100644 index 832548ad..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GenericReadOnlyDataSource.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Path; - -/** - * @author Geoffroy Jamgotchian - */ -public class GenericReadOnlyDataSource implements ReadOnlyDataSource { - - private final ReadOnlyDataSource[] dataSources; - - public GenericReadOnlyDataSource(Path directory, String baseName, DataSourceObserver observer) { - dataSources = new DataSource[]{ new FileDataSource(directory, baseName, observer), - new GzFileDataSource(directory, baseName, observer), - new ZipFileDataSource(directory, baseName + ".zip", baseName, observer), - new Bzip2FileDataSource(directory, baseName, observer)}; - } - - public GenericReadOnlyDataSource(Path directory, String baseName) { - this(directory, baseName, null); - } - - @Override - public String getBaseName() { - return dataSources[0].getBaseName(); - } - - @Override - public boolean exists(String suffix, String ext) throws IOException { - for (ReadOnlyDataSource dataSource : dataSources) { - if (dataSource.exists(suffix, ext)) { - return true; - } - } - return false; - } - - @Override - public boolean exists(String fileName) throws IOException { - for (ReadOnlyDataSource dataSource : dataSources) { - if (dataSource.exists(fileName)) { - return true; - } - } - return false; - } - - @Override - public InputStream newInputStream(String suffix, String ext) throws IOException { - for (ReadOnlyDataSource dataSource : dataSources) { - if (dataSource.exists(suffix, ext)) { - return dataSource.newInputStream(suffix, ext); - } - } - throw new IOException(DataSourceUtil.getFileName(getBaseName(), suffix, ext) + " not found"); - } - - @Override - public InputStream newInputStream(String fileName) throws IOException { - for (ReadOnlyDataSource dataSource : dataSources) { - if (dataSource.exists(fileName)) { - return dataSource.newInputStream(fileName); - } - } - throw new IOException(fileName + " not found"); - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GzFileDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GzFileDataSource.java deleted file mode 100644 index cedf7242..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/GzFileDataSource.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; -import java.util.Objects; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -/** - * @author Geoffroy Jamgotchian - */ -public class GzFileDataSource implements DataSource { - - private final Path directory; - - private final String baseName; - - private final DataSourceObserver observer; - - public GzFileDataSource(Path directory, String baseName, DataSourceObserver observer) { - this.directory = Objects.requireNonNull(directory); - this.baseName = Objects.requireNonNull(baseName); - this.observer = observer; - } - - public GzFileDataSource(Path directory, String baseName) { - this(directory, baseName, null); - } - - @Override - public String getBaseName() { - return baseName; - } - - private Path getPath(String suffix, String ext) { - return directory.resolve(DataSourceUtil.getFileName(baseName, suffix, ext) + ".gz"); - } - - @Override - public OutputStream newOutputStream(String suffix, String ext, boolean append) throws IOException { - Path path = getPath(suffix, ext); - OutputStream os = new GZIPOutputStream(Files.newOutputStream(path, append ? StandardOpenOption.APPEND : StandardOpenOption.CREATE)); - return observer != null ? new ObservableOutputStream(os, path.toString(), observer) : os; - } - - @Override - public boolean exists(String suffix, String ext) { - Path path = getPath(suffix, ext); - return Files.exists(path) && Files.isRegularFile(path); - } - - @Override - public boolean exists(String fileName) throws IOException { - Path path = directory.resolve(fileName + ".gz"); - return Files.exists(path) && Files.isRegularFile(path); - } - - @Override - public InputStream newInputStream(String suffix, String ext) throws IOException { - return new GZIPInputStream(Files.newInputStream(getPath(suffix, ext))); - } - - @Override - public InputStream newInputStream(String fileName) throws IOException { - return new GZIPInputStream(Files.newInputStream(directory.resolve(fileName + ".gz"))); - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/MemDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/MemDataSource.java deleted file mode 100644 index 088380cc..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/MemDataSource.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.io.*; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class MemDataSource implements DataSource { - - private static class Key { - - private String suffix; - - private String ext; - - private Key(String suffix, String ext) { - this.suffix = suffix; - this.ext = ext; - } - - @Override - public int hashCode() { - return Objects.hash(suffix, ext); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Key) { - Key other = (Key) obj; - return Objects.equals(suffix, other.suffix) - && Objects.equals(ext, other.ext); - } - return false; - } - - @Override - public String toString() { - return Objects.toString(suffix) + "." + Objects.toString(ext); - } - - } - - private final Map data = new HashMap<>(); - - public byte[] getData(String suffix, String ext) { - return data.get(new Key(suffix, ext)); - } - - public void putData(String suffix, String ext, byte[] data) { - this.data.put(new Key(suffix, ext), data); - } - - @Override - public String getBaseName() { - return ""; - } - - @Override - public OutputStream newOutputStream(final String suffix, final String ext, boolean append) throws IOException { - final Key key = new Key(suffix, ext); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - if (append) { - byte[] ba = data.get(new Key(suffix, ext)); - if (ba != null) { - os.write(ba, 0, ba.length); - } - } - return new ObservableOutputStream(os, key.toString(), new AbstractDataSourceObserver() { - @Override - public void closed(String streamName) { - data.put(key, os.toByteArray()); - } - }); - } - - @Override - public boolean exists(String suffix, String ext) { - return data.containsKey(new Key(suffix, ext)); - } - - @Override - public boolean exists(String fileName) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override - public InputStream newInputStream(String suffix, String ext) throws IOException { - byte[] ba = data.get(new Key(suffix, ext)); - if (ba == null) { - throw new IOException("*" + (suffix != null ? suffix : "") + "." + (ext != null ? ext : "") + " does not exist"); - } - return new ByteArrayInputStream(ba); - } - - @Override - public InputStream newInputStream(String fileName) throws IOException { - throw new UnsupportedOperationException(); - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableInputStream.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableInputStream.java deleted file mode 100644 index b5df90b2..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableInputStream.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import eu.itesla_project.commons.io.ForwardingInputStream; - -import java.io.IOException; -import java.io.InputStream; - -/** - * @author Geoffroy Jamgotchian - */ -class ObservableInputStream extends ForwardingInputStream { - - private final String streamName; - - private final DataSourceObserver observer; - - ObservableInputStream(InputStream is, String streamName, DataSourceObserver observer) { - super(is); - this.streamName = streamName; - this.observer = observer; - if (observer != null) { - observer.opened(streamName); - } - } - - @Override - public void close() throws IOException { - super.close(); - if (observer != null) { - observer.closed(streamName); - } - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableOutputStream.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableOutputStream.java deleted file mode 100644 index a4e0fd18..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ObservableOutputStream.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import eu.itesla_project.commons.io.ForwardingOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * An output stream wrapper that allows notification when the stream is opened - * and closed. - * - * @author Geoffroy Jamgotchian - */ -class ObservableOutputStream extends ForwardingOutputStream { - - private final String streamName; - - private final DataSourceObserver observer; - - ObservableOutputStream(OutputStream os, String streamName, DataSourceObserver observer) { - super(os); - this.streamName = streamName; - this.observer = observer; - if (observer != null) { - observer.opened(streamName); - } - } - - @Override - public void close() throws IOException { - super.close(); - if (observer != null) { - observer.closed(streamName); - } - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSource.java deleted file mode 100644 index 5c14981f..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSource.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.io.IOException; -import java.io.InputStream; - -/** - * @author Geoffroy Jamgotchian - */ -public interface ReadOnlyDataSource { - - String getBaseName(); - - boolean exists(String suffix, String ext) throws IOException; - - boolean exists(String fileName) throws IOException; - - InputStream newInputStream(String suffix, String ext) throws IOException; - - InputStream newInputStream(String fileName) throws IOException; -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSourceFactory.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSourceFactory.java deleted file mode 100644 index c4a5e9a1..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ReadOnlyDataSourceFactory.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import java.nio.file.Path; - -/** - * @author Geoffroy Jamgotchian - */ -public interface ReadOnlyDataSourceFactory { - - ReadOnlyDataSource create(Path directory, String baseName); - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ZipFileDataSource.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ZipFileDataSource.java deleted file mode 100644 index f7a2c221..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/datasource/ZipFileDataSource.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.datasource; - -import com.google.common.io.ByteStreams; -import eu.itesla_project.commons.io.ForwardingInputStream; -import eu.itesla_project.commons.io.ForwardingOutputStream; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.Enumeration; -import java.util.Objects; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipOutputStream; - -/** - * @author Geoffroy Jamgotchian - */ -public class ZipFileDataSource implements DataSource { - - private final Path directory; - - private final String zipFileName; - - private final String baseName; - - private final DataSourceObserver observer; - - public ZipFileDataSource(Path directory, String zipFileName, String baseName, DataSourceObserver observer) { - this.directory = Objects.requireNonNull(directory); - this.zipFileName = Objects.requireNonNull(zipFileName); - this.baseName = Objects.requireNonNull(baseName); - this.observer = observer; - } - - public ZipFileDataSource(Path directory, String zipFileName, String baseName) { - this(directory, zipFileName, baseName, null); - } - - public ZipFileDataSource(Path directory, String baseName) { - this(directory, baseName + ".zip", baseName, null); - } - - public ZipFileDataSource(Path zipFile) { - this(zipFile.getParent(), com.google.common.io.Files.getNameWithoutExtension(zipFile.getFileName().toString())); - } - - @Override - public String getBaseName() { - return baseName; - } - - @Override - public boolean exists(String suffix, String ext) throws IOException { - return exists(DataSourceUtil.getFileName(baseName, suffix, ext)); - } - - @Override - public boolean exists(String fileName) throws IOException { - Path zipFilePath = getZipFilePath(); - if (Files.isRegularFile(zipFilePath)) { - try (ZipFile zipFile = new ZipFile(zipFilePath.toFile())) { - return zipFile.getEntry(fileName) != null; - } - } - return false; - } - - private Path getZipFilePath() { - return directory.resolve(zipFileName); - } - - @Override - public InputStream newInputStream(String suffix, String ext) throws IOException { - return newInputStream(DataSourceUtil.getFileName(baseName, suffix, ext)); - } - - @Override - public InputStream newInputStream(String fileName) throws IOException { - ZipFile zipFile = new ZipFile(getZipFilePath().toFile()); - ZipEntry entry = zipFile.getEntry(fileName); - if (entry == null) { - zipFile.close(); - throw new IllegalArgumentException("Entry " + fileName + " not found"); - } - return new ForwardingInputStream(zipFile.getInputStream(entry)) { - @Override - public void close() throws IOException { - super.close(); - zipFile.close(); - } - }; - } - - @Override - public OutputStream newOutputStream(String suffix, String ext, boolean append) throws IOException { - if (append) { - throw new UnsupportedOperationException("append not supported in zip file data source"); - } - Path tmpZipFilePath = Files.createTempFile(directory, null, null); - ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(tmpZipFilePath)); - Path zipFilePath = getZipFilePath(); - String entryName = DataSourceUtil.getFileName(baseName, suffix, ext); - zos.putNextEntry(new ZipEntry(entryName)); - return new ForwardingOutputStream(zos) { - @Override - public void close() throws IOException { - os.closeEntry(); - if (Files.exists(zipFilePath)) { - try (ZipFile zipFile = new ZipFile(getZipFilePath().toFile())) { - for (Enumeration e = zipFile.entries(); e.hasMoreElements(); ) { - ZipEntry entry = e.nextElement(); - if (!entry.getName().equals(entryName)) { - zos.putNextEntry(entry); - ByteStreams.copy(zipFile.getInputStream(entry), zos); - zos.closeEntry(); - } - } - } - } - super.close(); - Files.copy(tmpZipFilePath, zipFilePath, StandardCopyOption.REPLACE_EXISTING); - Files.delete(tmpZipFilePath); - } - }; - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporter.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporter.java deleted file mode 100644 index c3bf71e7..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporter.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.export; - -import eu.itesla_project.iidm.datasource.DataSource; -import eu.itesla_project.iidm.network.Network; -import java.util.Properties; - -/** - * This is the base class for all IIDM exporters. - * - *

Exporter lookup is based on the ServiceLoader - * architecture so do not forget to create a - * META-INF/services/eu.itesla_project.iidm.export.Exporter file - * with the fully qualified name of your Exporter implementation. - * - * @see java.util.ServiceLoader - * @see Exporters - * @author Geoffroy Jamgotchian - */ -public interface Exporter { - - /** - * Get a unique identifier of the format. - */ - String getFormat(); - - /** - * Get some information about this exporter. - */ - String getComment(); - - /** - * Export a model. - * - * @param network the model - * @param parameters some properties to configure the export - * @param dataSource data source - */ - void export(Network network, Properties parameters, DataSource dataSource); - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporters.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporters.java deleted file mode 100644 index 0d433231..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/export/Exporters.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.export; - -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.datasource.DataSource; -import eu.itesla_project.iidm.datasource.FileDataSource; -import eu.itesla_project.iidm.network.Network; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Properties; -import java.util.ServiceLoader; - -/** - * A utility class to work with IIDM exporters. - * - * @author Geoffroy Jamgotchian - */ -public class Exporters { - - private Exporters() { - } - - /** - * Get all supported export formats. - */ - public static Collection getFormats() { - List formats = new ArrayList<>(); - for (Exporter e : ServiceLoader.load(Exporter.class)) { - formats.add(e.getFormat()); - } - return formats; - } - - /** - * Get an exporter. - * - * @param format the export format - * @return the exporter if one exists for the given format or - * null otherwise - */ - public static Exporter getExporter(String format) { - if (format == null) { - throw new IllegalArgumentException("format is null"); - } - for (Exporter e : ServiceLoader.load(Exporter.class)) { - if (format.equals(e.getFormat())) { - return e; - } - } - return null; - } - - /** - * A convenient method to export a model to a given format. - * - * @param format the export format - * @param network the model - * @param parameters some properties to configure the export - * @param dataSource data source - */ - public static void export(String format, Network network, Properties parameters, DataSource dataSource) { - Exporter exporter = getExporter(format); - if (exporter == null) { - throw new ITeslaException("Export format " + format + " not supported"); - } - exporter.export(network, parameters, dataSource); - } - - /** - * A convenient method to export a model to a given format. - * - * @param format the export format - * @param network the model - * @param parameters some properties to configure the export - * @param directory the output directory where files are generated - * @param baseName a base name for all generated files - */ - public static void export(String format, Network network, Properties parameters, String directory, String baseName) { - export(format, network, parameters, new FileDataSource(Paths.get(directory), baseName)); - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportConfig.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportConfig.java deleted file mode 100644 index 96a6bba7..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportConfig.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.import_; - -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class ImportConfig { - - public static final List DEFAULT_POST_PROCESSORS = Arrays.asList(JavaScriptPostProcessor.NAME); - - private final List postProcessors; - - public static ImportConfig load() { - List postProcessors; - if (PlatformConfig.defaultConfig().moduleExists("import")) { - ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("import"); - postProcessors = config.getStringListProperty("postProcessors", DEFAULT_POST_PROCESSORS); - } else { - postProcessors = DEFAULT_POST_PROCESSORS; - } - return new ImportConfig(postProcessors); - } - - public ImportConfig() { - this(Collections.emptyList()); - } - - public ImportConfig(String... postProcessors) { - this(Arrays.asList(postProcessors)); - } - - public ImportConfig(List postProcessors) { - this.postProcessors = Objects.requireNonNull(postProcessors); - } - - public List getPostProcessors() { - return postProcessors; - } - - @Override - public String toString() { - return "{postProcessors=" + postProcessors - + "}"; - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportPostProcessor.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportPostProcessor.java deleted file mode 100644 index c0d8be7e..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportPostProcessor.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.import_; - -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.iidm.network.Network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ImportPostProcessor { - - String getName(); - - void process(Network network, ComputationManager computationManager) throws Exception; - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importer.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importer.java deleted file mode 100644 index 6b3077ba..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importer.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.import_; - -import eu.itesla_project.iidm.datasource.ReadOnlyDataSource; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.parameters.Parameter; - -import java.io.InputStream; -import java.util.Collections; -import java.util.List; -import java.util.Properties; - -/** - * This is the base class for all IIDM importers. - * - *

Importer lookup is based on the ServiceLoader - * architecture so do not forget to create a - * META-INF/services/eu.itesla_project.iidm.import_.Importer file - * with the fully qualified name of your Importer implementation. - * - * @see java.util.ServiceLoader - * @see Importers - * - * @author Geoffroy Jamgotchian - */ -public interface Importer { - - /** - * Get a unique identifier of the format. - */ - String getFormat(); - - /** - * Get an InputStream on a 16*16 pixels icon. - * @return a 16*16 pixels icon - */ - default InputStream get16x16Icon() { - return null; - } - - /** - * Get a description of import parameters - * @return - */ - default List getParameters() { - return Collections.emptyList(); - } - - /** - * Get some information about this importer. - */ - String getComment(); - - /** - * Check if the data source is importable - * @param dataSource the data source - * @return true if the data source is importable, false otherwise - */ - boolean exists(ReadOnlyDataSource dataSource); - - /** - * Create a model. - * - * @param dataSource data source - * @param parameters some properties to configure the import - * @return the model - */ - Network import_(ReadOnlyDataSource dataSource, Properties parameters); - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importers.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importers.java deleted file mode 100644 index 01ddacdb..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/Importers.java +++ /dev/null @@ -1,399 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.import_; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import eu.itesla_project.commons.config.MapModuleConfig; -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.computation.local.LocalComputationManager; -import eu.itesla_project.iidm.datasource.*; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.parameters.Parameter; -import eu.itesla_project.iidm.parameters.ParameterDefaultValueConfig; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * A utility class to work with IIDM importers. - * - * @author Geoffroy Jamgotchian - */ -public class Importers { - - private static final Logger LOGGER = LoggerFactory.getLogger(Importers.class); - - private static final ImportersLoader LOADER = new ImportersServiceLoader(); - - private final static Supplier CONFIG = Suppliers.memoize(() -> ImportConfig.load()); - - private Importers() { - } - - /** - * Get all supported import formats. - */ - public static Collection getFormats() { - return LOADER.loadImporters().stream().map(Importer::getFormat).collect(Collectors.toList()); - } - - private static Importer wrapImporter(Importer importer, ComputationManager computationManager, ImportConfig config) { - Objects.requireNonNull(computationManager); - Objects.requireNonNull(config); - List postProcessorNames = config.getPostProcessors(); - if (postProcessorNames != null && postProcessorNames.size() > 0) { - return new ImporterWrapper(importer, computationManager, postProcessorNames); - } - return importer; - } - - public static Collection list(ComputationManager computationManager, ImportConfig config) { - return LOADER.loadImporters().stream() - .map(importer -> wrapImporter(importer, computationManager, config)) - .collect(Collectors.toList()); - } - - public static Collection list() { - return list(LocalComputationManager.getDefault(), CONFIG.get()); - } - - /** - * Get an importer. - * - * @param format the import format - * @return the importer if one exists for the given format or - * null otherwise. - */ - public static Importer getImporter(String format, ComputationManager computationManager, ImportConfig config) { - Objects.requireNonNull(format); - for (Importer importer : LOADER.loadImporters()) { - if (format.equals(importer.getFormat())) { - return wrapImporter(importer, computationManager, config); - } - } - return null; - } - - public static Importer getImporter(String format, ComputationManager computationManager) { - return getImporter(format, computationManager, CONFIG.get()); - } - - public static Importer getImporter(String format) { - return getImporter(format, LocalComputationManager.getDefault()); - } - - public static Collection getPostProcessorNames() { - return LOADER.loadPostProcessors().stream().map(ImportPostProcessor::getName).collect(Collectors.toList()); - } - - private static ImportPostProcessor getPostProcessor(String name) { - for (ImportPostProcessor ipp : LOADER.loadPostProcessors()) { - if (ipp.getName().equals(name)) { - return ipp; - } - } - throw new RuntimeException("Post processor " + name + " not found"); - } - - private static class ImporterWrapper implements Importer { - - private final Importer importer; - - private final ComputationManager computationManager; - - private final List names; - - ImporterWrapper(Importer importer, ComputationManager computationManager, List names) { - this.importer = importer; - this.computationManager = computationManager; - this.names = names; - } - - public Importer getImporter() { - return importer; - } - - @Override - public String getFormat() { - return importer.getFormat(); - } - - @Override - public InputStream get16x16Icon() { - return importer.get16x16Icon(); - } - - @Override - public List getParameters() { - return importer.getParameters(); - } - - @Override - public String getComment() { - return importer.getComment(); - } - - @Override - public boolean exists(ReadOnlyDataSource dataSource) { - return importer.exists(dataSource); - } - - @Override - public Network import_(ReadOnlyDataSource dataSource, Properties parameters) { - Network network = importer.import_(dataSource, parameters); - for (String name : names) { - try { - getPostProcessor(name).process(network, computationManager); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return network; - } - } - - public static Importer addPostProcessors(Importer importer, ComputationManager computationManager, String... names) { - return new ImporterWrapper(importer, computationManager, Arrays.asList(names)); - } - - public static Importer addPostProcessors(Importer importer, String... names) { - return new ImporterWrapper(importer, LocalComputationManager.getDefault(), Arrays.asList(names)); - } - - public static Importer setPostProcessors(Importer importer, ComputationManager computationManager, String... names) { - Importer importer2 = removePostProcessors(importer); - addPostProcessors(importer2, computationManager, names); - return importer2; - } - - public static Importer setPostProcessors(Importer importer, String... names) { - return setPostProcessors(importer, LocalComputationManager.getDefault(), names); - } - - public static Importer removePostProcessors(Importer importer) { - if (importer instanceof ImporterWrapper) { - return removePostProcessors(((ImporterWrapper) importer).getImporter()); - } - return importer; - } - - /** - * A convenient method to create a model from data in a given format. - * - * @param format the import format - * @param dataSource data source - * @param parameters some properties to configure the import - * @param computationManager computation manager to use for default post processors - * @return the model - */ - public static Network import_(String format, ReadOnlyDataSource dataSource, Properties parameters, ComputationManager computationManager) { - Importer importer = getImporter(format, computationManager); - if (importer == null) { - throw new RuntimeException("Import format " + format + " not supported"); - } - return importer.import_(dataSource, parameters); - } - - public static Network import_(String format, ReadOnlyDataSource dataSource, Properties parameters) { - return import_(format, dataSource, parameters, LocalComputationManager.getDefault()); - } - - /** - * A convenient method to create a model from data in a given format. - * - * @param format the import format - * @param directory the directory where input files are - * @param baseName a base name for all input files - * @param parameters some properties to configure the import - * @return the model - */ - public static Network import_(String format, String directory, String baseName, Properties parameters) { - return import_(format, new FileDataSource(Paths.get(directory), baseName), parameters); - } - - public static void importAll(Path dir, Importer importer, boolean parallel, Consumer consumer) throws IOException, InterruptedException, ExecutionException { - importAll(dir, importer, parallel, consumer, null); - } - - private static void doImport(ReadOnlyDataSource dataSource, Importer importer, Consumer consumer, Consumer listener) { - try { - if (listener != null) { - listener.accept(dataSource); - } - Network network = importer.import_(dataSource, null); - consumer.accept(network); - } catch (Exception e) { - LOGGER.error(e.toString(), e); - } - } - - public static void importAll(Path dir, Importer importer, boolean parallel, Consumer consumer, Consumer listener) throws IOException, InterruptedException, ExecutionException { - List dataSources = new ArrayList<>(); - importAll(dir, importer, dataSources); - if (parallel) { - ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); - try { - List> futures = dataSources.stream() - .map(ds -> executor.submit(() -> doImport(ds, importer, consumer, listener))) - .collect(Collectors.toList()); - for (Future future : futures) { - future.get(); - } - } finally { - executor.shutdownNow(); - } - } else { - for (ReadOnlyDataSource dataSource : dataSources) { - doImport(dataSource, importer, consumer, listener); - } - } - } - - public static String getBaseName(Path file) { - return getBaseName(file.getFileName().toString()); - } - - public static String getBaseName(String fileName) { - int pos = fileName.indexOf('.'); // find first dot in case of double extension (.xml.gz) - return pos == -1 ? fileName : fileName.substring(0, pos); - } - - private static void addDataSource(Path dir, Path file, Importer importer, List dataSources) { - String caseBaseName = getBaseName(file); - ReadOnlyDataSource ds = new GenericReadOnlyDataSource(dir, caseBaseName); - if (importer.exists(ds)) { - dataSources.add(ds); - } - } - - private static void importAll(Path parent, Importer importer, List dataSources) throws IOException { - if (Files.isDirectory(parent)) { - try (Stream stream = Files.list(parent)) { - stream.sorted().forEach(child -> { - if (Files.isDirectory(child)) { - try { - importAll(child, importer, dataSources); - } catch (IOException e) { - e.printStackTrace(); - } - } else { - addDataSource(parent, child, importer, dataSources); - } - }); - } - } else { - if (parent.getParent() != null) { - addDataSource(parent.getParent(), parent, importer, dataSources); - } - } - } - - public static Object readParameter(String format, Properties parameters, Parameter configuredParameter) { - Object value = null; - // priority on import parameter - if (parameters != null) { - MapModuleConfig moduleConfig = new MapModuleConfig(parameters); - switch (configuredParameter.getType()) { - case BOOLEAN: - value = moduleConfig.getOptinalBooleanProperty(configuredParameter.getName()); - break; - case STRING: - value = moduleConfig.getStringProperty(configuredParameter.getName(), null); - break; - case STRING_LIST: - value = moduleConfig.getStringListProperty(configuredParameter.getName(), null); - break; - default: - throw new AssertionError(); - } - } - // if none, use configured paramaters - if (value == null) { - value = ParameterDefaultValueConfig.INSTANCE.getValue(format, configuredParameter); - } - return value; - } - - public static ReadOnlyDataSource createReadOnly(Path directory, String fileNameOrBaseName) { - if (fileNameOrBaseName.endsWith(".zip")) { - return new ZipFileDataSource(directory, getBaseName(fileNameOrBaseName.substring(0, fileNameOrBaseName.length() - 4))); - } else if (fileNameOrBaseName.endsWith(".gz")) { - return new GzFileDataSource(directory, getBaseName(fileNameOrBaseName.substring(0, fileNameOrBaseName.length() - 3))); - } else if (fileNameOrBaseName.endsWith(".bz2")) { - return new Bzip2FileDataSource(directory, getBaseName(fileNameOrBaseName.substring(0, fileNameOrBaseName.length() - 4))); - } else { - return new FileDataSource(directory, getBaseName(fileNameOrBaseName)); - } - } - - public static ReadOnlyDataSource createReadOnly(Path file) { - if (!Files.isRegularFile(file)) { - throw new RuntimeException("File " + file + " does not exist or is not a regular file"); - } - return createReadOnly(file.getParent(), file.getFileName().toString()); - } - - public static Network loadNetwork(Path file, ComputationManager computationManager, ImportConfig config, Properties parameters) { - ReadOnlyDataSource dataSource = createReadOnly(file); - for (Importer importer : Importers.list(computationManager, config)) { - if (importer.exists(dataSource)) { - return importer.import_(dataSource, parameters); - } - } - return null; - } - - public static Network loadNetwork(Path file) { - return loadNetwork(file, LocalComputationManager.getDefault(), CONFIG.get(), null); - } - - public static Network loadNetwork(String file) { - return loadNetwork(Paths.get(file)); - } - - - public static void loadNetworks(Path dir, boolean parallel, ComputationManager computationManager, ImportConfig config, Consumer consumer, Consumer listener) throws IOException, InterruptedException, ExecutionException { - if (!Files.isDirectory(dir)) { - throw new RuntimeException("Directory " + dir + " does not exist or is not a regular directory"); - } - for (Importer importer : Importers.list(computationManager, config)) { - Importers.importAll(dir, importer, parallel, consumer, listener); - } - } - - public static void loadNetworks(Path dir, boolean parallel, ComputationManager computationManager, ImportConfig config, Consumer consumer) throws IOException, InterruptedException, ExecutionException { - loadNetworks(dir, parallel, LocalComputationManager.getDefault(), CONFIG.get(), consumer, null); - } - - public static void loadNetworks(Path dir, boolean parallel, Consumer consumer) throws IOException, InterruptedException, ExecutionException { - loadNetworks(dir, parallel, LocalComputationManager.getDefault(), CONFIG.get(), consumer); - } - - - public static void loadNetworks(Path dir, boolean parallel, Consumer consumer, Consumer listener) throws IOException, InterruptedException, ExecutionException { - loadNetworks(dir, parallel, LocalComputationManager.getDefault(), CONFIG.get(), consumer, listener); - } - - public static void loadNetworks(Path dir, Consumer consumer) throws IOException, InterruptedException, ExecutionException { - loadNetworks(dir, false, LocalComputationManager.getDefault(), CONFIG.get(), consumer); - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersLoader.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersLoader.java deleted file mode 100644 index 15ba9541..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersLoader.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.import_; - -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - */ -public interface ImportersLoader { - - List loadImporters(); - - List loadPostProcessors(); - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersServiceLoader.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersServiceLoader.java deleted file mode 100644 index 848031fb..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/ImportersServiceLoader.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.import_; - -import eu.itesla_project.commons.util.ServiceLoaderCache; - -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - */ -public class ImportersServiceLoader implements ImportersLoader { - - private static final ServiceLoaderCache IMPORTER_LOADER = new ServiceLoaderCache(Importer.class); - - private static final ServiceLoaderCache POST_PROCESSOR_LOADER = new ServiceLoaderCache(ImportPostProcessor.class); - - @Override - public List loadImporters() { - return IMPORTER_LOADER.getServices(); - } - - @Override - public List loadPostProcessors() { - return POST_PROCESSOR_LOADER.getServices(); - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/JavaScriptPostProcessor.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/JavaScriptPostProcessor.java deleted file mode 100644 index 47d404f0..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/import_/JavaScriptPostProcessor.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.import_; - -import com.google.auto.service.AutoService; -import com.google.common.io.CharStreams; -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.util.Networks; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.Reader; -import java.nio.file.Files; -import java.nio.file.Path; - -/** - * @author Geoffroy Jamgotchian - */ -@AutoService(ImportPostProcessor.class) -public class JavaScriptPostProcessor implements ImportPostProcessor { - - public static final String NAME = "javaScript"; - - private static final Logger LOGGER = LoggerFactory.getLogger(JavaScriptPostProcessor.class); - - private static final boolean DEFAULT_PRINT_TO_STD_OUT = true; - - private boolean printToStdOut = DEFAULT_PRINT_TO_STD_OUT; - - @Override - public String getName() { - return NAME; - } - - public JavaScriptPostProcessor() { - ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfigIfExists("javaScriptPostProcessor"); - if (config != null) { - printToStdOut = config.getBooleanProperty("printToStdOut", DEFAULT_PRINT_TO_STD_OUT); - } - } - - @Override - public void process(Network network, ComputationManager computationManager) throws Exception { - Path js = PlatformConfig.CONFIG_DIR.resolve("import-post-processor.js"); - if (Files.exists(js)) { - LOGGER.debug("Execute JS post processor {}", js); - try (Reader reader = Files.newBufferedReader(js)) { - Networks.runScript(network, reader, printToStdOut ? null : CharStreams.nullWriter()); - } - } - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/Parameter.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/Parameter.java deleted file mode 100644 index 33c225d3..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/Parameter.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.parameters; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class Parameter { - - private final String name; - - private final ParameterType type; - - private final String description; - - private final Object defaultValue; - - public Parameter(String name, ParameterType type, String description, Object defaultValue) { - if (!type.getClazz().isAssignableFrom(defaultValue.getClass())) { - throw new IllegalArgumentException("Bad default value type " + defaultValue.getClass() + ", " + type.getClazz() + " was expected"); - } - this.name = Objects.requireNonNull(name); - this.type = Objects.requireNonNull(type); - this.description = Objects.requireNonNull(description); - this.defaultValue = Objects.requireNonNull(defaultValue); - } - - public String getName() { - return name; - } - - public ParameterType getType() { - return type; - } - - public String getDescription() { - return description; - } - - public Object getDefaultValue() { - return defaultValue; - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterDefaultValueConfig.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterDefaultValueConfig.java deleted file mode 100644 index bbc26776..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterDefaultValueConfig.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.parameters; - -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; - -import java.util.List; -import java.util.Objects; - -/** - * To override programmatic default value. - * - * @author Geoffroy Jamgotchian - */ -public class ParameterDefaultValueConfig { - - private static final String MODULE_NAME = "import-export-parameters-default-value"; - - public static final ParameterDefaultValueConfig INSTANCE = new ParameterDefaultValueConfig(); - - private final ModuleConfig config ; - - public ParameterDefaultValueConfig() { - config = PlatformConfig.defaultConfig().moduleExists(MODULE_NAME) ? PlatformConfig.defaultConfig().getModuleConfig(MODULE_NAME) : null; - } - - public Object getValue(String format, Parameter parameter) { - Objects.requireNonNull(format); - Objects.requireNonNull(parameter); - String name = format + "_" + parameter.getName(); - switch (parameter.getType()) { - case BOOLEAN: { - boolean defaultValue = (Boolean) parameter.getDefaultValue(); - return config != null ? config.getBooleanProperty(name, defaultValue) : defaultValue; - } - case STRING: { - String defaultValue = (String) parameter.getDefaultValue(); - return config != null ? config.getStringProperty(name, defaultValue) : defaultValue; - } - case STRING_LIST: { - List defaultValue = (List) parameter.getDefaultValue(); - return config != null ? config.getStringListProperty(name, defaultValue) : defaultValue; - } - default: - throw new AssertionError(); - } - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterType.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterType.java deleted file mode 100644 index edd6c190..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/parameters/ParameterType.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.parameters; - -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - */ -public enum ParameterType { - BOOLEAN(Boolean.class), - STRING(String.class), - STRING_LIST(List.class); - - private final Class clazz; - - ParameterType(Class clazz) { - this.clazz = clazz; - } - - public Class getClazz() { - return clazz; - } -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionCommand.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionCommand.java deleted file mode 100644 index c3a5b9c4..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionCommand.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.tools; - -import eu.itesla_project.commons.tools.Command; -import eu.itesla_project.iidm.export.Exporters; -import eu.itesla_project.iidm.import_.Importers; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ConversionCommand implements Command { - - public static final ConversionCommand INSTANCE = new ConversionCommand(); - - @Override - public String getName() { - return "convert-network"; - } - - @Override - public String getTheme() { - return "Data conversion"; - } - - @Override - public String getDescription() { - return "convert a network from one format to another"; - } - - @Override - @SuppressWarnings("static-access") - public Options getOptions() { - Options options = new Options(); - options.addOption(Option.builder().longOpt("source") - .desc("the source format") - .hasArg() - .argName("SOURCE_FORMAT") - .required() - .build()); - options.addOption(Option.builder().longOpt("target") - .desc("the target format") - .hasArg() - .argName("TARGET_FORMAT") - .required() - .build()); - options.addOption(Option.builder().longOpt("input-dir") - .desc("the input directory for input files") - .hasArg() - .argName("DIR") - .required() - .build()); - options.addOption(Option.builder().longOpt("input-basename") - .desc("the base name for input files") - .hasArg() - .argName("NAME") - .required() - .build()); - options.addOption(Option.builder().longOpt("output-dir") - .desc("the output directory for generated files") - .hasArg() - .argName("DIR") - .required() - .build()); - options.addOption(Option.builder().longOpt("output-basename") - .desc("the base name for generated files") - .hasArg() - .argName("NAME") - .required() - .build()); - return options; - } - - @Override - public String getUsageFooter() { - return "Where SOURCE_FORMAT is one of " + Importers.getFormats() - + " and TARGET_FORMAT is one of " + Exporters.getFormats(); - } - -} diff --git a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionTool.java b/iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionTool.java deleted file mode 100644 index b6713ac3..00000000 --- a/iidm-converter-api/src/main/java/eu/itesla_project/iidm/tools/ConversionTool.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.tools; - -import eu.itesla_project.commons.tools.Tool; -import eu.itesla_project.commons.tools.Command; -import com.google.auto.service.AutoService; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.datasource.*; -import eu.itesla_project.iidm.export.Exporter; -import eu.itesla_project.iidm.export.Exporters; -import eu.itesla_project.iidm.import_.Importer; -import eu.itesla_project.iidm.import_.Importers; -import eu.itesla_project.iidm.network.Network; -import java.nio.file.Paths; -import java.util.Properties; -import org.apache.commons.cli.CommandLine; - -/** - * - * @author Geoffroy Jamgotchian - */ -@AutoService(Tool.class) -public class ConversionTool implements Tool { - - @Override - public Command getCommand() { - return ConversionCommand.INSTANCE; - } - - @Override - public void run(CommandLine line) throws Exception { - String sourceFormat = line.getOptionValue("source"); - String targetFormat = line.getOptionValue("target"); - String inputDirName = line.getOptionValue("input-dir"); - String inputBaseName = line.getOptionValue("input-basename"); - String outputDirName = line.getOptionValue("output-dir"); - String outputBaseName = line.getOptionValue("output-basename"); - - Importer importer = Importers.getImporter(sourceFormat); - if (importer == null) { - throw new ITeslaException("Source format " + sourceFormat + " not supported"); - } - Exporter exporter = Exporters.getExporter(targetFormat); - if (exporter == null) { - throw new ITeslaException("Target format " + targetFormat + " not supported"); - } - - Properties inputParams = new Properties(); - // TODO get parameters through the command line - ReadOnlyDataSource ds1 = new GenericReadOnlyDataSource(Paths.get(inputDirName), inputBaseName); - Network network = importer.import_(ds1, inputParams); - - Properties outputParams = new Properties(); - // TODO get parameters through the command line - DataSource ds2 = new FileDataSource(Paths.get(outputDirName), outputBaseName, new AbstractDataSourceObserver() { - @Override - public void opened(String streamName) { - System.out.println("Generating file " + streamName + "..."); - } - }); - exporter.export(network, outputParams, ds2); - } - -} diff --git a/iidm-ddb/iidm-ddb-eurostag-import-export/pom.xml b/iidm-ddb/iidm-ddb-eurostag-import-export/pom.xml index 13be3329..fc758921 100644 --- a/iidm-ddb/iidm-ddb-eurostag-import-export/pom.xml +++ b/iidm-ddb/iidm-ddb-eurostag-import-export/pom.xml @@ -38,6 +38,26 @@ + + com.google.auto.service + auto-service + + + commons-cli + commons-cli + + + net.sf.supercsv + super-csv + + + eu.itesla_project + commons + + + eu.itesla_project + iidm-network-api + @@ -53,24 +73,6 @@ 0.0.1-SNAPSHOT - - net.sf.supercsv - super-csv - 2.1.0 - - - - eu.itesla_project - commons - 0.1-SNAPSHOT - - - - eu.itesla_project - iidm-network-api - 0.1-SNAPSHOT - - eu.itesla_project EU2Mod_MB diff --git a/iidm-network-api/pom.xml b/iidm-network-api/pom.xml deleted file mode 100644 index bd6ed210..00000000 --- a/iidm-network-api/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - 4.0.0 - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - - iidm-network-api - - IIDM network API - This is the API of the network model - - - - org.apache.commons - commons-math3 - - - org.ow2.sirocco - sirocco-text-table-formatter - - - joda-time - joda-time - - - org.kohsuke - graphviz-api - - - ${project.groupId} - commons - ${project.version} - - - junit - junit - test - - - org.slf4j - slf4j-simple - test - - - - diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractNetworkListener.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractNetworkListener.java deleted file mode 100644 index 0c9e39bc..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractNetworkListener.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public class AbstractNetworkListener implements NetworkListener { - @Override - public void onCreation(Identifiable identifiable) { - } - - @Override - public void onRemoval(Identifiable identifiable) { - } - - @Override - public void onUpdate(Identifiable identifiable, String attribute, Object oldValue, Object newValue) { - } -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractTopologyVisitor.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractTopologyVisitor.java deleted file mode 100644 index c9ab5abe..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/AbstractTopologyVisitor.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class AbstractTopologyVisitor implements TopologyVisitor { - - @Override - public void visitBusbarSection(BusbarSection section) { - } - - @Override - public void visitLine(Line line, Line.Side side) { - } - - @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoWindingsTransformer.Side side) { - } - - @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { - } - - @Override - public void visitGenerator(Generator generator) { - } - - @Override - public void visitLoad(Load load) { - } - - @Override - public void visitShuntCompensator(ShuntCompensator sc) { - } - - @Override - public void visitDanglingLine(DanglingLine danglingLine) { - } - - @Override - public void visitStaticVarCompensator(StaticVarCompensator staticVarCompensator) { - } - - @Override - public void visitHvdcConverterStation(HvdcConverterStation converterStation) { - } -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Bus.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Bus.java deleted file mode 100644 index ffd91561..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Bus.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A bus is a set of equipemnts connected together through a closed switch. - * - * It could be a configured object ot a result of a computation depending of the - * context. - * - * @author Geoffroy Jamgotchian - */ -public interface Bus extends Identifiable { - - /** - * Get the voltage level to which the bus belongs. - */ - VoltageLevel getVoltageLevel(); - - /** - * Get the voltage magnitude of the bus in kV. - */ - float getV(); - - /** - * Set the voltage magnituge of the bus in kV. - */ - Bus setV(float v); - - /** - * Get the voltage angle of the bus in degree. - */ - float getAngle(); - - /** - * Set the voltage angle of the bus in degree. - */ - Bus setAngle(float angle); - - /** - * Get the active power in MW injected by equipments connected to the bus. - */ - float getP(); - - /** - * Get the reactive power in MVAR injected by equiments connected to the bus. - */ - float getQ(); - - /** - * Get the connected component that the bus is part of. - */ - ConnectedComponent getConnectedComponent(); - - /** - * Check if the bus belongs to the main connected component - * @return true if the bus belongs to the main connected component, false otherwise - */ - boolean isInMainConnectedComponent(); - - /** - * Get the AC lines connected to the bus. - */ - Iterable getLines(); - - /** - * Get 2 windings transformer connected to the bus. - */ - Iterable getTwoWindingTransformers(); - - /** - * Get 3 windings transformers connected to the bus. - */ - Iterable getThreeWindingTransformers(); - - /** - * Get generators connected to the bus. - */ - Iterable getGenerators(); - - /** - * Get loads connected to the bus. - */ - Iterable getLoads(); - - /** - * Get shunt compensators connected to the bus. - */ - Iterable getShunts(); - - /** - * Get dangling lines connected to the bus. - */ - Iterable getDanglingLines(); - - /** - * Visit equipments connected to the bus. - * - * @param visitor a handler to be notified for each equipment connected at the bus - */ - void visitConnectedEquipments(TopologyVisitor visitor); - - /** - * Visit equipments connected or connectable to the bus. - * - * @param visitor a handler to be notified for each equipment - */ - void visitConnectedOrConnectableEquipments(TopologyVisitor visitor); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusAdder.java deleted file mode 100644 index cfa61eaa..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusAdder.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface BusAdder extends IdentifiableAdder { - - Bus add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSection.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSection.java deleted file mode 100644 index d6d5f2d7..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSection.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A busbar section, a non impedant element used in a node/breaker substation - * topology to connect equipments. - * - * @author Geoffroy Jamgotchian - */ -public interface BusbarSection extends SingleTerminalConnectable { - - float getV(); - - float getAngle(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSectionAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSectionAdder.java deleted file mode 100644 index 536fba43..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/BusbarSectionAdder.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface BusbarSectionAdder extends IdentifiableAdder { - - BusbarSectionAdder setNode(int node); - - BusbarSection add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ChangeType.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ChangeType.java deleted file mode 100644 index e5b67932..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ChangeType.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public enum ChangeType { - CREATION, - DELETION, - UPDATE -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Connectable.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Connectable.java deleted file mode 100644 index 656402de..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Connectable.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import java.util.List; - -/** - * An equipment that is part of a substation topology. - * - * @author Geoffroy Jamgotchian - */ -public interface Connectable> extends Identifiable { - - /** - * Get the connectable type. - */ - ConnectableType getType(); - - List getTerminals(); - - /** - * Remove the equipment. - */ - void remove(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectableType.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectableType.java deleted file mode 100644 index 30bcf94e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectableType.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum ConnectableType { - BUSBAR_SECTION, - LINE, - TWO_WINDINGS_TRANSFORMER, - THREE_WINDINGS_TRANSFORMER, - GENERATOR, - LOAD, - SHUNT_COMPENSATOR, - DANGLING_LINE, - STATIC_VAR_COMPENSATOR, - HVDC_CONVERTER_STATION -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectedComponent.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectedComponent.java deleted file mode 100644 index 9f964ffa..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ConnectedComponent.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A set of connected bus in the network. - * - * @author Geoffroy Jamgotchian - */ -public interface ConnectedComponent { - - public static final int MAIN_CC_NUM = 0; - - /** - * Get the number of the connected component. - *

- * The biggest one has the number zero and the smallest has the highest number. - */ - int getNum(); - - /** - * Get the number of bus in the connected component. - */ - int getSize(); - - /** - * Get buses in the connected component. - */ - Iterable getBuses(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Container.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Container.java deleted file mode 100644 index 00bef452..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Container.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public interface Container> extends Identifiable { - - ContainerType getContainerType(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ContainerType.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ContainerType.java deleted file mode 100644 index d020c9f0..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ContainerType.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public enum ContainerType { - NETWORK, - SUBSTATION, - VOLTAGE_LEVEL -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Country.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Country.java deleted file mode 100644 index ddd7f90c..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Country.java +++ /dev/null @@ -1,275 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * Countries alpha-2 code. - * - * @author Geoffroy Jamgotchian - */ -public enum Country { - AF("AFGHANISTAN"), - AX("ÅLAND ISLANDS"), - AL("ALBANIA"), - DZ("ALGERIA"), - AS("AMERICAN SAMOA"), - AD("ANDORRA"), - AO("ANGOLA"), - AI("ANGUILLA"), - AQ("ANTARCTICA"), - AG("ANTIGUA AND BARBUDA"), - AR("ARGENTINA"), - AM("ARMENIA"), - AW("ARUBA"), - AU("AUSTRALIA"), - AT("AUSTRIA"), - AZ("AZERBAIJAN"), - BS("BAHAMAS"), - BH("BAHRAIN"), - BD("BANGLADESH"), - BB("BARBADOS"), - BY("BELARUS"), - BE("BELGIUM"), - BZ("BELIZE"), - BJ("BENIN"), - BM("BERMUDA"), - BT("BHUTAN"), - BO("BOLIVIA, PLURINATIONAL STATE OF"), - BQ("BONAIRE, SINT EUSTATIUS AND SABA"), - BA("BOSNIA AND HERZEGOVINA"), - BW("BOTSWANA"), - BV("BOUVET ISLAND"), - BR("BRAZIL"), - IO("BRITISH INDIAN OCEAN TERRITORY"), - BN("BRUNEI DARUSSALAM"), - BG("BULGARIA"), - BF("BURKINA FASO"), - BI("BURUNDI"), - KH("CAMBODIA"), - CM("CAMEROON"), - CA("CANADA"), - CV("CAPE VERDE"), - KY("CAYMAN ISLANDS"), - CF("CENTRAL AFRICAN REPUBLIC"), - TD("CHAD"), - CL("CHILE"), - CN("CHINA"), - CX("CHRISTMAS ISLAND"), - CC("COCOS (KEELING) ISLANDS"), - CO("COLOMBIA"), - KM("COMOROS"), - CG("CONGO"), - CD("CONGO, THE DEMOCRATIC REPUBLIC OF THE"), - CK("COOK ISLANDS"), - CR("COSTA RICA"), - CI("CÔTE D'IVOIRE"), - HR("CROATIA"), - CU("CUBA"), - CW("CURAÇAO"), - CY("CYPRUS"), - CZ("CZECH REPUBLIC"), - DK("DENMARK"), - DJ("DJIBOUTI"), - DM("DOMINICA"), - DO("DOMINICAN REPUBLIC"), - EC("ECUADOR"), - EG("EGYPT"), - SV("EL SALVADOR"), - GQ("EQUATORIAL GUINEA"), - ER("ERITREA"), - EE("ESTONIA"), - ET("ETHIOPIA"), - FK("FALKLAND ISLANDS (MALVINAS)"), - FO("FAROE ISLANDS"), - FJ("FIJI"), - FI("FINLAND"), - FR("FRANCE"), - GF("FRENCH GUIANA"), - PF("FRENCH POLYNESIA"), - TF("FRENCH SOUTHERN TERRITORIES"), - GA("GABON"), - GM("GAMBIA"), - GE("GEORGIA"), - DE("GERMANY"), - GH("GHANA"), - GI("GIBRALTAR"), - GR("GREECE"), - GL("GREENLAND"), - GD("GRENADA"), - GP("GUADELOUPE"), - GU("GUAM"), - GT("GUATEMALA"), - GG("GUERNSEY"), - GN("GUINEA"), - GW("GUINEA-BISSAU"), - GY("GUYANA"), - HT("HAITI"), - HM("HEARD ISLAND AND MCDONALD ISLANDS"), - VA("HOLY SEE (VATICAN CITY STATE)"), - HN("HONDURAS"), - HK("HONG KONG"), - HU("HUNGARY"), - IS("ICELAND"), - IN("INDIA"), - ID("INDONESIA"), - IR("IRAN, ISLAMIC REPUBLIC OF"), - IQ("IRAQ"), - IE("IRELAND"), - IM("ISLE OF MAN"), - IL("ISRAEL"), - IT("ITALY"), - JM("JAMAICA"), - JP("JAPAN"), - JE("JERSEY"), - JO("JORDAN"), - KZ("KAZAKHSTAN"), - KE("KENYA"), - KI("KIRIBATI"), - KP("KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF"), - KR("KOREA, REPUBLIC OF"), - KW("KUWAIT"), - KG("KYRGYZSTAN"), - LA("LAO PEOPLE'S DEMOCRATIC REPUBLIC"), - LV("LATVIA"), - LB("LEBANON"), - LS("LESOTHO"), - LR("LIBERIA"), - LY("LIBYA"), - LI("LIECHTENSTEIN"), - LT("LITHUANIA"), - LU("LUXEMBOURG"), - MO("MACAO"), - MK("MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF"), - MG("MADAGASCAR"), - MW("MALAWI"), - MY("MALAYSIA"), - MV("MALDIVES"), - ML("MALI"), - MT("MALTA"), - MH("MARSHALL ISLANDS"), - MQ("MARTINIQUE"), - MR("MAURITANIA"), - MU("MAURITIUS"), - YT("MAYOTTE"), - MX("MEXICO"), - FM("MICRONESIA, FEDERATED STATES OF"), - MD("MOLDOVA, REPUBLIC OF"), - MC("MONACO"), - MN("MONGOLIA"), - ME("MONTENEGRO"), - MS("MONTSERRAT"), - MA("MOROCCO"), - MZ("MOZAMBIQUE"), - MM("MYANMAR"), - NA("NAMIBIA"), - NR("NAURU"), - NP("NEPAL"), - NL("NETHERLANDS"), - NC("NEW CALEDONIA"), - NZ("NEW ZEALAND"), - NI("NICARAGUA"), - NE("NIGER"), - NG("NIGERIA"), - NU("NIUE"), - NF("NORFOLK ISLAND"), - MP("NORTHERN MARIANA ISLANDS"), - NO("NORWAY"), - OM("OMAN"), - PK("PAKISTAN"), - PW("PALAU"), - PS("PALESTINE, STATE OF"), - PA("PANAMA"), - PG("PAPUA NEW GUINEA"), - PY("PARAGUAY"), - PE("PERU"), - PH("PHILIPPINES"), - PN("PITCAIRN"), - PL("POLAND"), - PT("PORTUGAL"), - PR("PUERTO RICO"), - QA("QATAR"), - RE("RÉUNION"), - RO("ROMANIA"), - RU("RUSSIAN FEDERATION"), - RW("RWANDA"), - BL("SAINT BARTHÉLEMY"), - SH("SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA"), - KN("SAINT KITTS AND NEVIS"), - LC("SAINT LUCIA"), - MF("SAINT MARTIN (FRENCH PART)"), - PM("SAINT PIERRE AND MIQUELON"), - VC("SAINT VINCENT AND THE GRENADINES"), - WS("SAMOA"), - SM("SAN MARINO"), - ST("SAO TOME AND PRINCIPE"), - SA("SAUDI ARABIA"), - SN("SENEGAL"), - RS("SERBIA"), - SC("SEYCHELLES"), - SL("SIERRA LEONE"), - SG("SINGAPORE"), - SX("SINT MAARTEN (DUTCH PART)"), - SK("SLOVAKIA"), - SI("SLOVENIA"), - SB("SOLOMON ISLANDS"), - SO("SOMALIA"), - ZA("SOUTH AFRICA"), - GS("SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"), - SS("SOUTH SUDAN"), - ES("SPAIN"), - LK("SRI LANKA"), - SD("SUDAN"), - SR("SURINAME"), - SJ("SVALBARD AND JAN MAYEN"), - SZ("SWAZILAND"), - SE("SWEDEN"), - CH("SWITZERLAND"), - SY("SYRIAN ARAB REPUBLIC"), - TW("TAIWAN, PROVINCE OF CHINA"), - TJ("TAJIKISTAN"), - TZ("TANZANIA, UNITED REPUBLIC OF"), - TH("THAILAND"), - TL("TIMOR-LESTE"), - TG("TOGO"), - TK("TOKELAU"), - TO("TONGA"), - TT("TRINIDAD AND TOBAGO"), - TN("TUNISIA"), - TR("TURKEY"), - TM("TURKMENISTAN"), - TC("TURKS AND CAICOS ISLANDS"), - TV("TUVALU"), - UG("UGANDA"), - UA("UKRAINE"), - AE("UNITED ARAB EMIRATES"), - GB("UNITED KINGDOM"), - US("UNITED STATES"), - UM("UNITED STATES MINOR OUTLYING ISLANDS"), - UY("URUGUAY"), - UZ("UZBEKISTAN"), - VU("VANUATU"), - VE("VENEZUELA, BOLIVARIAN REPUBLIC OF"), - VN("VIET NAM"), - VG("VIRGIN ISLANDS, BRITISH"), - VI("VIRGIN ISLANDS, U.S."), - WF("WALLIS AND FUTUNA"), - EH("WESTERN SAHARA"), - YE("YEMEN"), - ZM("ZAMBIA"), - ZW("ZIMBABWE"); - - private final String name; - - Country(String name) { - this.name = name; - } - - public String getName() { - return name; - } - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java deleted file mode 100644 index 7580083c..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimits.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import java.util.Collection; - -/** - * Current limits are defined by: - *

    - *
  • A permanent limit (A)
  • - *
  • - * Any number of temporary limits. - * A permanent limit (A) has an acceptable duration (s). - * The branch can safely stay between the previous limit (could be another temporary limit or the permanent limit) and - * this limit during the acceptable duration. - * A NaN temporay limit value means infinite. - *
  • - *
- * - *

- * The following diagram shows current areas and corresponding acceptable duration for a permanent limit and 3 temporary - * limits with x, y and z acceptable durations. - *

- * - *
- *

- * @author Geoffroy Jamgotchian - */ -public interface CurrentLimits { - - /** - * Temporary current limit. - */ - interface TemporaryLimit { - - /** - * Get the temporary limit name - * @return the temporary limit name - */ - String getName(); - - /** - * Get the temporary limit value in A. - * @return the temporary limit value in A - */ - float getValue(); - - /** - * Get the acceptable duration of the limit in second. - * @return the acceptable duration of the limit in second - */ - int getAcceptableDuration(); - - /** - * Check if the temporary limit is a real limit corresponding to an overloading protection or just an operating - * rule - * @return false if it is a real limit, false otherwise - */ - boolean isFictitious(); - } - - /** - * Get the permanent limit in A. - * @return the permanent limit in A. - */ - float getPermanentLimit(); - - /** - * Get a list of temporary limits ordered by descending duration. - * @return a list of temporary limits ordered by descending duration - */ - Collection getTemporaryLimits(); - - /** - * Get a temporary limit from its acceptable duration. Return null if there is non temporay limit with this - * acceptable duration. - * @param acceptableDuration acceptable duration in second - * @return the temporary limit - */ - TemporaryLimit getTemporaryLimit(int acceptableDuration); - - /** - * Get a temporary limit value from its acceptable duration. Return NaN if there is non temporay limit with this - * acceptable duration. - * @param acceptableDuration acceptable duration in second - * @return the temporary limit value or NaN if there is no temporary limit for this acceptable duration - */ - float getTemporaryLimitValue(int acceptableDuration); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimitsAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimitsAdder.java deleted file mode 100644 index 8e7357eb..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/CurrentLimitsAdder.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface CurrentLimitsAdder { - - interface TemporaryLimitAdder { - - TemporaryLimitAdder setName(String name); - - TemporaryLimitAdder setValue(float value); - - TemporaryLimitAdder setAcceptableDuration(int duration); - - TemporaryLimitAdder setFictitious(boolean fictitious); - - CurrentLimitsAdder endTemporaryLimit(); - } - - CurrentLimitsAdder setPermanentLimit(float limit); - - TemporaryLimitAdder beginTemporaryLimit(); - - CurrentLimits add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLine.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLine.java deleted file mode 100644 index f3c09b44..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLine.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A dangling line to model boundaries (X nodes). - *

A dangling line is a component that aggregates a line chunk and a constant - * power injection (fixed p0, q0). - *

- * - *
- * Electrical characteritics (r, x, g, b) corresponding to a percent of the - * orginal line. - *

r, x, g, b have to be consistent with the declared length of the dangling - * line. - *

To create a dangling line, see {@link DanglingLineAdder} - * - * @author Geoffroy Jamgotchian - * @see DanglingLineAdder - */ -public interface DanglingLine extends SingleTerminalConnectable { - - /** - * Get the constant active power in MW. - *

Depends on the working state. - * @see StateManager - */ - float getP0(); - - /** - * Set the constant active power in MW. - *

Depends on the working state. - * @see StateManager - */ - DanglingLine setP0(float p0); - - /** - * Get the constant reactive power in MW. - *

Depends on the working state. - * @see StateManager - */ - float getQ0(); - - /** - * Set the constant reactive power in MW. - *

Depends on the working state. - * @see StateManager - */ - DanglingLine setQ0(float q0); - - /** - * Get the series resistance in Ω. - */ - float getR(); - - /** - * Set the series resistance in Ω. - */ - DanglingLine setR(float r); - - /** - * Get the series reactance in Ω. - */ - float getX(); - - /** - * Set the series reactance in Ω. - */ - DanglingLine setX(float x); - - /** - * Get the shunt conductance in S. - */ - float getG(); - - /** - * Set the shunt conductance in S. - */ - DanglingLine setG(float g); - - /** - * Get the shunt susceptance in S. - */ - float getB(); - - /** - * Set the shunt susceptance in S. - */ - DanglingLine setB(float b); - - /** - * Get the UCTE Xnode code corresponding to this dangling line in the case - * where the line is a boundary, return null otherwise. - */ - String getUcteXnodeCode(); - - CurrentLimits getCurrentLimits(); - - CurrentLimitsAdder newCurrentLimits(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLineAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLineAdder.java deleted file mode 100644 index c3228c2c..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/DanglingLineAdder.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * To create a dangling line, from a VoltageLevel instance call - * the {@link VoltageLevel#newDanglingLine()} method to get a dangling line - * builder instance. - *

- * Example: - *

- *    VoltageLevel vl = ...
- *    DanglingLine dl = vl.newDanglingLine()
- *            .setId("dl1")
- *            ...
- *        .add();
- *
- * - * @author Geoffroy Jamgotchian - * @see DanglingLine - * @see VoltageLevel - */ -public interface DanglingLineAdder extends SingleTerminalConnectableAdder { - - DanglingLineAdder setP0(float p0); - - DanglingLineAdder setQ0(float q0); - - DanglingLineAdder setR(float r); - - DanglingLineAdder setX(float x); - - DanglingLineAdder setG(float g); - - DanglingLineAdder setB(float b); - - DanglingLineAdder setUcteXnodeCode(String ucteXnodeCode); - - DanglingLine add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EnergySource.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EnergySource.java deleted file mode 100644 index c239d1ac..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EnergySource.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * The energy source of a generator. - * - * @author Geoffroy Jamgotchian - */ -public enum EnergySource { - HYDRO(false), - NUCLEAR(false), - WIND(true), - THERMAL(false), - SOLAR(true), - OTHER(false); - - private final boolean intermittent; - - private EnergySource(boolean intermittent) { - this.intermittent = intermittent; - } - - public boolean isIntermittent() { - return intermittent; - } - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EquipmentTopologyVisitor.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EquipmentTopologyVisitor.java deleted file mode 100644 index a9425227..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/EquipmentTopologyVisitor.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public abstract class EquipmentTopologyVisitor extends AbstractTopologyVisitor { - - public abstract void visitEquipment(Connectable eq); - - @Override - public void visitLine(Line line, TwoTerminalsConnectable.Side side) { - visitEquipment(line); - } - - @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoTerminalsConnectable.Side side) { - visitEquipment(transformer); - } - - @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { - visitEquipment(transformer); - } - - @Override - public void visitGenerator(Generator generator) { - visitEquipment(generator); - } - - @Override - public void visitLoad(Load load) { - visitEquipment(load); - } - - @Override - public void visitShuntCompensator(ShuntCompensator sc) { - visitEquipment(sc); - } - - @Override - public void visitDanglingLine(DanglingLine danglingLine) { - visitEquipment(danglingLine); - } - - @Override - public void visitStaticVarCompensator(StaticVarCompensator staticVarCompensator) { - visitEquipment(staticVarCompensator); - } - - @Override - public void visitHvdcConverterStation(HvdcConverterStation converterStation) { - visitEquipment(converterStation); - } -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Equipments.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Equipments.java deleted file mode 100644 index 877cbe96..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Equipments.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import java.util.Iterator; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class Equipments { - - private Equipments() { - } - - public static class ConnectionInfo { - - private final Bus connectionBus; - - private final boolean connected; - - public ConnectionInfo(Bus connectionBus, boolean connected) { - this.connectionBus = connectionBus; - this.connected = connected; - } - - public Bus getConnectionBus() { - return connectionBus; - } - - public boolean isConnected() { - return connected; - } - - } - - public static ConnectionInfo getConnectionInfoInBusBreakerView(Terminal t) { - Bus bus = t.getBusBreakerView().getBus(); - boolean connected; - if (bus != null) { - connected = true; - } else { - connected = false; - bus = t.getBusBreakerView().getConnectableBus(); - if (bus == null) { - // otherwise take first bus of the substation at the same voltage - // level... - Iterator itVLB = t.getVoltageLevel().getBusBreakerView().getBuses().iterator(); - if (itVLB.hasNext()) { - bus = itVLB.next(); - } else { - throw new RuntimeException("Cannot find a connection bus"); - } - } - } - return new ConnectionInfo(bus, connected); - } - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Generator.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Generator.java deleted file mode 100644 index fa54a36a..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Generator.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A power generator. - *

- * To create a generator, see {@link GeneratorAdder} - * - * @author Geoffroy Jamgotchian - * @see GeneratorAdder - * @see MinMaxReactiveLimits - * @see ReactiveCapabilityCurve - */ -public interface Generator extends SingleTerminalConnectable, ReactiveLimitsHolder { - - /** - * Get the energy source. - */ - EnergySource getEnergySource(); - - Generator setEnergySource(EnergySource energySource); - - /** - * Get the maximal active power in MW. - */ - float getMaxP(); - - /** - * Set the maximal active power in MW. - */ - Generator setMaxP(float maxP); - - /** - * Get the minimal active power in MW. - */ - float getMinP(); - - /** - * Set the minimal active power in MW. - */ - Generator setMinP(float minP); - - /** - * Get the voltage regulator status. - *

- * Depends on the working state. - * @see StateManager - */ - boolean isVoltageRegulatorOn(); - - /** - * Set the voltage regulator status. - *

- * Depends on the working state. - * @see StateManager - */ - Generator setVoltageRegulatorOn(boolean voltageRegulatorOn); - - /** - * Get the terminal used for regulation. - * @return the terminal used for regulation - */ - Terminal getRegulatingTerminal(); - - Generator setRegulatingTerminal(Terminal regulatingTerminal); - - /** - * Get the voltage target in kV. - *

- * Depends on the working state. - * @see StateManager - */ - float getTargetV(); - - /** - * Set the voltage target in kV. - *

- * Depends on the working state. - * @see StateManager - */ - Generator setTargetV(float targetV); - - /** - * Get the active power target in MW. - *

- * Depends on the working state. - * @see StateManager - */ - float getTargetP(); - - /** - * Set the active power target in MW. - *

- * Depends on the working state. - * @see StateManager - */ - Generator setTargetP(float targetP); - - /** - * Get the reactive power target in MVAR. - *

- * Depends on the working state. - * @see StateManager - */ - float getTargetQ(); - - /** - * Set the reactive power target in MVAR. - *

- * Depends on the working state. - * @see StateManager - */ - Generator setTargetQ(float targetQ); - - /** - * Get the rated nominal power in MVA. - * @return the rated nominal power in MVA or NaN if not defined - */ - float getRatedS(); - - Generator setRatedS(float ratedS); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/GeneratorAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/GeneratorAdder.java deleted file mode 100644 index bdd82b04..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/GeneratorAdder.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * To create a generator, from a VoltageLevel instance call - * the {@link VoltageLevel#newGenerator()} method to get a generator builder - * instance. - *

- * Example: - *

- *    VoltageLevel vl = ...
- *    Generator g = vl.newGenerator()
- *            .setId("g1")
- *            ...
- *        .add();
- *
- * - * @author Geoffroy Jamgotchian - * @see Generator - * @see VoltageLevel - */ -public interface GeneratorAdder extends SingleTerminalConnectableAdder { - - GeneratorAdder setEnergySource(EnergySource energySource); - - GeneratorAdder setMaxP(float maxP); - - GeneratorAdder setMinP(float minP); - - GeneratorAdder setVoltageRegulatorOn(boolean voltageRegulatorOn); - - /** - * Set the regulating terminal, If not set or set to null local terminal is used. - */ - GeneratorAdder setRegulatingTerminal(Terminal regulatingTerminal); - - GeneratorAdder setTargetP(float targetP); - - GeneratorAdder setTargetQ(float targetQ); - - GeneratorAdder setTargetV(float targetV); - - GeneratorAdder setRatedS(float ratedS); - - Generator add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcConverterStation.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcConverterStation.java deleted file mode 100644 index c4784dd0..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcConverterStation.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * HVDC converter station. This is the base class for VSC and LCC. - * AC side of the converter is connected inside a substation. - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface HvdcConverterStation> extends SingleTerminalConnectable { - - /** - * HDVC type: VSC or LCC - */ - enum HvdcType { - VSC, - LCC - } - - /** - * Get HVDC type. - * @return HVDC type - */ - HvdcType getHvdcType(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLine.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLine.java deleted file mode 100644 index 6ad2a3be..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLine.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A HVDC line connected to two HVDC converters on DC side. - * It has to be connected to the same {@link HvdcConverterStation} subclass. - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface HvdcLine extends Identifiable { - - /** - * Converters mode used to known the sign of the active power of the HVDC line. - */ - enum ConvertersMode { - SIDE_1_RECTIFIER_SIDE_2_INVERTER, - SIDE_1_INVERTER_SIDE_2_RECTIFIER - } - - /** - * Get the network this HVDC line belongs. - * @return the network this HVDC line belongs - */ - Network getNetwork(); - - /** - * Get converters mode. - * @return converters mode - */ - ConvertersMode getConvertersMode(); - - /** - * Change converters mode. - * @param mode converters mode - * @return the station itself to allow method chaining. - */ - HvdcLine setConvertersMode(ConvertersMode mode); - - /** - * Get resistance (in Ω) of the line. - * @return the resistance of the line - */ - float getR(); - - /** - * Set the resistance (in Ω) of the line. - * @param r the resistance of the line - * @return the HVDC line itself to allow method chaining - */ - HvdcLine setR(float r); - - /** - * Get the nominal voltage (in Kv). - * @return the nominal voltage. - */ - float getNominalV(); - - /** - * Set the nominal voltage. - * @param nominalV the nominal voltage. - * @return the HVDC line itself to allow method chaining - */ - HvdcLine setNominalV(float nominalV); - - /** - * Get the active power setpoint target (in MW). - * @return the active power setpoint target - */ - float getActivePowerSetPoint(); - - /** - * Set the active power setpoint target (in MW). - * @param activePowerSetPoint the active power setpoint target - * @return the HVDC line itself to allow method chaining - */ - HvdcLine setActivePowerSetPoint(float activePowerSetPoint); - - /** - * Get the maximum active power (in MW). - * @return the maximum active power - */ - float getMaxP(); - - /** - * Set the maximum active power (in MW). - * @param maxP the maximum active power - * @return the HVDC line itself to allow method chaining - */ - HvdcLine setMaxP(float maxP); - - /** - * Get the HVDC converter station connected on side 1. - * @return the HVDC converter station connected on side 1 - */ - HvdcConverterStation getConverterStation1(); - - /** - * Get the HVDC converter station connected on side 2. - * @return the HVDC converter station connected on side 2 - */ - HvdcConverterStation getConverterStation2(); - - /** - * Remove the HVDC line - */ - void remove(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLineAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLineAdder.java deleted file mode 100644 index c13fa9e3..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/HvdcLineAdder.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * HVDC line builder and adder. - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface HvdcLineAdder extends IdentifiableAdder { - - HvdcLineAdder setR(float r); - - HvdcLineAdder setConvertersMode(HvdcLine.ConvertersMode convertersMode); - - HvdcLineAdder setNominalV(float nominalV); - - HvdcLineAdder setActivePowerSetPoint(float activePowerSetPoint); - - HvdcLineAdder setMaxP(float maxP); - - HvdcLineAdder setConverterStationId1(String converterStationId1); - - HvdcLineAdder setConverterStationId2(String converterStationId2); - - HvdcLine add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Identifiable.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Identifiable.java deleted file mode 100644 index f2907e37..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Identifiable.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import java.util.Collection; -import java.util.Properties; - -/** - * An object that is part of the network model and that is identified uniquely - * by a String id. - * - * @author Geoffroy Jamgotchian - */ -public interface Identifiable> { - - interface Extension { - - String getName(); - - I getIdentifiable(); - } - - /** - * Get the unique identifier of the object. - */ - String getId(); - - /** - * Get an the (optional) name of the object. - */ - String getName(); - - /** - * Check that this object has some properties. - */ - boolean hasProperty(); - - /** - * Get properties associated to the object. - */ - Properties getProperties(); - - /** - * Add en extension to this identifiable. - * @param type the extension class type - * @param extension the extension - * @param the extension type - */ - > void addExtension(Class type, E extension); - - /** - * Get an extension based on its class type. - * @param type the extension class type - * @param the extension type - * @return the extension mapped to the class type or throws an exception if not found - */ - > E getExtension(Class type); - - /** - * Remove an extension based on its class type. - * @param type the extension class type - * @param the extension type - * @return true if the extension has been removed false if extension has not been found - */ - > boolean removeExtension(Class type); - - /** - * Get all extensions associated with this identifiable. - * @return all extensions associated to this identifiable - */ - Collection> getExtensions(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/IdentifiableAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/IdentifiableAdder.java deleted file mode 100644 index 26afc73a..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/IdentifiableAdder.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface IdentifiableAdder { - - T setId(String id); - - T setEnsureIdUnicity(boolean ensureIdUnicity); - - T setName(String name); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStation.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStation.java deleted file mode 100644 index acc20652..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStation.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * LCC converter station. - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface LccConverterStation extends HvdcConverterStation { - - /** - * Get power factor (ratio of the active power and the apparent power) - * @return the power factor. - */ - float getPowerFactor(); - - /** - * Set the power factor. Has to be greater that zero. - * @param powerFactor the new power factor - * @return the converter itself to allow method chaining - */ - LccConverterStation setPowerFactor(float powerFactor); - - /** - * Get a builder to create a new filter. - * @return a builder to create a new filter - */ - LccFilterAdder newFilter(); - - /** - * Get filter count. - * @return filter count - */ - int getFilterCount(); - - /** - * Remove a filter based on its index. - * @param index index of the filter to remove - */ - void removeFilterAt(int index); - - /** - * Get a filter based on its index. - * @param index index of the filter to get - * @return the filter corresponding to the index - */ - LccFilter getFilterAt(int index); - - /** - * Return all the filters. - * @return all the filters. - */ - Iterable getFilters(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStationAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStationAdder.java deleted file mode 100644 index 23402cd4..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccConverterStationAdder.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * LCC converter station builder and adder. - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface LccConverterStationAdder extends SingleTerminalConnectableAdder { - - LccConverterStationAdder setPowerFactor(float powerFactor); - - LccConverterStation add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilter.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilter.java deleted file mode 100644 index d794b695..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * Harmonic filter. - * q = b * v^2 - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface LccFilter { - - /** - * Get filter susceptance (Ω). - * @return - */ - float getB(); - - /** - * Set filter susceptance (Ω). - * @param b filter susceptance; - * @return the filter itself to allow method chaining - */ - LccFilter setB(float b); - - /** - * Check the filter is connected. - * @return true if the filter is connected, false otherwise. - */ - boolean isConnected(); - - /** - * Set the connection status of the filter. - * @param connected the new connection status of the filter - * @return the filter itself to allow method chaining - */ - LccFilter setConnected(boolean connected); -} - diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilterAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilterAdder.java deleted file mode 100644 index e6a86b03..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LccFilterAdder.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface LccFilterAdder { - - LccFilterAdder setB(float b); - - LccFilterAdder setConnected(boolean connected); - - LccFilter add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Line.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Line.java deleted file mode 100644 index f7e0461a..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Line.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * An AC line. - *

- * The equivalent π model used is: - *

- * - *
- * To create a line, see {@link LineAdder} - * - * @author Geoffroy Jamgotchian - * @see LineAdder - */ -public interface Line extends TwoTerminalsConnectable, LineCharasteristics { - - boolean isTieLine(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineAdder.java deleted file mode 100644 index c94fdd85..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineAdder.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * To create a new AC line, from a Network instance call the - * {@link Network#newLine()} method to get a line builder instance. - *

- * Example: - *

- *    Network n = ...
- *    Line l = n.newLine()
- *            .setId("l1")
- *            ...
- *        .add();
- *
- * - * @author Geoffroy Jamgotchian - * @see Line - * @see Network - */ -public interface LineAdder extends TwoTerminalsConnectableAdder { - - LineAdder setR(float r); - - LineAdder setX(float x); - - LineAdder setG1(float g1); - - LineAdder setB1(float b1); - - LineAdder setG2(float g2); - - LineAdder setB2(float b2); - - Line add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineCharasteristics.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineCharasteristics.java deleted file mode 100644 index ea35d527..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LineCharasteristics.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public interface LineCharasteristics { - - /** - * Get the series resistance in Ω. - */ - float getR(); - - /** - * Set the series resistance in Ω. - */ - T setR(float r); - - /** - * Get the series reactance in Ω. - */ - float getX(); - - /** - * Set the series reactance in Ω. - */ - T setX(float x); - - /** - * Get the first side shunt conductance in S. - */ - float getG1(); - - /** - * Set the first side shunt conductance in S. - */ - T setG1(float g1); - - /** - * Get the second side shunt conductance in S. - */ - float getG2(); - - /** - * Set the second side shunt conductance in S. - */ - T setG2(float g2); - - /** - * Get the first side shunt susceptance in S. - */ - float getB1(); - - /** - * Set the first side shunt susceptance in S. - */ - T setB1(float b1); - - /** - * Get the second side shunt susceptance in S. - */ - float getB2(); - - /** - * Set the second side shunt susceptance in S. - */ - T setB2(float b2); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Load.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Load.java deleted file mode 100644 index b8687f0d..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Load.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A constant power load (fixed p0 and q0). - *

p0 and q0 are given at the nominal voltage of the voltage level to which - * the load is connected (l.getTerminal().getVoltageLevel().getNominalV()). - * - *

To create a load, see {@link LoadAdder} - * - * @author Geoffroy Jamgotchian - * @see LoadAdder - */ -public interface Load extends SingleTerminalConnectable { - - LoadType getLoadType(); - - Load setLoadType(LoadType loadType); - - /** - * Get the constant active power in MW. - *

Depends on the working state. - * @see StateManager - */ - float getP0(); - - /** - * Set the constant active power in MW. - *

Depends on the working state. - * @see StateManager - */ - Load setP0(float p0); - - /** - * Get the constant reactive power in MVar. - *

Depends on the working state. - * @see StateManager - */ - float getQ0(); - - /** - * Set the constant reactive power in MVar. - *

Depends on the working state. - * @see StateManager - */ - Load setQ0(float q0); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadAdder.java deleted file mode 100644 index cf5b98f1..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadAdder.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * To create a load, from a VoltageLevel instance call - * the {@link VoltageLevel#newLoad()} method to get a load builder - * instance. - *

- * Example: - *

- *    VoltageLevel vl = ...
- *    Load l = vl.newLoad()
- *            .setId("l1")
- *            ...
- *        .add();
- *
- * - * @author Geoffroy Jamgotchian - * @see Load - * @see VoltageLevel - */ -public interface LoadAdder extends SingleTerminalConnectableAdder { - - LoadAdder setLoadType(LoadType loadType); - - LoadAdder setP0(float p0); - - LoadAdder setQ0(float q0); - - Load add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadType.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadType.java deleted file mode 100644 index 1f6ffd88..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/LoadType.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public enum LoadType { - UNDEFINED, - AUXILIARY, - FICTITIOUS -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimits.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimits.java deleted file mode 100644 index 56b644c1..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimits.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * Generator reactive limits that does not depend of the active - * power. - * - * @author Geoffroy Jamgotchian - */ -public interface MinMaxReactiveLimits extends ReactiveLimits { - - float getMinQ(); - - float getMaxQ(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimitsAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimitsAdder.java deleted file mode 100644 index c063beea..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/MinMaxReactiveLimitsAdder.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface MinMaxReactiveLimitsAdder { - - MinMaxReactiveLimitsAdder setMinQ(float minQ); - - MinMaxReactiveLimitsAdder setMaxQ(float maxQ); - - MinMaxReactiveLimits add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Network.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Network.java deleted file mode 100644 index 502ae315..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Network.java +++ /dev/null @@ -1,403 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import java.util.Collection; -import java.util.Set; -import org.joda.time.DateTime; - -/** - * A power network model. - * - *

To create a new network, use {@link NetworkFactory}. - * - *

The network is initially created with one state identified by - * StateManager.INITIAL_STATE_ID. {@link StateManager} is - * responsible for state management and is accessible from the network thanks - * to {@link #getStateManager()}. - * - *

Instances of Network are not thread safe except for attributes - * depending of the state (always specified in the javadoc) if - * {@link StateManager#allowStateMultiThreadAccess(boolean)} is set to true. - * - * @author Geoffroy Jamgotchian - * @see NetworkFactory - * @see StateManager - */ -public interface Network extends Container { - - /** - * A global bus/breaker view of the network. - *

- * Depends on the working state. - * @see StateManager - */ - public static interface BusBreakerView { - - /** - * Get all buses. - *

- * Depends on the working state. - * @see StateManager - */ - Iterable getBuses(); - - /** - * Get all switches. - */ - Iterable getSwitchs(); - - } - - /** - * A global bus view of the network. - */ - public static interface BusView { - - /** - * Get all buses. - *

- * Depends on the working state. - * @see StateManager - */ - Iterable getBuses(); - - /** - * Get all connected compoments. - *

- * Depends on the working state. - * @see StateManager - */ - Collection getConnectedComponents(); - - } - - /** - * Get the date that the network represents. - */ - DateTime getCaseDate(); - - /** - * Set the date that the network represents. - * @throws IllegalArgumentException if date is null. - */ - Network setCaseDate(DateTime date); - - /** - * Get the forecast distance in minutes. - *

Example: 0 for a snapshot, 6*60 to 30*60 for a DACF. - */ - int getForecastDistance(); - - Network setForecastDistance(int forecastDistance); - - /** - * Get the source format. - * @return the source format - */ - String getSourceFormat(); - - /** - * Get the state manager of the network. - */ - StateManager getStateManager(); - - /** - * Get all countries. - */ - Set getCountries(); - - /** - * Get the country count. - */ - int getCountryCount(); - - /** - * Get a builder to create a new substation. - */ - SubstationAdder newSubstation(); - - /** - * Get all substations. - */ - Iterable getSubstations(); - - /** - * Get the substation count. - */ - int getSubstationCount(); - - /** - * Get substation located in a specific county, TSO and marked with a list - * of geographical tag. - * - * @param country the country, if null there is no - * filtering on countries - * @param tsoId the id of the TSO, if null there is no - * filtering on TSOs - * @param geographicalTags a list a geographical tags - */ - Iterable getSubstations(Country country, String tsoId, String... geographicalTags); - - /** - * Get a substation. - * - * @param id the id of the substation - */ - Substation getSubstation(String id); - - /** - * Get all substation voltage levels. - */ - Iterable getVoltageLevels(); - - /** - * Get the voltage level count. - */ - int getVoltageLevelCount(); - - /** - * Get a substation voltage level. - * - * @param id the id of the substation voltage level - */ - VoltageLevel getVoltageLevel(String id); - - /** - * Get a builder to create a new AC line. - */ - LineAdder newLine(); - - /** - * Get all AC lines. - */ - Iterable getLines(); - - /** - * Get the AC line count. - */ - int getLineCount(); - - /** - * Get a AC line. - * - * @param id the name of the AC line - */ - Line getLine(String id); - - /** - * Get a builder to create a new AC tie line. - */ - TieLineAdder newTieLine(); - - /** - * Get all two windings transformers. - */ - Iterable getTwoWindingsTransformers(); - - /** - * Get the two windings transformer count. - */ - int getTwoWindingsTransformerCount(); - - /** - * Get a two windings transformer. - * - * @param id the id of the two windings transformer - */ - TwoWindingsTransformer getTwoWindingsTransformer(String id); - - /** - * Get all 3 windings transformers. - */ - Iterable getThreeWindingsTransformers(); - - /** - * Get the 3 windings transformer count. - */ - int getThreeWindingsTransformerCount(); - - /** - * Get a 3 windings transformer. - * - * @param id the id of the 3 windings transformer - */ - ThreeWindingsTransformer getThreeWindingsTransformer(String id); - - /** - * Get all generators. - */ - Iterable getGenerators(); - - /** - * Get the generator count. - */ - int getGeneratorCount(); - - /** - * Get a generator. - * - * @param id the id od the generator - */ - Generator getGenerator(String id); - - /** - * Get all loads. - */ - Iterable getLoads(); - - /** - * Get the load count. - */ - int getLoadCount(); - - /** - * Get a load. - * - * @param id the id the load - */ - Load getLoad(String id); - - /** - * Get all compensator shunts. - */ - Iterable getShunts(); - - /** - * Get the shunt count. - */ - int getShuntCount(); - - /** - * Get a compensator shunt. - * - * @param id the id of the compensator shunt - */ - ShuntCompensator getShunt(String id); - - /** - * Get all dangling lines. - */ - Iterable getDanglingLines(); - - /** - * Get the dangling line count. - */ - int getDanglingLineCount(); - - /** - * Get a dangling line. - * - * @param id the id of the dangling line - */ - DanglingLine getDanglingLine(String id); - - /** - * Get all static var compensators. - */ - Iterable getStaticVarCompensators(); - - /** - * Get the static var compensator count. - */ - int getStaticVarCompensatorCount(); - - /** - * Get a static var compensator. - * - * @param id the id of the static var compensator - */ - StaticVarCompensator getStaticVarCompensator(String id); - - /** - * Get a switch from its id. - * @param id id of the switch - * @return the switch - */ - Switch getSwitch(String id); - - /** - * Get all HVDC converter stations. - * @return all HVDC converter stations - */ - Iterable> getHvdcConverterStations(); - - /** - * Get HVDC converter stations count. - * @return HVDC converter station count - */ - int getHvdcConverterStationCount(); - - /** - * Get an HVDC converter station. - * @param id the id of the HVDC converter station - * @return the HVDC converter station or null if not found - */ - HvdcConverterStation getHvdcConverterStation(String id); - - /** - * Get all HVDC lines. - * @return all HVDC lines - */ - Iterable getHvdcLines(); - - /** - * Get HVDC lines count. - * @return HVDC lines count - */ - int getHvdcLineCount(); - - /** - * Get an HVDC line. - * @param id the id of the HVDC line - * @return the HVDC line or null if not found - */ - HvdcLine getHvdcLine(String id); - - /** - * Get a builder to create a new HVDC line. - * @return a builder to create a new HVDC line - */ - HvdcLineAdder newHvdcLine(); - - /** - * Get a equipment. - * - * @param id the id of the equipment - */ - Identifiable getIdentifiable(String id); - - /** - * Get all identifiables of the network. - * - * @return all identifiables of the network - */ - Collection> getIdentifiables(); - - /** - * Get a bus/breaker view of the network. - */ - BusBreakerView getBusBreakerView(); - - /** - * Get a bus view of the network. - */ - BusView getBusView(); - - /** - * Merge with an other network. At the end of the merge the other network - * is empty. - * @param other the other network - */ - void merge(Network other); - - void merge(Network... others); - - void addListener(NetworkListener listener); - - void removeListener(NetworkListener listener); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactory.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactory.java deleted file mode 100644 index c9e11f30..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import eu.itesla_project.commons.util.ServiceLoaderCache; -import java.util.List; - -/** - * To create a new empty network: - *

- *    Network n = NetworkFactory.create("test");
- *
- * - * @author Geoffroy Jamgotchian - */ -public class NetworkFactory { - - private static final ServiceLoaderCache LOADER - = new ServiceLoaderCache(NetworkFactoryService.class); - - private NetworkFactory() { - } - - public static Network create(String id, String sourceFormat) { - List services = LOADER.getServices(); - if (services.isEmpty()) { - throw new RuntimeException("No IIDM implementation found"); - } - return services.get(0).createNetwork(id, sourceFormat); - } -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactoryService.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactoryService.java deleted file mode 100644 index 85902a0f..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkFactoryService.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface NetworkFactoryService { - - Network createNetwork(String id, String sourceFormat); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkListener.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkListener.java deleted file mode 100644 index c06359f3..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/NetworkListener.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public interface NetworkListener { - - void onCreation(Identifiable identifiable); - - void onRemoval(Identifiable identifiable); - - void onUpdate(Identifiable identifiable, String attribute, Object oldValue, Object newValue); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChanger.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChanger.java deleted file mode 100644 index 939724e3..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChanger.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A phase tap changer that is associated to a transformer to control the phase. - * - * @author Geoffroy Jamgotchian - */ -public interface PhaseTapChanger extends TapChanger { - - enum RegulationMode { - CURRENT_LIMITER, - ACTIVE_POWER_CONTROL, - FIXED_TAP - } - - /** - * Get the regulation mode. - * @return the regulation mode - */ - RegulationMode getRegulationMode(); - - /** - * Set the regulation mode - * @param regulationMode the regulation mode - * @return itself for method chaining - */ - PhaseTapChanger setRegulationMode(RegulationMode regulationMode); - - /** - * Get the regulation value. - * - a threshold in A in case of current limiter regulation - * - a setpoint in MW in case of active power control regulation - *

- * Depends on the working state. - * @see StateManager - */ - float getRegulationValue(); - - /** - * Set the regulation value. - *

- * Depends on the working state. - * @see StateManager - */ - PhaseTapChanger setRegulationValue(float regulationValue); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerAdder.java deleted file mode 100644 index 32032361..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerAdder.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface PhaseTapChangerAdder { - - interface StepAdder { - - StepAdder setAlpha(float alpha); - - StepAdder setRho(float rho); - - StepAdder setR(float r); - - StepAdder setX(float x); - - StepAdder setG(float g); - - StepAdder setB(float b); - - PhaseTapChangerAdder endStep(); - } - - PhaseTapChangerAdder setLowTapPosition(int lowTapPosition); - - PhaseTapChangerAdder setTapPosition(int tapPosition); - - PhaseTapChangerAdder setRegulating(boolean regulating); - - PhaseTapChangerAdder setRegulationMode(PhaseTapChanger.RegulationMode regulationMode); - - PhaseTapChangerAdder setRegulationValue(float regulationValue); - - PhaseTapChangerAdder setRegulationTerminal(Terminal regulationTerminal); - - StepAdder beginStep(); - - PhaseTapChanger add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerHolder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerHolder.java deleted file mode 100644 index 2019fe78..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerHolder.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface PhaseTapChangerHolder { - - /** - * Get a builder to create and associate a phase tap changer to the - * transformer. - */ - PhaseTapChangerAdder newPhaseTapChanger(); - - /** - * Get the phase tap changer. - *

Could return null if the transfomer is not associated to - * a phase tap changer. - */ - PhaseTapChanger getPhaseTapChanger(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerStep.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerStep.java deleted file mode 100644 index 1f9432de..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/PhaseTapChangerStep.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface PhaseTapChangerStep extends TapChangerStep { - - /** - * Get the angle difference in degree. - */ - float getAlpha(); - - /** - * Set the angle difference in degree. - */ - PhaseTapChangerStep setAlpha(float alpha); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChanger.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChanger.java deleted file mode 100644 index 875f98f1..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChanger.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A ratio tap changer that is associated to a transformer to control the voltage. - * - * @author Geoffroy Jamgotchian - */ -public interface RatioTapChanger extends TapChanger { - - /** - * Get the target voltage in kV. - *

- * Depends on the working state. - * @see StateManager - */ - float getTargetV(); - - /** - * Set the target voltage in kV. - *

- * Depends on the working state. - * @see StateManager - */ - RatioTapChanger setTargetV(float targetV); - - /** - * Get the load tap changing capabilities status. - */ - boolean hasLoadTapChangingCapabilities(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerAdder.java deleted file mode 100644 index a8b4af36..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerAdder.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface RatioTapChangerAdder { - - public interface StepAdder { - - StepAdder setRho(float rho); - - StepAdder setR(float r); - - StepAdder setX(float x); - - StepAdder setG(float g); - - StepAdder setB(float b); - - RatioTapChangerAdder endStep(); - } - - RatioTapChangerAdder setLowTapPosition(int lowTapPosition); - - RatioTapChangerAdder setTapPosition(int tapPosition); - - RatioTapChangerAdder setLoadTapChangingCapabilities(boolean loadTapChangingCapabilities); - - RatioTapChangerAdder setRegulating(boolean regulating); - - RatioTapChangerAdder setTargetV(float targetV); - - RatioTapChangerAdder setRegulationTerminal(Terminal regulationTerminal); - - StepAdder beginStep(); - - RatioTapChanger add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerHolder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerHolder.java deleted file mode 100644 index 3f22de89..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerHolder.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface RatioTapChangerHolder { - - /** - * Get a builder to create and associate a ratio tap changer to the - * transformer. - */ - RatioTapChangerAdder newRatioTapChanger(); - - /** - * Get the ratio tap changer. - *

Could return null if the leg is not associated to a ratio - * tap changer. - */ - RatioTapChanger getRatioTapChanger(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerStep.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerStep.java deleted file mode 100644 index e4c0a0d7..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/RatioTapChangerStep.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface RatioTapChangerStep extends TapChangerStep { - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurve.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurve.java deleted file mode 100644 index d2ccc849..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurve.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import java.util.Collection; - -/** - * A reactive capability curve to define reactive limits of a Generator - * that depends of the active power. - *

- * This curve is made of Point and each point defines the minimum - * and maximum reactive limit for a given active power of the generator. - *

- * The following graph shows a 4 points reactive capability curve. On the X-axis - * is the active power in MW, on the Y-axis the minimal and maximal reactive - * values in MVAR. - *

- * Q (MVAR)
- * ^
- * |
- * |     *     *
- * |
- * | *             *
- * +---------------------> P (MW)
- * | *             *
- * |
- * |     *     *
- * |
- *
- * @author Geoffroy Jamgotchian - * @see Generator - */ -public interface ReactiveCapabilityCurve extends ReactiveLimits { - - /** - * A point of the reactive capability curve, for a given active power the - * minimal and the maximal value for the reactive power. - */ - public interface Point { - - float getP(); - - float getMinQ(); - - float getMaxQ(); - } - - /** - * Get the curve points. - */ - Collection getPoints(); - - /** - * Get the curve point count. - */ - int getPointCount(); - - /** - * Get the active power minimum value of the curve. - */ - float getMinP(); - - /** - * Get the active power maximim value of the curve. - */ - float getMaxP(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurveAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurveAdder.java deleted file mode 100644 index 4affbb8c..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveCapabilityCurveAdder.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ReactiveCapabilityCurveAdder { - - interface PointAdder { - - PointAdder setP(float p); - - PointAdder setMinQ(float minQ); - - PointAdder setMaxQ(float maxQ); - - ReactiveCapabilityCurveAdder endPoint(); - } - - PointAdder beginPoint(); - - ReactiveCapabilityCurve add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimits.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimits.java deleted file mode 100644 index 08b984e7..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimits.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * Base class for Generator reactive limits. - * - * @author Geoffroy Jamgotchian - */ -public interface ReactiveLimits { - - ReactiveLimitsKind getKind(); - - /** - * Get the reactive power minimum value at a given active power value. - * - * @param p the active power - */ - float getMinQ(float p); - - /** - * Get the reactive power maximum value at a given active power value. - * - * @param p the active power - */ - float getMaxQ(float p); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsHolder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsHolder.java deleted file mode 100644 index f1a2cfbf..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsHolder.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Mathieu Bague - */ -public interface ReactiveLimitsHolder { - - /** - * Get reactive limits of the generator. - */ - ReactiveLimits getReactiveLimits(); - - RL getReactiveLimits(Class type); - - /** - * Get a builder to create and associate a new reactive capability curve - * to this generator. - */ - ReactiveCapabilityCurveAdder newReactiveCapabilityCurve(); - - /** - * Get a builder to create and associate minimum and maximum reactive limits - * to this generator. - */ - MinMaxReactiveLimitsAdder newMinMaxReactiveLimits(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsKind.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsKind.java deleted file mode 100644 index dc75f124..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ReactiveLimitsKind.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum ReactiveLimitsKind { - MIN_MAX, - CURVE -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensator.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensator.java deleted file mode 100644 index 31ef0970..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensator.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A shunt compensator. - * - * To create a shunt compensator, see {@link ShuntCompensatorAdder} - * - * @author Geoffroy Jamgotchian - * @see ShuntCompensatorAdder - */ -public interface ShuntCompensator extends SingleTerminalConnectable { - - /** - * Get the maximum section count. - */ - int getMaximumSectionCount(); - - /** - * Set the maximum number of section. - * - * @param maximumSectionCount the maximum number of section - * @return the shunt compensator to chain method calls. - */ - ShuntCompensator setMaximumSectionCount(int maximumSectionCount); - - /** - * Get the current section count. - *

- * It is expected to be greater than one and lesser than or equal to the - * maximum section count. - *

- * Depends on the working state. - * @see StateManager - */ - int getCurrentSectionCount(); - - /** - * Change the number of section. - * - *

- * Depends on the working state. - * - * @see StateManager - * @param currentSectionCount the number of section - * @return the shunt compensator to chain method calls. - */ - ShuntCompensator setCurrentSectionCount(int currentSectionCount); - - /** - * Get the susceptance per section in S. - */ - float getbPerSection(); - - /** - * Set the susceptance per section in S. - * - * @param bPerSection the susceptance per section - * @return the shunt compensator to chain method calls. - */ - ShuntCompensator setbPerSection(float bPerSection); - - /** - * Get the susceptance for the maximum section count. - */ - float getMaximumB(); - - /** - * Get the susceptance for the current section counts. - *

- * Depends on the working state. - * @see StateManager - */ - float getCurrentB(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensatorAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensatorAdder.java deleted file mode 100644 index 3f941ade..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ShuntCompensatorAdder.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * To create a shunt compensator, from a VoltageLevel instance call - * the {@link VoltageLevel#newShunt()} method to get a shunt compensator builder - * instance. - *

- * Example: - *

- *    VoltageLevel vl = ...
- *    ShuntCompensator s = vl.newShunt()
- *            .setId("s1")
- *            ...
- *        .add();
- *
- * - * @author Geoffroy Jamgotchian - * @see ShuntCompensator - * @see VoltageLevel - */ -public interface ShuntCompensatorAdder extends SingleTerminalConnectableAdder { - - ShuntCompensatorAdder setbPerSection(float bPerSection); - - ShuntCompensatorAdder setMaximumSectionCount(int maximumSectionCount); - - ShuntCompensatorAdder setCurrentSectionCount(int currentSectionCount); - - ShuntCompensator add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectable.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectable.java deleted file mode 100644 index 611b173e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectable.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A equipment with one terminal. - * - * @author Geoffroy Jamgotchian - */ -public interface SingleTerminalConnectable> extends Connectable { - - /** - * Get the terminal. - */ - Terminal getTerminal(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectableAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectableAdder.java deleted file mode 100644 index 56e47988..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SingleTerminalConnectableAdder.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface SingleTerminalConnectableAdder extends IdentifiableAdder { - - T setNode(int node); - - T setBus(String bus); - - T setConnectableBus(String connectableBus); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StateManager.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StateManager.java deleted file mode 100644 index 72603fdc..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StateManager.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import eu.itesla_project.commons.ITeslaException; -import java.util.Collection; -import java.util.List; - -/** - * This class provides methods to manage states of the network (create and - * remove a state, set the working state, etc). - * - * @author Geoffroy Jamgotchian - */ -public interface StateManager { - - /** - * A constant for the id of the initial state (the one created by default) - */ - public static final String INITIAL_STATE_ID = "InitialState"; - - /** - * Get the state id list. - * - * @return the state id list - */ - Collection getStateIds(); - - /** - * Get the working state. - * - * @return the id of the working state - */ - String getWorkingStateId(); - - /** - * Set the working state. - * - * @param stateId the id of the working state - * @throws ITeslaException if the state is not found - */ - void setWorkingState(String stateId); - - /** - * Create a new state by cloning an existing one. - * - * @param sourceStateId the source state id - * @param targetStateIds the target state id list (the ones that will be created) - * @throws ITeslaException if the source state is not found or if a state with - * an id of targetStateIds already exists - */ - void cloneState(String sourceStateId, List targetStateIds); - - /** - * Create a new state by cloning an existing one. - * - * @param sourceStateId the source state id - * @param targetStateId the target state id (the one that will be created) - * @throws ITeslaException if the source state is not found or if a state with - * the id targetStateId already exists - */ - void cloneState(String sourceStateId, String targetStateId); - - /** - * Remove a state. - * - * @param stateId the id of the state to remove - */ - void removeState(String stateId); - - /** - * Allows states to be accessed simulaneously by different threads. When - * this options is activated, the working state can have a different value - * for each thread. - * @param allow - */ - void allowStateMultiThreadAccess(boolean allow); - - boolean isStateMultiThreadAccessAllowed(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensator.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensator.java deleted file mode 100644 index 399e903c..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensator.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * Static VAR compensator model. - * - * @author Geoffroy Jamgotchian - */ -public interface StaticVarCompensator extends SingleTerminalConnectable { - - enum RegulationMode { - VOLTAGE, - REACTIVE_POWER, - OFF - } - - /** - * Get the minimum susceptance in S. - * @return the minimum susceptance - */ - float getBmin(); - - /** - * Set the minimum susceptance in S. - * @param bMin minimum susceptance - * @return this to allow method chaining - */ - StaticVarCompensator setBmin(float bMin); - - /** - * Get the maximum susceptance in S. - * @return the maximum susceptance - */ - float getBmax(); - - /** - * Set the maximum susceptance in S. - * @param bMax the maximum susceptance - * @return this to allow method chaining - */ - StaticVarCompensator setBmax(float bMax); - - /** - *

Get the voltage set point in Kv.

- *

Needed only when regulating mode is set to {@link RegulationMode#VOLTAGE}.

- *

Depends on the working state.

- * @return the voltage set point - */ - float getVoltageSetPoint(); - - /** - *

Set the voltage set point in Kv.

- *

Needed only when regulating mode is set to {@link RegulationMode#VOLTAGE}.

- *

Depends on the working state.

- * @param voltageSetPoint the voltage set point - * @return this to allow method chaining - */ - StaticVarCompensator setVoltageSetPoint(float voltageSetPoint); - - /** - *

Get the reactive power set point in KV.

- *

Needed only when regulating mode is set to {@link RegulationMode#REACTIVE_POWER}.

- *

Depends on the working state.

- * @return the reactive power set point - */ - float getReactivePowerSetPoint(); - - /** - *

Set the reactive power set point in KV.

- *

Needed only when regulating mode is set to {@link RegulationMode#REACTIVE_POWER}.

- *

Depends on the working state.

- * @param reactivePowerSetPoint the reactive power set point - * @return this to allow method chaining - */ - StaticVarCompensator setReactivePowerSetPoint(float reactivePowerSetPoint); - - /** - *

Get the regulating mode.

- *

Depends on the working state.

- * @return the regulating mode - */ - RegulationMode getRegulationMode(); - - /** - *

set the regulating mode.

- *

Depends on the working state.

- * @param regulationMode the regulating mode - * @return this to allow method chaining - */ - StaticVarCompensator setRegulationMode(RegulationMode regulationMode); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensatorAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensatorAdder.java deleted file mode 100644 index eb6c6b60..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/StaticVarCompensatorAdder.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public interface StaticVarCompensatorAdder extends SingleTerminalConnectableAdder { - - StaticVarCompensatorAdder setBmin(float bMin); - - StaticVarCompensatorAdder setBmax(float bMax); - - StaticVarCompensatorAdder setVoltageSetPoint(float voltageSetPoint); - - StaticVarCompensatorAdder setReactivePowerSetPoint(float reactivePowerSetPoint); - - StaticVarCompensatorAdder setRegulationMode(StaticVarCompensator.RegulationMode regulationMode); - - StaticVarCompensator add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Substation.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Substation.java deleted file mode 100644 index c881bd80..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Substation.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import java.util.Set; - -/** - * A substation is a collection of equipment located at a the same geographical - * site. - *

It is composed of several voltage levels. - *

A substation is located to one country and belongs to one TSO. - *

To create a substation, see {@link SubstationAdder} - * @author Geoffroy Jamgotchian - * @see VoltageLevel - * @see Country - * @see SubstationAdder - */ -public interface Substation extends Container { - - Network getNetwork(); - - /** - * Get the country to which the substation belongs. - */ - Country getCountry(); - - Substation setCountry(Country country); - - /** - * Get the TSO to which the substation belongs. - */ - String getTso(); - - Substation setTso(String tso); - - /** - * Get a builder to create a new voltage level in the substation. - */ - VoltageLevelAdder newVoltageLevel(); - - /** - * Get the voltage levels of the substation. - */ - Iterable getVoltageLevels(); - - /** - * Get a builder to create a new two windings transformer in the substation. - */ - TwoWindingsTransformerAdder newTwoWindingsTransformer(); - - /** - * Get the two windings transformers connected to the substation. - */ - Iterable getTwoWindingsTransformers(); - - /** - * Get a builder to create a new 3 windings transformer in the substation. - */ - ThreeWindingsTransformerAdder newThreeWindingsTransformer(); - - /** - * Get the 3 windings transformers connected to the substation. - */ - Iterable getThreeWindingsTransformers(); - - /** - * Get geographical tags associated to the substation. - */ - Set getGeographicalTags(); - - /** - * Associate a new geographical tag to the substation. - */ - Substation addGeographicalTag(String tag); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SubstationAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SubstationAdder.java deleted file mode 100644 index 0a4c08d0..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SubstationAdder.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * To create a substation, from a Network instance call - * the {@link Network#newSubstation() } method to get a substation builder - * instance. - *

- * Example: - *

- *    Network n = ...
- *    Substation s = n.newSubstation()
- *            .setId("s1")
- *            ...
- *        .add();
- *
- * - * @author Geoffroy Jamgotchian - * @see Substation - * @see Network - */ -public interface SubstationAdder extends IdentifiableAdder { - - SubstationAdder setCountry(Country country); - - SubstationAdder setTso(String tso); - - SubstationAdder setGeographicalTags(String... tags); - - Substation add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Switch.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Switch.java deleted file mode 100644 index fb7b2f19..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Switch.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A switch to connect equipments in a substation. - * - * @author Geoffroy Jamgotchian - */ -public interface Switch extends Identifiable { - - /** - * Get the parent voltage level. - * @return the parent voltage level - */ - VoltageLevel getVoltageLevel(); - - /** - * Get the kind of switch. - */ - SwitchKind getKind(); - - /** - * Get the open status of the switch. - *

- * Depends on the working state. - * @see StateManager - */ - boolean isOpen(); - - /** - * Change the switch status. - *

- * Depends on the working state. - * @param open the new switch status - * @see StateManager - */ - void setOpen(boolean open); - - /** - * Get the retain status of the switch. A retained switch is a switch that - * will be part of the bus/breaker topology. - */ - boolean isRetained(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SwitchKind.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SwitchKind.java deleted file mode 100644 index dda41668..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/SwitchKind.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * The kind of switch. - * - * @author Geoffroy Jamgotchian - */ -public enum SwitchKind { - BREAKER, - DISCONNECTOR, - LOAD_BREAK_SWITCH -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChanger.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChanger.java deleted file mode 100644 index 5a7181db..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChanger.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface TapChanger, TCS extends TapChangerStep> { - - /** - * Get the lowest tap position corresponding to the first step of the tap changer. - */ - int getLowTapPosition(); - - /** - * Get the highest tap position corresponding to the last step of the tap changer. - */ - int getHighTapPosition(); - - /** - * Get the current tap position. - *

- * Depends on the working state. - * @see StateManager - */ - int getTapPosition(); - - /** - * Set the current tap position. - *

- * It is expected to be contained between the lowest and the highest tap position. - *

- * Depends on the working state. - * @see StateManager - * - * @param tapPosition the current tap position - */ - TC setTapPosition(int tapPosition); - - /** - * Get the number of steps. - */ - int getStepCount(); - - /** - * Get a step. - * - * @param tapPosition position of the tap - * @return the step - */ - TCS getStep(int tapPosition); - - /** - * Get the current step. - *

- * Depends on the working state. - * @see StateManager - */ - TCS getCurrentStep(); - - /** - * Get the regulating status. - *

- * Depends on the working state. - * @see StateManager - */ - boolean isRegulating(); - - /** - * Set the regulating status. - *

- * Depends on the working state. - * @see StateManager - */ - TC setRegulating(boolean regulating); - - /** - * Get the terminal used for regulation. - */ - Terminal getRegulationTerminal(); - - /** - * Set the terminal used for regulation. - */ - TC setRegulationTerminal(Terminal regulationTerminal); - - /** - * Remove the tap changer. - */ - void remove(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChangerStep.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChangerStep.java deleted file mode 100644 index 814a012e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TapChangerStep.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface TapChangerStep { - - /** - * Get the voltage ratio in per unit. - */ - float getRho(); - - /** - * Set the voltage ratio in per unit. - */ - TCS setRho(float rho); - - /** - * Get the resistance deviation in percent of nominal value. - */ - float getR(); - - /** - * Set the resistance deviation in percent of nominal value. - */ - TCS setR(float r); - - /** - * Get the reactance deviation in percent of nominal value. - */ - float getX(); - - /** - * Set the reactance deviation in percent of nominal value. - */ - TCS setX(float x); - - /** - * Get the susceptance deviation in percent of nominal value. - */ - float getB(); - - /** - * Set the susceptance deviation in percent of nominal value. - */ - TCS setB(float b); - - /** - * Get the conductance deviation in percent of nominal value. - */ - float getG(); - - /** - * Set the conductance deviation in percent of nominal value. - */ - TCS setG(float g); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Terminal.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Terminal.java deleted file mode 100644 index e9ee8c03..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/Terminal.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * An equipment connection point in a substation topology. - * - * @author Geoffroy Jamgotchian - */ -public interface Terminal { - - /** - * A node/breaker view of the terminal. - */ - public static interface NodeBreakerView { - - /** - * Get the connection node of this terminal in a node/breaker topology. - */ - int getNode(); - - } - - /** - * A bus/breaker view of the terminal. - */ - public static interface BusBreakerView { - - /** - * Get the connection bus of this terminal in the bus/breaker topology. - *

Depends on the working state. - * @return the connection bus in the bus/breaker topology or null if not connected - * @see StateManager - */ - Bus getBus(); - - /** - * Get a bus that can be used to connected the terminal in the - * bus/breaker topology. - */ - Bus getConnectableBus(); - - void setConnectableBus(String busId); - } - - /** - * A bus view of the terminal. - */ - public static interface BusView { - - /** - * Get the connection bus of this terminal in the bus only topology. - *

Depends on the working state. - * @return the connection bus in the bus only topology or null if not connected - * @see StateManager - */ - Bus getBus(); - - /** - * Get a bus that can be used to connected the terminal in the - * bus only topology. - */ - Bus getConnectableBus(); - - } - - /** - * Get the substation to which the terminal belongs. - */ - VoltageLevel getVoltageLevel(); - - /** - * Get a view to access to node/breaker topology informations at the terminal. - */ - NodeBreakerView getNodeBreakerView(); - - /** - * Get a view to access to bus/breaker topology informations at the terminal. - */ - BusBreakerView getBusBreakerView(); - - /** - * Get a view to access to bus topology informations at the terminal. - */ - BusView getBusView(); - - /** - * Get the equipment that is connected to the terminal. - */ - Connectable getConnectable(); - - /** - * Get the active power in MW injected at the terminal. - *

- * Depends on the working state. - * @see StateManager - */ - float getP(); - - /** - * Set the active power in MW injected at the terminal. - *

- * Depends on the working state. - * @see StateManager - */ - Terminal setP(float p); - - /** - * Get the reactive power in MVAR injected at the terminal. - *

- * Depends on the working state. - * @see StateManager - */ - float getQ(); - - /** - * Set the reactive power in MVAR injected at the terminal. - *

- * Depends on the working state. - * @see StateManager - */ - Terminal setQ(float q); - - /** - * Get the current in A at the terminal. - *

Depends on the working state. - * @see StateManager - */ - float getI(); - - /** - * Try to connect the terminal. - *

Depends on the working state. - * @return true if terminal has been connected, false otherwise - * @see StateManager - */ - boolean connect(); - - /** - * Disconnect the terminal. - *

Depends on the working state. - * @return true if terminal has been disconnected, false otherwise - * @see StateManager - */ - boolean disconnect(); - - /** - * Test if the terminal is connected. - * @return true if the terminal is connected, false otherwise - */ - boolean isConnected(); - - /** - * Traverse the full network topology graph. - * @param traverser traversal handler - */ - void traverse(VoltageLevel.TopologyTraverser traverser); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TerminalTopologyVisitor.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TerminalTopologyVisitor.java deleted file mode 100644 index d0a09d1d..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TerminalTopologyVisitor.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public abstract class TerminalTopologyVisitor extends AbstractTopologyVisitor { - - public abstract void visitTerminal(Terminal t); - - private void visitBranch(TwoTerminalsConnectable branch, TwoTerminalsConnectable.Side side) { - switch (side) { - case ONE: - visitTerminal(branch.getTerminal1()); - break; - case TWO: - visitTerminal(branch.getTerminal2()); - break; - default: - throw new AssertionError(); - } - } - - @Override - public void visitLine(Line line, TwoTerminalsConnectable.Side side) { - visitBranch(line, side); - } - - @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoTerminalsConnectable.Side side) { - visitBranch(transformer, side); - } - - @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { - switch (side) { - case ONE: - visitTerminal(transformer.getLeg1().getTerminal()); - break; - case TWO: - visitTerminal(transformer.getLeg2().getTerminal()); - break; - case THREE: - visitTerminal(transformer.getLeg3().getTerminal()); - break; - default: - throw new AssertionError(); - } - } - - private void visitInjection(SingleTerminalConnectable injection) { - visitTerminal(injection.getTerminal()); - } - - @Override - public void visitGenerator(Generator generator) { - visitInjection(generator); - } - - @Override - public void visitLoad(Load load) { - visitInjection(load); - } - - @Override - public void visitShuntCompensator(ShuntCompensator sc) { - visitInjection(sc); - } - - @Override - public void visitDanglingLine(DanglingLine danglingLine) { - visitInjection(danglingLine); - } - - @Override - public void visitStaticVarCompensator(StaticVarCompensator staticVarCompensator) { - visitInjection(staticVarCompensator); - } - - @Override - public void visitHvdcConverterStation(HvdcConverterStation converterStation) { - } -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformer.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformer.java deleted file mode 100644 index 56082537..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformer.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A 3 windings power transformer. - *

- * The equivalent star model used is: - *

- * - * - *
- *

Side 1 is the primary (high voltage), side 2 and side 3 can be indifferently - * the secondary (medium voltage) or the tertiary voltage (low voltage). - *

b1 and g1 unit is siemens. - *

r1, r2, r3, x1, x2 and x3 unit is ohm. - *

A 3 windings transformer is connected to 3 voltage levels (side 1, side 2 and side 3) - * that belong to the same substation. - *

To create a 3 windings transformer, see {@link ThreeWindingsTransformerAdder} - * @author Geoffroy Jamgotchian - * @see RatioTapChanger - * @see PhaseTapChanger - * @see ThreeWindingsTransformerAdder - */ -public interface ThreeWindingsTransformer extends Connectable { - - enum Side { - ONE, - TWO, - THREE - } - - interface LegBase { - - /** - * Get the terminal the leg is connected to. - */ - Terminal getTerminal(); - - /** - * Get the nominal series resistance specified in ohm at the voltage of - * the leg. - */ - float getR(); - - /** - * Set the nominal series resistance specified in ohm at the voltage of - * the leg. - */ - L setR(float r); - - /** - * Get the nominal series reactance specified in ohm at the voltage of - * the leg. - */ - float getX(); - - /** - * Set the nominal series reactance specified in ohm at the voltage of - * the leg. - */ - L setX(float x); - - /** - * Get the rated voltage in kV. - */ - float getRatedU(); - - /** - * Set the rated voltage in kV. - */ - L setRatedU(float ratedU); - - CurrentLimits getCurrentLimits(); - - CurrentLimitsAdder newCurrentLimits(); - - } - - /** - * Leg 1 of the equivalent star model. - */ - interface Leg1 extends LegBase { - - /** - * Get the nominal magnetizing conductance specified in S at the voltage - * of the leg. - */ - float getG(); - - /** - * Set the nominal magnetizing conductance specified in S at the voltage - * of the leg. - */ - Leg1 setG(float g); - - /** - * Get the nominal magnetizing susceptance specified in S at the voltage - * of the leg. - */ - float getB(); - - /** - * Set the nominal magnetizing susceptance specified in S at the voltage - * of the leg. - */ - Leg1 setB(float b); - - } - - /** - * Leg 2 or 3 of the equivalent star model. - */ - interface Leg2or3 extends LegBase, RatioTapChangerHolder { - - } - - Terminal getTerminal(Side side); - - /** - * Get the substation to which the transformer belongs. - */ - Substation getSubstation(); - - /** - * Get the leg at the primary side. - */ - Leg1 getLeg1(); - - /** - * Get the leg at the secondary side. - */ - Leg2or3 getLeg2(); - - /** - * Get the leg at the tertiary side. - */ - Leg2or3 getLeg3(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformerAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformerAdder.java deleted file mode 100644 index ab22f05e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/ThreeWindingsTransformerAdder.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface ThreeWindingsTransformerAdder extends IdentifiableAdder { - - public interface LegAdder { - - L setVoltageLevel(String voltageLevelId); - - L setNode(int node); - - L setBus(String bus); - - L setConnectableBus(String connectableBus); - - L setR(float r); - - L setX(float x); - - L setRatedU(float ratedU); - - ThreeWindingsTransformerAdder add(); - } - - public interface Leg1Adder extends LegAdder { - - Leg1Adder setG(float g); - - Leg1Adder setB(float b); - - } - - public interface Leg2or3Adder extends LegAdder { - - } - - Leg1Adder newLeg1(); - - Leg2or3Adder newLeg2(); - - Leg2or3Adder newLeg3(); - - ThreeWindingsTransformer add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLine.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLine.java deleted file mode 100644 index 3ef0e688..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLine.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public interface TieLine extends Line { - - interface HalfLine extends LineCharasteristics { - - String getId(); - - String getName(); - - /** - * Get Xnode active power consumption in MW. - */ - float getXnodeP(); - - /** - * Set Xnode active power consumption in MW. - */ - HalfLine setXnodeP(float p); - - /** - * Get Xnode reactive power consumption in MVar. - */ - float getXnodeQ(); - - /** - * Set Xnode reactive power consumption in MVar. - */ - HalfLine setXnodeQ(float q); - - } - - /** - * Get the UCTE Xnode code corresponding to this line in the case where the - * line is a boundary, return null otherwise. - */ - String getUcteXnodeCode(); - - /** - * Get first half of the line characteristics - */ - HalfLine getHalf1(); - - /** - * Get second half of the line characteristics - */ - HalfLine getHalf2(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLineAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLineAdder.java deleted file mode 100644 index 6cc868f8..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TieLineAdder.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * @author Geoffroy Jamgotchian - */ -public interface TieLineAdder extends TwoTerminalsConnectableAdder { - - TieLineAdder setR(float r); - - TieLineAdder setX(float x); - - TieLineAdder setG1(float g1); - - TieLineAdder setB1(float b1); - - TieLineAdder setG2(float g2); - - TieLineAdder setB2(float b2); - - TieLineAdder setXnodeP(float xnodeP); - - TieLineAdder setXnodeQ(float xnodeQ); - - TieLineAdder setUcteXnodeCode(String ucteXnodeCode); - - TieLineAdder line1(); - - TieLineAdder line2(); - - TieLine add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyKind.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyKind.java deleted file mode 100644 index 24a7c028..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyKind.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * The kind of topology. - * - * @author Geoffroy Jamgotchian - */ -public enum TopologyKind { - NODE_BREAKER, - BUS_BREAKER -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyVisitor.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyVisitor.java deleted file mode 100644 index 9482b575..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TopologyVisitor.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface TopologyVisitor { - - void visitBusbarSection(BusbarSection section); - - void visitLine(Line line, Line.Side side); - - void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoWindingsTransformer.Side side); - - void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side); - - void visitGenerator(Generator generator); - - void visitLoad(Load load); - - void visitShuntCompensator(ShuntCompensator sc); - - void visitDanglingLine(DanglingLine danglingLine); - - void visitStaticVarCompensator(StaticVarCompensator staticVarCompensator); - - default void visitHvdcConverterStation(HvdcConverterStation converterStation) {} -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectable.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectable.java deleted file mode 100644 index 8155003e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectable.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * An equipment with two terminals. - * - * @author Geoffroy Jamgotchian - */ -public interface TwoTerminalsConnectable> extends Connectable { - - enum Side { - ONE, - TWO - } - - interface Overload { - - CurrentLimits.TemporaryLimit getTemporaryLimit(); - - float getPreviousLimit(); - } - - /** - * Get the first terminal. - */ - Terminal getTerminal1(); - - /** - * Get the second terminal. - */ - Terminal getTerminal2(); - - Terminal getTerminal(Side side); - - Terminal getTerminal(String voltageLevelId); - - CurrentLimits getCurrentLimits1(); - - CurrentLimitsAdder newCurrentLimits1(); - - CurrentLimits getCurrentLimits2(); - - CurrentLimitsAdder newCurrentLimits2(); - - boolean isOverloaded(); - - int getOverloadDuration(); - - boolean checkPermanentLimit(Side side, float limitReduction); - - boolean checkPermanentLimit(Side side); - - boolean checkPermanentLimit1(float limitReduction); - - boolean checkPermanentLimit1(); - - boolean checkPermanentLimit2(float limitReduction); - - boolean checkPermanentLimit2(); - - Overload checkTemporaryLimits(Side side, float limitReduction); - - Overload checkTemporaryLimits(Side side); - - Overload checkTemporaryLimits1(float limitReduction); - - Overload checkTemporaryLimits1(); - - Overload checkTemporaryLimits2(float limitReduction); - - Overload checkTemporaryLimits2(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectableAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectableAdder.java deleted file mode 100644 index eac1241e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoTerminalsConnectableAdder.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface TwoTerminalsConnectableAdder extends IdentifiableAdder { - - T setVoltageLevel1(String voltageLevelId1); - - T setNode1(int node1); - - T setBus1(String bus1); - - T setConnectableBus1(String connectableBus1); - - T setVoltageLevel2(String voltageLevelId2); - - T setNode2(int node2); - - T setBus2(String bus2); - - T setConnectableBus2(String connectableBus2); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformer.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformer.java deleted file mode 100644 index 9b78a0ba..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformer.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * A two windings power transformer. - *

The equivalent π model used is: - *

- * - * - *
- *

b, g, r, x shall be specified at the side 2 voltage. - *

b and g unit is siemens, r and x unit is ohm. - *

b, g, r, x, ρ and α variables in the model can be computed with - * the following Java code supposing transfo is an instance of - * TwoWindingsTransformer. - *

- *r = transfo.getR()
- *    * (1 + (transfo.getRatioTapChanger() != null ? transfo.getRatioTapChanger().getCurrentStep().getR() / 100 : 0)
- *       + (transfo.getPhaseTapChanger() != null ? transfo.getPhaseTapChanger().getCurrentStep().getR() / 100 : 0));
- *x = transfo.getX()
- *    * (1 + (transfo.getRatioTapChanger() != null ? transfo.getRatioTapChanger().getCurrentStep().getX() / 100 : 0)
- *       + (transfo.getPhaseTapChanger() != null ? transfo.getPhaseTapChanger().getCurrentStep().getX() / 100 : 0));
- *g = transfo.getG()
- *    * (1 + (transfo.getRatioTapChanger() != null ? transfo.getRatioTapChanger().getCurrentStep().getG() / 100 : 0)
- *       + (transfo.getPhaseTapChanger() != null ? transfo.getPhaseTapChanger().getCurrentStep().getG() / 100 : 0));
- *b = transfo.getB()
- *    * (1 + (transfo.getRatioTapChanger() != null ? transfo.getRatioTapChanger().getCurrentStep().getB() / 100 : 0)
- *       + (transfo.getPhaseTapChanger() != null ? transfo.getPhaseTapChanger().getCurrentStep().getB() / 100 : 0));
- *rho = transfo.getRatedU2() / transfo.getRatedU1()
- *    * (transfo.getRatioTapChanger() != null ? transfo.getRatioTapChanger().getCurrentStep().getRho() : 1);
- *    * (transfo.getPhaseTapChanger() != null ? transfo.getPhaseTapChanger().getCurrentStep().getRho() : 1);
- *alpha = (transfo.getPhaseTapChanger() != null ? transfo.getPhaseTapChanger().getCurrentStep().getAlpha() : 0);
- *
- *
- * A 2 windings transformer is connected to 2 voltage levels (side 1 and side 2) - * that belong to the same substation. - *

To create a 2 windings transformer, see {@link TwoWindingsTransformerAdder} - * @author Geoffroy Jamgotchian - * @see RatioTapChanger - * @see PhaseTapChanger - * @see TwoWindingsTransformerAdder - */ -public interface TwoWindingsTransformer extends TwoTerminalsConnectable, RatioTapChangerHolder, PhaseTapChangerHolder { - - /** - * Get the substation to which the transformer belongs. - */ - Substation getSubstation(); - - /** - * Get the nominal series resistance specified in Ω at the secondary - * voltage side. - */ - float getR(); - - /** - * Set the nominal series resistance specified in Ω at the secondary - * voltage side. - */ - TwoWindingsTransformer setR(float r); - - /** - * Get the nominal series reactance specified in Ω at the secondary - * voltage side. - */ - float getX(); - - /** - * Set the nominal series reactance specified in Ω at the secondary - * voltage side. - */ - TwoWindingsTransformer setX(float x); - - /** - * Get the nominal magnetizing conductance specified in S at the secondary - * voltage side. - */ - float getG(); - - /** - * Set the nominal magnetizing conductance specified in S at the secondary - * voltage side. - */ - TwoWindingsTransformer setG(float g); - - /** - * Get the nominal magnetizing susceptance specified in S at the secondary - * voltage side. - */ - float getB(); - - /** - * Set the nominal magnetizing susceptance specified in S at the secondary - * voltage side. - */ - TwoWindingsTransformer setB(float b); - - /** - * Get the primary winding rated voltage in kV. - */ - float getRatedU1(); - - /** - * Set the secondary winding rated voltage in kV. - */ - TwoWindingsTransformer setRatedU1(float ratedU1); - - /** - * Get the secondary winding rated voltage in kV. - */ - float getRatedU2(); - - /** - * Set the secondary winding rated voltage in kV. - */ - TwoWindingsTransformer setRatedU2(float ratedU2); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformerAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformerAdder.java deleted file mode 100644 index f0c008ba..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/TwoWindingsTransformerAdder.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface TwoWindingsTransformerAdder extends TwoTerminalsConnectableAdder { - - TwoWindingsTransformerAdder setR(float r); - - TwoWindingsTransformerAdder setX(float x); - - TwoWindingsTransformerAdder setB(float b); - - TwoWindingsTransformerAdder setG(float g); - - TwoWindingsTransformerAdder setRatedU1(float ratedU1); - - TwoWindingsTransformerAdder setRatedU2(float ratedU2); - - TwoWindingsTransformer add(); - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevel.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevel.java deleted file mode 100644 index ac240527..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevel.java +++ /dev/null @@ -1,803 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.util.ShortIdDictionary; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; - -/** - * A voltage level is a collection of equipments located in the same substation - * and at the same base voltage. - *

A voltage level contains a topology model, i.e. an object that describes - * how equipments are connected together. - *

Topology model:

- * A voltage level may have two kinds of topology model depending on what level - * of detail we want to have ({@link #getTopologyKind}): - *
    - *
  • node/breaker model: this is the most detailed way to describe a topology. - * All elements are physical ones: busbar sections, breakers and disconnectors. - * A node in a node/breaker context means "connection node" and not topological - * node or bus.
  • - *
  • bus/breaker model: this is an aggregated form of the topology made of buses - * and breakers. A bus is the aggregation of busbar sections and closed switches.
  • - *
- *

Topology view:

- * A topology model can be managed through the 3 following views ordered from the - * most detailed to the less detailed: - *
    - *
  • node/breaker view
  • - *
  • bus/breaker view
  • - *
  • bus only view
  • - *
- *

Depending on the topology model kind of the voltage level a view can have - * the status: - *

    - *
  • N/A, it doesn't make sense to take view that is more detailed than the - * model. An exception is thrown when a method is called on an N/A view
  • - *
  • modifiable, when the view has the same level of detail than the model
  • - *
  • readable only, because the view is a result of a computation on the - * topology model
  • - *
- *

The view status is summarized in the following table: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Topology model
node/breakerbus/breaker
Topology viewnode/breakermodifiableN/A
bus/breakerreadablemodifiable
busreadablereadable
- *

Creating a substation with a node/breaker topology model:

- * The substation of the example has two voltage levels VL1 and VL2 described by a - * node/breaker topology model. The first voltage level VL1 has 2 busbar sections - * BBS1 and BBS2 , a generator GN, a load LD and a coupler BR3 between busbar - * section BBS1 and BBS2. The second voltage level VL2 has a single busbar - * section BBS3 a line LN and is connected to voltage level VL1 through - * transformer TR. - *

Here is a diagram of the substation: - *

- * - *
- * The node/breaker topology model is stored inside the voltage level as a graph - * where connection nodes are the vertices and switches are the edges. - *

The next diagram shows how to map the subtation topology to a graph. - *

- * - *
- * Each voltage level has its own topology graph. Voltage level VL1 has 8 - * connection nodes. Generator GN is connected to node 1, load LD to node 5, - * busbar sections BBS1 and BBS2 to node 3 and 4. 2, 6 and 7 are internal - * connection nodes. Voltage level VL2 has 3 nodes, line LN is connected to - * node 1, busbar section BBS3 to node 2. Transformer TR is connected - * to node 8 of voltage level 400Kv and node 3 of voltage level 225Kv. Plain - * edges represent closed switches. Dashed edges reprensent opened switches. - * Green edges will disappear during the bus/breaker topology computation - * whereas pink edges (like in this case 3<->4) will be retained whatever their - * position are (see {@link Switch#isRetained()}). - *

The following code shows how to create the substation with a node/breaker - * topology model. - *

- *    Network n = ...
- *    Substation s = ...
- *    VoltageLevel vl1 = s.newVoltageLevel()
- *        .setId("VL1")
- *        .setTopologyKind(TopologyKind.NODE_BREAKER)
- *        .add();
- *    vl1.getNodeBreakerView().setNodeCount(8);
- *    // create busbar sections BBS1 and BBS2
- *    vl1.getNodeBreakerView().newBusbarSection()
- *        .setId("BBS1")
- *        .add();
- *    vl1.getNodeBreakerView().newBusbarSection()
- *        .setId("BBS2")
- *        .add();
- *    // create generator GN
- *    vl1.newGenerator()
- *        .setId("GN")
- *        .setNode(1)
- *        ...
- *        .add();
- *    // create load LD
- *    vl1.newLoad()
- *        .setId("LD")
- *        .setNode(5)
- *        ...
- *        .add();
- *    // connect generator GN by creating breaker BR1 and disconnectors DI1 and DI2
- *    vl1.getNodeBreakerView().newBreaker()
- *        .setId("BR1")
- *        .setOpen(false)
- *        .setNode1(1)
- *        .setNode1(2)
- *        .add();
- *    vl1.getNodeBreakerView().newDisconnector()
- *        .setId("DI1")
- *        .setOpen(false)
- *        .setNode1(2)
- *        .setNode1(3)
- *        .add();
- *    vl1.getNodeBreakerView().newDisconnector()
- *        .setId("DI2")
- *        .setOpen(true)
- *        .setNode1(2)
- *        .setNode1(4)
- *        .add();
- *    // connect load LD
- *    ...
- *    // create busbar coupler BR3
- *    vl1.getNodeBreakerView().newBreaker()
- *        .setId("BR3")
- *        .setOpen(false)
- *        .setRetained(true) // retain this breaker in the bus/breaker topology!!!
- *        .setNode1(3)
- *        .setNode2(4)
- *        .add();
- *
- *    VoltageLevel vl2 = s.newVoltageLevel()
- *        .setId("VL2")
- *        .setTopologyKind(TopologyKind.NODE_BREAKER)
- *        .add();
- *    vl2.getNodeBreakerView().setNodeCount(3);
- *    // create busbar section BBS3
- *    vl2.getNodeBreakerView().newBusbarSection()
- *        .setId("BBS3")
- *        .add();
- *    // create line LN
- *    n.newLine()
- *        .setId("LN")
- *        .setVoltageLevel1("VL2")
- *        .setNode1(1)
- *        .setVoltageLevel2(...)
- *        .setNode2(...)
- *        ...
- *        .add();
- *
- *    // create transformer TR
- *    s.newTwoWindingsTransformer()
- *        .setId("TR")
- *        .setVoltageLevel1("VL1")
- *        .setNode1(8)
- *        .setVoltageLevel2("VL2")
- *        .setNode2(3)
- *        ...
- *        .add();
- * 
- * - *

The following diagram shows computed bus/breaker topology. Compared to - * node/breaker topology, only remains equipements (GN, LD, TR, LN), and switches - * flagged as retained (BR3). Equipments are now connected through buses - * (B1 and B2). - *

- * - *
- *

To get a bus/breaker view on the substation voltage level VL1 use - * {@link VoltageLevel#getBusBreakerView}. - * The following code shows how to get buses and breakers of the bus/breaker - * view in voltage level VL1. - *

- *    // VL1 contains 2 buses in the bus/breaker view
- *    Iterator<Bus> itB = vl1.getBusBreakerView().getBuses().iterator();
- *
- *    // first bus connects nodes 1, 2, 3, 5, 6
- *    Bus b1 = itB.next();
- *    // ... and consequently generator GN and load LD
- *    Generator gn = b1.getGenerators().iterator().next();
- *    Load ld = b1.getLoads().iterator().next();
- *
- *    // bus/breaker view can also be accessed from an equipment
- *    Bus alsoB1 = gn.getTerminal().getBusBreakerView.getBus();
- *
- *    // second bus connects nodes 4, 7, 8
- *    Bus b2 = itB.next();
- *    TwoWindingsTransformer tr = b2.getTwoWindingsTransformer().iterator().next();
- *
- *    // VL1 contains 1 switch in the bus/breaker view
- *    Iterator<Switch> itS = vl1.getBusBreakerView().getSwitches().iterator();
- *    Switch br3 = itS.next();
- * 
- * - *

The following diagram shows computed bus topology. Compared to bus/breaker - * topology, there is no switches anymore. Only remains equipements (GN, LD, TR, LN) - * connected through buses. - *

- * - *
- *

To get a bus view one the substation voltage level VL1 use - * {@link VoltageLevel#getBusView}. - * The following code shows how to get buses of the bus view in voltage level VL1. - *

- *    // VL1 contains 1 buses in the bus view
- *    Iterator<Bus> itB = vl1.getBusView().getBuses();
- *
- *    // the bus connects all the equipements of voltage level VL1
- *    Bus b1 = itB.next();
- * 
- *

Creating a substation with a bus/breaker topology model:

- * Instead of creating VL1 and VL3 with a node/breaker topology model, we can - * directly create them in a simpler bus/breaker topology model. It can be - * very useful when data source only contains bus/branch data link in DEF or CIM - * format. - *

The following code shows how to create the substation with a bus/breaker - * topology model. - *

- *    VoltageLevel vl1 = s.newVoltageLevel()
- *        .setId("VL1")
- *        .setTopologyKind(TopologyKind.BUS_BREAKER)
- *        .add();
- *    // create busbar sections BBS1 and BBS2
- *    vl1.getBusBreakerView().newBus()
- *        .setId("B1")
- *        .add();
- *    vl1.getBusBreakerView().newBus()
- *        .setId("B2")
- *        .add();
- *    // create generator GN
- *    vl1.newGenerator()
- *        .setId("GN")
- *        .setBus("B1")
- *        ...
- *        .add();
- *    // create load LD
- *    vl1.newLoad()
- *        .setId("LD")
- *        .setBus("B1")
- *        ...
- *        .add();
- *     // create busbar coupler BR3
- *     vl1.getBusBreakerView().newBreaker()
- *        .setId("BR3")
- *        .setOpen(false)
- *        .setBus1("B1")
- *        .setBus2("B2")
- *        .add();
- *
- *    VoltageLevel vl2 = s.newVoltageLevel()
- *        .setId("VL2")
- *        .setTopologyKind(TopologyKind.BUS_BREAKER)
- *        .add();
- *    vl2.getBusBreakerView().newBus()
- *        .setId("B3")
- *        .add();
- *    // create line LN
- *    n.newLine()
- *        .setId("LN")
- *        .setVoltageLevel1("VL2");
- *        .setBus1("B3")
- *        .setVoltageLevel2(...);
- *        .setBus2(...)
- *        ...
- *        .add();
- *
- *    // create transformer TR
- *    s.newTwoWindingsTransformer()
- *        .setId("TR")
- *        .setVoltageLevel1("VL1");
- *        .setBus1("B2")
- *        .setVoltageLevel2("VL2");
- *        .setBus2("B3")
- *        ...
- *        .add();
- * 
- *

Warning: in that case the node/breaker view status on voltage level VL1 and VL2 - * is N/A. - * - *

To create a voltage level, see {@link VoltageLevelAdder} - * - * @author Geoffroy Jamgotchian - * @see VoltageLevelAdder - */ -public interface VoltageLevel extends Container { - - /** - * A node/breaker view of the topology. - */ - public interface NodeBreakerView { - - public interface SwitchAdder extends IdentifiableAdder { - - SwitchAdder setNode1(int node1); - - SwitchAdder setNode2(int node2); - - SwitchAdder setKind(SwitchKind kind); - - SwitchAdder setKind(String kind); - - SwitchAdder setOpen(boolean open); - - SwitchAdder setRetained(boolean retained); - - Switch add(); - - } - - public interface InternalConnectionAdder extends IdentifiableAdder { - - InternalConnectionAdder setNode1(int node1); - - InternalConnectionAdder setNode2(int node2); - - void add(); - } - - /** - * Get the number of node. - */ - int getNodeCount(); - - /** - * Set the number of node. - */ - NodeBreakerView setNodeCount(int count); - - /** - * Get a builder to create a new switch. - */ - SwitchAdder newSwitch(); - - /** - * Get a builder to create a new switch. - */ - InternalConnectionAdder newInternalConnection(); - - /** - * Get a builder to create a new breaker. - */ - SwitchAdder newBreaker(); - - /** - * Get a builder to create a new disconnector. - */ - SwitchAdder newDisconnector(); - - /** - * Get the first node to which a switch is connected. - * - * @param switchId the id of the switch - * @throws ITeslaException if switch is not found - */ - int getNode1(String switchId); - - /** - * Get the second node to which a switch is connected. - * - * @param switchId the id of the switch - * @throws ITeslaException if switch is not found - */ - int getNode2(String switchId); - - /** - * Get a switch. - * - * @param switchId the id the switch - * @return the switch or null if not found - */ - Switch getSwitch(String switchId); - - /** - * Get switches. - */ - Iterable getSwitches(); - - /** - * Get the switch count. - */ - int getSwitchCount(); - - /** - * Get a builder to create a new busbar section. - */ - BusbarSectionAdder newBusbarSection(); - - /** - * Get busbar sections. - */ - Iterable getBusbarSections(); - - /** - * Get the busbar section count. - */ - int getBusbarSectionCount(); - - /** - * Get a busbar section. - * - * @param id the id of the busbar section - */ - BusbarSection getBusbarSection(String id); - - } - - /** - * A bus/breaker view of the topology. - */ - public interface BusBreakerView { - - public interface SwitchAdder extends IdentifiableAdder { - - SwitchAdder setBus1(String bus1); - - SwitchAdder setBus2(String bus2); - - SwitchAdder setOpen(boolean open); - - Switch add(); - - } - - /** - * Get buses. - *

- * Depends on the working state if topology kind is NODE_BREAKER. - * @see StateManager - */ - Iterable getBuses(); - - /** - * Get a bus. - *

- * Depends on the working state if topology kind is NODE_BREAKER. - * @param id the id of the bus. - * @return the bus or null if not found - * @see StateManager - */ - Bus getBus(String id); - - /** - * Get a builder to create a new bus. - * @throws ITeslaException if the topology kind is NODE_BREAKER - */ - BusAdder newBus(); - - /** - * Remove a bus. - * @param busId the bus id - */ - void removeBus(String busId); - - /** - * Remove all buses. - */ - void removeAllBuses(); - - /** - * Get switches. - */ - Iterable getSwitches(); - - /** - * Remove a switch. - * @param switchId the switch id - */ - void removeSwitch(String switchId); - - /** - * Remove all switches. - */ - void removeAllSwitches(); - - /** - * Get the first bus to which the switch is connected. - *

- * Depends on the working state if topology kind is NODE_BREAKER. - * @param switchId the id of the switch - * @throws ITeslaException if switch is not found - * @see StateManager - */ - Bus getBus1(String switchId); - - /** - * Get the second bus to which the switch is connected. - *

- * Depends on the working state if topology kind is NODE_BREAKER. - * @param switchId the id of the switch - * @throws ITeslaException if switch is not found - * @see StateManager - */ - Bus getBus2(String switchId); - - /** - * Get a switch. - * - * @param switchId the id of the switch - * @return the switch or null if not found - */ - Switch getSwitch(String switchId); - - /** - * Get a builer to create a new switch. - * @throws ITeslaException if the topology kind is NODE_BREAKER - */ - SwitchAdder newSwitch(); - - } - - /** - * A bus view of the substation topology. - */ - public interface BusView { - - /** - * Get buses. - *

- * Depends on the working state. - * @see StateManager - */ - Iterable getBuses(); - - /** - * Get a bus. - *

- * Depends on the working state. - * @param id the id of the bus. - * @return the bus or null if not found - * @see StateManager - */ - Bus getBus(String id); - - } - - /** - * Topology traversal handler - */ - interface TopologyTraverser { - - /** - * Called when a terminal in encountered. - * - * @param terminal the encountered terminal - * @param connected in bus/breaker topology, give the terminal connection status - * @return true to continue the graph traversal, false otherwise - */ - boolean traverse(Terminal terminal, boolean connected); - - /** - * Called when a switch in encountered - * - * @param aSwitch the encountered switch - * @return true to continue the graph traversal, false otherwise - */ - boolean traverse(Switch aSwitch); - - } - - /** - * Get the substation to which the voltage level belongs. - */ - Substation getSubstation(); - - /** - * Get the nominal voltage in KV. - */ - float getNominalV(); - - VoltageLevel setNominalV(float nominalV); - - /** - * Get the low voltage limit in KV. - * @return the low voltage limit or NaN if undefined - */ - float getLowVoltageLimit(); - - /** - * Set the low voltage limit in KV. - * @param lowVoltageLimit the low voltage limit in KV - */ - VoltageLevel setLowVoltageLimit(float lowVoltageLimit); - - /** - * Get the high voltage limit in KV. - * @return the high voltage limit or NaN if undefined - */ - float getHighVoltageLimit(); - - /** - * Set the high voltage limit in KV. - * @param highVoltageLimit the high voltage limit in KV - */ - VoltageLevel setHighVoltageLimit(float highVoltageLimit); - - /** - * Get an equipment connected to this substation voltage level. - * @param id the equipment id - * @param aClass - * @return the equipment - */ - T getConnectable(String id, Class aClass); - - /** - * Get a builder to create a new generator. - */ - GeneratorAdder newGenerator(); - - /** - * Get generators. - */ - Iterable getGenerators(); - - /** - * Get generator count. - */ - int getGeneratorCount(); - - /** - * Get a builder to create a new load. - */ - LoadAdder newLoad(); - - /** - * Get loads. - */ - Iterable getLoads(); - - /** - * Get load count. - */ - int getLoadCount(); - - /** - * Get a builder to create a new compensator shunt. - */ - ShuntCompensatorAdder newShunt(); - - /** - * Get compensator shunts. - */ - Iterable getShunts(); - - /** - * Get shunt count. - */ - int getShuntCount(); - - /** - * Get a builder to create a new dangling line. - */ - DanglingLineAdder newDanglingLine(); - - /** - * Get dangling lines. - */ - Iterable getDanglingLines(); - - /** - * Get dangling line count. - */ - int getDanglingLineCount(); - - /** - * Get a builder to create a new static var compensator. - */ - StaticVarCompensatorAdder newStaticVarCompensator(); - - /** - * Get static var compensators. - */ - Iterable getStaticVarCompensators(); - - /** - * Get static var compensator count. - */ - int getStaticVarCompensatorCount(); - - /** - * Get a builder to create a new VSC converter station connected to this voltage level. - * @return a builder to create a new VSC converter - */ - VscConverterStationAdder newVscConverterStation(); - - /** - * Get all VSC converter stations connected to this voltage level. - * @return all VSC converter stations connected to this voltage level - */ - Iterable getVscConverterStations(); - - /** - * Get VSC converter stations count connected to this voltage level. - * @return VSC converter stations count connected to this voltage level - */ - int getVscConverterStationCount(); - - /** - * Get a builder to create a new LCC converter station connected to this voltage level. - * @return a builder to create a new LCC converter - */ - LccConverterStationAdder newLccConverterStation(); - - /** - * Get all LCC converter stations connected to this voltage level. - * @return all LCC converter stations connected to this voltage level - */ - Iterable getLccConverterStations(); - - /** - * Get LCC converter stations count connected to this voltage level. - * @return LCC converter stations count connected to this voltage level - */ - int getLccConverterStationCount(); - - /** - * Visit equipments of the voltage level. - * @param visitor - */ - void visitEquipments(TopologyVisitor visitor); - - /** - * Get the kind of topology. - */ - TopologyKind getTopologyKind(); - - /** - * Get a node/breaker view of the topology. - * - * @return a node/breaker view of the topology - */ - NodeBreakerView getNodeBreakerView(); - - /** - * Get a bus/breaker view of the topology. - * - * @return a bus/breaker view of the topology - */ - BusBreakerView getBusBreakerView(); - - /** - * Get a bus view of the topology. - * - * @return a bus view of the topology - */ - BusView getBusView(); - - /** - * Print an ASCII representation of the topology on the standard ouput. - */ - void printTopology(); - - /** - * Print an ASCII representation of the topology on a stream. - * - * @param out the stream - */ - void printTopology(PrintStream out, ShortIdDictionary dict); - - /** - * Export in a file the topology in DOT format (Graphviz). - * - * @param filename the file name - */ - void exportTopology(String filename) throws IOException; - - /** - * Export the topology in DOT format (Graphviz). - * - * @param outputStream a writer - */ - void exportTopology(OutputStream outputStream) throws IOException; - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevelAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevelAdder.java deleted file mode 100644 index 2366e719..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VoltageLevelAdder.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface VoltageLevelAdder extends IdentifiableAdder { - - VoltageLevelAdder setNominalV(float nominalV); - - VoltageLevelAdder setLowVoltageLimit(float lowVoltageLimit); - - VoltageLevelAdder setHighVoltageLimit(float highVoltageLimit); - - VoltageLevelAdder setTopologyKind(String topologyKind); - - VoltageLevelAdder setTopologyKind(TopologyKind topologyKind); - - VoltageLevel add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStation.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStation.java deleted file mode 100644 index 055cc5ab..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStation.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * VSC converter station. - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface VscConverterStation extends HvdcConverterStation, ReactiveLimitsHolder { - - /** - * Check if voltage regulator is on. - * @return true if voltage regulator is on, false otherwise - */ - boolean isVoltageRegulatorOn(); - - /** - * Set voltage regulator status. - * @param voltageRegulatorOn the new voltage regulator status - * @return the converter itself to allow method chaining - */ - HvdcConverterStation setVoltageRegulatorOn(boolean voltageRegulatorOn); - - /** - * Get the voltage setpoint target (Kv). - * @return the voltage setpoint target - */ - float getVoltageSetPoint(); - - /** - * Set the voltage setpoint target (Kv). - * @param voltageSetPoint the voltage setpoint target - * @return the converter itself to allow method chaining - */ - HvdcConverterStation setVoltageSetPoint(float voltageSetPoint); - - /** - * Get the reactive power setpoint target (MVar). - * @return the reactive power setpoint target - */ - float getReactivePowerSetPoint(); - - /** - * Set the reactive power setpoint target (MVar). - * @param reactivePowerSetPoint the reactive power setpoint target - * @return the converter itself to allow method chaining - */ - HvdcConverterStation setReactivePowerSetPoint(float reactivePowerSetPoint); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStationAdder.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStationAdder.java deleted file mode 100644 index 4f6d42ed..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/VscConverterStationAdder.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network; - -/** - * VSC converter station builder and adder. - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public interface VscConverterStationAdder extends SingleTerminalConnectableAdder { - - VscConverterStationAdder setVoltageRegulatorOn(boolean voltageRegulatorOn); - - VscConverterStationAdder setVoltageSetPoint(float voltageSetPoint); - - VscConverterStationAdder setReactivePowerSetPoint(float reactivePowerSetPoint); - - VscConverterStation add(); -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ConnectedComponents.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ConnectedComponents.java deleted file mode 100644 index a0ad834e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ConnectedComponents.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.util; - -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.ConnectedComponent; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ConnectedComponents { - - private ConnectedComponents() { - } - - public static int getCcNum(Bus b) { - int ccNum = -1; - if (b != null) { - ConnectedComponent cc = b.getConnectedComponent(); - if (cc != null) { - ccNum = cc.getNum(); - } - } - return ccNum; - } - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/GraphvizConnectivity.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/GraphvizConnectivity.java deleted file mode 100644 index 254621cf..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/GraphvizConnectivity.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.util; - -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.TwoTerminalsConnectable; -import org.kohsuke.graphviz.Edge; -import org.kohsuke.graphviz.Graph; -import org.kohsuke.graphviz.Node; - -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.stream.StreamSupport; - -/** - * Example to generate a svg from the dot file: - * sfdp -Goverlap=prism -Tsvg -o /tmp/a.svg /tmp/a.dot - * - * @author Geoffroy Jamgotchian - */ -public class GraphvizConnectivity { - - private static final String NEWLINE = " "; - - private static final double GOLDEN_RATIO_CONJUGATE = 0.618033988749895; - - private static String[] generateColorScale(Network network) { - int maxCC = StreamSupport.stream(network.getBusView().getBuses().spliterator(), false).mapToInt(b -> b.getConnectedComponent().getNum()).max().getAsInt(); - String[] colors = new String[maxCC+1]; - Random ramdom = new Random(); - for (Bus bus : network.getBusView().getBuses()) { - double h = ramdom.nextDouble(); - h += GOLDEN_RATIO_CONJUGATE; - h %= 1; - long[] rgb = hsvToRgb(h, 0.5, 0.95); - String hex = String.format("#%02x%02x%02x", rgb[0], rgb[1], rgb[2]).toUpperCase(); - colors[bus.getConnectedComponent().getNum()] = hex; - } - return colors; - } - - private static long[] hsvToRgb(double h, double s, double v) { - int h_i = (int) Math.floor(h * 6); - double f = h * 6 - h_i; - double p = v * (1 - s); - double q = v * (1 - f * s); - double t = v * (1 - (1 - f) * s); - double r, g, b; - switch (h_i) { - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - case 5: - r = v; - g = p; - b = q; - break; - default: - throw new AssertionError(); - } - return new long[] { Math.round(r * 256), Math.round(g * 256), Math.round(b * 256) }; - } - - private final Network network; - - public GraphvizConnectivity(Network network) { - this.network = network; - } - - private static String getBusId(Bus bus) { - return bus.getId().replace('-', '_').replace("=", "_"); - } - - public void write(Path file) throws IOException { - try (OutputStream os = Files.newOutputStream(file)) { - write(os); - } - } - - public void write(OutputStream os) throws IOException { - Graph graph = new Graph().id("\"" + network.getId() + "\""); - String[] colors = generateColorScale(network); - Map nodes = new HashMap<>(); - for (Bus b : network.getBusView().getBuses()) { - long load = Math.round(StreamSupport.stream(b.getLoads().spliterator(), false).mapToDouble(l -> l.getP0()).sum()); - long maxGeneration = Math.round(StreamSupport.stream(b.getGenerators().spliterator(), false).mapToDouble(l -> l.getMaxP()).sum()); - String busId = getBusId(b); - Node n = new Node() - .id(busId) - .attr("shape", "oval") - .attr("style", "filled") - .attr("fontsize", "10") - .attr("fillcolor", colors[b.getConnectedComponent().getNum()]) - .attr("tooltip", "load=" + load + "MW" + NEWLINE + "max generation=" + maxGeneration + "MW" + NEWLINE + "cc=" + b.getConnectedComponent().getNum()); - nodes.put(busId, n); - graph.node(n); - } - for (TwoTerminalsConnectable branch : Iterables.concat(network.getLines(), network.getTwoWindingsTransformers())) { - Bus b1 = branch.getTerminal1().getBusView().getBus(); - Bus b2 = branch.getTerminal2().getBusView().getBus(); - if (b1 != null && b2 != null) { - Node n1 = nodes.get(getBusId(b1)); - Node n2 = nodes.get(getBusId(b2)); - graph.edge(new Edge(n1, n2).attr("tooltip", branch.getName())); - } - } - graph.writeTo(os); - } -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Identifiables.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Identifiables.java deleted file mode 100644 index 5a1ff548..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Identifiables.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.util; - -import eu.itesla_project.iidm.network.Identifiable; -import java.util.Collection; -import java.util.Map; -import java.util.TreeMap; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class Identifiables { - - private Identifiables() { - } - - public static Collection sort(Iterable identifiables) { - Map sortedIdentifiables = new TreeMap<>(); - for (T identifiable : identifiables) { - sortedIdentifiables.put(identifiable.getId(), identifiable); - } - return sortedIdentifiables.values(); - } - - public static String getNullableId(Identifiable identifiable) { - return identifiable == null ? null : identifiable.getId(); - } -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Networks.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Networks.java deleted file mode 100644 index 6e4f327e..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/Networks.java +++ /dev/null @@ -1,437 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.util; - -import com.google.common.collect.ImmutableMap; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.*; -import org.nocrala.tools.texttablefmt.BorderStyle; -import org.nocrala.tools.texttablefmt.CellStyle; -import org.nocrala.tools.texttablefmt.Table; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.script.*; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class Networks { - - private static final Logger LOGGER = LoggerFactory.getLogger(Networks.class); - - private Networks() { - } - - public static boolean isBusValid(int feederCount, int branchCount) { - return branchCount >=1; - } - - public static Map getExecutionTags(Network network) { - return ImmutableMap.of("state", network.getStateManager().getWorkingStateId()); - } - - public static void dumpStateId(Path workingDir, String stateId) throws IOException { - try (BufferedWriter writer = Files.newBufferedWriter(workingDir.resolve("state.txt"), StandardCharsets.UTF_8)) { - writer.write(stateId); - writer.newLine(); - } - } - - public static void dumpStateId(Path workingDir, Network network) throws IOException { - dumpStateId(workingDir, network.getStateManager().getWorkingStateId()); - } - - public static void runScript(Network network, Reader reader, Writer out) { - ScriptEngineManager mgr = new ScriptEngineManager(); - ScriptEngine jsEngine = mgr.getEngineByName("js"); - try { - ScriptContext context = new SimpleScriptContext(); - context.setAttribute("network", network, ScriptContext.ENGINE_SCOPE); - if (out != null) { - context.setWriter(out); - } - jsEngine.eval(reader, context); - } catch (ScriptException e) { - throw new ITeslaException(e); - } - } - - public static void printBalanceSummary(String title, Network network, Logger logger) { - - class ConnectedPower { - int busCount = 0; - - List connectedLoads = new ArrayList<>(); - List disconnectedLoads = new ArrayList<>(); - float connectedLoadVolume = 0f; - float disconnectedLoadVolume = 0f; - - float connectedMaxGeneration = 0f; - float disconnectedMaxGeneration = 0f; - float connectedGeneration = 0f; - float disconnectedGeneration = 0f; - List connectedGenerators = new ArrayList<>(); - List disconnectedGenerators = new ArrayList<>(); - - List connectedShunts = new ArrayList<>(); - List disconnectedShunts = new ArrayList<>(); - float connectedShuntPositiveVolume = 0f; - float disconnectedShuntPositiveVolume = 0f; - float connectedShuntNegativeVolume = 0f; - float disconnectedShuntNegativeVolume = 0f; - } - - ConnectedPower balanceMainCC = new ConnectedPower(); - ConnectedPower balanceOtherCC = new ConnectedPower(); - - for (Bus b : network.getBusBreakerView().getBuses()) { - if (b.isInMainConnectedComponent()) { - balanceMainCC.busCount++; - } else { - balanceOtherCC.busCount++; - } - } - - for (Load l : network.getLoads()) { - Terminal.BusBreakerView view = l.getTerminal().getBusBreakerView(); - if (view.getBus() != null) { - if (view.getBus().isInMainConnectedComponent()) { - balanceMainCC.connectedLoads.add(l.getId()); - balanceMainCC.connectedLoadVolume += l.getP0(); - } else { - balanceOtherCC.connectedLoads.add(l.getId()); - balanceOtherCC.connectedLoadVolume += l.getP0(); - } - } else { - if (view.getConnectableBus().isInMainConnectedComponent()) { - balanceMainCC.disconnectedLoads.add(l.getId()); - balanceMainCC.disconnectedLoadVolume += l.getP0(); - } else { - balanceOtherCC.disconnectedLoads.add(l.getId()); - balanceOtherCC.disconnectedLoadVolume += l.getP0(); - } - } - } - for (DanglingLine dl : network.getDanglingLines()) { - Terminal.BusBreakerView view = dl.getTerminal().getBusBreakerView(); - if (view.getBus() != null) { - if (view.getBus().isInMainConnectedComponent()) { - balanceMainCC.connectedLoads.add(dl.getId()); - balanceMainCC.connectedLoadVolume += dl.getP0(); - } else { - balanceOtherCC.connectedLoads.add(dl.getId()); - balanceOtherCC.connectedLoadVolume += dl.getP0(); - } - } else { - if (view.getConnectableBus().isInMainConnectedComponent()) { - balanceMainCC.disconnectedLoads.add(dl.getId()); - balanceMainCC.disconnectedLoadVolume += dl.getP0(); - } else { - balanceOtherCC.disconnectedLoads.add(dl.getId()); - balanceOtherCC.disconnectedLoadVolume += dl.getP0(); - } - } - } - for (Generator g : network.getGenerators()) { - Terminal.BusBreakerView view = g.getTerminal().getBusBreakerView(); - if (view.getBus() != null) { - if (view.getBus().isInMainConnectedComponent()) { - balanceMainCC.connectedMaxGeneration += g.getMaxP(); - balanceMainCC.connectedGeneration += g.getTargetP(); - balanceMainCC.connectedGenerators.add(g.getId()); - } else { - balanceOtherCC.connectedMaxGeneration += g.getMaxP(); - balanceOtherCC.connectedGeneration += g.getTargetP(); - balanceOtherCC.connectedGenerators.add(g.getId()); - } - } else { - if (view.getConnectableBus().isInMainConnectedComponent()) { - balanceMainCC.disconnectedMaxGeneration += g.getMaxP(); - balanceMainCC.disconnectedGeneration += g.getTargetP(); - balanceMainCC.disconnectedGenerators.add(g.getId()); - } else { - balanceOtherCC.disconnectedMaxGeneration += g.getMaxP(); - balanceOtherCC.disconnectedGeneration += g.getTargetP(); - balanceOtherCC.disconnectedGenerators.add(g.getId()); - } - } - } - for (ShuntCompensator sc : network.getShunts()) { - Terminal.BusBreakerView view = sc.getTerminal().getBusBreakerView(); - double q = sc.getCurrentB() * Math.pow(sc.getTerminal().getVoltageLevel().getNominalV(), 2); - if (view.getBus() != null) { - if (view.getBus().isInMainConnectedComponent()) { - if (q > 0) { - balanceMainCC.connectedShuntPositiveVolume += q; - } else { - balanceMainCC.connectedShuntNegativeVolume += q; - } - balanceMainCC.connectedShunts.add(sc.getId()); - } else { - if (q > 0) { - balanceOtherCC.connectedShuntPositiveVolume += q; - } else { - balanceOtherCC.connectedShuntNegativeVolume += q; - } - balanceOtherCC.connectedShunts.add(sc.getId()); - } - } else { - if (view.getConnectableBus().isInMainConnectedComponent()) { - if (q > 0) { - balanceMainCC.disconnectedShuntPositiveVolume += q; - } else { - balanceMainCC.disconnectedShuntNegativeVolume += q; - } - balanceMainCC.disconnectedShunts.add(sc.getId()); - } else { - if (q > 0) { - balanceOtherCC.disconnectedShuntPositiveVolume += q; - } else { - balanceOtherCC.disconnectedShuntNegativeVolume += q; - } - balanceOtherCC.disconnectedShunts.add(sc.getId()); - } - } - } - Table table = new Table(5, BorderStyle.CLASSIC_WIDE); - table.addCell(""); - table.addCell("Main CC connected/disconnected", 2); - table.addCell("Others CC connected/disconnected", 2); - table.addCell("Bus count"); - CellStyle centerStyle = new CellStyle(CellStyle.HorizontalAlign.center); - table.addCell(Integer.toString(balanceMainCC.busCount), centerStyle, 2); - table.addCell(Integer.toString(balanceOtherCC.busCount), centerStyle, 2); - table.addCell("Load count"); - table.addCell("" + balanceMainCC.connectedLoads.size()); - table.addCell("" + balanceMainCC.disconnectedLoads.size()); - table.addCell("" + balanceOtherCC.connectedLoads.size()); - table.addCell("" + balanceOtherCC.disconnectedLoads.size()); - table.addCell("Load (MW)"); - table.addCell("" + balanceMainCC.connectedLoadVolume); - table.addCell("" + balanceMainCC.disconnectedLoadVolume); - table.addCell("" + balanceOtherCC.connectedLoadVolume); - table.addCell("" + balanceOtherCC.disconnectedLoadVolume); - table.addCell("Generator count"); - table.addCell("" + balanceMainCC.connectedGenerators.size()); - table.addCell("" + balanceMainCC.disconnectedGenerators.size()); - table.addCell("" + balanceOtherCC.connectedGenerators.size()); - table.addCell("" + balanceOtherCC.disconnectedGenerators.size()); - table.addCell("Max generation (MW)"); - table.addCell("" + balanceMainCC.connectedMaxGeneration); - table.addCell("" + balanceMainCC.disconnectedMaxGeneration); - table.addCell("" + balanceOtherCC.connectedMaxGeneration); - table.addCell("" + balanceOtherCC.disconnectedMaxGeneration); - table.addCell("Generation (MW)"); - table.addCell("" + balanceMainCC.connectedGeneration); - table.addCell("" + balanceMainCC.disconnectedGeneration); - table.addCell("" + balanceOtherCC.connectedGeneration); - table.addCell("" + balanceOtherCC.disconnectedGeneration); - table.addCell("Shunt at nom V (MVar)"); - table.addCell("" + balanceMainCC.connectedShuntPositiveVolume + " " + balanceMainCC.connectedShuntNegativeVolume + " (" + balanceMainCC.connectedShunts.size() + ")"); - table.addCell("" + balanceMainCC.disconnectedShuntPositiveVolume + " " + balanceMainCC.disconnectedShuntNegativeVolume + " (" + balanceMainCC.disconnectedShunts.size() + ")"); - table.addCell("" + balanceOtherCC.connectedShuntPositiveVolume + " " + balanceOtherCC.connectedShuntNegativeVolume + " (" + balanceOtherCC.connectedShunts.size() + ")"); - table.addCell("" + balanceOtherCC.disconnectedShuntPositiveVolume + " " + balanceOtherCC.disconnectedShuntNegativeVolume + " (" + balanceOtherCC.disconnectedShunts.size() + ")"); - - logger.debug("Active balance at step '{}':\n{}", title, table.render()); - - if (balanceOtherCC.connectedLoads.size() > 0) { - logger.trace("Connected loads in other CC: {}", balanceOtherCC.connectedLoads); - } - if (balanceOtherCC.disconnectedLoads.size() > 0) { - logger.trace("Disconnected loads in other CC: {}", balanceOtherCC.disconnectedLoads); - } - if (balanceOtherCC.connectedGenerators.size() > 0) { - logger.trace("Connected generators in other CC: {}", balanceOtherCC.connectedGenerators); - } - if (balanceOtherCC.disconnectedGenerators.size() > 0) { - logger.trace("Disconnected generators in other CC: {}", balanceOtherCC.disconnectedGenerators); - } - if (balanceOtherCC.disconnectedShunts.size() > 0) { - logger.trace("Disconnected shunts in other CC: {}", balanceOtherCC.disconnectedShunts); - } - } - - - public static void printGeneratorsSetpointDiff(Network network, Logger logger) { - for (Generator g : network.getGenerators()) { - float dp = Math.abs(g.getTerminal().getP() + g.getTargetP()); - float dq = Math.abs(g.getTerminal().getQ() + g.getTargetQ()); - float dv = Math.abs(g.getTerminal().getBusBreakerView().getConnectableBus().getV() - g.getTargetV()); - if (dp > 1 || dq > 5 || dv > 0.1) { - logger.warn("Generator {}: ({}, {}, {}) ({}, {}, {}) -> ({}, {}, {})", g.getId(), - dp, dq, dv, - -g.getTargetP(), -g.getTargetQ(), g.getTargetV(), - g.getTerminal().getP(), g.getTerminal().getQ(), g.getTerminal().getBusBreakerView().getConnectableBus().getV()); - } - } - } - - private static double EPSILON_X = 0.01; - - public static boolean checkFlows(String id, double r, double x, double rho1, double rho2, double u1, double u2, double theta1, double theta2, double alpha1, - double alpha2, double g1, double g2, double b1, double b2, float p1, float q1, float p2, float q2) { - if (Math.abs(x) < EPSILON_X) { - // System.out.println("x " + x + " -> " + EPSILON_X); - // x = EPSILON_X; - } - double z = Math.hypot(r, x); - double y = 1 / z; - double ksi = Math.atan2(r, x); - double p1_calc = rho1 * rho2 * u1 * u2 * y * Math.sin(theta1 - theta2 - ksi + alpha1 - alpha2) + rho1 * rho1 * u1 * u1 * (y * Math.sin(ksi) + g1); - double q1_calc = - rho1 * rho2 * u1 * u2 * y * Math.cos(theta1 - theta2 - ksi + alpha1 - alpha2) + rho1 * rho1 * u1 * u1 * (y * Math.cos(ksi) - b1); - double p2_calc = rho2 * rho1 * u2 * u1 * y * Math.sin(theta2 - theta1 - ksi + alpha2 - alpha1) + rho2 * rho2 * u2 * u2 * (y * Math.sin(ksi) + g2); - double q2_calc = - rho2 * rho1 * u2 * u1 * y * Math.cos(theta2 - theta1 - ksi + alpha2 - alpha1) + rho2 * rho2 * u2 * u2 * (y * Math.cos(ksi) - b2); - - boolean debug = false; - if (debug) { - System.out.println("r=" + r); - System.out.println("x=" + x); - System.out.println("g1=" + g1); - System.out.println("g2=" + g2); - System.out.println("b1=" + b1); - System.out.println("b2=" + b2); - System.out.println("rho1=" + rho1); - System.out.println("rho2=" + rho2); - System.out.println("alpha1=" + alpha1); - System.out.println("alpha2=" + alpha2); - System.out.println("u1=" + u1); - System.out.println("u2=" + u2); - System.out.println("theta1=" + theta1); - System.out.println("theta2=" + theta2); - System.out.println("z=" + z); - System.out.println("y=" + y); - System.out.println("ksi=" + ksi); - System.out.println("p1=" + p1); - System.out.println("q1=" + q1); - System.out.println("p2=" + p2); - System.out.println("q2=" + q2); - } - float seuil = 0.1f; - boolean ok = true; - if (Math.abs(p1 - p1_calc) > seuil) { - System.out.println(id + " P1 " + p1 + " " + p1_calc); - ok = false; - } - if (Math.abs(q1 - q1_calc) > seuil) { - System.out.println(id + " Q1 " + q1 + " " + q1_calc); - ok = false; - } - if (Math.abs(p2 - p2_calc) > seuil) { - System.out.println(id + " P2 " + p2 + " " + p2_calc); - ok = false; - } - if (Math.abs(q2 - q2_calc) > seuil) { - System.out.println(id + " Q2 " + q2 + " " + q2_calc); - ok = false; - } - return ok; - } - - public static boolean checkFlows(Line l) { - float p1 = l.getTerminal1().getP(); - float q1 = l.getTerminal1().getQ(); - float p2 = l.getTerminal2().getP(); - float q2 = l.getTerminal2().getQ(); - Bus bus1 = l.getTerminal1().getBusView().getBus(); - Bus bus2 = l.getTerminal2().getBusView().getBus(); - if (bus1 != null && bus2 != null && !Float.isNaN(p1) && !Float.isNaN(p2) && !Float.isNaN(q1) && !Float.isNaN(q2)) { - double r = l.getR(); - double x = l.getX(); - double rho1 = 1f; - double rho2 = 1f; - double u1 = bus1.getV(); - double u2 = bus2.getV(); - double theta1 = Math.toRadians(bus1.getAngle()); - double theta2 = Math.toRadians(bus2.getAngle()); - double alpha1 = 0f; - double alpha2 = 0f; - double g1 = l.getG1(); - double g2 = l.getG2(); - double b1 = l.getB1(); - double b2 = l.getB2(); - return checkFlows(l.getId(), r, x, rho1, rho2, u1, u2, theta1, theta2, alpha1, alpha2, g1, g2, b1, b2, p1, q1, p2, q2); - } - return true; - } - - public static boolean checkFlows(TwoWindingsTransformer twt) { - if (twt.getRatioTapChanger() != null && twt.getPhaseTapChanger() != null) { - throw new AssertionError(); - } - float p1 = twt.getTerminal1().getP(); - float q1 = twt.getTerminal1().getQ(); - float p2 = twt.getTerminal2().getP(); - float q2 = twt.getTerminal2().getQ(); - Bus bus1 = twt.getTerminal1().getBusView().getBus(); - Bus bus2 = twt.getTerminal2().getBusView().getBus(); - if (bus1 != null && bus2 != null && !Float.isNaN(p1) && !Float.isNaN(p2) && !Float.isNaN(q1) && !Float.isNaN(q2)) { - float r = twt.getR(); - float x = twt.getX(); - double g1 = twt.getG(); - double g2 = 0f; - double b1 = twt.getB() / 2; - double b2 = twt.getB() / 2; - if (twt.getRatioTapChanger() != null) { - r *= (1 + twt.getRatioTapChanger().getCurrentStep().getR() / 100); - x *= (1 + twt.getRatioTapChanger().getCurrentStep().getX() / 100); - g1 *= (1 + twt.getRatioTapChanger().getCurrentStep().getG() / 100); - b1 *= (1 + twt.getRatioTapChanger().getCurrentStep().getB() / 100); - } - if (twt.getPhaseTapChanger() != null) { - r *= (1 + twt.getPhaseTapChanger().getCurrentStep().getR() / 100); - x *= (1 + twt.getPhaseTapChanger().getCurrentStep().getX() / 100); - g1 *= (1 + twt.getPhaseTapChanger().getCurrentStep().getG() / 100); - b1 *= (1 + twt.getPhaseTapChanger().getCurrentStep().getB() / 100); - } - - double rho1 = twt.getRatedU2() / twt.getRatedU1(); - if (twt.getRatioTapChanger() != null) { - rho1 *= twt.getRatioTapChanger().getCurrentStep().getRho(); - } - if (twt.getPhaseTapChanger() != null) { - rho1 *= twt.getPhaseTapChanger().getCurrentStep().getRho(); - } - double rho2 = 1f; - double u1 = bus1.getV(); - double u2 = bus2.getV(); - double theta1 = Math.toRadians(bus1.getAngle()); - double theta2 = Math.toRadians(bus2.getAngle()); - double alpha1 = twt.getPhaseTapChanger() != null ? Math.toRadians(twt.getPhaseTapChanger().getCurrentStep().getAlpha()) : 0f; - double alpha2 = 0f; - return checkFlows(twt.getId(), r, x, rho1, rho2, u1, u2, theta1, theta2, alpha1, alpha2, g1, g2, b1, b2, p1, q1, p2, q2); - } - return true; - } - - public static boolean checkFlows(Network network) { - boolean ok = true; - for (Line l : network.getLines()) { - if (!checkFlows(l)) { - ok = false; - } - } - for (TwoWindingsTransformer twt : network.getTwoWindingsTransformers()) { - if (!checkFlows(twt)) { - ok = false; - } - } - return ok; - } - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/SV.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/SV.java deleted file mode 100644 index 9dbe6bfb..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/SV.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.util; - -import eu.itesla_project.iidm.network.DanglingLine; -import eu.itesla_project.iidm.network.Line; -import eu.itesla_project.iidm.network.TwoWindingsTransformer; -import org.apache.commons.math3.complex.Complex; -import org.apache.commons.math3.complex.ComplexUtils; - -/** - * Utility class to compute the state variables on one side of a branch, knowing - * the state variables on the other side. - * - * @author Geoffroy Jamgotchian - */ -public class SV { - - public static float getRatio(TwoWindingsTransformer twt) { - float rho = twt.getRatedU2() / twt.getRatedU1(); - if (twt.getRatioTapChanger() != null) { - rho *= twt.getRatioTapChanger().getCurrentStep().getRho(); - } - return rho; - } - - public static float getR(TwoWindingsTransformer twt) { - float r = twt.getR(); - if (twt.getRatioTapChanger() != null) { - r *= (1 + twt.getRatioTapChanger().getCurrentStep().getR() / 100); - } - return r; - } - - public static float getX(TwoWindingsTransformer twt) { - float x = twt.getX(); - if (twt.getRatioTapChanger() != null) { - x *= (1 + twt.getRatioTapChanger().getCurrentStep().getX() / 100); - } - return x; - } - - public static float getG(TwoWindingsTransformer twt) { - float g = twt.getG(); - if (twt.getRatioTapChanger() != null) { - g *= (1 + twt.getRatioTapChanger().getCurrentStep().getG() / 100); - } - return g; - } - - public static float getB(TwoWindingsTransformer twt) { - float b = twt.getB(); - if (twt.getRatioTapChanger() != null) { - b *= (1 + twt.getRatioTapChanger().getCurrentStep().getB() / 100); - } - return b; - } - - float p; - - float q; - - float u; - - float a; - - public SV(float p, float q, float u, float a) { - this.p = p; - this.q = q; - this.u = u; - this.a = a; - } - - public float getP() { - return p; - } - - public float getQ() { - return q; - } - - public float getU() { - return u; - } - - public float getA() { - return a; - } - - public SV otherSide(float r, float x, float g, float b, float ratio) { - Complex z = new Complex(r, x); // z=r+jx - Complex y = new Complex(g, b); // y=g+jb - Complex s1 = new Complex(p, q); // s1=p1+jq1 - Complex u1 = ComplexUtils.polar2Complex(u, Math.toRadians(a)); - Complex v1 = u1.divide(Math.sqrt(3f)); // v1=u1/sqrt(3) - - Complex v1p = v1.multiply(ratio); // v1p=v1*rho - Complex i1 = s1.divide(v1.multiply(3)).conjugate(); // i1=conj(s1/(3*v1)) - Complex i1p = i1.divide(ratio); // i1p=i1/rho - Complex i2 = i1p.subtract(y.multiply(v1p)); // i2=i1p-y*v1p - Complex v2 = v1p.subtract(z.multiply(i2)); // v2=v1p-z*i2 - Complex s2 = v2.multiply(3).multiply(i2.conjugate()); // s2=3*v2*conj(i2) - - Complex u2 = v2.multiply(Math.sqrt(3f)); - return new SV((float) -s2.getReal(), (float) -s2.getImaginary(), (float) u2.abs(), (float) Math.toDegrees(u2.getArgument())); - } - - public SV otherSide(TwoWindingsTransformer twt) { - return otherSide(getR(twt), getX(twt), getG(twt), getB(twt), getRatio(twt)); - } - - public SV otherSide(Line l) { - return otherSide(l.getR(), l.getX(), l.getG1() + l.getG2(), l.getB1() + l.getB2(), 1); - } - - public SV otherSide(DanglingLine dl) { - return otherSide(dl.getR(), dl.getX(), dl.getG(), dl.getB(), 1); - } - - @Override - public String toString() { - return "p=" + p + ", q=" + q + ", u=" + u + ", a=" + a; - } - -} diff --git a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ShortIdDictionary.java b/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ShortIdDictionary.java deleted file mode 100644 index 1aa8b1c6..00000000 --- a/iidm-network-api/src/main/java/eu/itesla_project/iidm/network/util/ShortIdDictionary.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.util; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author Geoffroy Jamgotchian - */ -public class ShortIdDictionary { - - private final Map map = new HashMap<>(); - - public ShortIdDictionary(Set ids) { - char c = 'A'; - for (String id : ids) { - if (!map.containsKey(id)) { - map.put(id, Character.toString(c++)); - } - } - } - - public ShortIdDictionary(Path file) throws IOException { - try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { - String line; - while ((line = reader.readLine()) != null) { - String[] tokens = line.split(";"); - map.put(tokens[0], tokens[1]); - } - } - } - - public String getShortId(String realId) { - return map.get(realId); - } - - public void write(Path file) throws IOException { - try (BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) { - for (Map.Entry e : map.entrySet()) { - writer.write(e.getKey()); - writer.write(";"); - writer.write(e.getValue()); - writer.newLine(); - } - } - } -} diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busBreakerTopology.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busBreakerTopology.svg deleted file mode 100644 index 793bd6b6..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busBreakerTopology.svg +++ /dev/null @@ -1,395 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busTopology.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busTopology.svg deleted file mode 100644 index 578fc8e1..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/busTopology.svg +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/currentLimits.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/currentLimits.svg deleted file mode 100644 index 4d79e7cd..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/currentLimits.svg +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - permanent limit - - branch current (A) - temporary limit x s - - temporary limit y s - - temporary limit z s - - acceptable permanently - acceptable x s - acceptable y s - acceptable z s - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/danglingLine.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/danglingLine.svg deleted file mode 100644 index 26f43be7..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/danglingLine.svg +++ /dev/null @@ -1,306 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/line.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/line.svg deleted file mode 100644 index 1aaac29c..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/line.svg +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopology.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopology.svg deleted file mode 100644 index c8428ddf..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopology.svg +++ /dev/null @@ -1,675 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopologyGraph.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopologyGraph.svg deleted file mode 100644 index 7fa4f9af..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/nodeBreakerTopologyGraph.svg +++ /dev/null @@ -1,1116 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BBS2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/threeWindingsTransformer.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/threeWindingsTransformer.svg deleted file mode 100644 index ef919acf..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/threeWindingsTransformer.svg +++ /dev/null @@ -1,552 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/twoWindingsTransformer.svg b/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/twoWindingsTransformer.svg deleted file mode 100644 index ee28de98..00000000 --- a/iidm-network-api/src/main/javadoc/eu/itesla_project/iidm/network/doc-files/twoWindingsTransformer.svg +++ /dev/null @@ -1,357 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-network-api/src/test/java/eu/itesla_project/iidm/network/util/NetworksTest.java b/iidm-network-api/src/test/java/eu/itesla_project/iidm/network/util/NetworksTest.java deleted file mode 100644 index 4a18ebcb..00000000 --- a/iidm-network-api/src/test/java/eu/itesla_project/iidm/network/util/NetworksTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.util; - -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class NetworksTest { - - @Test - public void checkFlows() throws Exception { - double r=0.04; - double x=0.423; - double g1=0.0; - double g2=0.0; - double b1=0.0; - double b2=0.0; - double rho1=1; - double rho2=11.249999728; - double alpha1=0.0; - double alpha2=0.0; - double u1=236.80258178710938; - double u2=21.04814910888672; - double theta1=0.1257718437996544; - double theta2=0.12547118123496284; - - float p1=40.0744f; - float q1=2.3124743f; - float p2=-40.073254f; - float q2=-2.3003194f; - - assertTrue(Networks.checkFlows("test", r, x, rho1, rho2, u1, u2, theta1, theta2, alpha1, alpha2, g1, g2, b1, b2, p1, q1, p2, q2)); - - r= 0.04 / (rho2 * rho2); - x= 0.423 / (rho2 * rho2); - rho1 = 1 / rho2; - rho2 = 1; - - assertTrue(Networks.checkFlows("test", r, x, rho1, rho2, u1, u2, theta1, theta2, alpha1, alpha2, g1, g2, b1, b2, p1, q1, p2, q2)); - } - -} \ No newline at end of file diff --git a/iidm-network-impl/pom.xml b/iidm-network-impl/pom.xml deleted file mode 100644 index ebd8741d..00000000 --- a/iidm-network-impl/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - 4.0.0 - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - - iidm-network-impl - - IIDM network implementation - This is an in memory implementation of the network model - - - - junit - junit - - - org.slf4j - slf4j-api - - - org.kohsuke - graphviz-api - - - com.google.guava - guava - - - ${project.groupId} - commons - ${project.version} - - - ${project.groupId} - graph - ${project.version} - - - ${project.groupId} - iidm-network-api - ${project.version} - - - ${project.groupId} - iidm-network-test - ${project.version} - test - - - org.slf4j - slf4j-simple - test - - - diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractBus.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractBus.java deleted file mode 100644 index a45fa74e..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractBus.java +++ /dev/null @@ -1,231 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.FluentIterable; -import eu.itesla_project.iidm.network.*; - -import java.util.Collection; -import java.util.Collections; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class AbstractBus extends IdentifiableImpl { - - protected VoltageLevelExt voltageLevel; - - AbstractBus(String id, VoltageLevelExt voltageLevel) { - super(id, id); - this.voltageLevel = voltageLevel; - } - - protected abstract ConnectedComponent getConnectedComponent(); - - public boolean isInMainConnectedComponent() { - ConnectedComponent cc = getConnectedComponent(); - return cc != null && cc.getNum() == ConnectedComponent.MAIN_CC_NUM; - } - - public VoltageLevel getVoltageLevel() { - return voltageLevel; - } - - public abstract int getConnectedTerminalCount(); - - public abstract Iterable getConnectedTerminals(); - - public abstract Collection getTerminals(); - - public float getP() { - if (getConnectedTerminalCount() == 0) { - return Float.NaN; - } - float p = 0; - for (TerminalExt terminal : getConnectedTerminals()) { - ConnectableImpl connectable = terminal.getConnectable(); - switch (connectable.getType()) { - case BUSBAR_SECTION: - case SHUNT_COMPENSATOR: - case STATIC_VAR_COMPENSATOR: - case LINE: - case TWO_WINDINGS_TRANSFORMER: - case THREE_WINDINGS_TRANSFORMER: - case DANGLING_LINE: - // skip - break; - case GENERATOR: - case LOAD: - case HVDC_CONVERTER_STATION: - if (!Float.isNaN(terminal.getP())) { - p += terminal.getP(); - } - break; - default: - throw new AssertionError(); - } - } - return p; - } - - public float getQ() { - if (getConnectedTerminalCount() == 0) { - return Float.NaN; - } - float q = 0; - for (TerminalExt terminal : getConnectedTerminals()) { - ConnectableImpl connectable = terminal.getConnectable(); - switch (connectable.getType()) { - case BUSBAR_SECTION: - case LINE: - case TWO_WINDINGS_TRANSFORMER: - case THREE_WINDINGS_TRANSFORMER: - case DANGLING_LINE: - // skip - break; - case GENERATOR: - case LOAD: - case SHUNT_COMPENSATOR: - case STATIC_VAR_COMPENSATOR: - case HVDC_CONVERTER_STATION: - if (!Float.isNaN(terminal.getQ())) { - q += terminal.getQ(); - } - break; - default: - throw new AssertionError(); - } - } - return q; - } - - private Iterable getConnectables(Class clazz) { - if (getConnectedTerminalCount() == 0) { - return Collections.emptyList(); - } - return FluentIterable.from(getConnectedTerminals()) - .transform(Terminal::getConnectable) - .filter(clazz); - } - - public Iterable getLines() { - return getConnectables(Line.class); - } - - public Iterable getTwoWindingTransformers() { - return getConnectables(TwoWindingsTransformer.class); - } - - public Iterable getThreeWindingTransformers() { - return getConnectables(ThreeWindingsTransformer.class); - } - - public Iterable getLoads() { - return getConnectables(Load.class); - } - - public Iterable getShunts() { - return getConnectables(ShuntCompensator.class); - } - - public Iterable getGenerators() { - return getConnectables(Generator.class); - } - - public Iterable getDanglingLines() { - return getConnectables(DanglingLine.class); - } - - public void visitConnectedEquipments(TopologyVisitor visitor) { - visitEquipments(getConnectedTerminals(), visitor); - } - - public void visitConnectedOrConnectableEquipments(TopologyVisitor visitor) { - visitEquipments(getTerminals(), visitor); - } - - static void visitEquipments(Iterable terminals, TopologyVisitor visitor) { - if (visitor == null) { - throw new NullPointerException("visitor is null"); - } - for (T terminal : terminals) { - ConnectableImpl connectable = ((TerminalExt) terminal).getConnectable(); - switch (connectable.getType()) { - case BUSBAR_SECTION: - visitor.visitBusbarSection((BusbarSectionImpl) connectable); - break; - - case LINE: - { - LineImpl line = (LineImpl) connectable; - visitor.visitLine(line, line.getTerminal1() == terminal - ? TwoTerminalsConnectable.Side.ONE - : TwoTerminalsConnectable.Side.TWO); - } - break; - - case GENERATOR: - visitor.visitGenerator((GeneratorImpl) connectable); - break; - - case SHUNT_COMPENSATOR: - visitor.visitShuntCompensator((ShuntCompensatorImpl) connectable); - break; - - case TWO_WINDINGS_TRANSFORMER: - { - TwoWindingsTransformer transformer = (TwoWindingsTransformer) connectable; - visitor.visitTwoWindingsTransformer(transformer, - transformer.getTerminal1() == terminal - ? TwoTerminalsConnectable.Side.ONE - : TwoTerminalsConnectable.Side.TWO); - } - break; - - case THREE_WINDINGS_TRANSFORMER: - { - ThreeWindingsTransformer transformer = (ThreeWindingsTransformer) connectable; - ThreeWindingsTransformer.Side side; - if (transformer.getLeg1().getTerminal() == terminal) { - side = ThreeWindingsTransformer.Side.ONE; - } else if (transformer.getLeg2().getTerminal() == terminal) { - side = ThreeWindingsTransformer.Side.TWO; - } else { - side = ThreeWindingsTransformer.Side.THREE; - } - visitor.visitThreeWindingsTransformer(transformer, side); - } - break; - - case LOAD: - visitor.visitLoad((LoadImpl) connectable); - break; - - case DANGLING_LINE: - visitor.visitDanglingLine((DanglingLineImpl) connectable); - break; - - case STATIC_VAR_COMPENSATOR: - visitor.visitStaticVarCompensator((StaticVarCompensator) connectable); - break; - - case HVDC_CONVERTER_STATION: - visitor.visitHvdcConverterStation((HvdcConverterStation) connectable); - break; - - default: - throw new AssertionError(); - } - } - } - - @Override - protected String getTypeDescription() { - return "Bus"; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTerminal.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTerminal.java deleted file mode 100644 index 8528bfce..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTerminal.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.Terminal; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class AbstractTerminal implements TerminalExt { - - protected final Ref network; - - protected ConnectableImpl connectable; - - protected VoltageLevelExt voltageLevel; - - protected int num = -1; - - // attributes depending on the state - - protected final TFloatArrayList p; - - protected final TFloatArrayList q; - - AbstractTerminal(Ref network) { - this.network = network; - int stateArraySize = network.get().getStateManager().getStateArraySize(); - p = new TFloatArrayList(stateArraySize); - q = new TFloatArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - p.add(Float.NaN); - q.add(Float.NaN); - } - } - - @Override - public ConnectableImpl getConnectable() { - return connectable; - } - - @Override - public void setConnectable(ConnectableImpl connectable) { - this.connectable = connectable; - } - - @Override - public VoltageLevelExt getVoltageLevel() { - return voltageLevel; - } - - @Override - public void setVoltageLevel(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - public void setNum(int num) { - this.num = num; - } - - @Override - public float getP() { - return p.get(network.get().getStateIndex()); - } - - @Override - public Terminal setP(float p) { - if (connectable.getType() == ConnectableType.BUSBAR_SECTION) { - throw new ValidationException(connectable, "cannot set active power on a busbar section"); - } - if (!Float.isNaN(p) && connectable.getType() == ConnectableType.SHUNT_COMPENSATOR) { - throw new ValidationException(connectable, "cannot set active power on a shunt compensator"); - } - float oldValue = this.p.set(network.get().getStateIndex(), p); - getConnectable().notifyUpdate("p" + (num != -1 ? num : "") , oldValue, p); - return this; - } - - @Override - public float getQ() { - return q.get(network.get().getStateIndex()); - } - - @Override - public Terminal setQ(float q) { - if (connectable.getType() == ConnectableType.BUSBAR_SECTION) { - throw new ValidationException(connectable, "cannot set reactive power on a busbar section"); - } - float oldValue = this.q.set(network.get().getStateIndex(), q); - getConnectable().notifyUpdate("q" + (num != -1 ? num : ""), oldValue, q); - return this; - } - - protected abstract float getV(); - - @Override - public float getI() { - if (connectable.getType() == ConnectableType.BUSBAR_SECTION) { - return 0; - } - int stateIndex = network.get().getStateIndex(); - return (float) (Math.hypot(p.get(stateIndex), q.get(stateIndex)) - / (Math.sqrt(3.) * getV() / 1000)); - } - - @Override - public boolean connect() { - return voltageLevel.connect(this); - } - - @Override - public boolean disconnect() { - return voltageLevel.disconnect(this); - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - p.ensureCapacity(p.size() + number); - q.ensureCapacity(q.size() + number); - for (int i = 0; i < number; i++) { - p.add(p.get(sourceIndex)); - q.add(q.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - p.remove(p.size() - number, number); - q.remove(q.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - for (int index : indexes) { - p.set(index, p.get(sourceIndex)); - q.set(index, q.get(sourceIndex)); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTwoTerminalsConnectable.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTwoTerminalsConnectable.java deleted file mode 100644 index a7c2530f..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractTwoTerminalsConnectable.java +++ /dev/null @@ -1,220 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import eu.itesla_project.iidm.network.TwoTerminalsConnectable.Side; - -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class AbstractTwoTerminalsConnectable> extends ConnectableImpl implements CurrentLimitsOwner { - - private CurrentLimits limits1; - - private CurrentLimits limits2; - - AbstractTwoTerminalsConnectable(String id, String name) { - super(id, name); - } - - public TerminalExt getTerminal1() { - return terminals.get(0); - } - - public TerminalExt getTerminal2() { - return terminals.get(1); - } - - public Terminal getTerminal(Side side) { - switch (side) { - case ONE: - return getTerminal1(); - - case TWO: - return getTerminal2(); - - default: - throw new AssertionError(); - } - } - - public Terminal getTerminal(String voltageLevelId) { - Objects.requireNonNull(voltageLevelId); - boolean side1 = getTerminal1().getVoltageLevel().getId().equals(voltageLevelId); - boolean side2 = getTerminal2().getVoltageLevel().getId().equals(voltageLevelId); - if (side1) { - return getTerminal1(); - } else if (side2) { - return getTerminal2(); - } else if (side1 && side2) { - throw new RuntimeException("Both terminals are connected to voltage level " + voltageLevelId); - } else { - throw new RuntimeException("No terminal connected to voltage level " + voltageLevelId); - } - } - - @Override - public void setCurrentLimits(TwoTerminalsConnectable.Side side, CurrentLimitsImpl limits) { - switch (side) { - case ONE: - limits1 = limits; - break; - case TWO: - limits2 = limits; - break; - default: - throw new InternalError(); - } - } - - public CurrentLimits getCurrentLimits1() { - return limits1; - } - - public CurrentLimitsAdder newCurrentLimits1() { - return new CurrentLimitsAdderImpl<>(TwoTerminalsConnectable.Side.ONE, this); - } - - public CurrentLimits getCurrentLimits2() { - return limits2; - } - - public CurrentLimitsAdder newCurrentLimits2() { - return new CurrentLimitsAdderImpl<>(TwoTerminalsConnectable.Side.TWO, this); - } - - public boolean isOverloaded() { - return checkTemporaryLimits1() != null || checkTemporaryLimits2() != null; - } - - public int getOverloadDuration() { - TwoTerminalsConnectable.Overload o1 = checkTemporaryLimits1(); - TwoTerminalsConnectable.Overload o2 = checkTemporaryLimits2(); - int duration1 = o1 != null ? o1.getTemporaryLimit().getAcceptableDuration() : Integer.MAX_VALUE; - int duration2 = o2 != null ? o2.getTemporaryLimit().getAcceptableDuration() : Integer.MAX_VALUE; - return Math.min(duration1, duration2); - } - - public boolean checkPermanentLimit(Side side, float limitReduction) { - Objects.requireNonNull(side); - switch (side) { - case ONE: - return checkPermanentLimit1(limitReduction); - - case TWO: - return checkPermanentLimit2(limitReduction); - - default: - throw new AssertionError(); - } - } - - public boolean checkPermanentLimit(Side side) { - return checkPermanentLimit(side, 1f); - } - - public boolean checkPermanentLimit1(float limitReduction) { - return checkPermanentLimit(getTerminal1(), getCurrentLimits1(), limitReduction); - } - - public boolean checkPermanentLimit1() { - return checkPermanentLimit1(1f); - } - - public boolean checkPermanentLimit2(float limitReduction) { - return checkPermanentLimit(getTerminal2(), getCurrentLimits2(), limitReduction); - } - - public boolean checkPermanentLimit2() { - return checkPermanentLimit2(1f); - } - - private static boolean checkPermanentLimit(Terminal terminal, CurrentLimits limits, float limitReduction) { - float i = terminal.getI(); - if (limits != null && !Float.isNaN(limits.getPermanentLimit()) && !Float.isNaN(i) ) { - if (i > limits.getPermanentLimit() * limitReduction) { - return true; - } - } - return false; - } - - static class OverloadImpl implements TwoTerminalsConnectable.Overload { - - private final CurrentLimits.TemporaryLimit temporaryLimit; - - private final float previousLimit; - - private OverloadImpl(CurrentLimits.TemporaryLimit temporaryLimit, float previousLimit) { - this.temporaryLimit = Objects.requireNonNull(temporaryLimit); - this.previousLimit = previousLimit; - } - - @Override - public CurrentLimits.TemporaryLimit getTemporaryLimit() { - return temporaryLimit; - } - - @Override - public float getPreviousLimit() { - return previousLimit; - } - } - - public OverloadImpl checkTemporaryLimits(Side side, float limitReduction) { - Objects.requireNonNull(side); - switch (side) { - case ONE: - return checkTemporaryLimits1(limitReduction); - - case TWO: - return checkTemporaryLimits2(limitReduction); - - default: - throw new AssertionError(); - } - } - - public OverloadImpl checkTemporaryLimits(Side side) { - return checkTemporaryLimits(side, 1f); - } - - public OverloadImpl checkTemporaryLimits1(float limitReduction) { - return checkTemporaryLimits(getTerminal1(), limits1, limitReduction); - } - - public OverloadImpl checkTemporaryLimits1() { - return checkTemporaryLimits1(1f); - } - - public OverloadImpl checkTemporaryLimits2(float limitReduction) { - return checkTemporaryLimits(getTerminal2(), limits2, limitReduction); - } - - public OverloadImpl checkTemporaryLimits2() { - return checkTemporaryLimits2(1f); - } - - private static OverloadImpl checkTemporaryLimits(TerminalExt t, CurrentLimits limits, float limitReduction) { - Objects.requireNonNull(t); - float i = t.getI(); - if (limits != null && !Float.isNaN(limits.getPermanentLimit()) && !Float.isNaN(i)) { - float previousLimit = limits.getPermanentLimit(); - for (CurrentLimits.TemporaryLimit tl : limits.getTemporaryLimits()) { // iterate in ascending order - if (i >= previousLimit * limitReduction && i < tl.getValue() * limitReduction) { - return new OverloadImpl(tl, previousLimit); - } - previousLimit = tl.getValue(); - } - } - return null; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractVoltageLevel.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractVoltageLevel.java deleted file mode 100644 index d19b8356..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/AbstractVoltageLevel.java +++ /dev/null @@ -1,268 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; - -import java.util.List; -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class AbstractVoltageLevel extends IdentifiableImpl implements VoltageLevelExt { - - private final SubstationImpl substation; - - private float nominalV; - - private float lowVoltageLimit; - - private float highVoltageLimit; - - AbstractVoltageLevel(String id, String name, SubstationImpl substation, - float nominalV, float lowVoltageLimit, float highVoltageLimit) { - super(id, name); - this.substation = substation; - this.nominalV = nominalV; - this.lowVoltageLimit = lowVoltageLimit; - this.highVoltageLimit = highVoltageLimit; - } - - @Override - public ContainerType getContainerType() { - return ContainerType.VOLTAGE_LEVEL; - } - - @Override - public SubstationImpl getSubstation() { - return substation; - } - - @Override - public NetworkImpl getNetwork() { - return substation.getNetwork(); - } - - private void notifyUpdate(String attribute, Object oldValue, Object newValue) { - getNetwork().getListeners().notifyUpdate(this, attribute, oldValue, newValue); - } - - @Override - public float getNominalV() { - return nominalV; - } - - @Override - public VoltageLevelExt setNominalV(float nominalV) { - ValidationUtil.checkNominalV(this, nominalV); - float oldValue = this.nominalV; - this.nominalV = nominalV; - notifyUpdate("nominalV", oldValue, nominalV); - return this; - } - - @Override - public float getLowVoltageLimit() { - return lowVoltageLimit; - } - - @Override - public VoltageLevel setLowVoltageLimit(float lowVoltageLimit) { - ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit); - float oldValue = this.lowVoltageLimit; - this.lowVoltageLimit = lowVoltageLimit; - notifyUpdate("lowVoltageLimit", oldValue, lowVoltageLimit); - return this; - } - - @Override - public float getHighVoltageLimit() { - return highVoltageLimit; - } - - @Override - public VoltageLevel setHighVoltageLimit(float highVoltageLimit) { - ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit); - float oldValue = this.highVoltageLimit; - this.highVoltageLimit = highVoltageLimit; - notifyUpdate("highVoltageLimit", oldValue, highVoltageLimit); - return this; - } - - @Override - public T getConnectable(String id, Class aClass) { - // the fastest way to get the equipment is to look in the object store - // and then check if it is connected to this substation - T connectable = substation.getNetwork().getObjectStore().get(id, aClass); - if (connectable == null) { - return null; - } else if (connectable instanceof SingleTerminalConnectable) { - return ((SingleTerminalConnectable) connectable).getTerminal().getVoltageLevel() == this - ? connectable : null; - } else if (connectable instanceof TwoTerminalsConnectable) { - return ((TwoTerminalsConnectable) connectable).getTerminal1().getVoltageLevel() == this - || ((TwoTerminalsConnectable) connectable).getTerminal2().getVoltageLevel() == this - ? connectable : null; - } else if (connectable instanceof ThreeWindingsTransformer) { - return ((ThreeWindingsTransformer) connectable).getLeg1().getTerminal().getVoltageLevel() == this - || ((ThreeWindingsTransformer) connectable).getLeg2().getTerminal().getVoltageLevel() == this - || ((ThreeWindingsTransformer) connectable).getLeg3().getTerminal().getVoltageLevel() == this - ? connectable : null; - } else { - throw new AssertionError(); - } - } - - @Override - public GeneratorAdder newGenerator() { - return new GeneratorAdderImpl(this); - } - - @Override - public Iterable getGenerators() { - return getConnectables(Generator.class); - } - - @Override - public int getGeneratorCount() { - return getConnectableCount(Generator.class); - } - - @Override - public LoadAdder newLoad() { - return new LoadAdderImpl(this); - } - - @Override - public Iterable getLoads() { - return getConnectables(Load.class); - } - - @Override - public int getLoadCount() { - return getConnectableCount(Load.class); - } - - @Override - public ShuntCompensatorAdder newShunt() { - return new ShuntCompensatorAdderImpl(this); - } - - @Override - public int getShuntCount() { - return getConnectableCount(ShuntCompensator.class); - } - - @Override - public Iterable getShunts() { - return getConnectables(ShuntCompensator.class); - } - - @Override - public DanglingLineAdder newDanglingLine() { - return new DanglingLineAdderImpl(this); - } - - @Override - public Iterable getDanglingLines() { - return getConnectables(DanglingLine.class); - } - - @Override - public int getDanglingLineCount() { - return getConnectableCount(DanglingLine.class); - } - - @Override - public StaticVarCompensatorAdderImpl newStaticVarCompensator() { - return new StaticVarCompensatorAdderImpl(this); - } - - @Override - public Iterable getStaticVarCompensators() { - return getConnectables(StaticVarCompensator.class); - } - - @Override - public int getStaticVarCompensatorCount() { - return getConnectableCount(StaticVarCompensator.class); - } - - @Override - public int getVscConverterStationCount() { - return getConnectableCount(VscConverterStation.class); - } - - @Override - public Iterable getVscConverterStations() { - return getConnectables(VscConverterStation.class); - } - - @Override - public VscConverterStationAdder newVscConverterStation() { - return new VscConverterStationAdderImpl(this); - } - - @Override - public int getLccConverterStationCount() { - return getConnectableCount(LccConverterStation.class); - } - - @Override - public Iterable getLccConverterStations() { - return getConnectables(LccConverterStation.class); - } - - @Override - public LccConverterStationAdder newLccConverterStation() { - return new LccConverterStationAdderImpl(this); - } - - @Override - protected String getTypeDescription() { - return "Voltage level"; - } - - protected abstract Iterable getTerminals(); - - @Override - public void visitEquipments(TopologyVisitor visitor) { - AbstractBus.visitEquipments(getTerminals(), visitor); - } - - protected static void addNextTerminals(TerminalExt otherTerminal, List nextTerminals) { - Objects.requireNonNull(otherTerminal); - Objects.requireNonNull(nextTerminals); - Connectable otherConnectable = otherTerminal.getConnectable(); - if (otherConnectable instanceof TwoTerminalsConnectable) { - TwoTerminalsConnectable ttc = (TwoTerminalsConnectable) otherConnectable; - if (ttc.getTerminal1() == otherTerminal) { - nextTerminals.add((TerminalExt) ttc.getTerminal2()); - } else if (ttc.getTerminal2() == otherTerminal) { - nextTerminals.add(((TerminalExt) ttc.getTerminal1())); - } else { - throw new AssertionError(); - } - } else if (otherConnectable instanceof ThreeWindingsTransformer) { - ThreeWindingsTransformer ttc = (ThreeWindingsTransformer) otherConnectable; - if (ttc.getLeg1().getTerminal() == otherTerminal) { - nextTerminals.add(((TerminalExt) ttc.getLeg2().getTerminal())); - nextTerminals.add(((TerminalExt) ttc.getLeg3().getTerminal())); - } else if (ttc.getLeg2().getTerminal() == otherTerminal) { - nextTerminals.add(((TerminalExt) ttc.getLeg1().getTerminal())); - nextTerminals.add(((TerminalExt) ttc.getLeg3().getTerminal())); - } else if (ttc.getLeg3().getTerminal() == otherTerminal) { - nextTerminals.add(((TerminalExt) ttc.getLeg1().getTerminal())); - nextTerminals.add(((TerminalExt) ttc.getLeg2().getTerminal())); - } else { - throw new AssertionError(); - } - } - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Boundary.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Boundary.java deleted file mode 100644 index 06195fc4..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Boundary.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.Sets; -import eu.itesla_project.iidm.network.Country; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -class Boundary { - - private final Country country1; - private final Country country2; - - Boundary(Country country1, Country country2) { - this.country1 = Objects.requireNonNull(country1); - this.country2 = Objects.requireNonNull(country2); - } - - @Override - public int hashCode() { - return Objects.hash(country1, country2); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof Boundary) { - Boundary other = (Boundary) obj; - return Sets.newHashSet(country1, country2).equals(Sets.newHashSet(other.country1, other.country2)); - } - return false; - } - - @Override - public String toString() { - return country1 + "/" + country2; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusAdderImpl.java deleted file mode 100644 index 8564e186..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusAdderImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.BusAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class BusAdderImpl extends IdentifiableAdderImpl implements BusAdder { - - private final BusBreakerVoltageLevel voltageLevel; - - BusAdderImpl(BusBreakerVoltageLevel voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Bus"; - } - - @Override - public ConfiguredBus add() { - String id = checkAndGetUniqueId(); - ConfiguredBusImpl bus = new ConfiguredBusImpl(id, voltageLevel); - voltageLevel.addBus(bus); - getNetwork().getListeners().notifyCreation(bus); - return bus; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusBreakerVoltageLevel.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusBreakerVoltageLevel.java deleted file mode 100644 index f701ad5b..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusBreakerVoltageLevel.java +++ /dev/null @@ -1,855 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.base.Function; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Iterables; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.commons.collect.Downcast; -import eu.itesla_project.graph.TraverseResult; -import eu.itesla_project.graph.Traverser; -import eu.itesla_project.graph.UndirectedGraphImpl; -import eu.itesla_project.iidm.network.*; -import eu.itesla_project.iidm.network.util.Networks; -import eu.itesla_project.iidm.network.util.ShortIdDictionary; - -import java.io.*; -import java.util.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -class BusBreakerVoltageLevel extends AbstractVoltageLevel { - - private class SwitchAdderImpl extends IdentifiableAdderImpl implements BusBreakerView.SwitchAdder { - - private String busId1; - - private String busId2; - - private boolean open = false; - - private SwitchAdderImpl() { - } - - @Override - protected NetworkImpl getNetwork() { - return BusBreakerVoltageLevel.this.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Switch"; - } - - @Override - public BusBreakerView.SwitchAdder setBus1(String bus1) { - this.busId1 = bus1; - return this; - } - - @Override - public BusBreakerView.SwitchAdder setBus2(String bus2) { - this.busId2 = bus2; - return this; - } - - @Override - public BusBreakerView.SwitchAdder setOpen(boolean open) { - this.open = open; - return this; - } - - @Override - public Switch add() { - String id = checkAndGetUniqueId(); - if (busId1 == null) { - throw new ValidationException(this, "first connection bus is not set"); - } - if (busId2 == null) { - throw new ValidationException(this, "second connection bus is not set"); - } - - SwitchImpl _switch = new SwitchImpl(BusBreakerVoltageLevel.this, id, getName(), SwitchKind.BREAKER, open, true); - addSwitch(_switch, busId1, busId2); - getNetwork().getListeners().notifyCreation(_switch); - return _switch; - } - - } - - private final UndirectedGraphImpl graph = new UndirectedGraphImpl<>(); - - /* buses indexed by vertex number */ - private final Map buses = new HashMap<>(); - - /* switches indexed by edge number */ - private final Map switches = new HashMap<>(); - - private Integer getVertex(String busId, boolean throwException) { - Objects.requireNonNull(busId, "bus id is null"); - Integer v = buses.get(busId); - if (throwException && v == null) { - throw new ITeslaException("Bus " + busId - + " not found in substation voltage level " - + BusBreakerVoltageLevel.this.id); - } - return v; - } - - ConfiguredBus getBus(String busId, boolean throwException) { - Integer v = getVertex(busId, throwException); - if (v != null) { - ConfiguredBus bus = graph.getVertexObject(v); - if (!bus.getId().equals(busId)) { - throw new InternalError("Must not happened"); - } - return bus; - } - return null; - } - - private Integer getEdge(String switchId, boolean throwException) { - Objects.requireNonNull(switchId, "switch id is null"); - Integer e = switches.get(switchId); - if (throwException && e == null) { - throw new ITeslaException("Switch " + switchId - + " not found in substation voltage level" - + BusBreakerVoltageLevel.this.id); - } - return e; - } - - private SwitchImpl getSwitch(String switchId, boolean throwException) { - Integer e = getEdge(switchId, throwException); - if (e != null) { - SwitchImpl _switch = graph.getEdgeObject(e); - if (!_switch.getId().equals(switchId)) { - throw new InternalError("Must not happened"); - } - return _switch; - } - return null; - } - - /** - * Bus only topology cache - */ - private static class BusCache { - - /* merged bus by id */ - private final Map mergedBus; - - /* bus to merged bus mapping */ - private final Map mapping; - - private BusCache(Map mergedBus, Map mapping) { - this.mergedBus = mergedBus; - this.mapping = mapping; - } - - private Collection getMergedBuses() { - return mergedBus.values(); - } - - private MergedBus getMergedBus(String id) { - return mergedBus.get(id); - } - - private MergedBus getMergedBus(ConfiguredBus cfgBus) { - return mapping.get(cfgBus); - } - - } - - /** - * Bus only topology calculated from bus/breaker topology - */ - class CalculatedBusTopology { - - protected boolean isBusValid(Set busSet) { - int feederCount = 0; - int branchCount = 0; - for (TerminalExt terminal : FluentIterable.from(busSet).transformAndConcat(ConfiguredBus::getConnectedTerminals)) { - ConnectableImpl connectable = terminal.getConnectable(); - switch (connectable.getType()) { - case LINE: - case TWO_WINDINGS_TRANSFORMER: - case THREE_WINDINGS_TRANSFORMER: - branchCount++; - feederCount++; - break; - - case DANGLING_LINE: - case LOAD: - case GENERATOR: - case SHUNT_COMPENSATOR: - case STATIC_VAR_COMPENSATOR: - case HVDC_CONVERTER_STATION: - feederCount++; - break; - - case BUSBAR_SECTION: // must not happend in a bus/breaker topology - default: - throw new AssertionError(); - } - } - return Networks.isBusValid(feederCount, branchCount); - } - - private void updateCache() { - if (states.get().cache != null) { - return; - } - - Map mergedBuses = new LinkedHashMap<>(); - - // mapping between configured buses and merged buses - Map mapping = new IdentityHashMap<>(); - - boolean[] encountered = new boolean[graph.getMaxVertex()]; - Arrays.fill(encountered, false); - int busNum = 0; - for (int v : graph.getVertices()) { - if (!encountered[v]) { - final Set busSet = new HashSet<>(1); - busSet.add(graph.getVertexObject(v)); - graph.traverse(v, new Traverser() { - @Override - public TraverseResult traverse(int v1, int e, int v2) { - SwitchImpl _switch = graph.getEdgeObject(e); - if (_switch.isOpen()) { - return TraverseResult.TERMINATE; - } else { - busSet.add(graph.getVertexObject(v2)); - return TraverseResult.CONTINUE; - } - } - }, encountered); - if (isBusValid(busSet)) { - String mergedBusId = BusBreakerVoltageLevel.this.id + "_" + busNum++; - MergedBus mergedBus = new MergedBus(mergedBusId, busSet); - mergedBuses.put(mergedBus.getId(), mergedBus); - for (ConfiguredBus bus : busSet) { - mapping.put(bus, mergedBus); - } - } - } - } - - states.get().cache = new BusCache(mergedBuses, mapping); - } - - private void invalidateCache() { - // detach buses - if (states.get().cache != null) { - for (MergedBus bus : states.get().cache.getMergedBuses()) { - bus.invalidate(); - } - states.get().cache = null; - } - } - - private Collection getMergedBuses() { - updateCache(); - return states.get().cache.getMergedBuses(); - } - - private MergedBus getMergedBus(String mergedBusId, boolean throwException) { - updateCache(); - MergedBus bus = states.get().cache.getMergedBus(mergedBusId); - if (throwException && bus == null) { - throw new ITeslaException("Bus " + mergedBusId - + " not found in substation voltage level " - + BusBreakerVoltageLevel.this.id); - } - return bus; - } - - MergedBus getMergedBus(ConfiguredBus bus) { - Objects.requireNonNull(bus, "bus is null"); - updateCache(); - return states.get().cache.getMergedBus(bus); - } - - } - - final CalculatedBusTopology calculatedBusTopology - = new CalculatedBusTopology(); - - private static class StateImpl implements State { - - private BusCache cache; - - private StateImpl() { - } - - private StateImpl(StateImpl other) { - } - - @Override - public StateImpl copy() { - return new StateImpl(this); - } - - } - - protected final StateArray states; - - BusBreakerVoltageLevel(String id, String name, SubstationImpl substation, - float nominalV, float lowVoltageLimit, float highVoltageLimit) { - super(id, name, substation, nominalV, lowVoltageLimit, highVoltageLimit); - states = new StateArray<>(substation.getNetwork().getRef(), () -> new StateImpl()); - graph.addListener(() -> { - // invalidate topology and connected components - invalidateCache(); - }); - } - - @Override - public void invalidateCache() { - calculatedBusTopology.invalidateCache(); - getNetwork().getConnectedComponentsManager().invalidate(); - } - - @Override - public Iterable getTerminals() { - return FluentIterable.from(graph.getVerticesObj()) - .transformAndConcat(ConfiguredBus::getTerminals) - .transform(Terminal.class::cast); - } - - @Override - public FluentIterable getConnectables(Class clazz) { - Iterable terminals = getTerminals(); - return FluentIterable.from(terminals) - .transform(Terminal::getConnectable) - .filter(clazz); - } - - @Override - public int getConnectableCount(Class clazz) { - return getConnectables(clazz).size(); - } - - static ITeslaException createNotSupportedBusBreakerTopologyException() { - return new ITeslaException("Not supported in a bus breaker topology"); - } - - private final NodeBreakerViewExt nodeBreakerView = new NodeBreakerViewExt() { - - @Override - public int getNodeCount() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public NodeBreakerView setNodeCount(int count) { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public int getNode1(String switchId) { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public int getNode2(String switchId) { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public SwitchAdder newSwitch() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public InternalConnectionAdder newInternalConnection() { throw createNotSupportedBusBreakerTopologyException();} - - @Override - public SwitchAdder newBreaker() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public SwitchAdder newDisconnector() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public Switch getSwitch(String switchId) { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public Iterable getSwitches() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public int getSwitchCount() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public BusbarSectionAdder newBusbarSection() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public Iterable getBusbarSections() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public int getBusbarSectionCount() { - throw createNotSupportedBusBreakerTopologyException(); - } - - @Override - public BusbarSection getBusbarSection(String id) { - throw createNotSupportedBusBreakerTopologyException(); - } - - }; - - @Override - public NodeBreakerViewExt getNodeBreakerView() { - return nodeBreakerView; - } - - private final BusBreakerViewExt busBreakerView = new BusBreakerViewExt() { - - @Override - public Iterable getBuses() { - return Iterables.unmodifiableIterable(Iterables.transform(graph.getVerticesObj(), new Downcast<>())); - } - - @Override - public ConfiguredBus getBus(String id) { - return BusBreakerVoltageLevel.this.getBus(id, false); - } - - @Override - public BusAdder newBus() { - return new BusAdderImpl(BusBreakerVoltageLevel.this); - } - - @Override - public void removeBus(String busId) { - BusBreakerVoltageLevel.this.removeBus(busId); - } - - @Override - public void removeAllBuses() { - BusBreakerVoltageLevel.this.removeAllBuses(); - } - - @Override - public Iterable getSwitches() { - return Iterables.unmodifiableIterable(Iterables.transform(graph.getEdgesObject(), new Function() { - @Override - public Switch apply(SwitchImpl sw) { - return sw; - } - })); - } - - @Override - public void removeSwitch(String switchId) { - BusBreakerVoltageLevel.this.removeSwitch(switchId); - } - - @Override - public void removeAllSwitches() { - BusBreakerVoltageLevel.this.removeAllSwitches(); - } - - @Override - public ConfiguredBus getBus1(String switchId) { - int e = getEdge(switchId, true); - int v1 = graph.getEdgeVertex1(e); - return graph.getVertexObject(v1); - } - - @Override - public ConfiguredBus getBus2(String switchId) { - int e = getEdge(switchId, true); - int v2 = graph.getEdgeVertex2(e); - return graph.getVertexObject(v2); - } - - @Override - public SwitchImpl getSwitch(String switchId) { - return BusBreakerVoltageLevel.this.getSwitch(switchId, false); - } - - @Override - public BusBreakerView.SwitchAdder newSwitch() { - return new SwitchAdderImpl(); - } - - }; - - @Override - public BusBreakerViewExt getBusBreakerView() { - return busBreakerView; - } - - private final BusViewExt busView = new BusViewExt() { - - @Override - public Iterable getBuses() { - return Collections.unmodifiableCollection(calculatedBusTopology.getMergedBuses()); - } - - @Override - public MergedBus getBus(String id) { - return calculatedBusTopology.getMergedBus(id, false); - } - - }; - - @Override - public BusViewExt getBusView() { - return busView; - } - - @Override - public TopologyKind getTopologyKind() { - return TopologyKind.BUS_BREAKER; - } - - void addBus(ConfiguredBus bus) { - getNetwork().getObjectStore().checkAndAdd(bus); - int v = graph.addVertex(); - graph.setVertexObject(v, bus); - buses.put(bus.getId(), v); - } - - private void removeBus(String busId) { - ConfiguredBus bus = getBus(busId, true); - if (bus.getTerminalCount() > 0) { - throw new ValidationException(this, "Cannot remove bus " - + bus.getId() + " because of connectable equipments"); - } - // TODO improve check efficency - for (Map.Entry entry : switches.entrySet()) { - String switchId = entry.getKey(); - int e = entry.getValue(); - int v1 = graph.getEdgeVertex1(e); - int v2 = graph.getEdgeVertex2(e); - ConfiguredBus b1 = graph.getVertexObject(v1); - ConfiguredBus b2 = graph.getVertexObject(v2); - if (bus == b1 || bus == b2) { - throw new RuntimeException("Cannot remove bus '" + bus.getId() - + "' because switch '" + switchId + "' is connected to it"); - } - } - getNetwork().getObjectStore().remove(bus); - int v = buses.remove(bus.getId()); - graph.removeVertex(v); - } - - private void removeAllBuses() { - if (graph.getEdgeCount() > 0) { - throw new ValidationException(this, "Cannot remove all buses because there is still some switches"); - } - for (ConfiguredBus bus : graph.getVerticesObj()) { - if (bus.getTerminalCount() > 0) { - throw new ValidationException(this, "Cannot remove bus " - + bus.getId() + " because of connected equipments"); - } - } - for (ConfiguredBus bus : graph.getVerticesObj()) { - getNetwork().getObjectStore().remove(bus); - } - graph.removeAllVertices(); - buses.clear(); - } - - private void addSwitch(SwitchImpl _switch, String busId1, String busId2) { - int v1 = getVertex(busId1, true); - int v2 = getVertex(busId2, true); - getNetwork().getObjectStore().checkAndAdd(_switch); - int e = graph.addEdge(v1, v2, _switch); - switches.put(_switch.getId(), e); - } - - private void removeSwitch(String switchId) { - Integer e = switches.remove(switchId); - if (e == null) { - throw new RuntimeException("Switch '" + switchId - + "' not found in substation voltage level '" + id + "'"); - } - SwitchImpl _switch = graph.removeEdge(e); - getNetwork().getObjectStore().remove(_switch); - } - - private void removeAllSwitches() { - for (SwitchImpl s : graph.getEdgesObject()) { - getNetwork().getObjectStore().remove(s); - } - graph.removeAllEdges(); - switches.clear(); - } - - private void checkTerminal(TerminalExt terminal) { - if (!(terminal instanceof BusTerminal)) { - throw new ValidationException(terminal.getConnectable(), - "voltage level " + BusBreakerVoltageLevel.this.id + " has a bus/breaker topology" - + ", a bus connection should be specified instead of a node connection"); - } - - // check connectable buses exist - String connectableBusId = ((BusTerminal) terminal).getConnectableBusId(); - if (connectableBusId != null) { - getBus(connectableBusId, true); - } - } - - @Override - public void attach(final TerminalExt terminal, boolean test) { - checkTerminal(terminal); - if (test) { - return; - } - // create the link terminal -> voltage level - terminal.setVoltageLevel(this); - - // create the link bus -> terminal - String connectableBusId = ((BusTerminal) terminal).getConnectableBusId(); - - final ConfiguredBus connectableBus = getBus(connectableBusId, true); - - getNetwork().getStateManager().forEachState(() -> { - connectableBus.addTerminal((BusTerminal) terminal); - - // invalidate connected components - invalidateCache(); - }); - } - - @Override - public void detach(final TerminalExt terminal) { - assert terminal instanceof BusTerminal; - - // remove the link terminal -> voltage level - terminal.setVoltageLevel(null); - - // remove the link bus -> terminal - String connectableBusId = ((BusTerminal) terminal).getConnectableBusId(); - - final ConfiguredBus connectableBus = getBus(connectableBusId, true); - - getNetwork().getStateManager().forEachState(() -> { - connectableBus.removeTerminal((BusTerminal) terminal); - ((BusTerminal) terminal).setConnectableBusId(null); - - invalidateCache(); - }); - } - - @Override - public void clean() { - // nothing to do - } - - @Override - public boolean connect(TerminalExt terminal) { - assert terminal instanceof BusTerminal; - - // already connected? - if (((BusTerminal) terminal).isConnected()) { - return false; - } - - ((BusTerminal) terminal).setConnected(true); - - // invalidate connected components - invalidateCache(); - - return true; - } - - @Override - public boolean disconnect(TerminalExt terminal) { - assert terminal instanceof BusTerminal; - - // already connected? - if (!terminal.isConnected()) { - return false; - } - - ((BusTerminal) terminal).setConnected(false); - - // invalidate connected components - invalidateCache(); - - return true; - } - - void traverse(BusTerminal terminal, VoltageLevel.TopologyTraverser traverser) { - traverse(terminal, traverser, new HashSet<>()); - } - - void traverse(BusTerminal terminal, VoltageLevel.TopologyTraverser traverser, Set traversedVoltageLevelsIds) { - Objects.requireNonNull(terminal); - Objects.requireNonNull(traverser); - Objects.requireNonNull(traversedVoltageLevelsIds); - - if (traversedVoltageLevelsIds.contains(terminal.getVoltageLevel().getId())) { - return; - } - traversedVoltageLevelsIds.add(terminal.getVoltageLevel().getId()); - - List nextTerminals = new ArrayList<>(); - - // check if we are allowed to traverse the terminal itself - if (traverser.traverse(terminal, terminal.isConnected())) { - addNextTerminals(terminal, nextTerminals); - - // then check we can traverse terminal connected to same bus - int v = getVertex(terminal.getConnectableBusId(), true); - ConfiguredBus bus = graph.getVertexObject(v); - for (BusTerminal otherTerminal : bus.getTerminals()) { - if (otherTerminal != terminal) { - if (traverser.traverse(otherTerminal, otherTerminal.isConnected())) { - addNextTerminals(otherTerminal, nextTerminals); - } - } - } - - // then go through other buses of the substation - graph.traverse(v, (v1, e, v2) -> { - SwitchImpl aSwitch = graph.getEdgeObject(e); - ConfiguredBus otherBus = graph.getVertexObject(v2); - if (traverser.traverse(aSwitch)) { - for (BusTerminal otherTerminal : otherBus.getTerminals()) { - if (traverser.traverse(otherTerminal, otherTerminal.isConnected())) { - addNextTerminals(otherTerminal, nextTerminals); - return TraverseResult.CONTINUE; - } else { - return TraverseResult.TERMINATE; - } - } - return TraverseResult.CONTINUE; - } else { - return TraverseResult.TERMINATE; - } - }); - - for (TerminalExt nextTerminal : nextTerminals) { - nextTerminal.traverse(traverser, traversedVoltageLevelsIds); - } - } - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - states.push(number, () -> states.copy(sourceIndex)); - } - - @Override - public void reduceStateArraySize(int number) { - states.pop(number); - } - - @Override - public void deleteStateArrayElement(int index) { - states.delete(index); - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - states.allocate(indexes, () -> states.copy(sourceIndex)); - } - - @Override - public void printTopology() { - printTopology(System.out, null); - } - - @Override - public void printTopology(PrintStream out, ShortIdDictionary dict) { - out.println("-------------------------------------------------------------"); - out.println("Topology of " + BusBreakerVoltageLevel.this.id); - graph.print(out, bus -> { - StringBuilder builder = new StringBuilder(); - builder.append(bus.getId()) - .append(" ["); - for (Iterator it = bus.getConnectedTerminals().iterator(); it.hasNext(); ) { - TerminalExt terminal = it.next(); - builder.append(dict != null ? dict.getShortId(terminal.getConnectable().getId()) : terminal.getConnectable().getId()); - if (it.hasNext()) { - builder.append(", "); - } - } - builder.append("]"); - return builder.toString(); - }, aSwitch -> { - StringBuilder builder = new StringBuilder(); - builder.append("id=").append(aSwitch.getId()) - .append(" status=").append(aSwitch.isOpen() ? "open" : "closed"); - return builder.toString(); - }); - } - - @Override - public void exportTopology(String filename) throws IOException { - try (OutputStream writer = new FileOutputStream(filename)) { - exportTopology(writer); - } - } - - @Override - public void exportTopology(OutputStream outputStream) throws IOException { - Writer writer = new OutputStreamWriter(outputStream, "UTF-8"); - writer.append("graph \"").append(BusBreakerVoltageLevel.this.id).append("\" {\n"); - for (ConfiguredBus bus : graph.getVerticesObj()) { - String label = "BUS\\n" + bus.getId(); - writer.append(" ").append(bus.getId()) - .append(" [label=\"").append(label).append("\"]\n"); - for (TerminalExt terminal : bus.getTerminals()) { - ConnectableImpl connectable = terminal.getConnectable(); - label = connectable.getType().toString() + "\\n" + connectable.getId(); - writer.append(" ").append(connectable.getId()) - .append(" [label=\"").append(label).append("\"]\n"); - } - } - for (ConfiguredBus bus : graph.getVerticesObj()) { - for (TerminalExt terminal : bus.getTerminals()) { - ConnectableImpl connectable = terminal.getConnectable(); - writer.append(" ").append(bus.getId()) - .append(" -- ").append(connectable.getId()) - .append(" [").append("style=\"").append(terminal.isConnected() ? "solid" : "dotted").append("\"") - .append("]\n"); - } - } - boolean drawSwitchId = false; - for (int e = 0; e < graph.getEdgeCount(); e++) { - int v1 = graph.getEdgeVertex1(e); - int v2 = graph.getEdgeVertex2(e); - SwitchImpl sw = graph.getEdgeObject(e); - ConfiguredBus bus1 = graph.getVertexObject(v1); - ConfiguredBus bus2 = graph.getVertexObject(v2); - writer.append(" ").append(bus1.getId()) - .append(" -- ").append(bus2.getId()) - .append(" ["); - if (drawSwitchId) { - writer.append("label=\"").append(sw.getId()) - .append("\", fontsize=10"); - } - writer.append("style=\"").append(sw.isOpen() ? "dotted" : "solid").append("\""); - writer.append("]\n"); - } - writer.append("}\n"); - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusExt.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusExt.java deleted file mode 100644 index 65c7acf3..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusExt.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Bus; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface BusExt extends Bus { - - int getConnectedTerminalCount(); - - Iterable getConnectedTerminals(); - - void setConnectedComponentNumber(int connectedComponentNumber); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusTerminal.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusTerminal.java deleted file mode 100644 index 78109088..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusTerminal.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.impl.util.Ref; - -import java.util.ArrayList; -import java.util.BitSet; -import java.util.Objects; -import java.util.Set; - -/** - * A terminal connected to a bus/breaker topology. - * - * @author Geoffroy Jamgotchian - */ -class BusTerminal extends AbstractTerminal { - - private final NodeBreakerView nodeBreakerView = new NodeBreakerView() { - - @Override - public int getNode() { - throw BusBreakerVoltageLevel.createNotSupportedBusBreakerTopologyException(); - } - }; - - private final BusBreakerViewExt busBreakerView = new BusBreakerViewExt() { - - @Override - public BusExt getBus() { - return isConnected() ? getConnectableBus() : null; - } - - @Override - public ConfiguredBus getConnectableBus() { - return ((BusBreakerVoltageLevel) voltageLevel).getBus(getConnectableBusId(), true); - } - - @Override - public void setConnectableBus(String busId) { - Objects.requireNonNull(busId); - VoltageLevelExt vl = voltageLevel; - voltageLevel.detach(BusTerminal.this); - setConnectableBusId(busId); - vl.attach(BusTerminal.this, false); - } - }; - - private final BusViewExt busView = new BusViewExt() { - - @Override - public BusExt getBus() { - return isConnected() ? this.getConnectableBus() : null; - } - - @Override - public MergedBus getConnectableBus() { - ConfiguredBus bus = ((BusBreakerVoltageLevel) voltageLevel).getBus(getConnectableBusId(), true); - return ((BusBreakerVoltageLevel) voltageLevel).calculatedBusTopology.getMergedBus(bus); - } - - }; - - // attributes depending on the state - - private final BitSet connected; - - private final ArrayList connectableBusId; - - BusTerminal(Ref network, String connectableBusId, boolean connected) { - super(network); - Objects.requireNonNull(connectableBusId); - int stateArraySize = network.get().getStateManager().getStateArraySize(); - this.connectableBusId = new ArrayList<>(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - this.connectableBusId.add(connectableBusId); - } - this.connected = new BitSet(stateArraySize); - this.connected.set(0, stateArraySize, connected); - } - - void setConnectableBusId(String connectableBusId) { - this.connectableBusId.set(network.get().getStateIndex(), connectableBusId); - } - - String getConnectableBusId() { - return this.connectableBusId.get(network.get().getStateIndex()); - } - - void setConnected(boolean connected) { - this.connected.set(network.get().getStateIndex(), connected); - } - - @Override - public boolean isConnected() { - return this.connected.get(network.get().getStateIndex()); - } - - @Override - public void traverse(VoltageLevel.TopologyTraverser traverser, Set traversedVoltageLevelsIds) { - ((BusBreakerVoltageLevel) voltageLevel).traverse(this, traverser, traversedVoltageLevelsIds); - } - - @Override - public void traverse(VoltageLevel.TopologyTraverser traverser) { - ((BusBreakerVoltageLevel) voltageLevel).traverse(this, traverser); - } - - @Override - protected float getV() { - return busBreakerView.getBus() != null ? busBreakerView.getBus().getV() : Float.NaN; - } - - @Override - public NodeBreakerView getNodeBreakerView() { - return nodeBreakerView; - } - - @Override - public BusBreakerViewExt getBusBreakerView() { - return busBreakerView; - } - - @Override - public BusViewExt getBusView() { - return busView; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + getConnectableBusId() + "]"; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - connectableBusId.ensureCapacity(connectableBusId.size() + number); - for (int i = 0; i < number; i++) { - connectableBusId.add(connectableBusId.get(sourceIndex)); - connected.set(initStateArraySize + i, connected.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - for (int i = 0; i < number; i++) { - connectableBusId.remove(connectableBusId.size() - 1); - } - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - connectableBusId.set(index, null); - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - connectableBusId.set(index, connectableBusId.get(sourceIndex)); - connected.set(index, connected.get(sourceIndex)); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionAdderImpl.java deleted file mode 100644 index c144fea3..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionAdderImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.BusbarSection; -import eu.itesla_project.iidm.network.BusbarSectionAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class BusbarSectionAdderImpl extends IdentifiableAdderImpl implements BusbarSectionAdder { - - private final VoltageLevelExt voltageLevel; - - private Integer node; - - BusbarSectionAdderImpl(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Busbar section"; - } - - @Override - public BusbarSectionAdder setNode(int node) { - this.node = node; - return this; - } - - @Override - public BusbarSection add() { - String id = checkAndGetUniqueId(); - TerminalExt terminal = new NodeTerminal(getNetwork().getRef(), node); - BusbarSectionImpl section = new BusbarSectionImpl(id, getName()); - section.addTerminal(terminal); - voltageLevel.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(section); - getNetwork().getListeners().notifyCreation(section); - return section; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionImpl.java deleted file mode 100644 index 0fe5c70a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/BusbarSectionImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.BusbarSection; -import eu.itesla_project.iidm.network.ConnectableType; - -/** - * - * @author Geoffroy Jamgotchian - */ -class BusbarSectionImpl extends ConnectableImpl implements BusbarSection { - - BusbarSectionImpl(String id, String name) { - super(id, name); - } - - @Override - public ConnectableType getType() { - return ConnectableType.BUSBAR_SECTION; - } - - @Override - public TerminalExt getTerminal() { - return terminals.get(0); - } - - @Override - protected String getTypeDescription() { - return "Busbar section"; - } - - @Override - public float getV() { - return ((NodeTerminal) getTerminal()).getV(); - } - - @Override - public float getAngle() { - return ((NodeTerminal) getTerminal()).getAngle(); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBus.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBus.java deleted file mode 100644 index cabca9b5..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBus.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface CalculatedBus extends BusExt { - - void invalidate(); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBusImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBusImpl.java deleted file mode 100644 index 02e87e39..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CalculatedBusImpl.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.*; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -class CalculatedBusImpl extends AbstractBus implements CalculatedBus { - - private boolean valid = true; - - private final List terminals; - - CalculatedBusImpl(String id, VoltageLevelExt voltageLevel, List terminals) { - super(id, voltageLevel); -// if (terminals.isEmpty()) { -// throw new IllegalArgumentException("Calculated bus without any terminals"); -// } - this.terminals = terminals; - } - - private void checkValidity() { - if (!valid) { - throw new ITeslaException("Bus has been invalidated"); - } - } - - /** - * To invalidate the bus when it is a result of calculation and the topology - * of the substation is modified. - */ - @Override - public void invalidate() { - valid = false; - voltageLevel = null; - terminals.clear(); - } - - @Override - public VoltageLevel getVoltageLevel() { - checkValidity(); - return super.getVoltageLevel(); - } - - @Override - public int getConnectedTerminalCount() { - checkValidity(); - return terminals.size(); - } - - @Override - public Collection getConnectedTerminals() { - checkValidity(); - return Collections.unmodifiableCollection(terminals); - } - - @Override - public Collection getTerminals() { - checkValidity(); - return Collections.unmodifiableCollection(terminals); - } - - @Override - public BusExt setV(float v) { - checkValidity(); - for (NodeTerminal terminal : terminals) { - terminal.setV(v); - } - return this; - } - - @Override - public float getV() { - checkValidity(); - if (terminals.isEmpty()) return Float.NaN; - return terminals.get(0).getV(); - } - - @Override - public BusExt setAngle(float angle) { - checkValidity(); - for (NodeTerminal terminal : terminals) { - terminal.setAngle(angle); - } - return this; - } - - @Override - public float getAngle() { - checkValidity(); - if (terminals.isEmpty()) return Float.NaN; - return terminals.get(0).getAngle(); - } - - @Override - public float getP() { - checkValidity(); - return super.getP(); - } - - @Override - public float getQ() { - checkValidity(); - return super.getQ(); - } - - @Override - public void setConnectedComponentNumber(int connectedComponentNumber) { - checkValidity(); - for (NodeTerminal terminal : terminals) { - terminal.setConnectedComponentNumber(connectedComponentNumber); - } - } - - @Override - public ConnectedComponent getConnectedComponent() { - checkValidity(); - NetworkImpl.ConnectedComponentsManager ccm = voltageLevel.getNetwork().getConnectedComponentsManager(); - ccm.update(); - return ccm.getConnectedComponent(terminals.get(0).getConnectedComponentNumber()); - } - - @Override - public Iterable getLines() { - checkValidity(); - return super.getLines(); - } - - @Override - public Iterable getTwoWindingTransformers() { - checkValidity(); - return super.getTwoWindingTransformers(); - } - - @Override - public Iterable getThreeWindingTransformers() { - checkValidity(); - return super.getThreeWindingTransformers(); - } - - @Override - public Iterable getLoads() { - checkValidity(); - return super.getLoads(); - } - - @Override - public Iterable getShunts() { - checkValidity(); - return super.getShunts(); - } - - @Override - public Iterable getGenerators() { - checkValidity(); - return super.getGenerators(); - } - - @Override - public Iterable getDanglingLines() { - checkValidity(); - return super.getDanglingLines(); - } - - @Override - public void visitConnectedEquipments(TopologyVisitor visitor) { - checkValidity(); - super.visitConnectedEquipments(visitor); - } - - @Override - public void visitConnectedOrConnectableEquipments(TopologyVisitor visitor) { - checkValidity(); - super.visitConnectedOrConnectableEquipments(visitor); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBus.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBus.java deleted file mode 100644 index a4dfd0e5..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBus.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface ConfiguredBus extends BusExt { - - int getTerminalCount(); - - List getTerminals(); - - void addTerminal(BusTerminal t); - - void removeTerminal(BusTerminal t); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBusImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBusImpl.java deleted file mode 100644 index 0a00924b..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConfiguredBusImpl.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectedComponent; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; -import gnu.trove.list.array.TIntArrayList; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ConfiguredBusImpl extends AbstractBus implements ConfiguredBus, Stateful { - - private final Ref network; - - private final ArrayList> terminals; - - private final TFloatArrayList v; - - private final TFloatArrayList angle; - - protected final TIntArrayList connectedComponentNumber; - - ConfiguredBusImpl(String id, VoltageLevelExt voltageLevel) { - super(id, voltageLevel); - network = voltageLevel.getNetwork().getRef(); - int stateArraySize = network.get().getStateManager().getStateArraySize(); - terminals = new ArrayList<>(stateArraySize); - v = new TFloatArrayList(stateArraySize); - angle = new TFloatArrayList(stateArraySize); - connectedComponentNumber = new TIntArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - terminals.add(new ArrayList<>()); - v.add(Float.NaN); - angle.add(Float.NaN); - connectedComponentNumber.add(-1); - } - } - - @Override - public int getConnectedTerminalCount() { - return (int) getTerminals().stream().filter(BusTerminal::isConnected).count(); - } - - @Override - public List getConnectedTerminals() { - return getTerminals().stream().filter(BusTerminal::isConnected).collect(Collectors.toList()); - } - - @Override - public int getTerminalCount() { - return terminals.get(network.get().getStateIndex()).size(); - } - - @Override - public List getTerminals() { - return terminals.get(network.get().getStateIndex()); - } - - @Override - public void addTerminal(BusTerminal t) { - terminals.get(network.get().getStateIndex()).add(t); - } - - @Override - public void removeTerminal(BusTerminal t) { - if (!terminals.get(network.get().getStateIndex()).remove(t)) { - throw new IllegalStateException("Terminal " + t + " not found"); - } - } - - protected void notifyUpdate(String attribute, Object oldValue, Object newValue) { - network.get().getListeners().notifyUpdate(this, attribute, oldValue, newValue); - } - - @Override - public float getV() { - return v.get(network.get().getStateIndex()); - } - - @Override - public BusExt setV(float v) { - if (v <= 0) { - throw new ValidationException(this, "voltage cannot be <= 0"); - } - float oldValue = this.v.set(network.get().getStateIndex(), v); - notifyUpdate("v", oldValue, v); - return this; - } - - @Override - public float getAngle() { - return angle.get(network.get().getStateIndex()); - } - - @Override - public BusExt setAngle(float angle) { - float oldValue = this.angle.set(network.get().getStateIndex(), angle); - notifyUpdate("angle", oldValue, angle); - return this; - } - - @Override - public void setConnectedComponentNumber(int connectedComponentNumber) { - this.connectedComponentNumber.set(network.get().getStateIndex(), connectedComponentNumber); - } - - @Override - public ConnectedComponent getConnectedComponent() { - NetworkImpl.ConnectedComponentsManager ccm = voltageLevel.getNetwork().getConnectedComponentsManager(); - ccm.update(); - return ccm.getConnectedComponent(connectedComponentNumber.get(network.get().getStateIndex())); - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - terminals.ensureCapacity(terminals.size() + number); - v.ensureCapacity(v.size() + number); - angle.ensureCapacity(angle.size() + number); - connectedComponentNumber.ensureCapacity(connectedComponentNumber.size() + number); - for (int i = 0; i < number; i++) { - terminals.add(new ArrayList<>(terminals.get(sourceIndex))); - v.add(v.get(sourceIndex)); - angle.add(angle.get(sourceIndex)); - connectedComponentNumber.add(connectedComponentNumber.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - for (int i = 0; i < number; i++) { - terminals.remove(terminals.size()-1); - } - v.remove(v.size() - number, number); - angle.remove(angle.size() - number, number); - connectedComponentNumber.remove(connectedComponentNumber.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - terminals.set(index, null); - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - for (int index : indexes) { - terminals.set(index, new ArrayList<>(terminals.get(sourceIndex))); - v.set(index, v.get(sourceIndex)); - angle.set(index, angle.get(sourceIndex)); - connectedComponentNumber.set(index, connectedComponentNumber.get(sourceIndex)); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectableImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectableImpl.java deleted file mode 100644 index 55ecef6e..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectableImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Connectable; -import eu.itesla_project.iidm.network.Identifiable; - -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class ConnectableImpl> extends IdentifiableImpl implements Connectable, Stateful { - - protected final List terminals = new ArrayList<>(); - - ConnectableImpl(String id, String name) { - super(id, name); - } - - void addTerminal(TerminalExt terminal) { - terminals.add(terminal); - terminal.setConnectable(this); - } - - public List getTerminals() { - return terminals; - } - - protected NetworkImpl getNetwork() { - if (terminals.isEmpty()) { - throw new RuntimeException(id + " is not attached to a network"); - } - return terminals.get(0).getVoltageLevel().getNetwork(); - } - - @Override - public void remove() { - NetworkImpl network = getNetwork(); - network.getObjectStore().remove(this); - for (TerminalExt terminal : terminals) { - VoltageLevelExt vl = terminal.getVoltageLevel(); - vl.detach(terminal); - vl.clean(); - } - network.getListeners().notifyRemoval(this); - } - - protected void notifyUpdate(String attribute, Object oldValue, Object newValue) { - getNetwork().getListeners().notifyUpdate(this, attribute, oldValue, newValue); - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - for (TerminalExt t : terminals) { - t.extendStateArraySize(initStateArraySize, number, sourceIndex); - } - } - - @Override - public void reduceStateArraySize(int number) { - for (TerminalExt t : terminals) { - t.reduceStateArraySize(number); - } - } - - @Override - public void deleteStateArrayElement(int index) { - for (TerminalExt t : terminals) { - t.deleteStateArrayElement(index); - } - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - for (TerminalExt t : terminals) { - t.allocateStateArrayElement(indexes, sourceIndex); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectedComponentImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectedComponentImpl.java deleted file mode 100644 index 56817c12..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ConnectedComponentImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.impl.util.Ref; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.ConnectedComponent; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ConnectedComponentImpl implements ConnectedComponent { - - private final int num; - - private final int size; - - private final Ref networkRef; - - ConnectedComponentImpl(int num, int size, Ref networkRef) { - this.num = num; - this.size = size; - this.networkRef = networkRef; - } - - @Override - public int getNum() { - return num; - } - - @Override - public int getSize() { - return size; - } - - @Override - public Iterable getBuses() { - return Iterables.filter(networkRef.get().getBusView().getBuses(), new Predicate() { - @Override - public boolean apply(Bus bus) { - return bus.getConnectedComponent() == ConnectedComponentImpl.this; - } - }); - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsAdderImpl.java deleted file mode 100644 index 39dd018d..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsAdderImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.CurrentLimits; -import eu.itesla_project.iidm.network.CurrentLimits.TemporaryLimit; -import eu.itesla_project.iidm.network.CurrentLimitsAdder; -import eu.itesla_project.iidm.network.impl.CurrentLimitsImpl.TemporaryLimitImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Comparator; -import java.util.TreeMap; -import java.util.stream.Collectors; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CurrentLimitsAdderImpl & Validable> implements CurrentLimitsAdder { - - private static final Comparator ACCEPTABLE_DURATION_COMPARATOR = (acceptableDuraction1, acceptableDuraction2) -> acceptableDuraction2 - acceptableDuraction1; - - private static final Logger LOGGER = LoggerFactory.getLogger(CurrentLimitsAdderImpl.class); - - private final SIDE side; - - private final OWNER owner; - - private float permanentLimit = Float.NaN; - - private final TreeMap temporaryLimits = new TreeMap<>(ACCEPTABLE_DURATION_COMPARATOR); - - public class TemporaryLimitAdderImpl implements TemporaryLimitAdder { - - private String name; - - private float value = Float.NaN; - - private Integer acceptableDuration; - - private boolean fictitious = false; - - @Override - public TemporaryLimitAdder setName(String name) { - this.name = name; - return this; - } - - @Override - public TemporaryLimitAdder setValue(float value) { - this.value = value; - return this; - } - - @Override - public TemporaryLimitAdder setAcceptableDuration(int acceptableDuration) { - this.acceptableDuration = acceptableDuration; - return this; - } - - @Override - public TemporaryLimitAdder setFictitious(boolean fictitious) { - this.fictitious = fictitious; - return this; - } - - @Override - public CurrentLimitsAdder endTemporaryLimit() { - if (Float.isNaN(value)) { - throw new ValidationException(owner, "temporary limit value is not set"); - } - if (value <= 0) { - throw new ValidationException(owner, "temporary limit value must be > 0"); - } - if (acceptableDuration == null) { - throw new ValidationException(owner, "acceptable duration is not set"); - } - if (acceptableDuration < 0) { - throw new ValidationException(owner, "acceptable duration must be >= 0"); - } - if (name == null) { - throw new ValidationException(owner, "name is not set"); - } - temporaryLimits.put(acceptableDuration, new TemporaryLimitImpl(name, value, acceptableDuration, fictitious)); - return CurrentLimitsAdderImpl.this; - } - - } - - public CurrentLimitsAdderImpl(SIDE side, OWNER owner) { - this.side = side; - this.owner = owner; - } - - @Override - public CurrentLimitsAdder setPermanentLimit(float limit) { - this.permanentLimit = limit; - return this; - } - - @Override - public TemporaryLimitAdder beginTemporaryLimit() { - return new TemporaryLimitAdderImpl(); - } - - private void checkTemporaryLimits() { - // check temporary limits are consistents with permanent - float previousLimit = Float.NaN; - for (TemporaryLimit tl : temporaryLimits.values()) { // iterate in ascending order - if (tl.getValue() <= permanentLimit) { - LOGGER.debug("{}, temporary limit should be greather than permanent limit", owner.getMessageHeader()); - } - if (Float.isNaN(previousLimit)) { - previousLimit = tl.getValue(); - } else { - if (tl.getValue() <= previousLimit) { - LOGGER.debug("{} : temporary limits should be in ascending value order", owner.getMessageHeader()); - } - } - } - // check name unicity - temporaryLimits.values().stream() - .collect(Collectors.groupingBy(tl -> tl.getName())) - .forEach((name, temporaryLimits1) -> { - if (temporaryLimits1.size() > 1) { - throw new ValidationException(owner, temporaryLimits1.size() + "temporary limits have the same name " + name); - } - }); - } - - @Override - public CurrentLimits add() { - if (permanentLimit <= 0) { - throw new ValidationException(owner, "permanent limit must be > 0"); - } - checkTemporaryLimits(); - CurrentLimitsImpl limits = new CurrentLimitsImpl(permanentLimit, temporaryLimits); - owner.setCurrentLimits(side, limits); - return limits; - } - - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java deleted file mode 100644 index 7d034f97..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.CurrentLimits; -import java.util.Collection; -import java.util.Objects; -import java.util.TreeMap; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class CurrentLimitsImpl implements CurrentLimits { - - private final float permanentLimit; - - private final TreeMap temporaryLimits; - - static class TemporaryLimitImpl implements TemporaryLimit { - - private final String name; - - private final float value; - - private final int acceptableDuration; - - private boolean fictitious; - - TemporaryLimitImpl(String name, float value, int acceptableDuration, boolean fictitious) { - this.name = Objects.requireNonNull(name); - this.value = value; - this.acceptableDuration = acceptableDuration; - this.fictitious = fictitious; - } - - @Override - public String getName() { - return name; - } - - @Override - public float getValue() { - return value; - } - - @Override - public int getAcceptableDuration() { - return acceptableDuration; - } - - @Override - public boolean isFictitious() { - return fictitious; - } - } - - CurrentLimitsImpl(float permanentLimit, TreeMap temporaryLimits) { - this.permanentLimit = permanentLimit; - this.temporaryLimits = temporaryLimits; - } - - @Override - public float getPermanentLimit() { - return permanentLimit; - } - - @Override - public Collection getTemporaryLimits() { - return temporaryLimits.values(); - } - - @Override - public TemporaryLimit getTemporaryLimit(int acceptableDuration) { - return temporaryLimits.get(acceptableDuration); - } - - @Override - public float getTemporaryLimitValue(int acceptableDuration) { - TemporaryLimit tl = getTemporaryLimit(acceptableDuration); - return tl != null ? tl.getValue() : Float.NaN; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsOwner.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsOwner.java deleted file mode 100644 index 446ecf97..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/CurrentLimitsOwner.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface CurrentLimitsOwner { - - void setCurrentLimits(SIDE side, CurrentLimitsImpl limits); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineAdderImpl.java deleted file mode 100644 index c2d0df8f..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineAdderImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.DanglingLineAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class DanglingLineAdderImpl extends SingleTerminalConnectableAdderImpl implements DanglingLineAdder { - - private final VoltageLevelExt voltageLevel; - - private float p0 = Float.NaN; - - private float q0 = Float.NaN; - - private float r = Float.NaN; - - private float x = Float.NaN; - - private float g = Float.NaN; - - private float b = Float.NaN; - - private String ucteXnodeCode; - - DanglingLineAdderImpl(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Dangling line"; - } - - @Override - public DanglingLineAdderImpl setP0(float p0) { - this.p0 = p0; - return this; - } - - @Override - public DanglingLineAdderImpl setQ0(float q0) { - this.q0 = q0; - return this; - } - - @Override - public DanglingLineAdderImpl setR(float r) { - this.r = r; - return this; - } - - @Override - public DanglingLineAdderImpl setX(float x) { - this.x = x; - return this; - } - - @Override - public DanglingLineAdderImpl setG(float g) { - this.g = g; - return this; - } - - @Override - public DanglingLineAdderImpl setB(float b) { - this.b = b; - return this; - } - - @Override - public DanglingLineAdder setUcteXnodeCode(String ucteXnodeCode) { - this.ucteXnodeCode = ucteXnodeCode; - return this; - } - - @Override - public DanglingLineImpl add() { - String id = checkAndGetUniqueId(); - TerminalExt terminal = checkAndGetTerminal(id); - - ValidationUtil.checkP0(this, p0); - ValidationUtil.checkQ0(this, q0); - ValidationUtil.checkR(this, r); - ValidationUtil.checkX(this, x); - ValidationUtil.checkG(this, g); - ValidationUtil.checkB(this, b); - - DanglingLineImpl danglingLine = new DanglingLineImpl(getNetwork().getRef(), id, getName(), p0, q0, r, x, g, b, ucteXnodeCode); - danglingLine.addTerminal(terminal); - voltageLevel.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(danglingLine); - getNetwork().getListeners().notifyCreation(danglingLine); - return danglingLine; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineImpl.java deleted file mode 100644 index 0260d7d0..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/DanglingLineImpl.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.CurrentLimitsAdder; -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.DanglingLine; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; - -/** - * - * @author Geoffroy Jamgotchian - */ -class DanglingLineImpl extends ConnectableImpl implements DanglingLine, CurrentLimitsOwner { - - private final Ref network; - - private float r; - - private float x; - - private float g; - - private float b; - - private String ucteXnodeCode; - - private CurrentLimitsImpl limits; - - // attributes depending on the state - - private final TFloatArrayList p0; - - private final TFloatArrayList q0; - - DanglingLineImpl(Ref network, String id, String name, float p0, float q0, float r, float x, float g, float b, String ucteXnodeCode) { - super(id, name); - this.network = network; - int stateArraySize = network.get().getStateManager().getStateArraySize(); - this.p0 = new TFloatArrayList(stateArraySize); - this.q0 = new TFloatArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - this.p0.add(p0); - this.q0.add(q0); - } - this.r = r; - this.x = x; - this.g = g; - this.b = b; - this.ucteXnodeCode = ucteXnodeCode; - } - - @Override - public ConnectableType getType() { - return ConnectableType.DANGLING_LINE; - } - - @Override - public TerminalExt getTerminal() { - return terminals.get(0); - } - - @Override - protected String getTypeDescription() { - return "Dangling line"; - } - - @Override - public float getP0() { - return p0.get(network.get().getStateIndex()); - } - - @Override - public DanglingLineImpl setP0(float p0) { - ValidationUtil.checkP0(this, p0); - float oldValue = this.p0.set(network.get().getStateIndex(), p0); - notifyUpdate("p0", oldValue, p0); - return this; - } - - @Override - public float getQ0() { - return q0.get(network.get().getStateIndex()); - } - - @Override - public DanglingLineImpl setQ0(float q0) { - ValidationUtil.checkQ0(this, q0); - float oldValue = this.q0.set(network.get().getStateIndex(), q0); - notifyUpdate("q0", oldValue, q0); - return this; - } - - @Override - public float getR() { - return r; - } - - @Override - public DanglingLineImpl setR(float r) { - ValidationUtil.checkR(this, r); - float oldValue = this.r; - this.r = r; - notifyUpdate("r", oldValue, r); - return this; - } - - @Override - public float getX() { - return x; - } - - @Override - public DanglingLineImpl setX(float x) { - ValidationUtil.checkX(this, x); - float oldValue = this.x; - this.x = x; - notifyUpdate("x", oldValue, x); - return this; - } - - @Override - public float getG() { - return g; - } - - @Override - public DanglingLineImpl setG(float g) { - ValidationUtil.checkG(this, g); - float oldValue = this.g; - this.g = g; - notifyUpdate("g", oldValue, g); - return this; - } - - @Override - public float getB() { - return b; - } - - @Override - public DanglingLineImpl setB(float b) { - ValidationUtil.checkB(this, b); - float oldValue = this.b; - this.b = b; - notifyUpdate("b", oldValue, b); - return this; - } - - @Override - public String getUcteXnodeCode() { - return ucteXnodeCode; - } - - @Override - public void setCurrentLimits(Void side, CurrentLimitsImpl limits) { - this.limits = limits; - } - - @Override - public CurrentLimitsImpl getCurrentLimits() { - return limits; - } - - @Override - public CurrentLimitsAdder newCurrentLimits() { - return new CurrentLimitsAdderImpl<>(null, this); - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - p0.ensureCapacity(p0.size() + number); - q0.ensureCapacity(q0.size() + number); - for (int i = 0; i < number; i++) { - p0.add(p0.get(sourceIndex)); - q0.add(q0.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - p0.remove(p0.size() - number, number); - q0.remove(q0.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - p0.set(index, p0.get(sourceIndex)); - q0.set(index, q0.get(sourceIndex)); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorAdderImpl.java deleted file mode 100644 index eb337bb1..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorAdderImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.GeneratorAdder; -import eu.itesla_project.iidm.network.EnergySource; -import eu.itesla_project.iidm.network.Terminal; - -/** - * - * @author Geoffroy Jamgotchian - */ -class GeneratorAdderImpl extends SingleTerminalConnectableAdderImpl implements GeneratorAdder { - - private final VoltageLevelExt voltageLevel; - - private EnergySource energySource = EnergySource.OTHER; - - private float minP = Float.NaN; - - private float maxP = Float.NaN; - - private TerminalExt regulatingTerminal; - - private Boolean voltageRegulatorOn; - - private float targetP = Float.NaN; - - private float targetQ = Float.NaN; - - private float targetV = Float.NaN; - - private float ratedS = Float.NaN; - - GeneratorAdderImpl(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Generator"; - } - - @Override - public GeneratorAdderImpl setEnergySource(EnergySource energySource) { - this.energySource = energySource; - return this; - } - - @Override - public GeneratorAdderImpl setMaxP(float maxP) { - this.maxP = maxP; - return this; - } - - @Override - public GeneratorAdderImpl setMinP(float minP) { - this.minP = minP; - return this; - } - - @Override - public GeneratorAdder setVoltageRegulatorOn(boolean voltageRegulatorOn) { - this.voltageRegulatorOn = voltageRegulatorOn; - return this; - } - - @Override - public GeneratorAdder setRegulatingTerminal(Terminal regulatingTerminal) { - this.regulatingTerminal = (TerminalExt) regulatingTerminal; - return this; - } - - @Override - public GeneratorAdderImpl setTargetP(float targetP) { - this.targetP = targetP; - return this; - } - - @Override - public GeneratorAdderImpl setTargetQ(float targetQ) { - this.targetQ = targetQ; - return this; - } - - @Override - public GeneratorAdderImpl setTargetV(float targetV) { - this.targetV = targetV; - return this; - } - - @Override - public GeneratorAdder setRatedS(float ratedS) { - this.ratedS = ratedS; - return this; - } - - @Override - public GeneratorImpl add() { - String id = checkAndGetUniqueId(); - TerminalExt terminal = checkAndGetTerminal(id); - ValidationUtil.checkEnergySource(this, energySource); - ValidationUtil.checkMinP(this, minP); - ValidationUtil.checkMaxP(this, maxP); - ValidationUtil.checkRegulatingTerminal(this, regulatingTerminal, getNetwork()); - ValidationUtil.checkTargetP(this, targetP); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn, targetV, targetQ); - ValidationUtil.checkActiveLimits(this, minP, maxP); - ValidationUtil.checkRatedS(this, ratedS); - GeneratorImpl generator - = new GeneratorImpl(getNetwork().getRef(), - id, getName(), energySource, - minP, maxP, - voltageRegulatorOn, regulatingTerminal != null ? regulatingTerminal : terminal, - targetP, targetQ, targetV, - ratedS); - generator.addTerminal(terminal); - voltageLevel.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(generator); - getNetwork().getListeners().notifyCreation(generator); - return generator; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorImpl.java deleted file mode 100644 index 8dada786..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/GeneratorImpl.java +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; - -import java.util.BitSet; - -/** - * - * @author Geoffroy Jamgotchian - */ -class GeneratorImpl extends ConnectableImpl implements Generator, ReactiveLimitsOwner { - - private EnergySource energySource; - - private float minP; - - private float maxP; - - private float ratedS; - - private ReactiveLimits reactiveLimits; - - private TerminalExt regulatingTerminal; - - // attributes depending on the state - - private final BitSet voltageRegulatorOn; - - private final TFloatArrayList targetP; - - private final TFloatArrayList targetQ; - - private final TFloatArrayList targetV; - - GeneratorImpl(Ref ref, - String id, String name, EnergySource energySource, - float minP, float maxP, - boolean voltageRegulatorOn, TerminalExt regulatingTerminal, - float targetP, float targetQ, float targetV, - float ratedS) { - super(id, name); - this.energySource = energySource; - this.minP = minP; - this.maxP = maxP; - reactiveLimits = new MinMaxReactiveLimitsImpl(-Float.MAX_VALUE, Float.MAX_VALUE); - this.regulatingTerminal = regulatingTerminal; - this.ratedS = ratedS; - int stateArraySize = ref.get().getStateManager().getStateArraySize(); - this.voltageRegulatorOn = new BitSet(stateArraySize); - this.targetP = new TFloatArrayList(stateArraySize); - this.targetQ = new TFloatArrayList(stateArraySize); - this.targetV = new TFloatArrayList(stateArraySize); - this.voltageRegulatorOn.set(0, stateArraySize, voltageRegulatorOn); - for (int i = 0; i < stateArraySize; i++) { - this.targetP.add(targetP); - this.targetQ.add(targetQ); - this.targetV.add(targetV); - } - } - - @Override - public ConnectableType getType() { - return ConnectableType.GENERATOR; - } - - @Override - public TerminalExt getTerminal() { - return terminals.get(0); - } - - @Override - public EnergySource getEnergySource() { - return energySource; - } - - @Override - public GeneratorImpl setEnergySource(EnergySource energySource) { - ValidationUtil.checkEnergySource(this, energySource); - EnergySource oldValue = this.energySource; - this.energySource = energySource; - notifyUpdate("energySource", oldValue.toString(), energySource.toString()); - return this; - } - - @Override - public float getMaxP() { - return maxP; - } - - @Override - public GeneratorImpl setMaxP(float maxP) { - ValidationUtil.checkMaxP(this, maxP); - ValidationUtil.checkActiveLimits(this, minP, maxP); - float oldValue = this.maxP; - this.maxP = maxP; - notifyUpdate("maxP", oldValue, maxP); - return this; - } - - @Override - public float getMinP() { - return minP; - } - - @Override - public GeneratorImpl setMinP(float minP) { - ValidationUtil.checkMinP(this, minP); - ValidationUtil.checkActiveLimits(this, minP, maxP); - float oldValue = this.minP; - this.minP = minP; - notifyUpdate("minP", oldValue, minP); - return this; - } - - @Override - public boolean isVoltageRegulatorOn() { - return voltageRegulatorOn.get(getNetwork().getStateIndex()); - } - - @Override - public GeneratorImpl setVoltageRegulatorOn(boolean voltageRegulatorOn) { - int stateIndex = getNetwork().getStateIndex(); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn, targetV.get(stateIndex), targetQ.get(stateIndex)); - boolean oldValue = this.voltageRegulatorOn.get(stateIndex); - this.voltageRegulatorOn.set(stateIndex, voltageRegulatorOn); - notifyUpdate("voltageRegulatorOn", oldValue, voltageRegulatorOn); - return this; - } - - @Override - public TerminalExt getRegulatingTerminal() { - return regulatingTerminal; - } - - @Override - public GeneratorImpl setRegulatingTerminal(Terminal regulatingTerminal) { - ValidationUtil.checkRegulatingTerminal(this, (TerminalExt) regulatingTerminal, getNetwork()); - this.regulatingTerminal = regulatingTerminal != null ? (TerminalExt) regulatingTerminal : getTerminal(); - return this; - } - - @Override - public float getTargetP() { - return targetP.get(getNetwork().getStateIndex()); - } - - @Override - public GeneratorImpl setTargetP(float targetP) { - ValidationUtil.checkTargetP(this, targetP); - float oldValue = this.targetP.set(getNetwork().getStateIndex(), targetP); - notifyUpdate("targetP", oldValue, targetP); - return this; - } - - @Override - public float getTargetQ() { - return targetQ.get(getNetwork().getStateIndex()); - } - - @Override - public GeneratorImpl setTargetQ(float targetQ) { - int stateIndex = getNetwork().getStateIndex(); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn.get(stateIndex), targetV.get(stateIndex), targetQ); - float oldValue = this.targetQ.set(stateIndex, targetQ); - notifyUpdate("targetQ", oldValue, targetQ); - return this; - } - - @Override - public float getTargetV() { - return this.targetV.get(getNetwork().getStateIndex()); - } - - @Override - public GeneratorImpl setTargetV(float targetV) { - int stateIndex = getNetwork().getStateIndex(); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn.get(stateIndex), targetV, targetQ.get(stateIndex)); - float oldValue = this.targetV.set(stateIndex, targetV); - notifyUpdate("targetV", oldValue, targetV); - return this; - } - - @Override - public float getRatedS() { - return ratedS; - } - - @Override - public GeneratorImpl setRatedS(float ratedS) { - ValidationUtil.checkRatedS(this, ratedS); - float oldValue = this.ratedS; - this.ratedS = ratedS; - notifyUpdate("ratedS", oldValue, ratedS); - return this; - } - - @Override - public ReactiveCapabilityCurveAdderImpl newReactiveCapabilityCurve() { - return new ReactiveCapabilityCurveAdderImpl(this); - } - - @Override - public MinMaxReactiveLimitsAdderImpl newMinMaxReactiveLimits() { - return new MinMaxReactiveLimitsAdderImpl(this); - } - - @Override - public void setReactiveLimits(ReactiveLimits reactiveLimits) { - this.reactiveLimits = reactiveLimits; - } - - @Override - public ReactiveLimits getReactiveLimits() { - return reactiveLimits; - } - - @Override - public RL getReactiveLimits(Class type) { - if (type == null) { - throw new IllegalArgumentException("type is null"); - } - if (type.isInstance(reactiveLimits)) { - return type.cast(reactiveLimits); - } else { - throw new ValidationException(this, "incorrect reactive limits type " - + type.getName() + ", expected " + reactiveLimits.getClass()); - } - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - targetP.ensureCapacity(targetP.size() + number); - targetQ.ensureCapacity(targetQ.size() + number); - targetV.ensureCapacity(targetV.size() + number); - for (int i = 0; i < number; i++) { - voltageRegulatorOn.set(initStateArraySize + i, voltageRegulatorOn.get(sourceIndex)); - targetP.add(targetP.get(sourceIndex)); - targetQ.add(targetQ.get(sourceIndex)); - targetV.add(targetV.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - targetP.remove(targetP.size() - number, number); - targetQ.remove(targetQ.size() - number, number); - targetV.remove(targetV.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - voltageRegulatorOn.set(index, voltageRegulatorOn.get(sourceIndex)); - targetP.set(index, targetP.get(sourceIndex)); - targetQ.set(index, targetQ.get(sourceIndex)); - targetV.set(index, targetV.get(sourceIndex)); - } - } - - @Override - protected String getTypeDescription() { - return "Generator"; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcConverterStationImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcConverterStationImpl.java deleted file mode 100644 index e6eb5520..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcConverterStationImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.HvdcConverterStation; -import eu.itesla_project.iidm.network.Terminal; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -abstract class HvdcConverterStationImpl> extends ConnectableImpl implements HvdcConverterStation { - - HvdcConverterStationImpl(String id, String name) { - super(id, name); - } - - @Override - public Terminal getTerminal() { - return terminals.get(0); - } - - @Override - public ConnectableType getType() { - return ConnectableType.HVDC_CONVERTER_STATION; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineAdderImpl.java deleted file mode 100644 index 8472572e..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineAdderImpl.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.HvdcLine; -import eu.itesla_project.iidm.network.HvdcLineAdder; -import eu.itesla_project.iidm.network.impl.util.Ref; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class HvdcLineAdderImpl extends IdentifiableAdderImpl implements HvdcLineAdder { - - private final Ref networkRef; - - private float r = Float.NaN; - - private HvdcLine.ConvertersMode convertersMode; - - private float nominalV = Float.NaN; - - private float activePowerSetPoint = Float.NaN; - - private float maxP = Float.NaN; - - private String converterStationId1; - - private String converterStationId2; - - public HvdcLineAdderImpl(Ref networkRef) { - this.networkRef = Objects.requireNonNull(networkRef); - } - - @Override - protected NetworkImpl getNetwork() { - return networkRef.get(); - } - - @Override - protected String getTypeDescription() { - return HvdcLineImpl.TYPE_DESCRIPTION; - } - - @Override - public HvdcLineAdder setR(float r) { - this.r = r; - return this; - } - - @Override - public HvdcLineAdder setConvertersMode(HvdcLine.ConvertersMode convertersMode) { - this.convertersMode = convertersMode; - return this; - } - - @Override - public HvdcLineAdder setNominalV(float nominalV) { - this.nominalV = nominalV; - return this; - } - - @Override - public HvdcLineAdder setActivePowerSetPoint(float targetP) { - this.activePowerSetPoint = targetP; - return this; - } - - @Override - public HvdcLineAdder setMaxP(float maxP) { - this.maxP = maxP; - return this; - } - - @Override - public HvdcLineAdder setConverterStationId1(String converterStationId1) { - this.converterStationId1 = converterStationId1; - return this; - } - - @Override - public HvdcLineAdder setConverterStationId2(String converterStationId2) { - this.converterStationId2 = converterStationId2; - return this; - } - - @Override - public HvdcLine add() { - String id = checkAndGetUniqueId(); - String name = getName(); - ValidationUtil.checkR(this, r); - ValidationUtil.checkConvertersMode(this, convertersMode); - ValidationUtil.checkNominalV(this, nominalV); - ValidationUtil.checkActivePowerSetPoint(this, activePowerSetPoint); - ValidationUtil.checkMaxP(this, maxP); - HvdcConverterStationImpl converterStation1 = getNetwork().getHvdcConverterStation(converterStationId1); - if (converterStation1 == null) { - throw new RuntimeException("Side 1 converter station " + converterStationId1 + " not found"); - } - HvdcConverterStationImpl converterStation2 = getNetwork().getHvdcConverterStation(converterStationId2); - if (converterStation2 == null) { - throw new RuntimeException("Side 2 converter station " + converterStationId2 + " not found"); - } - HvdcLineImpl hvdcLine = new HvdcLineImpl(id, name, r, nominalV, maxP, convertersMode, activePowerSetPoint, - converterStation1, converterStation2, networkRef); - getNetwork().getObjectStore().checkAndAdd(hvdcLine); - getNetwork().getListeners().notifyCreation(hvdcLine); - return hvdcLine; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineImpl.java deleted file mode 100644 index 2ed98162..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/HvdcLineImpl.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.HvdcConverterStation; -import eu.itesla_project.iidm.network.HvdcLine; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; - -import java.util.BitSet; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class HvdcLineImpl extends IdentifiableImpl implements HvdcLine, Stateful { - - static final String TYPE_DESCRIPTION = "hvdcLine"; - - private float r; - - private float nominalV; - - private float maxP; - - // attributes depending on the state - - private final BitSet convertersMode; - - private final TFloatArrayList activePowerSetPoint; - - // - - private final HvdcConverterStationImpl converterStation1; - - private final HvdcConverterStationImpl converterStation2; - - private final Ref networkRef; - - HvdcLineImpl(String id, String name, float r, float nominalV, float maxP, ConvertersMode convertersMode, float activePowerSetPoint, - HvdcConverterStationImpl converterStation1, HvdcConverterStationImpl converterStation2, - Ref networkRef) { - super(id, name); - this.r = r; - this.nominalV = nominalV; - this.maxP = maxP; - int stateArraySize = networkRef.get().getStateManager().getStateArraySize(); - this.convertersMode = new BitSet(stateArraySize); - this.convertersMode.set(0, stateArraySize, convertersMode == ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER); - this.activePowerSetPoint = new TFloatArrayList(stateArraySize); - this.activePowerSetPoint.fill(0, stateArraySize, activePowerSetPoint); - this.converterStation1 = converterStation1; - this.converterStation2 = converterStation2; - this.networkRef = networkRef; - } - - protected void notifyUpdate(String attribute, Object oldValue, Object newValue) { - getNetwork().getListeners().notifyUpdate(this, attribute, oldValue, newValue); - } - - @Override - public NetworkImpl getNetwork() { - return networkRef.get(); - } - - private static ConvertersMode toEnum(boolean convertersMode) { - return convertersMode ? ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER : ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER; - } - - private static boolean fromEnum(ConvertersMode convertersMode) { - return convertersMode == ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER; - } - - @Override - public ConvertersMode getConvertersMode() { - return toEnum(convertersMode.get(getNetwork().getStateIndex())); - } - - @Override - public HvdcLineImpl setConvertersMode(ConvertersMode convertersMode) { - ValidationUtil.checkConvertersMode(this, convertersMode); - int stateIndex = getNetwork().getStateIndex(); - boolean oldValue = this.convertersMode.get(stateIndex); - this.convertersMode.set(stateIndex, fromEnum(Objects.requireNonNull(convertersMode))); - notifyUpdate("convertersMode", toEnum(oldValue), convertersMode); - return this; - } - - @Override - public float getR() { - return r; - } - - @Override - public HvdcLineImpl setR(float r) { - ValidationUtil.checkR(this, r); - float oldValue = this.r; - this.r = r; - notifyUpdate("r", oldValue, r); - return this; - } - - @Override - public float getNominalV() { - return nominalV; - } - - @Override - public HvdcLineImpl setNominalV(float nominalV) { - ValidationUtil.checkNominalV(this, nominalV); - float oldValue = this.nominalV; - this.nominalV = nominalV; - notifyUpdate("nominalV", oldValue, nominalV); - return this; - } - - @Override - public float getMaxP() { - return maxP; - } - - @Override - public HvdcLineImpl setMaxP(float maxP) { - ValidationUtil.checkMaxP(this, maxP); - float oldValue = this.maxP; - this.maxP = maxP; - notifyUpdate("maxP", oldValue, maxP); - return this; - } - - @Override - public float getActivePowerSetPoint() { - return activePowerSetPoint.get(getNetwork().getStateIndex()); - } - - @Override - public HvdcLineImpl setActivePowerSetPoint(float activePowerSetPoint) { - ValidationUtil.checkActivePowerSetPoint(this, activePowerSetPoint); - float oldValue = this.activePowerSetPoint.set(getNetwork().getStateIndex(), activePowerSetPoint); - notifyUpdate("targetP", oldValue, activePowerSetPoint); - return this; - } - - @Override - public HvdcConverterStation getConverterStation1() { - return converterStation1; - } - - @Override - public HvdcConverterStation getConverterStation2() { - return converterStation2; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - convertersMode.set(initStateArraySize, initStateArraySize + number, convertersMode.get(sourceIndex)); - - activePowerSetPoint.ensureCapacity(activePowerSetPoint.size() + number); - activePowerSetPoint.fill(initStateArraySize, initStateArraySize + number, activePowerSetPoint.get(sourceIndex)); - } - - @Override - public void reduceStateArraySize(int number) { - activePowerSetPoint.remove(activePowerSetPoint.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - for (int index : indexes) { - convertersMode.set(index, convertersMode.get(sourceIndex)); - activePowerSetPoint.set(index, activePowerSetPoint.get(sourceIndex)); - } - } - - @Override - public void remove() { - NetworkImpl network = getNetwork(); - network.getObjectStore().remove(this); - network.getListeners().notifyRemoval(this); - } - - @Override - protected String getTypeDescription() { - return "hvdcLine"; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableAdderImpl.java deleted file mode 100644 index 31c67470..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableAdderImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.Identifiable; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class IdentifiableAdderImpl> implements Validable { - - private String id; - - private boolean ensureIdUnicity = false; - - private String name; - - IdentifiableAdderImpl() { - } - - protected abstract NetworkImpl getNetwork(); - - protected abstract String getTypeDescription(); - - public T setId(String id) { - this.id = id; - return (T) this; - } - - public T setEnsureIdUnicity(boolean ensureIdUnicity) { - this.ensureIdUnicity = ensureIdUnicity; - return (T) this; - } - - public T setName(String name) { - this.name = name; - return (T) this; - } - - protected String checkAndGetUniqueId() { - if (id == null) { - throw new ITeslaException(getTypeDescription() + " id is not set"); - } - String uniqueId; - if (ensureIdUnicity) { - uniqueId = getNetwork().getObjectStore().getUniqueId(id); - } else { - if (getNetwork().getObjectStore().contains(id)) { - Identifiable obj = getNetwork().getObjectStore().get(id); - throw new ITeslaException("The network " + getNetwork().getId() - + " already contains an object '" + obj.getClass().getSimpleName() - + "' with the id '" + id + "'"); - } - uniqueId = id; - } - return uniqueId; - } - - protected String getName() { - return name; - } - - @Override - public String getMessageHeader() { - return getTypeDescription() + " '" + id + "': "; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableImpl.java deleted file mode 100644 index 75bfac32..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/IdentifiableImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Identifiable; - -import java.util.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class IdentifiableImpl> implements Identifiable, Validable { - - protected String id; - - protected String name; - - protected Properties properties; - - protected final Map, Extension> extensions = new HashMap<>(); - - IdentifiableImpl(String id, String name) { - this.id = id; - this.name = name; - } - - @Override - public String getId() { - return id; - } - - @Override - public String getName() { - return name != null ? name : id; - } - - protected abstract String getTypeDescription(); - - @Override - public String getMessageHeader() { - return getTypeDescription() + " '" + id + "': "; - } - - @Override - public boolean hasProperty() { - return properties != null && properties.size() > 0; - } - - @Override - public Properties getProperties() { - if (properties == null) { - properties = new Properties(); - } - return properties; - } - - @Override - public > void addExtension(Class type, E extension) { - Objects.requireNonNull(type); - Objects.requireNonNull(extension); - extensions.put(type, extension); - } - - @Override - public > E getExtension(Class type) { - Objects.requireNonNull(type); - return (E) extensions.get(type); - } - - @Override - public > boolean removeExtension(Class type) { - Objects.requireNonNull(type); - return extensions.remove(type) != null; - } - - @Override - public Collection> getExtensions() { - return extensions.values(); - } - - @Override - public String toString() { - return id; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationAdderImpl.java deleted file mode 100644 index 7571ea2a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationAdderImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.LccConverterStation; -import eu.itesla_project.iidm.network.LccConverterStationAdder; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class LccConverterStationAdderImpl extends SingleTerminalConnectableAdderImpl implements LccConverterStationAdder { - - private final VoltageLevelExt voltageLevel; - - private float powerFactor = Float.NaN; - - LccConverterStationAdderImpl(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return LccConverterStationImpl.TYPE_DESCRIPTION; - } - - @Override - public LccConverterStationAdder setPowerFactor(float powerFactor) { - this.powerFactor = powerFactor; - return this; - } - - @Override - public LccConverterStation add() { - String id = checkAndGetUniqueId(); - String name = getName(); - TerminalExt terminal = checkAndGetTerminal(id); - ValidationUtil.checkPowerFactor(this, powerFactor); - LccConverterStationImpl converterStation - = new LccConverterStationImpl(id, name, powerFactor); - converterStation.addTerminal(terminal); - voltageLevel.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(converterStation); - getNetwork().getListeners().notifyCreation(converterStation); - return converterStation; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationImpl.java deleted file mode 100644 index c026d325..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccConverterStationImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.LccConverterStation; -import eu.itesla_project.iidm.network.LccFilter; -import eu.itesla_project.iidm.network.LccFilterAdder; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class LccConverterStationImpl extends HvdcConverterStationImpl implements LccConverterStation { - - static final String TYPE_DESCRIPTION = "lccConverterStation"; - - private float powerFactor; - - private final List filters = new ArrayList<>(); - - LccConverterStationImpl(String id, String name, float powerFactor) { - super(id, name); - this.powerFactor = powerFactor; - } - - @Override - public HvdcType getHvdcType() { - return HvdcType.LCC; - } - - @Override - protected String getTypeDescription() { - return TYPE_DESCRIPTION; - } - - @Override - public float getPowerFactor() { - return powerFactor; - } - - @Override - public LccConverterStation setPowerFactor(float powerFactor) { - ValidationUtil.checkPowerFactor(this, powerFactor); - float oldValue = this.powerFactor; - this.powerFactor = powerFactor; - notifyUpdate("powerFactor", oldValue, powerFactor); - return this; - } - - @Override - public Iterable getFilters() { - return Collections.unmodifiableCollection(filters); - } - - private void checkFilterIndex(int index) { - if (index < 0 || index >= filters.size()) { - throw new RuntimeException("Bad filter index " + index); - } - } - - @Override - public LccFilter getFilterAt(int index) { - checkFilterIndex(index); - return filters.get(index); - } - - @Override - public LccFilterAdder newFilter() { - return new LccFilterAdderImpl(this); - } - - @Override - public int getFilterCount() { - return filters.size(); - } - - @Override - public void removeFilterAt(int index) { - checkFilterIndex(index); - filters.remove(index); - } - - void addFilter(LccFilterImpl filter) { - Objects.requireNonNull(filter); - filters.add(filter); - } - - void notifyFilterUpdate(LccFilterImpl filter, String attribute, Object oldValue, Object newValue) { - int filterIndex = filters.indexOf(filter); - notifyUpdate("filter[" + filterIndex + "]." + attribute, oldValue, newValue); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterAdderImpl.java deleted file mode 100644 index 9b3c13c6..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterAdderImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.LccFilterAdder; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class LccFilterAdderImpl implements LccFilterAdder, Validable { - - private final LccConverterStationImpl converterStation; - - private float b = Float.NaN; - - private Boolean connected; - - LccFilterAdderImpl(LccConverterStationImpl converterStation) { - this.converterStation = Objects.requireNonNull(converterStation); - } - - @Override - public String getMessageHeader() { - return converterStation.getMessageHeader() + "filter "; - } - - @Override - public LccFilterAdder setB(float b) { - this.b = b; - return this; - } - - @Override - public LccFilterAdder setConnected(boolean connected) { - this.connected = connected; - return this; - } - - @Override - public LccFilterImpl add() { - ValidationUtil.checkConnected(this, connected); - ValidationUtil.checkB(this, b); - LccFilterImpl filter = new LccFilterImpl(converterStation, b, connected); - converterStation.addFilter(filter); - return filter; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterImpl.java deleted file mode 100644 index 34c3fcde..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LccFilterImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.LccFilter; - -import java.util.BitSet; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class LccFilterImpl implements LccFilter, Stateful, Validable { - - private float b; - - private final BitSet connected; - - private final LccConverterStationImpl converterStation; - - LccFilterImpl(LccConverterStationImpl converterStation, float b, boolean connected) { - this.converterStation = Objects.requireNonNull(converterStation); - this.b = b; - - int stateArraySize = getNetwork().getStateManager().getStateArraySize(); - this.connected = new BitSet(stateArraySize); - this.connected.set(0, stateArraySize, connected); - } - - @Override - public String getMessageHeader() { - return converterStation.getMessageHeader() + "filter "; - } - - private NetworkImpl getNetwork() { - return converterStation.getNetwork(); - } - - private void notifyUpdate(String attribute, Object oldValue, Object newValue) { - converterStation.notifyFilterUpdate(this, attribute, oldValue, newValue); - } - - @Override - public float getB() { - return b; - } - - @Override - public LccFilterImpl setB(float b) { - ValidationUtil.checkB(this, b); - float oldValue = this.b; - this.b = b; - notifyUpdate("b", oldValue, b); - return this; - } - - @Override - public boolean isConnected() { - return connected.get(getNetwork().getStateIndex()); - } - - @Override - public LccFilterImpl setConnected(boolean connected) { - int stateIndex = getNetwork().getStateIndex(); - boolean oldValue = this.connected.get(stateIndex); - this.connected.set(stateIndex, connected); - notifyUpdate("connected", oldValue, connected); - return this; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - connected.set(initStateArraySize, initStateArraySize + number, connected.get(sourceIndex)); - } - - @Override - public void reduceStateArraySize(int number) { - // Nothing to do - } - - @Override - public void deleteStateArrayElement(int index) { - // Nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - for (int index : indexes) { - connected.set(index, connected.get(sourceIndex)); - } - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineAdderImpl.java deleted file mode 100644 index d299b6b3..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineAdderImpl.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.LineAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class LineAdderImpl extends TwoTerminalsConnectableAdderImpl implements LineAdder { - - private final NetworkImpl network; - - private float r = Float.NaN; - - private float x = Float.NaN; - - private float g1 = Float.NaN; - - private float b1 = Float.NaN; - - private float g2 = Float.NaN; - - private float b2 = Float.NaN; - - LineAdderImpl(NetworkImpl network) { - this.network = network; - } - - @Override - protected NetworkImpl getNetwork() { - return network; - } - - @Override - protected String getTypeDescription() { - return "AC Line"; - } - - @Override - public LineAdderImpl setR(float r) { - this.r = r; - return this; - } - - @Override - public LineAdderImpl setX(float x) { - this.x = x; - return this; - } - - @Override - public LineAdderImpl setG1(float g1) { - this.g1 = g1; - return this; - } - - @Override - public LineAdderImpl setB1(float b1) { - this.b1 = b1; - return this; - } - - @Override - public LineAdderImpl setG2(float g2) { - this.g2 = g2; - return this; - } - - @Override - public LineAdderImpl setB2(float b2) { - this.b2 = b2; - return this; - } - - @Override - public LineImpl add() { - String id = checkAndGetUniqueId(); - VoltageLevelExt voltageLevel1 = checkAndGetVoltageLevel1(id); - VoltageLevelExt voltageLevel2 = checkAndGetVoltageLevel2(id); - TerminalExt terminal1 = checkAndGetTerminal1(id); - TerminalExt terminal2 = checkAndGetTerminal2(id); - - ValidationUtil.checkR(this, r); - ValidationUtil.checkX(this, x); - ValidationUtil.checkG1(this, g1); - ValidationUtil.checkG2(this, g2); - ValidationUtil.checkB1(this, b1); - ValidationUtil.checkB2(this, b2); - - // check that the line is attachable on both side - voltageLevel1.attach(terminal1, true); - voltageLevel2.attach(terminal2, true); - - LineImpl line = new LineImpl(id, getName(), r, x, g1, b1, g2, b2); - terminal1.setNum(1); - terminal2.setNum(2); - line.addTerminal(terminal1); - line.addTerminal(terminal2); - voltageLevel1.attach(terminal1, false); - voltageLevel2.attach(terminal2, false); - network.getObjectStore().checkAndAdd(line); - getNetwork().getListeners().notifyCreation(line); - return line; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineImpl.java deleted file mode 100644 index 5e1007f2..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LineImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.Line; - -/** - * - * @author Geoffroy Jamgotchian - */ -class LineImpl extends AbstractTwoTerminalsConnectable implements Line { - - private float r; - - private float x; - - private float g1; - - private float b1; - - private float g2; - - private float b2; - - LineImpl(String id, String name, float r, float x, float g1, float b1, float g2, float b2) { - super(id, name); - this.r = r; - this.x = x; - this.g1 = g1; - this.b1 = b1; - this.g2 = g2; - this.b2 = b2; - } - - @Override - public ConnectableType getType() { - return ConnectableType.LINE; - } - - @Override - public float getR() { - return r; - } - - @Override - public LineImpl setR(float r) { - ValidationUtil.checkR(this, r); - float oldValue = this.r; - this.r = r; - notifyUpdate("r", oldValue, r); - return this; - } - - @Override - public float getX() { - return x; - } - - @Override - public LineImpl setX(float x) { - ValidationUtil.checkX(this, x); - float oldValue = this.x; - this.x = x; - notifyUpdate("x", oldValue, x); - return this; - } - - @Override - public float getG1() { - return g1; - } - - @Override - public LineImpl setG1(float g1) { - ValidationUtil.checkG1(this, g1); - float oldValue = this.g1; - this.g1 = g1; - notifyUpdate("g1", oldValue, g1); - return this; - } - - @Override - public float getB1() { - return b1; - } - - @Override - public LineImpl setB1(float b1) { - ValidationUtil.checkB1(this, b1); - float oldValue = this.b1; - this.b1 = b1; - notifyUpdate("b1", oldValue, b1); - return this; - } - - @Override - public float getG2() { - return g2; - } - - @Override - public LineImpl setG2(float g2) { - ValidationUtil.checkG2(this, g2); - float oldValue = this.g2; - this.g2 = g2; - notifyUpdate("g2", oldValue, g2); - return this; - } - - @Override - public float getB2() { - return b2; - } - - @Override - public LineImpl setB2(float b2) { - ValidationUtil.checkB2(this, b2); - float oldValue = this.b2; - this.b2 = b2; - notifyUpdate("b2", oldValue, b2); - return this; - } - - @Override - public boolean isTieLine() { - return false; - } - - @Override - protected String getTypeDescription() { - return "AC line"; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadAdderImpl.java deleted file mode 100644 index f2b8abcc..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadAdderImpl.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.LoadAdder; -import eu.itesla_project.iidm.network.LoadType; - -/** - * - * @author Geoffroy Jamgotchian - */ -class LoadAdderImpl extends SingleTerminalConnectableAdderImpl implements LoadAdder { - - private final VoltageLevelExt voltageLevel; - - private LoadType loadType = LoadType.UNDEFINED; - - private float p0 = Float.NaN; - - private float q0 = Float.NaN; - - LoadAdderImpl(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Load"; - } - - @Override - public LoadAdder setLoadType(LoadType loadType) { - this.loadType = loadType; - return this; - } - - @Override - public LoadAdderImpl setP0(float p0) { - this.p0 = p0; - return this; - } - - @Override - public LoadAdderImpl setQ0(float q0) { - this.q0 = q0; - return this; - } - - @Override - public LoadImpl add() { - String id = checkAndGetUniqueId(); - TerminalExt terminal = checkAndGetTerminal(id); - ValidationUtil.checkLoadType(this, loadType); - ValidationUtil.checkP0(this, p0); - ValidationUtil.checkQ0(this, q0); - LoadImpl load = new LoadImpl(getNetwork().getRef(), id, getName(), loadType, p0, q0); - load.addTerminal(terminal); - voltageLevel.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(load); - getNetwork().getListeners().notifyCreation(load); - return load; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadImpl.java deleted file mode 100644 index e645f4d9..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/LoadImpl.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.LoadType; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; - -/** - * - * @author Geoffroy Jamgotchian - */ -class LoadImpl extends ConnectableImpl implements Load { - - private final Ref network; - - private LoadType loadType; - - // attributes depending on the state - - private final TFloatArrayList p0; - - private final TFloatArrayList q0; - - LoadImpl(Ref network, - String id, String name, LoadType loadType, float p0, float q0) { - super(id, name); - this.network = network; - this.loadType = loadType; - int stateArraySize = network.get().getStateManager().getStateArraySize(); - this.p0 = new TFloatArrayList(stateArraySize); - this.q0 = new TFloatArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - this.p0.add(p0); - this.q0.add(q0); - } - } - - @Override - public ConnectableType getType() { - return ConnectableType.LOAD; - } - - @Override - public TerminalExt getTerminal() { - return terminals.get(0); - } - - @Override - protected String getTypeDescription() { - return "Load"; - } - - @Override - public LoadType getLoadType() { - return loadType; - } - - @Override - public Load setLoadType(LoadType loadType) { - ValidationUtil.checkLoadType(this, loadType); - LoadType oldValue = this.loadType; - this.loadType = loadType; - notifyUpdate("loadType", oldValue.toString(), loadType.toString()); - return this; - } - - @Override - public float getP0() { - return p0.get(network.get().getStateIndex()); - } - - @Override - public LoadImpl setP0(float p0) { - ValidationUtil.checkP0(this, p0); - float oldValue = this.p0.set(network.get().getStateIndex(), p0); - notifyUpdate("p0", oldValue, p0); - return this; - } - - @Override - public float getQ0() { - return q0.get(network.get().getStateIndex()); - } - - @Override - public LoadImpl setQ0(float q0) { - ValidationUtil.checkQ0(this, q0); - float oldValue = this.q0.set(network.get().getStateIndex(), q0); - notifyUpdate("q0", oldValue, q0); - return this; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - p0.ensureCapacity(p0.size() + number); - q0.ensureCapacity(q0.size() + number); - for (int i = 0; i < number; i++) { - p0.add(p0.get(sourceIndex)); - q0.add(q0.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - p0.remove(p0.size() - number, number); - q0.remove(q0.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - p0.set(index, p0.get(sourceIndex)); - q0.set(index, q0.get(sourceIndex)); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MergedBus.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MergedBus.java deleted file mode 100644 index 60a8cd76..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MergedBus.java +++ /dev/null @@ -1,260 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.Iterables; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.ConnectedComponent; -import eu.itesla_project.iidm.network.DanglingLine; -import eu.itesla_project.iidm.network.Generator; -import eu.itesla_project.iidm.network.Line; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.ShuntCompensator; -import eu.itesla_project.iidm.network.ThreeWindingsTransformer; -import eu.itesla_project.iidm.network.TopologyVisitor; -import eu.itesla_project.iidm.network.TwoWindingsTransformer; -import eu.itesla_project.iidm.network.VoltageLevel; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MergedBus extends IdentifiableImpl implements CalculatedBus { - - private final Set buses; - - private boolean valid = true; - - MergedBus(String id, Set buses) { - super(id, null); - if (buses.size() < 1) { - throw new IllegalArgumentException("buses.size() < 1"); - } - this.buses = buses; - } - - private void checkValidity() { - if (!valid) { - throw new ITeslaException("Bus has been invalidated"); - } - } - - @Override - public boolean isInMainConnectedComponent() { - for (ConfiguredBus bus : buses) { - return bus.isInMainConnectedComponent(); - } - return false; - } - - @Override - public int getConnectedTerminalCount() { - checkValidity(); - int count = 0; - for (ConfiguredBus bus : buses) { - count += bus.getTerminalCount(); - } - return count; - } - - @Override - public Iterable getConnectedTerminals() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getConnectedTerminals()); - } - return Iterables.concat(iterables); - } - - @Override - public void invalidate() { - valid = false; - buses.clear(); - } - - @Override - public VoltageLevel getVoltageLevel() { - checkValidity(); - return buses.iterator().next().getVoltageLevel(); - } - - @Override - public float getV() { - checkValidity(); - for (Bus b : buses) { - if (!Float.isNaN(b.getV())) { - return b.getV(); - } - } - return Float.NaN; - } - - @Override - public BusExt setV(float v) { - checkValidity(); - for (ConfiguredBus bus : buses) { - bus.setV(v); - } - return this; - } - - @Override - public float getAngle() { - checkValidity(); - for (Bus b : buses) { - if (!Float.isNaN(b.getAngle())) { - return b.getAngle(); - } - } - return Float.NaN; - } - - @Override - public BusExt setAngle(float angle) { - checkValidity(); - for (ConfiguredBus bus : buses) { - bus.setAngle(angle); - } - return this; - } - - @Override - public float getP() { - checkValidity(); - float p = 0; - for (Bus b : buses) { - p += b.getP(); - } - return p; - } - - @Override - public float getQ() { - checkValidity(); - float q = 0; - for (Bus b : buses) { - q += b.getQ(); - } - return q; - } - - @Override - public void setConnectedComponentNumber(int connectedComponentNumber) { - checkValidity(); - for (ConfiguredBus bus : buses) { - bus.setConnectedComponentNumber(connectedComponentNumber); - } - } - - @Override - public ConnectedComponent getConnectedComponent() { - checkValidity(); - for (Bus b : buses) { - ConnectedComponent cc = b.getConnectedComponent(); - if (cc != null) { - return cc; - } - } - throw new RuntimeException("Should not happened"); - } - - @Override - public Iterable getLines() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getLines()); - } - return Iterables.concat(iterables); - } - - @Override - public Iterable getTwoWindingTransformers() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getTwoWindingTransformers()); - } - return Iterables.concat(iterables); - } - - @Override - public Iterable getThreeWindingTransformers() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getThreeWindingTransformers()); - } - return Iterables.concat(iterables); - } - - @Override - public Iterable getGenerators() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getGenerators()); - } - return Iterables.concat(iterables); - } - - @Override - public Iterable getLoads() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getLoads()); - } - return Iterables.concat(iterables); - } - - @Override - public Iterable getShunts() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getShunts()); - } - return Iterables.concat(iterables); - } - - @Override - public Iterable getDanglingLines() { - checkValidity(); - List> iterables = new ArrayList<>(buses.size()); - for (ConfiguredBus bus : buses) { - iterables.add(bus.getDanglingLines()); - } - return Iterables.concat(iterables); - } - - @Override - public void visitConnectedEquipments(TopologyVisitor visitor) { - checkValidity(); - for (ConfiguredBus bus : buses) { - bus.visitConnectedEquipments(visitor); - } - } - - @Override - public void visitConnectedOrConnectableEquipments(TopologyVisitor visitor) { - checkValidity(); - for (ConfiguredBus bus : buses) { - bus.visitConnectedOrConnectableEquipments(visitor); - } - } - - @Override - protected String getTypeDescription() { - return "Bus"; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsAdderImpl.java deleted file mode 100644 index cf683679..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsAdderImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.MinMaxReactiveLimits; -import eu.itesla_project.iidm.network.MinMaxReactiveLimitsAdder; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class MinMaxReactiveLimitsAdderImpl implements MinMaxReactiveLimitsAdder { - - private final OWNER owner; - - private float minQ = Float.NaN; - - private float maxQ = Float.NaN; - - MinMaxReactiveLimitsAdderImpl(OWNER owner) { - this.owner = owner; - } - - @Override - public MinMaxReactiveLimitsAdder setMinQ(float minQ) { - this.minQ = minQ; - return this; - } - - @Override - public MinMaxReactiveLimitsAdder setMaxQ(float maxQ) { - this.maxQ = maxQ; - return this; - } - - @Override - public MinMaxReactiveLimits add() { - if (Float.isNaN(minQ)) { - throw new ValidationException(owner, "minimum reactive power is not set"); - } - if (Float.isNaN(maxQ)) { - throw new ValidationException(owner, "maximum reactive power is not set"); - } - if (maxQ < minQ) { - throw new ValidationException(owner, "maximum reactive power is expected to be greater than or equal to minimum reactive power"); - } - MinMaxReactiveLimitsImpl limits = new MinMaxReactiveLimitsImpl(minQ, maxQ); - owner.setReactiveLimits(limits); - return limits; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsImpl.java deleted file mode 100644 index e4644b93..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MinMaxReactiveLimitsImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.MinMaxReactiveLimits; -import eu.itesla_project.iidm.network.ReactiveLimitsKind; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MinMaxReactiveLimitsImpl implements MinMaxReactiveLimits { - - private final float minQ; - - private final float maxQ; - - MinMaxReactiveLimitsImpl(float minQ, float maxQ) { - this.minQ = minQ; - this.maxQ = maxQ; - } - - @Override - public float getMinQ() { - return minQ; - } - - @Override - public float getMaxQ() { - return maxQ; - } - - @Override - public ReactiveLimitsKind getKind() { - return ReactiveLimitsKind.MIN_MAX; - } - - @Override - public float getMinQ(float p) { - return minQ; - } - - @Override - public float getMaxQ(float p) { - return maxQ; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateContext.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateContext.java deleted file mode 100644 index c1c1e045..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateContext.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -class MultiStateContext implements StateContext { - - private int index; - - MultiStateContext(int initialStateIndex) { - this.index = initialStateIndex; - } - - @Override - public int getStateIndex() { - if (index == -1) { - throw new RuntimeException("State not set"); - } - return index; - } - - @Override - public void setStateIndex(int index) { - this.index = index; - } - - @Override - public void resetIfStateIndexIs(int index) { - if (this.index == index) { - this.index = -1; - } - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateObject.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateObject.java deleted file mode 100644 index 31ba0b54..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/MultiStateObject.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface MultiStateObject { - - StateManagerImpl getStateManager(); - - int getStateIndex(); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkFactoryServiceImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkFactoryServiceImpl.java deleted file mode 100644 index 4a79cbef..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkFactoryServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.NetworkFactoryService; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class NetworkFactoryServiceImpl implements NetworkFactoryService { - - @Override - public Network createNetwork(String id, String sourceFormat) { - return new NetworkImpl(id, id, sourceFormat); - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkImpl.java deleted file mode 100644 index 4f10ae6f..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkImpl.java +++ /dev/null @@ -1,840 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.*; -import eu.itesla_project.iidm.network.*; -import eu.itesla_project.iidm.network.impl.util.RefObj; -import eu.itesla_project.iidm.network.impl.util.RefChain; -import com.google.common.base.Function; -import eu.itesla_project.graph.GraphUtil; -import eu.itesla_project.graph.GraphUtil.ConnectedComponentsComputationResult; -import eu.itesla_project.iidm.network.TwoTerminalsConnectable.Side; -import gnu.trove.list.array.TIntArrayList; -import java.util.*; -import java.util.stream.Collectors; - -import org.joda.time.DateTime; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Geoffroy Jamgotchian - */ -class NetworkImpl extends IdentifiableImpl implements Network, MultiStateObject, Stateful { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetworkImpl.class); - - private static final Function> toBusBreakerViewBuses = new Function>() { - @Override - public Iterable apply(VoltageLevel vl) { - return vl.getBusBreakerView().getBuses(); - } - }; - - private static final Function> toBusBreakerViewSwitches = new Function>() { - @Override - public Iterable apply(VoltageLevel vl) { - return vl.getBusBreakerView().getSwitches(); - } - }; - - private static final Function> toBusViewBuses = new Function>() { - @Override - public Iterable apply(VoltageLevel vl) { - return vl.getBusView().getBuses(); - } - }; - - private final RefChain ref = new RefChain<>(new RefObj<>(this)); - - private DateTime caseDate = new DateTime(); // default is the time at which the network has been created - - private int forecastDistance = 0; - - private String sourceFormat; - - private final ObjectStore objectStore = new ObjectStore(); - - private final StateManagerImpl stateManager; - - private final NetworkListenerList listeners = new NetworkListenerList(); - - class BusBreakerViewImpl implements BusBreakerView { - - @Override - public Iterable getBuses() { - return FluentIterable.from(getVoltageLevels()) - .transformAndConcat(toBusBreakerViewBuses); - } - - @Override - public Iterable getSwitchs() { - return FluentIterable.from(getVoltageLevels()) - .transformAndConcat(toBusBreakerViewSwitches); - } - - } - - private final BusBreakerViewImpl busBreakerView = new BusBreakerViewImpl(); - - class BusViewImpl implements BusView { - - @Override - public Iterable getBuses() { - return FluentIterable.from(getVoltageLevels()) - .transformAndConcat(toBusViewBuses); - } - - @Override - public Collection getConnectedComponents() { - return Collections.unmodifiableList(states.get().connectedComponentsManager.getConnectedComponents()); - } - - } - - private final BusViewImpl busView = new BusViewImpl(); - - NetworkImpl(String id, String name, String sourceFormat) { - super(id, name); - Objects.requireNonNull(sourceFormat, "source format is null"); - this.sourceFormat = sourceFormat; - stateManager = new StateManagerImpl(objectStore); - states = new StateArray<>(ref, new StateFactory() { - @Override - public StateImpl newState() { - return new StateImpl(); - } - }); - // add the network the object list as it is a stateful object - // and it needs to be notified when and extension or a reduction of - // the state array is requested - objectStore.checkAndAdd(this); - } - - @Override - public ContainerType getContainerType() { - return ContainerType.NETWORK; - } - - @Override - public DateTime getCaseDate() { - return caseDate; - } - - @Override - public NetworkImpl setCaseDate(DateTime caseDate) { - ValidationUtil.checkCaseDate(this, caseDate); - this.caseDate = caseDate; - return this; - } - - @Override - public int getForecastDistance() { - return forecastDistance; - } - - @Override - public NetworkImpl setForecastDistance(int forecastDistance) { - ValidationUtil.checkForecastDistance(this, forecastDistance); - this.forecastDistance = forecastDistance; - return this; - } - - @Override - public String getSourceFormat() { - return sourceFormat; - } - - RefChain getRef() { - return ref; - } - - NetworkListenerList getListeners() { - return listeners; - } - - public ObjectStore getObjectStore() { - return objectStore; - } - - @Override - public StateManagerImpl getStateManager() { - return stateManager; - } - - @Override - public int getStateIndex() { - return stateManager.getStateContext().getStateIndex(); - } - - @Override - public Set getCountries() { - return FluentIterable.from(getSubstations()).transform(s -> s.getCountry()).toSet(); - } - - @Override - public int getCountryCount() { - return getCountries().size(); - } - - @Override - public SubstationAdder newSubstation() { - return new SubstationAdderImpl(ref); - } - - @Override - public Iterable getSubstations() { - return Collections.unmodifiableCollection(objectStore.getAll(SubstationImpl.class)); - } - - @Override - public int getSubstationCount() { - return objectStore.getAll(SubstationImpl.class).size(); - } - - @Override - public Iterable getSubstations(Country country, String tsoId, String... geographicalTags) { - return Substations.filter(getSubstations(), country, tsoId, geographicalTags); - } - - @Override - public SubstationImpl getSubstation(String id) { - return objectStore.get(id, SubstationImpl.class); - } - - @Override - public Iterable getVoltageLevels() { - return Iterables.concat(objectStore.getAll(BusBreakerVoltageLevel.class), - objectStore.getAll(NodeBreakerVoltageLevel.class)); - } - - @Override - public int getVoltageLevelCount() { - return objectStore.getAll(BusBreakerVoltageLevel.class).size() - + objectStore.getAll(NodeBreakerVoltageLevel.class).size() ; - } - - @Override - public VoltageLevelExt getVoltageLevel(String id) { - return objectStore.get(id, VoltageLevelExt.class); - } - - @Override - public LineAdderImpl newLine() { - return new LineAdderImpl(this); - } - - @Override - public Iterable getLines() { - return Iterables.concat(objectStore.getAll(LineImpl.class), objectStore.getAll(TieLineImpl.class)); - } - - @Override - public int getLineCount() { - return objectStore.getAll(LineImpl.class).size() + objectStore.getAll(TieLineImpl.class).size(); - } - - @Override - public LineImpl getLine(String id) { - LineImpl line = objectStore.get(id, LineImpl.class); - if (line == null) { - line = objectStore.get(id, TieLineImpl.class); - } - return line; - } - - @Override - public TieLineAdderImpl newTieLine() { - return new TieLineAdderImpl(this); - } - - @Override - public Iterable getTwoWindingsTransformers() { - return Collections.unmodifiableCollection(objectStore.getAll(TwoWindingsTransformerImpl.class)); - } - - @Override - public int getTwoWindingsTransformerCount() { - return objectStore.getAll(TwoWindingsTransformerImpl.class).size(); - } - - @Override - public TwoWindingsTransformer getTwoWindingsTransformer(String id) { - return objectStore.get(id, TwoWindingsTransformerImpl.class); - } - - @Override - public Iterable getThreeWindingsTransformers() { - return Collections.unmodifiableCollection(objectStore.getAll(ThreeWindingsTransformerImpl.class)); - } - - @Override - public int getThreeWindingsTransformerCount() { - return objectStore.getAll(ThreeWindingsTransformerImpl.class).size(); - } - - @Override - public ThreeWindingsTransformer getThreeWindingsTransformer(String id) { - return objectStore.get(id, ThreeWindingsTransformerImpl.class); - } - - @Override - public Iterable getGenerators() { - return Collections.unmodifiableCollection(objectStore.getAll(GeneratorImpl.class)); - } - - @Override - public int getGeneratorCount() { - return objectStore.getAll(GeneratorImpl.class).size(); - } - - @Override - public GeneratorImpl getGenerator(String id) { - return objectStore.get(id, GeneratorImpl.class); - } - - @Override - public Iterable getLoads() { - return Collections.unmodifiableCollection(objectStore.getAll(LoadImpl.class)); - } - - @Override - public int getLoadCount() { - return objectStore.getAll(LoadImpl.class).size(); - } - - @Override - public LoadImpl getLoad(String id) { - return objectStore.get(id, LoadImpl.class); - } - - @Override - public Iterable getShunts() { - return Collections.unmodifiableCollection(objectStore.getAll(ShuntCompensatorImpl.class)); - } - - @Override - public int getShuntCount() { - return objectStore.getAll(ShuntCompensatorImpl.class).size(); - } - - @Override - public ShuntCompensatorImpl getShunt(String id) { - return objectStore.get(id, ShuntCompensatorImpl.class); - } - - @Override - public Iterable getDanglingLines() { - return Collections.unmodifiableCollection(objectStore.getAll(DanglingLineImpl.class)); - } - - @Override - public int getDanglingLineCount() { - return objectStore.getAll(DanglingLineImpl.class).size(); - } - - @Override - public DanglingLineImpl getDanglingLine(String id) { - return objectStore.get(id, DanglingLineImpl.class); - } - - @Override - public Iterable getStaticVarCompensators() { - return Collections.unmodifiableCollection(objectStore.getAll(StaticVarCompensatorImpl.class)); - } - - @Override - public int getStaticVarCompensatorCount() { - return objectStore.getAll(StaticVarCompensatorImpl.class).size(); - } - - @Override - public StaticVarCompensatorImpl getStaticVarCompensator(String id) { - return objectStore.get(id, StaticVarCompensatorImpl.class); - } - - @Override - public Switch getSwitch(String id) { - return objectStore.get(id, SwitchImpl.class); - } - - @Override - public HvdcConverterStationImpl getHvdcConverterStation(String id) { - HvdcConverterStationImpl converterStation = objectStore.get(id, LccConverterStationImpl.class); - if (converterStation == null) { - converterStation = objectStore.get(id, VscConverterStationImpl.class); - } - return converterStation; - } - - @Override - public int getHvdcConverterStationCount() { - return objectStore.getAll(LccConverterStationImpl.class).size() + objectStore.getAll(VscConverterStationImpl.class).size(); - } - - @Override - public Iterable> getHvdcConverterStations() { - return Iterables.concat(objectStore.getAll(LccConverterStationImpl.class), objectStore.getAll(VscConverterStationImpl.class)); - } - - @Override - public HvdcLine getHvdcLine(String id) { - return objectStore.get(id, HvdcLineImpl.class); - } - - @Override - public int getHvdcLineCount() { - return objectStore.getAll(HvdcLineImpl.class).size(); - } - - @Override - public Iterable getHvdcLines() { - return Collections.unmodifiableCollection(objectStore.getAll(HvdcLineImpl.class)); - } - - @Override - public HvdcLineAdder newHvdcLine() { - return new HvdcLineAdderImpl(ref); - } - - @Override - public Identifiable getIdentifiable(String id) { - return objectStore.get(id, Identifiable.class); - } - - @Override - public Collection> getIdentifiables() { - return objectStore.getAll(); - } - - @Override - public BusBreakerViewImpl getBusBreakerView() { - return busBreakerView; - } - - @Override - public BusViewImpl getBusView() { - return busView; - } - - class ConnectedComponentsManager { - - private List connectedComponents; - - void invalidate() { - connectedComponents = null; - } - - void update() { - if (connectedComponents != null) { - return; - } - - long startTime = System.currentTimeMillis(); - - // reset - for (Bus b : getBusBreakerView().getBuses()) { - ((BusExt) b).setConnectedComponentNumber(-1); - } - - int num = 0; - Map id2num = new HashMap<>(); - List num2bus = new ArrayList<>(); - for (Bus bus : getBusView().getBuses()) { - num2bus.add((BusExt) bus); - id2num.put(bus.getId(), num); - num++; - } - TIntArrayList[] adjacencyList = new TIntArrayList[num]; - for (int i = 0; i < adjacencyList.length; i++) { - adjacencyList[i] = new TIntArrayList(3); - } - for (LineImpl line : Sets.union(objectStore.getAll(LineImpl.class), objectStore.getAll(TieLineImpl.class))) { - BusExt bus1 = line.getTerminal1().getBusView().getBus(); - BusExt bus2 = line.getTerminal2().getBusView().getBus(); - if (bus1 != null && bus2 != null) { - int busNum1 = id2num.get(bus1.getId()); - int busNum2 = id2num.get(bus2.getId()); - adjacencyList[busNum1].add(busNum2); - adjacencyList[busNum2].add(busNum1); - } - } - for (TwoWindingsTransformerImpl transfo : objectStore.getAll(TwoWindingsTransformerImpl.class)) { - BusExt bus1 = transfo.getTerminal1().getBusView().getBus(); - BusExt bus2 = transfo.getTerminal2().getBusView().getBus(); - if (bus1 != null && bus2 != null) { - int busNum1 = id2num.get(bus1.getId()); - int busNum2 = id2num.get(bus2.getId()); - adjacencyList[busNum1].add(busNum2); - adjacencyList[busNum2].add(busNum1); - } - } - for (ThreeWindingsTransformerImpl transfo : objectStore.getAll(ThreeWindingsTransformerImpl.class)) { - BusExt bus1 = transfo.getLeg1().getTerminal().getBusView().getBus(); - BusExt bus2 = transfo.getLeg2().getTerminal().getBusView().getBus(); - BusExt bus3 = transfo.getLeg3().getTerminal().getBusView().getBus(); - if (bus1 != null && bus2 != null) { - int busNum1 = id2num.get(bus1.getId()); - int busNum2 = id2num.get(bus2.getId()); - adjacencyList[busNum1].add(busNum2); - adjacencyList[busNum2].add(busNum1); - } - if (bus1 != null && bus3 != null) { - int busNum1 = id2num.get(bus1.getId()); - int busNum3 = id2num.get(bus3.getId()); - adjacencyList[busNum1].add(busNum3); - adjacencyList[busNum3].add(busNum1); - } - if (bus2 != null && bus3 != null) { - int busNum2 = id2num.get(bus2.getId()); - int busNum3 = id2num.get(bus3.getId()); - adjacencyList[busNum2].add(busNum3); - adjacencyList[busNum3].add(busNum2); - } - } - - ConnectedComponentsComputationResult result = GraphUtil.computeConnectedComponents(adjacencyList); - - connectedComponents = new ArrayList<>(result.getComponentSize().length); - for (int i = 0; i < result.getComponentSize().length; i++) { - connectedComponents.add(new ConnectedComponentImpl(i, result.getComponentSize()[i], ref)); - } - - for (int i = 0; i < result.getComponentNumber().length; i++) { - BusExt bus = num2bus.get(i); - bus.setConnectedComponentNumber(result.getComponentNumber()[i]); - } - - LOGGER.debug("Connected components computed in {} ms", (System.currentTimeMillis()-startTime)); - } - - List getConnectedComponents() { - update(); - return connectedComponents; - } - - ConnectedComponent getConnectedComponent(int num) { - // update() must not be put here, but explicitly called each time before because update may - // trigger a new cc computation and so on a change in the value of the num cc already passed - // (and outdated consequently) in parameter of this method - return num != -1 ? connectedComponents.get(num) : null; - } - - } - - private class StateImpl implements State { - - private final ConnectedComponentsManager connectedComponentsManager - = new ConnectedComponentsManager(); - - @Override - public StateImpl copy() { - return new StateImpl(); - } - - } - - private final StateArray states; - - ConnectedComponentsManager getConnectedComponentsManager() { - return states.get().connectedComponentsManager; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, final int sourceIndex) { - states.push(number, new StateFactory() { - @Override - public StateImpl newState() { - return states.copy(sourceIndex); - } - }); - } - - @Override - public void reduceStateArraySize(int number) { - states.pop(number); - } - - @Override - public void deleteStateArrayElement(int index) { - states.delete(index); - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - states.allocate(indexes, new StateFactory() { - @Override - public StateImpl newState() { - return states.copy(sourceIndex); - } - }); - } - - @Override - protected String getTypeDescription() { - return "Network"; - } - - private void setId(String id) { - objectStore.remove(this); - this.id = id; - name = null; // reset the name - objectStore.checkAndAdd(this); - } - - @Override - public void merge(Network other) { - NetworkImpl otherNetwork = (NetworkImpl) other; - - // this check must not be done on the number of state but on the size - // of the internal state array because the network can have only - // one state but an internal array with a size greater that one and - // some re-usable states - if (stateManager.getStateArraySize() != 1 || otherNetwork.stateManager.getStateArraySize() != 1) { - throw new RuntimeException("Merging of multi-states network is not supported"); - } - - long start = System.currentTimeMillis(); - - // check mergeability - Multimap, String> intersection = objectStore.intersection(otherNetwork.objectStore); - for (Map.Entry, Collection> entry : intersection.asMap().entrySet()) { - Class clazz = entry.getKey(); - if (clazz == DanglingLineImpl.class) { // fine for dangling lines - continue; - } - Collection objs = entry.getValue(); - if (objs.size() > 0) { - throw new RuntimeException("The following object(s) of type " - + clazz.getSimpleName() + " exist(s) in both networks: " - + objs); - } - } - - class LineMerge { - String id; - String voltageLevel1; - String voltageLevel2; - String xnode; - String bus1; - String bus2; - String connectableBus1; - String connectableBus2; - Integer node1; - Integer node2; - - class HalfLineMerge { - String id; - String name; - float r; - float x; - float g1; - float g2; - float b1; - float b2; - float xnodeP; - float xnodeQ; - } - - final HalfLineMerge half1 = new HalfLineMerge(); - final HalfLineMerge half2 = new HalfLineMerge(); - - CurrentLimits limits1; - CurrentLimits limits2; - float p1; - float q1; - float p2; - float q2; - - Country country1; - Country country2; - } - - // try to find dangling lines couples - Map dl1byXnodeCode = new HashMap<>(); - for (DanglingLine dl1 : getDanglingLines()) { - if (dl1.getUcteXnodeCode() != null) { - dl1byXnodeCode.put(dl1.getUcteXnodeCode(), dl1); - } - } - List lines = new ArrayList<>(); - for (DanglingLine dl2 : Lists.newArrayList(other.getDanglingLines())) { - DanglingLine dl1 = getDanglingLine(dl2.getId()); - if (dl1 == null) { - // mapping by ucte xnode code - if (dl2.getUcteXnodeCode() != null) { - dl1 = dl1byXnodeCode.get(dl2.getUcteXnodeCode()); - } - } else { - // mapping by id - if (dl1.getUcteXnodeCode() != null && dl2.getUcteXnodeCode() != null - && !dl1.getUcteXnodeCode().equals(dl2.getUcteXnodeCode())) { - throw new RuntimeException("Dangling line couple " + dl1.getId() - + " have inconsistent Xnodes (" + dl1.getUcteXnodeCode() - + "!=" + dl2.getUcteXnodeCode() + ")"); - } - } - if (dl1 != null) { - LineMerge l = new LineMerge(); - l.id = dl1.getId().compareTo(dl2.getId()) < 0 ? dl1.getId() + " + " + dl2.getId() : dl2.getId() + " + " + dl1.getId(); - Terminal t1 = dl1.getTerminal(); - Terminal t2 = dl2.getTerminal(); - VoltageLevel vl1 = t1.getVoltageLevel(); - VoltageLevel vl2 = t2.getVoltageLevel(); - l.voltageLevel1 = vl1.getId(); - l.voltageLevel2 = vl2.getId(); - l.xnode = dl1.getUcteXnodeCode(); - l.half1.id = dl1.getId(); - l.half1.name = dl1.getName(); - l.half1.r = dl1.getR(); - l.half1.x = dl1.getX(); - l.half1.g1 = dl1.getG(); - l.half1.g2 = 0; - l.half1.b1 = dl1.getB(); - l.half1.b2 = 0; - l.half1.xnodeP = dl1.getP0(); - l.half1.xnodeQ = dl1.getQ0(); - l.half2.id = dl2.getId(); - l.half2.name = dl2.getName(); - l.half2.r = dl2.getR(); - l.half2.x = dl2.getX(); - l.half2.g1 = dl2.getG(); - l.half2.g2 = 0; - l.half2.b1 = dl2.getB(); - l.half2.b2 = 0; - l.half2.xnodeP = dl2.getP0(); - l.half2.xnodeQ = dl2.getQ0(); - l.limits1 = dl1.getCurrentLimits(); - l.limits2 = dl2.getCurrentLimits(); - if (t1.getVoltageLevel().getTopologyKind() == TopologyKind.BUS_BREAKER) { - Bus b1 = t1.getBusBreakerView().getBus(); - if (b1 != null) { - l.bus1 = b1.getId(); - } - l.connectableBus1 = t1.getBusBreakerView().getConnectableBus().getId(); - } else { - l.node1 = t1.getNodeBreakerView().getNode(); - } - if (t2.getVoltageLevel().getTopologyKind() == TopologyKind.BUS_BREAKER) { - Bus b2 = t2.getBusBreakerView().getBus(); - if (b2 != null) { - l.bus2 = b2.getId(); - } - l.connectableBus2 = t2.getBusBreakerView().getConnectableBus().getId(); - } else { - l.node2 = t2.getNodeBreakerView().getNode(); - } - l.p1 = t1.getP(); - l.q1 = t1.getQ(); - l.p2 = t2.getP(); - l.q2 = t2.getQ(); - l.country1 = vl1.getSubstation().getCountry(); - l.country2 = vl2.getSubstation().getCountry(); - lines.add(l); - - // remove the 2 dangling lines - dl1.remove(); - dl2.remove(); - } - } - - // do not forget to remove the other network from its store!!! - otherNetwork.objectStore.remove(otherNetwork); - - // merge the stores - objectStore.merge(otherNetwork.objectStore); - - // fix network back reference of the other network objects - otherNetwork.ref.setRef(ref); - - Multimap mergedLineByBoundary = HashMultimap.create(); - for (LineMerge lm: lines) { - LOGGER.debug("Replacing dangling line couple '{}' (xnode={}, country1={}, country2={}) by a line", - lm.id, lm.xnode, lm.country1, lm.country2); - TieLineAdderImpl la = newTieLine() - .setId(lm.id) - .setVoltageLevel1(lm.voltageLevel1) - .setVoltageLevel2(lm.voltageLevel2) - .line1().setId(lm.half1.id) - .setName(lm.half1.name) - .setR(lm.half1.r) - .setX(lm.half1.x) - .setG1(lm.half1.g1) - .setG2(lm.half1.g2) - .setB1(lm.half1.b1) - .setB2(lm.half1.b2) - .setXnodeP(lm.half1.xnodeP) - .setXnodeQ(lm.half1.xnodeQ) - .line2().setId(lm.half2.id) - .setName(lm.half2.name) - .setR(lm.half2.r) - .setX(lm.half2.x) - .setG1(lm.half2.g1) - .setG2(lm.half2.g2) - .setB1(lm.half2.b1) - .setB2(lm.half2.b2) - .setXnodeP(lm.half2.xnodeP) - .setXnodeQ(lm.half2.xnodeQ) - .setUcteXnodeCode(lm.xnode); - if (lm.bus1 != null) { - la.setBus1(lm.bus1); - } - la.setConnectableBus1(lm.connectableBus1); - if (lm.bus2 != null) { - la.setBus2(lm.bus2); - } - la.setConnectableBus2(lm.connectableBus2); - if (lm.node1 != null) { - la.setNode1(lm.node1); - } - if (lm.node2 != null) { - la.setNode2(lm.node2); - } - TieLineImpl l = la.add(); - l.setCurrentLimits(Side.ONE, (CurrentLimitsImpl) lm.limits1); - l.setCurrentLimits(Side.TWO, (CurrentLimitsImpl) lm.limits2); - l.getTerminal1().setP(lm.p1).setQ(lm.q1); - l.getTerminal2().setP(lm.p2).setQ(lm.q2); - - mergedLineByBoundary.put(new Boundary(lm.country1, lm.country2), lm); - } - - if (lines.size() > 0) { - LOGGER.info("{} dangling line couples have been replaced by a line: {}", lines.size(), - mergedLineByBoundary.asMap().entrySet().stream().map(e -> e.getKey() + ": " + e.getValue().size()).collect(Collectors.toList())); - } - - // update the source format - if (!sourceFormat.equals(otherNetwork.sourceFormat)) { - sourceFormat = "hybrid"; - } - - // change the network id - setId(getId() + " + " + otherNetwork.getId()); - - LOGGER.info("Merging of {} done in {} ms", id, (System.currentTimeMillis() - start)); - } - - @Override - public void merge(Network... others) { - for (Network other : others) { - merge(other); - } - } - - @Override - public void addListener(NetworkListener listener) { - listeners.add(listener); - } - - @Override - public void removeListener(NetworkListener listener) { - listeners.remove(listener); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkListenerList.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkListenerList.java deleted file mode 100644 index a6b2de1d..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NetworkListenerList.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -class NetworkListenerList { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetworkListenerList.class); - - private final List listeners = new ArrayList<>(); - - void add(NetworkListener listener) { - listeners.add(listener); - } - - void remove(NetworkListener listener) { - listeners.remove(listener); - } - - void notifyUpdate(Identifiable identifiable, String attribute, Object oldValue, Object newValue) { - if (listeners.size() > 0 && !Objects.equals(oldValue, newValue)) { - for (NetworkListener listener : listeners) { - try { - listener.onUpdate(identifiable, attribute, oldValue, newValue); - } catch (Throwable t) { - LOGGER.error(t.toString(), t); - } - } - } - } - - void notifyCreation(Identifiable identifiable) { - for (NetworkListener listener : listeners) { - try { - listener.onCreation(identifiable); - } catch (Throwable t) { - LOGGER.error(t.toString(), t); - } - } - } - - void notifyRemoval(Identifiable identifiable) { - for (NetworkListener listener : listeners) { - try { - listener.onRemoval(identifiable); - } catch (Throwable t) { - LOGGER.error(t.toString(), t); - } - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeBreakerVoltageLevel.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeBreakerVoltageLevel.java deleted file mode 100644 index 69eac6f6..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeBreakerVoltageLevel.java +++ /dev/null @@ -1,1157 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.commons.collect.Downcast; -import eu.itesla_project.graph.TraverseResult; -import eu.itesla_project.graph.Traverser; -import eu.itesla_project.graph.UndirectedGraph; -import eu.itesla_project.graph.UndirectedGraphImpl; -import eu.itesla_project.iidm.network.*; -import eu.itesla_project.iidm.network.VoltageLevel.NodeBreakerView.SwitchAdder; -import eu.itesla_project.iidm.network.util.ShortIdDictionary; -import gnu.trove.list.array.TIntArrayList; -import org.kohsuke.graphviz.Edge; -import org.kohsuke.graphviz.Graph; -import org.kohsuke.graphviz.Node; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; -import java.util.*; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -/** - * - * @author Geoffroy Jamgotchian - */ -class NodeBreakerVoltageLevel extends AbstractVoltageLevel { - - private static final Logger LOGGER = LoggerFactory.getLogger(NodeBreakerVoltageLevel.class); - - private static final Downcast TERMINAL_DOWNCAST = new Downcast<>(); - - private static final BusChecker BUS_CHECKER = new RteBusChecker(); - - private static final BusNamingStrategy NAMING_STRATEGY = new NumberedBusNamingStrategy(); - - private final UndirectedGraphImpl graph = new UndirectedGraphImpl<>(); - - private final Map switches = new HashMap<>(); - - private class StateImpl implements State { - - final CalculatedBusTopology calculatedBusTopology - = new CalculatedBusTopology(); - - final CalculatedBusBreakerTopology calculatedBusBreakerTopology - = new CalculatedBusBreakerTopology(); - - @Override - public StateImpl copy() { - return new StateImpl(); - } - - } - - private final StateArray states; - - private class SwitchAdderImpl extends IdentifiableAdderImpl implements NodeBreakerView.SwitchAdder { - - private Integer node1; - - private Integer node2; - - private SwitchKind kind; - - private boolean open = false; - - private boolean retained = false; - - private SwitchAdderImpl() { - this(null); - } - - private SwitchAdderImpl(SwitchKind kind) { - this.kind = kind; - } - - @Override - protected NetworkImpl getNetwork() { - return NodeBreakerVoltageLevel.this.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Switch"; - } - - @Override - public NodeBreakerView.SwitchAdder setNode1(int node1) { - this.node1 = node1; - return this; - } - - @Override - public NodeBreakerView.SwitchAdder setNode2(int node2) { - this.node2 = node2; - return this; - } - - @Override - public NodeBreakerView.SwitchAdder setKind(SwitchKind kind) { - if (kind == null) { - throw new NullPointerException("kind is null"); - } - this.kind = kind; - return this; - } - - @Override - public SwitchAdder setKind(String kind) { - return setKind(SwitchKind.valueOf(kind)); - } - - @Override - public NodeBreakerView.SwitchAdder setOpen(boolean open) { - this.open = open; - return this; - } - - @Override - public NodeBreakerView.SwitchAdder setRetained(boolean retained) { - this.retained = retained; - return this; - } - - @Override - public Switch add() { - String id = checkAndGetUniqueId(); - if (node1 == null) { - throw new ValidationException(this, "first connection node is not set"); - } - if (node2 == null) { - throw new ValidationException(this, "second connection node is not set"); - } - if (kind == null) { - throw new ValidationException(this, "kind is not set"); - } - SwitchImpl _switch = new SwitchImpl(NodeBreakerVoltageLevel.this, id, getName(), kind, open, retained); - getNetwork().getObjectStore().checkAndAdd(_switch); - int e = graph.addEdge(node1, node2, _switch); - switches.put(id, e); - invalidateCache(); - getNetwork().getListeners().notifyCreation(_switch); - return _switch; - } - - } - - private class InternalConnectionAdderImpl extends IdentifiableAdderImpl implements NodeBreakerView.InternalConnectionAdder { - - private Integer node1; - - private Integer node2; - - private InternalConnectionAdderImpl() {} - - @Override - protected NetworkImpl getNetwork() { - return NodeBreakerVoltageLevel.this.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "InternalConnection"; - } - - @Override - public NodeBreakerView.InternalConnectionAdder setNode1(int node1) { - this.node1 = node1; - return this; - } - - @Override - public NodeBreakerView.InternalConnectionAdder setNode2(int node2) { - this.node2 = node2; - return this; - } - - - @Override - public void add() { - if (node1 == null) { - throw new ValidationException(this, "first connection node is not set"); - } - if (node2 == null) { - throw new ValidationException(this, "second connection node is not set"); - } - - int e = graph.addEdge(node1, node2, null); - invalidateCache(); - } - - } - - /** - * Cached data for buses - */ - private static class BusCache { - - private final CalculatedBus[] node2bus; - - private final Map id2bus; - - private BusCache(CalculatedBus[] node2bus, Map id2bus) { - this.node2bus = node2bus; - this.id2bus = id2bus; - } - - private Collection getBuses() { - return id2bus.values(); - } - - private CalculatedBus getBus(int node) { - return node2bus[node]; - } - - private CalculatedBus getBus(String id) { - return id2bus.get(id); - } - } - - /** - * Bus topology calculated from node breaker topology - */ - class CalculatedBusTopology { - - protected BusCache busCache; - - protected void updateCache() { - updateCache(new Predicate() { - @Override - public boolean apply(SwitchImpl _switch) { - return _switch.isOpen(); - } - }); - } - - protected BusChecker getBusChecker() { - return BUS_CHECKER; - } - - protected void updateCache(final Predicate terminate) { - if (busCache != null) { - return; - } - LOGGER.trace("Update bus topology of voltage level {}", NodeBreakerVoltageLevel.this.id); - Map id2bus = new LinkedHashMap<>(); - CalculatedBus[] node2bus = new CalculatedBus[graph.getMaxVertex()]; - boolean[] encountered = new boolean[graph.getMaxVertex()]; - Arrays.fill(encountered, false); - for (int n : graph.getVertices()) { - if (!encountered[n]) { - TerminalExt terminal = graph.getVertexObject(n); - final TIntArrayList nodes = new TIntArrayList(1); - nodes.add(n); - graph.traverse(n, new Traverser() { - @Override - public TraverseResult traverse(int n1, int e, int n2) { - SwitchImpl _switch = graph.getEdgeObject(e); - if (_switch != null && terminate.apply(_switch)) { - return TraverseResult.TERMINATE; - } else { - nodes.add(n2); - return TraverseResult.CONTINUE; - } - } - }, encountered); - - // check that the component is a bus - String busId = NAMING_STRATEGY.getName(NodeBreakerVoltageLevel.this, nodes); - CopyOnWriteArrayList terminals = new CopyOnWriteArrayList<>(); - for (int i = 0; i < nodes.size(); i++) { - int n2 = nodes.getQuick(i); - NodeTerminal terminal2 = graph.getVertexObject(n2); - if (terminal2 != null) { - terminals.add(terminal2); - } - } - if (getBusChecker().isValid(graph, nodes, terminals)) { - CalculatedBusImpl bus = new CalculatedBusImpl(busId, NodeBreakerVoltageLevel.this, terminals); - id2bus.put(busId, bus); - for (int i = 0; i < nodes.size(); i++) { - node2bus[nodes.getQuick(i)] = bus; - } - } - - } - } - busCache = new BusCache(node2bus, id2bus); - LOGGER.trace("Found buses {}", id2bus.values()); - } - - protected void invalidateCache() { - // detach buses - if (busCache != null) { - for (CalculatedBus bus : busCache.id2bus.values()) { - bus.invalidate(); - } - busCache = null; - } - } - - Collection getBuses() { - updateCache(); - return busCache.getBuses(); - } - - CalculatedBus getBus(int node) { - updateCache(); - return busCache.getBus(node); - } - - CalculatedBus getBus(String id, boolean throwException) { - updateCache(); - CalculatedBus bus = busCache.getBus(id); - if (throwException && bus == null) { - throw new ITeslaException("Bus " + id + " not found"); - } - return bus; - } - - BusExt getConnectableBus(int node) { - // check id the node is associated to a bus - BusExt connectableBus = getBus(node); - if (connectableBus != null) { - return connectableBus; - } - // if not traverse the graph starting from the node (without stopping at open switches) until finding another - // node associated to a bus - BusExt[] connectableBus2 = new BusExt[1]; - graph.traverse(node, (v1, e, v2) -> { - connectableBus2[0] = getBus(v2); - if (connectableBus2[0] != null) { - return TraverseResult.TERMINATE; - } - return TraverseResult.CONTINUE; - }); - // if nothing found, just take the first bus - if (connectableBus2[0] != null) { - Iterator it = getBuses().iterator(); - if (!it.hasNext()) { - throw new AssertionError("Should not happen"); - } - return it.next(); - } - return connectableBus2[0]; - } - } - - /** - * Bus breaker topology calculated from node breaker topology - */ - class CalculatedBusBreakerTopology extends CalculatedBusTopology { - - @Override - protected void updateCache() { - updateCache(new Predicate() { - @Override - public boolean apply(SwitchImpl _switch) { - return _switch.isOpen() || _switch.isRetained(); - } - }); - } - - protected BusChecker getBusChecker() { - return new BusChecker() { - @Override - public boolean isValid(UndirectedGraph graph, TIntArrayList nodes, List terminals) { - return nodes.size() > 1 || !terminals.isEmpty(); - } - }; - } - - Bus getBus1(String switchId, boolean throwException) { - int edge = getEdge(switchId, throwException); - SwitchImpl _switch = graph.getEdgeObject(edge); - if (!_switch.isRetained()) { - if (throwException) { - throw new ITeslaException("Switch " + switchId + " not found"); - } - return null; - } - int node1 = graph.getEdgeVertex1(edge); - return getBus(node1); - } - - Bus getBus2(String switchId, boolean throwException) { - int edge = getEdge(switchId, throwException); - SwitchImpl _switch = graph.getEdgeObject(edge); - if (!_switch.isRetained()) { - if (throwException) { - throw new ITeslaException("Switch " + switchId + " not found"); - } - return null; - } - int node2 = graph.getEdgeVertex2(edge); - return getBus(node2); - } - - Iterable getSwitches() { - return Iterables.filter(graph.getEdgesObject(), new Predicate() { - @Override - public boolean apply(SwitchImpl _switch) { - return _switch != null && _switch.isRetained(); - } - }); - } - - SwitchImpl getSwitch(String switchId, boolean throwException) { - Integer edge = getEdge(switchId, false); - if (edge != null) { - SwitchImpl _switch = graph.getEdgeObject(edge); - if (_switch.isRetained()) { - return _switch; - } - } - if (throwException) { - throw new ITeslaException("Switch " + switchId + " not found"); - } - return null; - } - } - - private static interface BusChecker { - - boolean isValid(UndirectedGraph graph, TIntArrayList nodes, List terminals); - } - - /** - * RTE bus definition - */ - private static class RteBusChecker implements BusChecker { - - @Override - public boolean isValid(UndirectedGraph graph, TIntArrayList nodes, List terminals) { - int feederCount = 0; - int branchCount = 0; - int busbarSectionCount = 0; - for (int i = 0; i < nodes.size(); i++) { - int node = nodes.get(i); - TerminalExt terminal = graph.getVertexObject(node); - if (terminal != null) { - ConnectableImpl connectable = terminal.getConnectable(); - switch (connectable.getType()) { - case LINE: - case TWO_WINDINGS_TRANSFORMER: - case THREE_WINDINGS_TRANSFORMER: - branchCount++; - feederCount++; - break; - - case LOAD: - case GENERATOR: - case SHUNT_COMPENSATOR: - case DANGLING_LINE: - case STATIC_VAR_COMPENSATOR: - case HVDC_CONVERTER_STATION: - feederCount++; - break; - - case BUSBAR_SECTION: - busbarSectionCount++; - break; - - default: - throw new AssertionError(); - } - } - } - return (busbarSectionCount >= 1 && feederCount >= 1) - || (branchCount >= 1 && feederCount >= 2); - } - } - - private interface BusNamingStrategy { - - String getName(VoltageLevel voltageLevel, TIntArrayList nodes); - } - - private static class RandomBusNamingStrategy implements BusNamingStrategy { - - @Override - public String getName(VoltageLevel voltageLevel, TIntArrayList nodes) { - return ObjectStore.getUniqueId(); - } - - } - - private static class NumberedBusNamingStrategy implements BusNamingStrategy { - - private final Map counter = new WeakHashMap<>(); - - private final Lock lock = new ReentrantLock(); - - @Override - public String getName(VoltageLevel voltageLevel, TIntArrayList nodes) { - AtomicInteger i; - lock.lock(); - try { - i = counter.get(voltageLevel); - if (i == null) { - i = new AtomicInteger(); - counter.put(voltageLevel, i); - } - } finally { - lock.unlock(); - } - return voltageLevel.getId() + "_" + i.getAndIncrement(); - } - - } - - private static class SimpleBusNamingStrategy implements BusNamingStrategy { - - @Override - public String getName(VoltageLevel voltageLevel, TIntArrayList nodes) { - StringBuilder builder = new StringBuilder(voltageLevel.getId()); - for (int i = 0; i < nodes.size(); i++) { - int node = nodes.get(i); - builder.append("_").append(node); - } - return builder.toString(); - } - - } - - NodeBreakerVoltageLevel(String id, String name, SubstationImpl substation, - float nominalV, float lowVoltageLimit, float highVoltageLimit) { - super(id, name, substation, nominalV, lowVoltageLimit, highVoltageLimit); - states = new StateArray<>(substation.getNetwork().getRef(), new StateFactory() { - @Override - public StateImpl newState() { - return new StateImpl(); - } - }); - } - - @Override - public void invalidateCache() { - states.get().calculatedBusBreakerTopology.invalidateCache(); - states.get().calculatedBusTopology.invalidateCache(); - getNetwork().getConnectedComponentsManager().invalidate(); - } - - private Integer getEdge(String switchId, boolean throwException) { - Integer edge = switches.get(switchId); - if (throwException && edge == null) { - throw new ITeslaException("Switch " + switchId + " not found"); - } - return edge; - } - - @Override - public Iterable getTerminals() { - return FluentIterable.from(graph.getVerticesObj()) - .filter(Predicates.notNull()) - .transform(TERMINAL_DOWNCAST); - } - - @Override - public FluentIterable getConnectables(final Class clazz) { - return FluentIterable.from(getTerminals()) - .transform(Terminal::getConnectable) - .filter(clazz); - } - - @Override - public int getConnectableCount(final Class clazz) { - return getConnectables(clazz).size(); - } - - static ITeslaException createNotSupportedNodeBreakerTopologyException() { - return new ITeslaException("Not supported in a node/breaker topology"); - } - - CalculatedBusBreakerTopology getCalculatedBusBreakerTopology() { - return states.get().calculatedBusBreakerTopology; - } - - CalculatedBusTopology getCalculatedBusTopology() { - return states.get().calculatedBusTopology; - } - - private final NodeBreakerViewExt nodeBreakerView = new NodeBreakerViewExt() { - - @Override - public int getNodeCount() { - return graph.getVertexCount(); - } - - @Override - public NodeBreakerView setNodeCount(int count) { - int oldCount = graph.getVertexCount(); - if (count > oldCount) { - for (int i = oldCount; i < count; i++) { - graph.addVertex(); - } - } - return this; - } - - @Override - public int getNode1(String switchId) { - int edge = getEdge(switchId, true); - return graph.getEdgeVertex1(edge); - } - - @Override - public int getNode2(String switchId) { - int edge = getEdge(switchId, true); - return graph.getEdgeVertex2(edge); - } - - @Override - public SwitchAdder newSwitch() { - return new SwitchAdderImpl(); - } - - @Override - public InternalConnectionAdder newInternalConnection() {return new InternalConnectionAdderImpl(); } - - @Override - public SwitchAdder newBreaker() { - return new SwitchAdderImpl(SwitchKind.BREAKER); - } - - @Override - public SwitchAdder newDisconnector() { - return new SwitchAdderImpl(SwitchKind.DISCONNECTOR); - } - - @Override - public SwitchImpl getSwitch(String switchId) { - Integer edge = getEdge(switchId, false); - if (edge != null) { - return graph.getEdgeObject(edge); - } - return null; - } - - @Override - public Iterable getSwitches() { - return Iterables.filter(graph.getEdgesObject(), Switch.class); // just to upcast and return an unmodifiable iterable - } - - @Override - public int getSwitchCount() { - return graph.getEdgeCount(); - } - - @Override - public BusbarSectionAdder newBusbarSection() { - return new BusbarSectionAdderImpl(NodeBreakerVoltageLevel.this); - } - - @Override - public Iterable getBusbarSections() { - return getConnectables(BusbarSection.class); - } - - @Override - public int getBusbarSectionCount() { - return getConnectableCount(BusbarSection.class); - } - - @Override - public BusbarSection getBusbarSection(String id) { - return getNetwork().getObjectStore().get(id, BusbarSection.class); - } - - }; - - @Override - public NodeBreakerViewExt getNodeBreakerView() { - return nodeBreakerView; - } - - private final BusViewExt busView = new BusViewExt() { - - @Override - public Iterable getBuses() { - return Collections.unmodifiableCollection(states.get().calculatedBusTopology.getBuses()); - } - - @Override - public CalculatedBus getBus(String id) { - return states.get().calculatedBusTopology.getBus(id, false); - } - - }; - - @Override - public BusViewExt getBusView() { - return busView; - } - - private final BusBreakerViewExt busBreakerView = new BusBreakerViewExt() { - - @Override - public Iterable getBuses() { - return Collections.unmodifiableCollection(states.get().calculatedBusBreakerTopology.getBuses()); - } - - @Override - public CalculatedBus getBus(String id) { - return states.get().calculatedBusBreakerTopology.getBus(id, false); - } - - @Override - public BusAdder newBus() { - throw createNotSupportedNodeBreakerTopologyException(); - } - - @Override - public void removeBus(String busId) { - throw createNotSupportedNodeBreakerTopologyException(); - } - - @Override - public void removeAllBuses() { - throw createNotSupportedNodeBreakerTopologyException(); - } - - @Override - public Iterable getSwitches() { - return Iterables.filter(states.get().calculatedBusBreakerTopology.getSwitches(), Switch.class); // just to upcast and return an unmodifiable iterable - } - - @Override - public void removeSwitch(String switchId) { - throw createNotSupportedNodeBreakerTopologyException(); - } - - @Override - public void removeAllSwitches() { - throw createNotSupportedNodeBreakerTopologyException(); - } - - @Override - public Bus getBus1(String switchId) { - return states.get().calculatedBusBreakerTopology.getBus1(switchId, false); - } - - @Override - public Bus getBus2(String switchId) { - return states.get().calculatedBusBreakerTopology.getBus2(switchId, false); - } - - @Override - public Switch getSwitch(String switchId) { - return states.get().calculatedBusBreakerTopology.getSwitch(switchId, false); - } - - @Override - public BusBreakerView.SwitchAdder newSwitch() { - throw createNotSupportedNodeBreakerTopologyException(); - } - - }; - - @Override - public BusBreakerViewExt getBusBreakerView() { - return busBreakerView; - } - - @Override - public TopologyKind getTopologyKind() { - return TopologyKind.NODE_BREAKER; - } - - private void checkTerminal(TerminalExt terminal) { - if (!(terminal instanceof NodeTerminal)) { - throw new ValidationException(terminal.getConnectable(), - "voltage level " + NodeBreakerVoltageLevel.this.id + " has a node/breaker topology" - + ", a node connection should be specified instead of a bus connection"); - } - } - - @Override - public void attach(TerminalExt terminal, boolean test) { - checkTerminal(terminal); - if (test) { - return; - } - int node = ((NodeTerminal) terminal).getNode(); - if (graph.getVertexObject(node) != null) { - throw new ValidationException(terminal.getConnectable(), - "an equipment (" + graph.getVertexObject(node).getConnectable().getId() - + ") is already connected to node " + node + " of voltage level " - + NodeBreakerVoltageLevel.this.id); - } - - // create the link terminal <-> voltage level - terminal.setVoltageLevel(NodeBreakerVoltageLevel.this); - - // create the link terminal <-> graph vertex - graph.setVertexObject(node, (NodeTerminal) terminal); - } - - @Override - public void detach(TerminalExt terminal) { - assert terminal instanceof NodeTerminal; - - int node = ((NodeTerminal) terminal).getNode(); - - assert node >=0 && node < graph.getVertexCount(); - assert graph.getVertexObject(node) == terminal; - - // remove adjacents edges - final TIntArrayList edgesToRemove = new TIntArrayList(); - graph.traverse(node, new Traverser() { - @Override - public TraverseResult traverse(int v1, int e, int v2) { - edgesToRemove.add(e); - return graph.getVertexObject(v2) == null ? TraverseResult.CONTINUE : TraverseResult.TERMINATE; - } - }); - for (int i = 0; i < edgesToRemove.size(); i++) { - int e = edgesToRemove.getQuick(i); - SwitchImpl _switch = graph.getEdgeObject(e); - switches.remove(_switch.getId()); - graph.removeEdge(e); - } - graph.setVertexObject(node, null); - - // remove the link terminal -> voltage level - terminal.setVoltageLevel(null); - } - - @Override - public void clean() { - // TODO remove unused connection nodes - } - - private static boolean isBusbarSection(Terminal t) { - return t != null && t.getConnectable().getType() == ConnectableType.BUSBAR_SECTION; - } - - private static boolean isOpenedDisconnector(Switch s) { - return s.getKind() == SwitchKind.DISCONNECTOR && s.isOpen(); - } - - @Override - public boolean connect(TerminalExt terminal) { - assert terminal instanceof NodeTerminal; - int node = ((NodeTerminal) terminal).getNode(); - // find all paths starting from the current terminal to a busbar section that does not contain an open disconnector - // paths are already sorted - List paths = graph.findAllPaths(node, NodeBreakerVoltageLevel::isBusbarSection, NodeBreakerVoltageLevel::isOpenedDisconnector); - boolean connected = false; - if (paths.size() > 0) { - // the shorted path is the best, close all opened breakers of the path - TIntArrayList shortestPath = paths.get(0); - for (int i = 0; i < shortestPath.size(); i++) { - int e = shortestPath.get(i); - SwitchImpl sw = graph.getEdgeObject(e); - if (sw.getKind() == SwitchKind.BREAKER && sw.isOpen()) { - sw.setOpen(false); - connected = true; - } - } - } - return connected; - } - - @Override - public boolean disconnect(TerminalExt terminal) { - assert terminal instanceof NodeTerminal; - int node = ((NodeTerminal) terminal).getNode(); - // find all paths starting from the current terminal to a busbar section that does not contain an open disconnector - // (because otherwise there is nothing we can do to connected the terminal using only breakers) - List paths = graph.findAllPaths(node, NodeBreakerVoltageLevel::isBusbarSection, NodeBreakerVoltageLevel::isOpenedDisconnector); - if (paths.isEmpty()) { - return false; - } else { - for (TIntArrayList path : paths) { - boolean pathOpen = false; - for (int i = 0; i < path.size(); i++) { - int e = path.get(i); - SwitchImpl sw = graph.getEdgeObject(e); - if (sw.getKind() == SwitchKind.BREAKER) { - if (!sw.isOpen()) { - sw.setOpen(true); - } - // just one open breaker is enough to disconnect the terminal, so we can stop - pathOpen = true; - break; - } - } - if (!pathOpen) { - return false; - } - } - return true; - } - } - - boolean isConnected(TerminalExt terminal) { - assert terminal instanceof NodeTerminal; - int node = ((NodeTerminal) terminal).getNode(); - List paths = graph.findAllPaths(node, NodeBreakerVoltageLevel::isBusbarSection, Switch::isOpen); - return paths.size() > 0; - } - - void traverse(NodeTerminal terminal, VoltageLevel.TopologyTraverser traverser) { - traverse(terminal, traverser, new HashSet<>()); - } - - void traverse(NodeTerminal terminal, VoltageLevel.TopologyTraverser traverser, Set traversedVoltageLevelsIds) { - Objects.requireNonNull(terminal); - Objects.requireNonNull(traverser); - Objects.requireNonNull(traversedVoltageLevelsIds); - - if (traversedVoltageLevelsIds.contains(terminal.getVoltageLevel().getId())) { - return; - } - traversedVoltageLevelsIds.add(terminal.getVoltageLevel().getId()); - - if (traverser.traverse(terminal, true)) { - int node = terminal.getNode(); - List nextTerminals = new ArrayList<>(); - - addNextTerminals(terminal, nextTerminals); - - graph.traverse(node, (v1, e, v2) -> { - SwitchImpl aSwitch = graph.getEdgeObject(e); - NodeTerminal otherTerminal = graph.getVertexObject(v2); - if (traverser.traverse(aSwitch)) { - if (otherTerminal == null) { - return TraverseResult.CONTINUE; - } else if ((otherTerminal != null && traverser.traverse(otherTerminal, true))) { - addNextTerminals(otherTerminal, nextTerminals); - addNextTerminals(otherTerminal, nextTerminals); - return TraverseResult.CONTINUE; - } else { - return TraverseResult.TERMINATE; - } - } else { - return TraverseResult.TERMINATE; - } - }); - - for (TerminalExt nextTerminal : nextTerminals) { - nextTerminal.traverse(traverser, traversedVoltageLevelsIds); - } - } - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - states.push(number, new StateFactory() { - @Override - public StateImpl newState() { - return new StateImpl(); - } - }); - } - - @Override - public void reduceStateArraySize(int number) { - states.pop(number); - } - - @Override - public void deleteStateArrayElement(int index) { - states.delete(index); - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - states.allocate(indexes, new StateFactory() { - @Override - public StateImpl newState() { - return new StateImpl(); - } - }); - } - - @Override - public void printTopology() { - printTopology(System.out, null); - } - - @Override - public void printTopology(PrintStream out, ShortIdDictionary dict) { - out.println("-------------------------------------------------------------"); - out.println("Topology of " + NodeBreakerVoltageLevel.this.id); - graph.print(out, terminal -> terminal != null ? terminal.getConnectable().toString() : null, null); - } - - @Override - public void exportTopology(String filename) throws IOException { - try (OutputStream outputStream = new FileOutputStream(filename)) { - exportTopology(outputStream); - } - } - - private static final double GOLDEN_RATIO_CONJUGATE = 0.618033988749895; - - private static String[] generateColorScale(int n) { - String[] colors = new String[n]; - Random random = new Random(); - for (int i = 0; i < n; i++) { - double h = random.nextDouble(); - h += GOLDEN_RATIO_CONJUGATE; - h %= 1; - long[] rgb = hsvToRgb(h, 0.5, 0.95); - String hex = String.format("#%02x%02x%02x", rgb[0], rgb[1], rgb[2]).toUpperCase(); - colors[i] = hex; - } - return colors; - } - - private static long[] hsvToRgb(double h, double s, double v) { - int h_i = (int) Math.floor(h * 6); - double f = h * 6 - h_i; - double p = v * (1 - s); - double q = v * (1 - f * s); - double t = v * (1 - (1 - f) * s); - double r, g, b; - switch (h_i) { - case 0: - r = v; - g = t; - b = p; - break; - case 1: - r = q; - g = v; - b = p; - break; - case 2: - r = p; - g = v; - b = t; - break; - case 3: - r = p; - g = q; - b = v; - break; - case 4: - r = t; - g = p; - b = v; - break; - case 5: - r = v; - g = p; - b = q; - break; - default: - throw new AssertionError(); - } - return new long[] { Math.round(r * 256), Math.round(g * 256), Math.round(b * 256) }; - } - - public void exportTopology(OutputStream os) throws IOException { - Graph g = new Graph().id("\"" + NodeBreakerVoltageLevel.this.id + "\""); - Map intToNode = new HashMap<>(); - Multimap busToNodes = ArrayListMultimap.create(); - for (int n = 0; n < graph.getVertexCount(); n++) { - Node node = new Node().id(Integer.toString(n)); - intToNode.put(n, node); - Bus bus = getCalculatedBusBreakerTopology().getBus(n); - if (bus != null) { - busToNodes.put(bus.getId(), n); - } else { - TerminalExt terminal = graph.getVertexObject(n); - if (terminal != null) { - ConnectableImpl connectable = terminal.getConnectable(); - String label = n + "\\n" + connectable.getType().toString() + "\\n" + connectable.getId(); - node.attr("label", label); - g.node(node); - } - } - } - String[] colors = generateColorScale(busToNodes.asMap().keySet().size()); - int i = 0; - for (String key : busToNodes.asMap().keySet()) { - Graph newBus = new Graph().id("\"" + key + "\""); - newBus.attr("label", key); - for (int nodeInt : busToNodes.get(key)) { - Node node = intToNode.get(nodeInt); - TerminalExt terminal = graph.getVertexObject(nodeInt); - if (terminal != null) { - ConnectableImpl connectable = terminal.getConnectable(); - String label = nodeInt + "\\n" + connectable.getType().toString() + "\\n" + connectable.getId(); - node.attr("label", label); - } - node.attr("style", "filled").attr("color", colors[i]); - newBus.node(node); - } - g.subGraph(newBus); - i++; - } - -// writer.append("graph \"").append(NodeBreakerVoltageLevel.this.id).append("\" {\n"); -// for (int n = 0; n < graph.getVertexCount(); n++) { -// TerminalExt terminal = graph.getVertexObject(n); -// if (terminal != null) { -// ConnectableImpl connectable = terminal.getConnectable(); -// String label = n + "\\n" + connectable.getType().toString() + "\\n" + connectable.getId(); -// writer.append(" ").append(Integer.toString(n)) -// .append(" [label=\"").append(label).append("\"]\n"); -// } -// } - boolean drawSwitchId = true; - for (int e = 0; e < graph.getEdgeCount(); e++) { - Edge edge = new Edge(intToNode.get(graph.getEdgeVertex1(e)), intToNode.get(graph.getEdgeVertex2(e))).id(Integer.toString(e)); - - SwitchImpl _switch = graph.getEdgeObject(e); - if (_switch != null) { - if (drawSwitchId) { - edge.attr("label", _switch.getKind().toString() + "\n" + _switch.getId()).attr("fontsize", "10"); - } - edge.attr("style", _switch.isOpen() ? "dotted" : "solid"); - } - g.edge(edge); - } - g.writeTo(os); -// for (int e = 0; e < graph.getEdgeCount(); e++) { -// writer.append(" ").append(Integer.toString(graph.getEdgeVertex1(e))) -// .append(" -- ").append(Integer.toString(graph.getEdgeVertex2(e))); -// SwitchImpl _switch = graph.getEdgeObject(e); -// if (_switch != null) { -// writer.append(" ["); -// if (drawSwitchId) { -// writer.append("label=\"").append(_switch.getId()) -// .append("\", fontsize=10"); -// } -// writer.append("style=\"").append(_switch.isOpen() ? "dotted" : "solid").append("\""); -// } -// writer.append("]\n"); -// } -// writer.append("}\n"); - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeTerminal.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeTerminal.java deleted file mode 100644 index 5f94ab0a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/NodeTerminal.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; -import gnu.trove.list.array.TIntArrayList; - -import java.util.ArrayList; -import java.util.Set; - -/** - * A terminal connected to a node breaker topology. - * - * @author Geoffroy Jamgotchian - */ -class NodeTerminal extends AbstractTerminal { - - private final int node; - - // attributes depending on the state - - protected final TFloatArrayList v; - - protected final TFloatArrayList angle; - - protected final TIntArrayList connectedComponentNumber; - - private final NodeBreakerView nodeBreakerView = new NodeBreakerView() { - - @Override - public int getNode() { - return node; - } - }; - - private final BusBreakerViewExt busBreakerView = new BusBreakerViewExt() { - - @Override - public BusExt getBus() { - return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusBreakerTopology().getBus(node); - } - - @Override - public BusExt getConnectableBus() { - ArrayList nodes = new ArrayList<>(); - nodes.add(node); - return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusBreakerTopology().getConnectableBus(node); - } - - @Override - public void setConnectableBus(String busId) { - throw NodeBreakerVoltageLevel.createNotSupportedNodeBreakerTopologyException(); - } - - }; - - private final BusViewExt busView = new BusViewExt() { - - @Override - public BusExt getBus() { - return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusTopology().getBus(node); - } - - @Override - public BusExt getConnectableBus() { - return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusTopology().getConnectableBus(node); - } - - }; - - NodeTerminal(Ref network, int node) { - super(network); - this.node = node; - int stateArraySize = network.get().getStateManager().getStateArraySize(); - v = new TFloatArrayList(stateArraySize); - angle = new TFloatArrayList(stateArraySize); - connectedComponentNumber = new TIntArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - v.add(Float.NaN); - angle.add(Float.NaN); - connectedComponentNumber.add(0); - } - } - - public int getNode() { - return node; - } - - @Override - protected float getV() { - return v.get(network.get().getStateIndex()); - } - - void setV(float v) { - if (v <= 0) { - throw new ValidationException(connectable, "voltage cannot be <= 0"); - } - this.v.set(network.get().getStateIndex(), v); - } - - float getAngle() { - return angle.get(network.get().getStateIndex()); - } - - void setAngle(float angle) { - this.angle.set(network.get().getStateIndex(), angle); - } - - int getConnectedComponentNumber() { - return connectedComponentNumber.get(network.get().getStateIndex()); - } - - void setConnectedComponentNumber(int connectedComponentNumber) { - this.connectedComponentNumber.set(network.get().getStateIndex(), connectedComponentNumber); - } - - @Override - public NodeBreakerView getNodeBreakerView() { - return nodeBreakerView; - } - - @Override - public BusBreakerViewExt getBusBreakerView() { - return busBreakerView; - } - - @Override - public BusViewExt getBusView() { - return busView; - } - - @Override - public boolean isConnected() { - return ((NodeBreakerVoltageLevel) voltageLevel).isConnected(this); - } - - @Override - public void traverse(VoltageLevel.TopologyTraverser traverser, Set traversedVoltageLevelsIds) { - ((NodeBreakerVoltageLevel) voltageLevel).traverse(this, traverser, traversedVoltageLevelsIds); - } - - @Override - public void traverse(VoltageLevel.TopologyTraverser traverser) { - ((NodeBreakerVoltageLevel) voltageLevel).traverse(this, traverser); - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - v.ensureCapacity(v.size() + number); - angle.ensureCapacity(angle.size() + number); - connectedComponentNumber.ensureCapacity(connectedComponentNumber.size() + number); - for (int i = 0; i < number; i++) { - v.add(v.get(sourceIndex)); - angle.add(angle.get(sourceIndex)); - connectedComponentNumber.add(connectedComponentNumber.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - v.remove(v.size() - number, number); - angle.remove(angle.size() - number, number); - connectedComponentNumber.remove(connectedComponentNumber.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - v.set(index, v.get(sourceIndex)); - angle.set(index, angle.get(sourceIndex)); - connectedComponentNumber.set(index, connectedComponentNumber.get(sourceIndex)); - } - } - - @Override - public String toString() { - return getClass().getSimpleName() + "[" + node + "]"; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ObjectStore.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ObjectStore.java deleted file mode 100644 index 7a74866b..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ObjectStore.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.Identifiable; -import java.util.*; -import java.util.stream.Collectors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ObjectStore { - - private static final Logger LOGGER = LoggerFactory.getLogger(ObjectStore.class); - - private final Map> objectsById = new HashMap<>(); - - private final Map, Set>> objectsByClass = new HashMap<>(); - - static void checkId(String id) { - if (id == null || id.isEmpty()) { - throw new ITeslaException("Invalid id '" + id + "'"); - } - } - - static String getUniqueId() { - return UUID.randomUUID().toString(); - } - - String getUniqueId(String baseId) { - String checkedBaseId; - if (baseId != null && baseId.length() > 0) { - if (!objectsById.containsKey(baseId)) { - return baseId; - } - checkedBaseId = baseId; - } else { - checkedBaseId = "autoid"; - } - String uniqueId; - int i = 0; - do { - uniqueId = checkedBaseId + '#' + Integer.toString(i++); - } while (i < Integer.MAX_VALUE && objectsById.containsKey(uniqueId)); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Object '{}' is not unique, rename to '{}'", baseId, uniqueId); - } - return uniqueId; - } - - void checkAndAdd(Identifiable obj) { - checkId(obj.getId()); - if (objectsById.containsKey(obj.getId())) { - throw new ITeslaException("Object (" + obj.getClass().getName() - + ") '" + obj.getId() + "' already exists"); - } - objectsById.put(obj.getId(), obj); - Set> all = objectsByClass.get(obj.getClass()); - if (all == null) { - all = new LinkedHashSet<>(); - objectsByClass.put(obj.getClass(), all); - } - all.add(obj); - } - - Identifiable get(String id) { - checkId(id); - return objectsById.get(id); - } - - T get(String id, Class clazz) { - checkId(id); - Identifiable obj = objectsById.get(id); - if (obj != null && clazz.isAssignableFrom(obj.getClass())) { - return (T) obj; - } else { - return null; - } - } - - Collection> getAll() { - return objectsById.values(); - } - - Set getAll(Class clazz) { - Set> all = objectsByClass.get(clazz); - if (all == null) { - return Collections.emptySet(); - } - return (Set) all; - } - - boolean contains(String id) { - checkId(id); - return objectsById.containsKey(id); - } - - void remove(Identifiable obj) { - checkId(obj.getId()); - Identifiable old = objectsById.remove(obj.getId()); - if (old == null || old != obj) { - throw new ITeslaException("Object (" + obj.getClass().getName() - + ") '" + obj.getId() + "' not found"); - } - Set> all = objectsByClass.get(obj.getClass()); - if (all != null) { - all.remove(obj); - } - } - - void clean() { - objectsById.clear(); - objectsByClass.clear(); - } - - /** - * Compute intersection between this object store and another one. - * @param other the other object store - * @return list of objects id that exist in both object store organized by class. - */ - Multimap, String> intersection(ObjectStore other) { - Multimap, String> intersection = HashMultimap.create(); - for (Map.Entry, Set>> entry : other.objectsByClass.entrySet()) { - Class clazz = entry.getKey(); - Set> objects = entry.getValue(); - for (Identifiable obj : objects) { - if (objectsById.containsKey(obj.getId())) { - intersection.put(clazz, obj.getId()); - } - } - } - return intersection; - } - - /** - * Merge an other object store into this one. At the end of the call the - * other object store is empty. - * @param other the object store to merge - */ - void merge(ObjectStore other) { - for (Identifiable obj : other.objectsById.values()) { - checkAndAdd(obj); - } - other.clean(); - } - - void printForDebug() { - for (Map.Entry> entry : objectsById.entrySet()) { - System.out.println(entry.getKey() + " " + System.identityHashCode(entry.getValue())); - } - for (Map.Entry, Set>> entry : objectsByClass.entrySet()) { - System.out.println(entry.getKey() + " " + entry.getValue().stream().map(System::identityHashCode).collect(Collectors.toList())); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerAdderImpl.java deleted file mode 100644 index be7e1467..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerAdderImpl.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.PhaseTapChanger; -import eu.itesla_project.iidm.network.PhaseTapChangerAdder; -import eu.itesla_project.iidm.network.Terminal; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -class PhaseTapChangerAdderImpl implements PhaseTapChangerAdder { - - private final TwoWindingsTransformerImpl transformer; - - private int lowTapPosition = 0; - - private Integer tapPosition; - - private final List steps = new ArrayList<>(); - - private PhaseTapChanger.RegulationMode regulationMode = PhaseTapChanger.RegulationMode.FIXED_TAP; - - private float regulationValue = Float.NaN; - - private boolean regulating = false; - - private TerminalExt regulationTerminal; - - class StepAdderImpl implements StepAdder { - - private float alpha = Float.NaN; - - private float rho = Float.NaN; - - private float r = Float.NaN; - - private float x = Float.NaN; - - private float g = Float.NaN; - - private float b = Float.NaN; - - @Override - public StepAdder setAlpha(float alpha) { - this.alpha = alpha; - return this; - } - - @Override - public StepAdder setRho(float rho) { - this.rho = rho; - return this; - } - - @Override - public StepAdder setR(float r) { - this.r = r; - return this; - } - - @Override - public StepAdder setX(float x) { - this.x = x; - return this; - } - - @Override - public StepAdder setG(float g) { - this.g = g; - return this; - } - - @Override - public StepAdder setB(float b) { - this.b = b; - return this; - } - - @Override - public PhaseTapChangerAdder endStep() { - if (Float.isNaN(alpha)) { - throw new ValidationException(transformer, "step alpha is not set"); - } - if (Float.isNaN(rho)) { - throw new ValidationException(transformer, "step rho is not set"); - } - if (Float.isNaN(r)) { - throw new ValidationException(transformer, "step r is not set"); - } - if (Float.isNaN(x)) { - throw new ValidationException(transformer, "step x is not set"); - } - if (Float.isNaN(g)) { - throw new ValidationException(transformer, "step g is not set"); - } - if (Float.isNaN(b)) { - throw new ValidationException(transformer, "step b is not set"); - } - PhaseTapChangerStepImpl step = new PhaseTapChangerStepImpl(alpha, rho, r, x, g, b); - steps.add(step); - return PhaseTapChangerAdderImpl.this; - } - - } - - PhaseTapChangerAdderImpl(TwoWindingsTransformerImpl transformer) { - this.transformer = transformer; - } - - NetworkImpl getNetwork() { - return transformer.getNetwork(); - } - - @Override - public PhaseTapChangerAdder setLowTapPosition(int lowTapPosition) { - this.lowTapPosition = lowTapPosition; - return this; - } - - @Override - public PhaseTapChangerAdder setTapPosition(int tapPosition) { - this.tapPosition = tapPosition; - return this; - } - - @Override - public PhaseTapChangerAdder setRegulationMode(PhaseTapChanger.RegulationMode regulationMode) { - this.regulationMode = regulationMode; - return this; - } - - @Override - public PhaseTapChangerAdder setRegulationValue(float regulationValue) { - this.regulationValue = regulationValue; - return this; - } - - @Override - public PhaseTapChangerAdder setRegulating(boolean regulating) { - this.regulating = regulating; - return this; - } - - @Override - public PhaseTapChangerAdder setRegulationTerminal(Terminal regulationTerminal) { - this.regulationTerminal = (TerminalExt) regulationTerminal; - return this; - } - - @Override - public StepAdder beginStep() { - return new StepAdderImpl(); - } - - @Override - public PhaseTapChanger add() { - if (tapPosition == null) { - throw new ValidationException(transformer, "tap position is not set"); - } - if (steps.isEmpty()) { - throw new ValidationException(transformer, "a phase tap changer shall have at least one step"); - } - int highTapPosition = lowTapPosition + steps.size() - 1; - if (tapPosition < lowTapPosition || tapPosition > highTapPosition) { - throw new ValidationException(transformer, "incorrect tap position " - + tapPosition + " [" + lowTapPosition + ", " - + highTapPosition + "]"); - } - ValidationUtil.checkPhaseTapChangerRegulation(transformer, regulationMode, regulationValue, regulating, regulationTerminal, getNetwork()); - PhaseTapChangerImpl tapChanger - = new PhaseTapChangerImpl(transformer, lowTapPosition, steps, regulationTerminal, tapPosition, regulating, regulationMode, regulationValue); - transformer.setPhaseTapChanger(tapChanger); - return tapChanger; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerImpl.java deleted file mode 100644 index 52a235ba..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.PhaseTapChanger; -import eu.itesla_project.iidm.network.Terminal; -import gnu.trove.list.array.TFloatArrayList; - -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -class PhaseTapChangerImpl extends TapChangerImpl - implements PhaseTapChanger { - - private RegulationMode regulationMode; - - // attributes depending on the state - - private final TFloatArrayList regulationValue; - - PhaseTapChangerImpl(TwoWindingsTransformerImpl parent, int lowTapPosition, - List steps, TerminalExt regulationTerminal, - int tapPosition, boolean regulating, RegulationMode regulationMode, float regulationValue) { - super(parent.getNetwork().getRef(), parent, lowTapPosition, steps, regulationTerminal, tapPosition, regulating); - int stateArraySize = network.get().getStateManager().getStateArraySize(); - this.regulationMode = regulationMode; - this.regulationValue = new TFloatArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - this.regulationValue.add(regulationValue); - } - } - - @Override - protected NetworkImpl getNetwork() { - return parent.getNetwork(); - } - - @Override - public RegulationMode getRegulationMode() { - return regulationMode; - } - - @Override - public PhaseTapChangerImpl setRegulationMode(RegulationMode regulationMode) { - ValidationUtil.checkPhaseTapChangerRegulation(parent, regulationMode, getRegulationValue(), isRegulating(), getRegulationTerminal(), getNetwork()); - this.regulationMode = regulationMode; - return this; - } - - @Override - public float getRegulationValue() { - return regulationValue.get(network.get().getStateIndex()); - } - - @Override - public PhaseTapChangerImpl setRegulationValue(float regulationValue) { - ValidationUtil.checkPhaseTapChangerRegulation(parent, regulationMode, regulationValue, isRegulating(), getRegulationTerminal(), getNetwork()); - this.regulationValue.set(network.get().getStateIndex(), regulationValue); - return this; - } - - @Override - public PhaseTapChangerImpl setRegulationTerminal(Terminal regulationTerminal) { - ValidationUtil.checkPhaseTapChangerRegulation(parent, regulationMode, getRegulationValue(), isRegulating(), regulationTerminal, getNetwork()); - return super.setRegulationTerminal(regulationTerminal); - } - - @Override - public void remove() { - parent.setPhaseTapChanger(null); - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - regulationValue.ensureCapacity(regulationValue.size() + number); - for (int i = 0; i < number; i++) { - regulationValue.add(regulationValue.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - regulationValue.remove(regulationValue.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - regulationValue.set(index, regulationValue.get(sourceIndex)); - } - } - - @Override - protected String getTapChangerAttribute() { - return "phaseTapChanger"; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerStepImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerStepImpl.java deleted file mode 100644 index fc3d5064..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/PhaseTapChangerStepImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.PhaseTapChangerStep; - -/** - * - * @author Geoffroy Jamgotchian - */ -class PhaseTapChangerStepImpl extends TapChangerStepImpl - implements PhaseTapChangerStep { - - private float alpha; - - PhaseTapChangerStepImpl(float alpha, float rho, float r, float x, float g, float b) { - super(rho, r, x, g, b); - this.alpha = alpha; - } - - @Override - public float getAlpha() { - return alpha; - } - - @Override - public PhaseTapChangerStep setAlpha(float alpha) { - this.alpha = alpha; - return this; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerAdderImpl.java deleted file mode 100644 index adf119de..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerAdderImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.RatioTapChanger; -import eu.itesla_project.iidm.network.RatioTapChangerAdder; -import eu.itesla_project.iidm.network.Terminal; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -class RatioTapChangerAdderImpl implements RatioTapChangerAdder { - - private final RatioTapChangerParent parent; - - private int lowTapPosition = 0; - - private Integer tapPosition; - - private final List steps = new ArrayList<>(); - - private boolean loadTapChangingCapabilities = false; - - private boolean regulating = false; - - private float targetV = Float.NaN; - - private TerminalExt regulationTerminal; - - class StepAdderImpl implements StepAdder { - - private float rho = Float.NaN; - - private float r = Float.NaN; - - private float x = Float.NaN; - - private float g = Float.NaN; - - private float b = Float.NaN; - - @Override - public StepAdder setRho(float rho) { - this.rho = rho; - return this; - } - - @Override - public StepAdder setR(float r) { - this.r = r; - return this; - } - - @Override - public StepAdder setX(float x) { - this.x = x; - return this; - } - - @Override - public StepAdder setG(float g) { - this.g = g; - return this; - } - - @Override - public StepAdder setB(float b) { - this.b = b; - return this; - } - - @Override - public RatioTapChangerAdder endStep() { - if (Float.isNaN(rho)) { - throw new ValidationException(parent, "step rho is not set"); - } - if (Float.isNaN(r)) { - throw new ValidationException(parent, "step r is not set"); - } - if (Float.isNaN(x)) { - throw new ValidationException(parent, "step x is not set"); - } - if (Float.isNaN(g)) { - throw new ValidationException(parent, "step g is not set"); - } - if (Float.isNaN(b)) { - throw new ValidationException(parent, "step b is not set"); - } - RatioTapChangerStepImpl step = new RatioTapChangerStepImpl(rho, r, x, g, b); - steps.add(step); - return RatioTapChangerAdderImpl.this; - } - - } - - RatioTapChangerAdderImpl(RatioTapChangerParent parent) { - this.parent = parent; - } - - NetworkImpl getNetwork() { - return parent.getNetwork(); - } - - @Override - public RatioTapChangerAdder setLowTapPosition(int lowTapPosition) { - this.lowTapPosition = lowTapPosition; - return this; - } - - @Override - public RatioTapChangerAdder setTapPosition(int tapPosition) { - this.tapPosition = tapPosition; - return this; - } - - @Override - public RatioTapChangerAdder setLoadTapChangingCapabilities(boolean loadTapChangingCapabilities) { - this.loadTapChangingCapabilities = loadTapChangingCapabilities; - return this; - } - - @Override - public RatioTapChangerAdder setRegulating(boolean regulating) { - this.regulating = regulating; - return this; - } - - @Override - public RatioTapChangerAdder setTargetV(float targetV) { - this.targetV = targetV; - return this; - } - - @Override - public RatioTapChangerAdder setRegulationTerminal(Terminal regulationTerminal) { - this.regulationTerminal = (TerminalExt) regulationTerminal; - return this; - } - - @Override - public StepAdder beginStep() { - return new StepAdderImpl(); - } - - @Override - public RatioTapChanger add() { - if (tapPosition == null) { - throw new ValidationException(parent, "tap position is not set"); - } - if (steps.isEmpty()) { - throw new ValidationException(parent, "ratio tap changer should have at least one step"); - } - int highTapPosition = lowTapPosition + steps.size() - 1; - if (tapPosition < lowTapPosition || tapPosition > highTapPosition) { - throw new ValidationException(parent, "incorrect tap position " - + tapPosition + " [" + lowTapPosition + ", " - + highTapPosition + "]"); - } - ValidationUtil.checkRatioTapChangerRegulation(parent, loadTapChangingCapabilities, regulating, regulationTerminal, targetV, getNetwork()); - RatioTapChangerImpl tapChanger - = new RatioTapChangerImpl(parent, lowTapPosition, steps, regulationTerminal, loadTapChangingCapabilities, - tapPosition, regulating, targetV); - parent.setRatioTapChanger(tapChanger); - return tapChanger; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerImpl.java deleted file mode 100644 index fe293075..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerImpl.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.RatioTapChanger; -import eu.itesla_project.iidm.network.Terminal; -import gnu.trove.list.array.TFloatArrayList; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -class RatioTapChangerImpl extends TapChangerImpl implements RatioTapChanger { - - private boolean loadTapChangingCapabilities; - - // attributes depending on the state - - private final TFloatArrayList targetV; - - RatioTapChangerImpl(RatioTapChangerParent parent, int lowTapPosition, - List steps, TerminalExt regulationTerminal, boolean loadTapChangingCapabilities, - int tapPosition, boolean regulating, float targetV) { - super(parent.getNetwork().getRef(), parent, lowTapPosition, steps, regulationTerminal, tapPosition, regulating); - this.loadTapChangingCapabilities = loadTapChangingCapabilities; - int stateArraySize = network.get().getStateManager().getStateArraySize(); - this.targetV = new TFloatArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - this.targetV.add(targetV); - } - } - - @Override - protected NetworkImpl getNetwork() { - return parent.getNetwork(); - } - - @Override - public RatioTapChangerImpl setRegulating(boolean regulating) { - ValidationUtil.checkRatioTapChangerRegulation(parent, loadTapChangingCapabilities, regulating, regulationTerminal, getTargetV(), getNetwork()); - return super.setRegulating(regulating); - } - - @Override - public boolean hasLoadTapChangingCapabilities() { - return loadTapChangingCapabilities; - } - - @Override - public float getTargetV() { - return targetV.get(network.get().getStateIndex()); - } - - @Override - public RatioTapChangerImpl setTargetV(float targetV) { - ValidationUtil.checkRatioTapChangerRegulation(parent, loadTapChangingCapabilities, isRegulating(), regulationTerminal, targetV, getNetwork()); - this.targetV.set(network.get().getStateIndex(), targetV); - return this; - } - - @Override - public RatioTapChangerImpl setRegulationTerminal(Terminal regulationTerminal) { - ValidationUtil.checkRatioTapChangerRegulation(parent, loadTapChangingCapabilities, isRegulating(), regulationTerminal, getTargetV(), getNetwork()); - return super.setRegulationTerminal(regulationTerminal); - } - - @Override - public void remove() { - parent.setRatioTapChanger(null); - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - targetV.ensureCapacity(targetV.size() + number); - for (int i = 0; i < number; i++) { - targetV.add(targetV.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - targetV.remove(targetV.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - targetV.set(index, targetV.get(sourceIndex)); - } - } - - @Override - protected String getTapChangerAttribute() { - return parent.getTapChangerAttribute(); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerParent.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerParent.java deleted file mode 100644 index 8b80b693..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerParent.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface RatioTapChangerParent extends TapChangerParent { - - String getTapChangerAttribute(); - - void setRatioTapChanger(RatioTapChangerImpl ratioTapChanger); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerStepImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerStepImpl.java deleted file mode 100644 index 5f1de8dc..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/RatioTapChangerStepImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.RatioTapChangerStep; - -/** - * - * @author Geoffroy Jamgotchian - */ -class RatioTapChangerStepImpl extends TapChangerStepImpl implements RatioTapChangerStep { - - RatioTapChangerStepImpl(float rho, float r, float x, float g, float b) { - super(rho, r, x, g, b); - } - -} \ No newline at end of file diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveAdderImpl.java deleted file mode 100644 index 09dc5bf5..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveAdderImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ReactiveCapabilityCurve; -import eu.itesla_project.iidm.network.ReactiveCapabilityCurveAdder; -import eu.itesla_project.iidm.network.impl.ReactiveCapabilityCurveImpl.PointImpl; -import java.util.TreeMap; - -/** - * - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class ReactiveCapabilityCurveAdderImpl implements ReactiveCapabilityCurveAdder { - - private final OWNER owner; - - private final TreeMap points = new TreeMap<>(); - - private class PointAdderImpl implements PointAdder { - - private float p = Float.NaN; - - private float minQ = Float.NaN; - - private float maxQ = Float.NaN; - - @Override - public PointAdder setP(float p) { - this.p = p; - return this; - } - - @Override - public PointAdder setMinQ(float minQ) { - this.minQ = minQ; - return this; - } - - @Override - public PointAdder setMaxQ(float maxQ) { - this.maxQ = maxQ; - return this; - } - - @Override - public ReactiveCapabilityCurveAdder endPoint() { - if (Float.isNaN(p)) { - throw new ValidationException(owner, "P is not set"); - } - if (Float.isNaN(minQ)) { - throw new ValidationException(owner, "min Q is not set"); - } - if (Float.isNaN(maxQ)) { - throw new ValidationException(owner, "max Q is not set"); - } - if (points.containsKey(p)) { - throw new ValidationException(owner, - "a point already exists for active power " + p); - } - points.put(p, new PointImpl(p, minQ, maxQ)); - return ReactiveCapabilityCurveAdderImpl.this; - } - - } - - ReactiveCapabilityCurveAdderImpl(OWNER owner) { - this.owner = owner; - } - - @Override - public PointAdderImpl beginPoint() { - return new PointAdderImpl(); - } - - @Override - public ReactiveCapabilityCurve add() { - if (points.size() < 2) { - throw new ValidationException(owner, "a reactive capability curve should have at least two points"); - } - ReactiveCapabilityCurveImpl curve = new ReactiveCapabilityCurveImpl(points); - owner.setReactiveLimits(curve); - return curve; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImpl.java deleted file mode 100644 index 31337995..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ReactiveCapabilityCurve; -import eu.itesla_project.iidm.network.ReactiveLimitsKind; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.TreeMap; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ReactiveCapabilityCurveImpl implements ReactiveCapabilityCurve { - - static class PointImpl implements Point { - - private float p; - - private float minQ; - - private float maxQ; - - PointImpl(float p, float minQ, float maxQ) { - this.p = p; - this.minQ = minQ; - this.maxQ = maxQ; - } - - @Override - public float getP() { - return p; - } - - @Override - public float getMinQ() { - return minQ; - } - - @Override - public float getMaxQ() { - return maxQ; - } - - } - - private final TreeMap points; - - ReactiveCapabilityCurveImpl(TreeMap points) { - assert points.size() >= 2; - this.points = points; - } - - @Override - public Collection getPoints() { - return Collections.unmodifiableCollection(points.values()); - } - - @Override - public int getPointCount() { - return points.size(); - } - - @Override - public float getMinP() { - return points.firstKey(); - } - - @Override - public float getMaxP() { - return points.lastKey(); - } - - @Override - public ReactiveLimitsKind getKind() { - return ReactiveLimitsKind.CURVE; - } - - @Override - public float getMinQ(float p) { - assert points.size() >= 2; - - Point pt = points.get(p); - if (pt != null) { - return pt.getMinQ(); - } else { - Map.Entry e1 = points.floorEntry(p); - Map.Entry e2 = points.ceilingEntry(p); - if (e1 == null && e2 != null) { - return e2.getValue().getMinQ(); - } else if (e1 != null && e2 == null) { - return e1.getValue().getMinQ(); - } else if (e1 != null && e2 != null) { - Point p1 = e1.getValue(); - Point p2 = e2.getValue(); - return p1.getMinQ() + (p2.getMinQ() - p1.getMinQ()) / (p2.getP() - p1.getP()) * (p - p1.getP()); - } else { - throw new AssertionError(); - } - } - } - - @Override - public float getMaxQ(float p) { - assert points.size() >= 2; - - Point pt = points.get(p); - if (pt != null) { - return pt.getMaxQ(); - } else { - Map.Entry e1 = points.floorEntry(p); - Map.Entry e2 = points.ceilingEntry(p); - if (e1 == null && e2 != null) { - return e2.getValue().getMaxQ(); - } else if (e1 != null && e2 == null) { - return e1.getValue().getMaxQ(); - } else if (e1 != null && e2 != null) { - Point p1 = e1.getValue(); - Point p2 = e2.getValue(); - return p1.getMaxQ() + (p2.getMaxQ() - p1.getMaxQ()) / (p2.getP() - p1.getP()) * (p - p1.getP()); - } else { - throw new AssertionError(); - } - } - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveLimitsOwner.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveLimitsOwner.java deleted file mode 100644 index a4194dbf..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ReactiveLimitsOwner.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ReactiveLimits; - -/** - * @author Mathieu Bague - */ -interface ReactiveLimitsOwner { - - void setReactiveLimits(ReactiveLimits reactiveLimits); -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorAdderImpl.java deleted file mode 100644 index 4c6e4f11..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorAdderImpl.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ShuntCompensatorAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ShuntCompensatorAdderImpl extends SingleTerminalConnectableAdderImpl implements ShuntCompensatorAdder { - - private final VoltageLevelExt voltageLevel; - - private float bPerSection; - - private int maximumSectionCount; - - private int currentSectionCount; - - ShuntCompensatorAdderImpl(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Shunt compensator"; - } - - @Override - public ShuntCompensatorAdder setbPerSection(float bPerSection) { - this.bPerSection = bPerSection; - return this; - } - - @Override - public ShuntCompensatorAdder setMaximumSectionCount(int maximumSectionCount) { - this.maximumSectionCount = maximumSectionCount; - return this; - } - - @Override - public ShuntCompensatorAdder setCurrentSectionCount(int currentSectionCount) { - this.currentSectionCount = currentSectionCount; - return this; - } - - @Override - public ShuntCompensatorImpl add() { - String id = checkAndGetUniqueId(); - TerminalExt terminal = checkAndGetTerminal(id); - ValidationUtil.checkbPerSection(this, bPerSection); - ValidationUtil.checkSections(this, currentSectionCount, maximumSectionCount); - ShuntCompensatorImpl shunt - = new ShuntCompensatorImpl(getNetwork().getRef(), - id, getName(), bPerSection, maximumSectionCount, - currentSectionCount); - shunt.addTerminal(terminal); - voltageLevel.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(shunt); - getNetwork().getListeners().notifyCreation(shunt); - return shunt; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorImpl.java deleted file mode 100644 index 4bbdf63e..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ShuntCompensatorImpl.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.ShuntCompensator; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TIntArrayList; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ShuntCompensatorImpl extends ConnectableImpl implements ShuntCompensator { - - private final Ref network; - - /* susceptance per section */ - private float bPerSection; - - /* the maximum number of section */ - private int maximumSectionCount; - - // attributes depending on the state - - /* the current number of section switched on */ - private final TIntArrayList currentSectionCount; - - ShuntCompensatorImpl(Ref network, - String id, String name, float bPerSection, int maximumSectionCount, - int currentSectionCount) { - super(id, name); - this.network = network; - this.bPerSection = bPerSection; - this.maximumSectionCount = maximumSectionCount; - int stateArraySize = network.get().getStateManager().getStateArraySize(); - this.currentSectionCount = new TIntArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - this.currentSectionCount.add(currentSectionCount); - } - } - - @Override - public ConnectableType getType() { - return ConnectableType.SHUNT_COMPENSATOR; - } - - @Override - public TerminalExt getTerminal() { - return terminals.get(0); - } - - @Override - public float getbPerSection() { - return bPerSection; - } - - @Override - public ShuntCompensatorImpl setbPerSection(float bPerSection) { - ValidationUtil.checkbPerSection(this, bPerSection); - float oldValue = this.bPerSection; - this.bPerSection = bPerSection; - notifyUpdate("bPerSection", oldValue, bPerSection); - return this; - } - - @Override - public int getMaximumSectionCount() { - return maximumSectionCount; - } - - @Override - public ShuntCompensatorImpl setMaximumSectionCount(int maximumSectionCount) { - ValidationUtil.checkSections(this, getCurrentSectionCount(), maximumSectionCount); - float oldValue = this.maximumSectionCount; - this.maximumSectionCount = maximumSectionCount; - notifyUpdate("maximumSectionCount", oldValue, maximumSectionCount); - return this; - } - - @Override - public int getCurrentSectionCount() { - return currentSectionCount.get(network.get().getStateIndex()); - } - - @Override - public ShuntCompensatorImpl setCurrentSectionCount(int currentSectionCount) { - ValidationUtil.checkSections(this, currentSectionCount, maximumSectionCount); - int oldValue = this.currentSectionCount.set(network.get().getStateIndex(), currentSectionCount); - notifyUpdate("currentSectionCount", oldValue, currentSectionCount); - return this; - } - - @Override - public float getCurrentB() { - return bPerSection * getCurrentSectionCount(); - } - - @Override - public float getMaximumB() { - return bPerSection * maximumSectionCount; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - currentSectionCount.ensureCapacity(currentSectionCount.size() + number); - for (int i = 0; i < number; i++) { - currentSectionCount.add(currentSectionCount.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - currentSectionCount.remove(currentSectionCount.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - currentSectionCount.set(index, currentSectionCount.get(sourceIndex)); - } - } - - @Override - protected String getTypeDescription() { - return "Shunt compensator"; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SingleTerminalConnectableAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SingleTerminalConnectableAdderImpl.java deleted file mode 100644 index 99c9a0fc..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SingleTerminalConnectableAdderImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class SingleTerminalConnectableAdderImpl> extends IdentifiableAdderImpl { - - private Integer node; - - private String bus; - - private String connectableBus; - - public T setNode(int node) { - this.node = node; - return (T) this; - } - - public T setBus(String bus) { - this.bus = bus; - return (T) this; - } - - public T setConnectableBus(String connectableBus) { - this.connectableBus = connectableBus; - return (T) this; - } - - protected TerminalExt checkAndGetTerminal(String id) { - return new TerminalBuilder(getNetwork().getRef(), this) - .setNode(node) - .setBus(bus) - .setConnectableBus(connectableBus) - .build(); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/State.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/State.java deleted file mode 100644 index 02c2f56e..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/State.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface State { - - S copy(); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateArray.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateArray.java deleted file mode 100644 index 88de71a0..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateArray.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.impl.util.Ref; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * To easily manage an array of state. - * - * @author Geoffroy Jamgotchian - */ -class StateArray { - - private final Ref multiStateObjRef; - - private final List states; - - StateArray(Ref multiStateObjRef, StateFactory stateFactory) { - this.multiStateObjRef = multiStateObjRef; - StateManagerImpl stateManager = multiStateObjRef.get().getStateManager(); - states = Collections.synchronizedList(new ArrayList(stateManager.getStateArraySize())); - for (int i = 0; i < stateManager.getStateArraySize(); i++) { - states.add(null); - } - for (int i : stateManager.getStateIndexes()) { - states.set(i, stateFactory.newState()); - } - } - - S get() { - return states.get(multiStateObjRef.get().getStateManager().getStateContext().getStateIndex()); - } - - void push(int number, StateFactory stateFactory) { - for (int i = 0; i < number; i++) { - states.add(stateFactory.newState()); - } - } - - void push(StateFactory stateFactory) { - states.add(stateFactory.newState()); - } - - void pop(int number) { - for (int i = 0; i < number; i++) { - states.remove(states.size()-1); - } - } - - void delete(int index) { - states.set(index, null); - } - - void allocate(int[] indexes, StateFactory stateFactory) { - for (int index : indexes) { - states.set(index, stateFactory.newState()); - } - } - - S copy(int index) { - return states.get(index).copy(); - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateContext.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateContext.java deleted file mode 100644 index a1b0c761..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateContext.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface StateContext { - - int getStateIndex(); - - void setStateIndex(int index); - - void resetIfStateIndexIs(int index); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateFactory.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateFactory.java deleted file mode 100644 index f8357882..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface StateFactory { - - S newState(); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateManagerImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateManagerImpl.java deleted file mode 100644 index 3ebf6353..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StateManagerImpl.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.BiMap; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.HashBiMap; -import com.google.common.primitives.Ints; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.StateManager; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.List; -import java.util.concurrent.locks.ReentrantLock; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * - * @author Geoffroy Jamgotchian - */ -class StateManagerImpl implements StateManager { - - private static final Logger LOGGER = LoggerFactory.getLogger(StateManagerImpl.class); - - private static final int INITIAL_STATE_INDEX = 0; - - private StateContext stateContext; - - private final ObjectStore objectStore; - - private final BiMap id2index = HashBiMap.create(); - - private int stateArraySize; - - private final Deque unusedIndexes = new ArrayDeque<>(); - - private final ReentrantLock stateLock = new ReentrantLock(); - - StateManagerImpl(ObjectStore objectStore) { - this.stateContext = new MultiStateContext(INITIAL_STATE_INDEX); - this.objectStore = objectStore; - // the network has always a zero index initial state - id2index.put(INITIAL_STATE_ID, INITIAL_STATE_INDEX); - stateArraySize = INITIAL_STATE_INDEX + 1; - } - - StateContext getStateContext() { - return stateContext; - } - - @Override - public Collection getStateIds() { - stateLock.lock(); - try { - return Collections.unmodifiableSet(id2index.keySet()); - } finally { - stateLock.unlock(); - } - } - - int getStateArraySize() { - return stateArraySize; - } - - int getStateCount() { - return id2index.size(); - } - - Collection getStateIndexes() { - return id2index.values(); - } - - private int getStateIndex(String stateId) { - Integer index = id2index.get(stateId); - if (index == null) { - throw new ITeslaException("State '" + stateId + "' not found"); - } - return index; - } - - @Override - public String getWorkingStateId() { - stateLock.lock(); - try { - int index = stateContext.getStateIndex(); - return id2index.inverse().get(index); - } finally { - stateLock.unlock(); - } - } - - @Override - public void setWorkingState(String stateId) { - stateLock.lock(); - try { - int index = getStateIndex(stateId); - stateContext.setStateIndex(index); - } finally { - stateLock.unlock(); - } - } - - private Iterable getStafulObjects() { - return FluentIterable.from(objectStore.getAll()).filter(Stateful.class); - } - - @Override - public void cloneState(String sourceStateId, String targetStateId) { - cloneState(sourceStateId, Arrays.asList(targetStateId)); - } - - @Override - public void cloneState(String sourceStateId, List targetStateIds) { - if (targetStateIds.isEmpty()) { - throw new IllegalArgumentException("Empty target state id list"); - } - LOGGER.debug("Creating states {}", targetStateIds); - stateLock.lock(); - try { - int sourceIndex = getStateIndex(sourceStateId); - int initStateArraySize = stateArraySize; - int extendedCount = 0; - List recycled = new ArrayList<>(); - for (String targetStateId : targetStateIds) { - if (id2index.containsKey(targetStateId)) { - throw new ITeslaException("Target state '" + targetStateId + "' already exists"); - } - if (unusedIndexes.isEmpty()) { - // extend state array size - id2index.put(targetStateId, stateArraySize); - stateArraySize++; - extendedCount++; - } else { - // recycle an index - int index = unusedIndexes.pollLast(); - id2index.put(targetStateId, index); - recycled.add(index); - } - } - if (recycled.size() > 0) { - int[] indexes = Ints.toArray(recycled); - for (Stateful obj : getStafulObjects()) { - obj.allocateStateArrayElement(indexes, sourceIndex); - } - LOGGER.trace("Recycling state array indexes {}", Arrays.toString(indexes)); - } - if (extendedCount > 0) { - for (Stateful obj : getStafulObjects()) { - obj.extendStateArraySize(initStateArraySize, extendedCount, sourceIndex); - } - LOGGER.trace("Extending state array size to {} (+{})", stateArraySize, extendedCount); - } - } finally { - stateLock.unlock(); - } - } - - @Override - public void removeState(String stateId) { - stateLock.lock(); - try { - if (INITIAL_STATE_ID.equals(stateId)) { - throw new ITeslaException("Removing initial state is vorbidden"); - } - int index = getStateIndex(stateId); - id2index.remove(stateId); - LOGGER.debug("Removing state '{}'", stateId); - if (index == stateArraySize-1) { - // remove consecutive unsused index starting from the end - int number = 0; // number of elements to remove - for (int j = index; j >= 0; j--) { - if (id2index.containsValue(j)) { - break; - } else { - number++; - unusedIndexes.remove(j); - } - } - // reduce state array size - for (Stateful obj : getStafulObjects()) { - obj.reduceStateArraySize(number); - } - stateArraySize -= number; - LOGGER.trace("Reducing state array size to {}", stateArraySize); - } else { - unusedIndexes.add(index); - // delete state array element at the unused index to avoid memory leak - // (so that state data can be garbage collected) - for (Stateful obj : getStafulObjects()) { - obj.deleteStateArrayElement(index); - } - LOGGER.trace("Deleting state array element at index {}", index); - } - // if the removed state is the working state, unset the working state - stateContext.resetIfStateIndexIs(index); - } finally { - stateLock.unlock(); - } - } - - @Override - public void allowStateMultiThreadAccess(boolean allow) { - stateLock.lock(); - try { - if (allow) { - int index = stateContext.getStateIndex(); - stateContext = ThreadLocalMultiStateContext.INSTANCE; - stateContext.setStateIndex(index); - } else { - stateContext = new MultiStateContext(stateContext.getStateIndex()); - } - } finally { - stateLock.unlock(); - } - } - - @Override - public boolean isStateMultiThreadAccessAllowed() { - stateLock.lock(); - try { - return stateContext instanceof ThreadLocalMultiStateContext; - } finally { - stateLock.unlock(); - } - } - - void forEachState(Runnable r) { - stateLock.lock(); - try { - for (int index : id2index.values()) { - stateContext.setStateIndex(index); - r.run(); - } - } finally { - stateLock.unlock(); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Stateful.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Stateful.java deleted file mode 100644 index 5d331607..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Stateful.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * An interface implemented by network objets that have attributes depending on - * the state. - *

- * A class implementing this interface internally manages an array of state and - * is notified when the array need to be resized thanks to extendStateArraySize - * and reduceStateArraySize callbacks. - * - * @author Geoffroy Jamgotchian - */ -interface Stateful { - - /** - * Called to extend the state array. - * - * @param initStateArraySize initial state array size - * @param number number of element to add - * @param sourceIndex - */ - void extendStateArraySize(int initStateArraySize, int number, int sourceIndex); - - /** - * Called to reduce the state array. - * - * @param number number of element to remove - */ - void reduceStateArraySize(int number); - - /** - * Called to delete a state array element. - * - * @param index the index of the state array to delete - */ - void deleteStateArrayElement(int index); - - /** - * Called to allocate a state array element. - * - * @param indexes the indexes of the state array to allocate - * @param sourceIndex - */ - void allocateStateArrayElement(int[] indexes, int sourceIndex); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorAdderImpl.java deleted file mode 100644 index afa47b08..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorAdderImpl.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.StaticVarCompensator; -import eu.itesla_project.iidm.network.StaticVarCompensatorAdder; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -class StaticVarCompensatorAdderImpl extends SingleTerminalConnectableAdderImpl implements StaticVarCompensatorAdder { - - private final VoltageLevelExt vl; - - private float bMin = Float.NaN; - - private float bMax = Float.NaN; - - private float voltageSetPoint = Float.NaN; - - private float reactivePowerSetPoint = Float.NaN; - - private StaticVarCompensator.RegulationMode regulationMode; - - StaticVarCompensatorAdderImpl(VoltageLevelExt vl) { - this.vl = Objects.requireNonNull(vl); - } - - @Override - protected NetworkImpl getNetwork() { - return vl.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return StaticVarCompensatorImpl.TYPE_DESCRIPTION; - } - - @Override - public StaticVarCompensatorAdderImpl setBmin(float bMin) { - this.bMin = bMin; - return this; - } - - @Override - public StaticVarCompensatorAdderImpl setBmax(float bMax) { - this.bMax = bMax; - return this; - } - - @Override - public StaticVarCompensatorAdderImpl setVoltageSetPoint(float voltageSetPoint) { - this.voltageSetPoint = voltageSetPoint; - return this; - } - - @Override - public StaticVarCompensatorAdderImpl setReactivePowerSetPoint(float reactivePowerSetPoint) { - this.reactivePowerSetPoint = reactivePowerSetPoint; - return this; - } - - @Override - public StaticVarCompensatorAdderImpl setRegulationMode(StaticVarCompensator.RegulationMode regulationMode) { - this.regulationMode = regulationMode; - return this; - } - - @Override - public StaticVarCompensatorImpl add() { - String id = checkAndGetUniqueId(); - String name = getName(); - TerminalExt terminal = checkAndGetTerminal(id); - ValidationUtil.checkBmin(this, bMin); - ValidationUtil.checkBmax(this, bMax); - ValidationUtil.checkSvcRegulator(this, voltageSetPoint, reactivePowerSetPoint, regulationMode); - StaticVarCompensatorImpl svc = new StaticVarCompensatorImpl(id, name, bMin, bMax, voltageSetPoint, reactivePowerSetPoint, - regulationMode, getNetwork().getRef()); - svc.addTerminal(terminal); - vl.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(svc); - getNetwork().getListeners().notifyCreation(svc); - return svc; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorImpl.java deleted file mode 100644 index 032094be..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorImpl.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.StaticVarCompensator; -import eu.itesla_project.iidm.network.Terminal; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; -import gnu.trove.list.array.TIntArrayList; - -/** - * @author Geoffroy Jamgotchian - */ -class StaticVarCompensatorImpl extends ConnectableImpl implements StaticVarCompensator { - - static final String TYPE_DESCRIPTION = "staticVarCompensator"; - - private float bMin; - - private float bMax; - - // attributes depending on the state - - private final TFloatArrayList voltageSetPoint; - - private final TFloatArrayList reactivePowerSetPoint; - - private final TIntArrayList regulationMode; - - StaticVarCompensatorImpl(String id, String name, float bMin, float bMax, float voltageSetPoint, float reactivePowerSetPoint, - RegulationMode regulationMode, Ref ref) { - super(id, name); - this.bMin = bMin; - this.bMax = bMax; - int stateArraySize = ref.get().getStateManager().getStateArraySize(); - this.voltageSetPoint = new TFloatArrayList(stateArraySize); - this.reactivePowerSetPoint = new TFloatArrayList(stateArraySize); - this.regulationMode = new TIntArrayList(stateArraySize); - for (int i = 0; i < stateArraySize; i++) { - this.voltageSetPoint.add(voltageSetPoint); - this.reactivePowerSetPoint.add(reactivePowerSetPoint); - this.regulationMode.add(regulationMode.ordinal()); - } - } - - @Override - public Terminal getTerminal() { - return terminals.get(0); - } - - @Override - public ConnectableType getType() { - return ConnectableType.STATIC_VAR_COMPENSATOR; - } - - @Override - protected String getTypeDescription() { - return TYPE_DESCRIPTION; - } - - @Override - public float getBmin() { - return bMin; - } - - @Override - public StaticVarCompensatorImpl setBmin(float bMin) { - ValidationUtil.checkBmin(this, bMin); - this.bMin = bMin; - return this; - } - - @Override - public float getBmax() { - return bMax; - } - - @Override - public StaticVarCompensatorImpl setBmax(float bMax) { - ValidationUtil.checkBmax(this, bMax); - this.bMax = bMax; - return this; - } - - @Override - public float getVoltageSetPoint() { - return voltageSetPoint.get(getNetwork().getStateIndex()); - } - - @Override - public StaticVarCompensatorImpl setVoltageSetPoint(float voltageSetPoint) { - ValidationUtil.checkSvcRegulator(this, voltageSetPoint, getReactivePowerSetPoint(), getRegulationMode()); - float oldValue = this.voltageSetPoint.set(getNetwork().getStateIndex(), voltageSetPoint); - notifyUpdate("voltageSetPoint", oldValue, voltageSetPoint); - return this; - } - - @Override - public float getReactivePowerSetPoint() { - return reactivePowerSetPoint.get(getNetwork().getStateIndex()); - } - - @Override - public StaticVarCompensatorImpl setReactivePowerSetPoint(float reactivePowerSetPoint) { - ValidationUtil.checkSvcRegulator(this, getVoltageSetPoint(), reactivePowerSetPoint, getRegulationMode()); - float oldValue = this.reactivePowerSetPoint.set(getNetwork().getStateIndex(), reactivePowerSetPoint); - notifyUpdate("reactivePowerSetPoint", oldValue, reactivePowerSetPoint); - return this; - } - - @Override - public RegulationMode getRegulationMode() { - return RegulationMode.values()[regulationMode.get(getNetwork().getStateIndex())]; - } - - @Override - public StaticVarCompensatorImpl setRegulationMode(RegulationMode regulationMode) { - ValidationUtil.checkSvcRegulator(this, getVoltageSetPoint(), getReactivePowerSetPoint(), regulationMode); - RegulationMode oldValue = RegulationMode.values()[this.regulationMode.set(getNetwork().getStateIndex(), regulationMode.ordinal())]; - notifyUpdate("regulationMode", oldValue, regulationMode); - return this; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - voltageSetPoint.ensureCapacity(voltageSetPoint.size() + number); - reactivePowerSetPoint.ensureCapacity(reactivePowerSetPoint.size() + number); - regulationMode.ensureCapacity(regulationMode.size() + number); - for (int i = 0; i < number; i++) { - voltageSetPoint.add(voltageSetPoint.get(sourceIndex)); - reactivePowerSetPoint.add(reactivePowerSetPoint.get(sourceIndex)); - regulationMode.add(regulationMode.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - voltageSetPoint.remove(voltageSetPoint.size() - number, number); - reactivePowerSetPoint.remove(reactivePowerSetPoint.size() - number, number); - regulationMode.remove(regulationMode.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - voltageSetPoint.set(index, voltageSetPoint.get(sourceIndex)); - reactivePowerSetPoint.set(index, reactivePowerSetPoint.get(sourceIndex)); - regulationMode.set(index, regulationMode.get(sourceIndex)); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationAdderImpl.java deleted file mode 100644 index 814e3c9a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationAdderImpl.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.impl.util.Ref; -import eu.itesla_project.iidm.network.Country; -import eu.itesla_project.iidm.network.Substation; -import eu.itesla_project.iidm.network.SubstationAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class SubstationAdderImpl extends IdentifiableAdderImpl implements SubstationAdder { - - private final Ref networkRef; - - private Country country; - - private String tso; - - private String[] tags; - - SubstationAdderImpl(Ref networkRef) { - this.networkRef = networkRef; - } - - @Override - protected NetworkImpl getNetwork() { - return networkRef.get(); - } - - @Override - protected String getTypeDescription() { - return "Substation"; - } - - @Override - public SubstationAdder setCountry(Country country) { - this.country = country; - return this; - } - - @Override - public SubstationAdder setTso(String tso) { - this.tso = tso; - return this; - } - - @Override - public SubstationAdder setGeographicalTags(String... tags) { - this.tags = tags; - return this; - } - - @Override - public Substation add() { - String id = checkAndGetUniqueId(); - ValidationUtil.checkCountry(this, country); - SubstationImpl substation = new SubstationImpl(id, getName(), country, tso, networkRef); - if (tags != null) { - for (String tag : tags) { - substation.addGeographicalTag(tag); - } - } - getNetwork().getObjectStore().checkAndAdd(substation); - getNetwork().getListeners().notifyCreation(substation); - return substation; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationImpl.java deleted file mode 100644 index 8e383aac..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SubstationImpl.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.base.Function; -import com.google.common.collect.FluentIterable; -import eu.itesla_project.iidm.network.*; -import eu.itesla_project.iidm.network.impl.util.Ref; - -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.Set; - -/** - * - * @author Geoffroy Jamgotchian - */ -class SubstationImpl extends IdentifiableImpl implements Substation { - - private static final Function> toTwoWindingsTransformers - = new Function>() { - @Override - public Iterable apply(VoltageLevelExt vl) { - return vl.getConnectables(TwoWindingsTransformer.class); - } - }; - - private static final Function> toThreeWindingsTransformers - = new Function>() { - @Override - public Iterable apply(VoltageLevelExt vl) { - return vl.getConnectables(ThreeWindingsTransformer.class); - } - }; - - private Country country; - - private String tso; - - private final Ref networkRef; - - private final Set geographicalTags = new LinkedHashSet<>(); - - private final Set voltageLevels = new LinkedHashSet<>(); - - SubstationImpl(String id, String name, Country country, String tso, Ref networkRef) { - super(id, name); - this.country = country; - this.tso = tso; - this.networkRef = networkRef; - } - - @Override - public ContainerType getContainerType() { - return ContainerType.SUBSTATION; - } - - @Override - public Country getCountry() { - return country; - } - - @Override - public SubstationImpl setCountry(Country country) { - ValidationUtil.checkCountry(this, country); - Country oldValue = this.country; - this.country = country; - getNetwork().getListeners().notifyUpdate(this, "country", oldValue.toString(), country.toString()); - return this; - } - - @Override - public String getTso() { - return tso; - } - - @Override - public SubstationImpl setTso(String tso) { - String oldValue = this.tso; - this.tso = tso; - getNetwork().getListeners().notifyUpdate(this, "tso", oldValue, tso); - return this; - } - - @Override - public NetworkImpl getNetwork() { - return networkRef.get(); - } - - void addVoltageLevel(VoltageLevelExt voltageLevel) { - voltageLevels.add(voltageLevel); - } - - @Override - public VoltageLevelAdderImpl newVoltageLevel() { - return new VoltageLevelAdderImpl(this); - } - - @Override - public Iterable getVoltageLevels() { - return Collections.unmodifiableSet(voltageLevels); - } - - @Override - public TwoWindingsTransformerAdderImpl newTwoWindingsTransformer() { - return new TwoWindingsTransformerAdderImpl(this); - } - - @Override - public Iterable getTwoWindingsTransformers() { - return FluentIterable.from(voltageLevels) - .transformAndConcat(toTwoWindingsTransformers) - .toSet(); - } - - @Override - public ThreeWindingsTransformerAdderImpl newThreeWindingsTransformer() { - return new ThreeWindingsTransformerAdderImpl(this); - } - - @Override - public Iterable getThreeWindingsTransformers() { - return FluentIterable.from(voltageLevels) - .transformAndConcat(toThreeWindingsTransformers) - .toSet(); - } - - @Override - public Set getGeographicalTags() { - return Collections.unmodifiableSet(geographicalTags); - } - - @Override - public Substation addGeographicalTag(String tag) { - if (tag == null) { - throw new ValidationException(this, "geographical tag is null"); - } - geographicalTags.add(tag); - return this; - } - - @Override - protected String getTypeDescription() { - return "Substation"; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Substations.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Substations.java deleted file mode 100644 index 8d86074a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Substations.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.Country; -import eu.itesla_project.iidm.network.Substation; - -/** - * - * @author Geoffroy Jamgotchian - */ -class Substations { - - private Substations() { - } - - static Iterable filter(Iterable substations, - final Country country, - final String tso, - final String... geographicalTags) { - if (geographicalTags.length == 0) { - return substations; - } - return Iterables.filter(substations, new Predicate() { - @Override - public boolean apply(Substation substation) { - if (country != null && country == substation.getCountry()) { - return false; - } - if (tso != null && !tso.equals(substation.getTso())) { - return false; - } - for (String tag : geographicalTags) { - if (!substation.getGeographicalTags().contains(tag)) { - return false; - } - } - return true; - } - }); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SwitchImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SwitchImpl.java deleted file mode 100644 index 2f246073..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/SwitchImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Switch; -import eu.itesla_project.iidm.network.SwitchKind; -import java.util.BitSet; - -/** - * - * @author Geoffroy Jamgotchian - */ -class SwitchImpl extends IdentifiableImpl implements Switch, Stateful { - - private final VoltageLevelExt voltageLevel; - - private final SwitchKind kind; - - private boolean retained; - - private final BitSet open; - - SwitchImpl(VoltageLevelExt voltageLevel, - String id, String name, SwitchKind kind, final boolean open, boolean retained) { - super(id, name); - this.voltageLevel = voltageLevel; - this.kind = kind; - this.retained = retained; - int stateArraySize = voltageLevel.getNetwork().getStateManager().getStateArraySize(); - this.open = new BitSet(stateArraySize); - this.open.set(0, stateArraySize, open); - } - - @Override - public VoltageLevelExt getVoltageLevel() { - return voltageLevel; - } - - @Override - public SwitchKind getKind() { - return kind; - } - - @Override - public boolean isOpen() { - return open.get(voltageLevel.getNetwork().getStateIndex()); - } - - @Override - public void setOpen(boolean open) { - NetworkImpl network = voltageLevel.getNetwork(); - int index = network.getStateIndex(); - boolean oldValue = this.open.get(index); - if (oldValue != open) { - this.open.set(index, open); - voltageLevel.invalidateCache(); - network.getListeners().notifyUpdate(this, "open", oldValue, open); - } - } - - @Override - public boolean isRetained() { - return retained; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - for (int i = 0; i < number; i++) { - this.open.set(initStateArraySize + i, this.open.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - } - - @Override - public void deleteStateArrayElement(int index) { - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - for (int index : indexes) { - open.set(index, open.get(sourceIndex)); - } - } - - @Override - protected String getTypeDescription() { - return "Switch"; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerImpl.java deleted file mode 100644 index 484fcfa0..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerImpl.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Terminal; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TIntArrayList; -import java.util.BitSet; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class TapChangerImpl, S extends TapChangerStepImpl> implements Stateful { - - protected final Ref network; - - protected final H parent; - - protected int lowTapPosition; - - protected final List steps; - - protected TerminalExt regulationTerminal; - - // attributes depending on the state - - protected final TIntArrayList tapPosition; - - protected final BitSet regulating; - - protected TapChangerImpl(Ref network, H parent, - int lowTapPosition, List steps, TerminalExt regulationTerminal, - int tapPosition, boolean regulating) { - this.network = network; - this.parent = parent; - this.lowTapPosition = lowTapPosition; - this.steps = steps; - this.regulationTerminal = regulationTerminal; - int stateArraySize = network.get().getStateManager().getStateArraySize(); - this.tapPosition = new TIntArrayList(stateArraySize); - this.regulating = new BitSet(stateArraySize); - this.regulating.set(0, stateArraySize, regulating); - for (int i = 0; i < stateArraySize; i++) { - this.tapPosition.add(tapPosition); - } - } - - protected abstract NetworkImpl getNetwork(); - - public int getStepCount() { - return steps.size(); - } - - public int getLowTapPosition() { - return lowTapPosition; - } - - public int getHighTapPosition() { - return lowTapPosition + steps.size() - 1; - } - - public int getTapPosition() { - return tapPosition.get(network.get().getStateIndex()); - } - - protected abstract String getTapChangerAttribute(); - - public C setTapPosition(int tapPosition) { - if (tapPosition < lowTapPosition - || tapPosition > getHighTapPosition()) { - throw new ValidationException(parent, "incorrect tap position " - + tapPosition + " [" + lowTapPosition + ", " - + getHighTapPosition() + "]"); - } - int oldValue = this.tapPosition.set(network.get().getStateIndex(), tapPosition); - parent.getNetwork().getListeners().notifyUpdate(parent.getTransformer(), getTapChangerAttribute() + ".tapPosition", oldValue, tapPosition); - return (C) this; - } - - public S getStep(int tapPosition) { - if (tapPosition < lowTapPosition || tapPosition > getHighTapPosition()) { - throw new ValidationException(parent, "incorrect tap position " - + tapPosition + " [" + lowTapPosition + ", " + getHighTapPosition() - + "]"); - } - return steps.get(tapPosition - lowTapPosition); - } - - public S getCurrentStep() { - return getStep(getTapPosition()); - } - - public boolean isRegulating() { - return regulating.get(network.get().getStateIndex()); - } - - public C setRegulating(boolean regulating) { - this.regulating.set(network.get().getStateIndex(), regulating); - return (C) this; - } - - public TerminalExt getRegulationTerminal() { - return regulationTerminal; - } - - public C setRegulationTerminal(Terminal regulationTerminal) { - if (regulationTerminal == null) { - throw new ValidationException(parent, "regulation terminal is null"); - } - if (((TerminalExt) regulationTerminal).getVoltageLevel().getNetwork() != getNetwork()) { - throw new ValidationException(parent, "regulation terminal is not part of the network"); - } - this.regulationTerminal = (TerminalExt) regulationTerminal; - return (C) this; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - tapPosition.ensureCapacity(tapPosition.size() + number); - for (int i = 0; i < number; i++) { - regulating.set(initStateArraySize + i, regulating.get(sourceIndex)); - tapPosition.add(tapPosition.get(sourceIndex)); - } - } - - @Override - public void reduceStateArraySize(int number) { - tapPosition.remove(tapPosition.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, final int sourceIndex) { - for (int index : indexes) { - regulating.set(index, regulating.get(sourceIndex)); - tapPosition.set(index, tapPosition.get(sourceIndex)); - } - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerParent.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerParent.java deleted file mode 100644 index c37f9445..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerParent.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Identifiable; - -/** - * @author Geoffroy Jamgotchian - */ -interface TapChangerParent extends Validable { - - NetworkImpl getNetwork(); - - Identifiable getTransformer(); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerStepImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerStepImpl.java deleted file mode 100644 index 88d028f2..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TapChangerStepImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -class TapChangerStepImpl> { - - private float rho; - - private float r; - - private float x; - - private float g; - - private float b; - - protected TapChangerStepImpl(float rho, float r, float x, float g, float b) { - this.rho = rho; - this.r = r; - this.x = x; - this.g = g; - this.b = b; - } - - public float getRho() { - return rho; - } - - public S setRho(float rho) { - this.rho = rho; - return (S) this; - } - - public float getR() { - return r; - } - - public S setR(float r) { - this.r = r; - return (S) this; - } - - public float getX() { - return x; - } - - public S setX(float x) { - this.x = x; - return (S) this; - } - - public float getB() { - return b; - } - - public S setB(float b) { - this.b = b; - return (S) this; - } - - public float getG() { - return g; - } - - public S setG(float g) { - this.g = g; - return (S) this; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalBuilder.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalBuilder.java deleted file mode 100644 index 873f380f..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.impl.util.Ref; - -/** - * - * @author Geoffroy Jamgotchian - */ -class TerminalBuilder { - - private final Ref network; - - private final Validable validable; - - private Integer node; - - private String bus; - - private String connectableBus; - - TerminalBuilder(Ref network, Validable validable) { - this.network = network; - this.validable = validable; - } - - TerminalBuilder setBus(String bus) { - this.bus = bus; - return this; - } - - TerminalBuilder setConnectableBus(String connectableBus) { - this.connectableBus = connectableBus; - return this; - } - - TerminalBuilder setNode(Integer node) { - this.node = node; - return this; - } - - TerminalExt build() { - if (node != null && connectableBus != null) { - throw new ValidationException(validable, - "connection node and connection bus are exclusives"); - } - if (node == null) { - if (connectableBus == null) { - throw new ValidationException(validable, "connectable bus is not set"); - } - if (bus != null && !bus.equals(connectableBus)) { - throw new ValidationException(validable, "connection bus is different to connectable bus"); - } - } - return node != null ? new NodeTerminal(network, node) - : new BusTerminal(network, connectableBus, bus != null); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalExt.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalExt.java deleted file mode 100644 index d5d575f6..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TerminalExt.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Terminal; -import eu.itesla_project.iidm.network.VoltageLevel; - -import java.util.Set; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface TerminalExt extends Terminal, Stateful { - - interface BusBreakerViewExt extends BusBreakerView { - - @Override BusExt getBus(); - - } - - interface BusViewExt extends BusView { - - @Override BusExt getBus(); - - } - - @Override ConnectableImpl getConnectable(); - - void setConnectable(ConnectableImpl connectable); - - @Override VoltageLevelExt getVoltageLevel(); - - void setVoltageLevel(VoltageLevelExt voltageLevel); - - @Override BusBreakerViewExt getBusBreakerView(); - - @Override BusViewExt getBusView(); - - void setNum(int num); - - void traverse(VoltageLevel.TopologyTraverser traverser, Set traversedVoltageLevelsIds); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreadLocalMultiStateContext.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreadLocalMultiStateContext.java deleted file mode 100644 index 304b644a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreadLocalMultiStateContext.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import java.util.function.Supplier; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ThreadLocalMultiStateContext implements StateContext { - - public static final ThreadLocalMultiStateContext INSTANCE = new ThreadLocalMultiStateContext(); - - private final ThreadLocal index = ThreadLocal.withInitial((Supplier) () -> null); - - @Override - public int getStateIndex() { - Integer i = index.get(); - if (i == null) { - throw new RuntimeException("State not set for current thread " + Thread.currentThread().getName()); - } - return i; - } - - @Override - public void setStateIndex(int index) { - this.index.set(index); - } - - public void reset() { - index.remove(); - } - - @Override - public void resetIfStateIndexIs(int index) { - Integer i = this.index.get(); - if (i != null && i == index) { - this.index.remove(); - } - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerAdderImpl.java deleted file mode 100644 index 495cc969..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerAdderImpl.java +++ /dev/null @@ -1,270 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ThreeWindingsTransformerAdder; -import eu.itesla_project.iidm.network.impl.ThreeWindingsTransformerImpl.Leg1Impl; -import eu.itesla_project.iidm.network.impl.ThreeWindingsTransformerImpl.Leg2Impl; -import eu.itesla_project.iidm.network.impl.ThreeWindingsTransformerImpl.Leg3Impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ThreeWindingsTransformerAdderImpl extends IdentifiableAdderImpl implements ThreeWindingsTransformerAdder { - - abstract class LegBaseAdderImpl> implements Validable { - - protected String voltageLevelId; - - protected Integer node; - - protected String bus; - - protected String connectableBus; - - protected float r = Float.NaN; - - protected float x = Float.NaN; - - protected float ratedU = Float.NaN; - - public L setVoltageLevel(String voltageLevelId) { - this.voltageLevelId = voltageLevelId; - return (L) this; - } - - public L setNode(int node) { - this.node = node; - return (L) this; - } - - public L setBus(String bus) { - this.bus = bus; - return (L) this; - } - - public L setConnectableBus(String connectableBus) { - this.connectableBus = connectableBus; - return (L) this; - } - - public L setR(float r) { - this.r = r; - return (L) this; - } - - public L setX(float x) { - this.x = x; - return (L) this; - } - - public L setRatedU(float ratedU) { - this.ratedU = ratedU; - return (L) this; - } - - protected void checkParams() { - if (Float.isNaN(r)) { - throw new ValidationException(this, "r is not set"); - } - if (Float.isNaN(x)) { - throw new ValidationException(this, "x is not set"); - } - if (Float.isNaN(ratedU)) { - throw new ValidationException(this, "rated u is not set"); - } - } - - protected TerminalExt checkAndGetTerminal() { - return new TerminalBuilder(getNetwork().getRef(), this) - .setNode(node) - .setBus(bus) - .setConnectableBus(connectableBus) - .build(); - } - - protected VoltageLevelExt checkAndGetVoltageLevel() { - if (voltageLevelId == null) { - throw new ValidationException(this, "voltage level is not set"); - } - VoltageLevelExt voltageLevel = getNetwork().getVoltageLevel(voltageLevelId); - if (voltageLevel == null) { - throw new ValidationException(this, "voltage level '" + voltageLevelId - + "' not found"); - } - if (voltageLevel.getSubstation() != substation) { - throw new ValidationException(this, - "voltage level shall belong to the substation '" - + substation.getId() + "'"); - } - return voltageLevel; - } - } - - class Leg1AdderImpl extends LegBaseAdderImpl implements Leg1Adder { - - protected float g = Float.NaN; - - protected float b = Float.NaN; - - @Override - public Leg1AdderImpl setG(float g) { - this.g = g; - return this; - } - - @Override - public Leg1AdderImpl setB(float b) { - this.b = b; - return this; - } - - @Override - protected void checkParams() { - super.checkParams(); - if (Float.isNaN(g)) { - throw new ValidationException(this, "g is not set"); - } - if (Float.isNaN(b)) { - throw new ValidationException(this, "b is not set"); - } - } - - @Override - public ThreeWindingsTransformerAdderImpl add() { - checkParams(); - voltageLevel1 = checkAndGetVoltageLevel(); - terminal1 = checkAndGetTerminal(); - leg1 = new Leg1Impl(r, x, g, b, ratedU); - return ThreeWindingsTransformerAdderImpl.this; - } - - @Override - public String getMessageHeader() { - return "3 windings transformer leg 1: "; - } - - } - - class Leg2AdderImpl extends LegBaseAdderImpl implements Leg2or3Adder { - - @Override - public ThreeWindingsTransformerAdderImpl add() { - checkParams(); - voltageLevel2 = checkAndGetVoltageLevel(); - terminal2 = checkAndGetTerminal(); - leg2 = new Leg2Impl(r, x, ratedU); - return ThreeWindingsTransformerAdderImpl.this; - } - - @Override - public String getMessageHeader() { - return "3 windings transformer leg 2: "; - } - - } - - class Leg3AdderImpl extends LegBaseAdderImpl implements Leg2or3Adder { - - @Override - public ThreeWindingsTransformerAdderImpl add() { - checkParams(); - voltageLevel3 = checkAndGetVoltageLevel(); - terminal3 = checkAndGetTerminal(); - leg3 = new Leg3Impl(r, x, ratedU); - return ThreeWindingsTransformerAdderImpl.this; - } - - @Override - public String getMessageHeader() { - return "3 windings transformer leg 3: "; - } - - } - - private final SubstationImpl substation; - - private ThreeWindingsTransformerImpl.Leg1Impl leg1; - - private ThreeWindingsTransformerImpl.Leg2Impl leg2; - - private ThreeWindingsTransformerImpl.Leg3Impl leg3; - - private VoltageLevelExt voltageLevel1; - - private VoltageLevelExt voltageLevel2; - - private VoltageLevelExt voltageLevel3; - - private TerminalExt terminal1; - - private TerminalExt terminal2; - - private TerminalExt terminal3; - - ThreeWindingsTransformerAdderImpl(SubstationImpl substation) { - this.substation = substation; - } - - @Override - protected NetworkImpl getNetwork() { - return substation.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "3 windings transformer"; - } - - @Override - public Leg1AdderImpl newLeg1() { - return new Leg1AdderImpl(); - } - - @Override - public Leg2AdderImpl newLeg2() { - return new Leg2AdderImpl(); - } - - @Override - public Leg3AdderImpl newLeg3() { - return new Leg3AdderImpl(); - } - - @Override - public ThreeWindingsTransformerImpl add() { - String id = checkAndGetUniqueId(); - - // check that the 3 windings transformer is attachable on the 3 sides - voltageLevel1.attach(terminal1, true); - voltageLevel2.attach(terminal2, true); - voltageLevel3.attach(terminal3, true); - - ThreeWindingsTransformerImpl transformer - = new ThreeWindingsTransformerImpl(id, getName(), leg1, leg2, leg3); - leg1.setTransformer(transformer); - leg2.setTransformer(transformer); - leg3.setTransformer(transformer); - terminal1.setNum(1); - terminal2.setNum(2); - terminal2.setNum(3); - transformer.addTerminal(terminal1); - transformer.addTerminal(terminal2); - transformer.addTerminal(terminal3); - - voltageLevel1.attach(terminal1, false); - voltageLevel2.attach(terminal2, false); - voltageLevel3.attach(terminal3, false); - - getNetwork().getObjectStore().checkAndAdd(transformer); - getNetwork().getListeners().notifyCreation(transformer); - - return transformer; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerImpl.java deleted file mode 100644 index 641a4ccc..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ThreeWindingsTransformerImpl.java +++ /dev/null @@ -1,350 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ThreeWindingsTransformerImpl extends ConnectableImpl implements ThreeWindingsTransformer { - - static abstract class LegBaseImpl> implements Validable, CurrentLimitsOwner { - - protected ThreeWindingsTransformerImpl transformer; - - private float r; - - private float x; - - private float ratedU; - - private CurrentLimits limits; - - LegBaseImpl(float r, float x, float ratedU) { - this.r = r; - this.x = x; - this.ratedU = ratedU; - } - - void setTransformer(ThreeWindingsTransformerImpl transformer) { - this.transformer = transformer; - } - - public TerminalExt getTerminal() { - return transformer.terminals.get(0); - } - - public float getR() { - return r; - } - - public T setR(float r) { - if (Float.isNaN(r)) { - throw new ValidationException(this, "r is invalid"); - } - this.r = r; - return (T) this; - } - - public float getX() { - return x; - } - - public T setX(float x) { - if (Float.isNaN(x)) { - throw new ValidationException(this, "x is invalid"); - } - this.x = x; - return (T) this; - } - - public float getRatedU() { - return ratedU; - } - - public T setRatedU(float ratedU) { - if (Float.isNaN(ratedU)) { - throw new ValidationException(this, "rated U is invalid"); - } - this.ratedU = ratedU; - return (T) this; - } - - @Override - public void setCurrentLimits(Void side, CurrentLimitsImpl limits) { - this.limits = limits; - } - - public CurrentLimits getCurrentLimits() { - return limits; - } - - public CurrentLimitsAdder newCurrentLimits() { - return new CurrentLimitsAdderImpl<>(null, this); - } - - protected abstract String getTypeDescription(); - - public Identifiable getTransformer() { - return transformer; - } - - @Override - public String getMessageHeader() { - return getTypeDescription() + " '" + transformer.getId() + "': "; - } - - } - - static class Leg1Impl extends LegBaseImpl implements Leg1 { - - private float g; - - private float b; - - Leg1Impl(float r, float x, float g, float b, float ratedU) { - super(r, x, ratedU); - this.g = g; - this.b = b; - } - - @Override - public float getG() { - return g; - } - - @Override - public Leg1Impl setG(float g) { - if (Float.isNaN(g)) { - throw new ValidationException(this, "g is invalid"); - } - this.g = g; - return this; - } - - @Override - public float getB() { - return b; - } - - @Override - public Leg1Impl setB(float b) { - if (Float.isNaN(b)) { - throw new ValidationException(this, "b is invalid"); - } - this.b = b; - return this; - } - - @Override - public TerminalExt getTerminal() { - return transformer.terminals.get(0); - } - - @Override - public String getTypeDescription() { - return "3 windings transformer leg 1"; - } - - @Override - public String toString() { - return transformer.getId() + " leg 1"; - } - - } - - private static abstract class Leg2or3Impl> extends LegBaseImpl implements RatioTapChangerParent { - - private RatioTapChangerImpl ratioTapChanger; - - Leg2or3Impl(float r, float x, float ratedU) { - super(r, x, ratedU); - } - - public RatioTapChangerAdderImpl newRatioTapChanger() { - return new RatioTapChangerAdderImpl(this); - } - - public RatioTapChangerImpl getRatioTapChanger() { - return ratioTapChanger; - } - - @Override - public NetworkImpl getNetwork() { - return transformer.getSubstation().getNetwork(); - } - - @Override - public void setRatioTapChanger(RatioTapChangerImpl ratioTapChanger) { - this.ratioTapChanger = ratioTapChanger; - } - - } - - static class Leg2Impl extends Leg2or3Impl implements Leg2or3 { - - Leg2Impl(float r, float x, float ratedU) { - super(r, x, ratedU); - } - - @Override - public TerminalExt getTerminal() { - return transformer.terminals.get(1); - } - - @Override - public String getTapChangerAttribute() { - return "ratioTapChanger2"; - } - - @Override - public String getTypeDescription() { - return "3 windings transformer leg 2"; - } - - @Override - public String toString() { - return transformer.getId() + " leg 2"; - } - - } - - static class Leg3Impl extends Leg2or3Impl implements Leg2or3 { - - Leg3Impl(float r, float x, float ratedU) { - super(r, x, ratedU); - } - - @Override - public TerminalExt getTerminal() { - return transformer.terminals.get(2); - } - - @Override - public String getTapChangerAttribute() { - return "ratioTapChanger3"; - } - - @Override - public String getTypeDescription() { - return "3 windings transformer leg 3"; - } - - @Override - public String toString() { - return transformer.getId() + " leg 3"; - } - - } - - private final Leg1Impl leg1; - - private final Leg2Impl leg2; - - private final Leg3Impl leg3; - - ThreeWindingsTransformerImpl(String id, String name, Leg1Impl leg1, Leg2Impl leg2, Leg3Impl leg3) { - super(id, name); - this.leg1 = leg1; - this.leg2 = leg2; - this.leg3 = leg3; - } - - @Override - public ConnectableType getType() { - return ConnectableType.THREE_WINDINGS_TRANSFORMER; - } - - @Override - public SubstationImpl getSubstation() { - return leg1.getTerminal().getVoltageLevel().getSubstation(); - } - - @Override - public Leg1Impl getLeg1() { - return leg1; - } - - @Override - public Leg2Impl getLeg2() { - return leg2; - } - - @Override - public Leg3Impl getLeg3() { - return leg3; - } - - @Override - public Terminal getTerminal(Side side) { - switch (side) { - case ONE: - return getLeg1().getTerminal(); - - case TWO: - return getLeg2().getTerminal(); - - case THREE: - return getLeg3().getTerminal(); - - default: - throw new AssertionError(); - } - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - if (leg2.getRatioTapChanger() != null) { - leg2.getRatioTapChanger().extendStateArraySize(initStateArraySize, number, sourceIndex); - } - if (leg3.getRatioTapChanger() != null) { - leg3.getRatioTapChanger().extendStateArraySize(initStateArraySize, number, sourceIndex); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - if (leg2.getRatioTapChanger() != null) { - leg2.getRatioTapChanger().reduceStateArraySize(number); - } - if (leg3.getRatioTapChanger() != null) { - leg3.getRatioTapChanger().reduceStateArraySize(number); - } - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - if (leg2.getRatioTapChanger() != null) { - leg2.getRatioTapChanger().deleteStateArrayElement(index); - } - if (leg3.getRatioTapChanger() != null) { - leg3.getRatioTapChanger().deleteStateArrayElement(index); - } - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - if (leg2.getRatioTapChanger() != null) { - leg2.getRatioTapChanger().allocateStateArrayElement(indexes, sourceIndex); - } - if (leg3.getRatioTapChanger() != null) { - leg3.getRatioTapChanger().allocateStateArrayElement(indexes, sourceIndex); - } - } - - @Override - protected String getTypeDescription() { - return "3 windings transformer"; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineAdderImpl.java deleted file mode 100644 index d1ebfdff..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineAdderImpl.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.TieLineAdder; - -/** - * @author Geoffroy Jamgotchian - */ -class TieLineAdderImpl extends TwoTerminalsConnectableAdderImpl implements TieLineAdder { - - private final NetworkImpl network; - - private String ucteXnodeCode; - - private TieLineImpl.HalfLineImpl half1 = new TieLineImpl.HalfLineImpl(); - - private TieLineImpl.HalfLineImpl half2 = new TieLineImpl.HalfLineImpl(); - - private TieLineImpl.HalfLineImpl activeHalf; - - TieLineAdderImpl(NetworkImpl network) { - this.network = network; - } - - @Override - protected NetworkImpl getNetwork() { - return network; - } - - @Override - protected String getTypeDescription() { - return "AC tie Line"; - } - - @Override - public TieLineAdderImpl setUcteXnodeCode(String ucteXnodeCode) { - this.ucteXnodeCode = ucteXnodeCode; - return this; - } - - @Override - public TieLineAdderImpl line1() { - activeHalf = half1; - return this; - } - - @Override - public TieLineAdderImpl line2() { - activeHalf = half2; - return this; - } - - private TieLineImpl.HalfLineImpl getActiveHalf() { - if (activeHalf == null) { - throw new ValidationException(this, "No active half of the line"); - } - return activeHalf; - } - - @Override - public TieLineAdderImpl setId(String id) { - if (activeHalf == null) { - return super.setId(id); - } else { - getActiveHalf().setId(id); - } - return this; - } - - @Override - public TieLineAdderImpl setName(String name) { - if (activeHalf == null) { - return super.setName(name); - } else { - getActiveHalf().setName(name); - } - return this; - } - - @Override - public TieLineAdderImpl setR(float r) { - getActiveHalf().setR(r); - return this; - } - - @Override - public TieLineAdderImpl setX(float x) { - getActiveHalf().setX(x); - return this; - } - - @Override - public TieLineAdderImpl setG1(float g1) { - getActiveHalf().setG1(g1); - return this; - } - - @Override - public TieLineAdderImpl setG2(float g2) { - getActiveHalf().setG2(g2); - return this; - } - - @Override - public TieLineAdderImpl setB1(float b1) { - getActiveHalf().setB1(b1); - return this; - } - - @Override - public TieLineAdderImpl setB2(float b2) { - getActiveHalf().setB2(b2); - return this; - } - - @Override - public TieLineAdderImpl setXnodeP(float xnodeP) { - getActiveHalf().setXnodeP(xnodeP); - return this; - } - - @Override - public TieLineAdderImpl setXnodeQ(float xnodeQ) { - getActiveHalf().setXnodeQ(xnodeQ); - return this; - } - - private void checkHalf(TieLineImpl.HalfLineImpl half, int num) { - if (half.id == null) { - throw new ValidationException(this, "id is not set for half line " + num); - } - if (Float.isNaN(half.r)) { - throw new ValidationException(this, "r is not set for half line " + num); - } - if (Float.isNaN(half.x)) { - throw new ValidationException(this, "x is not set for half line " + num); - } - if (Float.isNaN(half.g1)) { - throw new ValidationException(this, "g1 is not set for half line " + num); - } - if (Float.isNaN(half.b1)) { - throw new ValidationException(this, "b1 is not set for half line " + num); - } - if (Float.isNaN(half.g2)) { - throw new ValidationException(this, "g2 is not set for half line " + num); - } - if (Float.isNaN(half.b2)) { - throw new ValidationException(this, "b2 is not set for half line " + num); - } - if (Float.isNaN(half.xnodeP)) { - throw new ValidationException(this, "xnodeP is not set for half line " + num); - } - if (Float.isNaN(half.xnodeQ)) { - throw new ValidationException(this, "xnodeQ is not set for half line " + num); - } - } - - @Override - public TieLineImpl add() { - String id = checkAndGetUniqueId(); - VoltageLevelExt voltageLevel1 = checkAndGetVoltageLevel1(id); - VoltageLevelExt voltageLevel2 = checkAndGetVoltageLevel2(id); - TerminalExt terminal1 = checkAndGetTerminal1(id); - TerminalExt terminal2 = checkAndGetTerminal2(id); - - if (ucteXnodeCode == null) { - throw new ValidationException(this, "ucteXnodeCode is not set"); - } - checkHalf(half1, 1); - checkHalf(half2, 2); - - // check that the line is attachable on both side - voltageLevel1.attach(terminal1, true); - voltageLevel2.attach(terminal2, true); - - TieLineImpl line = new TieLineImpl(id, getName(), ucteXnodeCode, half1, half2); - terminal1.setNum(1); - terminal2.setNum(2); - line.addTerminal(terminal1); - line.addTerminal(terminal2); - voltageLevel1.attach(terminal1, false); - voltageLevel2.attach(terminal2, false); - network.getObjectStore().checkAndAdd(line); - return line; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineImpl.java deleted file mode 100644 index 3c0154d7..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TieLineImpl.java +++ /dev/null @@ -1,232 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.TieLine; - -/** - * @author Geoffroy Jamgotchian - */ -class TieLineImpl extends LineImpl implements TieLine { - - static class HalfLineImpl implements HalfLine { - - String id; - String name; - float xnodeP = Float.NaN; - float xnodeQ = Float.NaN; - float r = Float.NaN; - float x = Float.NaN; - float g1 = Float.NaN; - float g2 = Float.NaN; - float b1 = Float.NaN; - float b2 = Float.NaN; - - @Override - public String getId() { - return id; - } - - void setId(String id) { - this.id = id; - } - - @Override - public String getName() { - return name == null ? id : name; - } - - void setName(String name) { - this.name = name; - } - - @Override - public float getXnodeP() { - return xnodeP; - } - - @Override - public HalfLineImpl setXnodeP(float xnodeP) { - this.xnodeP = xnodeP; - return this; - } - - @Override - public float getXnodeQ() { - return xnodeQ; - } - - @Override - public HalfLineImpl setXnodeQ(float xnodeQ) { - this.xnodeQ = xnodeQ; - return null; - } - - @Override - public float getR() { - return r; - } - - @Override - public HalfLineImpl setR(float r) { - this.r = r; - return this; - } - - @Override - public float getX() { - return x; - } - - @Override - public HalfLineImpl setX(float x) { - this.x = x; - return this; - } - - @Override - public float getG1() { - return g1; - } - - @Override - public HalfLineImpl setG1(float g1) { - this.g1 = g1; - return this; - } - - @Override - public float getG2() { - return g2; - } - - @Override - public HalfLineImpl setG2(float g2) { - this.g2 = g2; - return this; - } - - @Override - public float getB1() { - return b1; - } - - @Override - public HalfLineImpl setB1(float b1) { - this.b1 = b1; - return this; - } - - @Override - public float getB2() { - return b2; - } - - @Override - public HalfLineImpl setB2(float b2) { - this.b2 = b2; - return this; - } - } - - private String ucteXnodeCode; - - private final HalfLineImpl half1; - - private final HalfLineImpl half2; - - TieLineImpl(String id, String name, String ucteXnodeCode, HalfLineImpl half1, HalfLineImpl half2) { - super(id, name, Float.NaN, Float.NaN, Float.NaN, Float.NaN, Float.NaN, Float.NaN); - this.ucteXnodeCode = ucteXnodeCode; - this.half1 = half1; - this.half2 = half2; - } - - @Override - public boolean isTieLine() { - return true; - } - - @Override - public String getUcteXnodeCode() { - return ucteXnodeCode; - } - - @Override - public HalfLineImpl getHalf1() { - return half1; - } - - @Override - public HalfLineImpl getHalf2() { - return half2; - } - - @Override - public float getR() { - return half1.getR() + half2.getR(); - } - - private ValidationException createNotSupportedForTieLines() { - return new ValidationException(this, "direct modification of characteristics not supported for tie lines"); - } - - @Override - public LineImpl setR(float r) { - throw createNotSupportedForTieLines(); - } - - @Override - public float getX() { - return half1.getX() + half2.getX(); - } - - @Override - public LineImpl setX(float x) { - throw createNotSupportedForTieLines(); - } - - @Override - public float getG1() { - return half1.getG1() + half2.getG1(); - } - - @Override - public LineImpl setG1(float g1) { - throw createNotSupportedForTieLines(); - } - - @Override - public float getB1() { - return half1.getB1() + half2.getB1(); - } - - @Override - public LineImpl setB1(float b1) { - throw createNotSupportedForTieLines(); - } - - @Override - public float getG2() { - return half1.getG2() + half2.getG2(); - } - - @Override - public LineImpl setG2(float g2) { - throw createNotSupportedForTieLines(); - } - - @Override - public float getB2() { - return half1.getB2() + half2.getB2(); - } - - @Override - public LineImpl setB2(float b2) { - throw createNotSupportedForTieLines(); - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoTerminalsConnectableAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoTerminalsConnectableAdderImpl.java deleted file mode 100644 index 7573f308..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoTerminalsConnectableAdderImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class TwoTerminalsConnectableAdderImpl> extends IdentifiableAdderImpl { - - private Integer node1; - - private String bus1; - - private String connectableBus1; - - private String voltageLevelId1; - - private Integer node2; - - private String bus2; - - private String connectableBus2; - - private String voltageLevelId2; - - public T setNode1(int node1) { - this.node1 = node1; - return (T) this; - } - - public T setBus1(String bus1) { - this.bus1 = bus1; - return (T) this; - } - - public T setConnectableBus1(String connectableBus1) { - this.connectableBus1 = connectableBus1; - return (T) this; - } - - public T setVoltageLevel1(String voltageLevelId1) { - this.voltageLevelId1 = voltageLevelId1; - return (T) this; - } - - protected TerminalExt checkAndGetTerminal1(String id) { - return new TerminalBuilder(getNetwork().getRef(), this) - .setNode(node1) - .setBus(bus1) - .setConnectableBus(connectableBus1) - .build(); - } - - protected VoltageLevelExt checkAndGetVoltageLevel1(String id) { - if (voltageLevelId1 == null) { - throw new ValidationException(this, "first voltage level is not set"); - } - VoltageLevelExt voltageLevel1 = getNetwork().getVoltageLevel(voltageLevelId1); - if (voltageLevel1 == null) { - throw new ValidationException(this, "first voltage level '" - + voltageLevelId1 + "' not found"); - } - return voltageLevel1; - } - - public T setNode2(int node2) { - this.node2 = node2; - return (T) this; - } - - public T setBus2(String bus2) { - this.bus2 = bus2; - return (T) this; - } - - public T setConnectableBus2(String connectableBus2) { - this.connectableBus2 = connectableBus2; - return (T) this; - } - - public T setVoltageLevel2(String voltageLevelId2) { - this.voltageLevelId2 = voltageLevelId2; - return (T) this; - } - - protected TerminalExt checkAndGetTerminal2(String id) { - return new TerminalBuilder(getNetwork().getRef(), this) - .setNode(node2) - .setBus(bus2) - .setConnectableBus(connectableBus2) - .build(); - } - - protected VoltageLevelExt checkAndGetVoltageLevel2(String id) { - if (voltageLevelId2 == null) { - throw new ValidationException(this, "second voltage level is not set"); - } - VoltageLevelExt voltageLevel2 = getNetwork().getVoltageLevel(voltageLevelId2); - if (voltageLevel2 == null) { - throw new ValidationException(this, "second voltage level '" - + voltageLevelId2 + "' not found"); - } - return voltageLevel2; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerAdderImpl.java deleted file mode 100644 index 097fd63e..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerAdderImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.TwoWindingsTransformer; -import eu.itesla_project.iidm.network.TwoWindingsTransformerAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class TwoWindingsTransformerAdderImpl extends TwoTerminalsConnectableAdderImpl implements TwoWindingsTransformerAdder { - - private final SubstationImpl substation; - - private float r = Float.NaN; - - private float x = Float.NaN; - - private float g = Float.NaN; - - private float b = Float.NaN; - - private float ratedU1 = Float.NaN; - - private float ratedU2 = Float.NaN; - - TwoWindingsTransformerAdderImpl(SubstationImpl substation) { - this.substation = substation; - } - - @Override - protected NetworkImpl getNetwork() { - return substation.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "2 windings transformer"; - } - - @Override - public TwoWindingsTransformerAdder setR(float r) { - this.r = r; - return this; - } - - @Override - public TwoWindingsTransformerAdder setX(float x) { - this.x = x; - return this; - } - - @Override - public TwoWindingsTransformerAdder setB(float b) { - this.b = b; - return this; - } - - @Override - public TwoWindingsTransformerAdder setG(float g) { - this.g = g; - return this; - } - - @Override - public TwoWindingsTransformerAdder setRatedU1(float ratedU1) { - this.ratedU1 = ratedU1; - return this; - } - - @Override - public TwoWindingsTransformerAdder setRatedU2(float ratedU2) { - this.ratedU2 = ratedU2; - return this; - } - - @Override - public TwoWindingsTransformer add() { - String id = checkAndGetUniqueId(); - VoltageLevelExt voltageLevel1 = checkAndGetVoltageLevel1(id); - VoltageLevelExt voltageLevel2 = checkAndGetVoltageLevel2(id); - if (voltageLevel1.getSubstation() != substation || voltageLevel2.getSubstation() != substation) { - throw new ValidationException(this, - "the 2 windings of the transformer shall belong to the substation '" - + substation.getId() + "' ('" + voltageLevel1.getSubstation().getId() + "', '" - + voltageLevel2.getSubstation().getId() + "')"); - } - TerminalExt terminal1 = checkAndGetTerminal1(id); - TerminalExt terminal2 = checkAndGetTerminal2(id); - - ValidationUtil.checkR(this, r); - ValidationUtil.checkX(this, x); - ValidationUtil.checkG(this, g); - ValidationUtil.checkB(this, b); - ValidationUtil.checkRatedU1(this, ratedU1); - ValidationUtil.checkRatedU2(this, ratedU2); - - TwoWindingsTransformerImpl transformer - = new TwoWindingsTransformerImpl(id, getName(), - voltageLevel1.getSubstation(), - r, x, g, b, - ratedU1, ratedU2); - terminal1.setNum(1); - terminal2.setNum(2); - transformer.addTerminal(terminal1); - transformer.addTerminal(terminal2); - - // check that the two windings transformer is attachable on both side - voltageLevel1.attach(terminal1, true); - voltageLevel2.attach(terminal2, true); - - voltageLevel1.attach(terminal1, false); - voltageLevel2.attach(terminal2, false); - getNetwork().getObjectStore().checkAndAdd(transformer); - getNetwork().getListeners().notifyCreation(transformer); - return transformer; - - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerImpl.java deleted file mode 100644 index a4d91c55..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/TwoWindingsTransformerImpl.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ConnectableType; -import eu.itesla_project.iidm.network.Identifiable; -import eu.itesla_project.iidm.network.TwoWindingsTransformer; - -/** - * - * @author Geoffroy Jamgotchian - */ -class TwoWindingsTransformerImpl extends AbstractTwoTerminalsConnectable implements TwoWindingsTransformer, RatioTapChangerParent { - - private final SubstationImpl substation; - - private float r; - - private float x; - - private float g; - - private float b; - - private float ratedU1; - - private float ratedU2; - - private RatioTapChangerImpl ratioTapChanger; - - private PhaseTapChangerImpl phaseTapChanger; - - TwoWindingsTransformerImpl(String id, String name, - SubstationImpl substation, - float r, float x, float g, float b, float ratedU1, float ratedU2) { - super(id, name); - this.substation = substation; - this.r = r; - this.x = x; - this.g = g; - this.b = b; - this.ratedU1 = ratedU1; - this.ratedU2 = ratedU2; - } - - @Override - public ConnectableType getType() { - return ConnectableType.TWO_WINDINGS_TRANSFORMER; - } - - @Override - public SubstationImpl getSubstation() { - return substation; - } - - @Override - public float getR() { - return r; - } - - @Override - public TwoWindingsTransformerImpl setR(float r) { - ValidationUtil.checkR(this, r); - float oldValue = this.r; - this.r = r; - notifyUpdate("r", oldValue, r); - return this; - } - - @Override - public float getX() { - return x; - } - - @Override - public TwoWindingsTransformerImpl setX(float x) { - ValidationUtil.checkX(this, x); - float oldValue = this.x; - this.x = x; - notifyUpdate("x", oldValue, x); - return this; - } - - @Override - public float getG() { - return g; - } - - @Override - public TwoWindingsTransformerImpl setG(float g) { - ValidationUtil.checkG(this, g); - float oldValue = this.g; - this.g = g; - notifyUpdate("g", oldValue, g); - return this; - } - - @Override - public float getB() { - return b; - } - - @Override - public TwoWindingsTransformerImpl setB(float b) { - ValidationUtil.checkB(this, b); - float oldValue = this.b; - this.b = b; - notifyUpdate("b", oldValue, b); - return this; - } - - @Override - public float getRatedU1() { - return ratedU1; - } - - @Override - public TwoWindingsTransformerImpl setRatedU1(float ratedU1) { - ValidationUtil.checkRatedU1(this, ratedU1); - float oldValue = this.ratedU1; - this.ratedU1 = ratedU1; - notifyUpdate("ratedU1", oldValue, ratedU1); - return this; - } - - @Override - public float getRatedU2() { - return ratedU2; - } - - @Override - public TwoWindingsTransformerImpl setRatedU2(float ratedU2) { - ValidationUtil.checkRatedU2(this, ratedU2); - float oldValue = this.ratedU2; - this.ratedU2 = ratedU2; - notifyUpdate("ratedU2", oldValue, ratedU2); - return this; - } - - @Override - public RatioTapChangerAdderImpl newRatioTapChanger() { - return new RatioTapChangerAdderImpl(this); - } - - @Override - public RatioTapChangerImpl getRatioTapChanger() { - return ratioTapChanger; - } - - @Override - public PhaseTapChangerAdderImpl newPhaseTapChanger() { - return new PhaseTapChangerAdderImpl(this); - } - - @Override - public PhaseTapChangerImpl getPhaseTapChanger() { - return phaseTapChanger; - } - - @Override - public NetworkImpl getNetwork() { - return substation.getNetwork(); - } - - @Override - public void setRatioTapChanger(RatioTapChangerImpl ratioTapChanger) { - this.ratioTapChanger = ratioTapChanger; - } - - void setPhaseTapChanger(PhaseTapChangerImpl phaseTapChanger) { - this.phaseTapChanger = phaseTapChanger; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - if (ratioTapChanger != null) { - ratioTapChanger.extendStateArraySize(initStateArraySize, number, sourceIndex); - } - if (phaseTapChanger != null) { - phaseTapChanger.extendStateArraySize(initStateArraySize, number, sourceIndex); - } - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - if (ratioTapChanger != null) { - ratioTapChanger.reduceStateArraySize(number); - } - if (phaseTapChanger != null) { - phaseTapChanger.reduceStateArraySize(number); - } - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - if (ratioTapChanger != null) { - ratioTapChanger.deleteStateArrayElement(index); - } - if (phaseTapChanger != null) { - phaseTapChanger.deleteStateArrayElement(index); - } - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - if (ratioTapChanger != null) { - ratioTapChanger.allocateStateArrayElement(indexes, sourceIndex); - } - if (phaseTapChanger != null) { - phaseTapChanger.allocateStateArrayElement(indexes, sourceIndex); - } - } - - public Identifiable getTransformer() { - return this; - } - - @Override - public String getTapChangerAttribute() { - return "ratioTapChanger"; - } - - @Override - protected String getTypeDescription() { - return "2 windings transformer"; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Validable.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Validable.java deleted file mode 100644 index 1087a678..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/Validable.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Validable { - - String getMessageHeader(); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationException.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationException.java deleted file mode 100644 index c9bf5d5a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationException.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.commons.ITeslaException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ValidationException extends ITeslaException { - - ValidationException(Validable validable, String msg) { - super(validable.getMessageHeader() + msg); - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationUtil.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationUtil.java deleted file mode 100644 index f92c2f90..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/ValidationUtil.java +++ /dev/null @@ -1,338 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.joda.time.DateTime; - -/** - * @author Geoffroy Jamgotchian - */ -public class ValidationUtil { - - private ValidationUtil() { - } - - @Deprecated - static void checkTargetP(Validable validable, float targetP) { - checkActivePowerSetPoint(validable, targetP); - } - - static void checkActivePowerSetPoint(Validable validable, float activePowerSetPoint) { - if (Float.isNaN(activePowerSetPoint)) { - throw new ValidationException(validable, "invalid value (" + activePowerSetPoint - + ") for active power set point"); - } - } - - static void checkActiveLimits(Validable validable, float minP, float maxP) { - if (minP > maxP) { - throw new ValidationException(validable, - "invalid active limits [" + minP + ", " + maxP + "]"); - } - } - - static void checkVoltageControl(Validable validable, Boolean voltageRegulatorOn, float voltageSetPoint, float reactivePowerSetPoint) { - if (voltageRegulatorOn == null) { - throw new ValidationException(validable, "voltage regulator status is not set"); - } - if (voltageRegulatorOn) { - if (Float.isNaN(voltageSetPoint) || voltageSetPoint <= 0) { - throw new ValidationException(validable, - "invalid value (" + voltageSetPoint + ") for voltage set point (voltage regulator is on)"); - } - } else { - if (Float.isNaN(reactivePowerSetPoint)) { - throw new ValidationException(validable, "invalid value (" + reactivePowerSetPoint - + ") for reactive power set point (voltage regulator is off)"); - } - } - } - - static void checkRatedS(Validable validable, float ratedS) { - if (!Float.isNaN(ratedS) && ratedS <= 0) { - throw new ValidationException(validable, "Invalid value of rated S " + ratedS); - } - } - - static void checkEnergySource(Validable validable, EnergySource energySource) { - if (energySource == null) { - throw new ValidationException(validable, "energy source is not set"); - } - } - - static void checkMinP(Validable validable, float minP) { - if (Float.isNaN(minP)) { - throw new ValidationException(validable, "invalid value (" + minP - + ") for minimum P"); - } - } - - static void checkMaxP(Validable validable, float maxP) { - if (Float.isNaN(maxP)) { - throw new ValidationException(validable, "invalid value (" + maxP - + ") for maximum P"); - } - } - - static void checkRegulatingTerminal(Validable validable, TerminalExt regulatingTerminal, NetworkImpl network) { - if (regulatingTerminal != null && regulatingTerminal.getVoltageLevel().getNetwork() != network) { - throw new ValidationException(validable, "regulating terminal is not part of the network"); - } - } - - - static void checkLoadType(Validable validable, LoadType loadType) { - if (loadType == null) { - throw new ValidationException(validable, "load type is null"); - } - } - - static void checkP0(Validable validable, float p0) { - if (Float.isNaN(p0)) { - throw new ValidationException(validable, "p0 is invalid"); - } - } - - static void checkQ0(Validable validable, float q0) { - if (Float.isNaN(q0)) { - throw new ValidationException(validable, "q0 is invalid"); - } - } - - static void checkR(Validable validable, float r) { - if (Float.isNaN(r)) { - throw new ValidationException(validable, "r is invalid"); - } - } - - static void checkX(Validable validable, float x) { - if (Float.isNaN(x)) { - throw new ValidationException(validable, "x is invalid"); - } - } - - static void checkG1(Validable validable, float g1) { - if (Float.isNaN(g1)) { - throw new ValidationException(validable, "g1 is invalid"); - } - } - - static void checkG2(Validable validable, float g2) { - if (Float.isNaN(g2)) { - throw new ValidationException(validable, "g2 is invalid"); - } - } - - static void checkB1(Validable validable, float b1) { - if (Float.isNaN(b1)) { - throw new ValidationException(validable, "b1 is invalid"); - } - } - - static void checkB2(Validable validable, float b2) { - if (Float.isNaN(b2)) { - throw new ValidationException(validable, "b2 is invalid"); - } - } - - static void checkG(Validable validable, float g) { - if (Float.isNaN(g)) { - throw new ValidationException(validable, "g is invalid"); - } - } - - static void checkB(Validable validable, float b) { - if (Float.isNaN(b)) { - throw new ValidationException(validable, "b is invalid"); - } - } - - static void checkCountry(Validable validable, Country country) { - if (country == null) { - throw new ValidationException(validable, "country is invalid"); - } - } - - static void checkNominalV(Validable validable, float nominalV) { - if (Float.isNaN(nominalV) || nominalV <= 0) { - throw new ValidationException(validable, "nominal voltage is invalid"); - } - } - - static void checkVoltageLimits(Validable validable, float lowVoltageLimit, float highVoltageLimit) { - if (lowVoltageLimit < 0) { - throw new ValidationException(validable, "low voltage limit is < 0"); - } - if (highVoltageLimit < 0) { - throw new ValidationException(validable, "high voltage limit is < 0"); - } - if (lowVoltageLimit >= highVoltageLimit) { - throw new ValidationException(validable, "Inconsistent voltage limit range [" - + lowVoltageLimit + ", " + highVoltageLimit + "]"); - } - } - - static void checkTopologyKind(Validable validable, TopologyKind topologyKind) { - if (topologyKind == null) { - throw new ValidationException(validable, "topology kind is invalid"); - } - } - - static void checkCaseDate(Validable validable, DateTime caseDate) { - if (caseDate == null) { - throw new ValidationException(validable, "case date is invalid"); - } - } - - static void checkForecastDistance(Validable validable, int forecastDistance) { - if (forecastDistance < 0) { - throw new ValidationException(validable, "forecast distance < 0"); - } - } - - static void checkbPerSection(Validable validable, float bPerSection) { - if (Float.isNaN(bPerSection)) { - throw new ValidationException(validable, "susceptance per section is invalid"); - } - if (bPerSection == 0) { - throw new ValidationException(validable, "susceptance per section is equal to zero"); - } - } - - static void checkSections(Validable validable, int currentSectionCount, int maximumSectionCount) { - if (currentSectionCount < 0) { - throw new ValidationException(validable, - "the current number of section (" + currentSectionCount - + ") should be greater than or equal to 0"); - } - if (maximumSectionCount <= 0) { - throw new ValidationException(validable, - "the maximum number of section (" + maximumSectionCount - + ")should be greater than 0"); - } - if (currentSectionCount > maximumSectionCount) { - throw new ValidationException(validable, - "the current number (" + currentSectionCount - + ") of section should be lesser than the maximum number of section (" - + maximumSectionCount + ")"); - } - } - - static void checkRatedU1(Validable validable, float ratedU1) { - if (Float.isNaN(ratedU1)) { - throw new ValidationException(validable, "rated U1 is invalid"); - } - } - - static void checkRatedU2(Validable validable, float ratedU2) { - if (Float.isNaN(ratedU2)) { - throw new ValidationException(validable, "rated U2 is invalid"); - } - } - - static void checkSvcRegulator(Validable validable, float voltageSetPoint, float reactivePowerSetPoint, StaticVarCompensator.RegulationMode regulationMode) { - if (regulationMode == null) { - throw new ValidationException(validable, "Regulation mode is invalid"); - } - switch (regulationMode) { - case VOLTAGE: - if (Float.isNaN(voltageSetPoint)) { - throw new ValidationException(validable, "invalid value (" + voltageSetPoint - + ") for voltage set point"); - } - break; - - case REACTIVE_POWER: - if (Float.isNaN(reactivePowerSetPoint)) { - throw new ValidationException(validable, "invalid value (" + reactivePowerSetPoint - + ") for reactive power set point"); - } - break; - - case OFF: - // nothing to check - break; - - default: - throw new AssertionError(); - } - - } - - static void checkBmin(Validable validable, float bMin) { - if (Float.isNaN(bMin)) { - throw new ValidationException(validable, "bmin is invalid"); - } - } - - static void checkBmax(Validable validable, float bMax) { - if (Float.isNaN(bMax)) { - throw new ValidationException(validable, "bmax is invalid"); - } - } - - static void checkRatioTapChangerRegulation(Validable validable, boolean loadTapChangingCapabilities, boolean regulating, - Terminal regulationTerminal, float targetV, Network network) { - if (loadTapChangingCapabilities) { - if (regulating) { - if (Float.isNaN(targetV)) { - throw new ValidationException(validable, - "a target voltage has to be set for a regulating ratio tap changer"); - } - if (targetV <= 0) { - throw new ValidationException(validable, "bad target voltage " + targetV); - } - if (regulationTerminal == null) { - throw new ValidationException(validable, - "a regulation terminal has to be set for a regulating ratio tap changer"); - } - if (regulationTerminal.getVoltageLevel().getSubstation().getNetwork() != network) { - throw new ValidationException(validable, "regulation terminal is not part of the network"); - } - } - } - } - - static void checkPhaseTapChangerRegulation(Validable validable, PhaseTapChanger.RegulationMode regulationMode, - float regulationValue, boolean regulating, Terminal regulationTerminal, - Network network) { - if (regulationMode == null) { - throw new ValidationException(validable, "phase regulation mode is not set"); - } - if (regulationMode != PhaseTapChanger.RegulationMode.FIXED_TAP && Float.isNaN(regulationValue)) { - throw new ValidationException(validable, "phase regulation is on and threshold/setpoint value is not set"); - } - if (regulationMode != PhaseTapChanger.RegulationMode.FIXED_TAP && regulationTerminal == null) { - throw new ValidationException(validable, "phase regulation is on and regulated terminal is not set"); - } - if (regulationTerminal != null && regulationTerminal.getVoltageLevel().getSubstation().getNetwork() != network) { - throw new ValidationException(validable, "phase regulation terminal is not part of the network"); - } - if (regulationMode == PhaseTapChanger.RegulationMode.FIXED_TAP && regulating) { - throw new ValidationException(validable, "phase regulation cannot be on if mode is FIXED"); - } - } - - static void checkConvertersMode(Validable validable, HvdcLine.ConvertersMode converterMode) { - if (converterMode == null) { - throw new ValidationException(validable, "converter mode is invalid"); - } - } - - static void checkPowerFactor(Validable validable, float powerFactor) { - if (Float.isNaN(powerFactor)) { - throw new ValidationException(validable, "power factor is invalid"); - } - } - - static void checkConnected(Validable validable, Boolean connected) { - if (connected == null) { - throw new ValidationException(validable, "connection status is invalid"); - } - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelAdderImpl.java deleted file mode 100644 index 4a07ecd8..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelAdderImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.TopologyKind; -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.VoltageLevelAdder; - -/** - * - * @author Geoffroy Jamgotchian - */ -class VoltageLevelAdderImpl extends IdentifiableAdderImpl implements VoltageLevelAdder { - - private final SubstationImpl substation; - - private float nominalV = Float.NaN; - - private float lowVoltageLimit = Float.NaN; - - private float highVoltageLimit = Float.NaN; - - private TopologyKind topologyKind; - - VoltageLevelAdderImpl(SubstationImpl substation) { - this.substation = substation; - } - - @Override - protected NetworkImpl getNetwork() { - return substation.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return "Voltage level"; - } - - @Override - public VoltageLevelAdder setNominalV(float nominalV) { - this.nominalV = nominalV; - return this; - } - - @Override - public VoltageLevelAdder setLowVoltageLimit(float lowVoltageLimit) { - this.lowVoltageLimit = lowVoltageLimit; - return this; - } - - @Override - public VoltageLevelAdder setHighVoltageLimit(float highVoltageLimit) { - this.highVoltageLimit = highVoltageLimit; - return this; - } - - @Override - public VoltageLevelAdder setTopologyKind(String topologyKind) { - this.topologyKind = TopologyKind.valueOf(topologyKind); - return this; - } - - @Override - public VoltageLevelAdder setTopologyKind(TopologyKind topologyKind) { - this.topologyKind = topologyKind; - return this; - } - - @Override - public VoltageLevel add() { - String id = checkAndGetUniqueId(); - // TODO : ckeck that there are not another voltage level with same base voltage - - ValidationUtil.checkNominalV(this, nominalV); - ValidationUtil.checkVoltageLimits(this, lowVoltageLimit, highVoltageLimit); - ValidationUtil.checkTopologyKind(this, topologyKind); - - VoltageLevelExt voltageLevel; - switch (topologyKind) { - case NODE_BREAKER: - voltageLevel = new NodeBreakerVoltageLevel(id, getName(), substation, nominalV, lowVoltageLimit, highVoltageLimit); - break; - case BUS_BREAKER: - voltageLevel = new BusBreakerVoltageLevel(id, getName(), substation, nominalV, lowVoltageLimit, highVoltageLimit); - break; - default: - throw new AssertionError(); - } - getNetwork().getObjectStore().checkAndAdd(voltageLevel); - substation.addVoltageLevel(voltageLevel); - getNetwork().getListeners().notifyCreation(voltageLevel); - return voltageLevel; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelExt.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelExt.java deleted file mode 100644 index bb376451..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VoltageLevelExt.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Connectable; -import eu.itesla_project.iidm.network.VoltageLevel; - -/** - * - * @author Geoffroy Jamgotchian - */ -interface VoltageLevelExt extends VoltageLevel, Stateful { - - interface NodeBreakerViewExt extends NodeBreakerView { - - } - - interface BusBreakerViewExt extends BusBreakerView { - - @Override BusExt getBus(String id); - - } - - interface BusViewExt extends BusView { - - @Override BusExt getBus(String id); - - } - - @Override NodeBreakerViewExt getNodeBreakerView(); - - @Override BusBreakerViewExt getBusBreakerView(); - - @Override BusViewExt getBusView(); - - Iterable getConnectables(Class clazz); - - int getConnectableCount(Class clazz); - - @Override SubstationImpl getSubstation(); - - NetworkImpl getNetwork(); - - /** - * Attach an equipment to the topology. - */ - void attach(TerminalExt terminal, boolean test); - - /** - * Detach an equipment from the topology. - */ - void detach(TerminalExt terminal); - - void clean(); - - boolean connect(TerminalExt terminal); - - boolean disconnect(TerminalExt terminal); - - void invalidateCache(); -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationAdderImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationAdderImpl.java deleted file mode 100644 index d6c6bb1a..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationAdderImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.VscConverterStationAdder; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class VscConverterStationAdderImpl extends SingleTerminalConnectableAdderImpl implements VscConverterStationAdder { - - private final VoltageLevelExt voltageLevel; - - private Boolean voltageRegulatorOn; - - private float reactivePowerSetPoint = Float.NaN; - - private float voltageSetPoint = Float.NaN; - - VscConverterStationAdderImpl(VoltageLevelExt voltageLevel) { - this.voltageLevel = voltageLevel; - } - - @Override - protected NetworkImpl getNetwork() { - return voltageLevel.getNetwork(); - } - - @Override - protected String getTypeDescription() { - return VscConverterStationImpl.TYPE_DESCRIPTION; - } - - @Override - public VscConverterStationAdderImpl setVoltageRegulatorOn(boolean voltageRegulatorOn) { - this.voltageRegulatorOn = voltageRegulatorOn; - return this; - } - - @Override - public VscConverterStationAdderImpl setVoltageSetPoint(float voltageSetPoint) { - this.voltageSetPoint = voltageSetPoint; - return this; - } - - @Override - public VscConverterStationAdderImpl setReactivePowerSetPoint(float reactivePowerSetPoint) { - this.reactivePowerSetPoint = reactivePowerSetPoint; - return this; - } - - @Override - public VscConverterStationImpl add() { - String id = checkAndGetUniqueId(); - String name = getName(); - TerminalExt terminal = checkAndGetTerminal(id); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn, voltageSetPoint, reactivePowerSetPoint); - VscConverterStationImpl converterStation - = new VscConverterStationImpl(id, name, getNetwork().getRef(), voltageRegulatorOn, reactivePowerSetPoint, voltageSetPoint); - converterStation.addTerminal(terminal); - voltageLevel.attach(terminal, false); - getNetwork().getObjectStore().checkAndAdd(converterStation); - getNetwork().getListeners().notifyCreation(converterStation); - return converterStation; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationImpl.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationImpl.java deleted file mode 100644 index 039288f9..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/VscConverterStationImpl.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ReactiveLimits; -import eu.itesla_project.iidm.network.VscConverterStation; -import eu.itesla_project.iidm.network.impl.util.Ref; -import gnu.trove.list.array.TFloatArrayList; - -import java.util.BitSet; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class VscConverterStationImpl extends HvdcConverterStationImpl implements VscConverterStation, ReactiveLimitsOwner { - - static final String TYPE_DESCRIPTION = "vscConverterStation"; - - private ReactiveLimits reactiveLimits; - - private final BitSet voltageRegulatorOn; - - private final TFloatArrayList reactivePowerSetPoint; - - private final TFloatArrayList voltageSetPoint; - - VscConverterStationImpl(String id, String name, Ref ref, boolean voltageRegulatorOn, - float reactivePowerSetPoint, float voltageSetPoint) { - super(id, name); - int stateArraySize = ref.get().getStateManager().getStateArraySize(); - this.voltageRegulatorOn = new BitSet(stateArraySize); - this.reactivePowerSetPoint = new TFloatArrayList(stateArraySize); - this.voltageSetPoint = new TFloatArrayList(stateArraySize); - this.voltageRegulatorOn.set(0, stateArraySize, voltageRegulatorOn); - this.reactivePowerSetPoint.fill(0, stateArraySize, reactivePowerSetPoint); - this.voltageSetPoint.fill(0, stateArraySize, voltageSetPoint); - this.reactiveLimits = new MinMaxReactiveLimitsImpl(-Float.MAX_VALUE, Float.MAX_VALUE); - } - - @Override - public HvdcType getHvdcType() { - return HvdcType.VSC; - } - - @Override - protected String getTypeDescription() { - return TYPE_DESCRIPTION; - } - - @Override - public boolean isVoltageRegulatorOn() { - return voltageRegulatorOn.get(getNetwork().getStateIndex()); - } - - @Override - public VscConverterStationImpl setVoltageRegulatorOn(boolean voltageRegulatorOn) { - int stateIndex = getNetwork().getStateIndex(); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn, voltageSetPoint.get(stateIndex), reactivePowerSetPoint.get(stateIndex)); - boolean oldValue = this.voltageRegulatorOn.get(stateIndex); - this.voltageRegulatorOn.set(stateIndex, voltageRegulatorOn); - notifyUpdate("voltageRegulatorOn", oldValue, voltageRegulatorOn); - return this; - } - - @Override - public float getVoltageSetPoint() { - return this.voltageSetPoint.get(getNetwork().getStateIndex()); - } - - @Override - public VscConverterStationImpl setVoltageSetPoint(float targetV) { - int stateIndex = getNetwork().getStateIndex(); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn.get(stateIndex), targetV, reactivePowerSetPoint.get(stateIndex)); - float oldValue = this.voltageSetPoint.set(stateIndex, targetV); - notifyUpdate("voltageSetPoint", oldValue, targetV); - return this; - } - - @Override - public float getReactivePowerSetPoint() { - return reactivePowerSetPoint.get(getNetwork().getStateIndex()); - } - - @Override - public VscConverterStationImpl setReactivePowerSetPoint(float targetQ) { - int stateIndex = getNetwork().getStateIndex(); - ValidationUtil.checkVoltageControl(this, voltageRegulatorOn.get(stateIndex), voltageSetPoint.get(stateIndex), targetQ); - float oldValue = this.reactivePowerSetPoint.set(stateIndex, targetQ); - notifyUpdate("reactivePowerSetPoint", oldValue, targetQ); - return this; - } - - @Override - public ReactiveCapabilityCurveAdderImpl newReactiveCapabilityCurve() { - return new ReactiveCapabilityCurveAdderImpl(this); - } - - @Override - public MinMaxReactiveLimitsAdderImpl newMinMaxReactiveLimits() { - return new MinMaxReactiveLimitsAdderImpl(this); - } - - @Override - public void setReactiveLimits(ReactiveLimits reactiveLimits) { - this.reactiveLimits = reactiveLimits; - } - - @Override - public ReactiveLimits getReactiveLimits() { - return reactiveLimits; - } - - @Override - public RL getReactiveLimits(Class type) { - if (type == null) { - throw new IllegalArgumentException("type is null"); - } - if (type.isInstance(reactiveLimits)) { - return type.cast(reactiveLimits); - } else { - throw new ValidationException(this, "incorrect reactive limits type " - + type.getName() + ", expected " + reactiveLimits.getClass()); - } - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - super.extendStateArraySize(initStateArraySize, number, sourceIndex); - - reactivePowerSetPoint.ensureCapacity(reactivePowerSetPoint.size() + number); - reactivePowerSetPoint.fill(initStateArraySize, initStateArraySize + number, reactivePowerSetPoint.get(sourceIndex)); - - voltageSetPoint.ensureCapacity(voltageSetPoint.size() + number); - voltageSetPoint.fill(initStateArraySize, initStateArraySize + number, voltageSetPoint.get(sourceIndex)); - - voltageRegulatorOn.set(initStateArraySize, initStateArraySize + number, voltageRegulatorOn.get(sourceIndex)); - } - - @Override - public void reduceStateArraySize(int number) { - super.reduceStateArraySize(number); - reactivePowerSetPoint.remove(reactivePowerSetPoint.size() - number, number); - voltageSetPoint.remove(voltageSetPoint.size() - number, number); - } - - @Override - public void deleteStateArrayElement(int index) { - super.deleteStateArrayElement(index); - // nothing to do - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - super.allocateStateArrayElement(indexes, sourceIndex); - for (int index : indexes) { - voltageRegulatorOn.set(index, voltageRegulatorOn.get(sourceIndex)); - reactivePowerSetPoint.set(index, reactivePowerSetPoint.get(sourceIndex)); - voltageSetPoint.set(index, voltageSetPoint.get(sourceIndex)); - } - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutors.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutors.java deleted file mode 100644 index fbe2eabb..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutors.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl.util; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import eu.itesla_project.iidm.network.impl.ThreadLocalMultiStateContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.*; - -/** - * Thread pool executors that reset the current network state each time a thread go back to the pool. - * - * @author Geoffroy Jamgotchian - */ -public class MultiStateNetworkAwareExecutors { - - private static final Logger LOGGER = LoggerFactory.getLogger(MultiStateNetworkAwareExecutors.class); - - private static final String DEFAULT_POOL_NAME = "COMPUTATION_POOL"; - - private static ThreadFactory threadFactory(String poolName) { - return new ThreadFactoryBuilder() - .setNameFormat(poolName + "-%d") - .build(); - } - - public static ExecutorService newFixedThreadPool(int nThreads) { - return newFixedThreadPool(DEFAULT_POOL_NAME, nThreads); - } - - public static ExecutorService newFixedThreadPool(String poolName, int nThreads) { - return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), threadFactory(poolName)) { - @Override - protected void afterExecute(Runnable r, Throwable t) { - super.afterExecute(r, t); - ThreadLocalMultiStateContext.INSTANCE.reset(); - } - }; - } - - public static ExecutorService newCachedThreadPool() { - return newCachedThreadPool(DEFAULT_POOL_NAME); - } - - public static ExecutorService newCachedThreadPool(String poolName) { - return new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory(poolName)) { - @Override - protected void afterExecute(Runnable r, Throwable t) { - super.afterExecute(r, t); - ThreadLocalMultiStateContext.INSTANCE.reset(); - } - }; - } - - public static ExecutorService newSizeLimitedThreadPool(int maxSize) { - return newSizeLimitedThreadPool(DEFAULT_POOL_NAME, maxSize); - } - - public static ExecutorService newSizeLimitedThreadPool(String poolName, int maxSize) { - if (maxSize < 1) { - throw new IllegalArgumentException("Invalid bounded max size"); - } - ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(maxSize, maxSize, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), threadFactory(poolName)) { - @Override - protected void afterExecute(Runnable r, Throwable t) { - super.afterExecute(r, t); -// LOGGER.info("activeCount=" + getActiveCount() + " ,corePoolSize=" + getCorePoolSize() -// + " ,largestPoolSize=" + getLargestPoolSize() + " ,maximumPoolSize=" + getMaximumPoolSize()); - ThreadLocalMultiStateContext.INSTANCE.reset(); - if (t != null) { - LOGGER.error(t.toString(), t); - } - } - }; - threadPoolExecutor.allowCoreThreadTimeOut(true); - return threadPoolExecutor; - } -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/Ref.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/Ref.java deleted file mode 100644 index 4b2e8740..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/Ref.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl.util; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Ref { - - T get(); - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefChain.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefChain.java deleted file mode 100644 index 101afb1c..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefChain.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl.util; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class RefChain implements Ref { - - private Ref ref; - - public RefChain(Ref ref) { - this.ref = ref; - } - - @Override - public T get() { - return ref.get(); - } - - public void setRef(Ref ref) { - this.ref = ref; - } - -} diff --git a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefObj.java b/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefObj.java deleted file mode 100644 index bd8d8abe..00000000 --- a/iidm-network-impl/src/main/java/eu/itesla_project/iidm/network/impl/util/RefObj.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl.util; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class RefObj implements Ref { - - private T o; - - public RefObj(T o) { - this.o = o; - } - - @Override - public T get() { - return o; - } - - public void set(T o) { - this.o = o; - } -} diff --git a/iidm-network-impl/src/main/resources/META-INF/services/eu.itesla_project.iidm.network.NetworkFactoryService b/iidm-network-impl/src/main/resources/META-INF/services/eu.itesla_project.iidm.network.NetworkFactoryService deleted file mode 100644 index 2881f7c2..00000000 --- a/iidm-network-impl/src/main/resources/META-INF/services/eu.itesla_project.iidm.network.NetworkFactoryService +++ /dev/null @@ -1 +0,0 @@ -eu.itesla_project.iidm.network.impl.NetworkFactoryServiceImpl diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ConnectedComponentWithTieLineBugTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ConnectedComponentWithTieLineBugTest.java deleted file mode 100644 index bda2f848..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ConnectedComponentWithTieLineBugTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Geoffroy Jamgotchian - */ -public class ConnectedComponentWithTieLineBugTest { - - @Test - public void test() { - Network n = NetworkFactory.create("n", "test"); - Substation s1 = n.newSubstation() - .setId("s1") - .setCountry(Country.FR) - .add(); - VoltageLevel vl1 = s1.newVoltageLevel() - .setId("vl1") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - Bus b1 = vl1.getBusBreakerView().newBus() - .setId("b1") - .add(); - vl1.newGenerator() - .setId("g1") - .setBus("b1") - .setConnectableBus("b1") - .setTargetP(100f) - .setTargetV(400f) - .setVoltageRegulatorOn(true) - .setMinP(50f) - .setMaxP(150f) - .add(); - Substation s2 = n.newSubstation() - .setId("s2") - .setCountry(Country.BE) - .add(); - VoltageLevel vl2 = s2.newVoltageLevel() - .setId("vl2") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - Bus b2 = vl2.getBusBreakerView().newBus() - .setId("b2") - .add(); - vl2.newLoad() - .setId("ld1") - .setConnectableBus("b2") - .setBus("b2") - .setP0(0) - .setQ0(0) - .add(); - n.newTieLine() - .setId("l1 + l2") - .setVoltageLevel1("vl1") - .setConnectableBus1("b1") - .setBus1("b1") - .setVoltageLevel2("vl2") - .setConnectableBus2("b2") - .setBus2("b2") - .line1() - .setId("l1") - .setR(1f) - .setX(1f) - .setG1(0f) - .setG2(0f) - .setB1(0f) - .setB2(0f) - .setXnodeP(0) - .setXnodeQ(0) - .line2() - .setId("l2") - .setR(1f) - .setX(1f) - .setG1(0f) - .setG2(0f) - .setB1(0f) - .setB2(0f) - .setXnodeP(0) - .setXnodeQ(0) - .setUcteXnodeCode("XNODE") - .add(); - Assert.assertTrue(b1.getConnectedComponent().getNum() == 0); - Assert.assertTrue(b2.getConnectedComponent().getNum() == 0); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/CurrentLimitsTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/CurrentLimitsTest.java deleted file mode 100644 index ff95fdd7..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/CurrentLimitsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class CurrentLimitsTest { - - private Network createNetwork() { - Network network = NetworkFactory.create("test", "test"); - Substation s1 = network.newSubstation() - .setId("S1") - .setCountry(Country.FR) - .add(); - VoltageLevel vl1 = s1.newVoltageLevel() - .setId("VL1") - .setNominalV(400f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl1.getBusBreakerView().newBus() - .setId("B1") - .add(); - Substation s2 = network.newSubstation() - .setId("S2") - .setCountry(Country.FR) - .add(); - VoltageLevel vl2 = s2.newVoltageLevel() - .setId("VL2") - .setNominalV(400f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl2.getBusBreakerView().newBus() - .setId("B2") - .add(); - Line l = network.newLine() - .setId("L") - .setVoltageLevel1("VL1") - .setConnectableBus1("B1") - .setBus1("B1") - .setVoltageLevel2("VL2") - .setConnectableBus2("B2") - .setBus2("B2") - .setR(1) - .setX(1) - .setG1(0) - .setG2(0) - .setB1(0) - .setB2(0) - .add(); - l.newCurrentLimits1() - .setPermanentLimit(1000) - .beginTemporaryLimit() - .setName("20'") - .setAcceptableDuration(20 * 60) - .setValue(1200) - .endTemporaryLimit() - .beginTemporaryLimit() - .setName("5'") - .setAcceptableDuration(5 * 60) - .setValue(1400) - .endTemporaryLimit() - .beginTemporaryLimit() - .setName("1'") - .setAcceptableDuration(60) - .setValue(1600) - .endTemporaryLimit() - .add(); - return network; - } - - @Test - public void test() { - Network network = createNetwork(); - Line l = network.getLine("L"); - assertFalse(l.isOverloaded()); - l.getTerminal1().getBusBreakerView().getBus().setV(390); - l.getTerminal1().setP(100).setQ(50); // i = 165.51212 - assertTrue(!Float.isNaN(l.getTerminal1().getI())); - assertFalse(l.isOverloaded()); - assertFalse(l.checkPermanentLimit1()); - assertNull(l.checkTemporaryLimits1()); - - l.getTerminal1().setP(800).setQ(400); // i = 1324.0969 - assertTrue(l.isOverloaded()); - assertTrue(l.getOverloadDuration() == 5 * 60); - assertTrue(l.checkPermanentLimit1()); - assertNotNull(l.checkTemporaryLimits1()); - assertTrue(l.checkTemporaryLimits1().getTemporaryLimit().getAcceptableDuration() == 5 * 60); - assertTrue(l.checkTemporaryLimits1().getPreviousLimit() == 1200); - - l.getTerminal1().setP(900).setQ(500); // i = 1524.1499 - assertTrue(l.getOverloadDuration() == 60); - assertNotNull(l.checkTemporaryLimits1()); - assertTrue(l.checkTemporaryLimits1().getTemporaryLimit().getAcceptableDuration() == 60); - assertTrue(l.checkTemporaryLimits1().getPreviousLimit() == 1400); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ExceptionIsThrownWhenRemoveStateAndWorkingStateIsNotSetTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ExceptionIsThrownWhenRemoveStateAndWorkingStateIsNotSetTest.java deleted file mode 100644 index f390c147..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ExceptionIsThrownWhenRemoveStateAndWorkingStateIsNotSetTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.StateManager; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import org.junit.Assert; -import org.junit.Test; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * @author Geoffroy Jamgotchian - */ -public class ExceptionIsThrownWhenRemoveStateAndWorkingStateIsNotSetTest { - - @Test - public void test() throws Exception { - Network network = EurostagTutorialExample1Factory.create(); - network.getStateManager().allowStateMultiThreadAccess(true); - network.getStateManager().cloneState(StateManager.INITIAL_STATE_ID, "s"); - ExecutorService executorService = Executors.newSingleThreadExecutor(); - boolean[] exceptionThrown = new boolean[1]; - exceptionThrown[0] = false; - executorService.execute(() -> { - try { - network.getStateManager().removeState("s"); - } catch (Throwable e) { - exceptionThrown[0] = true; - } - }); - executorService.shutdown(); - executorService.awaitTermination(10, TimeUnit.SECONDS); - Assert.assertFalse(exceptionThrown[0]); - } - -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/IdentifiableExtensionTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/IdentifiableExtensionTest.java deleted file mode 100644 index 64dfd1fa..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/IdentifiableExtensionTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Identifiable; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import eu.itesla_project.iidm.network.test.LoadZipModel; -import org.junit.Test; - -import java.util.Objects; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class IdentifiableExtensionTest { - - public static class LoadFooModel implements Identifiable.Extension { - - private final Load load; - - public LoadFooModel(Load load) { - this.load = Objects.requireNonNull(load); - } - - @Override - public Load getIdentifiable() { - return load; - } - - @Override - public String getName() { - return "loadFooModel"; - } - } - - @Test - public void test() { - Network network = EurostagTutorialExample1Factory.create(); - Load load = network.getLoad("LOAD"); - assertTrue(load.getExtensions().isEmpty()); - LoadZipModel zipModel = new LoadZipModel(load, 1, 2, 3, 4, 5, 6, 380); - load.addExtension(LoadZipModel.class, zipModel); - assertTrue(zipModel != null); - assertTrue(load.getExtension(LoadZipModel.class) == zipModel); - assertTrue(load.getExtension(LoadFooModel.class) == null); - assertTrue(load.getExtensions().size() == 1); - assertArrayEquals(load.getExtensions().toArray(new Identifiable.Extension[0]), new Identifiable.Extension[] {zipModel}); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/LccTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/LccTest.java deleted file mode 100644 index e0fe6699..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/LccTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.HvdcLine; -import eu.itesla_project.iidm.network.LccConverterStation; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.test.HvdcTestNetwork; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class LccTest { - - @Test - public void testBase() { - Network network = HvdcTestNetwork.createLcc(); - LccConverterStation cs1 = (LccConverterStation) network.getHvdcConverterStation("C1"); - assertNotNull(cs1); - LccConverterStation cs2 = (LccConverterStation) network.getHvdcConverterStation("C2"); - assertNotNull(cs2); - assertTrue(network.getVoltageLevel("VL1").getLccConverterStationCount() == 1); - assertTrue(network.getVoltageLevel("VL2").getLccConverterStationCount() == 1); - assertTrue(cs1.getPowerFactor() == 0.5f); - assertTrue(cs2.getPowerFactor() == 0.6f); - assertTrue(cs1.getFilterCount() == 2); - assertTrue(cs1.getFilterAt(0).getB() == 0.00001f); - assertTrue(cs1.getFilterAt(0).isConnected()); - assertTrue(cs1.getFilterAt(1).getB() == 0.00002f); - assertFalse(cs1.getFilterAt(1).isConnected()); - assertTrue(cs2.getFilterCount() == 2); - assertTrue(cs2.getFilterAt(0).getB() == 0.00003f); - assertTrue(cs2.getFilterAt(0).isConnected()); - assertTrue(cs2.getFilterAt(1).getB() == 0.00004f); - assertTrue(cs2.getFilterAt(1).isConnected()); - assertTrue(network.getHvdcLineCount() == 1); - HvdcLine l = network.getHvdcLine("L"); - assertNotNull(l); - assertTrue(l.getR() == 1); - assertTrue(l.getConvertersMode() == HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER); - assertTrue(l.getMaxP() == 300); - assertTrue(l. getConverterStation1() == cs1); - assertTrue(l. getConverterStation2() == cs2); - } - - @Test - public void testHvdcLineRemove() { - Network network = HvdcTestNetwork.createLcc(); - network.getHvdcLine("L").remove(); - assertTrue(network.getHvdcLineCount() == 0); - } - - @Test - public void testFilterRemove() { - Network network = HvdcTestNetwork.createLcc(); - LccConverterStation cs1 = (LccConverterStation) network.getHvdcConverterStation("C1"); - cs1.removeFilterAt(0); - assertTrue(cs1.getFilterCount() == 1); - assertTrue(cs1.getFilterAt(0).getB() == 0.00002f); - assertFalse(cs1.getFilterAt(0).isConnected()); - } - - @Test - public void testAddInvalidFilter() { - try { - Network network = HvdcTestNetwork.createLcc(); - LccConverterStation cs1 = (LccConverterStation) network.getHvdcConverterStation("C1"); - cs1.newFilter().setB(1.0f).add(); - fail(); - } catch (ValidationException exc) { - } - - try { - Network network = HvdcTestNetwork.createLcc(); - LccConverterStation cs1 = (LccConverterStation) network.getHvdcConverterStation("C1"); - cs1.newFilter().setConnected(true).add(); - fail(); - } catch (ValidationException exc) { - } - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/MultiStateNetworkTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/MultiStateNetworkTest.java deleted file mode 100644 index 2cb5bbd1..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/MultiStateNetworkTest.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.StateManager; -import eu.itesla_project.iidm.network.Generator; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import java.util.Arrays; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import static org.junit.Assert.*; -import org.junit.Test; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class MultiStateNetworkTest { - - @Test - public void singleThreadTest() { - Network network = EurostagTutorialExample1Factory.create(); - final StateManager manager = network.getStateManager(); - manager.cloneState(StateManager.INITIAL_STATE_ID, "SecondState"); - manager.setWorkingState("SecondState"); - final Generator generator = network.getGenerator("GEN"); - generator.setVoltageRegulatorOn(false); - assertTrue(!generator.isVoltageRegulatorOn()); - manager.setWorkingState(StateManager.INITIAL_STATE_ID); - assertTrue(generator.isVoltageRegulatorOn()); - } - - @Test - public void multiThreadTest() throws InterruptedException { - final Network network = EurostagTutorialExample1Factory.create(); - final StateManager manager = network.getStateManager(); - manager.allowStateMultiThreadAccess(true); - - manager.cloneState(StateManager.INITIAL_STATE_ID, "SecondState"); - - final Generator generator = network.getGenerator("GEN"); - - manager.setWorkingState(StateManager.INITIAL_STATE_ID); - generator.setVoltageRegulatorOn(true); - - manager.setWorkingState("SecondState"); - generator.setVoltageRegulatorOn(false); - - final boolean[] voltageRegulatorOnInitialState = new boolean[1]; - final boolean[] voltageRegulatorOnSecondState = new boolean[1]; - final CountDownLatch latch = new CountDownLatch(2); // to sync threads after having set the working state - ExecutorService service = Executors.newFixedThreadPool(2); - service.invokeAll(Arrays.asList( - new Callable() { - @Override - public Void call() throws Exception { - manager.setWorkingState(StateManager.INITIAL_STATE_ID); - latch.countDown(); - latch.await(); - voltageRegulatorOnInitialState[0] = generator.isVoltageRegulatorOn(); - return null; - } - }, - new Callable() { - @Override - public Void call() throws Exception { - manager.setWorkingState("SecondState"); - latch.countDown(); - latch.await(); - voltageRegulatorOnSecondState[0] = generator.isVoltageRegulatorOn(); - return null; - } - }) - ); - service.shutdown(); - service.awaitTermination(1, TimeUnit.MINUTES); - assertTrue(voltageRegulatorOnInitialState[0]); - assertTrue(!voltageRegulatorOnSecondState[0]); - } - - @Test - public void multiStateTopologyTest() throws InterruptedException { - Network network = EurostagTutorialExample1Factory.create(); - StateManager manager = network.getStateManager(); - manager.cloneState(StateManager.INITIAL_STATE_ID, "NEW_STATE"); - VoltageLevel vlload = network.getVoltageLevel("VLLOAD"); - Bus nload = vlload.getBusBreakerView().getBus("NLOAD"); - Load newLoad = vlload.newLoad() - .setId("NEW_LOAD") - .setP0(10) - .setQ0(10) - .setBus("NLOAD") - .setConnectableBus("NLOAD") - .add(); - manager.setWorkingState("NEW_STATE"); - assertTrue(newLoad.getTerminal().getBusBreakerView().getBus() != null); - assertTrue(Iterables.size(nload.getLoads()) == 2); - newLoad.getTerminal().disconnect(); - assertTrue(newLoad.getTerminal().getBusBreakerView().getBus() == null); - assertTrue(Iterables.size(vlload.getLoads()) == 2); - assertTrue(Iterables.size(nload.getLoads()) == 1); - manager.setWorkingState(StateManager.INITIAL_STATE_ID); - assertTrue(newLoad.getTerminal().getBusBreakerView().getBus() != null); - assertTrue(Iterables.size(vlload.getLoads()) == 2); - assertTrue(Iterables.size(nload.getLoads()) == 2); - } - - @Test - public void stateNotSetTest() throws InterruptedException { - Network network = EurostagTutorialExample1Factory.create(); - StateManager manager = network.getStateManager(); - manager.allowStateMultiThreadAccess(true); - assertTrue(manager.getWorkingStateId().equals(StateManager.INITIAL_STATE_ID)); - ExecutorService service = Executors.newSingleThreadExecutor(); - service.submit(() -> { - try { - network.getGenerator("GEN").getTargetP(); - fail(); - } catch (Exception e) { - } - }); - service.shutdown(); - service.awaitTermination(1, TimeUnit.MINUTES); - } - - @Test - public void stateSetTest() throws InterruptedException { - Network network = EurostagTutorialExample1Factory.create(); - StateManager manager = network.getStateManager(); - manager.allowStateMultiThreadAccess(true); - assertTrue(manager.getWorkingStateId().equals(StateManager.INITIAL_STATE_ID)); - ExecutorService service = Executors.newSingleThreadExecutor(); - service.submit(() -> { - try { - manager.setWorkingState(StateManager.INITIAL_STATE_ID); - network.getGenerator("GEN").getTargetP(); - } catch (Exception e) { - fail(); - } - }); - service.shutdown(); - service.awaitTermination(1, TimeUnit.MINUTES); - } - -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkRemoveTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkRemoveTest.java deleted file mode 100644 index 5a060072..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkRemoveTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.Line; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class NetworkRemoveTest { - - private Network network; - - @Before - public void setUp() { - network = EurostagTutorialExample1Factory.create(); - } - - @After - public void tearDown() { - network = null; - } - - @Test - public void removeLineTest() { - String id = "NHV1_NHV2_1"; - Line l = network.getLine(id); - assertTrue(network.getLineCount() == 2); - l.remove(); - assertTrue(network.getLineCount() == 1); - assertTrue(network.getLine(id) == null); - } - - @Test - public void moveLoadToNewBus() { - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - vl.getBusBreakerView().newBus() - .setId("NEW_BUS") - .add(); - Load l = network.getLoad("LOAD"); - assertTrue(l.getTerminal().getBusBreakerView().getBus().getId().equals("NLOAD")); - assertTrue(l.getTerminal().isConnected()); - l.getTerminal().getBusBreakerView().setConnectableBus("NEW_BUS"); - assertTrue(l.getTerminal().getBusBreakerView().getBus().getId().equals("NEW_BUS")); - assertTrue(l.getTerminal().isConnected()); - } - - private void extend(Network n) { - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - vl.getBusBreakerView().newBus() - .setId("NEW_BUS") - .add(); - vl.getBusBreakerView().newSwitch() - .setId("COUPL") - .setBus1("NLOAD") - .setBus2("NEW_BUS") - .setOpen(false) - .add(); - } - - @Test - public void removeAll() { - extend(network); - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - vl.getBusBreakerView().removeAllSwitches(); - network.getLoad("LOAD").remove(); - network.getTwoWindingsTransformer("NHV2_NLOAD").remove(); - vl.getBusBreakerView().removeAllBuses(); - assertTrue(Iterables.size(vl.getBusBreakerView().getBuses()) == 0); - assertTrue(Iterables.size(vl.getBusBreakerView().getSwitches()) == 0); - } - - @Test - public void removeBusFailure() { - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - try { - vl.getBusBreakerView().removeBus("NLOAD"); - fail(); - } catch (Exception e) { - } - } - - @Test - public void removeBus() { - network.getLoad("LOAD").remove(); - network.getTwoWindingsTransformer("NHV2_NLOAD").remove(); - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - vl.getBusBreakerView().removeBus("NLOAD"); - assertTrue(Iterables.size(vl.getBusBreakerView().getBuses()) == 0); - } - - @Test - public void removeBusFailureBecauseOfSwitch() { - extend(network); - network.getLoad("LOAD").remove(); - network.getTwoWindingsTransformer("NHV2_NLOAD").remove(); - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - try { - vl.getBusBreakerView().removeBus("NLOAD"); - fail(); - } catch (Exception e) { - } - } - - @Test - public void removeSwitchFailure() { - extend(network); - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - try { - vl.getBusBreakerView().removeSwitch("XXX"); - fail(); - } catch (Exception e) { - } - } - - @Test - public void removeSwitch() { - extend(network); - VoltageLevel vl = network.getVoltageLevel("VLLOAD"); - vl.getBusBreakerView().removeSwitch("COUPL"); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkTest.java deleted file mode 100644 index 8ede896e..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NetworkTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.VoltageLevel.NodeBreakerView; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import eu.itesla_project.iidm.network.test.NetworkTest1Factory; -import static org.junit.Assert.assertTrue; -import org.junit.Test; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class NetworkTest { - - public NetworkTest() { - } - - @Test - public void testNetwork1() { - Network network = NetworkTest1Factory.create(); - assertTrue(Iterables.size(network.getCountries()) == 1); - assertTrue(network.getCountryCount() == 1); - Country country1 = network.getCountries().iterator().next(); - - assertTrue(Iterables.size(network.getSubstations()) == 1); - assertTrue(network.getSubstationCount() == 1); - - Substation substation1 = network.getSubstation("substation1"); - assertTrue(substation1 != null); - assertTrue(substation1.getId().equals("substation1")); - assertTrue(substation1.getCountry() == country1); - assertTrue(substation1.getGeographicalTags().size() == 1); - assertTrue(substation1.getGeographicalTags().contains("region1")); - assertTrue(Iterables.size(network.getVoltageLevels()) == 1); - assertTrue(network.getVoltageLevelCount() == 1); - - VoltageLevel voltageLevel1 = network.getVoltageLevel("voltageLevel1"); - assertTrue(voltageLevel1 != null); - assertTrue(voltageLevel1.getId().equals("voltageLevel1")); - assertTrue(voltageLevel1.getNominalV() == 400); - assertTrue(voltageLevel1.getSubstation() == substation1); - assertTrue(voltageLevel1.getTopologyKind() == TopologyKind.NODE_BREAKER); - - NodeBreakerView topology1 = voltageLevel1.getNodeBreakerView(); - assertTrue(topology1.getNodeCount() == 10); - assertTrue(Iterables.size(topology1.getBusbarSections()) == 2); - assertTrue(topology1.getBusbarSectionCount() == 2); - - BusbarSection voltageLevel1BusbarSection1 = topology1.getBusbarSection("voltageLevel1BusbarSection1"); - assertTrue(voltageLevel1BusbarSection1 != null); - assertTrue(voltageLevel1BusbarSection1.getId().equals("voltageLevel1BusbarSection1")); - - BusbarSection voltageLevel1BusbarSection2 = topology1.getBusbarSection("voltageLevel1BusbarSection2"); - assertTrue(voltageLevel1BusbarSection2 != null); - assertTrue(voltageLevel1BusbarSection2.getId().equals("voltageLevel1BusbarSection2")); - assertTrue(Iterables.size(topology1.getSwitches()) == 5); - assertTrue(topology1.getSwitchCount() == 5); - - Switch voltageLevel1Breaker1 = topology1.getSwitch("voltageLevel1Breaker1"); - assertTrue(voltageLevel1Breaker1 != null); - assertTrue(voltageLevel1Breaker1.getId().equals("voltageLevel1Breaker1")); - assertTrue(!voltageLevel1Breaker1.isOpen()); - assertTrue(voltageLevel1Breaker1.isRetained()); - assertTrue(voltageLevel1Breaker1.getKind() == SwitchKind.BREAKER); - assertTrue(topology1.getNode1(voltageLevel1Breaker1.getId()) == voltageLevel1BusbarSection1.getTerminal().getNodeBreakerView().getNode()); - assertTrue(topology1.getNode2(voltageLevel1Breaker1.getId()) == voltageLevel1BusbarSection2.getTerminal().getNodeBreakerView().getNode()); - assertTrue(Iterables.size(voltageLevel1.getLoads()) == 1); - assertTrue(voltageLevel1.getLoadCount() == 1); - - Load load1 = network.getLoad("load1"); - assertTrue(load1 != null); - assertTrue(load1.getId().equals("load1")); - assertTrue(load1.getTerminal().getNodeBreakerView().getNode() == 2); - assertTrue(load1.getP0() == 10); - assertTrue(load1.getQ0() == 3); - - Generator generator1 = network.getGenerator("generator1"); - assertTrue(generator1 != null); - assertTrue(generator1.getId().equals("generator1")); - assertTrue(generator1.getTerminal().getNodeBreakerView().getNode() == 5); - assertTrue(generator1.getMinP() == 200); - assertTrue(generator1.getMaxP() == 900); - assertTrue(generator1.getEnergySource() == EnergySource.NUCLEAR); - assertTrue(generator1.isVoltageRegulatorOn()); - assertTrue(generator1.getTargetP() == 900); - assertTrue(generator1.getTargetV() == 380); - ReactiveCapabilityCurve rcc1 = generator1.getReactiveLimits(ReactiveCapabilityCurve.class); - assertTrue(rcc1.getPointCount() == 2); - assertTrue(rcc1.getMaxQ(500) == 500); - assertTrue(rcc1.getMinQ(500) == 300); - - assertTrue(Iterables.size(voltageLevel1.getBusBreakerView().getBuses()) == 2); - Bus busCalc1 = voltageLevel1BusbarSection1.getTerminal().getBusBreakerView().getBus(); - Bus busCalc2 = voltageLevel1BusbarSection2.getTerminal().getBusBreakerView().getBus(); - assertTrue(load1.getTerminal().getBusBreakerView().getBus() == busCalc1); - assertTrue(generator1.getTerminal().getBusBreakerView().getBus() == busCalc2); - assertTrue(busCalc1.getConnectedComponent().getNum() == 0); - assertTrue(busCalc2.getConnectedComponent().getNum() == 0); - - assertTrue(Iterables.size(voltageLevel1.getBusView().getBuses()) == 1); - Bus busCalc = voltageLevel1BusbarSection1.getTerminal().getBusView().getBus(); - assertTrue(busCalc == voltageLevel1BusbarSection2.getTerminal().getBusView().getBus()); - assertTrue(load1.getTerminal().getBusView().getBus() == busCalc); - assertTrue(generator1.getTerminal().getBusView().getBus() == busCalc); - assertTrue(busCalc.getConnectedComponent().getNum() == 0); - } - - @Test - public void testVoltageLevelGetConnectable() { - Network n = EurostagTutorialExample1Factory.create(); - assertTrue(n.getVoltageLevel("VLLOAD").getConnectable("LOAD", Load.class) != null); - assertTrue(n.getVoltageLevel("VLLOAD").getConnectable("NHV2_NLOAD", TwoTerminalsConnectable.class) != null); - assertTrue(n.getVoltageLevel("VLGEN").getConnectable("LOAD", Load.class) == null); - assertTrue(n.getVoltageLevel("VLGEN").getConnectable("NHV2_NLOAD", TwoTerminalsConnectable.class) == null); - } - -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerConnectDisconnectTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerConnectDisconnectTest.java deleted file mode 100644 index 7403b847..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerConnectDisconnectTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class NodeBreakerConnectDisconnectTest { - - private Network createNetwork() { - Network network = NetworkFactory.create("test", "test"); - Substation s = network.newSubstation() - .setId("S") - .setCountry(Country.FR) - .add(); - VoltageLevel vl = s.newVoltageLevel() - .setId("VL") - .setNominalV(400f) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); - vl.getNodeBreakerView().setNodeCount(10); - vl.getNodeBreakerView().newBusbarSection() - .setId("BBS") - .setNode(0) - .add(); - vl.newLoad() - .setId("L") - .setNode(2) - .setP0(1) - .setQ0(1) - .add(); - vl.newGenerator() - .setId("G") - .setNode(3) - .setMaxP(100) - .setMinP(50) - .setTargetP(100) - .setTargetV(400) - .setVoltageRegulatorOn(true) - .add(); - vl.getNodeBreakerView().newDisconnector() - .setId("D") - .setNode1(0) - .setNode2(1) - .setOpen(false) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("B1") - .setNode1(1) - .setNode2(2) - .setOpen(true) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("B2") - .setNode1(1) - .setNode2(3) - .setOpen(false) - .add(); - return network; - } - - @Test - public void test() { - Network network = createNetwork(); - Load l = network.getLoad("L"); - Generator g = network.getGenerator("G"); - - // generator is connected, load is disconnected - assertNotNull(g.getTerminal().getBusView().getBus()); - assertNull(l.getTerminal().getBusView().getBus()); - assertTrue(g.getTerminal().isConnected()); - assertFalse(l.getTerminal().isConnected()); - - // connect the load - assertTrue(l.getTerminal().connect()); - - // check load is connected - assertNotNull(l.getTerminal().getBusView().getBus()); - assertTrue(l.getTerminal().isConnected()); - - // disconnect the generator - g.getTerminal().disconnect(); - - // check generator is disconnected - assertNull(g.getTerminal().getBusView().getBus()); - assertFalse(g.getTerminal().isConnected()); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerDisconnectionDoublePathBugTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerDisconnectionDoublePathBugTest.java deleted file mode 100644 index aa8c07f6..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NodeBreakerDisconnectionDoublePathBugTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class NodeBreakerDisconnectionDoublePathBugTest { - - private Network createNetwork() { - Network network = NetworkFactory.create("test", "test"); - Substation s = network.newSubstation() - .setId("S") - .setCountry(Country.FR) - .add(); - VoltageLevel vl = s.newVoltageLevel() - .setId("VL") - .setNominalV(400f) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); - vl.getNodeBreakerView().setNodeCount(10); - vl.getNodeBreakerView().newBusbarSection() - .setId("BBS1") - .setNode(0) - .add(); - vl.getNodeBreakerView().newBusbarSection() - .setId("BBS2") - .setNode(1) - .add(); - vl.newLoad() - .setId("L") - .setNode(2) - .setP0(1) - .setQ0(1) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("BR0") - .setNode1(2) - .setNode2(3) - .setOpen(false) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("BR1") - .setNode1(3) - .setNode2(0) - .setOpen(true) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("BR2") - .setNode1(3) - .setNode2(1) - .setOpen(false) - .add(); - return network; - } - - @Test - public void testOnePathAlreadyOpen() { - Network network = createNetwork(); - Load l = network.getLoad("L"); - assertTrue(l.getTerminal().isConnected()); - l.getTerminal().disconnect(); - assertFalse(l.getTerminal().isConnected()); - } - - @Test - public void testBothPathClosed() { - Network network = createNetwork(); - Load l = network.getLoad("L"); - network.getSwitch("BR1").setOpen(false); - assertTrue(l.getTerminal().isConnected()); - l.getTerminal().disconnect(); - assertFalse(l.getTerminal().isConnected()); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NullPointerWhenRemovingMergedLineBugTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NullPointerWhenRemovingMergedLineBugTest.java deleted file mode 100644 index c05a381e..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/NullPointerWhenRemovingMergedLineBugTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Geoffroy Jamgotchian - */ -public class NullPointerWhenRemovingMergedLineBugTest { - - @Test - public void test() { - Network n1 = NetworkFactory.create("n1", "test"); - Substation s1 = n1.newSubstation() - .setId("s1") - .setCountry(Country.FR) - .add(); - VoltageLevel vl1 = s1.newVoltageLevel() - .setId("vl1") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl1.getBusBreakerView().newBus() - .setId("b1") - .add(); - vl1.newDanglingLine() - .setId("dl1") - .setConnectableBus("b1") - .setBus("b1") - .setP0(0f) - .setQ0(0f) - .setR(1f) - .setX(1f) - .setG(0f) - .setB(0f) - .setUcteXnodeCode("XNODE") - .add(); - Network n2 = NetworkFactory.create("n2", "test"); - Substation s2 = n2.newSubstation() - .setId("s2") - .setCountry(Country.BE) - .add(); - VoltageLevel vl2 = s2.newVoltageLevel() - .setId("vl2") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl2.getBusBreakerView().newBus() - .setId("b2") - .add(); - vl2.newDanglingLine() - .setId("dl2") - .setConnectableBus("b2") - .setBus("b2") - .setP0(0f) - .setQ0(0f) - .setR(1f) - .setX(1f) - .setG(0f) - .setB(0f) - .setUcteXnodeCode("XNODE") - .add(); - Assert.assertTrue(n1.getLineCount() == 0); - Assert.assertTrue(n1.getDanglingLineCount() == 1); - Assert.assertTrue(n2.getLineCount() == 0); - Assert.assertTrue(n2.getDanglingLineCount() == 1); - n1.merge(n2); - Assert.assertTrue(n1.getLineCount() == 1); - Assert.assertTrue(n1.getDanglingLineCount() == 0); - n1.getLine("dl1 + dl2").remove(); - for (Bus b : n1.getBusBreakerView().getBuses()) { - // throws an exception if bug already present - b.isInMainConnectedComponent(); - } - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImplTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImplTest.java deleted file mode 100644 index f3f6c87e..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/ReactiveCapabilityCurveImplTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.ReactiveCapabilityCurve.Point; -import eu.itesla_project.iidm.network.impl.ReactiveCapabilityCurveImpl.PointImpl; -import java.util.TreeMap; -import org.junit.Assert; -import org.junit.Test; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ReactiveCapabilityCurveImplTest { - - private ReactiveCapabilityCurveImpl createCurve(Point... points) { - TreeMap map = new TreeMap<>(); - for (Point pt : points) { - map.put(pt.getP(), pt); - } - return new ReactiveCapabilityCurveImpl(map); - } - - @Test - public void testInterpolation() { - ReactiveCapabilityCurveImpl curve = createCurve(new PointImpl(100, 200, 300), - new PointImpl(200, 300, 400)); - // bounds test - Assert.assertTrue(curve.getMinQ(100) == 200f); - Assert.assertTrue(curve.getMaxQ(100) == 300f); - Assert.assertTrue(curve.getMinQ(200) == 300f); - Assert.assertTrue(curve.getMaxQ(200) == 400f); - - // interpolation test - Assert.assertTrue(curve.getMinQ(150) == 250f); - Assert.assertTrue(curve.getMaxQ(150) == 350f); - Assert.assertTrue(curve.getMinQ(110) == 210f); - Assert.assertTrue(curve.getMaxQ(110) == 310f); - - // out of bounds test - Assert.assertTrue(curve.getMinQ(0) == 200f); - Assert.assertTrue(curve.getMaxQ(0) == 300f); - Assert.assertTrue(curve.getMinQ(1000) == 300f); - Assert.assertTrue(curve.getMaxQ(1000) == 400f); - } - -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StateManagerImplTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StateManagerImplTest.java deleted file mode 100644 index b499bc8c..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StateManagerImplTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.Sets; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.network.Identifiable; -import eu.itesla_project.iidm.network.StateManager; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; -import static org.junit.Assert.*; -import org.junit.Test; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class StateManagerImplTest { - - private class IdentifiableMock implements Identifiable, Stateful { - - private final String id; - - private final Set extended = new HashSet<>(); - - private final Set deleted = new HashSet<>(); - - private int reducedCount = 0; - - private IdentifiableMock(String id) { - this.id = id; - } - - @Override - public String getId() { - return id; - } - - @Override - public String getName() { - return id; - } - - @Override - public boolean hasProperty() { - return false; - } - - @Override - public Properties getProperties() { - return null; - } - - @Override - public void extendStateArraySize(int initStateArraySize, int number, int sourceIndex) { - for (int i = 0; i < number; i++) { - extended.add(sourceIndex); - } - } - - @Override - public void reduceStateArraySize(int number) { - reducedCount += number; - } - - @Override - public void deleteStateArrayElement(int index) { - deleted.add(index); - } - - @Override - public void allocateStateArrayElement(int[] indexes, int sourceIndex) { - } - - @Override - public void addExtension(Class type, Extension extension) { - throw new AssertionError(); - } - - @Override - public boolean removeExtension(Class type) { - throw new AssertionError(); - } - - @Override - public Extension getExtension(Class type) { - throw new AssertionError(); - } - - @Override - public Collection getExtensions() { - throw new AssertionError(); - } - } - - public StateManagerImplTest() { - } - - @Test - public void test() { - ObjectStore objectStore = new ObjectStore(); - IdentifiableMock identifiable1 = new IdentifiableMock("1"); - objectStore.checkAndAdd(identifiable1); - StateManagerImpl stateManager = new StateManagerImpl(objectStore); - // initial state test - assertTrue(stateManager.getStateArraySize() == 1); - assertTrue(Sets.newHashSet(StateManager.INITIAL_STATE_ID).equals(stateManager.getStateIds())); - assertTrue(Sets.newHashSet(0).equals(stateManager.getStateIndexes())); - try { - stateManager.setWorkingState("UnknownState"); - assertFalse(true); - } catch (ITeslaException e) { - } - try { - stateManager.removeState("UnknownState"); - assertFalse(true); - } catch (ITeslaException e) { - } - try { - stateManager.removeState(StateManager.INITIAL_STATE_ID); - assertFalse(true); - } catch (ITeslaException e) { - } - // cloning test - stateManager.cloneState(StateManager.INITIAL_STATE_ID, "ClonedState1"); - assertTrue(stateManager.getStateArraySize() == 2); - assertTrue(Sets.newHashSet(StateManager.INITIAL_STATE_ID, "ClonedState1").equals(stateManager.getStateIds())); - assertTrue(Sets.newHashSet(0, 1).equals(stateManager.getStateIndexes())); - assertTrue(Sets.newHashSet(0).equals(identifiable1.extended)); - // second cloning test - stateManager.cloneState("ClonedState1", "ClonedState2"); - assertTrue(stateManager.getStateArraySize() == 3); - assertTrue(Sets.newHashSet(StateManager.INITIAL_STATE_ID, "ClonedState1", "ClonedState2").equals(stateManager.getStateIds())); - assertTrue(Sets.newHashSet(0, 1, 2).equals(stateManager.getStateIndexes())); - assertTrue(stateManager.getWorkingStateId().equals(StateManager.INITIAL_STATE_ID)); - stateManager.setWorkingState("ClonedState1"); - assertTrue(stateManager.getWorkingStateId().equals("ClonedState1")); - // "middle" state removing test - stateManager.removeState("ClonedState1"); - try { - assertTrue(stateManager.getWorkingStateId().equals(StateManager.INITIAL_STATE_ID)); // because state is not set - fail(); - } catch (Exception e) { - } - assertTrue(stateManager.getStateArraySize() == 3); - assertTrue(Sets.newHashSet(StateManager.INITIAL_STATE_ID, "ClonedState2").equals(stateManager.getStateIds())); - assertTrue(Sets.newHashSet(0, 2).equals(stateManager.getStateIndexes())); - assertTrue(Sets.newHashSet(1).equals(identifiable1.deleted)); - // state array index recycling test - stateManager.cloneState("ClonedState2", "ClonedState3"); - assertTrue(stateManager.getStateArraySize() == 3); - assertTrue(Sets.newHashSet(StateManager.INITIAL_STATE_ID, "ClonedState2", "ClonedState3").equals(stateManager.getStateIds())); - assertTrue(Sets.newHashSet(0, 1, 2).equals(stateManager.getStateIndexes())); - // state array reduction test - stateManager.removeState("ClonedState3"); - assertTrue(stateManager.getStateArraySize() == 3); - stateManager.removeState("ClonedState2"); - assertTrue(stateManager.getStateArraySize() == 1); - assertTrue(Sets.newHashSet(StateManager.INITIAL_STATE_ID).equals(stateManager.getStateIds())); - assertTrue(Sets.newHashSet(0).equals(stateManager.getStateIndexes())); - assertTrue(identifiable1.reducedCount == 2); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorTest.java deleted file mode 100644 index 29139ba9..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/StaticVarCompensatorTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.StaticVarCompensator; -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.test.SvcTestCaseFactory; -import org.junit.After; -import static org.junit.Assert.*; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -/** - * @author Geoffroy Jamgotchian - */ -public class StaticVarCompensatorTest { - - private Network network; - - @Before - public void setUp() throws Exception { - network = SvcTestCaseFactory.create(); - } - - @After - public void tearDown() throws Exception { - network = null; - } - - @Test - public void initialStateTest() { - StaticVarCompensator svc = network.getStaticVarCompensator("SVC2"); - assertNotNull(svc); - assertTrue(network.getStaticVarCompensatorCount() == 1); - assertTrue(network.getStaticVarCompensators().iterator().next() == svc); - VoltageLevel vl2 = network.getVoltageLevel("VL2"); - assertTrue(vl2.getStaticVarCompensatorCount() == 1); - assertTrue(vl2.getStaticVarCompensators().iterator().next() == svc); - assertTrue(svc.getBmin() == 0.0002f); - assertTrue(svc.getBmax() == 0.0008f); - assertTrue(svc.getRegulationMode() == StaticVarCompensator.RegulationMode.VOLTAGE); - assertTrue(svc.getVoltageSetPoint() == 390f); - } - - @Test - public void removeTest() { - StaticVarCompensator svc = network.getStaticVarCompensator("SVC2"); - svc.remove(); - svc = network.getStaticVarCompensator("SVC2"); - assertNull(svc); - assertTrue(network.getStaticVarCompensatorCount() == 0); - assertFalse(network.getStaticVarCompensators().iterator().hasNext()); - VoltageLevel vl2 = network.getVoltageLevel("VL2"); - assertTrue(vl2.getStaticVarCompensatorCount() == 0); - assertFalse(vl2.getStaticVarCompensators().iterator().hasNext()); - } - - @Test - public void changeBminTest() { - StaticVarCompensator svc = network.getStaticVarCompensator("SVC2"); - svc.setBmin(0.0003f); - assertTrue(svc.getBmin() == 0.0003f); - } - - @Test - public void changeBmaxTest() { - StaticVarCompensator svc = network.getStaticVarCompensator("SVC2"); - svc.setBmax(0.0007f); - assertTrue(svc.getBmax() == 0.0007f); - } - - @Test - public void changeRegulationModeErrorTest() { - StaticVarCompensator svc = network.getStaticVarCompensator("SVC2"); - try { - svc.setRegulationMode(StaticVarCompensator.RegulationMode.REACTIVE_POWER); - fail(); - } catch (Exception ignored) { - } - } - - @Test - public void changeRegulationModeSuccessTest() { - StaticVarCompensator svc = network.getStaticVarCompensator("SVC2"); - svc.setReactivePowerSetPoint(200f); - svc.setRegulationMode(StaticVarCompensator.RegulationMode.REACTIVE_POWER); - assertTrue(svc.getReactivePowerSetPoint() == 200f); - assertTrue(svc.getRegulationMode() == StaticVarCompensator.RegulationMode.REACTIVE_POWER); - } - - @Test - public void changeVoltageSetPointTest() { - StaticVarCompensator svc = network.getStaticVarCompensator("SVC2"); - svc.setVoltageSetPoint(391f); - assertTrue(svc.getVoltageSetPoint() == 391f); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/SwitchOpenCloseNodeBreakerTopoTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/SwitchOpenCloseNodeBreakerTopoTest.java deleted file mode 100644 index ee0e90c8..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/SwitchOpenCloseNodeBreakerTopoTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.*; -import org.junit.Test; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * @author Geoffroy Jamgotchian - */ -public class SwitchOpenCloseNodeBreakerTopoTest { - - private Network createNetwork() { - Network network = NetworkFactory.create("test", "test"); - Substation s = network.newSubstation() - .setId("S") - .setCountry(Country.FR) - .add(); - VoltageLevel vl = s.newVoltageLevel() - .setId("VL") - .setNominalV(400f) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); - vl.getNodeBreakerView().setNodeCount(10); - vl.getNodeBreakerView().newBusbarSection() - .setId("BBS1") - .setNode(0) - .add(); - vl.getNodeBreakerView().newBusbarSection() - .setId("BBS2") - .setNode(3) - .add(); - vl.getNodeBreakerView().newDisconnector() - .setId("D1") - .setNode1(0) - .setNode2(1) - .setOpen(false) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("B1") - .setNode1(1) - .setNode2(2) - .setOpen(true) - .add(); - vl.getNodeBreakerView().newDisconnector() - .setId("2") - .setNode1(2) - .setNode2(3) - .setOpen(false) - .add(); - vl.newLoad() - .setId("L1") - .setNode(4) - .setP0(1) - .setQ0(1) - .add(); - vl.newLoad() - .setId("L2") - .setNode(5) - .setP0(1) - .setQ0(1) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("B2") - .setNode1(0) - .setNode2(4) - .setOpen(false) - .add(); - vl.getNodeBreakerView().newBreaker() - .setId("B3") - .setNode1(3) - .setNode2(5) - .setOpen(false) - .add(); - return network; - } - - @Test - public void test() { - Network network = createNetwork(); - VoltageLevel vl = network.getVoltageLevel("VL"); - assertNotNull(vl); - assertTrue(Iterables.size(vl.getBusView().getBuses()) == 2); - Switch s = vl.getNodeBreakerView().getSwitch("B1"); - s.setOpen(false); - assertTrue(Iterables.size(vl.getBusView().getBuses()) == 1); - s.setOpen(true); - assertTrue(Iterables.size(vl.getBusView().getBuses()) == 2); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/TopologyTraverserTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/TopologyTraverserTest.java deleted file mode 100644 index 7c288d11..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/TopologyTraverserTest.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.*; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - */ -public class TopologyTraverserTest { - - private Network createNodeBreakerNetwork() { - Network network = NetworkFactory.create("test", "test"); - Substation s1 = network.newSubstation() - .setId("S1") - .setCountry(Country.FR) - .add(); - VoltageLevel vl1 = s1.newVoltageLevel() - .setId("VL1") - .setNominalV(400f) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); - vl1.getNodeBreakerView().setNodeCount(4); - vl1.getNodeBreakerView().newBusbarSection() - .setId("BBS1") - .setNode(0) - .add(); - vl1.newGenerator() - .setId("G") - .setNode(1) - .setMaxP(100) - .setMinP(50) - .setTargetP(100) - .setTargetV(400) - .setVoltageRegulatorOn(true) - .add(); - vl1.getNodeBreakerView().newDisconnector() - .setId("BR1") - .setNode1(0) - .setNode2(1) - .setOpen(false) - .add(); - vl1.getNodeBreakerView().newDisconnector() - .setId("D1") - .setNode1(0) - .setNode2(2) - .setOpen(false) - .add(); - vl1.getNodeBreakerView().newBreaker() - .setId("BR2") - .setNode1(2) - .setNode2(3) - .setOpen(false) - .add(); - - Substation s2 = network.newSubstation() - .setId("S2") - .setCountry(Country.FR) - .add(); - VoltageLevel vl2 = s2.newVoltageLevel() - .setId("VL2") - .setNominalV(400f) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); - vl2.getNodeBreakerView().setNodeCount(5); - vl2.getNodeBreakerView().newBusbarSection() - .setId("BBS2") - .setNode(0) - .add(); - vl2.newLoad() - .setId("LD") - .setNode(1) - .setP0(1) - .setQ0(1) - .add(); - vl2.getNodeBreakerView().newDisconnector() - .setId("BR3") - .setNode1(0) - .setNode2(1) - .setOpen(false) - .add(); - vl2.getNodeBreakerView().newDisconnector() - .setId("D2") - .setNode1(0) - .setNode2(2) - .setOpen(false) - .add(); - vl2.getNodeBreakerView().newBreaker() - .setId("BR4") - .setNode1(2) - .setNode2(3) - .setOpen(false) - .add(); - network.newLine() - .setId("L1") - .setVoltageLevel1("VL1") - .setNode1(3) - .setVoltageLevel2("VL2") - .setNode2(3) - .setR(1) - .setX(1) - .setG1(0) - .setB1(0) - .setG2(0) - .setB2(0) - .add(); - return network; - } - - private Network createMixedNodeBreakerBusBreakerNetwork() { - Network network = createNodeBreakerNetwork(); - Substation s3 = network.newSubstation() - .setId("S3") - .setCountry(Country.FR) - .add(); - VoltageLevel vl3 = s3.newVoltageLevel() - .setId("VL3") - .setNominalV(400f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl3.getBusBreakerView().newBus() - .setId("B1") - .add(); - vl3.newLoad() - .setId("LD2") - .setConnectableBus("B1") - .setBus("B1") - .setP0(1) - .setQ0(1) - .add(); - network.getVoltageLevel("VL2").getNodeBreakerView().newBreaker() - .setId("BR5") - .setNode1(0) - .setNode2(4) - .setOpen(false) - .add(); - network.newLine() - .setId("L2") - .setVoltageLevel1("VL2") - .setNode1(4) - .setVoltageLevel2("VL3") - .setConnectableBus2("B1") - .setBus2("B1") - .setR(1) - .setX(1) - .setG1(0) - .setB1(0) - .setG2(0) - .setB2(0) - .add(); - return network; - } - - @Test - public void test1() { - Network network = createNodeBreakerNetwork(); - - List traversed = new ArrayList<>(); - network.getGenerator("G").getTerminal().traverse(new VoltageLevel.TopologyTraverser() { - @Override - public boolean traverse(Terminal terminal, boolean connected) { - traversed.add(terminal.getConnectable().getId()); - return true; - } - - @Override - public boolean traverse(Switch aSwitch) { - return true; - } - }); - Assert.assertEquals(traversed, Arrays.asList("G", "BBS1", "L1", "L1", "BBS2", "LD")); - } - - @Test - public void test2() { - Network network = createNodeBreakerNetwork(); - - List traversed = new ArrayList<>(); - network.getVoltageLevel("VL1").getNodeBreakerView().getBusbarSection("BBS1") - .getTerminal().traverse(new VoltageLevel.TopologyTraverser() { - @Override - public boolean traverse(Terminal terminal, boolean connected) { - traversed.add(terminal.getConnectable().getId()); - return connected; - } - - @Override - public boolean traverse(Switch aSwitch) { - return !aSwitch.isOpen() && aSwitch.getKind() != SwitchKind.BREAKER; - } - }); - Assert.assertEquals(traversed, Arrays.asList("BBS1", "G")); - } - - @Test - public void test3() { - Network network = createMixedNodeBreakerBusBreakerNetwork(); - - List traversed = new ArrayList<>(); - network.getGenerator("G").getTerminal().traverse(new VoltageLevel.TopologyTraverser() { - @Override - public boolean traverse(Terminal terminal, boolean connected) { - traversed.add(terminal.getConnectable().getId()); - return true; - } - - @Override - public boolean traverse(Switch aSwitch) { - return true; - } - }); - Assert.assertEquals(traversed, Arrays.asList("G", "BBS1", "L1", "L1", "BBS2", "LD", "L2", "L2", "LD2")); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/VscTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/VscTest.java deleted file mode 100644 index cf71afb2..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/VscTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl; - -import eu.itesla_project.iidm.network.HvdcLine; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.VscConverterStation; -import eu.itesla_project.iidm.network.test.HvdcTestNetwork; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class VscTest { - - @Test - public void testBase() { - Network network = HvdcTestNetwork.createVsc(); - VscConverterStation cs1 = (VscConverterStation) network.getHvdcConverterStation("C1"); - assertNotNull(cs1); - VscConverterStation cs2 = (VscConverterStation) network.getHvdcConverterStation("C2"); - assertNotNull(cs2); - assertTrue(network.getVoltageLevel("VL1").getVscConverterStationCount() == 1); - assertTrue(network.getVoltageLevel("VL2").getVscConverterStationCount() == 1); - assertTrue(cs1.isVoltageRegulatorOn()); - assertTrue(cs1.getVoltageSetPoint() == 405f); - assertTrue(Float.isNaN(cs1.getReactivePowerSetPoint())); - assertFalse(cs2.isVoltageRegulatorOn()); - assertTrue(cs2.getReactivePowerSetPoint() == 123f); - assertTrue(Float.isNaN(cs2.getVoltageSetPoint())); - assertTrue(network.getHvdcLineCount() == 1); - HvdcLine l = network.getHvdcLine("L"); - assertNotNull(l); - assertTrue(l.getR() == 1f); - assertTrue(l.getConvertersMode() == HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER); - assertTrue(l.getMaxP() == 300f); - assertTrue(l. getConverterStation1() == cs1); - assertTrue(l. getConverterStation2() == cs2); - } - - @Test - public void testRemove() { - Network network = HvdcTestNetwork.createVsc(); - network.getHvdcLine("L").remove(); - assertTrue(network.getHvdcLineCount() == 0); - } -} diff --git a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutorsTest.java b/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutorsTest.java deleted file mode 100644 index eb39a50d..00000000 --- a/iidm-network-impl/src/test/java/eu/itesla_project/iidm/network/impl/util/MultiStateNetworkAwareExecutorsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.impl.util; - -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.StateManager; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import org.junit.Test; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.TimeUnit; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class MultiStateNetworkAwareExecutorsTest { - - @Test - public void testAfterExecute() throws Exception { - Network network = EurostagTutorialExample1Factory.create(); - StateManager manager = network.getStateManager(); - manager.allowStateMultiThreadAccess(true); - assertTrue(manager.getWorkingStateId().equals(StateManager.INITIAL_STATE_ID)); - ExecutorService service = MultiStateNetworkAwareExecutors.newFixedThreadPool(1); - Thread[] threads = new Thread[1]; - service.submit(() -> { - manager.setWorkingState(StateManager.INITIAL_STATE_ID); - threads[0] = Thread.currentThread(); - }).get(); - service.submit(() -> { - assertTrue(threads[0] == Thread.currentThread()); // just one thread in the pool - try { - // current working state should not be set even if it is the same thread than previously - network.getGenerator("GEN").getTargetP(); - fail(); - } catch (Exception e) { - } - }).get(); - service.shutdown(); - service.awaitTermination(1, TimeUnit.MINUTES); - } - -} \ No newline at end of file diff --git a/iidm-network-test/pom.xml b/iidm-network-test/pom.xml deleted file mode 100644 index d24bb9ad..00000000 --- a/iidm-network-test/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - 4.0.0 - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - - iidm-network-test - - IIDM network test - Utility classes to test the network model - - - - ${project.groupId} - iidm-network-api - ${project.version} - - - diff --git a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/EurostagTutorialExample1Factory.java b/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/EurostagTutorialExample1Factory.java deleted file mode 100644 index 7646e2e2..00000000 --- a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/EurostagTutorialExample1Factory.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.test; - -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.Substation; -import eu.itesla_project.iidm.network.NetworkFactory; -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.TopologyKind; -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.Country; -import eu.itesla_project.iidm.network.TwoWindingsTransformer; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.Generator; - -/** - * This is a network test based on Eurostag tutorial example 1. - * - * @author Geoffroy Jamgotchian - */ -public class EurostagTutorialExample1Factory { - - private EurostagTutorialExample1Factory() { - } - - public static Network create() { - Network network = NetworkFactory.create("sim1", "test"); - Substation p1 = network.newSubstation() - .setId("P1") - .setCountry(Country.FR) - .setTso("RTE") - .setGeographicalTags("A") - .add(); - Substation p2 = network.newSubstation() - .setId("P2") - .setCountry(Country.FR) - .setTso("RTE") - .setGeographicalTags("B") - .add(); - VoltageLevel vlgen = p1.newVoltageLevel() - .setId("VLGEN") - .setNominalV(24) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - VoltageLevel vlhv1 = p1.newVoltageLevel() - .setId("VLHV1") - .setNominalV(380) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - VoltageLevel vlhv2 = p2.newVoltageLevel() - .setId("VLHV2") - .setNominalV(380) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - VoltageLevel vlload = p2.newVoltageLevel() - .setId("VLLOAD") - .setNominalV(150) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - Bus ngen = vlgen.getBusBreakerView().newBus() - .setId("NGEN") - .add(); - Bus nhv1 = vlhv1.getBusBreakerView().newBus() - .setId("NHV1") - .add(); - Bus nhv2 = vlhv2.getBusBreakerView().newBus() - .setId("NHV2") - .add(); - Bus nload = vlload.getBusBreakerView().newBus() - .setId("NLOAD") - .add(); - network.newLine() - .setId("NHV1_NHV2_1") - .setVoltageLevel1("VLHV1") - .setBus1("NHV1") - .setConnectableBus1("NHV1") - .setVoltageLevel2("VLHV2") - .setBus2("NHV2") - .setConnectableBus2("NHV2") - .setR(3) - .setX(33) - .setG1(0) - .setB1(386E-6f / 2) - .setG2(0f) - .setB2(386E-6f / 2) - .add(); - network.newLine() - .setId("NHV1_NHV2_2") - .setVoltageLevel1("VLHV1") - .setBus1("NHV1") - .setConnectableBus1("NHV1") - .setVoltageLevel2("VLHV2") - .setBus2("NHV2") - .setConnectableBus2("NHV2") - .setR(3) - .setX(33) - .setG1(0) - .setB1(386E-6f / 2) - .setG2(0f) - .setB2(386E-6f / 2) - .add(); - float zb380 = 380 * 380 / 100; - TwoWindingsTransformer ngen_nhv1 = p1.newTwoWindingsTransformer() - .setId("NGEN_NHV1") - .setVoltageLevel1("VLGEN") - .setBus1("NGEN") - .setConnectableBus1("NGEN") - .setRatedU1(24f) - .setVoltageLevel2("VLHV1") - .setBus2("NHV1") - .setConnectableBus2("NHV1") - .setRatedU2(400f) - .setR(0.24f / 1300 * zb380) - .setX(((float) Math.sqrt(10 * 10 - 0.24 * 0.24)) / 1300 * zb380) - .setG(0) - .setB(0) - .add(); - float zb150 = 150 * 150 / 100; - TwoWindingsTransformer nhv2_nload = p2.newTwoWindingsTransformer() - .setId("NHV2_NLOAD") - .setVoltageLevel1("VLHV2") - .setBus1("NHV2") - .setConnectableBus1("NHV2") - .setRatedU1(400f) - .setVoltageLevel2("VLLOAD") - .setBus2("NLOAD") - .setConnectableBus2("NLOAD") - .setRatedU2(158f) - .setR(0.21f / 1000 * zb150) - .setX(((float) Math.sqrt(18 * 18 - 0.21 * 0.21)) / 1000 * zb150) - .setG(0) - .setB(0) - .add(); - float a = (158f / 150f) / (400f / 380f); - nhv2_nload.newRatioTapChanger() - .beginStep() - .setRho(0.85f * a) - .setR(0f) - .setX(0f) - .setG(0f) - .setB(0f) - .endStep() - .beginStep() - .setRho(a) - .setR(0f) - .setX(0f) - .setG(0f) - .setB(0f) - .endStep() - .beginStep() - .setRho(1.15f * a) - .setR(0f) - .setX(0f) - .setG(0f) - .setB(0f) - .endStep() - .setTapPosition(1) - .setLoadTapChangingCapabilities(true) - .setRegulating(true) - .setTargetV(158) - .setRegulationTerminal(nhv2_nload.getTerminal2()) - .add(); - Load load = vlload.newLoad() - .setId("LOAD") - .setBus("NLOAD") - .setConnectableBus("NLOAD") - .setP0(600f) - .setQ0(200f) - .add(); - Generator generator = vlgen.newGenerator() - .setId("GEN") - .setBus("NGEN") - .setConnectableBus("NGEN") - .setMinP(-9999.99f) - .setMaxP(9999.99f) - .setVoltageRegulatorOn(true) - .setTargetV(24.5f) - .setTargetP(607f) - .setTargetQ(301f) - .add(); - generator.newMinMaxReactiveLimits() - .setMinQ(-9999.99f) - .setMaxQ(9999.99f) - .add(); - return network; - } - -} diff --git a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/HvdcTestNetwork.java b/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/HvdcTestNetwork.java deleted file mode 100644 index 902f9b7e..00000000 --- a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/HvdcTestNetwork.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.test; - -import eu.itesla_project.iidm.network.*; -import org.joda.time.DateTime; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class HvdcTestNetwork { - - private HvdcTestNetwork() { - } - - private static Network createBase() { - Network network = NetworkFactory.create("hvdctest", "test"); - network.setCaseDate(DateTime.parse("2016-06-27T16:34:55.930+02:00")); - Substation s1 = network.newSubstation() - .setId("S1") - .setCountry(Country.FR) - .add(); - VoltageLevel vl1 = s1.newVoltageLevel() - .setId("VL1") - .setNominalV(400) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl1.getBusBreakerView().newBus() - .setId("B1") - .add(); - Substation s2 = network.newSubstation() - .setId("S2") - .setCountry(Country.FR) - .add(); - VoltageLevel vl2 = s2.newVoltageLevel() - .setId("VL2") - .setNominalV(400) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); - vl2.getNodeBreakerView().setNodeCount(3); - vl2.getNodeBreakerView().newBusbarSection() - .setId("BBS1") - .setName("BusbarSection") - .setNode(0) - .add(); - vl2.getNodeBreakerView().newDisconnector() - .setId("DISC_BBS1_BK1") - .setName("Disconnector") - .setNode1(0) - .setNode2(1) - .setOpen(false) - .setRetained(true) - .add(); - vl2.getNodeBreakerView().newBreaker() - .setId("BK1") - .setName("Breaker") - .setNode1(1) - .setNode2(2) - .setOpen(false) - .setRetained(false) - .add(); - return network; - } - - private static void createLine(Network network) { - network.newHvdcLine() - .setId("L") - .setName("HVDC") - .setConverterStationId1("C1") - .setConverterStationId2("C2") - .setR(1) - .setNominalV(400) - .setConvertersMode(HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER) - .setMaxP(300) - .setActivePowerSetPoint(280) - .add(); - } - - public static Network createVsc() { - Network network = createBase(); - VoltageLevel vl1 = network.getVoltageLevel("VL1"); - VscConverterStation cs1 = vl1.newVscConverterStation() - .setId("C1") - .setName("Converter1") - .setConnectableBus("B1") - .setBus("B1") - .setVoltageSetPoint(405) - .setVoltageRegulatorOn(true) - .add(); - cs1.getTerminal() - .setP(100.0f) - .setQ(50.0f); - cs1.newReactiveCapabilityCurve() - .beginPoint() - .setP(5) - .setMinQ(0) - .setMaxQ(10) - .endPoint() - .beginPoint() - .setP(10) - .setMinQ(0) - .setMaxQ(10) - .endPoint() - .add(); - VoltageLevel vl2 = network.getVoltageLevel("VL2"); - VscConverterStation cs2 = vl2.newVscConverterStation() - .setId("C2") - .setName("Converter2") - .setNode(2) - .setReactivePowerSetPoint(123) - .setVoltageRegulatorOn(false) - .add(); - cs2.newMinMaxReactiveLimits() - .setMinQ(0) - .setMaxQ(10) - .add(); - createLine(network); - return network; - } - - public static Network createLcc() { - Network network = createBase(); - VoltageLevel vl1 = network.getVoltageLevel("VL1"); - LccConverterStation cs1 = vl1.newLccConverterStation() - .setId("C1") - .setName("Converter1") - .setConnectableBus("B1") - .setBus("B1") - .setPowerFactor(0.5f) - .add(); - cs1.getTerminal() - .setP(100.0f) - .setQ(50.0f); - cs1.newFilter() - .setB(0.00001f) - .setConnected(true) - .add(); - cs1.newFilter() - .setB(0.00002f) - .setConnected(false) - .add(); - VoltageLevel vl2 = network.getVoltageLevel("VL2"); - LccConverterStation cs2 = vl2.newLccConverterStation() - .setId("C2") - .setName("Converter2") - .setNode(2) - .setPowerFactor(0.6f) - .add(); - cs2.getTerminal() - .setP(75.0f) - .setQ(25.0f); - cs2.newFilter() - .setB(0.00003f) - .setConnected(true) - .add(); - cs2.newFilter() - .setB(0.00004f) - .setConnected(true) - .add(); - createLine(network); - return network; - } -} diff --git a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/LoadZipModel.java b/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/LoadZipModel.java deleted file mode 100644 index dcbb1dfd..00000000 --- a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/LoadZipModel.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.test; - -import eu.itesla_project.iidm.network.Identifiable; -import eu.itesla_project.iidm.network.Load; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -/** - * p = p0 * (a1 * (v / v0)^2 + a2 * v / v0 + a3) - * q = q0 * (a4 * (v / v0)^2 + a5 * v / v0 + a6) - */ -public class LoadZipModel implements Identifiable.Extension { - - Load load; - float v0; - float a1; - float a2; - float a3; - float a4; - float a5; - float a6; - - public LoadZipModel(Load load, float a1, float a2, float a3, float a4, float a5, float a6, float v0) { - this.load = Objects.requireNonNull(load); - this.a1 = a1; - this.a2 = a2; - this.a3 = a3; - this.a4 = a4; - this.a5 = a5; - this.a6 = a6; - this.v0 = v0; - } - - @Override - public Load getIdentifiable() { - return load; - } - - public float getV0() { - return v0; - } - - public void setV0(float v0) { - this.v0 = v0; - } - - public float getA1() { - return a1; - } - - public void setA1(float a1) { - this.a1 = a1; - } - - public float getA2() { - return a2; - } - - public void setA2(float a2) { - this.a2 = a2; - } - - public float getA3() { - return a3; - } - - public void setA3(float a3) { - this.a3 = a3; - } - - public float getA4() { - return a4; - } - - public void setA4(float a4) { - this.a4 = a4; - } - - public float getA5() { - return a5; - } - - public void setA5(float a5) { - this.a5 = a5; - } - - public float getA6() { - return a6; - } - - public void setA6(float a6) { - this.a6 = a6; - } - - @Override - public String getName() { - return "loadZipModel"; - } - -} - diff --git a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/NetworkTest1Factory.java b/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/NetworkTest1Factory.java deleted file mode 100644 index af401cc2..00000000 --- a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/NetworkTest1Factory.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.test; - -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.Switch; -import eu.itesla_project.iidm.network.TopologyKind; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.Country; -import eu.itesla_project.iidm.network.Substation; -import eu.itesla_project.iidm.network.NetworkFactory; -import eu.itesla_project.iidm.network.BusbarSection; -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.Generator; -import eu.itesla_project.iidm.network.EnergySource; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class NetworkTest1Factory { - - private NetworkTest1Factory() { - } - - public static Network create() { - Network network = NetworkFactory.create("network1", "test"); - Substation substation1 = network.newSubstation() - .setId("substation1") - .setCountry(Country.FR) - .setTso("TSO1") - .setGeographicalTags("region1") - .add(); - VoltageLevel voltageLevel1 = substation1.newVoltageLevel() - .setId("voltageLevel1") - .setNominalV(400) - .setTopologyKind(TopologyKind.NODE_BREAKER) - .add(); - VoltageLevel.NodeBreakerView topology1 = voltageLevel1.getNodeBreakerView(); - topology1.setNodeCount(10); - BusbarSection voltageLevel1BusbarSection1 = topology1.newBusbarSection() - .setId("voltageLevel1BusbarSection1") - .setNode(0) - .add(); - BusbarSection voltageLevel1BusbarSection2 = topology1.newBusbarSection() - .setId("voltageLevel1BusbarSection2") - .setNode(1) - .add(); - Switch voltageLevel1Breaker1 = topology1.newBreaker() - .setId("voltageLevel1Breaker1") - .setRetained(true) - .setOpen(false) - .setNode1(voltageLevel1BusbarSection1.getTerminal().getNodeBreakerView().getNode()) - .setNode2(voltageLevel1BusbarSection2.getTerminal().getNodeBreakerView().getNode()) - .add(); - Load load1 = voltageLevel1.newLoad() - .setId("load1") - .setNode(2) - .setP0(10) - .setQ0(3) - .add(); - Switch load1Disconnector1 = topology1.newDisconnector() - .setId("load1Disconnector1") - .setOpen(false) - .setNode1(load1.getTerminal().getNodeBreakerView().getNode()) - .setNode2(3) - .add(); - Switch load1Breaker1 = topology1.newDisconnector() - .setId("load1Breaker1") - .setOpen(false) - .setNode1(3) - .setNode2(voltageLevel1BusbarSection1.getTerminal().getNodeBreakerView().getNode()) - .add(); - Generator generator1 = voltageLevel1.newGenerator() - .setId("generator1") - .setEnergySource(EnergySource.NUCLEAR) - .setMinP(200) - .setMaxP(900) - .setVoltageRegulatorOn(true) - .setTargetP(900) - .setTargetV(380) - .setNode(5) - .add(); - generator1.newReactiveCapabilityCurve() - .beginPoint().setP(200).setMinQ(300).setMaxQ(500).endPoint() - .beginPoint().setP(900).setMinQ(300).setMaxQ(500).endPoint() - .add(); - Switch generator1Disconnector1 = topology1.newDisconnector() - .setId("generator1Disconnector1") - .setOpen(false) - .setNode1(generator1.getTerminal().getNodeBreakerView().getNode()) - .setNode2(6) - .add(); - Switch generator1Breaker1 = topology1.newDisconnector() - .setId("generator1Breaker1") - .setOpen(false) - .setNode1(6) - .setNode2(voltageLevel1BusbarSection2.getTerminal().getNodeBreakerView().getNode()) - .add(); - return network; - } - -} diff --git a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/PhaseShifterTestCaseFactory.java b/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/PhaseShifterTestCaseFactory.java deleted file mode 100644 index 376c6470..00000000 --- a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/PhaseShifterTestCaseFactory.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.test; - -import eu.itesla_project.iidm.network.*; -import org.joda.time.DateTime; - -/** - * A very small network to test phase shifters. - * - * G1 LD2 - * | L1 | - * | ----------------- | - * B1 B2 - * --------B3------- - * PS1 L2 - * - * @author Geoffroy Jamgotchian - */ -public class PhaseShifterTestCaseFactory { - - public static Network create() { - Network network = NetworkFactory.create("phaseShifterTestCase", "code"); - network.setCaseDate(DateTime.parse("2016-10-18T10:06:00.000+02:00")); - Substation s1 = network.newSubstation() - .setId("S1") - .setCountry(Country.FR) - .add(); - VoltageLevel vl1 = s1.newVoltageLevel() - .setId("VL1") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - Bus b1 = vl1.getBusBreakerView().newBus() - .setId("B1") - .add(); - b1.setV(400f).setAngle(0f); - Generator g1 = vl1.newGenerator() - .setId("G1") - .setConnectableBus("B1") - .setBus("B1") - .setVoltageRegulatorOn(true) - .setTargetP(100f) - .setTargetV(400f) - .setMinP(50) - .setMaxP(150) - .add(); - g1.getTerminal().setP(-100.16797f).setQ(-58.402832f); - Substation s2 = network.newSubstation() - .setId("S2") - .setCountry(Country.FR) - .add(); - VoltageLevel vl2 = s2.newVoltageLevel() - .setId("VL2") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - Bus b2 = vl2.getBusBreakerView().newBus() - .setId("B2") - .add(); - b2.setV(385.6934f).setAngle(-3.6792064f); - Load ld2 = vl2.newLoad() - .setId("LD2") - .setConnectableBus("B2") - .setBus("B2") - .setP0(100f) - .setQ0(50f) - .add(); - ld2.getTerminal().setP(100f).setQ(50f); - Line l1 = network.newLine() - .setId("L1") - .setVoltageLevel1("VL1") - .setConnectableBus1("B1") - .setBus1("B1") - .setVoltageLevel2("VL2") - .setConnectableBus2("B2") - .setBus2("B2") - .setR(4f) - .setX(200f) - .setG1(0f) - .setB1(0f) - .setG2(0f) - .setB2(0f) - .add(); - l1.getTerminal1().setP(50.084026f).setQ(29.201416f); - l1.getTerminal2().setP(-50f).setQ(-25f); - VoltageLevel vl3 = s1.newVoltageLevel() - .setId("VL3") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - Bus b3 = vl3.getBusBreakerView().newBus() - .setId("B3") - .add(); - b3.setV(392.6443f).setAngle(-1.8060945f); - TwoWindingsTransformer ps1 = s1.newTwoWindingsTransformer() - .setId("PS1") - .setVoltageLevel1("VL1") - .setConnectableBus1("B1") - .setBus1("B1") - .setVoltageLevel2("VL3") - .setConnectableBus2("B3") - .setBus2("B3") - .setRatedU1(380f) - .setRatedU2(380f) - .setR(2f) - .setX(100f) - .setG(0f) - .setB(0f) - .add(); - ps1.getTerminal1().setP(50.08403f).setQ(29.201416f); - ps1.getTerminal2().setP(-50.042015f).setQ(-27.100708f); - ps1.newPhaseTapChanger() - .setTapPosition(1) - .setRegulationTerminal(ps1.getTerminal2()) - .setRegulationMode(PhaseTapChanger.RegulationMode.FIXED_TAP) - .setRegulationValue(200) - .beginStep() - .setAlpha(-20f) - .setRho(1f) - .setR(0f) - .setX(0f) - .setG(0f) - .setB(0f) - .endStep() - .beginStep() - .setAlpha(0f) - .setRho(1f) - .setR(0f) - .setX(0f) - .setG(0f) - .setB(0f) - .endStep() - .beginStep() - .setAlpha(20f) - .setRho(1f) - .setR(0f) - .setX(0f) - .setG(0f) - .setB(0f) - .endStep() - .add(); - Line l2 = network.newLine() - .setId("L2") - .setVoltageLevel1("VL3") - .setConnectableBus1("B3") - .setBus1("B3") - .setVoltageLevel2("VL2") - .setConnectableBus2("B2") - .setBus2("B2") - .setR(2f) - .setX(100f) - .setG1(0f) - .setB1(0f) - .setG2(0f) - .setB2(0f) - .add(); - l2.getTerminal1().setP(50.042015f).setQ(27.100708f); - l2.getTerminal2().setP(-50f).setQ(-25f); - return network; - } -} diff --git a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/SvcTestCaseFactory.java b/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/SvcTestCaseFactory.java deleted file mode 100644 index 0bdfa6d8..00000000 --- a/iidm-network-test/src/main/java/eu/itesla_project/iidm/network/test/SvcTestCaseFactory.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.network.test; - -import eu.itesla_project.iidm.network.*; -import org.joda.time.DateTime; - -/** - * A very small network to test SVC modeling. 2 buses B1 and B2. A generator G1 regulating voltage is connected to B1. - * B1 and B2 are connected by a line with a high reactance to cause an important voltage drop. - * A SVC is connected to B2 to compensate the voltage drop. - * - * G1 L2 - * | | - * B1 ---------------B2 - * | - * SVC2 - * - * @author Geoffroy Jamgotchian - */ -public class SvcTestCaseFactory { - - public static Network create() { - Network network = NetworkFactory.create("svcTestCase", "code"); - network.setCaseDate(DateTime.parse("2016-06-29T14:54:03.427+02:00")); - Substation s1 = network.newSubstation() - .setId("S1") - .setCountry(Country.FR) - .add(); - VoltageLevel vl1 = s1.newVoltageLevel() - .setId("VL1") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl1.getBusBreakerView().newBus() - .setId("B1") - .add(); - vl1.newGenerator() - .setId("G1") - .setConnectableBus("B1") - .setBus("B1") - .setVoltageRegulatorOn(true) - .setTargetP(100f) - .setTargetV(400f) - .setMinP(50) - .setMaxP(150) - .add(); - Substation s2 = network.newSubstation() - .setId("S2") - .setCountry(Country.FR) - .add(); - VoltageLevel vl2 = s2.newVoltageLevel() - .setId("VL2") - .setNominalV(380f) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl2.getBusBreakerView().newBus() - .setId("B2") - .add(); - vl2.newLoad() - .setId("L2") - .setConnectableBus("B2") - .setBus("B2") - .setP0(100f) - .setQ0(50f) - .add(); - vl2.newStaticVarCompensator() - .setId("SVC2") - .setConnectableBus("B2") - .setBus("B2") - .setBmin(0.0002f) - .setBmax(0.0008f) - .setRegulationMode(StaticVarCompensator.RegulationMode.VOLTAGE) - .setVoltageSetPoint(390f) - .add(); - network.newLine() - .setId("L1") - .setVoltageLevel1("VL1") - .setConnectableBus1("B1") - .setBus1("B1") - .setVoltageLevel2("VL2") - .setConnectableBus2("B2") - .setBus2("B2") - .setR(4f) - .setX(200f) - .setG1(0f) - .setB1(0f) - .setG2(0f) - .setB2(0f) - .add(); - return network; - } -} diff --git a/iidm-xml-converter/pom.xml b/iidm-xml-converter/pom.xml deleted file mode 100644 index 3265bd7b..00000000 --- a/iidm-xml-converter/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - - 4.0.0 - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - - iidm-xml-converter - - IIDM XML converter - - - - org.slf4j - slf4j-api - - - net.java.dev.stax-utils - stax-utils - 20070216 - - - com.bea.xml - jsr173-ri - - - - - eu.itesla_project - commons - ${project.version} - - - eu.itesla_project - iidm-converter-api - ${project.version} - - - eu.itesla_project - iidm-network-api - ${project.version} - - - junit - junit - test - - - org.slf4j - slf4j-simple - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-base - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-nio2 - test - - - org.xmlunit - xmlunit-core - test - - - eu.itesla_project - iidm-network-test - ${project.version} - test - - - eu.itesla_project - iidm-network-impl - ${project.version} - test - - - eu.itesla_project - commons - ${project.version} - test-jar - test - - - diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/Anonymizer.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/Anonymizer.java deleted file mode 100644 index 0aad3fdb..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/Anonymizer.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Country; - -import java.io.BufferedReader; -import java.io.BufferedWriter; - -/** - * @author Geoffroy Jamgotchian - */ -public interface Anonymizer { - - String anonymizeString(String str); - - String deanonymizeString(String str); - - Country anonymizeCountry(Country country); - - Country deanonymizeCountry(Country country); - - void read(BufferedReader reader); - - void write(BufferedWriter writer); -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusBreakerViewSwitchXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusBreakerViewSwitchXml.java deleted file mode 100644 index 86093f55..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusBreakerViewSwitchXml.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.Switch; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * @author Geoffroy Jamgotchian - */ -public class BusBreakerViewSwitchXml extends SwitchXml { - - static final BusBreakerViewSwitchXml INSTANCE = new BusBreakerViewSwitchXml(); - - @Override - protected void writeRootElementAttributes(Switch s, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - super.writeRootElementAttributes(s, vl, context); - VoltageLevel.BusBreakerView v = vl.getBusBreakerView(); - Bus bus1 = v.getBus1(s.getId()); - Bus bus2 = v.getBus2(s.getId()); - context.getWriter().writeAttribute("bus1", context.getAnonymizer().anonymizeString(bus1.getId())); - context.getWriter().writeAttribute("bus2", context.getAnonymizer().anonymizeString(bus2.getId())); - } - - @Override - protected VoltageLevel.BusBreakerView.SwitchAdder createAdder(VoltageLevel vl) { - return vl.getBusBreakerView().newSwitch(); - } - - @Override - protected Switch readRootElementAttributes(VoltageLevel.BusBreakerView.SwitchAdder adder, XmlReaderContext context) { - boolean open = XmlUtil.readBoolAttribute(context.getReader(), "open"); - String bus1 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "bus1")); - String bus2 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "bus2")); - return adder.setOpen(open) - .setBus1(bus1) - .setBus2(bus2) - .add(); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusFilter.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusFilter.java deleted file mode 100644 index 88b546e7..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusFilter.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import com.google.common.collect.Iterables; -import eu.itesla_project.iidm.network.*; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -/** - * @author Geoffroy Jamgotchian - */ -public class BusFilter { - - private final Set buses; - - private final XMLExportOptions options; - - static BusFilter create(Network n, XMLExportOptions options) { - Set buses = null; - if (options.isOnlyMainCc()) { - buses = new HashSet<>(); - // keep bus of main cc - if (options.isForceBusBranchTopo()) { - for (Bus b : n.getBusView().getBuses()) { - if (b.isInMainConnectedComponent()) { - buses.add(b.getId()); - } - } - } else { - for (Bus b : n.getBusBreakerView().getBuses()) { - if (b.isInMainConnectedComponent()) { - buses.add(b.getId()); - } - } - } - // and also bus at the other side of open branches - for (TwoTerminalsConnectable branch : Iterables.concat(n.getLines(), n.getTwoWindingsTransformers())) { - Terminal t1 = branch.getTerminal1(); - Terminal t2 = branch.getTerminal2(); - if (options.isForceBusBranchTopo()) { - Bus b1 = t1.getBusView().getConnectableBus(); - Bus b2 = t2.getBusView().getConnectableBus(); - if ((b1 != null && b1.isInMainConnectedComponent()) && b2 != null && !b2.isInMainConnectedComponent()) { - buses.add(b2.getId()); - } else if (b1 != null && !b1.isInMainConnectedComponent() && b2 != null && b2.isInMainConnectedComponent()) { - buses.add(b1.getId()); - } - } else { - Bus b1 = t1.getBusBreakerView().getConnectableBus(); - Bus b2 = t2.getBusBreakerView().getConnectableBus(); - if (b1.isInMainConnectedComponent() && !b2.isInMainConnectedComponent()) { - buses.add(b2.getId()); - } else if (!b1.isInMainConnectedComponent() && b2.isInMainConnectedComponent()) { - buses.add(b1.getId()); - } - } - } - for (ThreeWindingsTransformer twt : n.getThreeWindingsTransformers()) { - throw new AssertionError("TODO"); - } - } - return new BusFilter(buses, options); - } - - BusFilter(Set buses, XMLExportOptions options) { - this.buses = buses; - this.options = Objects.requireNonNull(options); - } - - BusFilter(XMLExportOptions options) { - this(null, options); - } - - public boolean test(Bus b) { - return buses == null || buses.contains(b.getId()); - } - - public boolean test(Connectable connectable) { - if (buses == null) { - return true; - } - for (Terminal t : connectable.getTerminals()) { - Bus b = options.isForceBusBranchTopo() ? t.getBusView().getConnectableBus() : t.getBusBreakerView().getConnectableBus(); - if (b != null && !buses.contains(b.getId())) { - return false; - } - } - return true; - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusXml.java deleted file mode 100644 index 08051ada..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusXml.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.BusAdder; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class BusXml extends IdentifiableXml { - - static final BusXml INSTANCE = new BusXml(); - - static final String ROOT_ELEMENT_NAME = "bus"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(Bus b) { - return false; - } - - @Override - protected void writeRootElementAttributes(Bus b, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("v", b.getV(), context.getWriter()); - XmlUtil.writeFloat("angle", b.getAngle(), context.getWriter()); - } - - @Override - protected void writeSubElements(Bus b, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - } - - @Override - protected BusAdder createAdder(VoltageLevel vl) { - return vl.getBusBreakerView().newBus(); - } - - @Override - protected Bus readRootElementAttributes(BusAdder adder, XmlReaderContext context) { - float v = XmlUtil.readOptionalFloatAttribute(context.getReader(), "v"); - float angle = XmlUtil.readOptionalFloatAttribute(context.getReader(), "angle"); - Bus b = adder.add(); - b.setV(v); - b.setAngle(angle); - return b; - } - - @Override - protected void readSubElements(Bus b, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> BusXml.super.readSubElements(b, context)); - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusbarSectionXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusbarSectionXml.java deleted file mode 100644 index d842c7a8..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/BusbarSectionXml.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Bus; -import eu.itesla_project.iidm.network.BusbarSection; -import eu.itesla_project.iidm.network.BusbarSectionAdder; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class BusbarSectionXml extends IdentifiableXml { - - static final BusbarSectionXml INSTANCE = new BusbarSectionXml(); - - static final String ROOT_ELEMENT_NAME = "busbarSection"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(BusbarSection bs) { - return false; - } - - @Override - protected void writeRootElementAttributes(BusbarSection bs, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeInt("node", bs.getTerminal().getNodeBreakerView().getNode(), context.getWriter()); - XmlUtil.writeFloat("v", bs.getV(), context.getWriter()); - XmlUtil.writeFloat("angle", bs.getAngle(), context.getWriter()); - } - - @Override - protected void writeSubElements(BusbarSection bs, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - } - - @Override - protected BusbarSectionAdder createAdder(VoltageLevel vl) { - return vl.getNodeBreakerView().newBusbarSection(); - } - - @Override - protected BusbarSection readRootElementAttributes(BusbarSectionAdder adder, XmlReaderContext context) { - int node = XmlUtil.readIntAttribute(context.getReader(), "node"); - float v = XmlUtil.readOptionalFloatAttribute(context.getReader(), "v"); - float angle = XmlUtil.readOptionalFloatAttribute(context.getReader(), "angle"); - BusbarSection bbs = adder.setNode(node) - .add(); - context.getEndTasks().add(() -> { - Bus b = bbs.getTerminal().getBusView().getBus(); - if (b != null) { - b.setV(v).setAngle(angle); - } - }); - return bbs; - } - - @Override - protected void readSubElements(BusbarSection bs, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> BusbarSectionXml.super.readSubElements(bs, context)); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ConnectableXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ConnectableXml.java deleted file mode 100644 index 14e4eb9f..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ConnectableXml.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.*; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import java.util.function.Supplier; - -/** - * - * @author Geoffroy Jamgotchian - */ -public abstract class ConnectableXml, P extends Container> extends IdentifiableXml { - - private static String indexToString(Integer index) { - return index != null ? index.toString() : ""; - } - - protected static void writeNodeOrBus(Integer index, Terminal t, XmlWriterContext context) throws XMLStreamException { - if (context.getOptions().isForceBusBranchTopo()) { - Bus bus = t.getBusView().getBus(); - if (bus != null) { - context.getWriter().writeAttribute("bus" + indexToString(index), context.getAnonymizer().anonymizeString(bus.getId())); - } - Bus connectableBus = t.getBusView().getConnectableBus(); - if (connectableBus != null) { - context.getWriter().writeAttribute("connectableBus" + indexToString(index), context.getAnonymizer().anonymizeString(connectableBus.getId())); - } - } else { - switch (t.getVoltageLevel().getTopologyKind()) { - case NODE_BREAKER: - context.getWriter().writeAttribute("node" + indexToString(index), - Integer.toString(t.getNodeBreakerView().getNode())); - break; - - case BUS_BREAKER: - Bus bus = t.getBusBreakerView().getBus(); - if (bus != null) { - context.getWriter().writeAttribute("bus" + indexToString(index), context.getAnonymizer().anonymizeString(bus.getId())); - } - Bus connectableBus = t.getBusBreakerView().getConnectableBus(); - if (connectableBus != null) { - context.getWriter().writeAttribute("connectableBus" + indexToString(index), context.getAnonymizer().anonymizeString(connectableBus.getId())); - } - break; - - default: - throw new AssertionError(); - } - } - if (index != null) { - context.getWriter().writeAttribute("voltageLevelId" + index, context.getAnonymizer().anonymizeString(t.getVoltageLevel().getId())); - } - } - - protected static void readNodeOrBus(SingleTerminalConnectableAdder adder, XmlReaderContext context) { - String bus = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "bus")); - String connectableBus = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "connectableBus")); - Integer node = XmlUtil.readOptionalIntegerAttribute(context.getReader(), "node"); - if (bus != null) { - adder.setBus(bus); - } - if (connectableBus != null) { - adder.setConnectableBus(connectableBus); - } - if (node != null) { - adder.setNode(node); - } - } - - protected static void readNodeOrBus(TwoTerminalsConnectableAdder adder, XmlReaderContext context) { - String bus1 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "bus1")); - String connectableBus1 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "connectableBus1")); - Integer node1 = XmlUtil.readOptionalIntegerAttribute(context.getReader(), "node1"); - String voltageLevelId1 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "voltageLevelId1")); - String bus2 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "bus2")); - String connectableBus2 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "connectableBus2")); - Integer node2 = XmlUtil.readOptionalIntegerAttribute(context.getReader(), "node2"); - String voltageLevelId2 = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "voltageLevelId2")); - if (bus1 != null) { - adder.setBus1(bus1); - } - if (connectableBus1 != null) { - adder.setConnectableBus1(connectableBus1); - } - if (node1 != null) { - adder.setNode1(node1); - } - adder.setVoltageLevel1(voltageLevelId1); - if (bus2 != null) { - adder.setBus2(bus2); - } - if (connectableBus2 != null) { - adder.setConnectableBus2(connectableBus2); - } - if (node2 != null) { - adder.setNode2(node2); - } - adder.setVoltageLevel2(voltageLevelId2); - } - - protected static void writePQ(Integer index, Terminal t, XMLStreamWriter writer) throws XMLStreamException { - if (!Float.isNaN(t.getP())) { - XmlUtil.writeFloat("p" + indexToString(index), t.getP(), writer); - } - if (!Float.isNaN(t.getQ())) { - XmlUtil.writeFloat("q" + indexToString(index), t.getQ(), writer); - } - } - - protected static void readPQ(Integer index, Terminal t, XMLStreamReader reader) { - float p = XmlUtil.readOptionalFloatAttribute(reader, "p" + indexToString(index)); - float q = XmlUtil.readOptionalFloatAttribute(reader, "q" + indexToString(index)); - t.setP(p) - .setQ(q); - } - - public static void readCurrentLimits(Integer index, Supplier currentLimitOwner, XMLStreamReader reader) throws XMLStreamException { - CurrentLimitsAdder adder = currentLimitOwner.get(); - float permanentLimit = XmlUtil.readOptionalFloatAttribute(reader, "permanentLimit"); - adder.setPermanentLimit(permanentLimit); - XmlUtil.readUntilEndElement("currentLimits" + indexToString(index), reader, () -> { - if ("temporaryLimit".equals(reader.getLocalName())) { - String name = reader.getAttributeValue(null, "name"); - int acceptableDuration = XmlUtil.readOptionalIntegerAttribute(reader, "acceptableDuration", Integer.MAX_VALUE); - float value = XmlUtil.readOptionalFloatAttribute(reader, "value", Float.MAX_VALUE); - boolean fictitious = XmlUtil.readOptionalBoolAttribute(reader, "fictitious", false); - adder.beginTemporaryLimit() - .setName(name) - .setAcceptableDuration(acceptableDuration) - .setValue(value) - .setFictitious(fictitious) - .endTemporaryLimit(); - } - }); - adder.add(); - } - - public static void writeCurrentLimits(Integer index, CurrentLimits limits, XMLStreamWriter writer) throws XMLStreamException { - writeCurrentLimits(index, limits, writer, IIDM_URI); - } - - public static void writeCurrentLimits(Integer index, CurrentLimits limits, XMLStreamWriter writer, String nsUri) throws XMLStreamException { - if (!Float.isNaN(limits.getPermanentLimit()) - || limits.getTemporaryLimits().size() > 0) { - if (limits.getTemporaryLimits().isEmpty()) { - writer.writeEmptyElement(nsUri, "currentLimits" + indexToString(index)); - } else { - writer.writeStartElement(nsUri, "currentLimits" + indexToString(index)); - } - XmlUtil.writeFloat("permanentLimit", limits.getPermanentLimit(), writer); - for (CurrentLimits.TemporaryLimit tl : limits.getTemporaryLimits()) { - writer.writeEmptyElement(IIDM_URI, "temporaryLimit"); - writer.writeAttribute("name", tl.getName()); - if (tl.getAcceptableDuration() != Integer.MAX_VALUE) { - writer.writeAttribute("acceptableDuration", Integer.toString(tl.getAcceptableDuration())); - } - if (tl.getValue() != Float.MAX_VALUE) { - writer.writeAttribute("value", Float.toString(tl.getValue())); - } - if (tl.isFictitious()) { - writer.writeAttribute("fictitious", Boolean.toString(tl.isFictitious())); - } - } - if (!limits.getTemporaryLimits().isEmpty()) { - writer.writeEndElement(); - } - } - } - - protected static void writeTerminalRef(Terminal t, XmlWriterContext context, String elementName) throws XMLStreamException { - Connectable c = t.getConnectable(); - if (!context.getFilter().test(c)) { - throw new RuntimeException("Oups, terminal ref point to a filtered equipment " + c.getId()); - } - context.getWriter().writeEmptyElement(IIDM_URI, elementName); - context.getWriter().writeAttribute("id", context.getAnonymizer().anonymizeString(c.getId())); - if (c.getTerminals().size() > 1) { - if (c instanceof SingleTerminalConnectable) { - // nothing to do - } else if (c instanceof TwoTerminalsConnectable) { - TwoTerminalsConnectable branch = (TwoTerminalsConnectable) c; - context.getWriter().writeAttribute("side", branch.getTerminal1() == t - ? TwoTerminalsConnectable.Side.ONE.name() : TwoTerminalsConnectable.Side.TWO.name()); - } else if (c instanceof ThreeWindingsTransformer) { - ThreeWindingsTransformer twt = (ThreeWindingsTransformer) c; - ThreeWindingsTransformer.Side side; - if (twt.getLeg1().getTerminal() == t) { - side = ThreeWindingsTransformer.Side.ONE; - } else if (twt.getLeg2().getTerminal() == t) { - side = ThreeWindingsTransformer.Side.TWO; - } else if (twt.getLeg3().getTerminal() == t) { - side = ThreeWindingsTransformer.Side.THREE; - } else { - throw new InternalError(); - } - context.getWriter().writeAttribute("side", side.name()); - } else { - throw new AssertionError(); - } - } - } - - protected static Terminal readTerminalRef(Network network, String id, String side) { - Identifiable identifiable = network.getIdentifiable(id); - if (identifiable instanceof SingleTerminalConnectable) { - return ((SingleTerminalConnectable) identifiable).getTerminal(); - } else if (identifiable instanceof TwoTerminalsConnectable) { - return side.equals(TwoTerminalsConnectable.Side.ONE.name()) ? ((TwoTerminalsConnectable) identifiable).getTerminal1() - : ((TwoTerminalsConnectable) identifiable).getTerminal2(); - } else if (identifiable instanceof ThreeWindingsTransformer) { - throw new AssertionError("TODO"); // FIXME - } else { - throw new AssertionError(); - } - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/DanglingLineXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/DanglingLineXml.java deleted file mode 100644 index 2b303df6..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/DanglingLineXml.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.DanglingLine; -import eu.itesla_project.iidm.network.DanglingLineAdder; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class DanglingLineXml extends ConnectableXml { - - static final DanglingLineXml INSTANCE = new DanglingLineXml(); - - static final String ROOT_ELEMENT_NAME = "danglingLine"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(DanglingLine dl) { - return dl.getCurrentLimits() != null; - } - - @Override - protected void writeRootElementAttributes(DanglingLine dl, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("p0", dl.getP0(), context.getWriter()); - XmlUtil.writeFloat("q0", dl.getQ0(), context.getWriter()); - XmlUtil.writeFloat("r", dl.getR(), context.getWriter()); - XmlUtil.writeFloat("x", dl.getX(), context.getWriter()); - XmlUtil.writeFloat("g", dl.getG(), context.getWriter()); - XmlUtil.writeFloat("b", dl.getB(), context.getWriter()); - if (dl.getUcteXnodeCode() != null) { - context.getWriter().writeAttribute("ucteXnodeCode", dl.getUcteXnodeCode()); - } - writeNodeOrBus(null, dl.getTerminal(), context); - writePQ(null, dl.getTerminal(), context.getWriter()); - } - - @Override - protected void writeSubElements(DanglingLine dl, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - if (dl.getCurrentLimits() != null) { - writeCurrentLimits(null, dl.getCurrentLimits(), context.getWriter()); - } - } - - @Override - protected DanglingLineAdder createAdder(VoltageLevel vl) { - return vl.newDanglingLine(); - } - - @Override - protected DanglingLine readRootElementAttributes(DanglingLineAdder adder, XmlReaderContext context) { - float p0 = XmlUtil.readFloatAttribute(context.getReader(), "p0"); - float q0 = XmlUtil.readFloatAttribute(context.getReader(), "q0"); - float r = XmlUtil.readFloatAttribute(context.getReader(), "r"); - float x = XmlUtil.readFloatAttribute(context.getReader(), "x"); - float g = XmlUtil.readFloatAttribute(context.getReader(), "g"); - float b = XmlUtil.readFloatAttribute(context.getReader(), "b"); - String ucteXnodeCode = context.getReader().getAttributeValue(null, "ucteXnodeCode"); - readNodeOrBus(adder, context); - DanglingLine dl = adder.setP0(p0) - .setQ0(q0) - .setR(r) - .setX(x) - .setG(g) - .setB(b) - .setUcteXnodeCode(ucteXnodeCode) - .add(); - readPQ(null, dl.getTerminal(), context.getReader()); - return dl; - } - - @Override - protected void readSubElements(DanglingLine dl, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - if ("currentLimits".equals(context.getReader().getLocalName())) { - readCurrentLimits(null, dl::newCurrentLimits, context.getReader()); - } else { - super.readSubElements(dl, context); - } - }); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ExtensionXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ExtensionXml.java deleted file mode 100644 index 9ec084ec..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ExtensionXml.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Identifiable; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.io.InputStream; - -/** - * @author Geoffroy Jamgotchian - */ -public interface ExtensionXml> { - - String getExtensionName(); - - Class getExtensionClass(); - - boolean hasSubElements(); - - InputStream getXsdAsStream(); - - String getNamespaceUri(); - - String getNamespacePrefix(); - - void write(E extension, XmlWriterContext context) throws XMLStreamException; - - E read(I identifiable, XmlReaderContext context) throws XMLStreamException; -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/FakeAnonymizer.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/FakeAnonymizer.java deleted file mode 100644 index 0550819a..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/FakeAnonymizer.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Country; - -import java.io.BufferedReader; -import java.io.BufferedWriter; - -/** - * @author Geoffroy Jamgotchian - */ -public class FakeAnonymizer implements Anonymizer { - @Override - public String anonymizeString(String str) { - return str; - } - - @Override - public String deanonymizeString(String str) { - return str; - } - - @Override - public Country anonymizeCountry(Country country) { - return country; - } - - @Override - public Country deanonymizeCountry(Country country) { - return country; - } - - @Override - public void read(BufferedReader reader) { - } - - @Override - public void write(BufferedWriter writer) { - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/GeneratorXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/GeneratorXml.java deleted file mode 100644 index b7df1a26..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/GeneratorXml.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.*; - -import javax.xml.stream.XMLStreamException; -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -class GeneratorXml extends ConnectableXml { - - static final GeneratorXml INSTANCE = new GeneratorXml(); - - static final String ROOT_ELEMENT_NAME = "generator"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(Generator g) { - return true; - } - - @Override - protected void writeRootElementAttributes(Generator g, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeAttribute("energySource", g.getEnergySource().name()); - XmlUtil.writeFloat("minP", g.getMinP(), context.getWriter()); - XmlUtil.writeFloat("maxP", g.getMaxP(), context.getWriter()); - XmlUtil.writeFloat("ratedS", g.getRatedS(), context.getWriter()); - context.getWriter().writeAttribute("voltageRegulatorOn", Boolean.toString(g.isVoltageRegulatorOn())); - XmlUtil.writeFloat("targetP", g.getTargetP(), context.getWriter()); - XmlUtil.writeFloat("targetV", g.getTargetV(), context.getWriter()); - XmlUtil.writeFloat("targetQ", g.getTargetQ(), context.getWriter()); - writeNodeOrBus(null, g.getTerminal(), context); - writePQ(null, g.getTerminal(), context.getWriter()); - } - - @Override - protected void writeSubElements(Generator g, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - if (g.getRegulatingTerminal() != null - && !Objects.equals(g.getRegulatingTerminal().getBusBreakerView().getConnectableBus(), - g.getTerminal().getBusBreakerView().getConnectableBus())) { - writeTerminalRef(g.getRegulatingTerminal(), context, "regulatingTerminal"); - } - ReactiveLimitsXml.INSTANCE.write(g, context); - } - - @Override - protected GeneratorAdder createAdder(VoltageLevel vl) { - return vl.newGenerator(); - } - - @Override - protected Generator readRootElementAttributes(GeneratorAdder adder, XmlReaderContext context) { - EnergySource energySource = EnergySource.valueOf(context.getReader().getAttributeValue(null, "energySource")); - float minP = XmlUtil.readFloatAttribute(context.getReader(), "minP"); - float maxP = XmlUtil.readFloatAttribute(context.getReader(), "maxP"); - float ratedS = XmlUtil.readOptionalFloatAttribute(context.getReader(), "ratedS"); - boolean voltageRegulatorOn = XmlUtil.readBoolAttribute(context.getReader(), "voltageRegulatorOn"); - float targetP = XmlUtil.readFloatAttribute(context.getReader(), "targetP"); - float targetV = XmlUtil.readOptionalFloatAttribute(context.getReader(), "targetV"); - float targetQ = XmlUtil.readOptionalFloatAttribute(context.getReader(), "targetQ"); - readNodeOrBus(adder, context); - Generator g = adder.setEnergySource(energySource) - .setMinP(minP) - .setMaxP(maxP) - .setRatedS(ratedS) - .setVoltageRegulatorOn(voltageRegulatorOn) - .setTargetP(targetP) - .setTargetV(targetV) - .setTargetQ(targetQ) - .add(); - readPQ(null, g.getTerminal(), context.getReader()); - return g; - } - - @Override - protected void readSubElements(Generator g, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "regulatingTerminal": - String id = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "id")); - String side = context.getReader().getAttributeValue(null, "side"); - context.getEndTasks().add(() -> g.setRegulatingTerminal(readTerminalRef(g.getTerminal().getVoltageLevel().getSubstation().getNetwork(), id, side))); - break; - - case "reactiveCapabilityCurve": - case "minMaxReactiveLimits": - ReactiveLimitsXml.INSTANCE.read(g, context); - break; - - default: - super.readSubElements(g, context); - } - }); - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/HvdcLineXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/HvdcLineXml.java deleted file mode 100644 index d74d4565..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/HvdcLineXml.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.HvdcLine; -import eu.itesla_project.iidm.network.HvdcLineAdder; -import eu.itesla_project.iidm.network.Network; - -import javax.xml.stream.XMLStreamException; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class HvdcLineXml extends IdentifiableXml { - - static final HvdcLineXml INSTANCE = new HvdcLineXml(); - - static final String ROOT_ELEMENT_NAME = "hvdcLine"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(HvdcLine identifiable) { - return false; - } - - @Override - protected void writeRootElementAttributes(HvdcLine l, Network parent, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("r", l.getR(), context.getWriter()); - XmlUtil.writeFloat("nominalV", l.getNominalV(), context.getWriter()); - context.getWriter().writeAttribute("convertersMode", l.getConvertersMode().name()); - XmlUtil.writeFloat("activePowerSetPoint", l.getActivePowerSetPoint(), context.getWriter()); - XmlUtil.writeFloat("maxP", l.getMaxP(), context.getWriter()); - context.getWriter().writeAttribute("converterStation1", l.getConverterStation1().getId()); - context.getWriter().writeAttribute("converterStation2", l.getConverterStation2().getId()); - } - - @Override - protected void writeSubElements(HvdcLine l, Network parent, XmlWriterContext context) throws XMLStreamException { - } - - @Override - protected HvdcLineAdder createAdder(Network n) { - return n.newHvdcLine(); - } - - @Override - protected HvdcLine readRootElementAttributes(HvdcLineAdder adder, XmlReaderContext context) { - float r = XmlUtil.readFloatAttribute(context.getReader(), "r"); - float nominalV = XmlUtil.readFloatAttribute(context.getReader(), "nominalV"); - HvdcLine.ConvertersMode convertersMode = HvdcLine.ConvertersMode.valueOf(context.getReader().getAttributeValue(null, "convertersMode")); - float activePowerSetPoint = XmlUtil.readFloatAttribute(context.getReader(), "activePowerSetPoint"); - float maxP = XmlUtil.readFloatAttribute(context.getReader(), "maxP"); - String converterStation1 = context.getReader().getAttributeValue(null, "converterStation1"); - String converterStation2 = context.getReader().getAttributeValue(null, "converterStation2"); - return adder.setR(r) - .setNominalV(nominalV) - .setConvertersMode(convertersMode) - .setActivePowerSetPoint(activePowerSetPoint) - .setMaxP(maxP) - .setConverterStationId1(converterStation1) - .setConverterStationId2(converterStation2) - .add(); - } - - @Override - protected void readSubElements(HvdcLine l, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> HvdcLineXml.super.readSubElements(l, context)); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/IdentifiableXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/IdentifiableXml.java deleted file mode 100644 index f26d4c0f..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/IdentifiableXml.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Identifiable; -import eu.itesla_project.iidm.network.IdentifiableAdder; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.util.Properties; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class IdentifiableXml, P extends Identifiable> implements XmlConstants { - - protected abstract String getRootElementName(); - - protected abstract boolean hasSubElements(T identifiable); - - protected abstract void writeRootElementAttributes(T identifiable, P parent, XmlWriterContext context) throws XMLStreamException; - - protected abstract void writeSubElements(T identifiable, P parent, XmlWriterContext context) throws XMLStreamException; - - final public void write(T identifiable, P parent, XmlWriterContext context) throws XMLStreamException { - boolean hasSubElements = hasSubElements(identifiable); - if (hasSubElements || identifiable.hasProperty()) { - context.getWriter().writeStartElement(IIDM_URI, getRootElementName()); - } else { - context.getWriter().writeEmptyElement(IIDM_URI, getRootElementName()); - } - context.getWriter().writeAttribute("id", context.getAnonymizer().anonymizeString(identifiable.getId())); - if (!identifiable.getId().equals(identifiable.getName())) { - context.getWriter().writeAttribute("name", context.getAnonymizer().anonymizeString(identifiable.getName())); - } - writeRootElementAttributes(identifiable, parent, context); - if (identifiable.hasProperty()) { - Properties props = identifiable.getProperties(); - for (String name : props.stringPropertyNames()) { - String value = props.getProperty(name); - context.getWriter().writeEmptyElement(IIDM_URI, "property"); - context.getWriter().writeAttribute("name", name); - context.getWriter().writeAttribute("value", value); - } - } - writeSubElements(identifiable, parent, context); - if (hasSubElements || identifiable.hasProperty()) { - context.getWriter().writeEndElement(); - } - } - - protected void readUntilEndRootElement(XMLStreamReader reader, XmlUtil.XmlEventHandler eventHandler) throws XMLStreamException { - XmlUtil.readUntilEndElement(getRootElementName(), reader, eventHandler); - } - - protected abstract A createAdder(P parent); - - protected abstract T readRootElementAttributes(A adder, XmlReaderContext context); - - protected void readSubElements(T identifiable, XmlReaderContext context) throws XMLStreamException { - if (context.getReader().getLocalName().equals("property")) { - String name = context.getReader().getAttributeValue(null, "name"); - String value = context.getReader().getAttributeValue(null, "value"); - identifiable.getProperties().put(name, value); - } else { - throw new AssertionError(); - } - } - - final public void read(P parent, XmlReaderContext context) throws XMLStreamException { - A adder = createAdder(parent); - String id = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "id")); - String name = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "name")); - adder.setId(id) - .setName(name); - T identifiable = readRootElementAttributes(adder, context); - readSubElements(identifiable, context); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LccConverterStationXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LccConverterStationXml.java deleted file mode 100644 index ab6a28e4..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LccConverterStationXml.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.LccConverterStation; -import eu.itesla_project.iidm.network.LccConverterStationAdder; -import eu.itesla_project.iidm.network.LccFilter; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class LccConverterStationXml extends ConnectableXml { - - static final LccConverterStationXml INSTANCE = new LccConverterStationXml(); - - static final String ROOT_ELEMENT_NAME = "lccConverterStation"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(LccConverterStation cs) { - return cs.getFilterCount() > 0; - } - - @Override - protected void writeRootElementAttributes(LccConverterStation cs, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("powerFactor", cs.getPowerFactor(), context.getWriter()); - writeNodeOrBus(null, cs.getTerminal(), context); - writePQ(null, cs.getTerminal(), context.getWriter()); - } - - @Override - protected void writeSubElements(LccConverterStation cs, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - for (LccFilter filter : cs.getFilters()) { - context.getWriter().writeEmptyElement(IIDM_URI, "filter"); - XmlUtil.writeFloat("b", filter.getB(), context.getWriter()); - context.getWriter().writeAttribute("connected", Boolean.toString(filter.isConnected())); - } - } - - @Override - protected LccConverterStationAdder createAdder(VoltageLevel vl) { - return vl.newLccConverterStation(); - } - - @Override - protected LccConverterStation readRootElementAttributes(LccConverterStationAdder adder, XmlReaderContext context) { - float powerFactor = XmlUtil.readOptionalFloatAttribute(context.getReader(), "powerFactor"); - readNodeOrBus(adder, context); - LccConverterStation cs = adder.setPowerFactor(powerFactor).add(); - readPQ(null, cs.getTerminal(), context.getReader()); - return cs; - } - - @Override - protected void readSubElements(LccConverterStation cs, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "filter": - float b = XmlUtil.readOptionalFloatAttribute(context.getReader(), "b"); - boolean connected = XmlUtil.readBoolAttribute(context.getReader(), "connected"); - cs.newFilter() - .setB(b) - .setConnected(connected) - .add(); - break; - - default: - super.readSubElements(cs, context); - } - }); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LineXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LineXml.java deleted file mode 100644 index cec79281..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LineXml.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Line; -import eu.itesla_project.iidm.network.LineAdder; -import eu.itesla_project.iidm.network.Network; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class LineXml extends ConnectableXml { - - static final LineXml INSTANCE = new LineXml(); - - static final String ROOT_ELEMENT_NAME = "line"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(Line l) { - return l.getCurrentLimits1() != null || l.getCurrentLimits2() != null; - } - - @Override - protected void writeRootElementAttributes(Line l, Network n, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("r", l.getR(), context.getWriter()); - XmlUtil.writeFloat("x", l.getX(), context.getWriter()); - XmlUtil.writeFloat("g1", l.getG1(), context.getWriter()); - XmlUtil.writeFloat("b1", l.getB1(), context.getWriter()); - XmlUtil.writeFloat("g2", l.getG2(), context.getWriter()); - XmlUtil.writeFloat("b2", l.getB2(), context.getWriter()); - writeNodeOrBus(1, l.getTerminal1(), context); - writeNodeOrBus(2, l.getTerminal2(), context); - if (context.getOptions().isWithBranchSV()) { - writePQ(1, l.getTerminal1(), context.getWriter()); - writePQ(2, l.getTerminal2(), context.getWriter()); - } - } - - @Override - protected void writeSubElements(Line l, Network n, XmlWriterContext context) throws XMLStreamException { - if (l.getCurrentLimits1() != null) { - writeCurrentLimits(1, l.getCurrentLimits1(), context.getWriter()); - } - if (l.getCurrentLimits2() != null) { - writeCurrentLimits(2, l.getCurrentLimits2(), context.getWriter()); - } - } - - @Override - protected LineAdder createAdder(Network n) { - return n.newLine(); - } - - @Override - protected Line readRootElementAttributes(LineAdder adder, XmlReaderContext context) { - float r = XmlUtil.readFloatAttribute(context.getReader(), "r"); - float x = XmlUtil.readFloatAttribute(context.getReader(), "x"); - float g1 = XmlUtil.readFloatAttribute(context.getReader(), "g1"); - float b1 = XmlUtil.readFloatAttribute(context.getReader(), "b1"); - float g2 = XmlUtil.readFloatAttribute(context.getReader(), "g2"); - float b2 = XmlUtil.readFloatAttribute(context.getReader(), "b2"); - adder.setR(r) - .setX(x) - .setG1(g1) - .setB1(b1) - .setG2(g2) - .setB2(b2); - readNodeOrBus(adder, context); - Line l = adder.add(); - readPQ(1, l.getTerminal1(), context.getReader()); - readPQ(2, l.getTerminal2(), context.getReader()); - return l; - } - - @Override - protected void readSubElements(Line l, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "currentLimits1": - readCurrentLimits(1, l::newCurrentLimits1, context.getReader()); - break; - - case "currentLimits2": - readCurrentLimits(2, l::newCurrentLimits2, context.getReader()); - break; - - default: - super.readSubElements(l, context); - } - }); - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LoadXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LoadXml.java deleted file mode 100644 index ce5d34dd..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/LoadXml.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.LoadAdder; -import eu.itesla_project.iidm.network.LoadType; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class LoadXml extends ConnectableXml { - - static final LoadXml INSTANCE = new LoadXml(); - - static final String ROOT_ELEMENT_NAME = "load"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(Load l) { - return false; - } - - @Override - protected void writeRootElementAttributes(Load l, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeAttribute("loadType", l.getLoadType().name()); - XmlUtil.writeFloat("p0", l.getP0(), context.getWriter()); - XmlUtil.writeFloat("q0", l.getQ0(), context.getWriter()); - writeNodeOrBus(null, l.getTerminal(), context); - writePQ(null, l.getTerminal(), context.getWriter()); - } - - @Override - protected void writeSubElements(Load l, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - } - - @Override - protected LoadAdder createAdder(VoltageLevel vl) { - return vl.newLoad(); - } - - @Override - protected Load readRootElementAttributes(LoadAdder adder, XmlReaderContext context) { - String loadTypeStr = context.getReader().getAttributeValue(null, "loadType"); - LoadType loadType = loadTypeStr == null ? LoadType.UNDEFINED : LoadType.valueOf(loadTypeStr); - float p0 = XmlUtil.readFloatAttribute(context.getReader(), "p0"); - float q0 = XmlUtil.readFloatAttribute(context.getReader(), "q0"); - readNodeOrBus(adder, context); - Load l = adder.setLoadType(loadType) - .setP0(p0) - .setQ0(q0) - .add(); - readPQ(null, l.getTerminal(), context.getReader()); - return l; - } - - @Override - protected void readSubElements(Load l, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> LoadXml.super.readSubElements(l, context)); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NetworkXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NetworkXml.java deleted file mode 100644 index 5339deb1..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NetworkXml.java +++ /dev/null @@ -1,445 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import eu.itesla_project.commons.util.ServiceLoaderCache; -import eu.itesla_project.iidm.network.*; -import javanet.staxutils.IndentingXMLStreamWriter; -import org.joda.time.DateTime; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xml.sax.SAXException; - -import javax.xml.XMLConstants; -import javax.xml.stream.*; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamSource; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.stream.Collectors; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class NetworkXml implements XmlConstants { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetworkXml.class); - - static final String NETWORK_ROOT_ELEMENT_NAME = "network"; - private static final String EXTENSION_ELEMENT_NAME = "extension"; - private static final String IIDM_XSD = "iidm.xsd"; - - // cache XMLOutputFactory to improve performance - private static final Supplier XML_OUTPUT_FACTORY_SUPPLIER = Suppliers.memoize(XMLOutputFactory::newFactory); - - private static final Supplier XML_INPUT_FACTORY_SUPPLIER = Suppliers.memoize(XMLInputFactory::newInstance); - - private static final Supplier> EXTENSIONS_SUPPLIER - = Suppliers.memoize(() -> new ServiceLoaderCache<>(ExtensionXml.class).getServices().stream() - .collect(Collectors.toMap(extensionXml -> extensionXml.getExtensionName(), e -> e))); - - private static XMLStreamWriter createXmlStreamWriter(XMLExportOptions options, OutputStream os) throws XMLStreamException { - XMLStreamWriter writer = XML_OUTPUT_FACTORY_SUPPLIER.get().createXMLStreamWriter(os, StandardCharsets.UTF_8.toString()); - if (options.isIndent()) { - IndentingXMLStreamWriter indentingWriter = new IndentingXMLStreamWriter(writer); - indentingWriter.setIndent(INDENT); - writer = indentingWriter; - } - return writer; - } - - private static ExtensionXml findExtensionXml(String name) { - return EXTENSIONS_SUPPLIER.get().get(name); - } - - private static ExtensionXml findExtensionXmlOrThrowException(String name) { - ExtensionXml extensionXml = findExtensionXml(name); - if (extensionXml == null) { - throw new RuntimeException("Xml serializer not found for extension " + name); - } - return extensionXml; - } - - private static Set getNetworkExtensions(Network n) { - Set extensions = new TreeSet<>(); - for (Identifiable identifiable : n.getIdentifiables()) { - for (Identifiable.Extension> extension : identifiable.getExtensions()) { - extensions.add(extension.getName()); - } - } - return extensions; - } - - private static void validate(Source xml, List additionalSchemas) { - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - Source[] sources = new Source[additionalSchemas.size() + 1]; - sources[0] = new StreamSource(NetworkXml.class.getResourceAsStream("/xsd/" + IIDM_XSD)); - for (int i = 0 ; i < additionalSchemas.size(); i++) { - sources[i+1] = additionalSchemas.get(i); - } - try { - Schema schema = factory.newSchema(sources); - Validator validator = schema.newValidator(); - validator.validate(xml); - } catch (SAXException|IOException e) { - throw new RuntimeException(e); - } - } - - static void validate(InputStream is) { - validate(new StreamSource(is), Collections.emptyList()); - } - - static void validate(Path file) { - try (InputStream is = Files.newInputStream(file)) { - validate(is); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - static void validateWithExtensions(InputStream is) { - List additionalSchemas = EXTENSIONS_SUPPLIER.get().entrySet().stream() - .map(e -> new StreamSource(e.getValue().getXsdAsStream())) - .collect(Collectors.toList()); - validate(new StreamSource(is), additionalSchemas); - } - - static void validateWithExtensions(Path file) { - try (InputStream is = Files.newInputStream(file)) { - validateWithExtensions(is); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private static void writeExtensionNamespaces(Network n, XMLStreamWriter writer) throws XMLStreamException { - Set extensionUris = new HashSet<>(); - Set extensionPrefixes = new HashSet<>(); - for (String extensionName : getNetworkExtensions(n)) { - ExtensionXml extensionXml = findExtensionXmlOrThrowException(extensionName); - if (extensionUris.contains(extensionXml.getNamespaceUri())) { - throw new RuntimeException("Extension namespace URI collision"); - } else { - extensionUris.add(extensionXml.getNamespaceUri()); - } - if (extensionPrefixes.contains(extensionXml.getNamespacePrefix())) { - throw new RuntimeException("Extension namespace prefix collision"); - } else { - extensionPrefixes.add(extensionXml.getNamespacePrefix()); - } - writer.setPrefix(extensionXml.getNamespacePrefix(), extensionXml.getNamespaceUri()); - writer.writeNamespace(extensionXml.getNamespacePrefix(), extensionXml.getNamespaceUri()); - } - } - - private static void writeExtensions(Network n, XmlWriterContext context) throws XMLStreamException { - for (Identifiable identifiable : n.getIdentifiables()) { - for (Identifiable.Extension> extension : identifiable.getExtensions()) { - ExtensionXml extensionXml = findExtensionXmlOrThrowException(extension.getName()); - context.getWriter().writeStartElement(IIDM_URI, EXTENSION_ELEMENT_NAME); - context.getWriter().writeAttribute("id", context.getAnonymizer().anonymizeString(extension.getIdentifiable().getId())); - if (extensionXml.hasSubElements()) { - context.getWriter().writeStartElement(extensionXml.getNamespaceUri(), extension.getName()); - } else { - context.getWriter().writeEmptyElement(extensionXml.getNamespaceUri(), extension.getName()); - } - extensionXml.write(extension, context); - if (extensionXml.hasSubElements()) { - context.getWriter().writeEndElement(); - } - context.getWriter().writeEndElement(); - } - } - } - - public static Anonymizer write(Network n, XMLExportOptions options, OutputStream os) { - try { - final XMLStreamWriter writer = createXmlStreamWriter(options, os); - writer.writeStartDocument(StandardCharsets.UTF_8.toString(), "1.0"); - - writer.setPrefix(IIDM_PREFIX, IIDM_URI); - writer.writeStartElement(IIDM_URI, NETWORK_ROOT_ELEMENT_NAME); - writer.writeNamespace(IIDM_PREFIX, IIDM_URI); - - if (!options.isSkipExtensions()) { - // add additional extension namespaces and check there is no collision between extensions - writeExtensionNamespaces(n, writer); - } - - writer.writeAttribute("id", n.getId()); - writer.writeAttribute("caseDate", n.getCaseDate().toString()); - writer.writeAttribute("forecastDistance", Integer.toString(n.getForecastDistance())); - writer.writeAttribute("sourceFormat", n.getSourceFormat()); - BusFilter filter = BusFilter.create(n, options); - Anonymizer anonymizer = options.isAnonymized() ? new SimpleAnonymizer() : null; - XmlWriterContext context = new XmlWriterContext(anonymizer, writer, options, filter); - for (Substation s : n.getSubstations()) { - SubstationXml.INSTANCE.write(s, null, context); - } - for (Line l : n.getLines()) { - if (!filter.test(l)) { - continue; - } - if (l.isTieLine()) { - TieLineXml.INSTANCE.write((TieLine) l, n, context); - } else { - LineXml.INSTANCE.write(l, n, context); - } - } - for (HvdcLine l : n.getHvdcLines()) { - if (!filter.test(l.getConverterStation1()) && filter.test(l.getConverterStation2())) { - continue; - } - HvdcLineXml.INSTANCE.write(l, n, context); - } - - if (!options.isSkipExtensions()) { - // write extensions - writeExtensions(n, context); - } - - writer.writeEndElement(); - writer.writeEndDocument(); - - return anonymizer; - } catch (XMLStreamException e) { - throw new RuntimeException(e); - } - } - - public static Anonymizer write(Network n, OutputStream os) { - return write(n, new XMLExportOptions(), os); - } - - public static Anonymizer write(Network n, XMLExportOptions options, Path xmlFile) { - try (OutputStream os = Files.newOutputStream(xmlFile)) { - return write(n, options, os); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static Anonymizer write(Network n, Path xmlFile) { - return write(n, new XMLExportOptions(), xmlFile); - } - - public static Anonymizer writeAndValidate(Network n, Path xmlFile) { - Anonymizer anonymizer = write(n, xmlFile); - validateWithExtensions(xmlFile); - return anonymizer; - } - - public static Network read(InputStream is) { - return read(is, new XmlImportConfig(), null); - } - - public static Network read(InputStream is, XmlImportConfig config, Anonymizer anonymizer) { - try { - XMLStreamReader reader = XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(is); - reader.next(); - - String id = reader.getAttributeValue(null, "id"); - DateTime date = DateTime.parse(reader.getAttributeValue(null, "caseDate")); - int forecastDistance = XmlUtil.readOptionalIntegerAttribute(reader, "forecastDistance", 0); - String sourceFormat = reader.getAttributeValue(null, "sourceFormat"); - - Network network = NetworkFactory.create(id, sourceFormat); - network.setCaseDate(date); - network.setForecastDistance(forecastDistance); - - XmlReaderContext context = new XmlReaderContext(anonymizer, reader); - - Set extensionNamesNotFound = new TreeSet<>(); - - XmlUtil.readUntilEndElement(NETWORK_ROOT_ELEMENT_NAME, reader, () -> { - switch (reader.getLocalName()) { - case SubstationXml.ROOT_ELEMENT_NAME: - SubstationXml.INSTANCE.read(network, context); - break; - - case LineXml.ROOT_ELEMENT_NAME: - LineXml.INSTANCE.read(network, context); - break; - - case TieLineXml.ROOT_ELEMENT_NAME: - TieLineXml.INSTANCE.read(network, context); - break; - - case HvdcLineXml.ROOT_ELEMENT_NAME: - HvdcLineXml.INSTANCE.read(network, context); - break; - - case EXTENSION_ELEMENT_NAME: - String id2 = context.getAnonymizer().deanonymizeString(reader.getAttributeValue(null, "id")); - Identifiable identifiable = network.getIdentifiable(id2); - if (identifiable == null) { - throw new RuntimeException("Identifiable " + id2 + " not found"); - } - XmlUtil.readUntilEndElement(EXTENSION_ELEMENT_NAME, reader, () -> { - String extensionName = reader.getLocalName(); - ExtensionXml extensionXml = findExtensionXml(extensionName); - if (extensionXml != null) { - Identifiable.Extension> extension = extensionXml.read(identifiable, context); - identifiable.addExtension(extensionXml.getExtensionClass(), extension); - } else { - extensionNamesNotFound.add(extensionName); - } - }); - break; - - default: - throw new AssertionError(); - } - }); - - context.getEndTasks().forEach(Runnable::run); - - if (extensionNamesNotFound.size() > 0) { - if (config.isThrowExceptionIfExtensionNotFound()) { - throw new RuntimeException("Extensions " + extensionNamesNotFound + " not found"); - } else { - LOGGER.error("Extensions {} not found", extensionNamesNotFound); - } - } - - return network; - } catch (XMLStreamException e) { - throw new RuntimeException(e); - } - } - - public static Network read(Path xmlFile) { - try (InputStream is = Files.newInputStream(xmlFile)) { - return read(is); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static Network validateAndRead(Path xmlFile) { - validateWithExtensions(xmlFile); - return read(xmlFile); - } - - public static void update(Network network, InputStream is) { - try { - XMLStreamReader reader = XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(is); - reader.next(); - - final VoltageLevel[] vl = new VoltageLevel[1]; - - XmlUtil.readUntilEndElement(NETWORK_ROOT_ELEMENT_NAME, reader, () -> { - - switch (reader.getLocalName()) { - case VoltageLevelXml.ROOT_ELEMENT_NAME: { - String id = reader.getAttributeValue(null, "id"); - vl[0] = network.getVoltageLevel(id); - if (vl[0] == null) { - throw new RuntimeException("Voltage level '" + id + "' not found"); - } - break; - } - - case BusXml.ROOT_ELEMENT_NAME: { - String id = reader.getAttributeValue(null, "id"); - float v = XmlUtil.readFloatAttribute(reader, "v"); - float angle = XmlUtil.readFloatAttribute(reader, "angle"); - Bus b = vl[0].getBusBreakerView().getBus(id); - if (b == null) { - b = vl[0].getBusView().getBus(id); - } - b.setV(v > 0 ? v : Float.NaN).setAngle(angle); - break; - } - - case GeneratorXml.ROOT_ELEMENT_NAME: - case LoadXml.ROOT_ELEMENT_NAME: - case ShuntXml.ROOT_ELEMENT_NAME: - case DanglingLineXml.ROOT_ELEMENT_NAME: - case LccConverterStationXml.ROOT_ELEMENT_NAME: - case VscConverterStationXml.ROOT_ELEMENT_NAME: { - String id = reader.getAttributeValue(null, "id"); - float p = XmlUtil.readOptionalFloatAttribute(reader, "p"); - float q = XmlUtil.readOptionalFloatAttribute(reader, "q"); - SingleTerminalConnectable inj = (SingleTerminalConnectable) network.getIdentifiable(id); - inj.getTerminal().setP(p).setQ(q); - break; - } - - case LineXml.ROOT_ELEMENT_NAME: - case TwoWindingsTransformerXml.ROOT_ELEMENT_NAME: { - String id = reader.getAttributeValue(null, "id"); - float p1 = XmlUtil.readOptionalFloatAttribute(reader, "p1"); - float q1 = XmlUtil.readOptionalFloatAttribute(reader, "q1"); - float p2 = XmlUtil.readOptionalFloatAttribute(reader, "p2"); - float q2 = XmlUtil.readOptionalFloatAttribute(reader, "q2"); - TwoTerminalsConnectable branch = (TwoTerminalsConnectable) network.getIdentifiable(id); - branch.getTerminal1().setP(p1).setQ(q1); - branch.getTerminal2().setP(p2).setQ(q2); - break; - } - - case HvdcLineXml.ROOT_ELEMENT_NAME: { - // Nothing to do - } - - case ThreeWindingsTransformerXml.ROOT_ELEMENT_NAME: - throw new AssertionError(); - } - }); - } catch (XMLStreamException e) { - throw new RuntimeException(e); - } - } - - public static void update(Network network, Path xmlFile) { - try (InputStream is = Files.newInputStream(xmlFile)) { - update(network, is); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static byte[] gzip(Network network) { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try (GZIPOutputStream gzos = new GZIPOutputStream(bos)) { - NetworkXml.write(network, gzos); - } catch (IOException e) { - throw new RuntimeException(e); - } - return bos.toByteArray(); - } - - public static Network gunzip(byte[] networkXmlGz) { - try (InputStream is = new GZIPInputStream(new ByteArrayInputStream(networkXmlGz))) { - return NetworkXml.read(is); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - /** - * Deep copy of the network using XML converter. - * @param network the network to copy - * @return the copy of the network - */ - public static Network copy(Network network) { - return gunzip(gzip(network)); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NodeBreakerViewSwitchXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NodeBreakerViewSwitchXml.java deleted file mode 100644 index 5a79e420..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/NodeBreakerViewSwitchXml.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Switch; -import eu.itesla_project.iidm.network.SwitchKind; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * @author Geoffroy Jamgotchian - */ -public class NodeBreakerViewSwitchXml extends SwitchXml { - - static final NodeBreakerViewSwitchXml INSTANCE = new NodeBreakerViewSwitchXml(); - - @Override - protected void writeRootElementAttributes(Switch s, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - super.writeRootElementAttributes(s, vl, context); - VoltageLevel.NodeBreakerView v = vl.getNodeBreakerView(); - context.getWriter().writeAttribute("node1", Integer.toString(v.getNode1(s.getId()))); - context.getWriter().writeAttribute("node2", Integer.toString(v.getNode2(s.getId()))); - } - - @Override - protected VoltageLevel.NodeBreakerView.SwitchAdder createAdder(VoltageLevel vl) { - return vl.getNodeBreakerView().newSwitch(); - } - - @Override - protected Switch readRootElementAttributes(VoltageLevel.NodeBreakerView.SwitchAdder adder, XmlReaderContext context) { - boolean open = XmlUtil.readBoolAttribute(context.getReader(), "open"); - SwitchKind kind = SwitchKind.valueOf(context.getReader().getAttributeValue(null, "kind")); - boolean retained = XmlUtil.readBoolAttribute(context.getReader(), "retained"); - int node1 = XmlUtil.readIntAttribute(context.getReader(), "node1"); - int node2 = XmlUtil.readIntAttribute(context.getReader(), "node2"); - return adder.setKind(kind) - .setRetained(retained) - .setOpen(open) - .setNode1(node1) - .setNode2(node2) - .add(); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ReactiveLimitsXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ReactiveLimitsXml.java deleted file mode 100644 index c0257107..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ReactiveLimitsXml.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.MinMaxReactiveLimits; -import eu.itesla_project.iidm.network.ReactiveCapabilityCurve; -import eu.itesla_project.iidm.network.ReactiveCapabilityCurveAdder; -import eu.itesla_project.iidm.network.ReactiveLimitsHolder; - -import javax.xml.stream.XMLStreamException; - -/** - * @author Mathieu Bague - */ -public class ReactiveLimitsXml implements XmlConstants { - - static final ReactiveLimitsXml INSTANCE = new ReactiveLimitsXml(); - - public void write(ReactiveLimitsHolder holder, XmlWriterContext context) throws XMLStreamException { - switch (holder.getReactiveLimits().getKind()) { - case CURVE: { - ReactiveCapabilityCurve curve = holder.getReactiveLimits(ReactiveCapabilityCurve.class); - context.getWriter().writeStartElement(IIDM_URI, "reactiveCapabilityCurve"); - for (ReactiveCapabilityCurve.Point point : curve.getPoints()) { - context.getWriter().writeEmptyElement(IIDM_URI, "point"); - XmlUtil.writeFloat("p", point.getP(), context.getWriter()); - XmlUtil.writeFloat("minQ", point.getMinQ(), context.getWriter()); - XmlUtil.writeFloat("maxQ", point.getMaxQ(), context.getWriter()); - } - context.getWriter().writeEndElement(); - } - break; - - case MIN_MAX: { - MinMaxReactiveLimits limits = holder.getReactiveLimits(MinMaxReactiveLimits.class); - context.getWriter().writeEmptyElement(IIDM_URI, "minMaxReactiveLimits"); - XmlUtil.writeFloat("minQ", limits.getMinQ(), context.getWriter()); - XmlUtil.writeFloat("maxQ", limits.getMaxQ(), context.getWriter()); - } - break; - - default: - throw new AssertionError(); - } - } - - public void read(ReactiveLimitsHolder holder, XmlReaderContext context) throws XMLStreamException { - switch (context.getReader().getLocalName()) { - case "reactiveCapabilityCurve": - ReactiveCapabilityCurveAdder curveAdder = holder.newReactiveCapabilityCurve(); - XmlUtil.readUntilEndElement("reactiveCapabilityCurve", context.getReader(), () -> { - if (context.getReader().getLocalName().equals("point")) { - float p = XmlUtil.readFloatAttribute(context.getReader(), "p"); - float minQ = XmlUtil.readFloatAttribute(context.getReader(), "minQ"); - float maxQ = XmlUtil.readFloatAttribute(context.getReader(), "maxQ"); - curveAdder.beginPoint() - .setP(p) - .setMinQ(minQ) - .setMaxQ(maxQ) - .endPoint(); - } - }); - curveAdder.add(); - break; - - case "minMaxReactiveLimits": - float min = XmlUtil.readFloatAttribute(context.getReader(), "minQ"); - float max = XmlUtil.readFloatAttribute(context.getReader(), "maxQ"); - holder.newMinMaxReactiveLimits() - .setMinQ(min) - .setMaxQ(max) - .add(); - break; - - default: - - } - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ShuntXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ShuntXml.java deleted file mode 100644 index 72919814..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ShuntXml.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.ShuntCompensator; -import eu.itesla_project.iidm.network.ShuntCompensatorAdder; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ShuntXml extends ConnectableXml { - - static final ShuntXml INSTANCE = new ShuntXml(); - - static final String ROOT_ELEMENT_NAME = "shunt"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(ShuntCompensator sc) { - return false; - } - - @Override - protected void writeRootElementAttributes(ShuntCompensator sc, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("bPerSection", sc.getbPerSection(), context.getWriter()); - context.getWriter().writeAttribute("maximumSectionCount", Integer.toString(sc.getMaximumSectionCount())); - context.getWriter().writeAttribute("currentSectionCount", Integer.toString(sc.getCurrentSectionCount())); - writeNodeOrBus(null, sc.getTerminal(), context); - writePQ(null, sc.getTerminal(), context.getWriter()); - } - - @Override - protected void writeSubElements(ShuntCompensator sc, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - } - - @Override - protected ShuntCompensatorAdder createAdder(VoltageLevel vl) { - return vl.newShunt(); - } - - @Override - protected ShuntCompensator readRootElementAttributes(ShuntCompensatorAdder adder, XmlReaderContext context) { - float bPerSection = XmlUtil.readFloatAttribute(context.getReader(), "bPerSection"); - int maximumSectionCount = XmlUtil.readIntAttribute(context.getReader(), "maximumSectionCount"); - int currentSectionCount = XmlUtil.readIntAttribute(context.getReader(), "currentSectionCount"); - adder.setbPerSection(bPerSection) - .setMaximumSectionCount(maximumSectionCount) - .setCurrentSectionCount(currentSectionCount); - readNodeOrBus(adder, context); - ShuntCompensator sc = adder.add(); - readPQ(null, sc.getTerminal(), context.getReader()); - return sc; - } - - @Override - protected void readSubElements(ShuntCompensator sc, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> ShuntXml.super.readSubElements(sc, context)); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SimpleAnonymizer.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SimpleAnonymizer.java deleted file mode 100644 index 0de428fb..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SimpleAnonymizer.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import eu.itesla_project.iidm.network.Country; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; - -/** - * @author Geoffroy Jamgotchian - */ -public class SimpleAnonymizer implements Anonymizer { - - private static final String SEPARATOR = ";"; - - private final BiMap mapping = HashBiMap.create(); - - public static String getAlpha(int num) { - StringBuilder result = new StringBuilder(); - while (num > 0) { - num--; - int remainder = num % 26; - char digit = (char) (remainder + 97); - result.insert(0, digit); - num = (num - remainder) / 26; - } - return result.toString(); - } - - @Override - public String anonymizeString(String str) { - if (str == null) { - return null; - } - String str2 = mapping.get(str); - if (str2 == null) { - str2 = getAlpha(mapping.size() + 1).toUpperCase(); - mapping.put(str, str2); - } - return str2; - } - - @Override - public String deanonymizeString(String str) { - if (str == null) { - return null; - } - String str2 = mapping.inverse().get(str); - if (str2 == null) { - throw new RuntimeException("Mapping not for anonymized string '" + str + "'"); - } - return str2; - } - - @Override - public Country anonymizeCountry(Country country) { - return country; - } - - @Override - public Country deanonymizeCountry(Country country) { - return country; - } - - @Override - public void read(BufferedReader reader) { - try { - String line; - while ((line = reader.readLine()) != null) { - String[] tokens = line.split(SEPARATOR); - mapping.put(tokens[0], tokens[1]); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void write(BufferedWriter writer) { - mapping.forEach((s, s2) -> { - try { - writer.write(s); - writer.write(SEPARATOR); - writer.write(s2); - writer.newLine(); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXml.java deleted file mode 100644 index 42711400..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXml.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.StaticVarCompensator; -import eu.itesla_project.iidm.network.StaticVarCompensatorAdder; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * @author Geoffroy Jamgotchian - */ -public class StaticVarCompensatorXml extends ConnectableXml { - - static final StaticVarCompensatorXml INSTANCE = new StaticVarCompensatorXml(); - - static final String ROOT_ELEMENT_NAME = "staticVarCompensator"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(StaticVarCompensator svc) { - return false; - } - - @Override - protected void writeRootElementAttributes(StaticVarCompensator svc, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("bMin", svc.getBmin(), context.getWriter()); - XmlUtil.writeFloat("bMax", svc.getBmax(), context.getWriter()); - XmlUtil.writeFloat("voltageSetPoint", svc.getVoltageSetPoint(), context.getWriter()); - XmlUtil.writeFloat("reactivePowerSetPoint", svc.getReactivePowerSetPoint(), context.getWriter()); - context.getWriter().writeAttribute("regulationMode", svc.getRegulationMode().name()); - writeNodeOrBus(null, svc.getTerminal(), context); - writePQ(null, svc.getTerminal(), context.getWriter()); - } - - @Override - protected void writeSubElements(StaticVarCompensator svc, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - } - - @Override - protected StaticVarCompensatorAdder createAdder(VoltageLevel vl) { - return vl.newStaticVarCompensator(); - } - - @Override - protected StaticVarCompensator readRootElementAttributes(StaticVarCompensatorAdder adder, XmlReaderContext context) { - float bMin = XmlUtil.readFloatAttribute(context.getReader(), "bMin"); - float bMax = XmlUtil.readFloatAttribute(context.getReader(), "bMax"); - float voltageSetPoint = XmlUtil.readOptionalFloatAttribute(context.getReader(), "voltageSetPoint"); - float reactivePowerSetPoint = XmlUtil.readOptionalFloatAttribute(context.getReader(), "reactivePowerSetPoint"); - StaticVarCompensator.RegulationMode regulationMode = StaticVarCompensator.RegulationMode.valueOf(context.getReader().getAttributeValue(null, "regulationMode")); - adder.setBmin(bMin) - .setBmax(bMax) - .setVoltageSetPoint(voltageSetPoint) - .setReactivePowerSetPoint(reactivePowerSetPoint) - .setRegulationMode(regulationMode); - readNodeOrBus(adder, context); - StaticVarCompensator svc = adder.add(); - readPQ(null, svc.getTerminal(), context.getReader()); - return svc; - } - - @Override - protected void readSubElements(StaticVarCompensator svc, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> super.readSubElements(svc, context)); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SubstationXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SubstationXml.java deleted file mode 100644 index 09a5d49a..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SubstationXml.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.*; - -import javax.xml.stream.XMLStreamException; -import java.util.Arrays; -import java.util.stream.Collectors; - -/** - * - * @author Geoffroy Jamgotchian - */ -class SubstationXml extends IdentifiableXml { - - static final SubstationXml INSTANCE = new SubstationXml(); - - static final String ROOT_ELEMENT_NAME = "substation"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(Substation s) { - return true; - } - - @Override - protected void writeRootElementAttributes(Substation s, Network n, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeAttribute("country", context.getAnonymizer().anonymizeCountry(s.getCountry()).toString()); - if (s.getTso() != null) { - context.getWriter().writeAttribute("tso", context.getAnonymizer().anonymizeString(s.getTso())); - } - if (s.getGeographicalTags().size() > 0) { - context.getWriter().writeAttribute("geographicalTags", s.getGeographicalTags().stream() - .map(tag -> context.getAnonymizer().anonymizeString(tag)) - .collect(Collectors.joining(","))); - } - } - - @Override - protected void writeSubElements(Substation s, Network n, XmlWriterContext context) throws XMLStreamException { - for (VoltageLevel vl : s.getVoltageLevels()) { - VoltageLevelXml.INSTANCE.write(vl, null, context); - } - Iterable twts = s.getTwoWindingsTransformers(); - for (TwoWindingsTransformer twt : twts) { - if (!context.getFilter().test(twt)) { - continue; - } - TwoWindingsTransformerXml.INSTANCE.write(twt, null, context); - } - Iterable twts2 = s.getThreeWindingsTransformers(); - for (ThreeWindingsTransformer twt : twts2) { - if (!context.getFilter().test(twt)) { - continue; - } - ThreeWindingsTransformerXml.INSTANCE.write(twt, null, context); - } - } - - @Override - protected SubstationAdder createAdder(Network network) { - return network.newSubstation(); - } - - @Override - protected Substation readRootElementAttributes(SubstationAdder adder, XmlReaderContext context) { - Country country = context.getAnonymizer().deanonymizeCountry(Country.valueOf(context.getReader().getAttributeValue(null, "country"))); - String tso = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "tso")); - String geographicalTags = context.getReader().getAttributeValue(null, "geographicalTags"); - if (geographicalTags != null) { - adder.setGeographicalTags(Arrays.stream(geographicalTags.split(",")) - .map(tag -> context.getAnonymizer().deanonymizeString(tag)) - .toArray(size -> new String[size])); - } - return adder.setCountry(country) - .setTso(tso) - .add(); - } - - @Override - protected void readSubElements(Substation s, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case VoltageLevelXml.ROOT_ELEMENT_NAME: - VoltageLevelXml.INSTANCE.read(s, context); - break; - - case TwoWindingsTransformerXml.ROOT_ELEMENT_NAME: - TwoWindingsTransformerXml.INSTANCE.read(s, context); - break; - - case ThreeWindingsTransformerXml.ROOT_ELEMENT_NAME: - ThreeWindingsTransformerXml.INSTANCE.read(s, context); - break; - - default: - super.readSubElements(s, context); - } - }); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SwitchXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SwitchXml.java deleted file mode 100644 index bf5b7e12..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/SwitchXml.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.IdentifiableAdder; -import eu.itesla_project.iidm.network.Switch; -import eu.itesla_project.iidm.network.VoltageLevel; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class SwitchXml> extends IdentifiableXml { - - static final String ROOT_ELEMENT_NAME = "switch"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(Switch s) { - return false; - } - - @Override - protected void writeRootElementAttributes(Switch s, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeAttribute("kind", s.getKind().name()); - context.getWriter().writeAttribute("retained", Boolean.toString(s.isRetained())); - context.getWriter().writeAttribute("open", Boolean.toString(s.isOpen())); - } - - @Override - protected void writeSubElements(Switch s, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - } - - @Override - protected void readSubElements(Switch s, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> SwitchXml.super.readSubElements(s, context)); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ThreeWindingsTransformerXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ThreeWindingsTransformerXml.java deleted file mode 100644 index 1940e735..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/ThreeWindingsTransformerXml.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.RatioTapChanger; -import eu.itesla_project.iidm.network.Substation; -import eu.itesla_project.iidm.network.ThreeWindingsTransformer; -import eu.itesla_project.iidm.network.ThreeWindingsTransformerAdder; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class ThreeWindingsTransformerXml extends TransformerXml { - - static final ThreeWindingsTransformerXml INSTANCE = new ThreeWindingsTransformerXml(); - - static final String ROOT_ELEMENT_NAME = "threeWindingsTransformer"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(ThreeWindingsTransformer twt) { - return twt.getLeg2().getRatioTapChanger() != null - || twt.getLeg3().getRatioTapChanger() != null - || twt.getLeg1().getCurrentLimits() != null - || twt.getLeg2().getCurrentLimits() != null - || twt.getLeg3().getCurrentLimits() != null; - } - - @Override - protected void writeRootElementAttributes(ThreeWindingsTransformer twt, Substation s, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("r1", twt.getLeg1().getR(), context.getWriter()); - XmlUtil.writeFloat("x1", twt.getLeg1().getX(), context.getWriter()); - XmlUtil.writeFloat("g1", twt.getLeg1().getG(), context.getWriter()); - XmlUtil.writeFloat("b1", twt.getLeg1().getB(), context.getWriter()); - XmlUtil.writeFloat("ratedU1", twt.getLeg1().getRatedU(), context.getWriter()); - XmlUtil.writeFloat("r2", twt.getLeg2().getR(), context.getWriter()); - XmlUtil.writeFloat("x2", twt.getLeg2().getX(), context.getWriter()); - XmlUtil.writeFloat("ratedU2", twt.getLeg2().getRatedU(), context.getWriter()); - XmlUtil.writeFloat("r3", twt.getLeg3().getR(), context.getWriter()); - XmlUtil.writeFloat("x3", twt.getLeg3().getX(), context.getWriter()); - XmlUtil.writeFloat("ratedU3", twt.getLeg3().getRatedU(), context.getWriter()); - writeNodeOrBus(1, twt.getLeg1().getTerminal(), context); - writeNodeOrBus(2, twt.getLeg2().getTerminal(), context); - writeNodeOrBus(3, twt.getLeg3().getTerminal(), context); - if (context.getOptions().isWithBranchSV()) { - writePQ(1, twt.getLeg1().getTerminal(), context.getWriter()); - writePQ(2, twt.getLeg2().getTerminal(), context.getWriter()); - writePQ(3, twt.getLeg3().getTerminal(), context.getWriter()); - } - } - - @Override - protected void writeSubElements(ThreeWindingsTransformer twt, Substation s, XmlWriterContext context) throws XMLStreamException { - RatioTapChanger rtc2 = twt.getLeg2().getRatioTapChanger(); - if (rtc2 != null) { - writeRatioTapChanger("ratioTapChanger2", rtc2, context); - } - RatioTapChanger rtc3 = twt.getLeg3().getRatioTapChanger(); - if (rtc3 != null) { - writeRatioTapChanger("ratioTapChanger3", rtc3, context); - } - if (twt.getLeg1().getCurrentLimits() != null) { - writeCurrentLimits(1, twt.getLeg1().getCurrentLimits(), context.getWriter()); - } - if (twt.getLeg2().getCurrentLimits() != null) { - writeCurrentLimits(2, twt.getLeg2().getCurrentLimits(), context.getWriter()); - } - if (twt.getLeg3().getCurrentLimits() != null) { - writeCurrentLimits(3, twt.getLeg3().getCurrentLimits(), context.getWriter()); - } - } - - @Override - protected ThreeWindingsTransformerAdder createAdder(Substation s) { - return s.newThreeWindingsTransformer(); - } - - @Override - protected ThreeWindingsTransformer readRootElementAttributes(ThreeWindingsTransformerAdder adder, XmlReaderContext context) { - throw new AssertionError("TODO"); // FIXME - } - - @Override - protected void readSubElements(ThreeWindingsTransformer identifiable, XmlReaderContext context) throws XMLStreamException { - throw new AssertionError("TODO"); // FIXME - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TieLineXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TieLineXml.java deleted file mode 100644 index d206b534..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TieLineXml.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.TieLine; -import eu.itesla_project.iidm.network.TieLineAdder; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class TieLineXml extends ConnectableXml { - - static final TieLineXml INSTANCE = new TieLineXml(); - - static final String ROOT_ELEMENT_NAME = "tieLine"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(TieLine tl) { - return tl.getCurrentLimits1() != null || tl.getCurrentLimits2() != null; - } - - private static void writeHalf(TieLine.HalfLine halfLine, XmlWriterContext context, int side) throws XMLStreamException { - context.getWriter().writeAttribute("id_" + side, context.getAnonymizer().anonymizeString(halfLine.getId())); - if (halfLine.getName() != null) { - context.getWriter().writeAttribute("name_" + side, context.getAnonymizer().anonymizeString(halfLine.getName())); - } - XmlUtil.writeFloat("r_" + side, halfLine.getR(), context.getWriter()); - XmlUtil.writeFloat("x_" + side, halfLine.getX(), context.getWriter()); - XmlUtil.writeFloat("g1_" + side, halfLine.getG1(), context.getWriter()); - XmlUtil.writeFloat("b1_" + side, halfLine.getB1(), context.getWriter()); - XmlUtil.writeFloat("g2_" + side, halfLine.getG2(), context.getWriter()); - XmlUtil.writeFloat("b2_" + side, halfLine.getB2(), context.getWriter()); - XmlUtil.writeFloat("xnodeP_" + side, halfLine.getXnodeP(), context.getWriter()); - XmlUtil.writeFloat("xnodeQ_" + side, halfLine.getXnodeQ(), context.getWriter()); - } - - @Override - protected void writeRootElementAttributes(TieLine tl, Network n, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeAttribute("ucteXnodeCode", tl.getUcteXnodeCode()); - writeNodeOrBus(1, tl.getTerminal1(), context); - writeNodeOrBus(2, tl.getTerminal2(), context); - if (context.getOptions().isWithBranchSV()) { - writePQ(1, tl.getTerminal1(), context.getWriter()); - writePQ(2, tl.getTerminal2(), context.getWriter()); - } - writeHalf(tl.getHalf1(), context, 1); - writeHalf(tl.getHalf2(), context, 2); - } - - @Override - protected void writeSubElements(TieLine tl, Network n, XmlWriterContext context) throws XMLStreamException { - if (tl.getCurrentLimits1() != null) { - writeCurrentLimits(1, tl.getCurrentLimits1(), context.getWriter()); - } - if (tl.getCurrentLimits2() != null) { - writeCurrentLimits(2, tl.getCurrentLimits2(), context.getWriter()); - } - } - - @Override - protected TieLineAdder createAdder(Network n) { - return n.newTieLine(); - } - - private static void readHalf(TieLineAdder adder, XmlReaderContext context, int side) { - String id = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "id_" + side)); - String name = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "name_" + side)); - float r = XmlUtil.readFloatAttribute(context.getReader(), "r_" + side); - float x = XmlUtil.readFloatAttribute(context.getReader(), "x_" + side); - float g1 = XmlUtil.readFloatAttribute(context.getReader(), "g1_" + side); - float b1 = XmlUtil.readFloatAttribute(context.getReader(), "b1_" + side); - float g2 = XmlUtil.readFloatAttribute(context.getReader(), "g2_" + side); - float b2 = XmlUtil.readFloatAttribute(context.getReader(), "b2_" + side); - float xnodeP = XmlUtil.readFloatAttribute(context.getReader(), "xnodeP_" + side); - float xnodeQ = XmlUtil.readFloatAttribute(context.getReader(), "xnodeQ_" + side); - adder.setId(id) - .setName(name) - .setR(r) - .setX(x) - .setG1(g1) - .setB1(b1) - .setG2(g2) - .setB2(b2) - .setXnodeP(xnodeP) - .setXnodeQ(xnodeQ); - } - - @Override - protected TieLine readRootElementAttributes(TieLineAdder adder, XmlReaderContext context) { - readHalf(adder.line1(), context, 1); - readHalf(adder.line2(), context, 2); - readNodeOrBus(adder, context); - String ucteXnodeCode = context.getReader().getAttributeValue(null, "ucteXnodeCode"); - TieLine tl = adder.setUcteXnodeCode(ucteXnodeCode) - .add(); - readPQ(1, tl.getTerminal1(), context.getReader()); - readPQ(2, tl.getTerminal2(), context.getReader()); - return tl; - } - - @Override - protected void readSubElements(TieLine tl, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "currentLimits1": - readCurrentLimits(1, tl::newCurrentLimits1, context.getReader()); - break; - - case "currentLimits2": - readCurrentLimits(2, tl::newCurrentLimits2, context.getReader()); - break; - - default: - super.readSubElements(tl, context); - } - }); - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TransformerXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TransformerXml.java deleted file mode 100644 index f7766a3c..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TransformerXml.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.*; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class TransformerXml> extends ConnectableXml { - - protected static void writeTapChangerStep(TapChangerStep tcs, XMLStreamWriter writer) throws XMLStreamException { - XmlUtil.writeFloat("r", tcs.getR(), writer); - XmlUtil.writeFloat("x", tcs.getX(), writer); - XmlUtil.writeFloat("g", tcs.getG(), writer); - XmlUtil.writeFloat("b", tcs.getB(), writer); - XmlUtil.writeFloat("rho", tcs.getRho(), writer); - } - - protected static void writeTapChanger(TapChanger tc, XMLStreamWriter writer) throws XMLStreamException { - writer.writeAttribute("lowTapPosition", Integer.toString(tc.getLowTapPosition())); - writer.writeAttribute("tapPosition", Integer.toString(tc.getTapPosition())); - } - - protected static void writeRatioTapChanger(String name, RatioTapChanger rtc, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeStartElement(IIDM_URI, name); - writeTapChanger(rtc, context.getWriter()); - context.getWriter().writeAttribute("loadTapChangingCapabilities", Boolean.toString(rtc.hasLoadTapChangingCapabilities())); - if (rtc.hasLoadTapChangingCapabilities() || rtc.isRegulating()) { - context.getWriter().writeAttribute("regulating", Boolean.toString(rtc.isRegulating())); - } - if (rtc.hasLoadTapChangingCapabilities() || !Float.isNaN(rtc.getTargetV())) { - XmlUtil.writeFloat("targetV", rtc.getTargetV(), context.getWriter()); - } - if (rtc.hasLoadTapChangingCapabilities() || rtc.getRegulationTerminal() != null) { - writeTerminalRef(rtc.getRegulationTerminal(), context, "terminalRef"); - } - for (int p = rtc.getLowTapPosition(); p <= rtc.getHighTapPosition(); p++) { - RatioTapChangerStep rtcs = rtc.getStep(p); - context.getWriter().writeEmptyElement(IIDM_URI, "step"); - writeTapChangerStep(rtcs, context.getWriter()); - } - context.getWriter().writeEndElement(); - } - - protected static void readRatioTapChanger(TwoWindingsTransformer twt, XmlReaderContext context) throws XMLStreamException { - int lowTapPosition = XmlUtil.readIntAttribute(context.getReader(), "lowTapPosition"); - int tapPosition = XmlUtil.readIntAttribute(context.getReader(), "tapPosition"); - boolean regulating = XmlUtil.readOptionalBoolAttribute(context.getReader(), "regulating", false); - boolean loadTapChangingCapabilities = XmlUtil.readBoolAttribute(context.getReader(), "loadTapChangingCapabilities"); - float targetV = XmlUtil.readOptionalFloatAttribute(context.getReader(), "targetV"); - RatioTapChangerAdder adder = twt.newRatioTapChanger() - .setLowTapPosition(lowTapPosition) - .setTapPosition(tapPosition) - .setLoadTapChangingCapabilities(loadTapChangingCapabilities) - .setTargetV(targetV); - if (loadTapChangingCapabilities) { - adder.setRegulating(regulating); - } - boolean[] hasTerminalRef = new boolean[1]; - XmlUtil.readUntilEndElement("ratioTapChanger", context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "terminalRef": - String id = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "id")); - String side = context.getReader().getAttributeValue(null, "side"); - context.getEndTasks().add(() -> { - adder.setRegulationTerminal(readTerminalRef(twt.getTerminal1().getVoltageLevel().getSubstation().getNetwork(), id, side)); - adder.add(); - }); - hasTerminalRef[0] = true; - break; - - case "step": - float r = XmlUtil.readFloatAttribute(context.getReader(), "r"); - float x = XmlUtil.readFloatAttribute(context.getReader(), "x"); - float g = XmlUtil.readFloatAttribute(context.getReader(), "g"); - float b = XmlUtil.readFloatAttribute(context.getReader(), "b"); - float rho = XmlUtil.readFloatAttribute(context.getReader(), "rho"); - adder.beginStep() - .setR(r) - .setX(x) - .setG(g) - .setB(b) - .setRho(rho) - .endStep(); - break; - - default: - throw new AssertionError(); - } - }); - if (!hasTerminalRef[0]) { - adder.add(); - } - } - - protected static void writePhaseTapChanger(String name, PhaseTapChanger ptc, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeStartElement(IIDM_URI, name); - writeTapChanger(ptc, context.getWriter()); - context.getWriter().writeAttribute("regulationMode", ptc.getRegulationMode().name()); - if (ptc.getRegulationMode() != PhaseTapChanger.RegulationMode.FIXED_TAP || !Float.isNaN(ptc.getRegulationValue())) { - XmlUtil.writeFloat("regulationValue", ptc.getRegulationValue(), context.getWriter()); - } - if (ptc.getRegulationMode() != PhaseTapChanger.RegulationMode.FIXED_TAP || ptc.isRegulating()) { - context.getWriter().writeAttribute("regulating", Boolean.toString(ptc.isRegulating())); - } - if (ptc.getRegulationMode() != PhaseTapChanger.RegulationMode.FIXED_TAP || ptc.getRegulationTerminal() != null) { - writeTerminalRef(ptc.getRegulationTerminal(), context, "terminalRef"); - } - for (int p = ptc.getLowTapPosition(); p <= ptc.getHighTapPosition(); p++) { - PhaseTapChangerStep ptcs = ptc.getStep(p); - context.getWriter().writeEmptyElement(IIDM_URI, "step"); - writeTapChangerStep(ptcs, context.getWriter()); - XmlUtil.writeFloat("alpha", ptcs.getAlpha(), context.getWriter()); - } - context.getWriter().writeEndElement(); - } - - protected static void readPhaseTapChanger(TwoWindingsTransformer twt, XmlReaderContext context) throws XMLStreamException { - int lowTapPosition = XmlUtil.readIntAttribute(context.getReader(), "lowTapPosition"); - int tapPosition = XmlUtil.readIntAttribute(context.getReader(), "tapPosition"); - PhaseTapChanger.RegulationMode regulationMode = PhaseTapChanger.RegulationMode.valueOf(context.getReader().getAttributeValue(null, "regulationMode")); - float regulationValue = XmlUtil.readOptionalFloatAttribute(context.getReader(), "regulationValue"); - boolean regulating = XmlUtil.readOptionalBoolAttribute(context.getReader(), "regulating", false); - PhaseTapChangerAdder adder = twt.newPhaseTapChanger() - .setLowTapPosition(lowTapPosition) - .setTapPosition(tapPosition) - .setRegulationMode(regulationMode) - .setRegulationValue(regulationValue) - .setRegulating(regulating); - boolean[] hasTerminalRef = new boolean[1]; - XmlUtil.readUntilEndElement("phaseTapChanger", context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "terminalRef": - String id = context.getAnonymizer().deanonymizeString(context.getReader().getAttributeValue(null, "id")); - String side = context.getReader().getAttributeValue(null, "side"); - context.getEndTasks().add(() -> { - adder.setRegulationTerminal(readTerminalRef(twt.getTerminal1().getVoltageLevel().getSubstation().getNetwork(), id, side)); - adder.add(); - }); - hasTerminalRef[0] = true; - break; - - case "step": - float r = XmlUtil.readFloatAttribute(context.getReader(), "r"); - float x = XmlUtil.readFloatAttribute(context.getReader(), "x"); - float g = XmlUtil.readFloatAttribute(context.getReader(), "g"); - float b = XmlUtil.readFloatAttribute(context.getReader(), "b"); - float rho = XmlUtil.readFloatAttribute(context.getReader(), "rho"); - float alpha = XmlUtil.readFloatAttribute(context.getReader(), "alpha"); - adder.beginStep() - .setR(r) - .setX(x) - .setG(g) - .setB(b) - .setRho(rho) - .setAlpha(alpha) - .endStep(); - break; - - default: - throw new AssertionError(); - } - }); - if (!hasTerminalRef[0]) { - adder.add(); - } - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TwoWindingsTransformerXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TwoWindingsTransformerXml.java deleted file mode 100644 index ac5d08f4..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/TwoWindingsTransformerXml.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.*; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class TwoWindingsTransformerXml extends TransformerXml { - - static final TwoWindingsTransformerXml INSTANCE = new TwoWindingsTransformerXml(); - - static final String ROOT_ELEMENT_NAME = "twoWindingsTransformer"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(TwoWindingsTransformer twt) { - return twt.getRatioTapChanger() != null - || twt.getPhaseTapChanger() != null - || twt.getCurrentLimits1() != null - || twt.getCurrentLimits2() != null; - } - - @Override - protected void writeRootElementAttributes(TwoWindingsTransformer twt, Substation s, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("r", twt.getR(), context.getWriter()); - XmlUtil.writeFloat("x", twt.getX(), context.getWriter()); - XmlUtil.writeFloat("g", twt.getG(), context.getWriter()); - XmlUtil.writeFloat("b", twt.getB(), context.getWriter()); - XmlUtil.writeFloat("ratedU1", twt.getRatedU1(), context.getWriter()); - XmlUtil.writeFloat("ratedU2", twt.getRatedU2(), context.getWriter()); - writeNodeOrBus(1, twt.getTerminal1(), context); - writeNodeOrBus(2, twt.getTerminal2(), context); - if (context.getOptions().isWithBranchSV()) { - writePQ(1, twt.getTerminal1(), context.getWriter()); - writePQ(2, twt.getTerminal2(), context.getWriter()); - } - } - - @Override - protected void writeSubElements(TwoWindingsTransformer twt, Substation s, XmlWriterContext context) throws XMLStreamException { - RatioTapChanger rtc = twt.getRatioTapChanger(); - if (rtc != null) { - writeRatioTapChanger("ratioTapChanger", rtc, context); - } - PhaseTapChanger ptc = twt.getPhaseTapChanger(); - if (ptc != null) { - writePhaseTapChanger("phaseTapChanger", ptc, context); - } - if (twt.getCurrentLimits1() != null) { - writeCurrentLimits(1, twt.getCurrentLimits1(), context.getWriter()); - } - if (twt.getCurrentLimits2() != null) { - writeCurrentLimits(2, twt.getCurrentLimits2(), context.getWriter()); - } - } - - @Override - protected TwoWindingsTransformerAdder createAdder(Substation s) { - return s.newTwoWindingsTransformer(); - } - - @Override - protected TwoWindingsTransformer readRootElementAttributes(TwoWindingsTransformerAdder adder, XmlReaderContext context) { - float r = XmlUtil.readFloatAttribute(context.getReader(), "r"); - float x = XmlUtil.readFloatAttribute(context.getReader(), "x"); - float g = XmlUtil.readFloatAttribute(context.getReader(), "g"); - float b = XmlUtil.readFloatAttribute(context.getReader(), "b"); - float ratedU1 = XmlUtil.readFloatAttribute(context.getReader(), "ratedU1"); - float ratedU2 = XmlUtil.readFloatAttribute(context.getReader(), "ratedU2"); - adder.setR(r) - .setX(x) - .setG(g) - .setB(b) - .setRatedU1(ratedU1) - .setRatedU2(ratedU2); - readNodeOrBus(adder, context); - TwoWindingsTransformer twt = adder.add(); - readPQ(1, twt.getTerminal1(), context.getReader()); - readPQ(2, twt.getTerminal2(), context.getReader()); - return twt; - } - - @Override - protected void readSubElements(TwoWindingsTransformer twt, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "currentLimits1": - readCurrentLimits(1, twt::newCurrentLimits1, context.getReader()); - break; - - case "currentLimits2": - readCurrentLimits(2, twt::newCurrentLimits2, context.getReader()); - break; - - case "ratioTapChanger": - readRatioTapChanger(twt, context); - break; - - case "phaseTapChanger": - readPhaseTapChanger(twt, context); - break; - - default: - super.readSubElements(twt, context); - } - }); - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VoltageLevelXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VoltageLevelXml.java deleted file mode 100644 index c3747496..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VoltageLevelXml.java +++ /dev/null @@ -1,240 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.*; - -import javax.xml.stream.XMLStreamException; - -/** - * - * @author Geoffroy Jamgotchian - */ -class VoltageLevelXml extends IdentifiableXml { - - static final VoltageLevelXml INSTANCE = new VoltageLevelXml(); - - static final String ROOT_ELEMENT_NAME = "voltageLevel"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(VoltageLevel vl) { - return true; - } - - @Override - protected void writeRootElementAttributes(VoltageLevel vl, Substation s, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("nominalV", vl.getNominalV(), context.getWriter()); - XmlUtil.writeFloat("lowVoltageLimit", vl.getLowVoltageLimit(), context.getWriter()); - XmlUtil.writeFloat("highVoltageLimit", vl.getHighVoltageLimit(), context.getWriter()); - context.getWriter().writeAttribute("topologyKind", vl.getTopologyKind().name()); - } - - @Override - protected void writeSubElements(VoltageLevel vl, Substation s, XmlWriterContext context) throws XMLStreamException { - if (context.getOptions().isForceBusBranchTopo()) { - context.getWriter().writeStartElement(IIDM_URI, "busBreakerTopology"); - for (Bus b : vl.getBusView().getBuses()) { - if (!context.getFilter().test(b)) { - continue; - } - BusXml.INSTANCE.write(b, null, context); - } - context.getWriter().writeEndElement(); - } else { - switch (vl.getTopologyKind()) { - case NODE_BREAKER: - context.getWriter().writeStartElement(IIDM_URI, "nodeBreakerTopology"); - context.getWriter().writeAttribute("nodeCount", Integer.toString(vl.getNodeBreakerView().getNodeCount())); - for (BusbarSection bs : vl.getNodeBreakerView().getBusbarSections()) { - BusbarSectionXml.INSTANCE.write(bs, null, context); - } - for (Switch sw : vl.getNodeBreakerView().getSwitches()) { - NodeBreakerViewSwitchXml.INSTANCE.write(sw, vl, context); - } - context.getWriter().writeEndElement(); - break; - - case BUS_BREAKER: - context.getWriter().writeStartElement(IIDM_URI, "busBreakerTopology"); - for (Bus b : vl.getBusBreakerView().getBuses()) { - if (!context.getFilter().test(b)) { - continue; - } - BusXml.INSTANCE.write(b, null, context); - } - for (Switch sw : vl.getBusBreakerView().getSwitches()) { - Bus b1 = vl.getBusBreakerView().getBus1(context.getAnonymizer().anonymizeString(sw.getId())); - Bus b2 = vl.getBusBreakerView().getBus2(context.getAnonymizer().anonymizeString(sw.getId())); - if (!context.getFilter().test(b1) || !context.getFilter().test(b2)) { - continue; - } - BusBreakerViewSwitchXml.INSTANCE.write(sw, vl, context); - } - context.getWriter().writeEndElement(); - break; - - default: - throw new AssertionError(); - } - } - if (vl.getGeneratorCount() > 0) { - for (Generator g : vl.getGenerators()) { - if (!context.getFilter().test(g)) { - continue; - } - GeneratorXml.INSTANCE.write(g, null, context); - } - } - if (vl.getLoadCount() > 0) { - for (Load l : vl.getLoads()) { - if (!context.getFilter().test(l)) { - continue; - } - - LoadXml.INSTANCE.write(l, null, context); - } - } - if (vl.getShuntCount() > 0) { - for (ShuntCompensator sc : vl.getShunts()) { - if (!context.getFilter().test(sc)) { - continue; - } - ShuntXml.INSTANCE.write(sc, null, context); - } - } - if (vl.getDanglingLineCount() > 0) { - for (DanglingLine dl : vl.getDanglingLines()) { - if (!context.getFilter().test(dl)) { - continue; - } - DanglingLineXml.INSTANCE.write(dl, null, context); - } - } - if (vl.getStaticVarCompensatorCount() > 0) { - for (StaticVarCompensator svc : vl.getStaticVarCompensators()) { - if (!context.getFilter().test(svc)) { - continue; - } - StaticVarCompensatorXml.INSTANCE.write(svc, null, context); - } - } - if (vl.getVscConverterStationCount() > 0) { - for (VscConverterStation cs : vl.getVscConverterStations()) { - if (!context.getFilter().test(cs)) { - continue; - } - VscConverterStationXml.INSTANCE.write(cs, vl, context); - } - } - if (vl.getLccConverterStationCount() > 0) { - for (LccConverterStation cs : vl.getLccConverterStations()) { - if (!context.getFilter().test(cs)) { - continue; - } - LccConverterStationXml.INSTANCE.write(cs, vl, context); - } - } - } - - @Override - protected VoltageLevelAdder createAdder(Substation s) { - return s.newVoltageLevel(); - } - - @Override - protected VoltageLevel readRootElementAttributes(VoltageLevelAdder adder, XmlReaderContext context) { - float nominalV = XmlUtil.readFloatAttribute(context.getReader(), "nominalV"); - float lowVoltageLimit = XmlUtil.readOptionalFloatAttribute(context.getReader(), "lowVoltageLimit"); - float highVoltageLimit = XmlUtil.readOptionalFloatAttribute(context.getReader(), "highVoltageLimit"); - TopologyKind topologyKind = TopologyKind.valueOf(context.getReader().getAttributeValue(null, "topologyKind")); - return adder - .setNominalV(nominalV) - .setLowVoltageLimit(lowVoltageLimit) - .setHighVoltageLimit(highVoltageLimit) - .setTopologyKind(topologyKind) - .add(); - } - - @Override - protected void readSubElements(VoltageLevel vl, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "nodeBreakerTopology": - int nodeCount = XmlUtil.readIntAttribute(context.getReader(), "nodeCount"); - vl.getNodeBreakerView().setNodeCount(nodeCount); - XmlUtil.readUntilEndElement("nodeBreakerTopology", context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case BusbarSectionXml.ROOT_ELEMENT_NAME: - BusbarSectionXml.INSTANCE.read(vl, context); - break; - - case NodeBreakerViewSwitchXml.ROOT_ELEMENT_NAME: - NodeBreakerViewSwitchXml.INSTANCE.read(vl, context); - break; - - default: - throw new AssertionError(); - } - }); - break; - - case "busBreakerTopology": - XmlUtil.readUntilEndElement("busBreakerTopology", context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case BusXml.ROOT_ELEMENT_NAME: - BusXml.INSTANCE.read(vl, context); - break; - - case BusBreakerViewSwitchXml.ROOT_ELEMENT_NAME: - BusBreakerViewSwitchXml.INSTANCE.read(vl, context); - break; - - default: - throw new AssertionError(); - } - }); - break; - - case GeneratorXml.ROOT_ELEMENT_NAME: - GeneratorXml.INSTANCE.read(vl, context); - break; - - case LoadXml.ROOT_ELEMENT_NAME: - LoadXml.INSTANCE.read(vl, context); - break; - - case ShuntXml.ROOT_ELEMENT_NAME: - ShuntXml.INSTANCE.read(vl, context); - break; - - case DanglingLineXml.ROOT_ELEMENT_NAME: - DanglingLineXml.INSTANCE.read(vl, context); - break; - - case StaticVarCompensatorXml.ROOT_ELEMENT_NAME: - StaticVarCompensatorXml.INSTANCE.read(vl, context); - break; - - case VscConverterStationXml.ROOT_ELEMENT_NAME: - VscConverterStationXml.INSTANCE.read(vl, context); - break; - - case LccConverterStationXml.ROOT_ELEMENT_NAME: - LccConverterStationXml.INSTANCE.read(vl, context); - break; - - default: - super.readSubElements(vl, context); - } - }); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VscConverterStationXml.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VscConverterStationXml.java deleted file mode 100644 index c4fe80a2..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/VscConverterStationXml.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.VoltageLevel; -import eu.itesla_project.iidm.network.VscConverterStation; -import eu.itesla_project.iidm.network.VscConverterStationAdder; - -import javax.xml.stream.XMLStreamException; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -class VscConverterStationXml extends ConnectableXml { - - static final VscConverterStationXml INSTANCE = new VscConverterStationXml(); - - static final String ROOT_ELEMENT_NAME = "vscConverterStation"; - - @Override - protected String getRootElementName() { - return ROOT_ELEMENT_NAME; - } - - @Override - protected boolean hasSubElements(VscConverterStation cs) { - return true; - } - - @Override - protected void writeRootElementAttributes(VscConverterStation cs, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - context.getWriter().writeAttribute("voltageRegulatorOn", Boolean.toString(cs.isVoltageRegulatorOn())); - XmlUtil.writeFloat("voltageSetPoint", cs.getVoltageSetPoint(), context.getWriter()); - XmlUtil.writeFloat("reactivePowerSetPoint", cs.getReactivePowerSetPoint(), context.getWriter()); - writeNodeOrBus(null, cs.getTerminal(), context); - writePQ(null, cs.getTerminal(), context.getWriter()); - } - - @Override - protected void writeSubElements(VscConverterStation cs, VoltageLevel vl, XmlWriterContext context) throws XMLStreamException { - ReactiveLimitsXml.INSTANCE.write(cs, context); - } - - @Override - protected VscConverterStationAdder createAdder(VoltageLevel vl) { - return vl.newVscConverterStation(); - } - - @Override - protected VscConverterStation readRootElementAttributes(VscConverterStationAdder adder, XmlReaderContext context) { - boolean voltageRegulatorOn = XmlUtil.readBoolAttribute(context.getReader(), "voltageRegulatorOn"); - float voltageSetPoint = XmlUtil.readOptionalFloatAttribute(context.getReader(), "voltageSetPoint"); - float reactivePowerSetPoint = XmlUtil.readOptionalFloatAttribute(context.getReader(), "reactivePowerSetPoint"); - readNodeOrBus(adder, context); - VscConverterStation cs = adder - .setVoltageRegulatorOn(voltageRegulatorOn) - .setVoltageSetPoint(voltageSetPoint) - .setReactivePowerSetPoint(reactivePowerSetPoint) - .add(); - readPQ(null, cs.getTerminal(), context.getReader()); - return cs; - } - - @Override - protected void readSubElements(VscConverterStation cs, XmlReaderContext context) throws XMLStreamException { - readUntilEndRootElement(context.getReader(), () -> { - switch (context.getReader().getLocalName()) { - case "reactiveCapabilityCurve": - case "minMaxReactiveLimits": - ReactiveLimitsXml.INSTANCE.read(cs, context); - break; - - default: - super.readSubElements(cs, context); - } - }); - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExportOptions.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExportOptions.java deleted file mode 100644 index a7ce6fc4..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExportOptions.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class XMLExportOptions { - - private boolean withBranchSV = true; - - private boolean forceBusBranchTopo = false; - - private boolean indent = true; - - private boolean onlyMainCc = false; - - private boolean anonymized = false; - - private boolean skipExtensions = false; - - public XMLExportOptions() { - } - - public XMLExportOptions(boolean withBranchSV, boolean forceBusBranchTopo, boolean indent, boolean onlyMainCc) { - this.withBranchSV = withBranchSV; - this.forceBusBranchTopo = forceBusBranchTopo; - this.indent = indent; - this.onlyMainCc = onlyMainCc; - } - - public boolean isWithBranchSV() { - return withBranchSV; - } - - public XMLExportOptions setWithBranchSV(boolean withBranchSV) { - this.withBranchSV = withBranchSV; - return this; - } - - public boolean isForceBusBranchTopo() { - return forceBusBranchTopo; - } - - public XMLExportOptions setForceBusBranchTopo(boolean forceBusBranchTopo) { - this.forceBusBranchTopo = forceBusBranchTopo; - return this; - } - - public boolean isIndent() { - return indent; - } - - public XMLExportOptions setIndent(boolean indent) { - this.indent = indent; - return this; - } - - public boolean isOnlyMainCc() { - return onlyMainCc; - } - - public XMLExportOptions setOnlyMainCc(boolean onlyMainCc) { - this.onlyMainCc = onlyMainCc; - return this; - } - - public boolean isAnonymized() { - return anonymized; - } - - public XMLExportOptions setAnonymized(boolean anonymized) { - this.anonymized = anonymized; - return this; - } - - public boolean isSkipExtensions() { - return skipExtensions; - } - - public XMLExportOptions setSkipExtensions(boolean skipExtensions) { - this.skipExtensions = skipExtensions; - return this; - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExporter.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExporter.java deleted file mode 100644 index 101b8b50..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLExporter.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import com.google.auto.service.AutoService; -import eu.itesla_project.iidm.datasource.DataSource; -import eu.itesla_project.iidm.export.Exporter; -import eu.itesla_project.iidm.network.Network; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.util.Properties; - -/** - * XML export of an IIDM model.

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
property namecommentpossible values
iidm.export.xml.indentif true write indented xml (4 spaces)true or false
iidm.export.xml.with-branch-state-variablesif true export branches state (active and reactive flow)true or false
iidm.export.xml.force-bus-branch-topoif true remove switches and aggregate busestrue or false
iidm.export.xml.only-main-ccif true only export equipments of the main connected componenttrue or false
- * @author Geoffroy Jamgotchian - */ -@AutoService(Exporter.class) -public class XMLExporter implements Exporter, XmlConstants { - - private static final Logger LOGGER = LoggerFactory.getLogger(XMLExporter.class); - - public static final String INDENT_PROPERTY = "iidm.export.xml.indent"; - - public static final String WITH_BRANCH_STATE_VARIABLES_PROPERTY = "iidm.export.xml.with-branch-state-variables"; - - public static final String FORCE_BUS_BRANCH_TOPO_PROPERTY = "iidm.export.xml.force-bus-branch-topo"; - - public static final String ONLY_MAIN_CC_PROPERTIES = "iidm.export.xml.only-main-cc"; - - public static final String ANONYMISED_PROPERTIES = "iidm.export.xml.anonymised"; - - public static final String SKIP_EXTENSIONS_PROPERTIES = "iidm.export.xml.skip-extensions"; - - @Override - public String getFormat() { - return "XIIDM"; - } - - @Override - public String getComment() { - return "IIDM XML v" + VERSION + " exporter"; - } - - @Override - public void export(Network network, Properties parameters, DataSource dataSource) { - if (network == null) { - throw new IllegalArgumentException("network is null"); - } - - XMLExportOptions options = new XMLExportOptions(); - if (parameters != null) { - options.setIndent(!"false".equals(parameters.getProperty(INDENT_PROPERTY))) - .setWithBranchSV("true".equals(parameters.getProperty(WITH_BRANCH_STATE_VARIABLES_PROPERTY))) - .setForceBusBranchTopo("true".equals(parameters.getProperty(FORCE_BUS_BRANCH_TOPO_PROPERTY, "false"))) - .setOnlyMainCc("true".equals(parameters.getProperty(ONLY_MAIN_CC_PROPERTIES))) - .setAnonymized("true".equals(parameters.getProperty(ANONYMISED_PROPERTIES))) - .setSkipExtensions("true".equals(parameters.getProperty(SKIP_EXTENSIONS_PROPERTIES))); - } - - try { - long startTime = System.currentTimeMillis(); - - try (OutputStream os = dataSource.newOutputStream(null, "xiidm", false); - BufferedOutputStream bos = new BufferedOutputStream(os)) { - Anonymizer anonymizer = NetworkXml.write(network, options, bos); - if (anonymizer != null) { - try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(dataSource.newOutputStream("_mapping", "csv", false)))) { - anonymizer.write(writer); - } - } - } - - LOGGER.debug("XIIDM export done in {} ms", (System.currentTimeMillis() - startTime)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLImporter.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLImporter.java deleted file mode 100644 index 9f5a2cac..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XMLImporter.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import com.google.auto.service.AutoService; -import com.google.common.base.Joiner; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.iidm.datasource.ReadOnlyDataSource; -import eu.itesla_project.iidm.import_.Importer; -import eu.itesla_project.iidm.import_.Importers; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.parameters.Parameter; -import eu.itesla_project.iidm.parameters.ParameterType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.events.XMLEvent; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Arrays; -import java.util.List; -import java.util.Properties; - -/** - * @author Geoffroy Jamgotchian - */ -@AutoService(Importer.class) -public class XMLImporter implements Importer, XmlConstants { - - private static final Logger LOGGER = LoggerFactory.getLogger(XMLImporter.class); - - private final String[] EXTENSIONS = { "xiidm", "iidm", "xml" }; - - private static final Supplier XML_INPUT_FACTORY_SUPPLIER = Suppliers.memoize(XMLInputFactory::newInstance); - - private static final Parameter THROW_EXCEPTION_IF_EXTENSION_NOT_FOUND - = new Parameter("throwExceptionIfExtensionNotFound", ParameterType.BOOLEAN, "Throw exception if extension not found", Boolean.FALSE); - - @Override - public String getFormat() { - return "XIIDM"; - } - - @Override - public InputStream get16x16Icon() { - return XMLImporter.class.getResourceAsStream("/icons/itesla16x16.png"); - } - - @Override - public List getParameters() { - return Arrays.asList(THROW_EXCEPTION_IF_EXTENSION_NOT_FOUND); - } - - @Override - public String getComment() { - return "IIDM XML v " + VERSION + " importer"; - } - - private String findExtension(ReadOnlyDataSource dataSource) throws IOException { - for (String ext : EXTENSIONS) { - if (dataSource.exists(null, ext)) { - return ext; - } - } - return null; - } - - @Override - public boolean exists(ReadOnlyDataSource dataSource) { - try { - String ext = findExtension(dataSource); - if (ext != null) { - try (InputStream is = dataSource.newInputStream(null, ext)) { - // check the first root element is network and namespace is IIDM - XMLStreamReader xmlsr = XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(is); - try { - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - if (eventType == XMLEvent.START_ELEMENT) { - String name = xmlsr.getLocalName(); - String ns = xmlsr.getNamespaceURI(); - return NetworkXml.NETWORK_ROOT_ELEMENT_NAME.equals(name) && IIDM_URI.equals(ns); - } - } - } finally { - try { - xmlsr.close(); - } catch (XMLStreamException e) { - LOGGER.error(e.toString(), e); - } - } - } - } - return false; - } catch (XMLStreamException e) { - // not a valid xml file - return false; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public Network import_(ReadOnlyDataSource dataSource, Properties parameters) { - Network network; - long startTime = System.currentTimeMillis(); - try { - String ext = findExtension(dataSource); - if (ext == null) { - throw new RuntimeException("File " + dataSource.getBaseName() - + "." + Joiner.on("|").join(EXTENSIONS) + " not found"); - } - boolean throwExceptionIfExtensionNotFound = (Boolean) Importers.readParameter(getFormat(), parameters, THROW_EXCEPTION_IF_EXTENSION_NOT_FOUND); - Anonymizer anonymizer = null; - if (dataSource.exists("_mapping", "csv")) { - anonymizer = new SimpleAnonymizer(); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(dataSource.newInputStream("_mapping", "csv")))) { - anonymizer.read(reader); - } - } - try (InputStream is = dataSource.newInputStream(null, ext)) { - network = NetworkXml.read(is, new XmlImportConfig(throwExceptionIfExtensionNotFound), anonymizer); - } - LOGGER.debug("XIIDM import done in {} ms", (System.currentTimeMillis() - startTime)); - } catch (IOException e) { - throw new ITeslaException(e); - } - return network; - } - -} - diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlConstants.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlConstants.java deleted file mode 100644 index a077eb29..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlConstants.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface XmlConstants { - - String INDENT = " "; - - List VERSION_ARRAY = Arrays.asList(1, 0); - - String VERSION = VERSION_ARRAY.stream().map(Object::toString).collect(Collectors.joining(".")); - - String IIDM_BASE_URI = "http://www.itesla_project.eu/schema/iidm/"; - - String IIDM_PREFIX = "iidm"; - - String IIDM_URI = IIDM_BASE_URI + VERSION_ARRAY.stream().map(Object::toString).collect(Collectors.joining("_")); - -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlContext.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlContext.java deleted file mode 100644 index 6ac26da5..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlContext.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -/** - * @author Geoffroy Jamgotchian - */ -public class XmlContext { - - private final Anonymizer anonymizer; - - public XmlContext(Anonymizer anonymizer) { - this.anonymizer = anonymizer != null ? anonymizer : new FakeAnonymizer(); - } - - public Anonymizer getAnonymizer() { - return anonymizer; - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlImportConfig.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlImportConfig.java deleted file mode 100644 index c44375aa..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlImportConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -/** - * @author Geoffroy Jamgotchian - */ -public class XmlImportConfig { - - private boolean throwExceptionIfExtensionNotFound; - - public XmlImportConfig() { - this(false); - } - - public XmlImportConfig(boolean throwExceptionIfExtensionNotFound) { - this.throwExceptionIfExtensionNotFound = throwExceptionIfExtensionNotFound; - } - - public boolean isThrowExceptionIfExtensionNotFound() { - return throwExceptionIfExtensionNotFound; - } - - public void setThrowExceptionIfExtensionNotFound(boolean throwExceptionIfExtensionNotFound) { - this.throwExceptionIfExtensionNotFound = throwExceptionIfExtensionNotFound; - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlReaderContext.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlReaderContext.java deleted file mode 100644 index 25fa120d..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlReaderContext.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import javax.xml.stream.XMLStreamReader; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class XmlReaderContext extends XmlContext { - - private final XMLStreamReader reader; - private final List endTasks = new ArrayList<>(); - - public XmlReaderContext(Anonymizer anonymizer, XMLStreamReader reader) { - super(anonymizer); - this.reader = Objects.requireNonNull(reader); - } - - public XMLStreamReader getReader() { - return reader; - } - - public List getEndTasks() { - return endTasks; - } - -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlUtil.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlUtil.java deleted file mode 100644 index 8c3d04cd..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlUtil.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -/** - * @author Geoffroy Jamgotchian - */ -public class XmlUtil { - - private XmlUtil() { - } - - public interface XmlEventHandler { - - void onStartElement() throws XMLStreamException; - - } - - public static String readUntilEndElement(String endElementName, XMLStreamReader reader, XmlEventHandler eventHandler) throws XMLStreamException { - String text = null; - int event; - while (!((event = reader.next()) == XMLStreamConstants.END_ELEMENT - && reader.getLocalName().equals(endElementName))) { - text = null; - switch (event) { - case XMLStreamConstants.START_ELEMENT: - if (eventHandler != null) { - eventHandler.onStartElement(); - } - break; - - case XMLStreamConstants.CHARACTERS: - text = reader.getText(); - break; - } - } - return text; - } - - public static void writeFloat(String name, float value, XMLStreamWriter writer) throws XMLStreamException { - if (!Float.isNaN(value)) { - writer.writeAttribute(name, Float.toString(value)); - } - } - - public static void writeInt(String name, int value, XMLStreamWriter writer) throws XMLStreamException { - writer.writeAttribute(name, Integer.toString(value)); - } - - public static int readIntAttribute(XMLStreamReader reader, String attributeName) { - return Integer.valueOf(reader.getAttributeValue(null, attributeName)); - } - - public static boolean readBoolAttribute(XMLStreamReader reader, String attributeName) { - return Boolean.valueOf(reader.getAttributeValue(null, attributeName)); - } - - public static boolean readOptionalBoolAttribute(XMLStreamReader reader, String attributeName, boolean defaultValue) { - String attributeValue = reader.getAttributeValue(null, attributeName); - return attributeValue != null ? Boolean.valueOf(attributeValue) : defaultValue; - } - - public static Integer readOptionalIntegerAttribute(XMLStreamReader reader, String attributeName) { - String attributeValue = reader.getAttributeValue(null, attributeName); - return attributeValue != null ? Integer.valueOf(attributeValue) : null; - } - - public static int readOptionalIntegerAttribute(XMLStreamReader reader, String attributeName, int defaultValue) { - String attributeValue = reader.getAttributeValue(null, attributeName); - return attributeValue != null ? Integer.valueOf(attributeValue) : defaultValue; - } - - public static float readFloatAttribute(XMLStreamReader reader, String attributeName) { - return Float.valueOf(reader.getAttributeValue(null, attributeName)); - } - - public static float readOptionalFloatAttribute(XMLStreamReader reader, String attributeName) { - return readOptionalFloatAttribute(reader, attributeName, Float.NaN); - } - - public static float readOptionalFloatAttribute(XMLStreamReader reader, String attributeName, float defaultValue) { - String attributeValue = reader.getAttributeValue(null, attributeName); - return attributeValue != null ? Float.valueOf(attributeValue) : defaultValue; - } -} diff --git a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlWriterContext.java b/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlWriterContext.java deleted file mode 100644 index 5837e824..00000000 --- a/iidm-xml-converter/src/main/java/eu/itesla_project/iidm/xml/XmlWriterContext.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import javax.xml.stream.XMLStreamWriter; - -/** - * @author Geoffroy Jamgotchian - */ -public class XmlWriterContext extends XmlContext { - - private final XMLStreamWriter writer; - private final XMLExportOptions options; - private final BusFilter filter; - - XmlWriterContext(Anonymizer anonymizer, XMLStreamWriter writer, XMLExportOptions options, BusFilter filter) { - super(anonymizer); - this.writer = writer; - this.options = options; - this.filter = filter; - } - - public XMLStreamWriter getWriter() { - return writer; - } - - public XMLExportOptions getOptions() { - return options; - } - - public BusFilter getFilter() { - return filter; - } -} diff --git a/iidm-xml-converter/src/main/resources/icons/itesla16x16.png b/iidm-xml-converter/src/main/resources/icons/itesla16x16.png deleted file mode 100644 index 34f5cc645ba3dbc0c3116bee29076e657a6e8a84..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1072 zcmV-01kd}4P)GW*iac9pK&Z-p}{v_wApgXM6s8K7T#WgV-qs z4<(KOx3Qc=Tg}dxpL9n3&M|zO! z)_^K~Q+hC>3RRw;`HiV(m6@x)%x>N{8%R3Hfkd457%|2tUO+YgaIA+CBZXCx$USp^ z%+_bF)E18mmI+>>z4OWJ)i;Vom-Ucfbq^DZ05#69PB#Ej7rXOL4ogFP zqf)I^hFPH?|C$k*R@|ez(~Xj^aM_c;IIA8VNS0mN(0{+U=A3frK^4}Ru9$vRF54V! z$iB_ih4&iyfg1-+Z^Zi_sC;@LtJu02SCAzdYkyp-Cd92DV03b>w8j2T@iAe1CXq7_&^Ul@bhO_^NBcOa=}S;*2(n=> zK57!OKey#3hs*)6hL;#D%5UzHXTyz}F3hskZ;svC1ddGrkQN4VVxI&6Q+8X#n-|%W zT&ioHA54$X;jBs~<|jU#MQtc)3Pwd;Xl#R*xq9WkZ^!S5LWm_JUeQkUbW^euB{x>*)8WqJ*v#^oozQ#&m~=Ji9L z(zUu7CdVKb@}B2Y(vfJWKv$@9tI^8M?FS62VKKiue@{h1%!vx+g_3%9OtN}rWXIv; z%QR@Ws*_8Z)Y)iHK8q6N?Hsc_rzXfA!1(`6(Nn}hSYsa(VQKoLE2P~K2(jra13P7< zye#P<7tKFPr|nPMeBoV;V3^%a#zf3dz(h_0oWQ~PmbTE^B#M^t6`2~-Yl)3qiJAci qPkg&~3oj#;k8lzIVtxX53&p>=UAf8((s*A00000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/HvdcXmlTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/HvdcXmlTest.java deleted file mode 100644 index e31aeb52..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/HvdcXmlTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.commons.ConverterBaseTest; -import eu.itesla_project.iidm.network.test.HvdcTestNetwork; -import org.junit.Test; - -import java.io.IOException; - -/** - * @author Mathieu Bague - */ -public class HvdcXmlTest extends ConverterBaseTest { - - @Test - public void roundTripLccTest() throws IOException { - roundTripXmlTest(HvdcTestNetwork.createLcc(), - NetworkXml::writeAndValidate, - NetworkXml::read, - "/LccRoundTripRef.xml"); - } - - @Test - public void roundTripVscTest() throws IOException { - roundTripXmlTest(HvdcTestNetwork.createVsc(), - NetworkXml::writeAndValidate, - NetworkXml::read, - "/VscRoundTripRef.xml"); - } -} diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/IdentifiableExtensionXmlTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/IdentifiableExtensionXmlTest.java deleted file mode 100644 index f6f85528..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/IdentifiableExtensionXmlTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import eu.itesla_project.iidm.network.test.LoadZipModel; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import static org.junit.Assert.assertTrue; - -/** - * @author Geoffroy Jamgotchian - */ -public class IdentifiableExtensionXmlTest { - - @Test - public void test() throws IOException { - Network network = EurostagTutorialExample1Factory.create(); - Load load = network.getLoad("LOAD"); - LoadZipModel zipModel = new LoadZipModel(load, 1, 2, 3, 4, 5, 6, 380); - load.addExtension(LoadZipModel.class, zipModel); - byte[] buffer; - try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { - NetworkXml.write(network, new XMLExportOptions(), os); - buffer = os.toByteArray(); - } - // try to validate the schema with extensions - try (ByteArrayInputStream is = new ByteArrayInputStream(buffer)) { - NetworkXml.validateWithExtensions(is); - } - try (ByteArrayInputStream is = new ByteArrayInputStream(buffer)) { - Network network2 = NetworkXml.read(is); - LoadZipModel zipModel2 = network2.getLoad("LOAD").getExtension(LoadZipModel.class); - assertTrue(zipModel2 != null); - assertTrue(zipModel.getA1() == zipModel2.getA1() - && zipModel.getA2() == zipModel2.getA2() - && zipModel.getA3() == zipModel2.getA3() - && zipModel.getA4() == zipModel2.getA4() - && zipModel.getA5() == zipModel2.getA5() - && zipModel.getA6() == zipModel2.getA6() - && zipModel.getV0() == zipModel2.getV0() - ); - } - } -} diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/LoadZipModelXml.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/LoadZipModelXml.java deleted file mode 100644 index 43c0afa5..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/LoadZipModelXml.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import com.google.auto.service.AutoService; -import eu.itesla_project.iidm.network.Load; -import eu.itesla_project.iidm.network.test.LoadZipModel; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.io.InputStream; - -/** - * @author Geoffroy Jamgotchian - */ -@AutoService(ExtensionXml.class) -public class LoadZipModelXml implements ExtensionXml { - - @Override - public String getExtensionName() { - return "loadZipModel"; - } - - @Override - public Class getExtensionClass() { - return LoadZipModel.class; - } - - @Override - public boolean hasSubElements() { - return false; - } - - @Override - public InputStream getXsdAsStream() { - return getClass().getResourceAsStream("/xsd/loadZipModel.xsd"); - } - - @Override - public String getNamespaceUri() { - return "http://www.itesla_project.eu/schema/iidm/ext/loadzipmodel/1_0"; - } - - @Override - public String getNamespacePrefix() { - return "extZip"; - } - - @Override - public void write(LoadZipModel zipModel, XmlWriterContext context) throws XMLStreamException { - XmlUtil.writeFloat("a1", zipModel.getA1(), context.getWriter()); - XmlUtil.writeFloat("a2", zipModel.getA2(), context.getWriter()); - XmlUtil.writeFloat("a3", zipModel.getA3(), context.getWriter()); - XmlUtil.writeFloat("a4", zipModel.getA4(), context.getWriter()); - XmlUtil.writeFloat("a5", zipModel.getA5(), context.getWriter()); - XmlUtil.writeFloat("a6", zipModel.getA6(), context.getWriter()); - XmlUtil.writeFloat("v0", zipModel.getV0(), context.getWriter()); - } - - @Override - public LoadZipModel read(Load load, XmlReaderContext context) { - float a1 = XmlUtil.readFloatAttribute(context.getReader(), "a1"); - float a2 = XmlUtil.readFloatAttribute(context.getReader(), "a2"); - float a3 = XmlUtil.readFloatAttribute(context.getReader(), "a3"); - float a4 = XmlUtil.readFloatAttribute(context.getReader(), "a4"); - float a5 = XmlUtil.readFloatAttribute(context.getReader(), "a5"); - float a6 = XmlUtil.readFloatAttribute(context.getReader(), "a6"); - float v0 = XmlUtil.readFloatAttribute(context.getReader(), "v0"); - return new LoadZipModel(load, a1, a2, a3, a4, a5, a6, v0); - } -} diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/NetworkXmlTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/NetworkXmlTest.java deleted file mode 100644 index d83d04b4..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/NetworkXmlTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.commons.ConverterBaseTest; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.test.EurostagTutorialExample1Factory; -import org.joda.time.DateTime; -import org.junit.Test; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -/** - * @author Geoffroy Jamgotchian - */ -public class NetworkXmlTest extends ConverterBaseTest { - - static Network createEurostagTutorialExample1() { - Network network = EurostagTutorialExample1Factory.create(); - network.setCaseDate(DateTime.parse("2013-01-15T18:45:00+01:00")); - return network; - } - - @Test - public void roundTripTest() throws IOException { - roundTripXmlTest(createEurostagTutorialExample1(), - NetworkXml::writeAndValidate, - NetworkXml::read, - "/eurostag-tutorial-example1.xml"); - } - - @Test - public void testValidationIssueWithProperties() throws Exception { - Network network = createEurostagTutorialExample1(); - network.getGenerator("GEN").getProperties().setProperty("test", "foo"); - Path xmlFile = tmpDir.resolve("n.xml"); - NetworkXml.writeAndValidate(network, xmlFile); - } - - @Test - public void testGzipGunzip() throws IOException { - Network network = createEurostagTutorialExample1(); - Path file1 = tmpDir.resolve("n.xml"); - NetworkXml.write(network, file1); - Network network2 = NetworkXml.copy(network); - Path file2 = tmpDir.resolve("n2.xml"); - NetworkXml.write(network2, file2); - assertArrayEquals(Files.readAllBytes(file1), Files.readAllBytes(file2)); - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/OptionalLoadTypeBugTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/OptionalLoadTypeBugTest.java deleted file mode 100644 index 4945aa7b..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/OptionalLoadTypeBugTest.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import org.junit.Test; - -/** - * @author Geoffroy Jamgotchian - */ -public class OptionalLoadTypeBugTest { - - @Test - public void shouldNotThrowNullPointerExceptionTest() { - NetworkXml.read(getClass().getResourceAsStream("/optionalLoadTypeBug.xml")); - } -} diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/PhaseShifterXmlTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/PhaseShifterXmlTest.java deleted file mode 100644 index 4a7c5c9d..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/PhaseShifterXmlTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.commons.ConverterBaseTest; -import eu.itesla_project.iidm.network.test.PhaseShifterTestCaseFactory; -import org.junit.Test; - -import java.io.IOException; - -/** - * @author Geoffroy Jamgotchian - */ -public class PhaseShifterXmlTest extends ConverterBaseTest { - - @Test - public void roundTripTest() throws IOException { - roundTripXmlTest(PhaseShifterTestCaseFactory.create(), - NetworkXml::writeAndValidate, - NetworkXml::read, - "/phaseShifterRoundTripRef.xml"); - } -} diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/ReactiveLimitsXmlTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/ReactiveLimitsXmlTest.java deleted file mode 100644 index 6bab5a45..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/ReactiveLimitsXmlTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.commons.ConverterBaseTest; -import eu.itesla_project.iidm.network.*; -import org.joda.time.DateTime; -import org.junit.Test; - -import java.io.IOException; - -/** - * @author Mathieu Bague - */ -public class ReactiveLimitsXmlTest extends ConverterBaseTest { - - private static Network createNetwork() { - Network network = NetworkFactory.create("ReactiveLimits", "???"); - network.setCaseDate(DateTime.parse("2016-01-01T10:00:00.000+02:00")); - Substation s = network.newSubstation() - .setId("S") - .setCountry(Country.FR) - .setTso("RTE") - .add(); - VoltageLevel vl = s.newVoltageLevel() - .setId("VL") - .setNominalV(380) - .setTopologyKind(TopologyKind.BUS_BREAKER) - .add(); - vl.getBusBreakerView().newBus() - .setId("B") - .add(); - Generator g1 = vl.newGenerator() - .setId("G1") - .setEnergySource(EnergySource.OTHER) - .setMaxP(10) - .setMinP(0) - .setVoltageRegulatorOn(true) - .setTargetV(380) - .setTargetP(10) - .setBus("B") - .setConnectableBus("B") - .add(); - g1.newReactiveCapabilityCurve() - .beginPoint() - .setP(5) - .setMinQ(1) - .setMaxQ(10) - .endPoint() - .beginPoint() - .setP(10) - .setMinQ(-10) - .setMaxQ(1) - .endPoint() - .add(); - Generator g2 = vl.newGenerator() - .setId("G2") - .setEnergySource(EnergySource.OTHER) - .setMaxP(10) - .setMinP(0) - .setVoltageRegulatorOn(true) - .setTargetV(380) - .setTargetP(10) - .setBus("B") - .setConnectableBus("B") - .add(); - g2.newMinMaxReactiveLimits() - .setMinQ(1) - .setMaxQ(10) - .add(); - - return network; - } - - @Test - public void roundTripTest() throws IOException { - roundTripXmlTest(createNetwork(), - NetworkXml::writeAndValidate, - NetworkXml::read, - "/reactiveLimitsRoundTripRef.xml"); - } -} diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/SimpleAnonymizerTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/SimpleAnonymizerTest.java deleted file mode 100644 index 00d4e4c9..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/SimpleAnonymizerTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.commons.ConverterBaseTest; -import eu.itesla_project.iidm.datasource.MemDataSource; -import eu.itesla_project.iidm.network.Network; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * @author Geoffroy Jamgotchian - */ -public class SimpleAnonymizerTest extends ConverterBaseTest { - - private void anonymisationTest(Network network, String xiidmRef, String anonymizedXiidmRef, String anonymizedCsvRef) throws IOException { - // export with anonymisation on - Properties properties = new Properties(); - properties.put(XMLExporter.ANONYMISED_PROPERTIES, "true"); - MemDataSource dataSource = new MemDataSource(); - new XMLExporter().export(network, properties, dataSource); - - // check we have 2 files, the anonymized IIDM XML and a CSV mapping file and compare to anonymized reference files - try (InputStream is = new ByteArrayInputStream(dataSource.getData(null, "xiidm"))) { - compareXml(getClass().getResourceAsStream(anonymizedXiidmRef), is); - } - try (InputStream is = new ByteArrayInputStream(dataSource.getData("_mapping", "csv"))) { - compareTxt(getClass().getResourceAsStream(anonymizedCsvRef), is); - } - - // re-import the IIDM XML using the CSV mapping file - Network network2 = new XMLImporter().import_(dataSource, null); - MemDataSource dataSource2 = new MemDataSource(); - new XMLExporter().export(network2, null, dataSource2); - - // check that re-imported IIDM XML has been deanonymized and is equals to reference file - roundTripXmlTest(network2, - NetworkXml::writeAndValidate, - NetworkXml::read, - xiidmRef); - } - - @Test - public void test() throws IOException { - anonymisationTest(NetworkXmlTest.createEurostagTutorialExample1(), - "/eurostag-tutorial-example1.xml", - "/eurostag-tutorial-example1-anonymized.xml", - "/eurostag-tutorial-example1-mapping.csv"); - } -} \ No newline at end of file diff --git a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXmlTest.java b/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXmlTest.java deleted file mode 100644 index 3f44633c..00000000 --- a/iidm-xml-converter/src/test/java/eu/itesla_project/iidm/xml/StaticVarCompensatorXmlTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.iidm.xml; - -import eu.itesla_project.commons.ConverterBaseTest; -import eu.itesla_project.iidm.network.test.SvcTestCaseFactory; -import org.junit.Test; - -import java.io.IOException; - -/** - * @author Geoffroy Jamgotchian - */ -public class StaticVarCompensatorXmlTest extends ConverterBaseTest { - - @Test - public void roundTripTest() throws IOException { - roundTripXmlTest(SvcTestCaseFactory.create(), - NetworkXml::writeAndValidate, - NetworkXml::read, - "/staticVarCompensatorRoundTripRef.xml"); - } -} diff --git a/iidm-xml-converter/src/test/resources/LccRoundTripRef.xml b/iidm-xml-converter/src/test/resources/LccRoundTripRef.xml deleted file mode 100644 index f902b018..00000000 --- a/iidm-xml-converter/src/test/resources/LccRoundTripRef.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/iidm-xml-converter/src/test/resources/VscRoundTripRef.xml b/iidm-xml-converter/src/test/resources/VscRoundTripRef.xml deleted file mode 100644 index 4e3a0cbc..00000000 --- a/iidm-xml-converter/src/test/resources/VscRoundTripRef.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-anonymized.xml b/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-anonymized.xml deleted file mode 100644 index 15a8ae79..00000000 --- a/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-anonymized.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-mapping.csv b/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-mapping.csv deleted file mode 100644 index 0455f767..00000000 --- a/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1-mapping.csv +++ /dev/null @@ -1,19 +0,0 @@ -P1;A -RTE;B -A;C -VLGEN;D -NGEN;E -GEN;F -VLHV1;G -NHV1;H -NGEN_NHV1;I -P2;J -B;K -VLHV2;L -NHV2;M -VLLOAD;N -NLOAD;O -LOAD;P -NHV2_NLOAD;Q -NHV1_NHV2_1;R -NHV1_NHV2_2;S diff --git a/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1.xml b/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1.xml deleted file mode 100644 index dbb2f91a..00000000 --- a/iidm-xml-converter/src/test/resources/eurostag-tutorial-example1.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-xml-converter/src/test/resources/optionalLoadTypeBug.xml b/iidm-xml-converter/src/test/resources/optionalLoadTypeBug.xml deleted file mode 100644 index 49e0a91f..00000000 --- a/iidm-xml-converter/src/test/resources/optionalLoadTypeBug.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/iidm-xml-converter/src/test/resources/phaseShifterRoundTripRef.xml b/iidm-xml-converter/src/test/resources/phaseShifterRoundTripRef.xml deleted file mode 100644 index d32cb081..00000000 --- a/iidm-xml-converter/src/test/resources/phaseShifterRoundTripRef.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-xml-converter/src/test/resources/reactiveLimitsRoundTripRef.xml b/iidm-xml-converter/src/test/resources/reactiveLimitsRoundTripRef.xml deleted file mode 100644 index 53f66a66..00000000 --- a/iidm-xml-converter/src/test/resources/reactiveLimitsRoundTripRef.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/iidm-xml-converter/src/test/resources/staticVarCompensatorRoundTripRef.xml b/iidm-xml-converter/src/test/resources/staticVarCompensatorRoundTripRef.xml deleted file mode 100644 index 81d777c3..00000000 --- a/iidm-xml-converter/src/test/resources/staticVarCompensatorRoundTripRef.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iidm-xml-converter/src/test/resources/xsd/loadZipModel.xsd b/iidm-xml-converter/src/test/resources/xsd/loadZipModel.xsd deleted file mode 100644 index 1b144c9c..00000000 --- a/iidm-xml-converter/src/test/resources/xsd/loadZipModel.xsd +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/loadflow-api/pom.xml b/loadflow-api/pom.xml deleted file mode 100644 index e228a032..00000000 --- a/loadflow-api/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - 4.0.0 - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - - loadflow-api - - Loadflow API - - - - eu.itesla_project - computation - ${project.version} - - - eu.itesla_project - iidm-network-api - ${project.version} - - - - diff --git a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlow.java b/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlow.java deleted file mode 100644 index 520957e3..00000000 --- a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlow.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.loadflow.api; - -import eu.itesla_project.commons.Versionable; - -import java.util.concurrent.CompletableFuture; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface LoadFlow extends Versionable { - - LoadFlowResult run(LoadFlowParameters parameters) throws Exception; - - LoadFlowResult run() throws Exception; - - default CompletableFuture runAsync(String workingStateId, LoadFlowParameters parameters) { - throw new UnsupportedOperationException(); - } - -} diff --git a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowFactory.java b/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowFactory.java deleted file mode 100644 index eb2edc0b..00000000 --- a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.loadflow.api; - -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.iidm.network.Network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface LoadFlowFactory { - - LoadFlow create(Network network, ComputationManager computationManager, int priority); - -} diff --git a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowParameters.java b/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowParameters.java deleted file mode 100644 index 9b42149c..00000000 --- a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowParameters.java +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.loadflow.api; - -import com.google.common.collect.ImmutableMap; -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; - -import java.util.Map; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class LoadFlowParameters implements Cloneable { - - private static final VoltageInitMode DEFAULT_VOLTAGE_INIT_MODE = VoltageInitMode.UNIFORM_VALUES; - private static final boolean DEFAULT_TRANSFORMER_VOLTAGE_CONTROL_ON = false; - private static final boolean DEFAULT_NO_GENERATOR_REACTIVE_LIMITS = false; - private static final boolean DEFAULT_PHASE_SHIFTER_REGULATION_ON = false; - - public enum VoltageInitMode { - UNIFORM_VALUES, // v=1pu, theta=0 - PREVIOUS_VALUES, - DC_VALUES // preprocessing to compute DC angles - } - - public static LoadFlowParameters load() { - LoadFlowParameters parameters = new LoadFlowParameters(); - load(parameters); - return parameters; - } - - protected static void load(LoadFlowParameters parameters) { - ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfigIfExists("load-flow-default-parameters"); - if (config != null) { - parameters.setVoltageInitMode(config.getEnumProperty("voltageInitMode", VoltageInitMode.class, DEFAULT_VOLTAGE_INIT_MODE)); - parameters.setTransformerVoltageControlOn(config.getBooleanProperty("transformerVoltageControlOn", DEFAULT_TRANSFORMER_VOLTAGE_CONTROL_ON)); - parameters.setNoGeneratorReactiveLimits(config.getBooleanProperty("noGeneratorReactiveLimits", DEFAULT_NO_GENERATOR_REACTIVE_LIMITS)); - parameters.setPhaseShifterRegulationOn(config.getBooleanProperty("phaseShifterRegulationOn", DEFAULT_PHASE_SHIFTER_REGULATION_ON)); - } - } - - private VoltageInitMode voltageInitMode; - - private boolean transformerVoltageControlOn; - - private boolean noGeneratorReactiveLimits; - - private boolean phaseShifterRegulationOn; - - public LoadFlowParameters(VoltageInitMode voltageInitMode, boolean transformerVoltageControlOn, - boolean noGeneratorReactiveLimits, boolean phaseShifterRegulationOn) { - this.voltageInitMode = voltageInitMode; - this.transformerVoltageControlOn = transformerVoltageControlOn; - this.noGeneratorReactiveLimits = noGeneratorReactiveLimits; - this.phaseShifterRegulationOn = phaseShifterRegulationOn; - } - - public LoadFlowParameters(VoltageInitMode voltageInitMode, boolean transformerVoltageControlOn) { - this(voltageInitMode, transformerVoltageControlOn, DEFAULT_NO_GENERATOR_REACTIVE_LIMITS, DEFAULT_PHASE_SHIFTER_REGULATION_ON); - } - - public LoadFlowParameters(VoltageInitMode voltageInitMode) { - this(voltageInitMode, DEFAULT_TRANSFORMER_VOLTAGE_CONTROL_ON, DEFAULT_NO_GENERATOR_REACTIVE_LIMITS, DEFAULT_PHASE_SHIFTER_REGULATION_ON); - } - - public LoadFlowParameters() { - this(DEFAULT_VOLTAGE_INIT_MODE, DEFAULT_TRANSFORMER_VOLTAGE_CONTROL_ON, DEFAULT_NO_GENERATOR_REACTIVE_LIMITS, DEFAULT_PHASE_SHIFTER_REGULATION_ON); - } - - protected LoadFlowParameters(LoadFlowParameters other) { - Objects.requireNonNull(other); - voltageInitMode = other.voltageInitMode; - transformerVoltageControlOn = other.transformerVoltageControlOn; - noGeneratorReactiveLimits = other.noGeneratorReactiveLimits; - phaseShifterRegulationOn = other.phaseShifterRegulationOn; - } - - public VoltageInitMode getVoltageInitMode() { - return voltageInitMode; - } - - public LoadFlowParameters setVoltageInitMode(VoltageInitMode voltageInitMode) { - this.voltageInitMode = Objects.requireNonNull(voltageInitMode); - return this; - } - - public boolean isTransformerVoltageControlOn() { - return transformerVoltageControlOn; - } - - public LoadFlowParameters setTransformerVoltageControlOn(boolean transformerVoltageControlOn) { - this.transformerVoltageControlOn = transformerVoltageControlOn; - return this; - } - - public boolean isNoGeneratorReactiveLimits() { - return noGeneratorReactiveLimits; - } - - public LoadFlowParameters setNoGeneratorReactiveLimits(boolean noGeneratorReactiveLimits) { - this.noGeneratorReactiveLimits = noGeneratorReactiveLimits; - return this; - } - - public boolean isPhaseShifterRegulationOn() { - return phaseShifterRegulationOn; - } - - public LoadFlowParameters setPhaseShifterRegulationOn(boolean phaseShifterRegulationOn) { - this.phaseShifterRegulationOn = phaseShifterRegulationOn; - return this; - } - - protected Map toMap() { - return ImmutableMap.of("voltageInitMode", voltageInitMode, - "transformerVoltageControlOn", transformerVoltageControlOn, - "noGeneratorReactiveLimits", noGeneratorReactiveLimits, - "phaseShifterRegulationOn", phaseShifterRegulationOn); - } - - @Override - public LoadFlowParameters clone() { - return new LoadFlowParameters(this); - } - - @Override - public String toString() { - return toMap().toString(); - } -} diff --git a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowResult.java b/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowResult.java deleted file mode 100644 index 2c17dd3a..00000000 --- a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/LoadFlowResult.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.loadflow.api; - -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface LoadFlowResult { - - boolean isOk(); - - Map getMetrics(); - - String getLogs(); - -} diff --git a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowFactoryMock.java b/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowFactoryMock.java deleted file mode 100644 index 6e3796c7..00000000 --- a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowFactoryMock.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.loadflow.api.mock; - -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.loadflow.api.LoadFlow; -import eu.itesla_project.loadflow.api.LoadFlowFactory; - -/** - * @author Quinary - * @author Mathieu Bague - */ -public class LoadFlowFactoryMock implements LoadFlowFactory { - @Override - public LoadFlow create(Network network, ComputationManager computationManager, int priority) { - return new LoadFlowMock(); - } -} diff --git a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowMock.java b/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowMock.java deleted file mode 100644 index b4ec3e80..00000000 --- a/loadflow-api/src/main/java/eu/itesla_project/loadflow/api/mock/LoadFlowMock.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.loadflow.api.mock; - -import eu.itesla_project.loadflow.api.LoadFlow; -import eu.itesla_project.loadflow.api.LoadFlowParameters; -import eu.itesla_project.loadflow.api.LoadFlowResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collections; -import java.util.Map; - -/** - * @author Quinary - * @author Mathieu Bague - */ -class LoadFlowMock implements LoadFlow { - private Logger LOGGER = LoggerFactory.getLogger(LoadFlowMock.class); - - @Override - public String getName() { - return "LoadFlow Mock"; - } - - @Override - public String getVersion() { - return null; - } - - @Override - public LoadFlowResult run() throws Exception { - return run(null); - } - - @Override - public LoadFlowResult run(LoadFlowParameters parameters) throws Exception { - LOGGER.warn("Running loadflow mock"); - - return new LoadFlowResult() { - - @Override - public boolean isOk() { - return true; - } - - @Override - public Map getMetrics() { - return Collections.emptyMap(); - } - - @Override - public String getLogs() { - return ""; - } - }; - } -}; diff --git a/mmap-offline-db/pom.xml b/mmap-offline-db/pom.xml index 79b357da..9919c590 100644 --- a/mmap-offline-db/pom.xml +++ b/mmap-offline-db/pom.xml @@ -83,13 +83,16 @@ eu.itesla_project iidm-network-test - 0.1-SNAPSHOT test eu.itesla_project iidm-network-impl - 0.1-SNAPSHOT + test + + + eu.itesla_project + graph test diff --git a/modelica-events-adder/pom.xml b/modelica-events-adder/pom.xml index fcfe8109..4290ff2b 100644 --- a/modelica-events-adder/pom.xml +++ b/modelica-events-adder/pom.xml @@ -36,6 +36,10 @@ /home/machados/sources/itesla/platform/modelica-events-adder/events/CIMEvents_example.csv + + org.slf4j + slf4j-api + ch.qos.logback logback-classic diff --git a/modelica-export/pom.xml b/modelica-export/pom.xml index 09cbe8d9..187ba548 100644 --- a/modelica-export/pom.xml +++ b/modelica-export/pom.xml @@ -55,28 +55,27 @@ + + ${project.groupId} + computation-local + ${project.groupId} iidm-network-api - ${project.version} ${project.groupId} iidm-network-impl - ${project.version} ${project.groupId} iidm-converter-api - ${project.version} eu.itesla_project loadflow-api - ${project.version} - eu.itesla_project.iidm-ddb diff --git a/modules/pom.xml b/modules/pom.xml index a418a9a9..7aee52c4 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -45,27 +45,22 @@ ${project.groupId} iidm-network-api - ${project.version} ${project.groupId} iidm-converter-api - ${project.version} ${project.groupId} computation - ${project.version} ${project.groupId} computation-local - ${project.version} ${project.groupId} case-repository - ${project.version} ${project.groupId} @@ -80,22 +75,18 @@ ${project.groupId} simulation-api - ${project.version} ${project.groupId} contingency-api - ${project.version} eu.itesla_project security-analysis - ${project.version} eu.itesla_project iidm-xml-converter - ${project.version} joda-time @@ -112,7 +103,6 @@ eu.itesla_project loadflow-api - ${project.version} junit @@ -152,7 +142,11 @@ ${project.groupId} iidm-network-impl - ${project.version} + test + + + eu.itesla_project + graph test diff --git a/mpi-communication/CMakeLists.txt b/mpi-communication/CMakeLists.txt deleted file mode 100644 index bbd7adfd..00000000 --- a/mpi-communication/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -# Copyright (c) 2016, RTE (http://www.rte-france.com) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -cmake_minimum_required(VERSION 2.6) - -project(mpi) - -find_package(MPI REQUIRED) -set(CMAKE_CXX_COMPILER mpicxx) - -find_package(Boost REQUIRED COMPONENTS filesystem system program_options iostreams) -find_package(JNI REQUIRED) -find_package(Log4cpp REQUIRED) -find_package(LibArchive REQUIRED) -find_package(Protobuf REQUIRED) -find_package(ZLIB REQUIRED) - -# common library -set(COMMON_SOURCES - src/ioutil.cpp - src/mpitags.cpp - src/mpiutil.cpp -) -add_library(common ${COMMON_SOURCES}) - -# master library -set(MASTER_SOURCES - src/jniutil.cpp - src/master.cpp -) -add_library(master SHARED ${MASTER_SOURCES}) -target_link_libraries(master common ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_IOSTREAMS_LIBRARY} ${Log4cpp_LIBRARIES} ${LibArchive_LIBRARIES}) - -# slave binary -set(SLAVE_SOURCES - src/messages.pb.cc - src/slave.cpp -) -add_executable(slave ${SLAVE_SOURCES}) -target_link_libraries(slave common ${Boost_LIBRARIES} ${LibArchive_LIBRARIES} ${Log4cpp_LIBRARIES} ${Protobuf_LIBRARIES} ${ZLIB_LIBRARIES}) - -include_directories(${Boost_INCLUDE_DIRS}) -include_directories(${JNI_INCLUDE_DIRS}) -include_directories(${LibArchive_INCLUDE_DIRS}) -include_directories(${Log4cpp_INCLUDE_DIRS}) -include_directories(${Protobuf_INCLUDE_DIRS}) diff --git a/mpi-communication/src/ioutil.cpp b/mpi-communication/src/ioutil.cpp deleted file mode 100644 index de21f2dd..00000000 --- a/mpi-communication/src/ioutil.cpp +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file ioutil.cpp - * @author Geoffroy Jamgotchian - */ - -#include "ioutil.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if BOOST_VERSION >= 104600 -#define BOOST_FILENAME_STRING(filename) filename.string() -#else -#define BOOST_FILENAME_STRING(filename) filename -#endif - -extern char** environ; - -namespace itesla { - -namespace io { - -const float SPACE_WARNING_THRESHOLD = 0.1f; - -void checkSpace(const boost::filesystem::path& path, log4cpp::Category& logger) { - boost::filesystem::space_info space = boost::filesystem::space(path); - float p = (float) space.available / space.capacity; - if (p < SPACE_WARNING_THRESHOLD) { - logger.warnStream() << path.string() << " almost full (" << p * 100 << "% available)" << log4cpp::eol; - } -} - -log4cpp::PatternLayout* createLayout() { - log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); - layout->setConversionPattern("%d{%Y-%m-%d_%H:%M:%S.%l} %p %c - %m%n"); - return layout; -} - -log4cpp::Appender* createConsoleLogAppender() { - log4cpp::Appender* appender = new log4cpp::OstreamAppender("console", &std::cout); - appender->setLayout(createLayout()); - return appender; -} - -log4cpp::Appender* createFileLogAppender(const std::string& file) { - log4cpp::Appender* appender = new log4cpp::FileAppender("file", file); - appender->setLayout(createLayout()); - return appender; -} - -std::map readProperties(const boost::filesystem::path& file) { - if (!boost::filesystem::exists(file) || !boost::filesystem::is_regular(file)) { - throw std::runtime_error(file.string() + " does not exist or is not a regular file"); - } - std::map properties; - std::ifstream ifs(file.string()); - std::string line; - while (std::getline(ifs, line)) { - boost::algorithm::trim(line); - if (line.empty()) { - continue; - } - std::istringstream iss(line); - std::string name; - std::string value; - if (!std::getline(iss, name, '=') || !std::getline(iss, value, '=')) { - throw std::runtime_error("Error while reading line '" + line + "' of file " + file.string()); - } - properties[name] = value; - } - if (!ifs.eof()) { - throw std::runtime_error("Error while reading file " + file.string()); - } - return properties; -} - -std::map getEnv() { - std::map env; - for(char** v = environ; *v; v++) { - std::istringstream iss(*v); - std::string name; - std::string value; - std::getline(iss, name, '='); - std::getline(iss, value, '='); - env[name] = value; - } - return env; -} - -std::string errnoMsg(const std::string& f) { - char buferr[256]; - std::string msg = f + " : "; - msg += strerror_r(errno, buferr, sizeof(buferr)); - return msg; -} - -int systemSafe(const std::string& command, const boost::filesystem::path& workingDir, const std::map& env, const boost::filesystem::path& outFile, int timeout, log4cpp::Category& logger) { - std::string command2; - if (timeout != -1) { - command2 = "timeout -s KILL " + boost::lexical_cast(timeout) + " "; - } - command2 += "/bin/sh -c '"; - if (env.size() > 0) { - for (std::map::const_iterator it = env.begin(); it != env.end(); it++) { - command2 += "export "; - command2 += it->first; - command2 += "="; - command2 += it->second; - command2 += "; "; - } - } - command2 += "cd " + workingDir.string() + "; " + command + " >> \"" + outFile.string() + "\" 2>&1'"; - int status = ::system(command2.c_str()); - if (WIFEXITED(status)) { - int exitCode = WEXITSTATUS(status); - log4cpp::CategoryStream stream = (exitCode == 0 ? logger.debugStream() : logger.warnStream()); - // log the full system command line in case of 127 - stream << "command '" << (exitCode == 127 ? command2 : command) << "' exited with code " << exitCode << log4cpp::eol; - return exitCode; - } else if (WIFSIGNALED(status)) { - int signal = WTERMSIG(status); - logger.warnStream() << "command '" << command << "' received signal " << signal << log4cpp::eol; - return signal; - } else { - logger.warnStream() << "command '" << command << "' terminated with unexpected status " << status << log4cpp::eol; - return status; - } -} - -void cleanDir(boost::filesystem::path dir) { - for (boost::filesystem::directory_iterator end_dir_it, it(dir); it != end_dir_it; ++it) { - boost::filesystem::remove_all(it->path()); - } -} - -size_t dirSize(boost::filesystem::path dir) { - size_t size = 0; - for(boost::filesystem::recursive_directory_iterator it(dir); - it != boost::filesystem::recursive_directory_iterator(); - ++it) { - if(!boost::filesystem::is_directory(*it)) { - size += boost::filesystem::file_size(*it); - } - } - return size; -} - -std::string readFile(const boost::filesystem::path& file) { - boost::filesystem::ifstream ifs(file, std::ios::binary); - return std::string(std::istreambuf_iterator(ifs), std::istreambuf_iterator()); -} - -void gunzipMem(const std::string& gzipData, const boost::filesystem::path& toFile) { - boost::filesystem::ofstream ofs(toFile, std::ios::binary); - std::istringstream iss(gzipData, std::ios_base::binary); - boost::iostreams::filtering_streambuf in; - in.push(boost::iostreams::gzip_decompressor()); - in.push(iss); - boost::iostreams::copy(in, ofs); -} - -void gunzipFile(const boost::filesystem::path& file, const boost::filesystem::path& destDir) { - if (!boost::filesystem::exists(file) || !boost::filesystem::is_regular(file)) { - throw std::runtime_error(file.string() + " does not exist or is not a regular file"); - } - if (!boost::filesystem::exists(destDir) || !boost::filesystem::is_directory(destDir)) { - throw std::runtime_error(destDir.string() + " does not exist or is not a directory"); - } - boost::filesystem::ifstream ifs(file, std::ios_base::binary); - boost::iostreams::filtering_streambuf in; - in.push(boost::iostreams::gzip_decompressor()); - in.push(ifs); - boost::filesystem::ofstream ofs(destDir / file.stem(), std::ios::binary); - boost::iostreams::copy(in, ofs); -} - -std::string gzipMem(const boost::filesystem::path& file, log4cpp::Category& logger) { - if (!boost::filesystem::exists(file) || !boost::filesystem::is_regular(file)) { - throw std::runtime_error(file.string() + " does not exist or is not a regular file"); - } - std::ostringstream oss(std::ios_base::binary); - try { - boost::filesystem::ifstream ifs(file, std::ios::binary); - boost::iostreams::filtering_streambuf in; - in.push(boost::iostreams::gzip_compressor()); - in.push(ifs); - boost::iostreams::copy(in, oss); - } catch(const boost::iostreams::gzip_error& e) { - logger.errorStream() << "Gzip error (msg='" << e.what() << "', error=" << e.error() << ", zlib_error_code=" << e.zlib_error_code() - << ", file=" << file.string() << ", file_size=" << boost::filesystem::file_size(file) << ")" << log4cpp::eol; - throw; - } - return oss.str(); -} - -void unzipMem(const std::string& zipMem, const boost::filesystem::path& dir) { - if (!boost::filesystem::exists(dir) || !boost::filesystem::is_directory(dir)) { - throw std::runtime_error(dir.string() + " does not exist or is not a directory"); - } - struct archive* a = archive_read_new(); - struct archive_entry* entry; - archive_read_support_format_zip(a); - archive_read_open_memory(a, (void*) zipMem.c_str(), zipMem.length()); - size_t bufferSize = 1000; - char buffer[bufferSize]; - while (archive_read_next_header(a, &entry) == ARCHIVE_OK) { - boost::filesystem::path file = dir / archive_entry_pathname(entry); - boost::filesystem::ofstream ofs(file, std::ios_base::binary); - for (;;) { - size_t size = archive_read_data(a, buffer, bufferSize); - if (size < 0) { - throw std::runtime_error("error archive_read_data"); - } - if (size == 0) { - break; - } - ofs.write(buffer, size); - } - } - archive_read_finish(a); -} - -void unzipFile(const boost::filesystem::path& zipFile, const boost::filesystem::path& dir) { - if (!boost::filesystem::exists(zipFile) || !boost::filesystem::is_regular(zipFile)) { - throw std::runtime_error(zipFile.string() + " does not exist or is not a regular file"); - } - if (!boost::filesystem::exists(dir) || !boost::filesystem::is_directory(dir)) { - throw std::runtime_error(dir.string() + " does not exist or is not a directory"); - } - struct archive* a = archive_read_new(); - struct archive_entry* entry; - archive_read_support_format_zip(a); - int r = archive_read_open_filename(a, zipFile.string().c_str(), 10240); - if (r != ARCHIVE_OK) { - throw std::runtime_error("error archive_read_open_filename"); - } - size_t bufferSize = 1000; - char buffer[bufferSize]; - while (archive_read_next_header(a, &entry) == ARCHIVE_OK) { - boost::filesystem::path file = dir / archive_entry_pathname(entry); - boost::filesystem::ofstream ofs(file, std::ios_base::binary); - for (;;) { - size_t size = archive_read_data(a, buffer, bufferSize); - if (size < 0) { - throw std::runtime_error("error archive_read_data"); - } - if (size == 0) { - break; - } - ofs.write(buffer, size); - } - } - archive_read_finish(a); -} - -void zipDir(const boost::filesystem::path& dir, const boost::filesystem::path& zipFile, const std::string& zipDirName) { - if (!boost::filesystem::exists(dir) || !boost::filesystem::is_directory(dir)) { - throw std::runtime_error(dir.string() + " does not exist or is not a directory"); - } - struct archive* a = archive_write_new(); - archive_write_set_format_zip(a); - archive_write_open_filename(a, zipFile.string().c_str()); - for (boost::filesystem::directory_iterator endDirIt, it(dir); it != endDirIt; ++it) { - boost::filesystem::path file = it->path(); - struct stat st; - stat(file.string().c_str(), &st); - struct archive_entry * entry = archive_entry_new(); - archive_entry_set_pathname(entry, (zipDirName + "/" + BOOST_FILENAME_STRING(file.filename())).c_str()); - archive_entry_set_size(entry, st.st_size); - archive_entry_set_filetype(entry, AE_IFREG); - archive_entry_set_perm(entry, 0644); - archive_write_header(a, entry); - std::string buffer = readFile(file); - archive_write_data(a, buffer.c_str(), buffer.size()); - archive_entry_free(entry); - } - archive_write_close(a); - archive_write_finish(a); -} - -} - -} diff --git a/mpi-communication/src/ioutil.hpp b/mpi-communication/src/ioutil.hpp deleted file mode 100644 index 2a58a1f5..00000000 --- a/mpi-communication/src/ioutil.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file ioutil.hpp - * @author Geoffroy Jamgotchian - */ - -#include -#include -#include -#include -#include -#include - -namespace itesla { - -namespace io { - -void checkSpace(const boost::filesystem::path& path, log4cpp::Category& logger); -log4cpp::Appender* createConsoleLogAppender(); -log4cpp::Appender* createFileLogAppender(const std::string& file); -std::map readProperties(const boost::filesystem::path& file); -std::map getEnv(); -int systemSafe(const std::string& command, const boost::filesystem::path& workingDir, const std::map& env, const boost::filesystem::path& outFile, int timeout, log4cpp::Category& logger); -void cleanDir(boost::filesystem::path dir); -size_t dirSize(boost::filesystem::path dir); -std::string readFile(const boost::filesystem::path& file); -void gunzipMem(const std::string& gzipData, const boost::filesystem::path& toFile); -void gunzipFile(const boost::filesystem::path& file, const boost::filesystem::path& destDir); -std::string gzipMem(const boost::filesystem::path& file, log4cpp::Category& logger); -void unzipMem(const std::string& zipMem, const boost::filesystem::path& dir); -void unzipFile(const boost::filesystem::path& zipFile, const boost::filesystem::path& dir); -void zipDir(const boost::filesystem::path& dir, const boost::filesystem::path& zipFile, const std::string& zipDirName); - -} - -} diff --git a/mpi-communication/src/jniutil.cpp b/mpi-communication/src/jniutil.cpp deleted file mode 100644 index aa6f2b99..00000000 --- a/mpi-communication/src/jniutil.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file jniutil.cpp - * @author Geoffroy Jamgotchian - */ - -#include "jniutil.hpp" - -namespace itesla { - -namespace jni { - -jmethodID JavaUtilList::_sizeMethodId = 0; -jmethodID JavaUtilList::_getMethodId = 0; -jmethodID JavaUtilList::_addMethodId = 0; - -void JavaUtilList::init(JNIEnv* env) { - jclass _class = (jclass) env->FindClass("java/util/List"); - _sizeMethodId = env->GetMethodID(_class, "size", "()I"); - _getMethodId = env->GetMethodID(_class, "get", "(I)Ljava/lang/Object;"); - _addMethodId = env->GetMethodID(_class, "add", "(Ljava/lang/Object;)Z"); -} - -jmethodID EuIteslaProjectComputationMpiMpiTask::_getIdMethodId = 0; -jmethodID EuIteslaProjectComputationMpiMpiTask::_getRankMethodId = 0; -jmethodID EuIteslaProjectComputationMpiMpiTask::_getThreadMethodId = 0; -jmethodID EuIteslaProjectComputationMpiMpiTask::_getMessageMethodId = 0; -jmethodID EuIteslaProjectComputationMpiMpiTask::_setResultMessageMethodId = 0; - -void EuIteslaProjectComputationMpiMpiTask::init(JNIEnv* env) { - jclass _class = env->FindClass("eu/itesla_project/computation/mpi/MpiTask"); - _getIdMethodId = env->GetMethodID(_class, "getId", "()I"); - _getRankMethodId = env->GetMethodID(_class, "getRank", "()I"); - _getThreadMethodId = env->GetMethodID(_class, "getThread", "()I"); - _getMessageMethodId = env->GetMethodID(_class, "getMessage", "()[B"); - _setResultMessageMethodId = env->GetMethodID(_class, "setResultMessage", "([B)V"); -} - -int EuIteslaProjectComputationMpiMpiTask::id() const { - return _env->CallIntMethod(_obj, _getIdMethodId); -} - -int EuIteslaProjectComputationMpiMpiTask::rank() const { - return _env->CallIntMethod(_obj, _getRankMethodId); -} - -int EuIteslaProjectComputationMpiMpiTask::thread() const { - return _env->CallIntMethod(_obj, _getThreadMethodId); -} - -jbyteArray EuIteslaProjectComputationMpiMpiTask::message() const { - return (jbyteArray) _env->CallObjectMethod(_obj, _getMessageMethodId); -} - -void EuIteslaProjectComputationMpiMpiTask::resultMessage(const std::string& buffer) { - jbyteArray jresult = _env->NewByteArray(buffer.size()); - _env->SetByteArrayRegion(jresult, 0, buffer.size(), (jbyte*) &buffer[0]); - _env->CallVoidMethod(_obj, _setResultMessageMethodId, jresult); -} - -void throwJavaLangRuntimeException(JNIEnv* env, const char* msg) { - jclass clazz = env->FindClass("java/lang/RuntimeException"); - env->ThrowNew(clazz, msg); -} - -} - -} diff --git a/mpi-communication/src/jniutil.hpp b/mpi-communication/src/jniutil.hpp deleted file mode 100644 index 01dfc2bb..00000000 --- a/mpi-communication/src/jniutil.hpp +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file jniutil.hpp - * @author Geoffroy Jamgotchian - */ - -#ifndef JNIUTIL_HPP -#define JNIUTIL_HPP - -#include -#include -#include "jni.h" - -namespace itesla { - -namespace jni { - -class JniWrapper { -public: - JNIEnv* env() const { return _env; } - jobject obj() const { return _obj; } - -protected: - JniWrapper(JNIEnv* env, jobject obj) - : _env(env), _obj(obj) { - } - - virtual ~JniWrapper() { - } - - JNIEnv* _env; - jobject _obj; -private: - JniWrapper(const JniWrapper&); - JniWrapper& operator=(const JniWrapper&); -}; - -class ObjectArray : public JniWrapper { -public: - ObjectArray(JNIEnv* env, jobjectArray obj) - : JniWrapper(env, obj) { - } - - size_t length() const { - return _env->GetArrayLength((jobjectArray) _obj); - } - - jobject at(size_t i) const { - return _env->GetObjectArrayElement((jobjectArray) _obj, i); - } -}; - -class ByteArray : public JniWrapper { -public: - ByteArray(JNIEnv* env, jbyteArray obj) - : JniWrapper(env, obj), - _ptr(_env->GetByteArrayElements(obj, &_iscopy)) { - } - - ~ByteArray() { - if (_iscopy == JNI_TRUE) { - _env->ReleaseByteArrayElements((jbyteArray) _obj, _ptr, 0); - } - } - - size_t length() const { - return _env->GetArrayLength((jbyteArray) _obj); - } - - const char* get() const { - return (const char*) _ptr; - } - -private: - jboolean _iscopy; - jbyte* _ptr; -}; - -class JavaUtilList : public JniWrapper { -public: - JavaUtilList(JNIEnv* env, jobject obj) - : JniWrapper(env, obj) { - } - - static void init(JNIEnv* env); - - size_t size() const { return _env->CallIntMethod(_obj, _sizeMethodId); } - jobject get(size_t i) const { return _env->CallObjectMethod(_obj, _getMethodId, i); } - bool add(jobject e) const { return _env->CallBooleanMethod(_obj, _addMethodId, e); } - -private: - static jmethodID _sizeMethodId; - static jmethodID _getMethodId; - static jmethodID _addMethodId; -}; - -class EuIteslaProjectComputationMpiMpiTask : public JniWrapper { -public: - EuIteslaProjectComputationMpiMpiTask(JNIEnv* env, jobject obj) - : JniWrapper(env, obj) { - } - - static void init(JNIEnv* env); - - int id() const; - int rank() const; - int thread() const; - - jbyteArray message() const; - - void resultMessage(const std::string& buffer); - -private: - static jmethodID _getIdMethodId; - static jmethodID _getRankMethodId; - static jmethodID _getThreadMethodId; - static jmethodID _getMessageMethodId; - static jmethodID _setResultMessageMethodId; -}; - -void throwJavaLangRuntimeException(JNIEnv* env, const char* msg); - -} - -} - -#endif // JNIUTIL_HPP - diff --git a/mpi-communication/src/master.cpp b/mpi-communication/src/master.cpp deleted file mode 100644 index af502a3d..00000000 --- a/mpi-communication/src/master.cpp +++ /dev/null @@ -1,508 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file master.cpp - * @author Geoffroy Jamgotchian - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "jniutil.hpp" -#include "mpitags.hpp" -#include "mpiutil.hpp" -#include "ioutil.hpp" - -log4cpp::Category& LOGGER = log4cpp::Category::getInstance("Master"); - -namespace itesla { - -namespace master { - -struct SendContext { - SendContext(const std::string& sendBuffer) - : _length(sendBuffer.size()), - _lengthRequest(MPI_REQUEST_NULL), - _buffer(sendBuffer), - _bufferRequest(MPI_REQUEST_NULL) - {} - SendContext(const SendContext&) = delete; - SendContext& operator=(const SendContext&) = delete; - - int _length; - MPI_Request _lengthRequest; - std::string _buffer; - MPI_Request _bufferRequest; -}; - -struct TaskContext { - TaskContext(const std::string& sendBuffer) - : _send(sendBuffer), - _receiveLengthRequest(MPI_REQUEST_NULL), - _receiveBufferRequest(MPI_REQUEST_NULL) - {} - TaskContext(const TaskContext&) = delete; - TaskContext& operator=(const TaskContext&) = delete; - - SendContext _send; - - int _receiveLength; - MPI_Request _receiveLengthRequest; - std::string _receiveBuffer; - MPI_Request _receiveBufferRequest; -}; - -class CommunicationManager { -public: - CommunicationManager(int coresPerRank); - CommunicationManager(const CommunicationManager&) = delete; - CommunicationManager& operator=(const CommunicationManager&) = delete; - ~CommunicationManager(); - - void init(); - void shutdown(); - - int commRank(); - int commSize(); - const std::string& mpiVersion(); - void startTasks(const itesla::jni::JavaUtilList& tasks); - void checkTasksCompletion(const itesla::jni::JavaUtilList& runningTasks, const itesla::jni::JavaUtilList& completedTasks); - void broadcastCommonFile(const itesla::jni::ByteArray& file); - -private: - void checkThread() const; - void ensureStep(Step step); - void checkStep(Step step); - void checkStep(Step step1, Step step2); - - const int _coresPerRank; - std::thread::id _threadId; - int _commRank; - int _commSize; - std::string _mpiVersion; - Step _step; - std::map > _taskContexts; -}; - -CommunicationManager::CommunicationManager(int coresPerRank) - : _coresPerRank(coresPerRank), - _step(Step::SHUTDOWN) { -} - -CommunicationManager::~CommunicationManager() { -} - -void CommunicationManager::checkThread() const { - // if (_threadId != std::this_thread::get_id()) { - // throw std::runtime_error("All MPI functions must be called from the same thread"); - // } -} - -void CommunicationManager::init() { - _threadId = std::this_thread::get_id(); - - _step = Step::COMMON_FILES_BCAST; - - if (_coresPerRank > MAX_CORES_PER_RANK) { - throw std::runtime_error("Too many cores per rank"); - } - - LOGGER.debugStream() << "starting " << log4cpp::eol; - - itesla::mpi::initThreadFunneled(); - if (MPI_Comm_rank(MPI_COMM_WORLD, &_commRank) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Comm_rank error"); - } - if (MPI_Comm_size(MPI_COMM_WORLD, &_commSize) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Comm_size error"); - } - - _mpiVersion = itesla::mpi::version(); - - LOGGER.debugStream() << "started on " << itesla::mpi::processorName() - << ", communicator size: " << _commSize << log4cpp::eol; - - LOGGER.debugStream() << "waiting for slaves to start" << log4cpp::eol; - if (MPI_Barrier(MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Barrier error"); - } -} - -void CommunicationManager::shutdown() { - checkThread(); - - LOGGER.debugStream() << "stopping" << log4cpp::eol; - - ensureStep(Step::SHUTDOWN); - - if (MPI_Finalize() != MPI_SUCCESS) { - throw std::runtime_error("MPI_Finalize error"); - } - - LOGGER.debugStream() << "stopped" << log4cpp::eol; -} - -int CommunicationManager::commRank() { - checkStep(Step::COMMON_FILES_BCAST, Step::TASKS_EXECUTION); - return _commRank; -} - -int CommunicationManager::commSize() { - checkStep(Step::COMMON_FILES_BCAST, Step::TASKS_EXECUTION); - return _commSize; -} - -const std::string& CommunicationManager::mpiVersion() { - checkStep(Step::COMMON_FILES_BCAST, Step::TASKS_EXECUTION); - return _mpiVersion; -} - -void CommunicationManager::ensureStep(Step nextStep) { - checkThread(); - - if (nextStep == _step) { - return; - } - - LOGGER.debugStream() << "switch slaves to " << str(nextStep) << log4cpp::eol; - - switch (_step) { - case Step::COMMON_FILES_BCAST: - switch (nextStep) { - case Step::TASKS_EXECUTION: - case Step::SHUTDOWN: { - // broadcast a special length message to switch slaves state - int length = step2specialLength(nextStep); - if (MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Bcast error"); - } - } - break; - - default: - throw std::runtime_error("Invalid next step " + str(nextStep) - + ", expected " + str(Step::TASKS_EXECUTION) + "|" + str(Step::SHUTDOWN)); - } - break; - - case Step::TASKS_EXECUTION: - switch (nextStep) { - case Step::COMMON_FILES_BCAST: - case Step::SHUTDOWN: { - // send a special length message to switch all slaves state - int length = step2specialLength(nextStep); - for (int rank = 1; rank < _commSize; rank++) { - for (int thread = 0; thread < _coresPerRank; thread++) { - if (MPI_Send(&length, 1, MPI_INT, rank, JOB_LENGTH_TAG + thread, MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Send error"); - } - } - } - } - - // master/slaves synchronization - if (MPI_Barrier(MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Barrier error"); - } - break; - - default: - throw std::runtime_error("Invalid next step " + str(nextStep) - + ", expected " + str(Step::COMMON_FILES_BCAST) + "|" + str(Step::SHUTDOWN)); - } - break; - - default: // cannot move from an other step - throw std::runtime_error("Cannot move from step " + str(_step)); - } - _step = nextStep; -} - -void CommunicationManager::checkStep(Step step) { - if (_step != step) { - throw std::runtime_error("Unexpected step " + str(_step)); - } -} - -void CommunicationManager::checkStep(Step step1, Step step2) { - if (_step != step1 && _step != step2) { - throw std::runtime_error("Unexpected step " + str(_step)); - } -} - -void CommunicationManager::startTasks(const itesla::jni::JavaUtilList& tasks) { - checkThread(); - - ensureStep(Step::TASKS_EXECUTION); - - for (size_t i = 0; i < tasks.size() ; i++) { - itesla::jni::EuIteslaProjectComputationMpiMpiTask task(tasks.env(), tasks.get(i)); - int taskId = task.id(); - int rank = task.rank(); - int thread = task.thread(); - itesla::jni::ByteArray message(tasks.env(), task.message()); - - // create job mpi context - std::shared_ptr context(new TaskContext(std::string(message.get(), message.length()))); - _taskContexts[taskId] = context; - - if (MPI_Isend(&context->_send._length, 1, MPI_INT, rank, JOB_LENGTH_TAG + thread, MPI_COMM_WORLD, &context->_send._lengthRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Isend error"); - } - if (MPI_Isend(&(context->_send._buffer[0]), context->_send._length, MPI_BYTE, rank, JOB_BUFFER_TAG + thread, MPI_COMM_WORLD, &context->_send._bufferRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Isend error"); - } - if (MPI_Irecv(&context->_receiveLength, 1, MPI_INT, rank, JOB_RESULT_LENGTH_TAG + thread, MPI_COMM_WORLD, &context->_receiveLengthRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Irecv error"); - } - } -} - -void CommunicationManager::checkTasksCompletion(const itesla::jni::JavaUtilList& runningTasks, const itesla::jni::JavaUtilList& completedTasks) { - checkThread(); - - if (runningTasks.size() == 0) { - return; - } - - checkStep(Step::TASKS_EXECUTION); - - for (size_t i = 0; i < runningTasks.size() ; i++) { - itesla::jni::EuIteslaProjectComputationMpiMpiTask task(runningTasks.env(), runningTasks.get(i)); - int taskId = task.id(); - std::shared_ptr context = _taskContexts[taskId]; - int flag; - MPI_Status status; - - if (context->_receiveLengthRequest != MPI_REQUEST_NULL) { - if (MPI_Test(&context->_receiveLengthRequest, &flag, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Test error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - if (flag) { - // receiving the result length message means, length and buffer have been sent. - // we must wall an MPI_Wait to avoid memory leaks - if (MPI_Wait(&context->_send._lengthRequest, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Wait error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - if (MPI_Wait(&context->_send._bufferRequest, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Wait error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - // receive the result message - context->_receiveBuffer.resize(context->_receiveLength); - int rank = task.rank(); - int thread = task.thread(); - if (MPI_Irecv(&(context->_receiveBuffer[0]), context->_receiveLength, MPI_BYTE, rank, JOB_RESULT_BUFFER_TAG + thread, MPI_COMM_WORLD, &context->_receiveBufferRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Recv error"); - } - } - } else if (context->_receiveBufferRequest != MPI_REQUEST_NULL) { - if (MPI_Test(&context->_receiveBufferRequest, &flag, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Test error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - if (flag) { - // store the result in the job - task.resultMessage(context->_receiveBuffer); - - completedTasks.add(task.obj()); - - // destroy context - _taskContexts.erase(taskId); - } - } else { - throw std::runtime_error("Unexpected state"); - } - } -} - -void CommunicationManager::broadcastCommonFile(const itesla::jni::ByteArray& file) { - checkThread(); - - ensureStep(Step::COMMON_FILES_BCAST); - - int length = file.length(); - const char* buffer = file.get(); - - // broadcast the common file message to all slaves - if (MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Bcast error"); - } - if (MPI_Bcast((void*) buffer, length, MPI_BYTE, 0, MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Bcast error"); - } - - // to wait for the slave to write file on local directory - if (MPI_Barrier(MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Barrier error"); - } -} - -} - -} - -#ifdef __cplusplus -extern "C" { -#endif - -std::shared_ptr MANAGER; - -/* - * Class: eu_itesla_project_computation_mpi_JniMpiNativeServices - * Method: initMpi - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_eu_itesla_1project_computation_mpi_JniMpiNativeServices_initMpi(JNIEnv * env, jobject, jint coresPerRank, jboolean verbose) { - try { - LOGGER.setPriority(verbose ? log4cpp::Priority::DEBUG : log4cpp::Priority::ERROR); - LOGGER.addAppender(itesla::io::createConsoleLogAppender()); - - MANAGER.reset(new itesla::master::CommunicationManager(coresPerRank)); - MANAGER->init(); - if (MANAGER->commRank() != 0) { - throw std::runtime_error("CommunicationManager (data manager) must have MPI rank 0"); - } - - itesla::jni::JavaUtilList::init(env); - itesla::jni::EuIteslaProjectComputationMpiMpiTask::init(env); - } catch (const std::exception& e) { - LOGGER.fatalStream() << e.what() << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, e.what()); - } catch (...) { - LOGGER.fatalStream() << "Unknown exception" << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, "Unknown exception"); - } -} - -/* - * Class: eu_itesla_project_computation_mpi_JniMpiNativeServices - * Method: terminateMpi - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_eu_itesla_1project_computation_mpi_JniMpiNativeServices_terminateMpi(JNIEnv * env, jobject) { - try { - MANAGER->shutdown(); - MANAGER.reset(); - } catch (const std::exception& e) { - LOGGER.fatalStream() << e.what() << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, e.what()); - } catch (...) { - LOGGER.fatalStream() << "Unknown exception" << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, "Unknown exception"); - } -} - -/* - * Class: eu_itesla_project_computation_mpi_JniMpiNativeServices - * Method: getMpiVersion - * Signature: ()Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_eu_itesla_1project_computation_mpi_JniMpiNativeServices_getMpiVersion(JNIEnv * env, jobject) { - try { - std::string version = MANAGER->mpiVersion(); - return env->NewStringUTF(version.c_str()); - } catch (const std::exception& e) { - LOGGER.fatalStream() << e.what() << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, e.what()); - } catch (...) { - LOGGER.fatalStream() << "Unknown exception" << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, "Unknown exception"); - } - return NULL; -} - -/* - * Class: eu_itesla_project_computation_mpi_JniMpiNativeServices - * Method: getMpiCommSize - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_eu_itesla_1project_computation_mpi_JniMpiNativeServices_getMpiCommSize(JNIEnv * env, jobject) { - try { - return MANAGER->commSize(); - } catch (const std::exception& e) { - LOGGER.fatalStream() << e.what() << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, e.what()); - } catch (...) { - LOGGER.fatalStream() << "Unknown exception" << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, "Unknown exception"); - } - return -1; -} - -/* - * Class: eu_itesla_project_computation_mpi_JniMpiNativeServices - * Method: startTasks - * Signature: (Ljava/util/List;)V - */ -JNIEXPORT void JNICALL Java_eu_itesla_1project_computation_mpi_JniMpiNativeServices_startTasks(JNIEnv * env, jobject, jobject jtask) { - try { - itesla::jni::JavaUtilList tasks(env, jtask); - - // send job messages - MANAGER->startTasks(tasks); - - } catch (const std::exception& e) { - LOGGER.fatalStream() << e.what() << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, e.what()); - } catch (...) { - LOGGER.fatalStream() << "Unknown exception" << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, "Unknown exception"); - } -} - -/* - * Class: eu_itesla_project_computation_mpi_JniMpiNativeServices - * Method: checkTasksCompletion - * Signature: (Ljava/util/List;Ljava/util/List;)V - */ -JNIEXPORT void JNICALL Java_eu_itesla_1project_computation_mpi_JniMpiNativeServices_checkTasksCompletion(JNIEnv * env, jobject, jobject jrunningtasks, jobject jcompletedtasks) { - try { - itesla::jni::JavaUtilList runningTasks(env, jrunningtasks); - itesla::jni::JavaUtilList completedTasks(env, jcompletedtasks); - - // check tasks completion - MANAGER->checkTasksCompletion(runningTasks, completedTasks); - - } catch (const std::exception& e) { - LOGGER.fatalStream() << e.what() << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, e.what()); - } catch (...) { - LOGGER.fatalStream() << "Unknown exception" << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, "Unknown exception"); - } -} - -/* - * Class: eu_itesla_project_computation_mpi_JniMpiNativeServices - * Method: sendCommonFile - * Signature: ([B)V - */ -JNIEXPORT void JNICALL Java_eu_itesla_1project_computation_mpi_JniMpiNativeServices_sendCommonFile(JNIEnv * env, jobject, jbyteArray jfile) { - try { - itesla::jni::ByteArray file(env, jfile); - - // broadcast the common file message to all slaves - MANAGER->broadcastCommonFile(file); - - } catch (const std::exception& e) { - LOGGER.fatalStream() << e.what() << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, e.what()); - } catch (...) { - LOGGER.fatalStream() << "Unknown exception" << log4cpp::eol; - itesla::jni::throwJavaLangRuntimeException(env, "Unknown exception"); - } -} - -#ifdef __cplusplus -} -#endif diff --git a/mpi-communication/src/messages.pb.cc b/mpi-communication/src/messages.pb.cc deleted file mode 100644 index f04ae953..00000000 --- a/mpi-communication/src/messages.pb.cc +++ /dev/null @@ -1,3433 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: messages.proto - -#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION -#include "messages.pb.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace messages { - -namespace { - -const ::google::protobuf::Descriptor* CommonFile_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - CommonFile_reflection_ = NULL; -const ::google::protobuf::Descriptor* Task_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Task_reflection_ = NULL; -const ::google::protobuf::Descriptor* Task_InputFile_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Task_InputFile_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* Task_InputFile_PreProcessor_descriptor_ = NULL; -const ::google::protobuf::EnumDescriptor* Task_InputFile_Scope_descriptor_ = NULL; -const ::google::protobuf::Descriptor* Task_OutputFile_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Task_OutputFile_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* Task_OutputFile_PostProcessor_descriptor_ = NULL; -const ::google::protobuf::Descriptor* Task_Variable_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Task_Variable_reflection_ = NULL; -const ::google::protobuf::Descriptor* Task_Environment_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Task_Environment_reflection_ = NULL; -const ::google::protobuf::Descriptor* Task_Command_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - Task_Command_reflection_ = NULL; -const ::google::protobuf::Descriptor* TaskResult_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - TaskResult_reflection_ = NULL; -const ::google::protobuf::Descriptor* TaskResult_OutputFile_descriptor_ = NULL; -const ::google::protobuf::internal::GeneratedMessageReflection* - TaskResult_OutputFile_reflection_ = NULL; - -} // namespace - - -void protobuf_AssignDesc_messages_2eproto() { - protobuf_AddDesc_messages_2eproto(); - const ::google::protobuf::FileDescriptor* file = - ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( - "messages.proto"); - GOOGLE_CHECK(file != NULL); - CommonFile_descriptor_ = file->message_type(0); - static const int CommonFile_offsets_[4] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CommonFile, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CommonFile, chunk_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CommonFile, last_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CommonFile, data_), - }; - CommonFile_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - CommonFile_descriptor_, - CommonFile::default_instance_, - CommonFile_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CommonFile, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CommonFile, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(CommonFile)); - Task_descriptor_ = file->message_type(1); - static const int Task_offsets_[9] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, jobid_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, index_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, env_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, cmdid_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, command_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, inputfile_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, outputfile_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, initjob_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, completedjobid_), - }; - Task_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Task_descriptor_, - Task::default_instance_, - Task_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Task)); - Task_InputFile_descriptor_ = Task_descriptor_->nested_type(0); - static const int Task_InputFile_offsets_[4] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_InputFile, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_InputFile, scope_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_InputFile, data_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_InputFile, preprocessor_), - }; - Task_InputFile_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Task_InputFile_descriptor_, - Task_InputFile::default_instance_, - Task_InputFile_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_InputFile, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_InputFile, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Task_InputFile)); - Task_InputFile_PreProcessor_descriptor_ = Task_InputFile_descriptor_->enum_type(0); - Task_InputFile_Scope_descriptor_ = Task_InputFile_descriptor_->enum_type(1); - Task_OutputFile_descriptor_ = Task_descriptor_->nested_type(1); - static const int Task_OutputFile_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_OutputFile, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_OutputFile, postprocessor_), - }; - Task_OutputFile_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Task_OutputFile_descriptor_, - Task_OutputFile::default_instance_, - Task_OutputFile_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_OutputFile, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_OutputFile, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Task_OutputFile)); - Task_OutputFile_PostProcessor_descriptor_ = Task_OutputFile_descriptor_->enum_type(0); - Task_Variable_descriptor_ = Task_descriptor_->nested_type(2); - static const int Task_Variable_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Variable, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Variable, value_), - }; - Task_Variable_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Task_Variable_descriptor_, - Task_Variable::default_instance_, - Task_Variable_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Variable, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Variable, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Task_Variable)); - Task_Environment_descriptor_ = Task_descriptor_->nested_type(3); - static const int Task_Environment_offsets_[1] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Environment, variable_), - }; - Task_Environment_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Task_Environment_descriptor_, - Task_Environment::default_instance_, - Task_Environment_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Environment, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Environment, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Task_Environment)); - Task_Command_descriptor_ = Task_descriptor_->nested_type(4); - static const int Task_Command_offsets_[3] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Command, program_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Command, argument_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Command, timeout_), - }; - Task_Command_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - Task_Command_descriptor_, - Task_Command::default_instance_, - Task_Command_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Command, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Task_Command, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(Task_Command)); - TaskResult_descriptor_ = file->message_type(2); - static const int TaskResult_offsets_[5] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult, exitcode_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult, taskduration_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult, commandduration_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult, workingdatasize_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult, outputfile_), - }; - TaskResult_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - TaskResult_descriptor_, - TaskResult::default_instance_, - TaskResult_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(TaskResult)); - TaskResult_OutputFile_descriptor_ = TaskResult_descriptor_->nested_type(0); - static const int TaskResult_OutputFile_offsets_[2] = { - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult_OutputFile, name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult_OutputFile, data_), - }; - TaskResult_OutputFile_reflection_ = - new ::google::protobuf::internal::GeneratedMessageReflection( - TaskResult_OutputFile_descriptor_, - TaskResult_OutputFile::default_instance_, - TaskResult_OutputFile_offsets_, - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult_OutputFile, _has_bits_[0]), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TaskResult_OutputFile, _unknown_fields_), - -1, - ::google::protobuf::DescriptorPool::generated_pool(), - ::google::protobuf::MessageFactory::generated_factory(), - sizeof(TaskResult_OutputFile)); -} - -namespace { - -GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); -inline void protobuf_AssignDescriptorsOnce() { - ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, - &protobuf_AssignDesc_messages_2eproto); -} - -void protobuf_RegisterTypes(const ::std::string&) { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - CommonFile_descriptor_, &CommonFile::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Task_descriptor_, &Task::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Task_InputFile_descriptor_, &Task_InputFile::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Task_OutputFile_descriptor_, &Task_OutputFile::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Task_Variable_descriptor_, &Task_Variable::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Task_Environment_descriptor_, &Task_Environment::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - Task_Command_descriptor_, &Task_Command::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - TaskResult_descriptor_, &TaskResult::default_instance()); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( - TaskResult_OutputFile_descriptor_, &TaskResult_OutputFile::default_instance()); -} - -} // namespace - -void protobuf_ShutdownFile_messages_2eproto() { - delete CommonFile::default_instance_; - delete CommonFile_reflection_; - delete Task::default_instance_; - delete Task_reflection_; - delete Task_InputFile::default_instance_; - delete Task_InputFile_reflection_; - delete Task_OutputFile::default_instance_; - delete Task_OutputFile_reflection_; - delete Task_Variable::default_instance_; - delete Task_Variable_reflection_; - delete Task_Environment::default_instance_; - delete Task_Environment_reflection_; - delete Task_Command::default_instance_; - delete Task_Command_reflection_; - delete TaskResult::default_instance_; - delete TaskResult_reflection_; - delete TaskResult_OutputFile::default_instance_; - delete TaskResult_OutputFile_reflection_; -} - -void protobuf_AddDesc_messages_2eproto() { - static bool already_here = false; - if (already_here) return; - already_here = true; - GOOGLE_PROTOBUF_VERIFY_VERSION; - - ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\016messages.proto\022\010messages\"E\n\nCommonFile" - "\022\014\n\004name\030\001 \002(\t\022\r\n\005chunk\030\002 \002(\005\022\014\n\004last\030\003 " - "\002(\010\022\014\n\004data\030\004 \002(\014\"\254\006\n\004Task\022\r\n\005jobId\030\001 \002(" - "\005\022\r\n\005index\030\002 \002(\005\022\'\n\003env\030\003 \002(\0132\032.messages" - ".Task.Environment\022\r\n\005cmdId\030\004 \002(\t\022\'\n\007comm" - "and\030\005 \003(\0132\026.messages.Task.Command\022+\n\tinp" - "utFile\030\006 \003(\0132\030.messages.Task.InputFile\022-" - "\n\noutputFile\030\007 \003(\0132\031.messages.Task.Outpu" - "tFile\022\017\n\007initJob\030\010 \002(\010\022\026\n\016completedJobId" - "\030\t \003(\005\032\366\001\n\tInputFile\022\014\n\004name\030\001 \002(\t\022-\n\005sc" - "ope\030\002 \002(\0162\036.messages.Task.InputFile.Scop" - "e\022\014\n\004data\030\003 \001(\014\022;\n\014preProcessor\030\004 \002(\0162%." - "messages.Task.InputFile.PreProcessor\"<\n\014" - "PreProcessor\022\010\n\004NONE\020\001\022\021\n\rARCHIVE_UNZIP\020" - "\002\022\017\n\013FILE_GUNZIP\020\003\"#\n\005Scope\022\007\n\003RUN\020\001\022\007\n\003" - "JOB\020\002\022\010\n\004TASK\020\003\032\204\001\n\nOutputFile\022\014\n\004name\030\001" - " \002(\t\022>\n\rpostProcessor\030\002 \002(\0162\'.messages.T" - "ask.OutputFile.PostProcessor\"(\n\rPostProc" - "essor\022\010\n\004NONE\020\001\022\r\n\tFILE_GZIP\020\002\032\'\n\010Variab" - "le\022\014\n\004name\030\001 \002(\t\022\r\n\005value\030\002 \002(\t\0328\n\013Envir" - "onment\022)\n\010variable\030\001 \003(\0132\027.messages.Task" - ".Variable\032=\n\007Command\022\017\n\007program\030\001 \002(\t\022\020\n" - "\010argument\030\002 \003(\t\022\017\n\007timeout\030\003 \001(\005\"\305\001\n\nTas" - "kResult\022\020\n\010exitCode\030\001 \002(\005\022\024\n\014taskDuratio" - "n\030\002 \002(\003\022\027\n\017commandDuration\030\003 \003(\003\022\027\n\017work" - "ingDataSize\030\004 \002(\003\0223\n\noutputFile\030\005 \003(\0132\037." - "messages.TaskResult.OutputFile\032(\n\nOutput" - "File\022\014\n\004name\030\001 \002(\t\022\014\n\004data\030\002 \001(\014B6\n*eu.i" - "tesla_project.computation.mpi.messagesB\010" - "Messages", 1168); - ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( - "messages.proto", &protobuf_RegisterTypes); - CommonFile::default_instance_ = new CommonFile(); - Task::default_instance_ = new Task(); - Task_InputFile::default_instance_ = new Task_InputFile(); - Task_OutputFile::default_instance_ = new Task_OutputFile(); - Task_Variable::default_instance_ = new Task_Variable(); - Task_Environment::default_instance_ = new Task_Environment(); - Task_Command::default_instance_ = new Task_Command(); - TaskResult::default_instance_ = new TaskResult(); - TaskResult_OutputFile::default_instance_ = new TaskResult_OutputFile(); - CommonFile::default_instance_->InitAsDefaultInstance(); - Task::default_instance_->InitAsDefaultInstance(); - Task_InputFile::default_instance_->InitAsDefaultInstance(); - Task_OutputFile::default_instance_->InitAsDefaultInstance(); - Task_Variable::default_instance_->InitAsDefaultInstance(); - Task_Environment::default_instance_->InitAsDefaultInstance(); - Task_Command::default_instance_->InitAsDefaultInstance(); - TaskResult::default_instance_->InitAsDefaultInstance(); - TaskResult_OutputFile::default_instance_->InitAsDefaultInstance(); - ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_messages_2eproto); -} - -// Force AddDescriptors() to be called at static initialization time. -struct StaticDescriptorInitializer_messages_2eproto { - StaticDescriptorInitializer_messages_2eproto() { - protobuf_AddDesc_messages_2eproto(); - } -} static_descriptor_initializer_messages_2eproto_; - -// =================================================================== - -#ifndef _MSC_VER -const int CommonFile::kNameFieldNumber; -const int CommonFile::kChunkFieldNumber; -const int CommonFile::kLastFieldNumber; -const int CommonFile::kDataFieldNumber; -#endif // !_MSC_VER - -CommonFile::CommonFile() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void CommonFile::InitAsDefaultInstance() { -} - -CommonFile::CommonFile(const CommonFile& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void CommonFile::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - chunk_ = 0; - last_ = false; - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -CommonFile::~CommonFile() { - SharedDtor(); -} - -void CommonFile::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (this != default_instance_) { - } -} - -void CommonFile::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* CommonFile::descriptor() { - protobuf_AssignDescriptorsOnce(); - return CommonFile_descriptor_; -} - -const CommonFile& CommonFile::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -CommonFile* CommonFile::default_instance_ = NULL; - -CommonFile* CommonFile::New() const { - return new CommonFile; -} - -void CommonFile::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - chunk_ = 0; - last_ = false; - if (has_data()) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } - } - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool CommonFile::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_chunk; - break; - } - - // required int32 chunk = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_chunk: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &chunk_))); - set_has_chunk(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(24)) goto parse_last; - break; - } - - // required bool last = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_last: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &last_))); - set_has_last(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_data; - break; - } - - // required bytes data = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_data: - DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( - input, this->mutable_data())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void CommonFile::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // required int32 chunk = 2; - if (has_chunk()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->chunk(), output); - } - - // required bool last = 3; - if (has_last()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->last(), output); - } - - // required bytes data = 4; - if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteBytes( - 4, this->data(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* CommonFile::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // required int32 chunk = 2; - if (has_chunk()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->chunk(), target); - } - - // required bool last = 3; - if (has_last()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->last(), target); - } - - // required bytes data = 4; - if (has_data()) { - target = - ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( - 4, this->data(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int CommonFile::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // required int32 chunk = 2; - if (has_chunk()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->chunk()); - } - - // required bool last = 3; - if (has_last()) { - total_size += 1 + 1; - } - - // required bytes data = 4; - if (has_data()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::BytesSize( - this->data()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void CommonFile::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const CommonFile* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void CommonFile::MergeFrom(const CommonFile& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_chunk()) { - set_chunk(from.chunk()); - } - if (from.has_last()) { - set_last(from.last()); - } - if (from.has_data()) { - set_data(from.data()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void CommonFile::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void CommonFile::CopyFrom(const CommonFile& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool CommonFile::IsInitialized() const { - if ((_has_bits_[0] & 0x0000000f) != 0x0000000f) return false; - - return true; -} - -void CommonFile::Swap(CommonFile* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(chunk_, other->chunk_); - std::swap(last_, other->last_); - std::swap(data_, other->data_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata CommonFile::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = CommonFile_descriptor_; - metadata.reflection = CommonFile_reflection_; - return metadata; -} - - -// =================================================================== - -const ::google::protobuf::EnumDescriptor* Task_InputFile_PreProcessor_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_InputFile_PreProcessor_descriptor_; -} -bool Task_InputFile_PreProcessor_IsValid(int value) { - switch(value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const Task_InputFile_PreProcessor Task_InputFile::NONE; -const Task_InputFile_PreProcessor Task_InputFile::ARCHIVE_UNZIP; -const Task_InputFile_PreProcessor Task_InputFile::FILE_GUNZIP; -const Task_InputFile_PreProcessor Task_InputFile::PreProcessor_MIN; -const Task_InputFile_PreProcessor Task_InputFile::PreProcessor_MAX; -const int Task_InputFile::PreProcessor_ARRAYSIZE; -#endif // _MSC_VER -const ::google::protobuf::EnumDescriptor* Task_InputFile_Scope_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_InputFile_Scope_descriptor_; -} -bool Task_InputFile_Scope_IsValid(int value) { - switch(value) { - case 1: - case 2: - case 3: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const Task_InputFile_Scope Task_InputFile::RUN; -const Task_InputFile_Scope Task_InputFile::JOB; -const Task_InputFile_Scope Task_InputFile::TASK; -const Task_InputFile_Scope Task_InputFile::Scope_MIN; -const Task_InputFile_Scope Task_InputFile::Scope_MAX; -const int Task_InputFile::Scope_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int Task_InputFile::kNameFieldNumber; -const int Task_InputFile::kScopeFieldNumber; -const int Task_InputFile::kDataFieldNumber; -const int Task_InputFile::kPreProcessorFieldNumber; -#endif // !_MSC_VER - -Task_InputFile::Task_InputFile() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Task_InputFile::InitAsDefaultInstance() { -} - -Task_InputFile::Task_InputFile(const Task_InputFile& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Task_InputFile::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - scope_ = 1; - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - preprocessor_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Task_InputFile::~Task_InputFile() { - SharedDtor(); -} - -void Task_InputFile::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (this != default_instance_) { - } -} - -void Task_InputFile::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Task_InputFile::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_InputFile_descriptor_; -} - -const Task_InputFile& Task_InputFile::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -Task_InputFile* Task_InputFile::default_instance_ = NULL; - -Task_InputFile* Task_InputFile::New() const { - return new Task_InputFile; -} - -void Task_InputFile::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - scope_ = 1; - if (has_data()) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } - } - preprocessor_ = 1; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Task_InputFile::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_scope; - break; - } - - // required .messages.Task.InputFile.Scope scope = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_scope: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::messages::Task_InputFile_Scope_IsValid(value)) { - set_scope(static_cast< ::messages::Task_InputFile_Scope >(value)); - } else { - mutable_unknown_fields()->AddVarint(2, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_data; - break; - } - - // optional bytes data = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_data: - DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( - input, this->mutable_data())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(32)) goto parse_preProcessor; - break; - } - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_preProcessor: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::messages::Task_InputFile_PreProcessor_IsValid(value)) { - set_preprocessor(static_cast< ::messages::Task_InputFile_PreProcessor >(value)); - } else { - mutable_unknown_fields()->AddVarint(4, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Task_InputFile::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // required .messages.Task.InputFile.Scope scope = 2; - if (has_scope()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 2, this->scope(), output); - } - - // optional bytes data = 3; - if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteBytes( - 3, this->data(), output); - } - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - if (has_preprocessor()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 4, this->preprocessor(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Task_InputFile::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // required .messages.Task.InputFile.Scope scope = 2; - if (has_scope()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 2, this->scope(), target); - } - - // optional bytes data = 3; - if (has_data()) { - target = - ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( - 3, this->data(), target); - } - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - if (has_preprocessor()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 4, this->preprocessor(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Task_InputFile::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // required .messages.Task.InputFile.Scope scope = 2; - if (has_scope()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->scope()); - } - - // optional bytes data = 3; - if (has_data()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::BytesSize( - this->data()); - } - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - if (has_preprocessor()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->preprocessor()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Task_InputFile::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Task_InputFile* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Task_InputFile::MergeFrom(const Task_InputFile& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_scope()) { - set_scope(from.scope()); - } - if (from.has_data()) { - set_data(from.data()); - } - if (from.has_preprocessor()) { - set_preprocessor(from.preprocessor()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Task_InputFile::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Task_InputFile::CopyFrom(const Task_InputFile& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Task_InputFile::IsInitialized() const { - if ((_has_bits_[0] & 0x0000000b) != 0x0000000b) return false; - - return true; -} - -void Task_InputFile::Swap(Task_InputFile* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(scope_, other->scope_); - std::swap(data_, other->data_); - std::swap(preprocessor_, other->preprocessor_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Task_InputFile::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Task_InputFile_descriptor_; - metadata.reflection = Task_InputFile_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -const ::google::protobuf::EnumDescriptor* Task_OutputFile_PostProcessor_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_OutputFile_PostProcessor_descriptor_; -} -bool Task_OutputFile_PostProcessor_IsValid(int value) { - switch(value) { - case 1: - case 2: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const Task_OutputFile_PostProcessor Task_OutputFile::NONE; -const Task_OutputFile_PostProcessor Task_OutputFile::FILE_GZIP; -const Task_OutputFile_PostProcessor Task_OutputFile::PostProcessor_MIN; -const Task_OutputFile_PostProcessor Task_OutputFile::PostProcessor_MAX; -const int Task_OutputFile::PostProcessor_ARRAYSIZE; -#endif // _MSC_VER -#ifndef _MSC_VER -const int Task_OutputFile::kNameFieldNumber; -const int Task_OutputFile::kPostProcessorFieldNumber; -#endif // !_MSC_VER - -Task_OutputFile::Task_OutputFile() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Task_OutputFile::InitAsDefaultInstance() { -} - -Task_OutputFile::Task_OutputFile(const Task_OutputFile& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Task_OutputFile::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - postprocessor_ = 1; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Task_OutputFile::~Task_OutputFile() { - SharedDtor(); -} - -void Task_OutputFile::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (this != default_instance_) { - } -} - -void Task_OutputFile::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Task_OutputFile::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_OutputFile_descriptor_; -} - -const Task_OutputFile& Task_OutputFile::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -Task_OutputFile* Task_OutputFile::default_instance_ = NULL; - -Task_OutputFile* Task_OutputFile::New() const { - return new Task_OutputFile; -} - -void Task_OutputFile::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - postprocessor_ = 1; - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Task_OutputFile::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_postProcessor; - break; - } - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_postProcessor: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::messages::Task_OutputFile_PostProcessor_IsValid(value)) { - set_postprocessor(static_cast< ::messages::Task_OutputFile_PostProcessor >(value)); - } else { - mutable_unknown_fields()->AddVarint(2, value); - } - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Task_OutputFile::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - if (has_postprocessor()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( - 2, this->postprocessor(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Task_OutputFile::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - if (has_postprocessor()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 2, this->postprocessor(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Task_OutputFile::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - if (has_postprocessor()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->postprocessor()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Task_OutputFile::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Task_OutputFile* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Task_OutputFile::MergeFrom(const Task_OutputFile& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_postprocessor()) { - set_postprocessor(from.postprocessor()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Task_OutputFile::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Task_OutputFile::CopyFrom(const Task_OutputFile& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Task_OutputFile::IsInitialized() const { - if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; - - return true; -} - -void Task_OutputFile::Swap(Task_OutputFile* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(postprocessor_, other->postprocessor_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Task_OutputFile::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Task_OutputFile_descriptor_; - metadata.reflection = Task_OutputFile_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int Task_Variable::kNameFieldNumber; -const int Task_Variable::kValueFieldNumber; -#endif // !_MSC_VER - -Task_Variable::Task_Variable() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Task_Variable::InitAsDefaultInstance() { -} - -Task_Variable::Task_Variable(const Task_Variable& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Task_Variable::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Task_Variable::~Task_Variable() { - SharedDtor(); -} - -void Task_Variable::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (value_ != &::google::protobuf::internal::kEmptyString) { - delete value_; - } - if (this != default_instance_) { - } -} - -void Task_Variable::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Task_Variable::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_Variable_descriptor_; -} - -const Task_Variable& Task_Variable::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -Task_Variable* Task_Variable::default_instance_ = NULL; - -Task_Variable* Task_Variable::New() const { - return new Task_Variable; -} - -void Task_Variable::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_value()) { - if (value_ != &::google::protobuf::internal::kEmptyString) { - value_->clear(); - } - } - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Task_Variable::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_value; - break; - } - - // required string value = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_value: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_value())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->value().data(), this->value().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Task_Variable::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // required string value = 2; - if (has_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->value().data(), this->value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->value(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Task_Variable::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // required string value = 2; - if (has_value()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->value().data(), this->value().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 2, this->value(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Task_Variable::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // required string value = 2; - if (has_value()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->value()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Task_Variable::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Task_Variable* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Task_Variable::MergeFrom(const Task_Variable& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_value()) { - set_value(from.value()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Task_Variable::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Task_Variable::CopyFrom(const Task_Variable& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Task_Variable::IsInitialized() const { - if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false; - - return true; -} - -void Task_Variable::Swap(Task_Variable* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(value_, other->value_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Task_Variable::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Task_Variable_descriptor_; - metadata.reflection = Task_Variable_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int Task_Environment::kVariableFieldNumber; -#endif // !_MSC_VER - -Task_Environment::Task_Environment() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Task_Environment::InitAsDefaultInstance() { -} - -Task_Environment::Task_Environment(const Task_Environment& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Task_Environment::SharedCtor() { - _cached_size_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Task_Environment::~Task_Environment() { - SharedDtor(); -} - -void Task_Environment::SharedDtor() { - if (this != default_instance_) { - } -} - -void Task_Environment::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Task_Environment::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_Environment_descriptor_; -} - -const Task_Environment& Task_Environment::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -Task_Environment* Task_Environment::default_instance_ = NULL; - -Task_Environment* Task_Environment::New() const { - return new Task_Environment; -} - -void Task_Environment::Clear() { - variable_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Task_Environment::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // repeated .messages.Task.Variable variable = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_variable: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_variable())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(10)) goto parse_variable; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Task_Environment::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // repeated .messages.Task.Variable variable = 1; - for (int i = 0; i < this->variable_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 1, this->variable(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Task_Environment::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // repeated .messages.Task.Variable variable = 1; - for (int i = 0; i < this->variable_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 1, this->variable(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Task_Environment::ByteSize() const { - int total_size = 0; - - // repeated .messages.Task.Variable variable = 1; - total_size += 1 * this->variable_size(); - for (int i = 0; i < this->variable_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->variable(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Task_Environment::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Task_Environment* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Task_Environment::MergeFrom(const Task_Environment& from) { - GOOGLE_CHECK_NE(&from, this); - variable_.MergeFrom(from.variable_); - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Task_Environment::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Task_Environment::CopyFrom(const Task_Environment& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Task_Environment::IsInitialized() const { - - for (int i = 0; i < variable_size(); i++) { - if (!this->variable(i).IsInitialized()) return false; - } - return true; -} - -void Task_Environment::Swap(Task_Environment* other) { - if (other != this) { - variable_.Swap(&other->variable_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Task_Environment::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Task_Environment_descriptor_; - metadata.reflection = Task_Environment_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int Task_Command::kProgramFieldNumber; -const int Task_Command::kArgumentFieldNumber; -const int Task_Command::kTimeoutFieldNumber; -#endif // !_MSC_VER - -Task_Command::Task_Command() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Task_Command::InitAsDefaultInstance() { -} - -Task_Command::Task_Command(const Task_Command& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Task_Command::SharedCtor() { - _cached_size_ = 0; - program_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - timeout_ = 0; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Task_Command::~Task_Command() { - SharedDtor(); -} - -void Task_Command::SharedDtor() { - if (program_ != &::google::protobuf::internal::kEmptyString) { - delete program_; - } - if (this != default_instance_) { - } -} - -void Task_Command::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Task_Command::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_Command_descriptor_; -} - -const Task_Command& Task_Command::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -Task_Command* Task_Command::default_instance_ = NULL; - -Task_Command* Task_Command::New() const { - return new Task_Command; -} - -void Task_Command::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_program()) { - if (program_ != &::google::protobuf::internal::kEmptyString) { - program_->clear(); - } - } - timeout_ = 0; - } - argument_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Task_Command::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required string program = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_program())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->program().data(), this->program().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_argument; - break; - } - - // repeated string argument = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_argument: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->add_argument())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->argument(this->argument_size() - 1).data(), - this->argument(this->argument_size() - 1).length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_argument; - if (input->ExpectTag(24)) goto parse_timeout; - break; - } - - // optional int32 timeout = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_timeout: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &timeout_))); - set_has_timeout(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Task_Command::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required string program = 1; - if (has_program()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->program().data(), this->program().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->program(), output); - } - - // repeated string argument = 2; - for (int i = 0; i < this->argument_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->argument(i).data(), this->argument(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 2, this->argument(i), output); - } - - // optional int32 timeout = 3; - if (has_timeout()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->timeout(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Task_Command::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required string program = 1; - if (has_program()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->program().data(), this->program().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->program(), target); - } - - // repeated string argument = 2; - for (int i = 0; i < this->argument_size(); i++) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->argument(i).data(), this->argument(i).length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = ::google::protobuf::internal::WireFormatLite:: - WriteStringToArray(2, this->argument(i), target); - } - - // optional int32 timeout = 3; - if (has_timeout()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->timeout(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Task_Command::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required string program = 1; - if (has_program()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->program()); - } - - // optional int32 timeout = 3; - if (has_timeout()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->timeout()); - } - - } - // repeated string argument = 2; - total_size += 1 * this->argument_size(); - for (int i = 0; i < this->argument_size(); i++) { - total_size += ::google::protobuf::internal::WireFormatLite::StringSize( - this->argument(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Task_Command::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Task_Command* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Task_Command::MergeFrom(const Task_Command& from) { - GOOGLE_CHECK_NE(&from, this); - argument_.MergeFrom(from.argument_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_program()) { - set_program(from.program()); - } - if (from.has_timeout()) { - set_timeout(from.timeout()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Task_Command::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Task_Command::CopyFrom(const Task_Command& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Task_Command::IsInitialized() const { - if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; - - return true; -} - -void Task_Command::Swap(Task_Command* other) { - if (other != this) { - std::swap(program_, other->program_); - argument_.Swap(&other->argument_); - std::swap(timeout_, other->timeout_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Task_Command::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Task_Command_descriptor_; - metadata.reflection = Task_Command_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int Task::kJobIdFieldNumber; -const int Task::kIndexFieldNumber; -const int Task::kEnvFieldNumber; -const int Task::kCmdIdFieldNumber; -const int Task::kCommandFieldNumber; -const int Task::kInputFileFieldNumber; -const int Task::kOutputFileFieldNumber; -const int Task::kInitJobFieldNumber; -const int Task::kCompletedJobIdFieldNumber; -#endif // !_MSC_VER - -Task::Task() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void Task::InitAsDefaultInstance() { - env_ = const_cast< ::messages::Task_Environment*>(&::messages::Task_Environment::default_instance()); -} - -Task::Task(const Task& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void Task::SharedCtor() { - _cached_size_ = 0; - jobid_ = 0; - index_ = 0; - env_ = NULL; - cmdid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - initjob_ = false; - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -Task::~Task() { - SharedDtor(); -} - -void Task::SharedDtor() { - if (cmdid_ != &::google::protobuf::internal::kEmptyString) { - delete cmdid_; - } - if (this != default_instance_) { - delete env_; - } -} - -void Task::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* Task::descriptor() { - protobuf_AssignDescriptorsOnce(); - return Task_descriptor_; -} - -const Task& Task::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -Task* Task::default_instance_ = NULL; - -Task* Task::New() const { - return new Task; -} - -void Task::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - jobid_ = 0; - index_ = 0; - if (has_env()) { - if (env_ != NULL) env_->::messages::Task_Environment::Clear(); - } - if (has_cmdid()) { - if (cmdid_ != &::google::protobuf::internal::kEmptyString) { - cmdid_->clear(); - } - } - initjob_ = false; - } - command_.Clear(); - inputfile_.Clear(); - outputfile_.Clear(); - completedjobid_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool Task::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required int32 jobId = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &jobid_))); - set_has_jobid(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_index; - break; - } - - // required int32 index = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_index: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &index_))); - set_has_index(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(26)) goto parse_env; - break; - } - - // required .messages.Task.Environment env = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_env: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, mutable_env())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(34)) goto parse_cmdId; - break; - } - - // required string cmdId = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_cmdId: - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_cmdid())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->cmdid().data(), this->cmdid().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(42)) goto parse_command; - break; - } - - // repeated .messages.Task.Command command = 5; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_command: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_command())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(42)) goto parse_command; - if (input->ExpectTag(50)) goto parse_inputFile; - break; - } - - // repeated .messages.Task.InputFile inputFile = 6; - case 6: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_inputFile: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_inputfile())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(50)) goto parse_inputFile; - if (input->ExpectTag(58)) goto parse_outputFile; - break; - } - - // repeated .messages.Task.OutputFile outputFile = 7; - case 7: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_outputFile: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_outputfile())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(58)) goto parse_outputFile; - if (input->ExpectTag(64)) goto parse_initJob; - break; - } - - // required bool initJob = 8; - case 8: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_initJob: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &initjob_))); - set_has_initjob(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(72)) goto parse_completedJobId; - break; - } - - // repeated int32 completedJobId = 9; - case 9: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_completedJobId: - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - 1, 72, input, this->mutable_completedjobid()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, this->mutable_completedjobid()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(72)) goto parse_completedJobId; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void Task::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required int32 jobId = 1; - if (has_jobid()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->jobid(), output); - } - - // required int32 index = 2; - if (has_index()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->index(), output); - } - - // required .messages.Task.Environment env = 3; - if (has_env()) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 3, this->env(), output); - } - - // required string cmdId = 4; - if (has_cmdid()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->cmdid().data(), this->cmdid().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 4, this->cmdid(), output); - } - - // repeated .messages.Task.Command command = 5; - for (int i = 0; i < this->command_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, this->command(i), output); - } - - // repeated .messages.Task.InputFile inputFile = 6; - for (int i = 0; i < this->inputfile_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 6, this->inputfile(i), output); - } - - // repeated .messages.Task.OutputFile outputFile = 7; - for (int i = 0; i < this->outputfile_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 7, this->outputfile(i), output); - } - - // required bool initJob = 8; - if (has_initjob()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->initjob(), output); - } - - // repeated int32 completedJobId = 9; - for (int i = 0; i < this->completedjobid_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteInt32( - 9, this->completedjobid(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* Task::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required int32 jobId = 1; - if (has_jobid()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->jobid(), target); - } - - // required int32 index = 2; - if (has_index()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->index(), target); - } - - // required .messages.Task.Environment env = 3; - if (has_env()) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 3, this->env(), target); - } - - // required string cmdId = 4; - if (has_cmdid()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->cmdid().data(), this->cmdid().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 4, this->cmdid(), target); - } - - // repeated .messages.Task.Command command = 5; - for (int i = 0; i < this->command_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 5, this->command(i), target); - } - - // repeated .messages.Task.InputFile inputFile = 6; - for (int i = 0; i < this->inputfile_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 6, this->inputfile(i), target); - } - - // repeated .messages.Task.OutputFile outputFile = 7; - for (int i = 0; i < this->outputfile_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 7, this->outputfile(i), target); - } - - // required bool initJob = 8; - if (has_initjob()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->initjob(), target); - } - - // repeated int32 completedJobId = 9; - for (int i = 0; i < this->completedjobid_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteInt32ToArray(9, this->completedjobid(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int Task::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required int32 jobId = 1; - if (has_jobid()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->jobid()); - } - - // required int32 index = 2; - if (has_index()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->index()); - } - - // required .messages.Task.Environment env = 3; - if (has_env()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->env()); - } - - // required string cmdId = 4; - if (has_cmdid()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->cmdid()); - } - - // required bool initJob = 8; - if (has_initjob()) { - total_size += 1 + 1; - } - - } - // repeated .messages.Task.Command command = 5; - total_size += 1 * this->command_size(); - for (int i = 0; i < this->command_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->command(i)); - } - - // repeated .messages.Task.InputFile inputFile = 6; - total_size += 1 * this->inputfile_size(); - for (int i = 0; i < this->inputfile_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->inputfile(i)); - } - - // repeated .messages.Task.OutputFile outputFile = 7; - total_size += 1 * this->outputfile_size(); - for (int i = 0; i < this->outputfile_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->outputfile(i)); - } - - // repeated int32 completedJobId = 9; - { - int data_size = 0; - for (int i = 0; i < this->completedjobid_size(); i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int32Size(this->completedjobid(i)); - } - total_size += 1 * this->completedjobid_size() + data_size; - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void Task::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const Task* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void Task::MergeFrom(const Task& from) { - GOOGLE_CHECK_NE(&from, this); - command_.MergeFrom(from.command_); - inputfile_.MergeFrom(from.inputfile_); - outputfile_.MergeFrom(from.outputfile_); - completedjobid_.MergeFrom(from.completedjobid_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_jobid()) { - set_jobid(from.jobid()); - } - if (from.has_index()) { - set_index(from.index()); - } - if (from.has_env()) { - mutable_env()->::messages::Task_Environment::MergeFrom(from.env()); - } - if (from.has_cmdid()) { - set_cmdid(from.cmdid()); - } - if (from.has_initjob()) { - set_initjob(from.initjob()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void Task::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void Task::CopyFrom(const Task& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool Task::IsInitialized() const { - if ((_has_bits_[0] & 0x0000008f) != 0x0000008f) return false; - - if (has_env()) { - if (!this->env().IsInitialized()) return false; - } - for (int i = 0; i < command_size(); i++) { - if (!this->command(i).IsInitialized()) return false; - } - for (int i = 0; i < inputfile_size(); i++) { - if (!this->inputfile(i).IsInitialized()) return false; - } - for (int i = 0; i < outputfile_size(); i++) { - if (!this->outputfile(i).IsInitialized()) return false; - } - return true; -} - -void Task::Swap(Task* other) { - if (other != this) { - std::swap(jobid_, other->jobid_); - std::swap(index_, other->index_); - std::swap(env_, other->env_); - std::swap(cmdid_, other->cmdid_); - command_.Swap(&other->command_); - inputfile_.Swap(&other->inputfile_); - outputfile_.Swap(&other->outputfile_); - std::swap(initjob_, other->initjob_); - completedjobid_.Swap(&other->completedjobid_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata Task::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = Task_descriptor_; - metadata.reflection = Task_reflection_; - return metadata; -} - - -// =================================================================== - -#ifndef _MSC_VER -const int TaskResult_OutputFile::kNameFieldNumber; -const int TaskResult_OutputFile::kDataFieldNumber; -#endif // !_MSC_VER - -TaskResult_OutputFile::TaskResult_OutputFile() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void TaskResult_OutputFile::InitAsDefaultInstance() { -} - -TaskResult_OutputFile::TaskResult_OutputFile(const TaskResult_OutputFile& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void TaskResult_OutputFile::SharedCtor() { - _cached_size_ = 0; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -TaskResult_OutputFile::~TaskResult_OutputFile() { - SharedDtor(); -} - -void TaskResult_OutputFile::SharedDtor() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (this != default_instance_) { - } -} - -void TaskResult_OutputFile::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* TaskResult_OutputFile::descriptor() { - protobuf_AssignDescriptorsOnce(); - return TaskResult_OutputFile_descriptor_; -} - -const TaskResult_OutputFile& TaskResult_OutputFile::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -TaskResult_OutputFile* TaskResult_OutputFile::default_instance_ = NULL; - -TaskResult_OutputFile* TaskResult_OutputFile::New() const { - return new TaskResult_OutputFile; -} - -void TaskResult_OutputFile::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (has_name()) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - } - if (has_data()) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } - } - } - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool TaskResult_OutputFile::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required string name = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - DO_(::google::protobuf::internal::WireFormatLite::ReadString( - input, this->mutable_name())); - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::PARSE); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(18)) goto parse_data; - break; - } - - // optional bytes data = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_data: - DO_(::google::protobuf::internal::WireFormatLite::ReadBytes( - input, this->mutable_data())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void TaskResult_OutputFile::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - ::google::protobuf::internal::WireFormatLite::WriteString( - 1, this->name(), output); - } - - // optional bytes data = 2; - if (has_data()) { - ::google::protobuf::internal::WireFormatLite::WriteBytes( - 2, this->data(), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* TaskResult_OutputFile::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required string name = 1; - if (has_name()) { - ::google::protobuf::internal::WireFormat::VerifyUTF8String( - this->name().data(), this->name().length(), - ::google::protobuf::internal::WireFormat::SERIALIZE); - target = - ::google::protobuf::internal::WireFormatLite::WriteStringToArray( - 1, this->name(), target); - } - - // optional bytes data = 2; - if (has_data()) { - target = - ::google::protobuf::internal::WireFormatLite::WriteBytesToArray( - 2, this->data(), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int TaskResult_OutputFile::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required string name = 1; - if (has_name()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::StringSize( - this->name()); - } - - // optional bytes data = 2; - if (has_data()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::BytesSize( - this->data()); - } - - } - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void TaskResult_OutputFile::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const TaskResult_OutputFile* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void TaskResult_OutputFile::MergeFrom(const TaskResult_OutputFile& from) { - GOOGLE_CHECK_NE(&from, this); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_name()) { - set_name(from.name()); - } - if (from.has_data()) { - set_data(from.data()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void TaskResult_OutputFile::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void TaskResult_OutputFile::CopyFrom(const TaskResult_OutputFile& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool TaskResult_OutputFile::IsInitialized() const { - if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; - - return true; -} - -void TaskResult_OutputFile::Swap(TaskResult_OutputFile* other) { - if (other != this) { - std::swap(name_, other->name_); - std::swap(data_, other->data_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata TaskResult_OutputFile::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = TaskResult_OutputFile_descriptor_; - metadata.reflection = TaskResult_OutputFile_reflection_; - return metadata; -} - - -// ------------------------------------------------------------------- - -#ifndef _MSC_VER -const int TaskResult::kExitCodeFieldNumber; -const int TaskResult::kTaskDurationFieldNumber; -const int TaskResult::kCommandDurationFieldNumber; -const int TaskResult::kWorkingDataSizeFieldNumber; -const int TaskResult::kOutputFileFieldNumber; -#endif // !_MSC_VER - -TaskResult::TaskResult() - : ::google::protobuf::Message() { - SharedCtor(); -} - -void TaskResult::InitAsDefaultInstance() { -} - -TaskResult::TaskResult(const TaskResult& from) - : ::google::protobuf::Message() { - SharedCtor(); - MergeFrom(from); -} - -void TaskResult::SharedCtor() { - _cached_size_ = 0; - exitcode_ = 0; - taskduration_ = GOOGLE_LONGLONG(0); - workingdatasize_ = GOOGLE_LONGLONG(0); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); -} - -TaskResult::~TaskResult() { - SharedDtor(); -} - -void TaskResult::SharedDtor() { - if (this != default_instance_) { - } -} - -void TaskResult::SetCachedSize(int size) const { - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); -} -const ::google::protobuf::Descriptor* TaskResult::descriptor() { - protobuf_AssignDescriptorsOnce(); - return TaskResult_descriptor_; -} - -const TaskResult& TaskResult::default_instance() { - if (default_instance_ == NULL) protobuf_AddDesc_messages_2eproto(); - return *default_instance_; -} - -TaskResult* TaskResult::default_instance_ = NULL; - -TaskResult* TaskResult::New() const { - return new TaskResult; -} - -void TaskResult::Clear() { - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - exitcode_ = 0; - taskduration_ = GOOGLE_LONGLONG(0); - workingdatasize_ = GOOGLE_LONGLONG(0); - } - commandduration_.Clear(); - outputfile_.Clear(); - ::memset(_has_bits_, 0, sizeof(_has_bits_)); - mutable_unknown_fields()->Clear(); -} - -bool TaskResult::MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input) { -#define DO_(EXPRESSION) if (!(EXPRESSION)) return false - ::google::protobuf::uint32 tag; - while ((tag = input->ReadTag()) != 0) { - switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { - // required int32 exitCode = 1; - case 1: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( - input, &exitcode_))); - set_has_exitcode(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(16)) goto parse_taskDuration; - break; - } - - // required int64 taskDuration = 2; - case 2: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_taskDuration: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( - input, &taskduration_))); - set_has_taskduration(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(24)) goto parse_commandDuration; - break; - } - - // repeated int64 commandDuration = 3; - case 3: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_commandDuration: - DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive< - ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( - 1, 24, input, this->mutable_commandduration()))); - } else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) - == ::google::protobuf::internal::WireFormatLite:: - WIRETYPE_LENGTH_DELIMITED) { - DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline< - ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( - input, this->mutable_commandduration()))); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(24)) goto parse_commandDuration; - if (input->ExpectTag(32)) goto parse_workingDataSize; - break; - } - - // required int64 workingDataSize = 4; - case 4: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_workingDataSize: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>( - input, &workingdatasize_))); - set_has_workingdatasize(); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(42)) goto parse_outputFile; - break; - } - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - case 5: { - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { - parse_outputFile: - DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual( - input, add_outputfile())); - } else { - goto handle_uninterpreted; - } - if (input->ExpectTag(42)) goto parse_outputFile; - if (input->ExpectAtEnd()) return true; - break; - } - - default: { - handle_uninterpreted: - if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { - return true; - } - DO_(::google::protobuf::internal::WireFormat::SkipField( - input, tag, mutable_unknown_fields())); - break; - } - } - } - return true; -#undef DO_ -} - -void TaskResult::SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const { - // required int32 exitCode = 1; - if (has_exitcode()) { - ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->exitcode(), output); - } - - // required int64 taskDuration = 2; - if (has_taskduration()) { - ::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->taskduration(), output); - } - - // repeated int64 commandDuration = 3; - for (int i = 0; i < this->commandduration_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteInt64( - 3, this->commandduration(i), output); - } - - // required int64 workingDataSize = 4; - if (has_workingdatasize()) { - ::google::protobuf::internal::WireFormatLite::WriteInt64(4, this->workingdatasize(), output); - } - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - for (int i = 0; i < this->outputfile_size(); i++) { - ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray( - 5, this->outputfile(i), output); - } - - if (!unknown_fields().empty()) { - ::google::protobuf::internal::WireFormat::SerializeUnknownFields( - unknown_fields(), output); - } -} - -::google::protobuf::uint8* TaskResult::SerializeWithCachedSizesToArray( - ::google::protobuf::uint8* target) const { - // required int32 exitCode = 1; - if (has_exitcode()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->exitcode(), target); - } - - // required int64 taskDuration = 2; - if (has_taskduration()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(2, this->taskduration(), target); - } - - // repeated int64 commandDuration = 3; - for (int i = 0; i < this->commandduration_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteInt64ToArray(3, this->commandduration(i), target); - } - - // required int64 workingDataSize = 4; - if (has_workingdatasize()) { - target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(4, this->workingdatasize(), target); - } - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - for (int i = 0; i < this->outputfile_size(); i++) { - target = ::google::protobuf::internal::WireFormatLite:: - WriteMessageNoVirtualToArray( - 5, this->outputfile(i), target); - } - - if (!unknown_fields().empty()) { - target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( - unknown_fields(), target); - } - return target; -} - -int TaskResult::ByteSize() const { - int total_size = 0; - - if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { - // required int32 exitCode = 1; - if (has_exitcode()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int32Size( - this->exitcode()); - } - - // required int64 taskDuration = 2; - if (has_taskduration()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int64Size( - this->taskduration()); - } - - // required int64 workingDataSize = 4; - if (has_workingdatasize()) { - total_size += 1 + - ::google::protobuf::internal::WireFormatLite::Int64Size( - this->workingdatasize()); - } - - } - // repeated int64 commandDuration = 3; - { - int data_size = 0; - for (int i = 0; i < this->commandduration_size(); i++) { - data_size += ::google::protobuf::internal::WireFormatLite:: - Int64Size(this->commandduration(i)); - } - total_size += 1 * this->commandduration_size() + data_size; - } - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - total_size += 1 * this->outputfile_size(); - for (int i = 0; i < this->outputfile_size(); i++) { - total_size += - ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual( - this->outputfile(i)); - } - - if (!unknown_fields().empty()) { - total_size += - ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( - unknown_fields()); - } - GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); - _cached_size_ = total_size; - GOOGLE_SAFE_CONCURRENT_WRITES_END(); - return total_size; -} - -void TaskResult::MergeFrom(const ::google::protobuf::Message& from) { - GOOGLE_CHECK_NE(&from, this); - const TaskResult* source = - ::google::protobuf::internal::dynamic_cast_if_available( - &from); - if (source == NULL) { - ::google::protobuf::internal::ReflectionOps::Merge(from, this); - } else { - MergeFrom(*source); - } -} - -void TaskResult::MergeFrom(const TaskResult& from) { - GOOGLE_CHECK_NE(&from, this); - commandduration_.MergeFrom(from.commandduration_); - outputfile_.MergeFrom(from.outputfile_); - if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { - if (from.has_exitcode()) { - set_exitcode(from.exitcode()); - } - if (from.has_taskduration()) { - set_taskduration(from.taskduration()); - } - if (from.has_workingdatasize()) { - set_workingdatasize(from.workingdatasize()); - } - } - mutable_unknown_fields()->MergeFrom(from.unknown_fields()); -} - -void TaskResult::CopyFrom(const ::google::protobuf::Message& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -void TaskResult::CopyFrom(const TaskResult& from) { - if (&from == this) return; - Clear(); - MergeFrom(from); -} - -bool TaskResult::IsInitialized() const { - if ((_has_bits_[0] & 0x0000000b) != 0x0000000b) return false; - - for (int i = 0; i < outputfile_size(); i++) { - if (!this->outputfile(i).IsInitialized()) return false; - } - return true; -} - -void TaskResult::Swap(TaskResult* other) { - if (other != this) { - std::swap(exitcode_, other->exitcode_); - std::swap(taskduration_, other->taskduration_); - commandduration_.Swap(&other->commandduration_); - std::swap(workingdatasize_, other->workingdatasize_); - outputfile_.Swap(&other->outputfile_); - std::swap(_has_bits_[0], other->_has_bits_[0]); - _unknown_fields_.Swap(&other->_unknown_fields_); - std::swap(_cached_size_, other->_cached_size_); - } -} - -::google::protobuf::Metadata TaskResult::GetMetadata() const { - protobuf_AssignDescriptorsOnce(); - ::google::protobuf::Metadata metadata; - metadata.descriptor = TaskResult_descriptor_; - metadata.reflection = TaskResult_reflection_; - return metadata; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace messages - -// @@protoc_insertion_point(global_scope) diff --git a/mpi-communication/src/messages.pb.h b/mpi-communication/src/messages.pb.h deleted file mode 100644 index 6bd39669..00000000 --- a/mpi-communication/src/messages.pb.h +++ /dev/null @@ -1,2602 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: messages.proto - -#ifndef PROTOBUF_messages_2eproto__INCLUDED -#define PROTOBUF_messages_2eproto__INCLUDED - -#include - -#include - -#if GOOGLE_PROTOBUF_VERSION < 2005000 -#error This file was generated by a newer version of protoc which is -#error incompatible with your Protocol Buffer headers. Please update -#error your headers. -#endif -#if 2005000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION -#error This file was generated by an older version of protoc which is -#error incompatible with your Protocol Buffer headers. Please -#error regenerate this file with a newer version of protoc. -#endif - -#include -#include -#include -#include -#include -#include -// @@protoc_insertion_point(includes) - -namespace messages { - -// Internal implementation detail -- do not call these. -void protobuf_AddDesc_messages_2eproto(); -void protobuf_AssignDesc_messages_2eproto(); -void protobuf_ShutdownFile_messages_2eproto(); - -class CommonFile; -class Task; -class Task_InputFile; -class Task_OutputFile; -class Task_Variable; -class Task_Environment; -class Task_Command; -class TaskResult; -class TaskResult_OutputFile; - -enum Task_InputFile_PreProcessor { - Task_InputFile_PreProcessor_NONE = 1, - Task_InputFile_PreProcessor_ARCHIVE_UNZIP = 2, - Task_InputFile_PreProcessor_FILE_GUNZIP = 3 -}; -bool Task_InputFile_PreProcessor_IsValid(int value); -const Task_InputFile_PreProcessor Task_InputFile_PreProcessor_PreProcessor_MIN = Task_InputFile_PreProcessor_NONE; -const Task_InputFile_PreProcessor Task_InputFile_PreProcessor_PreProcessor_MAX = Task_InputFile_PreProcessor_FILE_GUNZIP; -const int Task_InputFile_PreProcessor_PreProcessor_ARRAYSIZE = Task_InputFile_PreProcessor_PreProcessor_MAX + 1; - -const ::google::protobuf::EnumDescriptor* Task_InputFile_PreProcessor_descriptor(); -inline const ::std::string& Task_InputFile_PreProcessor_Name(Task_InputFile_PreProcessor value) { - return ::google::protobuf::internal::NameOfEnum( - Task_InputFile_PreProcessor_descriptor(), value); -} -inline bool Task_InputFile_PreProcessor_Parse( - const ::std::string& name, Task_InputFile_PreProcessor* value) { - return ::google::protobuf::internal::ParseNamedEnum( - Task_InputFile_PreProcessor_descriptor(), name, value); -} -enum Task_InputFile_Scope { - Task_InputFile_Scope_RUN = 1, - Task_InputFile_Scope_JOB = 2, - Task_InputFile_Scope_TASK = 3 -}; -bool Task_InputFile_Scope_IsValid(int value); -const Task_InputFile_Scope Task_InputFile_Scope_Scope_MIN = Task_InputFile_Scope_RUN; -const Task_InputFile_Scope Task_InputFile_Scope_Scope_MAX = Task_InputFile_Scope_TASK; -const int Task_InputFile_Scope_Scope_ARRAYSIZE = Task_InputFile_Scope_Scope_MAX + 1; - -const ::google::protobuf::EnumDescriptor* Task_InputFile_Scope_descriptor(); -inline const ::std::string& Task_InputFile_Scope_Name(Task_InputFile_Scope value) { - return ::google::protobuf::internal::NameOfEnum( - Task_InputFile_Scope_descriptor(), value); -} -inline bool Task_InputFile_Scope_Parse( - const ::std::string& name, Task_InputFile_Scope* value) { - return ::google::protobuf::internal::ParseNamedEnum( - Task_InputFile_Scope_descriptor(), name, value); -} -enum Task_OutputFile_PostProcessor { - Task_OutputFile_PostProcessor_NONE = 1, - Task_OutputFile_PostProcessor_FILE_GZIP = 2 -}; -bool Task_OutputFile_PostProcessor_IsValid(int value); -const Task_OutputFile_PostProcessor Task_OutputFile_PostProcessor_PostProcessor_MIN = Task_OutputFile_PostProcessor_NONE; -const Task_OutputFile_PostProcessor Task_OutputFile_PostProcessor_PostProcessor_MAX = Task_OutputFile_PostProcessor_FILE_GZIP; -const int Task_OutputFile_PostProcessor_PostProcessor_ARRAYSIZE = Task_OutputFile_PostProcessor_PostProcessor_MAX + 1; - -const ::google::protobuf::EnumDescriptor* Task_OutputFile_PostProcessor_descriptor(); -inline const ::std::string& Task_OutputFile_PostProcessor_Name(Task_OutputFile_PostProcessor value) { - return ::google::protobuf::internal::NameOfEnum( - Task_OutputFile_PostProcessor_descriptor(), value); -} -inline bool Task_OutputFile_PostProcessor_Parse( - const ::std::string& name, Task_OutputFile_PostProcessor* value) { - return ::google::protobuf::internal::ParseNamedEnum( - Task_OutputFile_PostProcessor_descriptor(), name, value); -} -// =================================================================== - -class CommonFile : public ::google::protobuf::Message { - public: - CommonFile(); - virtual ~CommonFile(); - - CommonFile(const CommonFile& from); - - inline CommonFile& operator=(const CommonFile& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const CommonFile& default_instance(); - - void Swap(CommonFile* other); - - // implements Message ---------------------------------------------- - - CommonFile* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const CommonFile& from); - void MergeFrom(const CommonFile& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // required int32 chunk = 2; - inline bool has_chunk() const; - inline void clear_chunk(); - static const int kChunkFieldNumber = 2; - inline ::google::protobuf::int32 chunk() const; - inline void set_chunk(::google::protobuf::int32 value); - - // required bool last = 3; - inline bool has_last() const; - inline void clear_last(); - static const int kLastFieldNumber = 3; - inline bool last() const; - inline void set_last(bool value); - - // required bytes data = 4; - inline bool has_data() const; - inline void clear_data(); - static const int kDataFieldNumber = 4; - inline const ::std::string& data() const; - inline void set_data(const ::std::string& value); - inline void set_data(const char* value); - inline void set_data(const void* value, size_t size); - inline ::std::string* mutable_data(); - inline ::std::string* release_data(); - inline void set_allocated_data(::std::string* data); - - // @@protoc_insertion_point(class_scope:messages.CommonFile) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_chunk(); - inline void clear_has_chunk(); - inline void set_has_last(); - inline void clear_has_last(); - inline void set_has_data(); - inline void clear_has_data(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::google::protobuf::int32 chunk_; - bool last_; - ::std::string* data_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static CommonFile* default_instance_; -}; -// ------------------------------------------------------------------- - -class Task_InputFile : public ::google::protobuf::Message { - public: - Task_InputFile(); - virtual ~Task_InputFile(); - - Task_InputFile(const Task_InputFile& from); - - inline Task_InputFile& operator=(const Task_InputFile& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Task_InputFile& default_instance(); - - void Swap(Task_InputFile* other); - - // implements Message ---------------------------------------------- - - Task_InputFile* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Task_InputFile& from); - void MergeFrom(const Task_InputFile& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef Task_InputFile_PreProcessor PreProcessor; - static const PreProcessor NONE = Task_InputFile_PreProcessor_NONE; - static const PreProcessor ARCHIVE_UNZIP = Task_InputFile_PreProcessor_ARCHIVE_UNZIP; - static const PreProcessor FILE_GUNZIP = Task_InputFile_PreProcessor_FILE_GUNZIP; - static inline bool PreProcessor_IsValid(int value) { - return Task_InputFile_PreProcessor_IsValid(value); - } - static const PreProcessor PreProcessor_MIN = - Task_InputFile_PreProcessor_PreProcessor_MIN; - static const PreProcessor PreProcessor_MAX = - Task_InputFile_PreProcessor_PreProcessor_MAX; - static const int PreProcessor_ARRAYSIZE = - Task_InputFile_PreProcessor_PreProcessor_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - PreProcessor_descriptor() { - return Task_InputFile_PreProcessor_descriptor(); - } - static inline const ::std::string& PreProcessor_Name(PreProcessor value) { - return Task_InputFile_PreProcessor_Name(value); - } - static inline bool PreProcessor_Parse(const ::std::string& name, - PreProcessor* value) { - return Task_InputFile_PreProcessor_Parse(name, value); - } - - typedef Task_InputFile_Scope Scope; - static const Scope RUN = Task_InputFile_Scope_RUN; - static const Scope JOB = Task_InputFile_Scope_JOB; - static const Scope TASK = Task_InputFile_Scope_TASK; - static inline bool Scope_IsValid(int value) { - return Task_InputFile_Scope_IsValid(value); - } - static const Scope Scope_MIN = - Task_InputFile_Scope_Scope_MIN; - static const Scope Scope_MAX = - Task_InputFile_Scope_Scope_MAX; - static const int Scope_ARRAYSIZE = - Task_InputFile_Scope_Scope_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - Scope_descriptor() { - return Task_InputFile_Scope_descriptor(); - } - static inline const ::std::string& Scope_Name(Scope value) { - return Task_InputFile_Scope_Name(value); - } - static inline bool Scope_Parse(const ::std::string& name, - Scope* value) { - return Task_InputFile_Scope_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - // required string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // required .messages.Task.InputFile.Scope scope = 2; - inline bool has_scope() const; - inline void clear_scope(); - static const int kScopeFieldNumber = 2; - inline ::messages::Task_InputFile_Scope scope() const; - inline void set_scope(::messages::Task_InputFile_Scope value); - - // optional bytes data = 3; - inline bool has_data() const; - inline void clear_data(); - static const int kDataFieldNumber = 3; - inline const ::std::string& data() const; - inline void set_data(const ::std::string& value); - inline void set_data(const char* value); - inline void set_data(const void* value, size_t size); - inline ::std::string* mutable_data(); - inline ::std::string* release_data(); - inline void set_allocated_data(::std::string* data); - - // required .messages.Task.InputFile.PreProcessor preProcessor = 4; - inline bool has_preprocessor() const; - inline void clear_preprocessor(); - static const int kPreProcessorFieldNumber = 4; - inline ::messages::Task_InputFile_PreProcessor preprocessor() const; - inline void set_preprocessor(::messages::Task_InputFile_PreProcessor value); - - // @@protoc_insertion_point(class_scope:messages.Task.InputFile) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_scope(); - inline void clear_has_scope(); - inline void set_has_data(); - inline void clear_has_data(); - inline void set_has_preprocessor(); - inline void clear_has_preprocessor(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* data_; - int scope_; - int preprocessor_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static Task_InputFile* default_instance_; -}; -// ------------------------------------------------------------------- - -class Task_OutputFile : public ::google::protobuf::Message { - public: - Task_OutputFile(); - virtual ~Task_OutputFile(); - - Task_OutputFile(const Task_OutputFile& from); - - inline Task_OutputFile& operator=(const Task_OutputFile& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Task_OutputFile& default_instance(); - - void Swap(Task_OutputFile* other); - - // implements Message ---------------------------------------------- - - Task_OutputFile* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Task_OutputFile& from); - void MergeFrom(const Task_OutputFile& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef Task_OutputFile_PostProcessor PostProcessor; - static const PostProcessor NONE = Task_OutputFile_PostProcessor_NONE; - static const PostProcessor FILE_GZIP = Task_OutputFile_PostProcessor_FILE_GZIP; - static inline bool PostProcessor_IsValid(int value) { - return Task_OutputFile_PostProcessor_IsValid(value); - } - static const PostProcessor PostProcessor_MIN = - Task_OutputFile_PostProcessor_PostProcessor_MIN; - static const PostProcessor PostProcessor_MAX = - Task_OutputFile_PostProcessor_PostProcessor_MAX; - static const int PostProcessor_ARRAYSIZE = - Task_OutputFile_PostProcessor_PostProcessor_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - PostProcessor_descriptor() { - return Task_OutputFile_PostProcessor_descriptor(); - } - static inline const ::std::string& PostProcessor_Name(PostProcessor value) { - return Task_OutputFile_PostProcessor_Name(value); - } - static inline bool PostProcessor_Parse(const ::std::string& name, - PostProcessor* value) { - return Task_OutputFile_PostProcessor_Parse(name, value); - } - - // accessors ------------------------------------------------------- - - // required string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // required .messages.Task.OutputFile.PostProcessor postProcessor = 2; - inline bool has_postprocessor() const; - inline void clear_postprocessor(); - static const int kPostProcessorFieldNumber = 2; - inline ::messages::Task_OutputFile_PostProcessor postprocessor() const; - inline void set_postprocessor(::messages::Task_OutputFile_PostProcessor value); - - // @@protoc_insertion_point(class_scope:messages.Task.OutputFile) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_postprocessor(); - inline void clear_has_postprocessor(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - int postprocessor_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static Task_OutputFile* default_instance_; -}; -// ------------------------------------------------------------------- - -class Task_Variable : public ::google::protobuf::Message { - public: - Task_Variable(); - virtual ~Task_Variable(); - - Task_Variable(const Task_Variable& from); - - inline Task_Variable& operator=(const Task_Variable& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Task_Variable& default_instance(); - - void Swap(Task_Variable* other); - - // implements Message ---------------------------------------------- - - Task_Variable* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Task_Variable& from); - void MergeFrom(const Task_Variable& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // required string value = 2; - inline bool has_value() const; - inline void clear_value(); - static const int kValueFieldNumber = 2; - inline const ::std::string& value() const; - inline void set_value(const ::std::string& value); - inline void set_value(const char* value); - inline void set_value(const char* value, size_t size); - inline ::std::string* mutable_value(); - inline ::std::string* release_value(); - inline void set_allocated_value(::std::string* value); - - // @@protoc_insertion_point(class_scope:messages.Task.Variable) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_value(); - inline void clear_has_value(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* value_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static Task_Variable* default_instance_; -}; -// ------------------------------------------------------------------- - -class Task_Environment : public ::google::protobuf::Message { - public: - Task_Environment(); - virtual ~Task_Environment(); - - Task_Environment(const Task_Environment& from); - - inline Task_Environment& operator=(const Task_Environment& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Task_Environment& default_instance(); - - void Swap(Task_Environment* other); - - // implements Message ---------------------------------------------- - - Task_Environment* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Task_Environment& from); - void MergeFrom(const Task_Environment& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // repeated .messages.Task.Variable variable = 1; - inline int variable_size() const; - inline void clear_variable(); - static const int kVariableFieldNumber = 1; - inline const ::messages::Task_Variable& variable(int index) const; - inline ::messages::Task_Variable* mutable_variable(int index); - inline ::messages::Task_Variable* add_variable(); - inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_Variable >& - variable() const; - inline ::google::protobuf::RepeatedPtrField< ::messages::Task_Variable >* - mutable_variable(); - - // @@protoc_insertion_point(class_scope:messages.Task.Environment) - private: - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::RepeatedPtrField< ::messages::Task_Variable > variable_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static Task_Environment* default_instance_; -}; -// ------------------------------------------------------------------- - -class Task_Command : public ::google::protobuf::Message { - public: - Task_Command(); - virtual ~Task_Command(); - - Task_Command(const Task_Command& from); - - inline Task_Command& operator=(const Task_Command& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Task_Command& default_instance(); - - void Swap(Task_Command* other); - - // implements Message ---------------------------------------------- - - Task_Command* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Task_Command& from); - void MergeFrom(const Task_Command& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required string program = 1; - inline bool has_program() const; - inline void clear_program(); - static const int kProgramFieldNumber = 1; - inline const ::std::string& program() const; - inline void set_program(const ::std::string& value); - inline void set_program(const char* value); - inline void set_program(const char* value, size_t size); - inline ::std::string* mutable_program(); - inline ::std::string* release_program(); - inline void set_allocated_program(::std::string* program); - - // repeated string argument = 2; - inline int argument_size() const; - inline void clear_argument(); - static const int kArgumentFieldNumber = 2; - inline const ::std::string& argument(int index) const; - inline ::std::string* mutable_argument(int index); - inline void set_argument(int index, const ::std::string& value); - inline void set_argument(int index, const char* value); - inline void set_argument(int index, const char* value, size_t size); - inline ::std::string* add_argument(); - inline void add_argument(const ::std::string& value); - inline void add_argument(const char* value); - inline void add_argument(const char* value, size_t size); - inline const ::google::protobuf::RepeatedPtrField< ::std::string>& argument() const; - inline ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_argument(); - - // optional int32 timeout = 3; - inline bool has_timeout() const; - inline void clear_timeout(); - static const int kTimeoutFieldNumber = 3; - inline ::google::protobuf::int32 timeout() const; - inline void set_timeout(::google::protobuf::int32 value); - - // @@protoc_insertion_point(class_scope:messages.Task.Command) - private: - inline void set_has_program(); - inline void clear_has_program(); - inline void set_has_timeout(); - inline void clear_has_timeout(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* program_; - ::google::protobuf::RepeatedPtrField< ::std::string> argument_; - ::google::protobuf::int32 timeout_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static Task_Command* default_instance_; -}; -// ------------------------------------------------------------------- - -class Task : public ::google::protobuf::Message { - public: - Task(); - virtual ~Task(); - - Task(const Task& from); - - inline Task& operator=(const Task& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const Task& default_instance(); - - void Swap(Task* other); - - // implements Message ---------------------------------------------- - - Task* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const Task& from); - void MergeFrom(const Task& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef Task_InputFile InputFile; - typedef Task_OutputFile OutputFile; - typedef Task_Variable Variable; - typedef Task_Environment Environment; - typedef Task_Command Command; - - // accessors ------------------------------------------------------- - - // required int32 jobId = 1; - inline bool has_jobid() const; - inline void clear_jobid(); - static const int kJobIdFieldNumber = 1; - inline ::google::protobuf::int32 jobid() const; - inline void set_jobid(::google::protobuf::int32 value); - - // required int32 index = 2; - inline bool has_index() const; - inline void clear_index(); - static const int kIndexFieldNumber = 2; - inline ::google::protobuf::int32 index() const; - inline void set_index(::google::protobuf::int32 value); - - // required .messages.Task.Environment env = 3; - inline bool has_env() const; - inline void clear_env(); - static const int kEnvFieldNumber = 3; - inline const ::messages::Task_Environment& env() const; - inline ::messages::Task_Environment* mutable_env(); - inline ::messages::Task_Environment* release_env(); - inline void set_allocated_env(::messages::Task_Environment* env); - - // required string cmdId = 4; - inline bool has_cmdid() const; - inline void clear_cmdid(); - static const int kCmdIdFieldNumber = 4; - inline const ::std::string& cmdid() const; - inline void set_cmdid(const ::std::string& value); - inline void set_cmdid(const char* value); - inline void set_cmdid(const char* value, size_t size); - inline ::std::string* mutable_cmdid(); - inline ::std::string* release_cmdid(); - inline void set_allocated_cmdid(::std::string* cmdid); - - // repeated .messages.Task.Command command = 5; - inline int command_size() const; - inline void clear_command(); - static const int kCommandFieldNumber = 5; - inline const ::messages::Task_Command& command(int index) const; - inline ::messages::Task_Command* mutable_command(int index); - inline ::messages::Task_Command* add_command(); - inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_Command >& - command() const; - inline ::google::protobuf::RepeatedPtrField< ::messages::Task_Command >* - mutable_command(); - - // repeated .messages.Task.InputFile inputFile = 6; - inline int inputfile_size() const; - inline void clear_inputfile(); - static const int kInputFileFieldNumber = 6; - inline const ::messages::Task_InputFile& inputfile(int index) const; - inline ::messages::Task_InputFile* mutable_inputfile(int index); - inline ::messages::Task_InputFile* add_inputfile(); - inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_InputFile >& - inputfile() const; - inline ::google::protobuf::RepeatedPtrField< ::messages::Task_InputFile >* - mutable_inputfile(); - - // repeated .messages.Task.OutputFile outputFile = 7; - inline int outputfile_size() const; - inline void clear_outputfile(); - static const int kOutputFileFieldNumber = 7; - inline const ::messages::Task_OutputFile& outputfile(int index) const; - inline ::messages::Task_OutputFile* mutable_outputfile(int index); - inline ::messages::Task_OutputFile* add_outputfile(); - inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_OutputFile >& - outputfile() const; - inline ::google::protobuf::RepeatedPtrField< ::messages::Task_OutputFile >* - mutable_outputfile(); - - // required bool initJob = 8; - inline bool has_initjob() const; - inline void clear_initjob(); - static const int kInitJobFieldNumber = 8; - inline bool initjob() const; - inline void set_initjob(bool value); - - // repeated int32 completedJobId = 9; - inline int completedjobid_size() const; - inline void clear_completedjobid(); - static const int kCompletedJobIdFieldNumber = 9; - inline ::google::protobuf::int32 completedjobid(int index) const; - inline void set_completedjobid(int index, ::google::protobuf::int32 value); - inline void add_completedjobid(::google::protobuf::int32 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& - completedjobid() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* - mutable_completedjobid(); - - // @@protoc_insertion_point(class_scope:messages.Task) - private: - inline void set_has_jobid(); - inline void clear_has_jobid(); - inline void set_has_index(); - inline void clear_has_index(); - inline void set_has_env(); - inline void clear_has_env(); - inline void set_has_cmdid(); - inline void clear_has_cmdid(); - inline void set_has_initjob(); - inline void clear_has_initjob(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::int32 jobid_; - ::google::protobuf::int32 index_; - ::messages::Task_Environment* env_; - ::std::string* cmdid_; - ::google::protobuf::RepeatedPtrField< ::messages::Task_Command > command_; - ::google::protobuf::RepeatedPtrField< ::messages::Task_InputFile > inputfile_; - ::google::protobuf::RepeatedPtrField< ::messages::Task_OutputFile > outputfile_; - ::google::protobuf::RepeatedField< ::google::protobuf::int32 > completedjobid_; - bool initjob_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(9 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static Task* default_instance_; -}; -// ------------------------------------------------------------------- - -class TaskResult_OutputFile : public ::google::protobuf::Message { - public: - TaskResult_OutputFile(); - virtual ~TaskResult_OutputFile(); - - TaskResult_OutputFile(const TaskResult_OutputFile& from); - - inline TaskResult_OutputFile& operator=(const TaskResult_OutputFile& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const TaskResult_OutputFile& default_instance(); - - void Swap(TaskResult_OutputFile* other); - - // implements Message ---------------------------------------------- - - TaskResult_OutputFile* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const TaskResult_OutputFile& from); - void MergeFrom(const TaskResult_OutputFile& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - // accessors ------------------------------------------------------- - - // required string name = 1; - inline bool has_name() const; - inline void clear_name(); - static const int kNameFieldNumber = 1; - inline const ::std::string& name() const; - inline void set_name(const ::std::string& value); - inline void set_name(const char* value); - inline void set_name(const char* value, size_t size); - inline ::std::string* mutable_name(); - inline ::std::string* release_name(); - inline void set_allocated_name(::std::string* name); - - // optional bytes data = 2; - inline bool has_data() const; - inline void clear_data(); - static const int kDataFieldNumber = 2; - inline const ::std::string& data() const; - inline void set_data(const ::std::string& value); - inline void set_data(const char* value); - inline void set_data(const void* value, size_t size); - inline ::std::string* mutable_data(); - inline ::std::string* release_data(); - inline void set_allocated_data(::std::string* data); - - // @@protoc_insertion_point(class_scope:messages.TaskResult.OutputFile) - private: - inline void set_has_name(); - inline void clear_has_name(); - inline void set_has_data(); - inline void clear_has_data(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::std::string* name_; - ::std::string* data_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(2 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static TaskResult_OutputFile* default_instance_; -}; -// ------------------------------------------------------------------- - -class TaskResult : public ::google::protobuf::Message { - public: - TaskResult(); - virtual ~TaskResult(); - - TaskResult(const TaskResult& from); - - inline TaskResult& operator=(const TaskResult& from) { - CopyFrom(from); - return *this; - } - - inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { - return _unknown_fields_; - } - - inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { - return &_unknown_fields_; - } - - static const ::google::protobuf::Descriptor* descriptor(); - static const TaskResult& default_instance(); - - void Swap(TaskResult* other); - - // implements Message ---------------------------------------------- - - TaskResult* New() const; - void CopyFrom(const ::google::protobuf::Message& from); - void MergeFrom(const ::google::protobuf::Message& from); - void CopyFrom(const TaskResult& from); - void MergeFrom(const TaskResult& from); - void Clear(); - bool IsInitialized() const; - - int ByteSize() const; - bool MergePartialFromCodedStream( - ::google::protobuf::io::CodedInputStream* input); - void SerializeWithCachedSizes( - ::google::protobuf::io::CodedOutputStream* output) const; - ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; - int GetCachedSize() const { return _cached_size_; } - private: - void SharedCtor(); - void SharedDtor(); - void SetCachedSize(int size) const; - public: - - ::google::protobuf::Metadata GetMetadata() const; - - // nested types ---------------------------------------------------- - - typedef TaskResult_OutputFile OutputFile; - - // accessors ------------------------------------------------------- - - // required int32 exitCode = 1; - inline bool has_exitcode() const; - inline void clear_exitcode(); - static const int kExitCodeFieldNumber = 1; - inline ::google::protobuf::int32 exitcode() const; - inline void set_exitcode(::google::protobuf::int32 value); - - // required int64 taskDuration = 2; - inline bool has_taskduration() const; - inline void clear_taskduration(); - static const int kTaskDurationFieldNumber = 2; - inline ::google::protobuf::int64 taskduration() const; - inline void set_taskduration(::google::protobuf::int64 value); - - // repeated int64 commandDuration = 3; - inline int commandduration_size() const; - inline void clear_commandduration(); - static const int kCommandDurationFieldNumber = 3; - inline ::google::protobuf::int64 commandduration(int index) const; - inline void set_commandduration(int index, ::google::protobuf::int64 value); - inline void add_commandduration(::google::protobuf::int64 value); - inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >& - commandduration() const; - inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >* - mutable_commandduration(); - - // required int64 workingDataSize = 4; - inline bool has_workingdatasize() const; - inline void clear_workingdatasize(); - static const int kWorkingDataSizeFieldNumber = 4; - inline ::google::protobuf::int64 workingdatasize() const; - inline void set_workingdatasize(::google::protobuf::int64 value); - - // repeated .messages.TaskResult.OutputFile outputFile = 5; - inline int outputfile_size() const; - inline void clear_outputfile(); - static const int kOutputFileFieldNumber = 5; - inline const ::messages::TaskResult_OutputFile& outputfile(int index) const; - inline ::messages::TaskResult_OutputFile* mutable_outputfile(int index); - inline ::messages::TaskResult_OutputFile* add_outputfile(); - inline const ::google::protobuf::RepeatedPtrField< ::messages::TaskResult_OutputFile >& - outputfile() const; - inline ::google::protobuf::RepeatedPtrField< ::messages::TaskResult_OutputFile >* - mutable_outputfile(); - - // @@protoc_insertion_point(class_scope:messages.TaskResult) - private: - inline void set_has_exitcode(); - inline void clear_has_exitcode(); - inline void set_has_taskduration(); - inline void clear_has_taskduration(); - inline void set_has_workingdatasize(); - inline void clear_has_workingdatasize(); - - ::google::protobuf::UnknownFieldSet _unknown_fields_; - - ::google::protobuf::int64 taskduration_; - ::google::protobuf::RepeatedField< ::google::protobuf::int64 > commandduration_; - ::google::protobuf::int64 workingdatasize_; - ::google::protobuf::RepeatedPtrField< ::messages::TaskResult_OutputFile > outputfile_; - ::google::protobuf::int32 exitcode_; - - mutable int _cached_size_; - ::google::protobuf::uint32 _has_bits_[(5 + 31) / 32]; - - friend void protobuf_AddDesc_messages_2eproto(); - friend void protobuf_AssignDesc_messages_2eproto(); - friend void protobuf_ShutdownFile_messages_2eproto(); - - void InitAsDefaultInstance(); - static TaskResult* default_instance_; -}; -// =================================================================== - - -// =================================================================== - -// CommonFile - -// required string name = 1; -inline bool CommonFile::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void CommonFile::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void CommonFile::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void CommonFile::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& CommonFile::name() const { - return *name_; -} -inline void CommonFile::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void CommonFile::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void CommonFile::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* CommonFile::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* CommonFile::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void CommonFile::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// required int32 chunk = 2; -inline bool CommonFile::has_chunk() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void CommonFile::set_has_chunk() { - _has_bits_[0] |= 0x00000002u; -} -inline void CommonFile::clear_has_chunk() { - _has_bits_[0] &= ~0x00000002u; -} -inline void CommonFile::clear_chunk() { - chunk_ = 0; - clear_has_chunk(); -} -inline ::google::protobuf::int32 CommonFile::chunk() const { - return chunk_; -} -inline void CommonFile::set_chunk(::google::protobuf::int32 value) { - set_has_chunk(); - chunk_ = value; -} - -// required bool last = 3; -inline bool CommonFile::has_last() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void CommonFile::set_has_last() { - _has_bits_[0] |= 0x00000004u; -} -inline void CommonFile::clear_has_last() { - _has_bits_[0] &= ~0x00000004u; -} -inline void CommonFile::clear_last() { - last_ = false; - clear_has_last(); -} -inline bool CommonFile::last() const { - return last_; -} -inline void CommonFile::set_last(bool value) { - set_has_last(); - last_ = value; -} - -// required bytes data = 4; -inline bool CommonFile::has_data() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void CommonFile::set_has_data() { - _has_bits_[0] |= 0x00000008u; -} -inline void CommonFile::clear_has_data() { - _has_bits_[0] &= ~0x00000008u; -} -inline void CommonFile::clear_data() { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } - clear_has_data(); -} -inline const ::std::string& CommonFile::data() const { - return *data_; -} -inline void CommonFile::set_data(const ::std::string& value) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); -} -inline void CommonFile::set_data(const char* value) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); -} -inline void CommonFile::set_data(const void* value, size_t size) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(reinterpret_cast(value), size); -} -inline ::std::string* CommonFile::mutable_data() { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - return data_; -} -inline ::std::string* CommonFile::release_data() { - clear_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = data_; - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void CommonFile::set_allocated_data(::std::string* data) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (data) { - set_has_data(); - data_ = data; - } else { - clear_has_data(); - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// ------------------------------------------------------------------- - -// Task_InputFile - -// required string name = 1; -inline bool Task_InputFile::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Task_InputFile::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void Task_InputFile::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Task_InputFile::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& Task_InputFile::name() const { - return *name_; -} -inline void Task_InputFile::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void Task_InputFile::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void Task_InputFile::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* Task_InputFile::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* Task_InputFile::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void Task_InputFile::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// required .messages.Task.InputFile.Scope scope = 2; -inline bool Task_InputFile::has_scope() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void Task_InputFile::set_has_scope() { - _has_bits_[0] |= 0x00000002u; -} -inline void Task_InputFile::clear_has_scope() { - _has_bits_[0] &= ~0x00000002u; -} -inline void Task_InputFile::clear_scope() { - scope_ = 1; - clear_has_scope(); -} -inline ::messages::Task_InputFile_Scope Task_InputFile::scope() const { - return static_cast< ::messages::Task_InputFile_Scope >(scope_); -} -inline void Task_InputFile::set_scope(::messages::Task_InputFile_Scope value) { - assert(::messages::Task_InputFile_Scope_IsValid(value)); - set_has_scope(); - scope_ = value; -} - -// optional bytes data = 3; -inline bool Task_InputFile::has_data() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void Task_InputFile::set_has_data() { - _has_bits_[0] |= 0x00000004u; -} -inline void Task_InputFile::clear_has_data() { - _has_bits_[0] &= ~0x00000004u; -} -inline void Task_InputFile::clear_data() { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } - clear_has_data(); -} -inline const ::std::string& Task_InputFile::data() const { - return *data_; -} -inline void Task_InputFile::set_data(const ::std::string& value) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); -} -inline void Task_InputFile::set_data(const char* value) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); -} -inline void Task_InputFile::set_data(const void* value, size_t size) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(reinterpret_cast(value), size); -} -inline ::std::string* Task_InputFile::mutable_data() { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - return data_; -} -inline ::std::string* Task_InputFile::release_data() { - clear_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = data_; - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void Task_InputFile::set_allocated_data(::std::string* data) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (data) { - set_has_data(); - data_ = data; - } else { - clear_has_data(); - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// required .messages.Task.InputFile.PreProcessor preProcessor = 4; -inline bool Task_InputFile::has_preprocessor() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void Task_InputFile::set_has_preprocessor() { - _has_bits_[0] |= 0x00000008u; -} -inline void Task_InputFile::clear_has_preprocessor() { - _has_bits_[0] &= ~0x00000008u; -} -inline void Task_InputFile::clear_preprocessor() { - preprocessor_ = 1; - clear_has_preprocessor(); -} -inline ::messages::Task_InputFile_PreProcessor Task_InputFile::preprocessor() const { - return static_cast< ::messages::Task_InputFile_PreProcessor >(preprocessor_); -} -inline void Task_InputFile::set_preprocessor(::messages::Task_InputFile_PreProcessor value) { - assert(::messages::Task_InputFile_PreProcessor_IsValid(value)); - set_has_preprocessor(); - preprocessor_ = value; -} - -// ------------------------------------------------------------------- - -// Task_OutputFile - -// required string name = 1; -inline bool Task_OutputFile::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Task_OutputFile::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void Task_OutputFile::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Task_OutputFile::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& Task_OutputFile::name() const { - return *name_; -} -inline void Task_OutputFile::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void Task_OutputFile::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void Task_OutputFile::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* Task_OutputFile::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* Task_OutputFile::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void Task_OutputFile::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// required .messages.Task.OutputFile.PostProcessor postProcessor = 2; -inline bool Task_OutputFile::has_postprocessor() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void Task_OutputFile::set_has_postprocessor() { - _has_bits_[0] |= 0x00000002u; -} -inline void Task_OutputFile::clear_has_postprocessor() { - _has_bits_[0] &= ~0x00000002u; -} -inline void Task_OutputFile::clear_postprocessor() { - postprocessor_ = 1; - clear_has_postprocessor(); -} -inline ::messages::Task_OutputFile_PostProcessor Task_OutputFile::postprocessor() const { - return static_cast< ::messages::Task_OutputFile_PostProcessor >(postprocessor_); -} -inline void Task_OutputFile::set_postprocessor(::messages::Task_OutputFile_PostProcessor value) { - assert(::messages::Task_OutputFile_PostProcessor_IsValid(value)); - set_has_postprocessor(); - postprocessor_ = value; -} - -// ------------------------------------------------------------------- - -// Task_Variable - -// required string name = 1; -inline bool Task_Variable::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Task_Variable::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void Task_Variable::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Task_Variable::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& Task_Variable::name() const { - return *name_; -} -inline void Task_Variable::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void Task_Variable::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void Task_Variable::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* Task_Variable::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* Task_Variable::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void Task_Variable::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// required string value = 2; -inline bool Task_Variable::has_value() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void Task_Variable::set_has_value() { - _has_bits_[0] |= 0x00000002u; -} -inline void Task_Variable::clear_has_value() { - _has_bits_[0] &= ~0x00000002u; -} -inline void Task_Variable::clear_value() { - if (value_ != &::google::protobuf::internal::kEmptyString) { - value_->clear(); - } - clear_has_value(); -} -inline const ::std::string& Task_Variable::value() const { - return *value_; -} -inline void Task_Variable::set_value(const ::std::string& value) { - set_has_value(); - if (value_ == &::google::protobuf::internal::kEmptyString) { - value_ = new ::std::string; - } - value_->assign(value); -} -inline void Task_Variable::set_value(const char* value) { - set_has_value(); - if (value_ == &::google::protobuf::internal::kEmptyString) { - value_ = new ::std::string; - } - value_->assign(value); -} -inline void Task_Variable::set_value(const char* value, size_t size) { - set_has_value(); - if (value_ == &::google::protobuf::internal::kEmptyString) { - value_ = new ::std::string; - } - value_->assign(reinterpret_cast(value), size); -} -inline ::std::string* Task_Variable::mutable_value() { - set_has_value(); - if (value_ == &::google::protobuf::internal::kEmptyString) { - value_ = new ::std::string; - } - return value_; -} -inline ::std::string* Task_Variable::release_value() { - clear_has_value(); - if (value_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = value_; - value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void Task_Variable::set_allocated_value(::std::string* value) { - if (value_ != &::google::protobuf::internal::kEmptyString) { - delete value_; - } - if (value) { - set_has_value(); - value_ = value; - } else { - clear_has_value(); - value_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// ------------------------------------------------------------------- - -// Task_Environment - -// repeated .messages.Task.Variable variable = 1; -inline int Task_Environment::variable_size() const { - return variable_.size(); -} -inline void Task_Environment::clear_variable() { - variable_.Clear(); -} -inline const ::messages::Task_Variable& Task_Environment::variable(int index) const { - return variable_.Get(index); -} -inline ::messages::Task_Variable* Task_Environment::mutable_variable(int index) { - return variable_.Mutable(index); -} -inline ::messages::Task_Variable* Task_Environment::add_variable() { - return variable_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_Variable >& -Task_Environment::variable() const { - return variable_; -} -inline ::google::protobuf::RepeatedPtrField< ::messages::Task_Variable >* -Task_Environment::mutable_variable() { - return &variable_; -} - -// ------------------------------------------------------------------- - -// Task_Command - -// required string program = 1; -inline bool Task_Command::has_program() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Task_Command::set_has_program() { - _has_bits_[0] |= 0x00000001u; -} -inline void Task_Command::clear_has_program() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Task_Command::clear_program() { - if (program_ != &::google::protobuf::internal::kEmptyString) { - program_->clear(); - } - clear_has_program(); -} -inline const ::std::string& Task_Command::program() const { - return *program_; -} -inline void Task_Command::set_program(const ::std::string& value) { - set_has_program(); - if (program_ == &::google::protobuf::internal::kEmptyString) { - program_ = new ::std::string; - } - program_->assign(value); -} -inline void Task_Command::set_program(const char* value) { - set_has_program(); - if (program_ == &::google::protobuf::internal::kEmptyString) { - program_ = new ::std::string; - } - program_->assign(value); -} -inline void Task_Command::set_program(const char* value, size_t size) { - set_has_program(); - if (program_ == &::google::protobuf::internal::kEmptyString) { - program_ = new ::std::string; - } - program_->assign(reinterpret_cast(value), size); -} -inline ::std::string* Task_Command::mutable_program() { - set_has_program(); - if (program_ == &::google::protobuf::internal::kEmptyString) { - program_ = new ::std::string; - } - return program_; -} -inline ::std::string* Task_Command::release_program() { - clear_has_program(); - if (program_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = program_; - program_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void Task_Command::set_allocated_program(::std::string* program) { - if (program_ != &::google::protobuf::internal::kEmptyString) { - delete program_; - } - if (program) { - set_has_program(); - program_ = program; - } else { - clear_has_program(); - program_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated string argument = 2; -inline int Task_Command::argument_size() const { - return argument_.size(); -} -inline void Task_Command::clear_argument() { - argument_.Clear(); -} -inline const ::std::string& Task_Command::argument(int index) const { - return argument_.Get(index); -} -inline ::std::string* Task_Command::mutable_argument(int index) { - return argument_.Mutable(index); -} -inline void Task_Command::set_argument(int index, const ::std::string& value) { - argument_.Mutable(index)->assign(value); -} -inline void Task_Command::set_argument(int index, const char* value) { - argument_.Mutable(index)->assign(value); -} -inline void Task_Command::set_argument(int index, const char* value, size_t size) { - argument_.Mutable(index)->assign( - reinterpret_cast(value), size); -} -inline ::std::string* Task_Command::add_argument() { - return argument_.Add(); -} -inline void Task_Command::add_argument(const ::std::string& value) { - argument_.Add()->assign(value); -} -inline void Task_Command::add_argument(const char* value) { - argument_.Add()->assign(value); -} -inline void Task_Command::add_argument(const char* value, size_t size) { - argument_.Add()->assign(reinterpret_cast(value), size); -} -inline const ::google::protobuf::RepeatedPtrField< ::std::string>& -Task_Command::argument() const { - return argument_; -} -inline ::google::protobuf::RepeatedPtrField< ::std::string>* -Task_Command::mutable_argument() { - return &argument_; -} - -// optional int32 timeout = 3; -inline bool Task_Command::has_timeout() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void Task_Command::set_has_timeout() { - _has_bits_[0] |= 0x00000004u; -} -inline void Task_Command::clear_has_timeout() { - _has_bits_[0] &= ~0x00000004u; -} -inline void Task_Command::clear_timeout() { - timeout_ = 0; - clear_has_timeout(); -} -inline ::google::protobuf::int32 Task_Command::timeout() const { - return timeout_; -} -inline void Task_Command::set_timeout(::google::protobuf::int32 value) { - set_has_timeout(); - timeout_ = value; -} - -// ------------------------------------------------------------------- - -// Task - -// required int32 jobId = 1; -inline bool Task::has_jobid() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void Task::set_has_jobid() { - _has_bits_[0] |= 0x00000001u; -} -inline void Task::clear_has_jobid() { - _has_bits_[0] &= ~0x00000001u; -} -inline void Task::clear_jobid() { - jobid_ = 0; - clear_has_jobid(); -} -inline ::google::protobuf::int32 Task::jobid() const { - return jobid_; -} -inline void Task::set_jobid(::google::protobuf::int32 value) { - set_has_jobid(); - jobid_ = value; -} - -// required int32 index = 2; -inline bool Task::has_index() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void Task::set_has_index() { - _has_bits_[0] |= 0x00000002u; -} -inline void Task::clear_has_index() { - _has_bits_[0] &= ~0x00000002u; -} -inline void Task::clear_index() { - index_ = 0; - clear_has_index(); -} -inline ::google::protobuf::int32 Task::index() const { - return index_; -} -inline void Task::set_index(::google::protobuf::int32 value) { - set_has_index(); - index_ = value; -} - -// required .messages.Task.Environment env = 3; -inline bool Task::has_env() const { - return (_has_bits_[0] & 0x00000004u) != 0; -} -inline void Task::set_has_env() { - _has_bits_[0] |= 0x00000004u; -} -inline void Task::clear_has_env() { - _has_bits_[0] &= ~0x00000004u; -} -inline void Task::clear_env() { - if (env_ != NULL) env_->::messages::Task_Environment::Clear(); - clear_has_env(); -} -inline const ::messages::Task_Environment& Task::env() const { - return env_ != NULL ? *env_ : *default_instance_->env_; -} -inline ::messages::Task_Environment* Task::mutable_env() { - set_has_env(); - if (env_ == NULL) env_ = new ::messages::Task_Environment; - return env_; -} -inline ::messages::Task_Environment* Task::release_env() { - clear_has_env(); - ::messages::Task_Environment* temp = env_; - env_ = NULL; - return temp; -} -inline void Task::set_allocated_env(::messages::Task_Environment* env) { - delete env_; - env_ = env; - if (env) { - set_has_env(); - } else { - clear_has_env(); - } -} - -// required string cmdId = 4; -inline bool Task::has_cmdid() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void Task::set_has_cmdid() { - _has_bits_[0] |= 0x00000008u; -} -inline void Task::clear_has_cmdid() { - _has_bits_[0] &= ~0x00000008u; -} -inline void Task::clear_cmdid() { - if (cmdid_ != &::google::protobuf::internal::kEmptyString) { - cmdid_->clear(); - } - clear_has_cmdid(); -} -inline const ::std::string& Task::cmdid() const { - return *cmdid_; -} -inline void Task::set_cmdid(const ::std::string& value) { - set_has_cmdid(); - if (cmdid_ == &::google::protobuf::internal::kEmptyString) { - cmdid_ = new ::std::string; - } - cmdid_->assign(value); -} -inline void Task::set_cmdid(const char* value) { - set_has_cmdid(); - if (cmdid_ == &::google::protobuf::internal::kEmptyString) { - cmdid_ = new ::std::string; - } - cmdid_->assign(value); -} -inline void Task::set_cmdid(const char* value, size_t size) { - set_has_cmdid(); - if (cmdid_ == &::google::protobuf::internal::kEmptyString) { - cmdid_ = new ::std::string; - } - cmdid_->assign(reinterpret_cast(value), size); -} -inline ::std::string* Task::mutable_cmdid() { - set_has_cmdid(); - if (cmdid_ == &::google::protobuf::internal::kEmptyString) { - cmdid_ = new ::std::string; - } - return cmdid_; -} -inline ::std::string* Task::release_cmdid() { - clear_has_cmdid(); - if (cmdid_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = cmdid_; - cmdid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void Task::set_allocated_cmdid(::std::string* cmdid) { - if (cmdid_ != &::google::protobuf::internal::kEmptyString) { - delete cmdid_; - } - if (cmdid) { - set_has_cmdid(); - cmdid_ = cmdid; - } else { - clear_has_cmdid(); - cmdid_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// repeated .messages.Task.Command command = 5; -inline int Task::command_size() const { - return command_.size(); -} -inline void Task::clear_command() { - command_.Clear(); -} -inline const ::messages::Task_Command& Task::command(int index) const { - return command_.Get(index); -} -inline ::messages::Task_Command* Task::mutable_command(int index) { - return command_.Mutable(index); -} -inline ::messages::Task_Command* Task::add_command() { - return command_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_Command >& -Task::command() const { - return command_; -} -inline ::google::protobuf::RepeatedPtrField< ::messages::Task_Command >* -Task::mutable_command() { - return &command_; -} - -// repeated .messages.Task.InputFile inputFile = 6; -inline int Task::inputfile_size() const { - return inputfile_.size(); -} -inline void Task::clear_inputfile() { - inputfile_.Clear(); -} -inline const ::messages::Task_InputFile& Task::inputfile(int index) const { - return inputfile_.Get(index); -} -inline ::messages::Task_InputFile* Task::mutable_inputfile(int index) { - return inputfile_.Mutable(index); -} -inline ::messages::Task_InputFile* Task::add_inputfile() { - return inputfile_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_InputFile >& -Task::inputfile() const { - return inputfile_; -} -inline ::google::protobuf::RepeatedPtrField< ::messages::Task_InputFile >* -Task::mutable_inputfile() { - return &inputfile_; -} - -// repeated .messages.Task.OutputFile outputFile = 7; -inline int Task::outputfile_size() const { - return outputfile_.size(); -} -inline void Task::clear_outputfile() { - outputfile_.Clear(); -} -inline const ::messages::Task_OutputFile& Task::outputfile(int index) const { - return outputfile_.Get(index); -} -inline ::messages::Task_OutputFile* Task::mutable_outputfile(int index) { - return outputfile_.Mutable(index); -} -inline ::messages::Task_OutputFile* Task::add_outputfile() { - return outputfile_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::messages::Task_OutputFile >& -Task::outputfile() const { - return outputfile_; -} -inline ::google::protobuf::RepeatedPtrField< ::messages::Task_OutputFile >* -Task::mutable_outputfile() { - return &outputfile_; -} - -// required bool initJob = 8; -inline bool Task::has_initjob() const { - return (_has_bits_[0] & 0x00000080u) != 0; -} -inline void Task::set_has_initjob() { - _has_bits_[0] |= 0x00000080u; -} -inline void Task::clear_has_initjob() { - _has_bits_[0] &= ~0x00000080u; -} -inline void Task::clear_initjob() { - initjob_ = false; - clear_has_initjob(); -} -inline bool Task::initjob() const { - return initjob_; -} -inline void Task::set_initjob(bool value) { - set_has_initjob(); - initjob_ = value; -} - -// repeated int32 completedJobId = 9; -inline int Task::completedjobid_size() const { - return completedjobid_.size(); -} -inline void Task::clear_completedjobid() { - completedjobid_.Clear(); -} -inline ::google::protobuf::int32 Task::completedjobid(int index) const { - return completedjobid_.Get(index); -} -inline void Task::set_completedjobid(int index, ::google::protobuf::int32 value) { - completedjobid_.Set(index, value); -} -inline void Task::add_completedjobid(::google::protobuf::int32 value) { - completedjobid_.Add(value); -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >& -Task::completedjobid() const { - return completedjobid_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >* -Task::mutable_completedjobid() { - return &completedjobid_; -} - -// ------------------------------------------------------------------- - -// TaskResult_OutputFile - -// required string name = 1; -inline bool TaskResult_OutputFile::has_name() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void TaskResult_OutputFile::set_has_name() { - _has_bits_[0] |= 0x00000001u; -} -inline void TaskResult_OutputFile::clear_has_name() { - _has_bits_[0] &= ~0x00000001u; -} -inline void TaskResult_OutputFile::clear_name() { - if (name_ != &::google::protobuf::internal::kEmptyString) { - name_->clear(); - } - clear_has_name(); -} -inline const ::std::string& TaskResult_OutputFile::name() const { - return *name_; -} -inline void TaskResult_OutputFile::set_name(const ::std::string& value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void TaskResult_OutputFile::set_name(const char* value) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(value); -} -inline void TaskResult_OutputFile::set_name(const char* value, size_t size) { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - name_->assign(reinterpret_cast(value), size); -} -inline ::std::string* TaskResult_OutputFile::mutable_name() { - set_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - name_ = new ::std::string; - } - return name_; -} -inline ::std::string* TaskResult_OutputFile::release_name() { - clear_has_name(); - if (name_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = name_; - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void TaskResult_OutputFile::set_allocated_name(::std::string* name) { - if (name_ != &::google::protobuf::internal::kEmptyString) { - delete name_; - } - if (name) { - set_has_name(); - name_ = name; - } else { - clear_has_name(); - name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// optional bytes data = 2; -inline bool TaskResult_OutputFile::has_data() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void TaskResult_OutputFile::set_has_data() { - _has_bits_[0] |= 0x00000002u; -} -inline void TaskResult_OutputFile::clear_has_data() { - _has_bits_[0] &= ~0x00000002u; -} -inline void TaskResult_OutputFile::clear_data() { - if (data_ != &::google::protobuf::internal::kEmptyString) { - data_->clear(); - } - clear_has_data(); -} -inline const ::std::string& TaskResult_OutputFile::data() const { - return *data_; -} -inline void TaskResult_OutputFile::set_data(const ::std::string& value) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); -} -inline void TaskResult_OutputFile::set_data(const char* value) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(value); -} -inline void TaskResult_OutputFile::set_data(const void* value, size_t size) { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - data_->assign(reinterpret_cast(value), size); -} -inline ::std::string* TaskResult_OutputFile::mutable_data() { - set_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - data_ = new ::std::string; - } - return data_; -} -inline ::std::string* TaskResult_OutputFile::release_data() { - clear_has_data(); - if (data_ == &::google::protobuf::internal::kEmptyString) { - return NULL; - } else { - ::std::string* temp = data_; - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - return temp; - } -} -inline void TaskResult_OutputFile::set_allocated_data(::std::string* data) { - if (data_ != &::google::protobuf::internal::kEmptyString) { - delete data_; - } - if (data) { - set_has_data(); - data_ = data; - } else { - clear_has_data(); - data_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - } -} - -// ------------------------------------------------------------------- - -// TaskResult - -// required int32 exitCode = 1; -inline bool TaskResult::has_exitcode() const { - return (_has_bits_[0] & 0x00000001u) != 0; -} -inline void TaskResult::set_has_exitcode() { - _has_bits_[0] |= 0x00000001u; -} -inline void TaskResult::clear_has_exitcode() { - _has_bits_[0] &= ~0x00000001u; -} -inline void TaskResult::clear_exitcode() { - exitcode_ = 0; - clear_has_exitcode(); -} -inline ::google::protobuf::int32 TaskResult::exitcode() const { - return exitcode_; -} -inline void TaskResult::set_exitcode(::google::protobuf::int32 value) { - set_has_exitcode(); - exitcode_ = value; -} - -// required int64 taskDuration = 2; -inline bool TaskResult::has_taskduration() const { - return (_has_bits_[0] & 0x00000002u) != 0; -} -inline void TaskResult::set_has_taskduration() { - _has_bits_[0] |= 0x00000002u; -} -inline void TaskResult::clear_has_taskduration() { - _has_bits_[0] &= ~0x00000002u; -} -inline void TaskResult::clear_taskduration() { - taskduration_ = GOOGLE_LONGLONG(0); - clear_has_taskduration(); -} -inline ::google::protobuf::int64 TaskResult::taskduration() const { - return taskduration_; -} -inline void TaskResult::set_taskduration(::google::protobuf::int64 value) { - set_has_taskduration(); - taskduration_ = value; -} - -// repeated int64 commandDuration = 3; -inline int TaskResult::commandduration_size() const { - return commandduration_.size(); -} -inline void TaskResult::clear_commandduration() { - commandduration_.Clear(); -} -inline ::google::protobuf::int64 TaskResult::commandduration(int index) const { - return commandduration_.Get(index); -} -inline void TaskResult::set_commandduration(int index, ::google::protobuf::int64 value) { - commandduration_.Set(index, value); -} -inline void TaskResult::add_commandduration(::google::protobuf::int64 value) { - commandduration_.Add(value); -} -inline const ::google::protobuf::RepeatedField< ::google::protobuf::int64 >& -TaskResult::commandduration() const { - return commandduration_; -} -inline ::google::protobuf::RepeatedField< ::google::protobuf::int64 >* -TaskResult::mutable_commandduration() { - return &commandduration_; -} - -// required int64 workingDataSize = 4; -inline bool TaskResult::has_workingdatasize() const { - return (_has_bits_[0] & 0x00000008u) != 0; -} -inline void TaskResult::set_has_workingdatasize() { - _has_bits_[0] |= 0x00000008u; -} -inline void TaskResult::clear_has_workingdatasize() { - _has_bits_[0] &= ~0x00000008u; -} -inline void TaskResult::clear_workingdatasize() { - workingdatasize_ = GOOGLE_LONGLONG(0); - clear_has_workingdatasize(); -} -inline ::google::protobuf::int64 TaskResult::workingdatasize() const { - return workingdatasize_; -} -inline void TaskResult::set_workingdatasize(::google::protobuf::int64 value) { - set_has_workingdatasize(); - workingdatasize_ = value; -} - -// repeated .messages.TaskResult.OutputFile outputFile = 5; -inline int TaskResult::outputfile_size() const { - return outputfile_.size(); -} -inline void TaskResult::clear_outputfile() { - outputfile_.Clear(); -} -inline const ::messages::TaskResult_OutputFile& TaskResult::outputfile(int index) const { - return outputfile_.Get(index); -} -inline ::messages::TaskResult_OutputFile* TaskResult::mutable_outputfile(int index) { - return outputfile_.Mutable(index); -} -inline ::messages::TaskResult_OutputFile* TaskResult::add_outputfile() { - return outputfile_.Add(); -} -inline const ::google::protobuf::RepeatedPtrField< ::messages::TaskResult_OutputFile >& -TaskResult::outputfile() const { - return outputfile_; -} -inline ::google::protobuf::RepeatedPtrField< ::messages::TaskResult_OutputFile >* -TaskResult::mutable_outputfile() { - return &outputfile_; -} - - -// @@protoc_insertion_point(namespace_scope) - -} // namespace messages - -#ifndef SWIG -namespace google { -namespace protobuf { - -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::messages::Task_InputFile_PreProcessor>() { - return ::messages::Task_InputFile_PreProcessor_descriptor(); -} -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::messages::Task_InputFile_Scope>() { - return ::messages::Task_InputFile_Scope_descriptor(); -} -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::messages::Task_OutputFile_PostProcessor>() { - return ::messages::Task_OutputFile_PostProcessor_descriptor(); -} - -} // namespace google -} // namespace protobuf -#endif // SWIG - -// @@protoc_insertion_point(global_scope) - -#endif // PROTOBUF_messages_2eproto__INCLUDED diff --git a/mpi-communication/src/mpitags.cpp b/mpi-communication/src/mpitags.cpp deleted file mode 100644 index d6767039..00000000 --- a/mpi-communication/src/mpitags.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file mpitags.cpp - * @author Geoffroy Jamgotchian - */ - -#include -#include "mpitags.hpp" - -namespace itesla { - -std::string str(const Step& step) { - switch (step) { - case Step::COMMON_FILES_BCAST: - return "COMMON_FILES_BCAST"; - case Step::TASKS_EXECUTION: - return "TASKS_EXECUTION"; - case Step::SHUTDOWN: - return "SHUTDOWN"; - default: - throw std::runtime_error("Unexpected step value"); - } -} - -// special length message to switch slaves state -const int SPECIAL_LENGTH_SWITCH_TO_SHUTDOWN = -1; -const int SPECIAL_LENGTH_SWITCH_TO_TASKS_EXECUTION = -2; -const int SPECIAL_LENGTH_SWITCH_TO_COMMON_FILES_BCAST = -3; - -int step2specialLength(Step step) { - switch (step) { - case Step::COMMON_FILES_BCAST: - return SPECIAL_LENGTH_SWITCH_TO_COMMON_FILES_BCAST; - case Step::TASKS_EXECUTION: - return SPECIAL_LENGTH_SWITCH_TO_TASKS_EXECUTION; - case Step::SHUTDOWN: - return SPECIAL_LENGTH_SWITCH_TO_SHUTDOWN; - default: - throw std::runtime_error("Unexpected step value"); - } -} - -Step specialLength2step(int length) { - switch (length) { - case SPECIAL_LENGTH_SWITCH_TO_SHUTDOWN: - return Step::SHUTDOWN; - case SPECIAL_LENGTH_SWITCH_TO_TASKS_EXECUTION: - return Step::TASKS_EXECUTION; - case SPECIAL_LENGTH_SWITCH_TO_COMMON_FILES_BCAST: - return Step::COMMON_FILES_BCAST; - default: - throw std::runtime_error("Unexpected length code"); - } -} - -bool isSpecialLength(int length) { - return length == SPECIAL_LENGTH_SWITCH_TO_SHUTDOWN - || length == SPECIAL_LENGTH_SWITCH_TO_TASKS_EXECUTION - || length == SPECIAL_LENGTH_SWITCH_TO_COMMON_FILES_BCAST; -} - -} diff --git a/mpi-communication/src/mpitags.hpp b/mpi-communication/src/mpitags.hpp deleted file mode 100644 index 0975bd56..00000000 --- a/mpi-communication/src/mpitags.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file mpitags.hpp - * @author Geoffroy Jamgotchian - */ - -#ifndef MPITAGS_HPP -#define MPITAGS_HPP - -#include - -namespace itesla { - -const int MAX_CORES_PER_RANK = 1000; -const int JOB_BUFFER_TAG = 0; -const int JOB_LENGTH_TAG = JOB_BUFFER_TAG + MAX_CORES_PER_RANK; -const int JOB_RESULT_BUFFER_TAG = JOB_LENGTH_TAG + MAX_CORES_PER_RANK; -const int JOB_RESULT_LENGTH_TAG = JOB_RESULT_BUFFER_TAG + MAX_CORES_PER_RANK; - -enum class Step { - COMMON_FILES_BCAST, - TASKS_EXECUTION, - SHUTDOWN -}; - -int step2specialLength(Step step); -Step specialLength2step(int length); -bool isSpecialLength(int length); - -std::string str(const Step& step); - -} - -#endif // MPITAGS_HPP diff --git a/mpi-communication/src/mpiutil.cpp b/mpi-communication/src/mpiutil.cpp deleted file mode 100644 index 09fd6a23..00000000 --- a/mpi-communication/src/mpiutil.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file mpiutil.cpp - * @author Geoffroy Jamgotchian - */ - -#include -#include -#include -#include -#include "mpiutil.hpp" - -namespace itesla { - -namespace mpi { - -std::string processorName() { - char buffer[MPI_MAX_PROCESSOR_NAME]; - int length; - if (MPI_Get_processor_name(buffer, &length) != MPI_SUCCESS) { - throw new std::runtime_error("MPI_Get_processor_name error"); - } - return std::string(buffer, length); -} - -std::string version() { - int version; - int subversion; - if (MPI_Get_version(&version, &subversion) != MPI_SUCCESS) { - throw new std::runtime_error("MPI_Get_version error"); - } - return boost::lexical_cast(version) + "." + boost::lexical_cast(subversion); -} - -void initThreadFunneled() { - int provided; - if (MPI_Init_thread(NULL, NULL, MPI_THREAD_FUNNELED, &provided) != MPI_SUCCESS) { - throw new std::runtime_error("MPI_Init_thread error"); - } - if (provided != MPI_THREAD_FUNNELED) { - throw std::runtime_error("MPI_THREAD_FUNNELED level not supported (provided=" - + boost::lexical_cast(provided) + ")"); - } -} - -} - -} diff --git a/mpi-communication/src/mpiutil.hpp b/mpi-communication/src/mpiutil.hpp deleted file mode 100644 index 792e54d1..00000000 --- a/mpi-communication/src/mpiutil.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file mpiutil.hpp - * @author Geoffroy Jamgotchian - */ - -#ifndef MPIUTIL_HPP -#define MPIUTIL_HPP - -namespace itesla { - -namespace mpi { - -std::string processorName(); -std::string version(); -void initThreadFunneled(); - -} - -} - -#endif // MPIUTIL_HPP diff --git a/mpi-communication/src/slave.cpp b/mpi-communication/src/slave.cpp deleted file mode 100644 index 60741856..00000000 --- a/mpi-communication/src/slave.cpp +++ /dev/null @@ -1,981 +0,0 @@ -// Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -/** - * @file slave.cpp - * @author Geoffroy Jamgotchian - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define BOOST_NO_CXX11_SCOPED_ENUMS -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mpitags.hpp" -#include "mpiutil.hpp" -#include "ioutil.hpp" -#include "messages.pb.h" - -namespace itesla { - -namespace slave { - -const std::string COMMON_DIR_PREFIX = "itesla_common_"; -const std::string WORKING_DIR_PREFIX = "itesla_work_"; -const std::string JOB_DIR_PREFIX = "itesla_job_"; - -boost::filesystem::path commonDir(const boost::filesystem::path& localDir, int rank) { - return localDir / (COMMON_DIR_PREFIX + boost::lexical_cast(rank)); -} - -boost::filesystem::path workingDir(const boost::filesystem::path& localDir, int rank, int threadNum) { - return localDir / (WORKING_DIR_PREFIX + boost::lexical_cast(rank) + "_" + boost::lexical_cast(threadNum)); -} - -boost::filesystem::path jobDir(const boost::filesystem::path& localDir, int rank, int jobId) { - return localDir / (JOB_DIR_PREFIX + boost::lexical_cast(rank) + "_" + boost::lexical_cast(jobId)); -} - -log4cpp::Category& createLogger(int rank, int threadNum, bool verbose) { - std::string loggerName = "Slave" + boost::lexical_cast(rank); - if (threadNum >= 0) { - loggerName += "_" + boost::lexical_cast(threadNum); - } - log4cpp::Category& logger = log4cpp::Category::getInstance(loggerName); - logger.setPriority(verbose ? log4cpp::Priority::DEBUG : log4cpp::Priority::INFO); - return logger; -} - -void parseProtobufMessage(const std::string& buffer, google::protobuf::Message& message) { - std::istringstream iss(buffer, std::ios::binary); - google::protobuf::io::IstreamInputStream isis(&iss); - google::protobuf::io::CodedInputStream cis(&isis); - cis.SetTotalBytesLimit(buffer.size()+1, buffer.size()+1); - if (!message.ParseFromCodedStream(&cis)) { - throw std::runtime_error("Failed to parse message"); - } -} - -void writeInputFile(const messages::Task::InputFile& inputFile, const boost::filesystem::path& dir) { - if (!inputFile.has_data()) { - throw std::runtime_error("Data is expected"); - } - switch (inputFile.preprocessor()) { - case messages::Task_InputFile_PreProcessor_NONE: - { - boost::filesystem::ofstream ofs(dir / inputFile.name(), std::ios::binary); - ofs << inputFile.data(); - } - break; - case messages::Task_InputFile_PreProcessor_ARCHIVE_UNZIP: - itesla::io::unzipMem(inputFile.data(), dir); - break; - case messages::Task_InputFile_PreProcessor_FILE_GUNZIP: - itesla::io::gunzipMem(inputFile.data(), dir / inputFile.name().substr(0, inputFile.name().size()-3)); - break; - default: - throw std::runtime_error("Unknown pre-processor"); - } -} - -boost::filesystem::path toExplodedArchiveDir(const boost::filesystem::path& archiveFile) { - return archiveFile.parent_path() / (archiveFile.filename().string() + ".exploded"); -} - -void explodeInputFileArchive(messages::Task_InputFile_PreProcessor preProcessor, const boost::filesystem::path& archiveFile) { - switch (preProcessor) { - case messages::Task_InputFile_PreProcessor_NONE: - // nothing to explode... - break; - case messages::Task_InputFile_PreProcessor_ARCHIVE_UNZIP: - { - boost::filesystem::path explodedArchiveDir = toExplodedArchiveDir(archiveFile); - boost::filesystem::remove_all(explodedArchiveDir); - boost::filesystem::create_directory(explodedArchiveDir); - itesla::io::unzipFile(archiveFile, explodedArchiveDir); - } - break; - case messages::Task_InputFile_PreProcessor_FILE_GUNZIP: - { - boost::filesystem::path explodedArchiveDir = toExplodedArchiveDir(archiveFile); - boost::filesystem::remove_all(explodedArchiveDir); - boost::filesystem::create_directory(explodedArchiveDir); - itesla::io::gunzipFile(archiveFile, explodedArchiveDir); - } - break; - default: - throw std::runtime_error("Unknown pre-processor"); - } -} - -std::mutex explodedArchiveMutex; - -void createSymbLinkToInputFile(messages::Task_InputFile_PreProcessor preProcessor, const boost::filesystem::path& file, const boost::filesystem::path& dir) { - if (!boost::filesystem::exists(dir) || !boost::filesystem::is_directory(dir)) { - throw std::runtime_error(dir.string() + " does not exist or is not a directory"); - } - switch (preProcessor) { - case messages::Task_InputFile_PreProcessor_NONE: - boost::filesystem::create_symlink(file, dir / file.filename().string()); - break; - case messages::Task_InputFile_PreProcessor_ARCHIVE_UNZIP: - case messages::Task_InputFile_PreProcessor_FILE_GUNZIP: - { - boost::filesystem::path explodedArchiveDir = toExplodedArchiveDir(file); - { - // lock to avoid 2 worker threads to explode the archive at the same time - std::lock_guard lock(explodedArchiveMutex); - explodeInputFileArchive(preProcessor, file); - } - // create one symbolic link for each file of the exploded archive - for (boost::filesystem::directory_iterator endDirIt, it(explodedArchiveDir); it != endDirIt; ++it) { - boost::filesystem::path p = it->path(); - boost::filesystem::create_symlink(p, dir / p.filename().string()); - } - } - break; - default: - throw std::runtime_error("Unknown pre-processor"); - } -} - -class CommunicationManager { -public: - - struct WorkerThreadContext { - WorkerThreadContext(int threadNum) - : _threadNum(threadNum), - _lengthRequest(MPI_REQUEST_NULL), - _bufferRequest(MPI_REQUEST_NULL) {} - WorkerThreadContext(const WorkerThreadContext&) = delete; - WorkerThreadContext& operator=(const WorkerThreadContext&) = delete; - - const int _threadNum; - - int _length; - MPI_Request _lengthRequest; - - std::string _buffer; - MPI_Request _bufferRequest; - - std::mutex _mutexCond; - std::condition_variable _cond; - }; - - struct MpiThreadContext { - MpiThreadContext(int cores, const boost::filesystem::path& localDir, bool verbose, const boost::filesystem::path& archiveDir) - : _cores(cores), - _localDir(localDir), - _verbose(verbose), - _archiveDir(archiveDir), - _rank(-1), - _abortRequested(false), - _step(Step::COMMON_FILES_BCAST) - { - _stopRequested.reserve(_cores); - _stopped.reserve(_cores); - for (int i = 0; i < _cores; i++) { - _stopRequested.push_back(false); - _stopped.push_back(false); - } - } - MpiThreadContext(const MpiThreadContext&) = delete; - MpiThreadContext& operator=(const MpiThreadContext&) = delete; - - int _cores; - boost::filesystem::path _localDir; - bool _verbose; - boost::filesystem::path _archiveDir; - - int _rank; - std::mutex _startedMutex; - std::condition_variable _startedCond; - - std::mutex _receivingContextsMutex; - std::vector > _receivingContexts; - - std::mutex _sendingContextsMutex; - std::vector > _sendingContexts; - - bool isWorkerThreadStopRequested(int threadNum); - void requestWorkerThreadStop(int threadNum); - void cancelWorkerThreadStopRequest(int threadNum); - - void workerThreadStopped(int threadNum); - bool areAllWorkerThreadsStopped(); - void resetWorkerThreadsStopStatus(); - - bool isAbortRequested(); - void requestAbort(); - - void waitForJobInitialization(int jobId); - void notifyJobInitialization(int jobId); - - bool receiveFromMaster(const std::shared_ptr& receivingContext); - void sendToMaster(const std::shared_ptr& sendingContext); - - std::mutex _stopRequestMutex; - std::vector _stopRequested; - - std::mutex _stopMutex; - std::vector _stopped; - - std::mutex _abortMutex; - bool _abortRequested; - - std::set _initializedJobs; - std::mutex _initializedJobsMutex; - std::condition_variable _initializedJobsCond; - - Step _step; - }; - - CommunicationManager(int cores, const boost::filesystem::path& localDir, bool verbose, const boost::filesystem::path& archiveDir); - CommunicationManager(const CommunicationManager&) = delete; - CommunicationManager& operator=(const CommunicationManager&) = delete; - - void start(int& rank); - void wait(); - -private: - static const int TIMEOUT; - - static void mpiThread(const std::shared_ptr& MpiThreadContext); - static void workerThread(const std::shared_ptr& mpiThreadContext, int threadNum); - static void commonFilesBroadcastStep(const std::shared_ptr& mpiThreadContext, log4cpp::Category& logger); - static void tasksExecutionStep(const std::shared_ptr& mpiThreadContext, log4cpp::Category& logger); - - std::shared_ptr _mpiThreadContext; - std::shared_ptr _mpiThread; -}; - -const int CommunicationManager::TIMEOUT = 10; - -bool CommunicationManager::MpiThreadContext::isWorkerThreadStopRequested(int threadNum) { - std::lock_guard lock(_stopRequestMutex); - return _stopRequested[threadNum]; -} - -void CommunicationManager::MpiThreadContext::requestWorkerThreadStop(int threadNum) { - std::lock_guard lock(_stopRequestMutex); - _stopRequested[threadNum] = true; -} - -void CommunicationManager::MpiThreadContext::cancelWorkerThreadStopRequest(int threadNum) { - std::lock_guard lock(_stopRequestMutex); - _stopRequested[threadNum] = false; -} - -void CommunicationManager::MpiThreadContext::workerThreadStopped(int threadNum) { - std::lock_guard lock(_stopMutex); - _stopped[threadNum] = true; -} - -bool CommunicationManager::MpiThreadContext::areAllWorkerThreadsStopped() { - std::lock_guard lock(_stopMutex); - for (std::vector::const_iterator it = _stopped.begin(); it != _stopped.end(); it++) { - if (!*it) { - return false; - } - } - return true; -} - -void CommunicationManager::MpiThreadContext::resetWorkerThreadsStopStatus() { - std::lock_guard lock(_stopMutex); - for (size_t i = 0; i < _stopped.size(); i++) { - _stopped[i] = false; - } -} - -bool CommunicationManager::MpiThreadContext::isAbortRequested() { - std::lock_guard lock(_abortMutex); - return _abortRequested; -} - - -void CommunicationManager::MpiThreadContext::requestAbort() { - std::lock_guard lock(_abortMutex); - _abortRequested = true; -} - -void CommunicationManager::MpiThreadContext::waitForJobInitialization(int jobId) { - while (true) { - std::unique_lock initializedJobsLock(_initializedJobsMutex); - if (_initializedJobs.count(jobId)) { - break; - } - _initializedJobsCond.wait(initializedJobsLock); - } -} - -void CommunicationManager::MpiThreadContext::notifyJobInitialization(int jobId) { - std::unique_lock initializedJobsLock(_initializedJobsMutex); - _initializedJobs.insert(jobId); - _initializedJobsCond.notify_all(); -} - -bool CommunicationManager::MpiThreadContext::receiveFromMaster(const std::shared_ptr& receivingContext) { - std::unique_lock lockCond(receivingContext->_mutexCond); - { - std::lock_guard receivingContextsLock(_receivingContextsMutex); - _receivingContexts.push_back(receivingContext); - } - receivingContext->_cond.wait(lockCond); - if (isWorkerThreadStopRequested(receivingContext->_threadNum)) { - cancelWorkerThreadStopRequest(receivingContext->_threadNum); - return false; - } else { - return true; - } -} - -void CommunicationManager::MpiThreadContext::sendToMaster(const std::shared_ptr& sendingContext) { - std::unique_lock lockCond(sendingContext->_mutexCond); - { - std::lock_guard sendingContextsLock(_sendingContextsMutex); - _sendingContexts.push_back(sendingContext); - } - sendingContext->_cond.wait(lockCond); -} - -CommunicationManager::CommunicationManager(int cores, const boost::filesystem::path& localDir, bool verbose, const boost::filesystem::path& archiveDir) - : _mpiThreadContext(new MpiThreadContext(cores, localDir, verbose, archiveDir)) -{} - -void CommunicationManager::start(int& rank) { - _mpiThread.reset(new std::thread(&CommunicationManager::mpiThread, _mpiThreadContext)); - std::unique_lock startedLock(_mpiThreadContext->_startedMutex); - _mpiThreadContext->_startedCond.wait(startedLock); - rank = _mpiThreadContext->_rank; -} - -void CommunicationManager::wait() { - _mpiThread->join(); - _mpiThread.reset(); -} - -std::string chunkFileName(const std::string& fileName, int chunk) { - return fileName + ".chunk" + boost::lexical_cast(chunk); -} - -void CommunicationManager::commonFilesBroadcastStep(const std::shared_ptr& mpiThreadContext, log4cpp::Category& logger) { - - boost::filesystem::path commonDir = itesla::slave::commonDir(mpiThreadContext->_localDir, mpiThreadContext->_rank); - - while (true) { - int length; - if (MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Bcast error"); - } - // a special length message means the slave must change its state - if (isSpecialLength(length)) { - mpiThreadContext->_step = specialLength2step(length); - break; - } - std::string buffer; - buffer.resize(length); - if (MPI_Bcast(&buffer[0], buffer.size(), MPI_BYTE, 0, MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Bcast error"); - } - - // decode the common file message - messages::CommonFile commonFile; - parseProtobufMessage(buffer, commonFile); - - // write common file into the common directory - logger.debugStream() << "receiving chunk " << commonFile.chunk() << " of run scoped file '" << commonFile.name() << "'" << log4cpp::eol; - - { - boost::filesystem::ofstream ofs(commonDir / chunkFileName(commonFile.name(), commonFile.chunk()) , std::ios::binary); - ofs << commonFile.data(); - } - - // if last chunk concatenate everything - if (commonFile.last()) { - logger.debugStream() << "assembling the " << commonFile.chunk() << " chunks of run scoped file '" << commonFile.name() << "'" << log4cpp::eol; - boost::filesystem::path concFile = commonDir / commonFile.name(); - { - boost::filesystem::ofstream ofsConc(concFile, std::ios::binary); - for (int i = 0; i <= commonFile.chunk(); i++) { - boost::filesystem::path chunkFile = commonDir / chunkFileName(commonFile.name(), i); - boost::filesystem::ifstream ifsChunk(chunkFile, std::ios::binary); - ofsConc << ifsChunk.rdbuf(); - boost::filesystem::remove(chunkFile); - } - } - } - - // unblock the master - if (MPI_Barrier(MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Barrier error"); - } - } -} - -void CommunicationManager::tasksExecutionStep(const std::shared_ptr& mpiThreadContext, log4cpp::Category& logger) { - - mpiThreadContext->resetWorkerThreadsStopStatus(); - - // create one worker thread per core - std::thread workers[mpiThreadContext->_cores]; - for (int threadNum = 0; threadNum < mpiThreadContext->_cores; threadNum++) { - workers[threadNum] = std::thread(CommunicationManager::workerThread, mpiThreadContext, threadNum); - } - - std::chrono::system_clock::time_point t1 = std::chrono::system_clock::now(); - - // listen to workers threads requests - while (!mpiThreadContext->areAllWorkerThreadsStopped()) { - bool sleep = true; - - if (mpiThreadContext->isAbortRequested()) { - throw std::runtime_error("Abort requested by a worker thread"); - } - - { - std::lock_guard receivingContextsLock(mpiThreadContext->_receivingContextsMutex); - - if (mpiThreadContext->_receivingContexts.size() > 0) { - for (std::vector >::iterator it = mpiThreadContext->_receivingContexts.begin(); - it != mpiThreadContext->_receivingContexts.end();) { - const std::shared_ptr& receivingContext = *it; - - bool remove = false; - - if (receivingContext->_bufferRequest != MPI_REQUEST_NULL) { - // check if the data message has been received - int flag; - MPI_Status status; - if (MPI_Test(&receivingContext->_bufferRequest, &flag, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Test error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - if (flag) { - // if yes notify the worker thread... - { - std::unique_lock lockCond(receivingContext->_mutexCond); - receivingContext->_cond.notify_one(); - } - remove = true; - } - } else { - // receive length message - if (receivingContext->_lengthRequest == MPI_REQUEST_NULL) { - if (MPI_Irecv(&receivingContext->_length, 1, MPI_INT, 0, JOB_LENGTH_TAG + receivingContext->_threadNum, MPI_COMM_WORLD, &receivingContext->_lengthRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Irecv error"); - } - } - - // check if the length message has been received - int flag; - MPI_Status status; - if (MPI_Test(&receivingContext->_lengthRequest, &flag, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Test error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - if (flag) { - // length message has been received - if (isSpecialLength(receivingContext->_length)) { - - mpiThreadContext->_step = specialLength2step(receivingContext->_length); - - // a special length message means slave must change its state, so stop worker threads - mpiThreadContext->requestWorkerThreadStop(receivingContext->_threadNum); - - // notify the worker thread - { - std::unique_lock lockCond(receivingContext->_mutexCond); - receivingContext->_cond.notify_one(); - } - remove = true; - } else { - // receive the data message - receivingContext->_buffer.resize(receivingContext->_length); - if (MPI_Irecv(&(receivingContext->_buffer[0]), receivingContext->_length, MPI_BYTE, 0, JOB_BUFFER_TAG + receivingContext->_threadNum, MPI_COMM_WORLD, &receivingContext->_bufferRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Recv error"); - } - } - } - } - - if (remove) { - it = mpiThreadContext->_receivingContexts.erase(it); - } else { - it++; - } - } - - sleep = false; - } - } - - { - std::lock_guard sendingContextsLock(mpiThreadContext->_sendingContextsMutex); - - if (mpiThreadContext->_sendingContexts.size() > 0) { - for (std::vector >::iterator it = mpiThreadContext->_sendingContexts.begin(); - it != mpiThreadContext->_sendingContexts.end();) { - const std::shared_ptr& sendingContext = *it; - - bool remove = false; - - // send the length and data message - if (sendingContext->_bufferRequest == MPI_REQUEST_NULL) { - sendingContext->_length = sendingContext->_buffer.size(); - if (MPI_Isend(&sendingContext->_length, 1, MPI_INT, 0, JOB_RESULT_LENGTH_TAG + sendingContext->_threadNum, MPI_COMM_WORLD, &sendingContext->_lengthRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Isend error"); - } - if (MPI_Isend((void*) &(sendingContext->_buffer[0]), sendingContext->_buffer.size(), MPI_BYTE, 0, JOB_RESULT_BUFFER_TAG + sendingContext->_threadNum, MPI_COMM_WORLD, &sendingContext->_bufferRequest) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Isend error"); - } - } else { - int flag; - MPI_Status status; - // check that data message sent is complete - if (MPI_Test(&sendingContext->_bufferRequest, &flag, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Test error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - if (flag) { - // if data message sent is complete, length message is too, call MPI_Wait to avoid memory leak - if (MPI_Wait(&sendingContext->_lengthRequest, &status) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Wait error (" + boost::lexical_cast(status.MPI_ERROR) + ")"); - } - // notify the worker thread - { - std::unique_lock lockCond(sendingContext->_mutexCond); - sendingContext->_cond.notify_one(); - } - remove = true; - } - } - - if (remove) { - it = mpiThreadContext->_sendingContexts.erase(it); - } else { - it++; - } - } - - sleep = false; - } - } - - if (sleep) { - std::chrono::system_clock::time_point t2 = std::chrono::system_clock::now(); - float durationInS = std::chrono::duration_cast(t2 - t1).count(); - if (durationInS > 30 * 60) { // every 30 minutes - t1 = std::chrono::system_clock::now(); - boost::filesystem::space_info space = boost::filesystem::space(mpiThreadContext->_localDir); - logger.infoStream() << space.available / 1024 << "k/" << space.capacity / 1024 - << "k available on " << mpiThreadContext->_localDir.string() - << log4cpp::eol; - } - usleep(1000* TIMEOUT); - } - } - - // master/slaves synchronization - if (MPI_Barrier(MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Barrier error"); - } - - // remove job directories - { - std::lock_guard initializedJobsLock(mpiThreadContext->_initializedJobsMutex); - for (std::set::const_iterator it = mpiThreadContext->_initializedJobs.begin(); - it != mpiThreadContext->_initializedJobs.end(); - it++) { - int jobId = *it; - boost::filesystem::path jobDir = itesla::slave::jobDir(mpiThreadContext->_localDir, mpiThreadContext->_rank, jobId); - boost::filesystem::remove_all(jobDir); - } - mpiThreadContext->_initializedJobs.clear(); - } - - for (int threadNum = 0; threadNum < mpiThreadContext->_cores; threadNum++) { - workers[threadNum].join(); - } -} - -void CommunicationManager::mpiThread(const std::shared_ptr& mpiThreadContext) { - try { - itesla::mpi::initThreadFunneled(); - - // OpenMPI bug... unset SIGCHLD handler - signal(SIGCHLD, SIG_DFL); - - if (MPI_Comm_rank(MPI_COMM_WORLD, &(mpiThreadContext->_rank)) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Comm_rank error"); - } - if (mpiThreadContext->_rank == 0) { - throw std::runtime_error("Slave (computation manager) must have MPI rank != 0"); - } - - log4cpp::Category& logger = createLogger(mpiThreadContext->_rank, -1, mpiThreadContext->_verbose); - - boost::filesystem::space_info space = boost::filesystem::space(mpiThreadContext->_localDir); - logger.infoStream() << "started on " << itesla::mpi::processorName() << " (" << space.available / 1024 << "k/" << space.capacity / 1024 - << "k available on " << mpiThreadContext->_localDir.string() << ")" << log4cpp::eol; - - // start synchronization - if (MPI_Barrier(MPI_COMM_WORLD) != MPI_SUCCESS) { - throw std::runtime_error("MPI_Barrier error"); - } - - { - std::unique_lock startedLock(mpiThreadContext->_startedMutex); - mpiThreadContext->_startedCond.notify_one(); - } - - while (mpiThreadContext->_step != Step::SHUTDOWN) { - switch (mpiThreadContext->_step) { - case Step::COMMON_FILES_BCAST: - logger.debugStream() << "switch to " << str(Step::COMMON_FILES_BCAST) << log4cpp::eol; - // start common files broadcast step - commonFilesBroadcastStep(mpiThreadContext, logger); - break; - case Step::TASKS_EXECUTION: - logger.debugStream() << "switch to " << str(Step::TASKS_EXECUTION) << log4cpp::eol; - // start tasks execution step - tasksExecutionStep(mpiThreadContext, logger); - break; - case Step::SHUTDOWN: - // nothing to do - break; - default: - throw std::runtime_error("Unknown step"); - } - } - - logger.debugStream() << "switch to " << str(Step::SHUTDOWN) << log4cpp::eol; - - if (MPI_Finalize() != MPI_SUCCESS) { - throw std::runtime_error("MPI_Finalize error"); - } - - logger.debugStream() << "stopped" << log4cpp::eol; - - } catch (const std::exception& e) { - log4cpp::Category::getRoot().fatalStream() << e.what() << log4cpp::eol; - MPI_Abort(MPI_COMM_WORLD, -1); - } catch (...) { - log4cpp::Category::getRoot().fatalStream() << "Unknown exception" << log4cpp::eol; - MPI_Abort(MPI_COMM_WORLD, -1); - } -} - -void CommunicationManager::workerThread(const std::shared_ptr& mpiThreadContext, int threadNum) { - try { - log4cpp::Category& logger = createLogger(mpiThreadContext->_rank, threadNum, mpiThreadContext->_verbose); - - boost::filesystem::path commonDir = itesla::slave::commonDir(mpiThreadContext->_localDir, mpiThreadContext->_rank); - - boost::filesystem::path workingDir = itesla::slave::workingDir(mpiThreadContext->_localDir, mpiThreadContext->_rank, threadNum); - boost::filesystem::remove_all(workingDir); - boost::filesystem::create_directory(workingDir); - - std::shared_ptr receivingContext(new CommunicationManager::WorkerThreadContext(threadNum)); - std::shared_ptr sendingContext(new CommunicationManager::WorkerThreadContext(threadNum)); - while (mpiThreadContext->receiveFromMaster(receivingContext)) { - std::chrono::system_clock::time_point t1 = std::chrono::system_clock::now(); - - // decode the job message - messages::Task task; - parseProtobufMessage(receivingContext->_buffer, task); - - // remove completed job directories - for (int i = 0; i < task.completedjobid_size(); i++) { - int jobId = task.completedjobid(i); - boost::filesystem::path jobDir = itesla::slave::jobDir(mpiThreadContext->_localDir, mpiThreadContext->_rank, jobId); - boost::filesystem::remove_all(jobDir); - } - - // create a directory to store job scoped files - boost::filesystem::path jobDir = itesla::slave::jobDir(mpiThreadContext->_localDir, mpiThreadContext->_rank, task.jobid()); - if (task.initjob()) { - boost::filesystem::remove_all(jobDir); - boost::filesystem::create_directory(jobDir); - for (int i = 0; i < task.inputfile_size(); i++) { - messages::Task_InputFile inputFile = task.inputfile(i); - if (inputFile.scope() == messages::Task_InputFile_Scope_JOB) { - logger.debugStream() << "receiving job scoped file '" << inputFile.name() << "'" << log4cpp::eol; - boost::filesystem::path jobLevelFile = jobDir / inputFile.name(); - { - boost::filesystem::ofstream ofs(jobLevelFile, std::ios::binary); - ofs << inputFile.data(); - } - } - } - mpiThreadContext->notifyJobInitialization(task.jobid()); - } else { - mpiThreadContext->waitForJobInitialization(task.jobid()); - } - - // write input files into the working directory - for (int i = 0; i < task.inputfile_size(); i++) { - messages::Task::InputFile inputFile = task.inputfile(i); - switch (inputFile.scope()) { - case messages::Task_InputFile_Scope_RUN: - { - boost::filesystem::path path = commonDir / inputFile.name(); - if (boost::filesystem::exists(path)) { - createSymbLinkToInputFile(inputFile.preprocessor(), path, workingDir); - } else { - logger.errorStream() << "Run scoped file '" << path.string() << "' not found" << log4cpp::eol; - } - } - break; - - case messages::Task_InputFile_Scope_JOB: - { - boost::filesystem::path path = jobDir / inputFile.name(); - if (boost::filesystem::exists(path)) { - createSymbLinkToInputFile(inputFile.preprocessor(), path, workingDir); - } else { - logger.errorStream() << "Job scoped file '" << path.string() << "' not found" << log4cpp::eol; - } - } - break; - - case messages::Task_InputFile_Scope_TASK: - logger.debugStream() << "receiving task scoped file '" << inputFile.name() << "'" << log4cpp::eol; - writeInputFile(inputFile, workingDir); - break; - - default: - throw std::runtime_error("Unexpected input file scope"); - } - } - - // update environment variables - std::map env = itesla::io::getEnv(); - std::map env2; - env2["PATH"] = env["PATH"]; - env2["LD_LIBRARY_PATH"] = env["LD_LIBRARY_PATH"]; - for (int i = 0; i < task.env().variable_size(); i++) { - messages::Task::Variable variable = task.env().variable(i); - if (variable.name() == "PATH" || variable.name() == "LD_LIBRARY_PATH") { - env2[variable.name()] = variable.value() + ":" + env2[variable.name()]; - } else { - env2[variable.name()] = variable.value(); - } - } - - // because some programs rely on it and in case if it not defined used /tmp by default - env2["TMPDIR"] = workingDir.string(); - - // run commands - int exitCode = 0; - std::vector commandsDuration; - commandsDuration.reserve(task.command_size()); - std::string stdOutFileName = task.cmdid() + "_" + boost::lexical_cast(task.index()) + ".out"; - boost::filesystem::path stdOutPath = workingDir / stdOutFileName; - for (int i = 0; i < task.command_size(); i++) { - messages::Task::Command command = task.command(i); - std::string cmdStr = command.program(); - for (int j = 0; j < command.argument_size(); j++) { - cmdStr += " "; - cmdStr += command.argument(j); - } - int timeout = command.has_timeout() ? command.timeout() : -1; - logger.debugStream() << "executing '" << cmdStr << "' with a " << timeout << "s timeout" << log4cpp::eol; - std::chrono::system_clock::time_point t3 = std::chrono::system_clock::now(); - exitCode = itesla::io::systemSafe(cmdStr, workingDir, env2, stdOutPath, timeout, logger); - std::chrono::system_clock::time_point t4 = std::chrono::system_clock::now(); - std::chrono::duration commandDuration = std::chrono::duration_cast>(t4 - t3); - commandsDuration.push_back(commandDuration.count()); - if (exitCode != 0) { - break; - } - } - - if (exitCode != 0 && !mpiThreadContext->_archiveDir.empty()) { - std::string archiveName = "job-" + boost::lexical_cast(task.jobid()); - boost::filesystem::path archiveZipFile = mpiThreadContext->_archiveDir / (archiveName + ".zip"); - itesla::io::zipDir(workingDir, archiveZipFile, archiveName); - } - - // create a result message - messages::TaskResult result; - result.set_exitcode(exitCode); - - // compute working directory size - size_t workingDataSize = itesla::io::dirSize(workingDir); - result.set_workingdatasize(workingDataSize); - - // pack standard output in the result message - if (boost::filesystem::exists(stdOutPath)) { - std::string stdOutGzFileName = stdOutFileName + ".gz"; - logger.debugStream() << "sending file '" << stdOutGzFileName << "'" << log4cpp::eol; - messages::TaskResult::OutputFile* stdOutFile = result.add_outputfile(); - stdOutFile->set_name(stdOutGzFileName); - stdOutFile->set_data(itesla::io::gzipMem(stdOutPath, logger)); - } - // pack output files in the result message - for (int i = 0; i < task.outputfile_size(); i++) { - const messages::Task::OutputFile& outputFile = task.outputfile(i); - boost::filesystem::path path = workingDir / outputFile.name(); - if (boost::filesystem::exists(path)) { - std::string outputFileName; - std::string outputFileData; - switch (outputFile.postprocessor()) { - case messages::Task_OutputFile_PostProcessor_NONE: - outputFileName = outputFile.name(); - outputFileData = itesla::io::readFile(path); - break; - case messages::Task_OutputFile_PostProcessor_FILE_GZIP: - outputFileName = outputFile.name() + ".gz"; - outputFileData = itesla::io::gzipMem(path, logger); - break; - default: - throw std::runtime_error("Unknown pre-processor"); - } - - logger.debugStream() << "sending file '" << outputFileName << "'" << log4cpp::eol; - - messages::TaskResult::OutputFile* resultOutputFile = result.add_outputfile(); - resultOutputFile->set_name(outputFileName); - resultOutputFile->set_data(outputFileData); - } else { - if (exitCode == 0) { - logger.errorStream() << "output file '" << outputFile.name() << "' not found" << log4cpp::eol; - } - } - } - for (std::vector::const_iterator it = commandsDuration.begin(); - it != commandsDuration.end(); - it++) { - result.add_commandduration((long) (*it * std::pow(10, 3))); // in ms - } - std::chrono::system_clock::time_point t2 = std::chrono::system_clock::now(); - std::chrono::duration taskDuration = std::chrono::duration_cast>(t2 - t1); - result.set_taskduration((long) (taskDuration.count() * std::pow(10, 3))); // in ms - - // encode the result message - std::ostringstream output(std::ios::binary); - if (!result.SerializeToOstream(&output)) { - throw std::runtime_error("Failed to serialize result"); - } - - // send back the result message to the master - sendingContext->_buffer = output.str(); - mpiThreadContext->sendToMaster(sendingContext); - - // clean working dir - itesla::io::cleanDir(workingDir); - } - - boost::filesystem::remove_all(workingDir); - - mpiThreadContext->workerThreadStopped(threadNum); - - } catch (const std::exception& e) { - log4cpp::Category::getRoot().fatalStream() << e.what() << log4cpp::eol; - mpiThreadContext->requestAbort(); - } catch (...) { - log4cpp::Category::getRoot().fatalStream() << "Unknown exception" << log4cpp::eol; - mpiThreadContext->requestAbort(); - } -} - -} - -} - -int main(int argc, char *argv[]) { - try { - GOOGLE_PROTOBUF_VERIFY_VERSION; - - log4cpp::Category::getRoot().setPriority(log4cpp::Priority::ERROR); - log4cpp::Appender* consoleAppender = itesla::io::createConsoleLogAppender(); - consoleAppender->setThreshold(log4cpp::Priority::ERROR); - log4cpp::Category::getRoot().addAppender(consoleAppender); - - boost::program_options::options_description desc("Allowed options"); - desc.add_options() - ("tmp-dir", boost::program_options::value(), "local temporary directory") - ("archive-dir", boost::program_options::value(), "archive directory to store failing jobs") - ("verbose", "verbose mode") - ("log-file", boost::program_options::value(), "log file") - ("cores", boost::program_options::value(), "number of cores"); - - boost::program_options::variables_map vm; - boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); - boost::program_options::notify(vm); - if (!vm.count("tmp-dir")) { - throw std::runtime_error("tmp-dir option is not set"); - } - boost::filesystem::path localDir(vm["tmp-dir"].as()); - if (!boost::filesystem::exists(localDir) || !boost::filesystem::is_directory(localDir)) { - throw std::runtime_error("local directory " + localDir.string() + " does not exist or is not a directory"); - } - - boost::filesystem::path archiveDir; - if (vm.count("archive-dir")) { - archiveDir = boost::filesystem::path(vm["archive-dir"].as()); - if (!boost::filesystem::exists(archiveDir) || !boost::filesystem::is_directory(archiveDir)) { - throw std::runtime_error("archive directory " + archiveDir.string() + " does not exist or is not a directory"); - } - } - - bool verbose = vm.count("verbose"); - if (verbose) { - log4cpp::Category::getRoot().setPriority(log4cpp::Priority::DEBUG); - } - - if (!vm.count("cores")) { - throw std::runtime_error("cores option is not set"); - } - int cores = vm["cores"].as(); - - if (vm.count("log-file")) { - std::string logFile = vm["log-file"].as(); - log4cpp::Category::getRoot().addAppender(itesla::io::createFileLogAppender(logFile)); - } - - std::shared_ptr manager(new itesla::slave::CommunicationManager(cores, localDir, verbose, archiveDir)); - int rank; - manager->start(rank); - - boost::filesystem::path commonDir = itesla::slave::commonDir(localDir, rank); - boost::filesystem::remove_all(commonDir); - boost::filesystem::create_directory(commonDir); - - manager->wait(); - - boost::filesystem::remove_all(commonDir); - - google::protobuf::ShutdownProtobufLibrary(); - - } catch (const std::exception& e) { - log4cpp::Category::getRoot().fatalStream() << e.what() << log4cpp::eol; - return -1; - } catch (...) { - log4cpp::Category::getRoot().fatalStream() << "Unknown exception" << log4cpp::eol; - return -1; - } - - return 0; -} - diff --git a/network-merge/pom.xml b/network-merge/pom.xml index 2b5a0b68..aba85018 100644 --- a/network-merge/pom.xml +++ b/network-merge/pom.xml @@ -21,16 +21,30 @@ Network merge + + com.google.auto.service + auto-service + + + commons-cli + commons-cli + eu.itesla_project case-repository - ${project.version} + + + eu.itesla_project + commons + + + eu.itesla_project + computation-local eu.itesla_project loadflow-api - ${project.version} - \ No newline at end of file + diff --git a/offline-workflow/pom.xml b/offline-workflow/pom.xml index db3d97ec..8a452dcf 100644 --- a/offline-workflow/pom.xml +++ b/offline-workflow/pom.xml @@ -54,13 +54,16 @@ ${project.groupId} iidm-network-test - ${project.version} test ${project.groupId} iidm-network-impl - ${project.version} + test + + + eu.itesla_project + graph test diff --git a/pom.xml b/pom.xml index 1c2fff0c..9823ae36 100644 --- a/pom.xml +++ b/pom.xml @@ -21,14 +21,8 @@ ampl-export - case-repository cim1-model cim1-import - commons - computation - computation-local - computation-mpi - contingency-api distribution dymola-integration entsoe-case-repository @@ -40,17 +34,10 @@ eurostag-step-up-transformer file-system-rules-db fpf-integration - graph histodb-client iidm-actions-contingencies-xml-client - iidm-converter-api iidm-ddb - iidm-network-api - iidm-network-impl - iidm-network-test - iidm-xml-converter - loadflow-api mcla-integration mmap-offline-db modelica-events-adder @@ -65,12 +52,9 @@ online-workflow pclfsim-integration sampling-integration - security-analysis - simulation-api ucte-import ucte-network wca-integration - computation-mpi-util @@ -123,6 +107,7 @@ 2.4 2.1.1 1.12 + 0.1-SNAPSHOT @@ -268,56 +253,32 @@ + - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - slf4j-simple - ${slf4j.version} + com.fasterxml.jackson.core + jackson-core + ${jackson.version} - org.slf4j - log4j-over-slf4j - ${slf4j.version} + com.google.auto.service + auto-service + ${autoservice.version} - ch.qos.logback - logback-classic - ${logback.version} + com.google.code.gson + gson + ${gson.version} com.google.guava guava ${guava.version} - - net.sf.trove4j - trove4j - ${trove4j.version} - - - org.apache.commons - commons-math3 - ${commonsmath3.version} - - - commons-io - commons-io - ${commonsio.version} - commons-cli commons-cli ${commonscli.version} - - commons-lang - commons-lang - ${commonslang.version} - commons-codec commons-codec @@ -329,20 +290,71 @@ ${commonsconfiguration.version} - org.apache.commons - commons-lang3 - ${commonslang3.version} + commons-io + commons-io + ${commonsio.version} + + + com.h2database + h2 + ${h2database.version} + + + com.h2database + h2-mvstore + ${h2database.version} + + + joda-time + joda-time + ${jodatime.version} + + + net.sf.json-lib + json-lib + jdk15 + ${jsonlib.version} net.sf.supercsv super-csv ${supercsv.version} + + net.sf.trove4j + trove4j + ${trove4j.version} + + + net.sourceforge.javacsv + javacsv + ${javacsv.version} + + + net.sourceforge.jmatio + jmatio + ${jmatio.version} + + + org.apache.commons + commons-math3 + ${commonsmath3.version} + org.apache.httpcomponents httpclient ${httpclient.version} + + org.apache.poi + poi-ooxml + ${poi.version} + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.gdata + ${gdata.version} + org.jboss.shrinkwrap shrinkwrap-api @@ -364,14 +376,14 @@ ${shrinkwrap.version} - joda-time - joda-time - ${jodatime.version} + org.jgrapht + jgrapht-core + ${jgrapht.version} - com.google.auto.service - auto-service - ${autoservice.version} + org.json + json + ${json.version} org.ow2.sirocco @@ -385,40 +397,105 @@ - com.fasterxml.jackson.core - jackson-core - ${jackson.version} + org.slf4j + slf4j-api + ${slf4j.version} + + - com.h2database - h2 - ${h2database.version} + eu.itesla_project + case-repository + ${ipstcore.version} - com.h2database - h2-mvstore - ${h2database.version} + eu.itesla_project + commons + ${ipstcore.version} - org.apache.servicemix.bundles - org.apache.servicemix.bundles.gdata - ${gdata.version} + eu.itesla_project + computation + ${ipstcore.version} - org.json - json - ${json.version} + eu.itesla_project + computation-local + ${ipstcore.version} - net.sourceforge.javacsv - javacsv - ${javacsv.version} + eu.itesla_project + contingency-api + ${ipstcore.version} - net.sourceforge.jmatio - jmatio - ${jmatio.version} + eu.itesla_project + graph + ${ipstcore.version} + + + eu.itesla_project + iidm-converter-api + ${ipstcore.version} + + + eu.itesla_project + iidm-network-api + ${ipstcore.version} + + + ${project.groupId} + iidm-network-impl + ${ipstcore.version} + + + eu.itesla_project + iidm-xml-converter + ${ipstcore.version} + + + eu.itesla_project + loadflow-api + ${ipstcore.version} + + + eu.itesla_project + security-analysis + ${ipstcore.version} + + + eu.itesla_project + simulation-api + ${ipstcore.version} + + + + + + - net.sf.json-lib - json-lib - jdk15 - ${jsonlib.version} + ch.qos.logback + logback-classic + ${logback.version} + runtime - org.apache.commons - commons-compress - ${commons-compress.version} + org.slf4j + log4j-over-slf4j + ${slf4j.version} + runtime - + + junit junit @@ -464,9 +549,15 @@ test - org.xmlunit - xmlunit-core - ${xmlunit.version} + org.slf4j + slf4j-simple + ${slf4j.version} + test + + + ${project.groupId} + iidm-network-test + ${ipstcore.version} test diff --git a/scripts/itools b/scripts/itools deleted file mode 100755 index ec650b2a..00000000 --- a/scripts/itools +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -if [ -z $JAVA_HOME ]; then - echo "JAVA_HOME is not defined" - exit -1 -fi - -installBinDir=$(dirname $(readlink -f $0)) -installDir=${installBinDir%/*} - -. $installDir/etc/itesla.conf - -args=($@) -for ((i=0; i<${#args[@]}; i++)); do - current=${args[i]} - next=${args[$((i+1))]} - case $current in - --config-name) - itesla_config_name=$next - unset args[i] - unset args[$((i+1))] - ;; - esac -done - -[ -n "$itesla_cache_dir" ] && options+="-Ditesla.cache.dir=$itesla_cache_dir" -[ -n "$itesla_config_dir" ] && options+=" -Ditesla.config.dir=$itesla_config_dir" -[ -n "$itesla_config_name" ] && options+=" -Ditesla.config.name=$itesla_config_name" -options+=" -Dlogback.configurationFile=" -[ -f "$itesla_config_dir/logback-cmdline.xml" ] && options+="$itesla_config_dir" || options+="$installDir/etc" -options+="/logback-cmdline.xml" - -$JAVA_HOME/bin/java \ --Xmx8G \ --cp "$installDir/share/java/*" \ -$options \ -eu.itesla_project.commons.tools.Main ${args[@]} diff --git a/security-analysis/pom.xml b/security-analysis/pom.xml deleted file mode 100644 index 1742ec42..00000000 --- a/security-analysis/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - 4.0.0 - - security-analysis - - Security analysis - - - - eu.itesla_project - iidm-network-api - ${project.version} - - - eu.itesla_project - loadflow-api - ${project.version} - - - eu.itesla_project - iidm-converter-api - ${project.version} - - - eu.itesla_project - contingency-api - ${project.version} - - - junit - junit - test - - - org.jboss.shrinkwrap - shrinkwrap-api - test - - - org.jboss.shrinkwrap - shrinkwrap-api-nio2 - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-base - test - - - org.jboss.shrinkwrap - shrinkwrap-impl-nio2 - test - - - org.slf4j - slf4j-simple - test - - - - \ No newline at end of file diff --git a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolation.java b/security-analysis/src/main/java/eu/itesla_project/security/LimitViolation.java deleted file mode 100644 index 4140e512..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolation.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.iidm.network.Country; -import eu.itesla_project.iidm.network.Identifiable; - -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class LimitViolation { - - private final Identifiable subject; - - private final LimitViolationType limitType; - - private final float limit; - - private final String limitName; - - private final float limitReduction; - - private final float value; - - private final Country country; - - private final float baseVoltage; - - public LimitViolation(Identifiable subject, LimitViolationType limitType, float limit, String limitName, float limitReduction, float value, Country country, float baseVoltage) { - this.subject = Objects.requireNonNull(subject); - this.limitType = Objects.requireNonNull(limitType); - this.limit = limit; - this.limitName = limitName; - this.limitReduction = limitReduction; - this.value = value; - this.country = country; - this.baseVoltage = baseVoltage; - } - - public LimitViolation(Identifiable subject, LimitViolationType limitType, float limit, String limitName, float value) { - this(subject, limitType, limit, limitName, 1, value, null, Float.NaN); - } - - public Identifiable getSubject() { - return subject; - } - - public LimitViolationType getLimitType() { - return limitType; - } - - public float getLimit() { - return limit; - } - - public String getLimitName() { - return limitName; - } - - public float getLimitReduction() { - return limitReduction; - } - - public float getValue() { - return value; - } - - public Country getCountry() { - return country; - } - - public float getBaseVoltage() { - return baseVoltage; - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationFilter.java b/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationFilter.java deleted file mode 100644 index c16a9c37..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationFilter.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; - -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * @author Geoffroy Jamgotchian - */ -public class LimitViolationFilter { - - private static final Set DEFAULT_VIOLATION_TYPES = null; - private static final float DEFAULT_MIN_BASE_VOLTAGE = 0f; - - private static Set checkViolationTypes(Set violationTypes) { - if (violationTypes != null && violationTypes.isEmpty()) { - throw new IllegalArgumentException("Bad violation types filter"); - } - return violationTypes; - } - - private static float checkMinBaseVoltage(float minBaseVoltage) { - if (Float.isNaN(minBaseVoltage) || minBaseVoltage < 0) { - throw new IllegalArgumentException("Bad min base voltage filter " + minBaseVoltage); - } - return minBaseVoltage; - } - - public static LimitViolationFilter load() { - return load(PlatformConfig.defaultConfig()); - } - - static LimitViolationFilter load(PlatformConfig platformConfig) { - LimitViolationFilter filter = new LimitViolationFilter(); - ModuleConfig moduleConfig = platformConfig.getModuleConfigIfExists("limit-violation-default-filter"); - if (moduleConfig != null) { - filter.setViolationTypes(moduleConfig.getEnumSetProperty("violationTypes", LimitViolationType.class, DEFAULT_VIOLATION_TYPES)); - filter.setMinBaseVoltage(moduleConfig.getFloatProperty("minBaseVoltage", DEFAULT_MIN_BASE_VOLTAGE)); - } - return filter; - } - - private Set violationTypes; - - private float minBaseVoltage; - - public LimitViolationFilter(Set violationTypes) { - this(violationTypes, DEFAULT_MIN_BASE_VOLTAGE); - } - - public LimitViolationFilter() { - this(DEFAULT_VIOLATION_TYPES, DEFAULT_MIN_BASE_VOLTAGE); - } - - public LimitViolationFilter(Set violationTypes, float minBaseVoltage) { - this.violationTypes = checkViolationTypes(violationTypes); - this.minBaseVoltage = checkMinBaseVoltage(minBaseVoltage); - } - - public Set getViolationTypes() { - return violationTypes; - } - - public LimitViolationFilter setViolationTypes(Set violationTypes) { - this.violationTypes = checkViolationTypes(violationTypes); - return this; - } - - public float getMinBaseVoltage() { - return minBaseVoltage; - } - - public LimitViolationFilter setMinBaseVoltage(float minBaseVoltage) { - this.minBaseVoltage = checkMinBaseVoltage(minBaseVoltage); - return this; - } - - public List apply(List violations) { - return violations.stream() - .filter(violation -> violationTypes == null || violationTypes.contains(violation.getLimitType())) - .filter(violation -> Float.isNaN(violation.getBaseVoltage()) || violation.getBaseVoltage() > minBaseVoltage) - .collect(Collectors.toList()); - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationType.java b/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationType.java deleted file mode 100644 index 6909e619..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationType.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -/** - * @author Geoffroy Jamgotchian - */ -public enum LimitViolationType { - CURRENT, - LOW_VOLTAGE, - HIGH_VOLTAGE -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationsResult.java b/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationsResult.java deleted file mode 100644 index e98bedc5..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/LimitViolationsResult.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import java.util.List; -import java.util.Objects; - -/** - * @author Mathieu Bague - */ -abstract class LimitViolationsResult { - - private final boolean computationOk; - - private final List limitViolations; - - private final List actionsTaken; - - public LimitViolationsResult(boolean computationOk, List limitViolations, List actionsTaken) { - this.computationOk = computationOk; - this.limitViolations = Objects.requireNonNull(limitViolations); - this.actionsTaken = Objects.requireNonNull(actionsTaken); - } - - public boolean isComputationOk() { - return computationOk; - } - - public List getLimitViolations() { - return limitViolations; - } - - public List getActionsTaken() { - return actionsTaken; - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/PostContingencyResult.java b/security-analysis/src/main/java/eu/itesla_project/security/PostContingencyResult.java deleted file mode 100644 index 48b27351..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/PostContingencyResult.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.contingency.Contingency; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class PostContingencyResult extends LimitViolationsResult { - - private final Contingency contingency; - - public PostContingencyResult(Contingency contingency, boolean computationOk, List limitViolations) { - this(contingency, computationOk, limitViolations, Collections.emptyList()); - } - - public PostContingencyResult(Contingency contingency, boolean computationOk, List limitViolations, List actionsTaken) { - super(computationOk, limitViolations, actionsTaken); - this.contingency = Objects.requireNonNull(contingency); - } - - public Contingency getContingency() { - return contingency; - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/PreContingencyResult.java b/security-analysis/src/main/java/eu/itesla_project/security/PreContingencyResult.java deleted file mode 100644 index d08d93a9..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/PreContingencyResult.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import java.util.Collections; -import java.util.List; - -/** - * @author Geoffroy Jamgotchian - * @author Mathieu Bague - */ -public class PreContingencyResult extends LimitViolationsResult { - - public PreContingencyResult(boolean computationOk, List limitViolations) { - this(computationOk, limitViolations, Collections.emptyList()); - } - - public PreContingencyResult(boolean computationOk, List limitViolations, List actionsTaken) { - super(computationOk, limitViolations, actionsTaken); - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/Security.java b/security-analysis/src/main/java/eu/itesla_project/security/Security.java deleted file mode 100644 index ef1b9795..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/Security.java +++ /dev/null @@ -1,356 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.commons.io.table.Column; -import eu.itesla_project.commons.io.table.TableFormatter; -import eu.itesla_project.commons.io.table.TableFormatterConfig; -import eu.itesla_project.commons.io.table.TableFormatterFactory; -import eu.itesla_project.iidm.network.*; -import org.nocrala.tools.texttablefmt.BorderStyle; -import org.nocrala.tools.texttablefmt.Table; - -import java.io.IOException; -import java.io.Writer; -import java.util.*; -import java.util.stream.Collectors; - -/** - * @author Geoffroy Jamgotchian - */ -public class Security { - - public Security() { - } - - public enum CurrentLimitType { - PATL, - TATL - } - - private static Country getCountry(TwoTerminalsConnectable branch, Terminal terminal) { - return terminal == branch.getTerminal1() ? branch.getTerminal1().getVoltageLevel().getSubstation().getCountry() - : branch.getTerminal2().getVoltageLevel().getSubstation().getCountry(); - } - - private static float getBaseVoltage(TwoTerminalsConnectable branch) { - return Math.max(branch.getTerminal1().getVoltageLevel().getNominalV(), - branch.getTerminal2().getVoltageLevel().getNominalV()); - } - - private static void checkCurrentLimits(Iterable branches, CurrentLimitType currentLimitType, - float limitReduction, List violations) { - for (TwoTerminalsConnectable branch : branches) { - switch (currentLimitType) { - case PATL: - if (branch.checkPermanentLimit1(limitReduction)) { - violations.add(new LimitViolation(branch, - LimitViolationType.CURRENT, - branch.getCurrentLimits1().getPermanentLimit(), - null, - limitReduction, - branch.getTerminal1().getI(), - getCountry(branch, branch.getTerminal1()), - getBaseVoltage(branch))); - } - if (branch.checkPermanentLimit2(limitReduction)) { - violations.add(new LimitViolation(branch, - LimitViolationType.CURRENT, - branch.getCurrentLimits2().getPermanentLimit(), - null, - limitReduction, - branch.getTerminal2().getI(), - getCountry(branch, branch.getTerminal2()), - getBaseVoltage(branch))); - } - break; - - case TATL: - TwoTerminalsConnectable.Overload o1 = branch.checkTemporaryLimits1(limitReduction); - if (o1 != null) { - violations.add(new LimitViolation(branch, - LimitViolationType.CURRENT, - o1.getPreviousLimit(), - o1.getTemporaryLimit().getName(), - limitReduction, - branch.getTerminal1().getI(), - getCountry(branch, branch.getTerminal1()), - getBaseVoltage(branch))); - } - TwoTerminalsConnectable.Overload o2 = branch.checkTemporaryLimits2(limitReduction); - if (o2 != null) { - violations.add(new LimitViolation(branch, - LimitViolationType.CURRENT, - o2.getPreviousLimit(), - o2.getTemporaryLimit().getName(), - limitReduction, - branch.getTerminal2().getI(), - getCountry(branch, branch.getTerminal2()), - getBaseVoltage(branch))); - } - break; - - default: - throw new AssertionError(); - } - } - } - - public static List checkLimits(Network network) { - return checkLimits(network, CurrentLimitType.PATL, 1f); - } - - public static List checkLimits(Network network, CurrentLimitType currentLimitType, float limitReduction) { - Objects.requireNonNull(network); - Objects.requireNonNull(currentLimitType); - //if (limitReduction <= 0 || limitReduction > 1) { - // allow to increase the limits - if (limitReduction <= 0) { - throw new IllegalArgumentException("Bad limit reduction " + limitReduction); - } - List violations = new ArrayList<>(); - checkCurrentLimits(network.getLines(), currentLimitType, limitReduction, violations); - checkCurrentLimits(network.getTwoWindingsTransformers(), currentLimitType, limitReduction, violations); - for (VoltageLevel vl : network.getVoltageLevels()) { - if (!Float.isNaN(vl.getLowVoltageLimit())) { - for (Bus b : vl.getBusView().getBuses()) { - if (!Float.isNaN(b.getV())) { - if (b.getV() < vl.getLowVoltageLimit()) { - violations.add(new LimitViolation(vl, LimitViolationType.LOW_VOLTAGE, vl.getLowVoltageLimit(), null, - 1, b.getV(), vl.getSubstation().getCountry(), vl.getNominalV())); - } - } - } - } - if (!Float.isNaN(vl.getHighVoltageLimit())) { - for (Bus b : vl.getBusView().getBuses()) { - if (!Float.isNaN(b.getV())) { - if (b.getV() > vl.getHighVoltageLimit()) { - violations.add(new LimitViolation(vl, LimitViolationType.HIGH_VOLTAGE, vl.getHighVoltageLimit(), null, - 1, b.getV(), vl.getSubstation().getCountry(), vl.getNominalV())); - } - } - } - } - } - return violations; - } - - public static String printLimitsViolations(Network network) { - return printLimitsViolations(network, LimitViolationFilter.load()); - } - - public static String printLimitsViolations(Network network, LimitViolationFilter filter) { - return printLimitsViolations(checkLimits(network), filter); - } - - public static String printLimitsViolations(List violations) { - return printLimitsViolations(violations, LimitViolationFilter.load()); - } - - public static String printLimitsViolations(List violations, LimitViolationFilter filter) { - Objects.requireNonNull(violations); - Objects.requireNonNull(filter); - List filteredViolations = filter.apply(violations); - if (filteredViolations.size() > 0) { - Collections.sort(filteredViolations, (o1, o2) -> o1.getSubject().getId().compareTo(o2.getSubject().getId())); - Table table = new Table(9, BorderStyle.CLASSIC_WIDE); - table.addCell("Country"); - table.addCell("Base voltage"); - table.addCell("Equipment (" + filteredViolations.size() + ")"); - table.addCell("Violation type"); - table.addCell("Violation name"); - table.addCell("value"); - table.addCell("limit"); - table.addCell("abs(value-limit)"); - table.addCell("charge %"); - for (LimitViolation violation : filteredViolations) { - table.addCell(violation.getCountry() != null ? violation.getCountry().name() : ""); - table.addCell(Float.isNaN(violation.getBaseVoltage()) ? "" : Float.toString(violation.getBaseVoltage())); - table.addCell(violation.getSubject().getId()); - table.addCell(violation.getLimitType().name()); - table.addCell(Objects.toString(violation.getLimitName(), "")); - table.addCell(Float.toString(violation.getValue())); - table.addCell(Float.toString(violation.getLimit()) + (violation.getLimitReduction() != 1f ? " * " + violation.getLimitReduction() : "")); - table.addCell(Float.toString(Math.abs(violation.getValue() - violation.getLimit() * violation.getLimitReduction()))); - table.addCell(Integer.toString(Math.round(Math.abs(violation.getValue()) / violation.getLimit() * 100f))); - } - return table.render(); - } - return null; - } - - public static void printPreContingencyViolations(SecurityAnalysisResult result, Writer writer, TableFormatterFactory formatterFactory, - LimitViolationFilter limitViolationFilter) { - Objects.requireNonNull(result); - Objects.requireNonNull(writer); - Objects.requireNonNull(formatterFactory); - try (TableFormatter formatter = formatterFactory.create(writer, - "Pre-contingency violations", - TableFormatterConfig.load(), - new Column("Action"), - new Column("Equipment"), - new Column("Violation type"), - new Column("Violation name"), - new Column("Value"), - new Column("Limit"), - new Column("Charge %"))) { - for (String action : result.getPreContingencyResult().getActionsTaken()) { - formatter.writeCell(action) - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell(); - } - List filteredLimitViolations = limitViolationFilter != null - ? limitViolationFilter.apply(result.getPreContingencyResult().getLimitViolations()) - : result.getPreContingencyResult().getLimitViolations(); - filteredLimitViolations.stream() - .sorted((o1, o2) -> o1.getSubject().getId().compareTo(o2.getSubject().getId())) - .forEach(violation -> { - try { - formatter.writeEmptyCell() - .writeCell(violation.getSubject().getId()) - .writeCell(violation.getLimitType().name()) - .writeCell(Objects.toString(violation.getLimitName(), "")) - .writeCell(violation.getValue()) - .writeCell(Float.toString(violation.getLimit()) + (violation.getLimitReduction() != 1f ? " * " + violation.getLimitReduction() : "")) - .writeCell(Math.round(Math.abs(violation.getValue()) / violation.getLimit() * 100f)); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - /** - * Used to identify a limit violation to avoid duplicated violation between pre and post contingency analysis - */ - private static class LimitViolationKey { - - private final String id; - private final LimitViolationType limitType; - private final float limit; - - public LimitViolationKey(String id, LimitViolationType limitType, float limit) { - this.id = Objects.requireNonNull(id); - this.limitType = Objects.requireNonNull(limitType); - this.limit = limit; - } - - @Override - public int hashCode() { - return Objects.hash(id, limitType, limit); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof LimitViolationKey) { - LimitViolationKey other = (LimitViolationKey) obj; - return id.equals(other.id) && limitType == other.limitType && limit == other.limit; - } - return false; - } - } - - private static LimitViolationKey toKey(LimitViolation violation) { - return new LimitViolationKey(violation.getSubject().getId(), violation.getLimitType(), violation.getLimit()); - } - - public static void printPostContingencyViolations(SecurityAnalysisResult result, Writer writer, TableFormatterFactory formatterFactory, - LimitViolationFilter limitViolationFilter) { - Objects.requireNonNull(result); - Objects.requireNonNull(writer); - Objects.requireNonNull(formatterFactory); - if (result.getPostContingencyResults().size() > 0) { - Set preContingencyViolations = result.getPreContingencyResult().getLimitViolations() - .stream() - .map(Security::toKey) - .collect(Collectors.toSet()); - - try (TableFormatter formatter = formatterFactory.create(writer, - "Post-contingency limit violations", - TableFormatterConfig.load(), - new Column("Contingency"), - new Column("Status"), - new Column("Action"), - new Column("Equipment"), - new Column("Violation type"), - new Column("Violation name"), - new Column("Value"), - new Column("Limit"), - new Column("Charge %"))) { - result.getPostContingencyResults() - .stream() - .sorted((o1, o2) -> o1.getContingency().getId().compareTo(o2.getContingency().getId())) - .forEach(postContingencyResult -> { - try { - // configured filtering - List filteredLimitViolations = limitViolationFilter != null - ? limitViolationFilter.apply(postContingencyResult.getLimitViolations()) - : postContingencyResult.getLimitViolations(); - - // pre-contingency violations filtering - List filteredLimitViolations2 = filteredLimitViolations.stream() - .filter(violation -> preContingencyViolations.isEmpty() || !preContingencyViolations.contains(toKey(violation))) - .collect(Collectors.toList()); - - if (filteredLimitViolations2.size() > 0 || !postContingencyResult.isComputationOk()) { - formatter.writeCell(postContingencyResult.getContingency().getId()) - .writeCell(postContingencyResult.isComputationOk() ? "converge" : "diverge") - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell(); - - for (String action : postContingencyResult.getActionsTaken()) { - formatter.writeEmptyCell() - .writeEmptyCell() - .writeCell(action) - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell(); - } - - filteredLimitViolations2.stream() - .sorted((o1, o2) -> o1.getSubject().getId().compareTo(o2.getSubject().getId())) - .forEach(violation -> { - try { - formatter.writeEmptyCell() - .writeEmptyCell() - .writeEmptyCell() - .writeCell(violation.getSubject().getId()) - .writeCell(violation.getLimitType().name()) - .writeCell(Objects.toString(violation.getLimitName(), "")) - .writeCell(violation.getValue()) - .writeCell(Float.toString(violation.getLimit()) + (violation.getLimitReduction() != 1f ? " * " + violation.getLimitReduction() : "")) - .writeCell(Math.round(Math.abs(violation.getValue()) / violation.getLimit() * 100f)); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysis.java b/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysis.java deleted file mode 100644 index 0b8c8d3e..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysis.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.contingency.ContingenciesProvider; -import eu.itesla_project.loadflow.api.LoadFlowParameters; - -import java.util.concurrent.CompletableFuture; - -/** - * @author Geoffroy Jamgotchian - */ -public interface SecurityAnalysis { - - CompletableFuture runAsync(ContingenciesProvider contingenciesProvider, String workingStateId, LoadFlowParameters parameters); - - CompletableFuture runAsync(ContingenciesProvider contingenciesProvider, String workingStateId); - - CompletableFuture runAsync(ContingenciesProvider contingenciesProvider); -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactory.java b/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactory.java deleted file mode 100644 index 0a245ffc..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.iidm.network.Network; - -/** - * @author Geoffroy Jamgotchian - */ -public interface SecurityAnalysisFactory { - - SecurityAnalysis create(Network network, ComputationManager computationManager, int priority); - -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactoryImpl.java b/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactoryImpl.java deleted file mode 100644 index 3e8deb84..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisFactoryImpl.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.commons.config.ComponentDefaultConfig; -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.loadflow.api.LoadFlowFactory; - -/** - * @author Geoffroy Jamgotchian - */ -public class SecurityAnalysisFactoryImpl implements SecurityAnalysisFactory { - @Override - public SecurityAnalysis create(Network network, ComputationManager computationManager, int priority) { - ComponentDefaultConfig defaultConfig = ComponentDefaultConfig.load(); - LoadFlowFactory loadFlowFactory = defaultConfig.newFactoryImpl(LoadFlowFactory.class); - return new SecurityAnalysisImpl(network, computationManager, loadFlowFactory); - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisImpl.java b/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisImpl.java deleted file mode 100644 index db49a72b..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.contingency.ContingenciesProvider; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.iidm.network.StateManager; -import eu.itesla_project.loadflow.api.LoadFlow; -import eu.itesla_project.loadflow.api.LoadFlowFactory; -import eu.itesla_project.loadflow.api.LoadFlowParameters; -import eu.itesla_project.loadflow.api.LoadFlowResult; -import eu.itesla_project.contingency.Contingency; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.function.BiFunction; -import java.util.function.Supplier; - -/** - * @author Geoffroy Jamgotchian - */ -public class SecurityAnalysisImpl implements SecurityAnalysis { - - private static final Logger LOGGER = LoggerFactory.getLogger(SecurityAnalysisImpl.class); - - private final Network network; - private final ComputationManager computationManager; - private final LoadFlowFactory loadFlowFactory; - - public SecurityAnalysisImpl(Network network, ComputationManager computationManager, LoadFlowFactory loadFlowFactory) { - this.network = Objects.requireNonNull(network); - this.computationManager = Objects.requireNonNull(computationManager); - this.loadFlowFactory = Objects.requireNonNull(loadFlowFactory); - } - - private static List checkLimits(Network network) { - return Security.checkLimits(network, Security.CurrentLimitType.TATL, 1f); - } - - @Override - public CompletableFuture runAsync(ContingenciesProvider contingenciesProvider, String workingStateId, LoadFlowParameters parameters) { - Objects.requireNonNull(contingenciesProvider); - Objects.requireNonNull(workingStateId); - Objects.requireNonNull(parameters); - - LoadFlow loadFlow = loadFlowFactory.create(network, computationManager, 0); - - final boolean[] preContingencyComputationOk = new boolean[1]; - final List preContingencyLimitViolations = new ArrayList<>(); - final List postContingencyResults = Collections.synchronizedList(new ArrayList<>()); - - // start post contingency LF from pre-contingency state variables - LoadFlowParameters postContParameters = parameters.clone().setVoltageInitMode(LoadFlowParameters.VoltageInitMode.PREVIOUS_VALUES); - - return loadFlow.runAsync(workingStateId, parameters) // run base load flow - .thenComposeAsync(loadFlowResult -> { - network.getStateManager().setWorkingState(workingStateId); - - preContingencyComputationOk[0] = loadFlowResult.isOk(); - preContingencyLimitViolations.addAll(checkLimits(network)); - - CompletableFuture[] futures; - - if (loadFlowResult.isOk()) { - List contingencies = contingenciesProvider.getContingencies(network); - - futures = new CompletableFuture[contingencies.size()]; - - String hash = UUID.randomUUID().toString(); - for (int i = 0; i < contingencies.size(); i++) { - Contingency contingency = contingencies.get(i); - - String postContStateId = hash + "_" + contingency.getId(); - - // run one loadflow per contingency - futures[i] = CompletableFuture - .supplyAsync(new Supplier() { - @Override - public Void get() { - network.getStateManager().cloneState(StateManager.INITIAL_STATE_ID, postContStateId); - network.getStateManager().setWorkingState(postContStateId); - - // apply the contingency on the network - contingency.toTask().modify(network); - - return null; - } - }, computationManager.getExecutor()) - .thenComposeAsync(aVoid -> loadFlow.runAsync(postContStateId, postContParameters), computationManager.getExecutor()) - .handleAsync(new BiFunction() { - @Override - public Void apply(LoadFlowResult loadFlowResult, Throwable throwable) { - network.getStateManager().setWorkingState(postContStateId); - - postContingencyResults.add(new PostContingencyResult(contingency, - loadFlowResult.isOk(), - checkLimits(network))); - - network.getStateManager().removeState(postContStateId); - - return null; - } - }, computationManager.getExecutor()); - } - } - else { - futures = new CompletableFuture[0]; - } - - return CompletableFuture.allOf(futures) - .thenApplyAsync(aVoid -> new SecurityAnalysisResult(new PreContingencyResult(preContingencyComputationOk[0], preContingencyLimitViolations), postContingencyResults)); - }, computationManager.getExecutor()); - } - - @Override - public CompletableFuture runAsync(ContingenciesProvider contingenciesProvider, String workingStateId) { - return runAsync(contingenciesProvider, workingStateId, LoadFlowParameters.load()); - } - - @Override - public CompletableFuture runAsync(ContingenciesProvider contingenciesProvider) { - return runAsync(contingenciesProvider, StateManager.INITIAL_STATE_ID); - } - -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisResult.java b/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisResult.java deleted file mode 100644 index 08ad24d3..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisResult.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import java.util.List; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class SecurityAnalysisResult { - - private final PreContingencyResult preContingencyResult; - - private final List postContingencyResults; - - public SecurityAnalysisResult(PreContingencyResult preContingencyResult, List postContingencyResults) { - this.preContingencyResult = Objects.requireNonNull(preContingencyResult); - this.postContingencyResults = Objects.requireNonNull(postContingencyResults); - } - - public PreContingencyResult getPreContingencyResult() { - return preContingencyResult; - } - - public List getPostContingencyResults() { - return postContingencyResults; - } -} diff --git a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisTool.java b/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisTool.java deleted file mode 100644 index ce5819a6..00000000 --- a/security-analysis/src/main/java/eu/itesla_project/security/SecurityAnalysisTool.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import com.google.auto.service.AutoService; -import eu.itesla_project.commons.config.ComponentDefaultConfig; -import eu.itesla_project.commons.io.SystemOutStreamWriter; -import eu.itesla_project.commons.io.table.AsciiTableFormatterFactory; -import eu.itesla_project.commons.io.table.CsvTableFormatterFactory; -import eu.itesla_project.commons.tools.Command; -import eu.itesla_project.commons.tools.Tool; -import eu.itesla_project.computation.local.LocalComputationManager; -import eu.itesla_project.contingency.ContingenciesProvider; -import eu.itesla_project.contingency.ContingenciesProviderFactory; -import eu.itesla_project.iidm.import_.Importers; -import eu.itesla_project.iidm.network.Network; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardOpenOption; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * @author Geoffroy Jamgotchian - */ -@AutoService(Tool.class) -public class SecurityAnalysisTool implements Tool { - - @Override - public Command getCommand() { - return new Command() { - @Override - public String getName() { - return "security-analysis"; - } - - @Override - public String getTheme() { - return "Computation"; - } - - @Override - public String getDescription() { - return "Run security analysis"; - } - - @Override - public Options getOptions() { - Options options = new Options(); - options.addOption(Option.builder().longOpt("case-file") - .desc("the case path") - .hasArg() - .argName("FILE") - .required() - .build()); - options.addOption(Option.builder().longOpt("limit-types") - .desc("limit type filter (all if not set)") - .hasArg() - .argName("LIMIT-TYPES") - .build()); - options.addOption(Option.builder().longOpt("output-csv") - .desc("the CSV output path") - .hasArg() - .argName("FILE") - .build()); - return options; - } - - @Override - public String getUsageFooter() { - return "Where LIMIT-TYPES is one of " + Arrays.toString(LimitViolationType.values()); - } - }; - } - - @Override - public void run(CommandLine line) throws Exception { - Path caseFile = Paths.get(line.getOptionValue("case-file")); - Set limitViolationTypes = line.hasOption("limit-types") - ? Arrays.stream(line.getOptionValue("limit-types").split(",")).map(LimitViolationType::valueOf).collect(Collectors.toSet()) - : EnumSet.allOf(LimitViolationType.class); - Path csvFile = null; - if (line.hasOption("output-csv")) { - csvFile = Paths.get(line.getOptionValue("output-csv")); - } - - System.out.println("Loading network '" + caseFile + "'"); - - // load network - Network network = Importers.loadNetwork(caseFile); - if (network == null) { - throw new RuntimeException("Case '" + caseFile + "' not found"); - } - network.getStateManager().allowStateMultiThreadAccess(true); - - ComponentDefaultConfig defaultConfig = ComponentDefaultConfig.load(); - SecurityAnalysisFactory securityAnalysisFactory = defaultConfig.newFactoryImpl(SecurityAnalysisFactory.class); - SecurityAnalysis securityAnalysis = securityAnalysisFactory.create(network, LocalComputationManager.getDefault(), 0); - - ContingenciesProviderFactory contingenciesProviderFactory = defaultConfig.newFactoryImpl(ContingenciesProviderFactory.class); - ContingenciesProvider contingenciesProvider = contingenciesProviderFactory.create(); - - // run security analysis on all N-1 lines - SecurityAnalysisResult result = securityAnalysis.runAsync(contingenciesProvider) - .join(); - - if (!result.getPreContingencyResult().isComputationOk()) { - System.out.println("Pre-contingency state divergence"); - } - LimitViolationFilter limitViolationFilter = new LimitViolationFilter(limitViolationTypes); - if (csvFile != null) { - System.out.println("Writing results to '" + csvFile + "'"); - CsvTableFormatterFactory csvTableFormatterFactory = new CsvTableFormatterFactory(); - Security.printPreContingencyViolations(result, Files.newBufferedWriter(csvFile, StandardCharsets.UTF_8), csvTableFormatterFactory, limitViolationFilter); - Security.printPostContingencyViolations(result, Files.newBufferedWriter(csvFile, StandardCharsets.UTF_8, StandardOpenOption.APPEND), csvTableFormatterFactory, limitViolationFilter); - } else { - SystemOutStreamWriter soutWriter = new SystemOutStreamWriter(); - AsciiTableFormatterFactory asciiTableFormatterFactory = new AsciiTableFormatterFactory(); - Security.printPreContingencyViolations(result, soutWriter, asciiTableFormatterFactory, limitViolationFilter); - Security.printPostContingencyViolations(result, soutWriter, asciiTableFormatterFactory, limitViolationFilter); - } - } -} diff --git a/security-analysis/src/test/java/eu/itesla_project/security/LimitViolationFilterTest.java b/security-analysis/src/test/java/eu/itesla_project/security/LimitViolationFilterTest.java deleted file mode 100644 index 6d8b4f30..00000000 --- a/security-analysis/src/test/java/eu/itesla_project/security/LimitViolationFilterTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2016, RTE (http://www.rte-france.com) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.security; - -import eu.itesla_project.commons.config.InMemoryPlatformConfig; -import eu.itesla_project.commons.config.MapModuleConfig; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.nio.file.ShrinkWrapFileSystems; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.nio.file.FileSystem; -import java.nio.file.Path; -import java.util.Arrays; -import java.util.EnumSet; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class LimitViolationFilterTest { - - private FileSystem fileSystem; - private Path configDir; - private MapModuleConfig moduleConfig; - private InMemoryPlatformConfig platformConfig; - - @Before - public void setUp() throws Exception { - JavaArchive archive = ShrinkWrap.create(JavaArchive.class); - fileSystem = ShrinkWrapFileSystems.newFileSystem(archive); - configDir = fileSystem.getPath("/config"); - platformConfig = new InMemoryPlatformConfig(fileSystem); - moduleConfig = platformConfig.createModuleConfig("limit-violation-default-filter"); - moduleConfig.setStringListProperty("violationTypes", Arrays.asList("CURRENT", "LOW_VOLTAGE")); - moduleConfig.setStringProperty("minBaseVoltage", "150"); - } - - @After - public void tearDown() throws Exception { - fileSystem.close(); - } - @Test - public void load() throws Exception { - LimitViolationFilter filter = LimitViolationFilter.load(platformConfig); - assertEquals(filter.getViolationTypes(), EnumSet.of(LimitViolationType.CURRENT, LimitViolationType.LOW_VOLTAGE)); - assertTrue(filter.getMinBaseVoltage() == 150f); - filter.setViolationTypes(EnumSet.of(LimitViolationType.HIGH_VOLTAGE)); - assertEquals(filter.getViolationTypes(), EnumSet.of(LimitViolationType.HIGH_VOLTAGE)); - filter.setMinBaseVoltage(225f); - assertTrue(filter.getMinBaseVoltage() == 225f); - filter.setViolationTypes(null); - assertNull(filter.getViolationTypes()); - try { - filter.setViolationTypes(EnumSet.noneOf(LimitViolationType.class)); - fail(); - } catch (Exception ignored) { - } - try { - filter.setMinBaseVoltage(-3f); - fail(); - } catch (Exception ignored) { - } - } - -} \ No newline at end of file diff --git a/simulation-api/pom.xml b/simulation-api/pom.xml deleted file mode 100644 index 99f27fbe..00000000 --- a/simulation-api/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - itesla-parent - eu.itesla_project - 0.1-SNAPSHOT - - 4.0.0 - - simulation-api - - Time domain simulation API - - - - com.google.guava - guava - - - eu.itesla_project - commons - ${project.version} - - - eu.itesla_project - iidm-network-api - ${project.version} - - - eu.itesla_project - iidm-converter-api - ${project.version} - - - eu.itesla_project - contingency-api - ${project.version} - - - junit - junit - test - - - - \ No newline at end of file diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysis.java b/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysis.java deleted file mode 100644 index 21e8879e..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysis.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import eu.itesla_project.commons.Versionable; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -/** - * This is intended to become the base class for all dynamic simulator integrated - * in the iTESLA platform. - * TODO: extend the API with simulation result querying - * - * @author Geoffroy Jamgotchian - */ -public interface ImpactAnalysis extends Versionable { - - void init(SimulationParameters parameters, Map context) throws Exception; - - ImpactAnalysisResult run(SimulationState state) throws Exception; - - ImpactAnalysisResult run(SimulationState state, Set contingencyIds) throws Exception; - - CompletableFuture runAsync(SimulationState state, Set contingencyIds, ImpactAnalysisProgressListener listener); - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisCommand.java b/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisCommand.java deleted file mode 100644 index 4ff8db11..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import eu.itesla_project.commons.tools.Command; -import org.apache.commons.cli.Option; -import org.apache.commons.cli.Options; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ImpactAnalysisCommand implements Command { - - static final ImpactAnalysisCommand INSTANCE = new ImpactAnalysisCommand(); - - @Override - public String getName() { - return "run-impact-analysis"; - } - - @Override - public String getTheme() { - return "Computation"; - } - - @Override - public String getDescription() { - return "run an impact analysis"; - } - - @Override - public Options getOptions() { - Options options = new Options(); - options.addOption(Option.builder().longOpt("case-file") - .desc("the case path") - .hasArg() - .argName("FILE") - .required() - .build()); - options.addOption(Option.builder().longOpt("contingencies") - .desc("contingencies to test separated by , (all the db in not set)") - .hasArg() - .argName("LIST") - .build()); - options.addOption(Option.builder().longOpt("output-csv-file") - .desc("output CSV file path (pretty print on standard output if not specified)") - .hasArg() - .argName("FILE") - .build()); - return options; - } - - @Override - public String getUsageFooter() { - return null; - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisProgressListener.java b/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisProgressListener.java deleted file mode 100644 index 30e66147..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisProgressListener.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -/** - * @author Geoffroy Jamgotchian - */ -public interface ImpactAnalysisProgressListener { - - void onProgress(int index); - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisResult.java b/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisResult.java deleted file mode 100644 index 8b77655d..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import eu.itesla_project.simulation.securityindexes.SecurityIndex; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class ImpactAnalysisResult { - - private final Map metrics; - - private final List securityIndexes; - - public ImpactAnalysisResult(Map metrics) { - this(metrics, new ArrayList<>()); - } - - public ImpactAnalysisResult(Map metrics, List securityIndexes) { - this.metrics = metrics; - this.securityIndexes = securityIndexes; - } - - public Map getMetrics() { - return metrics; - } - - public void addSecurityIndex(SecurityIndex index) { - securityIndexes.add(index); - } - - public List getSecurityIndexes() { - return securityIndexes; - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisTool.java b/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisTool.java deleted file mode 100644 index c5ae662e..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/ImpactAnalysisTool.java +++ /dev/null @@ -1,257 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import com.google.auto.service.AutoService; -import com.google.common.base.Function; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import com.google.common.collect.Sets; -import eu.itesla_project.commons.ITeslaException; -import eu.itesla_project.commons.config.ComponentDefaultConfig; -import eu.itesla_project.commons.tools.Command; -import eu.itesla_project.commons.tools.Tool; -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.computation.local.LocalComputationManager; -import eu.itesla_project.contingency.ContingenciesProvider; -import eu.itesla_project.contingency.ContingenciesProviderFactory; -import eu.itesla_project.iidm.datasource.GenericReadOnlyDataSource; -import eu.itesla_project.iidm.import_.Importer; -import eu.itesla_project.iidm.import_.Importers; -import eu.itesla_project.iidm.network.Network; -import eu.itesla_project.simulation.securityindexes.SecurityIndex; -import eu.itesla_project.simulation.securityindexes.SecurityIndexId; -import eu.itesla_project.simulation.securityindexes.SecurityIndexType; -import org.apache.commons.cli.CommandLine; -import org.nocrala.tools.texttablefmt.BorderStyle; -import org.nocrala.tools.texttablefmt.Table; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; -import java.util.stream.Collectors; - -/** - * - * @author Geoffroy Jamgotchian - */ -@AutoService(Tool.class) -public class ImpactAnalysisTool implements Tool { - - private static final Logger LOGGER = LoggerFactory.getLogger(ImpactAnalysisTool.class); - - private static final char CSV_SEPARATOR = ';'; - - @Override - public Command getCommand() { - return ImpactAnalysisCommand.INSTANCE; - } - - private static String okToStr(Boolean b) { - String str; - if (b == null) { - str = "NA"; - } else { - str = b ? "OK" : "NOK"; - } - return str; - } - - private static List toRow(Collection securityIndexes) { - List l = new ArrayList<>(); - Map ok = new EnumMap<>(SecurityIndexType.class); - for (SecurityIndex securityIndex : securityIndexes) { - ok.put(securityIndex.getId().getSecurityIndexType(), securityIndex.isOk()); - } - - for (SecurityIndexType securityIndexType : SecurityIndexType.values()) { - Boolean b = ok.get(securityIndexType); - l.add(okToStr(b)); - } - - return l; - } - - private static void prettyPrint(Multimap securityIndexesPerContingency) { - Table table = new Table(1 + SecurityIndexType.values().length, BorderStyle.CLASSIC_WIDE); - table.addCell("Contingency"); - for (SecurityIndexType securityIndexType : SecurityIndexType.values()) { - table.addCell(securityIndexType.toString()); - } - - for (Map.Entry> entry : securityIndexesPerContingency.asMap().entrySet()) { - String contingencyId = entry.getKey(); - table.addCell(contingencyId); - for (String str : toRow(entry.getValue())) { - table.addCell(str); - } - } - - System.out.println(table.render()); - } - - private static void writeCsv(Multimap securityIndexesPerContingency, Path outputCsvFile) throws IOException { - Objects.requireNonNull(outputCsvFile); - try (BufferedWriter writer = Files.newBufferedWriter(outputCsvFile, StandardCharsets.UTF_8)) { - writer.write("Contingency"); - for (SecurityIndexType securityIndexType : SecurityIndexType.values()) { - writer.write(CSV_SEPARATOR); - writer.write(securityIndexType.toString()); - } - writer.newLine(); - - for (Map.Entry> entry : securityIndexesPerContingency.asMap().entrySet()) { - String contingencyId = entry.getKey(); - writer.write(contingencyId); - for (String str : toRow(entry.getValue())) { - writer.write(CSV_SEPARATOR); - writer.write(str); - } - writer.newLine(); - } - } - } - - private static void writeCsv(Map> securityIndexesPerCase, Path outputCsvFile) throws IOException { - Objects.requireNonNull(outputCsvFile); - - Set securityIndexIds = new LinkedHashSet<>(); - for (Map securityIndexesPerId : securityIndexesPerCase.values()) { - if (securityIndexesPerId != null) { - securityIndexIds.addAll(securityIndexesPerId.keySet()); - } - } - - try (BufferedWriter writer = Files.newBufferedWriter(outputCsvFile, StandardCharsets.UTF_8)) { - writer.write("Base case"); - for (SecurityIndexId securityIndexId : securityIndexIds) { - writer.write(CSV_SEPARATOR); - writer.write(securityIndexId.toString()); - } - writer.newLine(); - - for (Map.Entry> entry : securityIndexesPerCase.entrySet()) { - String baseCaseName = entry.getKey(); - writer.write(baseCaseName); - - Map securityIndexes = entry.getValue(); - for (SecurityIndexId securityIndexId : securityIndexIds) { - Boolean b = null; - if (securityIndexes != null) { - SecurityIndex securityIndex = securityIndexes.get(securityIndexId); - if (securityIndex != null) { - b = securityIndex.isOk(); - } - } - writer.write(CSV_SEPARATOR); - writer.write(okToStr(b)); - } - - writer.newLine(); - } - } - } - - private static Multimap runImpactAnalysis(Network network, Set contingencyIds, - ComputationManager computationManager, SimulatorFactory simulatorFactory, - ContingenciesProvider contingenciesProvider) throws Exception { - Stabilization stabilization = simulatorFactory.createStabilization(network, computationManager, 0); - ImpactAnalysis impactAnalysis = simulatorFactory.createImpactAnalysis(network, computationManager, 0, contingenciesProvider); - Map initContext = new HashMap<>(); - SimulationParameters simulationParameters = SimulationParameters.load(); - stabilization.init(simulationParameters, initContext); - impactAnalysis.init(simulationParameters, initContext); - System.out.println("running stabilization simulation..."); - StabilizationResult sr = stabilization.run(); - System.out.println("stabilization status: " + sr.getStatus()); - System.out.println("stabilization metrics: " + sr.getMetrics()); - if (sr.getStatus() == StabilizationStatus.COMPLETED) { - System.out.println("running impact analysis..."); - ImpactAnalysisResult iar = impactAnalysis.run(sr.getState(), contingencyIds); - System.out.println("impact analysis metrics: " + iar.getMetrics()); - - return Multimaps.index(iar.getSecurityIndexes(), new Function() { - @Override - public String apply(SecurityIndex securityIndex) { - return securityIndex.getId().getContingencyId(); - } - }); - - } - return null; - } - - @Override - public void run(CommandLine line) throws Exception { - ComponentDefaultConfig defaultConfig = ComponentDefaultConfig.load(); - Path caseFile = Paths.get(line.getOptionValue("case-file")); - final Set contingencyIds = line.hasOption("contingencies") - ? Sets.newHashSet(line.getOptionValue("contingencies").split(",")) : null; - Path outputCsvFile = null; - if (line.hasOption("output-csv-file")) { - outputCsvFile = Paths.get(line.getOptionValue("output-csv-file")); - } - - try (ComputationManager computationManager = new LocalComputationManager()) { - - ContingenciesProvider contingenciesProvider = defaultConfig.newFactoryImpl(ContingenciesProviderFactory.class).create(); - SimulatorFactory simulatorFactory = defaultConfig.newFactoryImpl(SimulatorFactory.class); - - if (Files.isRegularFile(caseFile)) { - - System.out.println("loading case " + caseFile + "..."); - // load the network - Network network = Importers.loadNetwork(caseFile); - if (network == null) { - throw new RuntimeException("Case '" + caseFile + "' not found"); - } - network.getStateManager().allowStateMultiThreadAccess(true); - - Multimap securityIndexesPerContingency - = runImpactAnalysis(network, contingencyIds, computationManager, - simulatorFactory, contingenciesProvider); - - if (securityIndexesPerContingency != null) { - if (outputCsvFile == null) { - prettyPrint(securityIndexesPerContingency); - } else { - writeCsv(securityIndexesPerContingency, outputCsvFile); - } - } - } else if (Files.isDirectory(caseFile)) { - if (outputCsvFile == null) { - throw new RuntimeException("In case of multiple impact analyses, only output to csv file is supported"); - } - Map> securityIndexesPerCase = new LinkedHashMap<>(); - Importers.loadNetworks(caseFile, false, network -> { - try { - Multimap securityIndexesPerContingency - = runImpactAnalysis(network, contingencyIds, computationManager, - simulatorFactory, contingenciesProvider); - if (securityIndexesPerContingency == null) { - securityIndexesPerCase.put(network.getId(), null); - } else { - Map securityIndexesPerId = securityIndexesPerContingency.values().stream().collect(Collectors.toMap(SecurityIndex::getId, e -> e)); - securityIndexesPerCase.put(network.getId(), securityIndexesPerId); - } - } catch (Exception e) { - LOGGER.error(e.toString(), e); - } - }, dataSource -> System.out.println("loading case " + dataSource.getBaseName() + "...")); - - writeCsv(securityIndexesPerCase, outputCsvFile); - } - } - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationDetailedParameters.java b/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationDetailedParameters.java deleted file mode 100644 index dcbc6ca4..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationDetailedParameters.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import eu.itesla_project.commons.config.PlatformConfig; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.events.XMLEvent; -import java.io.BufferedReader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * @author Geoffroy Jamgotchian - */ -public class SimulationDetailedParameters { - - private final static Supplier XML_INPUT_FACTORY_SUPPLIER = Suppliers.memoize(XMLInputFactory::newInstance); - - public static class Contingency { - - private final String id; - private final Map branches = new HashMap<>(); - private final Map generators = new HashMap<>(); - - public Contingency(String id) { - this.id = Objects.requireNonNull(id); - } - - public String getId() { - return id; - } - - public Map getBranches() { - return branches; - } - - public Branch getBranch(String id) { - return branches.get(id); - } - - public Map getGenerators() { - return generators; - } - - public Generator getGenerator(String id) { - return generators.get(id); - } - } - - public static class Branch { - - private final String id; - private final Double shortCircuitDuration; - private final Double shortCircuitDistance; - private final String shortCircuitSide; - - public Branch(String id, Double shortCircuitDuration, Double shortCircuitDistance, String shortCircuitSide) { - this.id = Objects.requireNonNull(id); - this.shortCircuitDuration = shortCircuitDuration; - this.shortCircuitDistance = shortCircuitDistance; - this.shortCircuitSide = shortCircuitSide; - } - - public String getId() { - return id; - } - - public Double getShortCircuitDistance() { - return shortCircuitDistance; - } - - public Double getShortCircuitDuration() { - return shortCircuitDuration; - } - - public String getShortCircuitSide() { - return shortCircuitSide; - } - } - - public static class Generator { - private final String id; - private final Double shortCircuitDuration; - - public Generator(String id, Double shortCircuitDuration) { - this.id = Objects.requireNonNull(id); - this.shortCircuitDuration = Objects.requireNonNull(shortCircuitDuration); - } - - public String getId() { - return id; - } - - public Double getShortCircuitDuration() { - return shortCircuitDuration; - } - } - - private final String fileName; - - private final Map contingencies = new HashMap<>(); - - public SimulationDetailedParameters(String fileName) { - this.fileName = Objects.requireNonNull(fileName); - } - - public String getFileName() { - return fileName; - } - - public Map getContingencies() { - return contingencies; - } - - public Contingency getContingency(String id) { - return contingencies.get(id); - } - - private static Double parseDoubleIfNotNull(String str) { - return str == null ? null : Double.parseDouble(str); - } - - private static void parse(BufferedReader reader, SimulationDetailedParameters parameters) { - try { - XMLStreamReader xmlsr = XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(reader); - Contingency contingency = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.START_ELEMENT: - switch (xmlsr.getLocalName()) { - case "contingency": - contingency = new Contingency(xmlsr.getAttributeValue(null, "id")); - parameters.getContingencies().put(contingency.getId(), contingency); - break; - case "branch": - Branch branch = new Branch(xmlsr.getAttributeValue(null, "id"), - parseDoubleIfNotNull(xmlsr.getAttributeValue(null, "shortCircuitDuration")), - parseDoubleIfNotNull(xmlsr.getAttributeValue(null, "shortCircuitDistance")), - xmlsr.getAttributeValue(null, "shortCircuitSide")); - contingency.getBranches().put(branch.getId(), branch); - break; - case "generator": - Generator generator = new Generator(xmlsr.getAttributeValue(null, "id"), - parseDoubleIfNotNull(xmlsr.getAttributeValue(null, "shortCircuitDuration"))); - contingency.getGenerators().put(generator.getId(), generator); - } - break; - - case XMLStreamConstants.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "contingency": - contingency = null; - break; - } - break; - } - } - } catch (XMLStreamException e) { - throw new RuntimeException(e); - } - } - - public static SimulationDetailedParameters load(String fileName) { - SimulationDetailedParameters parameters = null; - Path file = PlatformConfig.CONFIG_DIR.resolve(fileName); - if (Files.exists(file)) { - parameters = new SimulationDetailedParameters(fileName); - try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) { - parse(reader, parameters); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return parameters; - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationParameters.java b/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationParameters.java deleted file mode 100644 index 44999db7..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationParameters.java +++ /dev/null @@ -1,233 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import eu.itesla_project.commons.config.ModuleConfig; -import eu.itesla_project.commons.config.PlatformConfig; - -/** - * Parameters used to convert a contingency static description to a dynamic simulation scenario. - * - * preFaultSimulationStopInstant faultEventInstant postFaultSimulationStopInstant - * |-----------|-------------------------------[***]------------------------| - * 0s 50s 70s 70.1s 150s - * - * @author Geoffroy Jamgotchian - */ -public class SimulationParameters { - - private static final double DEFAULT_BRANCH_SHORT_CIRCUIT_DISTANCE = 50; - private static final double DEFAULT_BRANCH_FAULT_RESISTANCE = 0; - private static final double DEFAULT_BRANCH_FAULT_REACTANCE = 0.01; - private static final double DEFAULT_GENERATOR_FAULT_RESISTANCE = 0.00001; - private static final double DEFAULT_GENERATOR_FAULT_REACTANCE = 0.00001; - - private final double preFaultSimulationStopInstant; - - private final double faultEventInstant; - - private final double branchFaultShortCircuitDuration; - - private final double generatorFaultShortCircuitDuration; - - private final double postFaultSimulationStopInstant; - - private final double branchShortCircuitDistance; - - private final double branchFaultResistance; - - private final double branchFaultReactance; - - private final double generatorFaultResistance; - - private final double generatorFaultReactance; - - private final SimulationDetailedParameters detailedParameters; - - public static SimulationParameters load() { - ModuleConfig config = PlatformConfig.defaultConfig().getModuleConfig("simulation-parameters"); - double preFaultSimulationStopInstant = config.getDoubleProperty("preFaultSimulationStopInstant"); - double faultEventInstant = config.getDoubleProperty("faultEventInstant"); - double branchFaultShortCircuitDuration = config.getDoubleProperty("branchFaultShortCircuitDuration"); - double generatorFaultShortCircuitDuration = config.getDoubleProperty("generatorFaultShortCircuitDuration"); - double postFaultSimulationStopInstant = config.getDoubleProperty("postFaultSimulationStopInstant"); - double branchShortCircuitDistance = config.getDoubleProperty("branchShortCircuitDistance", DEFAULT_BRANCH_SHORT_CIRCUIT_DISTANCE); - double branchFaultResistance = config.getDoubleProperty("branchFaultResistance", DEFAULT_BRANCH_FAULT_RESISTANCE); - double branchFaultReactance = config.getDoubleProperty("branchFaultReactance", DEFAULT_BRANCH_FAULT_REACTANCE); - double generatorFaultResistance = config.getDoubleProperty("generatorFaultResistance", DEFAULT_GENERATOR_FAULT_RESISTANCE); - double generatorFaultReactance = config.getDoubleProperty("generatorFaultReactance", DEFAULT_GENERATOR_FAULT_REACTANCE); - String detailedParametersFileName = config.getStringProperty("detailsFileName", null); - SimulationDetailedParameters detailedParameters = null; - if (detailedParametersFileName != null) { - detailedParameters = SimulationDetailedParameters.load(detailedParametersFileName); - } - return new SimulationParameters(preFaultSimulationStopInstant, faultEventInstant, branchFaultShortCircuitDuration, - generatorFaultShortCircuitDuration, postFaultSimulationStopInstant, branchShortCircuitDistance, - branchFaultResistance, branchFaultReactance, generatorFaultResistance, generatorFaultReactance, - detailedParameters); - } - - public SimulationParameters(double preFaultSimulationStopInstant, double faultEventInstant, - double branchFaultShortCircuitDuration, double generatorFaultShortCircuitDuration, - double postFaultSimulationStopInstant) { - this(preFaultSimulationStopInstant, faultEventInstant, branchFaultShortCircuitDuration, generatorFaultShortCircuitDuration, postFaultSimulationStopInstant, - DEFAULT_BRANCH_SHORT_CIRCUIT_DISTANCE, DEFAULT_BRANCH_FAULT_RESISTANCE, DEFAULT_BRANCH_FAULT_REACTANCE, DEFAULT_GENERATOR_FAULT_RESISTANCE, DEFAULT_GENERATOR_FAULT_REACTANCE, null); - } - - public SimulationParameters(double preFaultSimulationStopInstant, double faultEventInstant, - double branchFaultShortCircuitDuration, double generatorFaultShortCircuitDuration, - double postFaultSimulationStopInstant, double branchShortCircuitDistance, - double branchFaultResistance, double branchFaultReactance, - double generatorFaultResistance, double generatorFaultReactance, - SimulationDetailedParameters detailedParameters) { - if (preFaultSimulationStopInstant <= 0) { - throw new IllegalArgumentException("preFaultSimulationStopInstant > 0 is expected"); - } - if (faultEventInstant <= preFaultSimulationStopInstant) { - throw new IllegalArgumentException("faultEventInstant > preFaultSimulationStopInstant is expected"); - } - if (postFaultSimulationStopInstant <= faultEventInstant) { - throw new IllegalArgumentException("postFaultSimulationStopInstant > faultEventInstant is expected"); - } - if (branchFaultShortCircuitDuration <= 0) { - throw new IllegalArgumentException("branchFaultShortCircuitDuration > 0 is expected"); - } - if (generatorFaultShortCircuitDuration <= 0) { - throw new IllegalArgumentException("generatorFaultShortCircuitDuration > 0 is expected"); - } - if (branchShortCircuitDistance < 0 || branchShortCircuitDistance > 100) { - throw new IllegalArgumentException("bad short curcuit distance " + branchShortCircuitDistance); - } - this.preFaultSimulationStopInstant = preFaultSimulationStopInstant; - this.faultEventInstant = faultEventInstant; - this.branchFaultShortCircuitDuration = branchFaultShortCircuitDuration; - this.generatorFaultShortCircuitDuration = generatorFaultShortCircuitDuration; - this.postFaultSimulationStopInstant = postFaultSimulationStopInstant; - this.branchShortCircuitDistance = branchShortCircuitDistance; - this.branchFaultResistance = branchFaultResistance; - this.branchFaultReactance = branchFaultReactance; - this.generatorFaultResistance = generatorFaultResistance; - this.generatorFaultReactance = generatorFaultReactance; - this.detailedParameters = detailedParameters; - } - - public double getPreFaultSimulationStopInstant() { - return preFaultSimulationStopInstant; - } - - public double getFaultEventInstant() { - return faultEventInstant; - } - - public double getBranchFaultShortCircuitDuration() { - return branchFaultShortCircuitDuration; - } - - public double getGeneratorFaultShortCircuitDuration() { - return generatorFaultShortCircuitDuration; - } - - public double getPostFaultSimulationStopInstant() { - return postFaultSimulationStopInstant; - } - - public double getBranchShortCircuitDistance() { - return branchShortCircuitDistance; - } - - public double getBranchFaultResistance() { - return branchFaultResistance; - } - - public double getBranchFaultReactance() { - return branchFaultReactance; - } - - public double getGeneratorFaultResistance() { - return generatorFaultResistance; - } - - public double getGeneratorFaultReactance() { - return generatorFaultReactance; - } - - public SimulationDetailedParameters getDetailedParameters() { - return detailedParameters; - } - - public double getBranchFaultShortCircuitDistance(String contingencyId, String branchId) { - Double distance = null; - if (detailedParameters != null) { - SimulationDetailedParameters.Contingency contingency = detailedParameters.getContingency(contingencyId); - if (contingency != null) { - SimulationDetailedParameters.Branch branch = contingency.getBranch(branchId); - if (branch != null) { - distance = branch.getShortCircuitDistance(); - } - } - } - return distance != null ? distance : branchShortCircuitDistance; - } - - public double getBranchFaultShortCircuitDuration(String contingencyId, String branchId) { - Double duration = null; - if (detailedParameters != null) { - SimulationDetailedParameters.Contingency contingency = detailedParameters.getContingency(contingencyId); - if (contingency != null) { - SimulationDetailedParameters.Branch branch = contingency.getBranch(branchId); - if (branch != null) { - duration = branch.getShortCircuitDuration(); - } - } - } - return duration != null ? duration : branchFaultShortCircuitDuration; - } - - public String getBranchFaultShortCircuitSide(String contingencyId, String branchId) { - String side = null; - if (detailedParameters != null) { - SimulationDetailedParameters.Contingency contingency = detailedParameters.getContingency(contingencyId); - if (contingency != null) { - SimulationDetailedParameters.Branch branch = contingency.getBranch(branchId); - if (branch != null) { - side = branch.getShortCircuitSide(); - } - } - } - return side; - } - - public double getGeneratorFaultShortCircuitDuration(String contingencyId, String generatorId) { - Double duration = null; - if (detailedParameters != null) { - SimulationDetailedParameters.Contingency contingency = detailedParameters.getContingency(contingencyId); - if (contingency != null) { - SimulationDetailedParameters.Generator generator = contingency.getGenerator(generatorId); - if (generator != null) { - duration = generator.getShortCircuitDuration(); - } - } - } - return duration != null ? duration : generatorFaultShortCircuitDuration; - } - - @Override - public String toString() { - return getClass().getSimpleName() + " [preFaultSimulationStopInstant=" + preFaultSimulationStopInstant + - ", faultEventInstant=" + faultEventInstant + - ", branchFaultShortCircuitDuration=" + branchFaultShortCircuitDuration + - ", generatorFaultShortCircuitDuration=" + generatorFaultShortCircuitDuration + - ", postFaultSimulationStopInstant=" + postFaultSimulationStopInstant + - ", branchShortCircuitDistance=" + branchShortCircuitDistance + - ", branchFaultResistance=" + branchFaultResistance + - ", branchFaultReactance=" + branchFaultReactance + - ", generatorFaultResistance=" + generatorFaultResistance + - ", generatorFaultReactance=" + generatorFaultReactance + - ", detailedParameters=" + Boolean.toString(detailedParameters != null) + - "]"; - } -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationState.java b/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationState.java deleted file mode 100644 index 9043f927..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulationState.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface SimulationState { - - String getName(); - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulatorFactory.java b/simulation-api/src/main/java/eu/itesla_project/simulation/SimulatorFactory.java deleted file mode 100644 index 893d642c..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/SimulatorFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import eu.itesla_project.contingency.ContingenciesProvider; -import eu.itesla_project.computation.ComputationManager; -import eu.itesla_project.iidm.network.Network; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface SimulatorFactory { - - Stabilization createStabilization(Network network, ComputationManager computationManager, int priority); - - ImpactAnalysis createImpactAnalysis(Network network, ComputationManager computationManager, int priority, ContingenciesProvider contingenciesProvider); - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/Stabilization.java b/simulation-api/src/main/java/eu/itesla_project/simulation/Stabilization.java deleted file mode 100644 index 33cc08af..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/Stabilization.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import eu.itesla_project.commons.Versionable; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface Stabilization extends Versionable { - - void init(SimulationParameters parameters, Map context) throws Exception; - - StabilizationResult run() throws Exception; - - CompletableFuture runAsync(String workingStateId); - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationResult.java b/simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationResult.java deleted file mode 100644 index 8c43e73b..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationResult.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public interface StabilizationResult { - - StabilizationStatus getStatus(); - - Map getMetrics(); - - SimulationState getState(); - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationStatus.java b/simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationStatus.java deleted file mode 100644 index f7b90690..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/StabilizationStatus.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation; - -/** - * @author Geoffroy Jamgotchian - */ -public enum StabilizationStatus { - COMPLETED, - COMPLETED_BUT_NOT_TO_STEADY_STATE, - FAILED -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/AbstractSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/AbstractSecurityIndex.java deleted file mode 100644 index 6feaf058..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/AbstractSecurityIndex.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import java.io.IOException; -import java.io.StringWriter; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -/** - * - * @author Geoffroy Jamgotchian - */ -abstract class AbstractSecurityIndex implements SecurityIndex { - - protected final static Supplier xmlof = Suppliers.memoize(new Supplier() { - @Override - public XMLOutputFactory get() { - return XMLOutputFactory.newInstance(); - } - }); - - protected final SecurityIndexId id; - - protected AbstractSecurityIndex(String contingencyId, SecurityIndexType securityIndexType) { - id = new SecurityIndexId(contingencyId, securityIndexType); - } - - @Override - public SecurityIndexId getId() { - return id; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder("SecurityIndex(id="); - builder.append(id); - toMap().entrySet().forEach(e -> builder.append(", ").append(e.getKey()).append("=").append(e.getValue())); - builder.append(")"); - return builder.toString(); - } - - abstract protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException; - - @Override - public String toXml() { - StringWriter writer = new StringWriter(); - try { - XMLStreamWriter xmlWriter = xmlof.get().createXMLStreamWriter(writer); - try { - toXml(xmlWriter); - } finally { - xmlWriter.close(); - } - writer.close(); - } catch (IOException | XMLStreamException e) { - throw new RuntimeException(e); - } - return writer.toString(); - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex.java deleted file mode 100644 index 2c2c4872..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class MultiCriteriaVoltageStabilityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "multi-criteria-voltage-stability"; - - private static final float LOCKED_TAP_CHANGER_LOAD_THRESHOLD = 0f; - private static final float STOPPED_TAP_CHANGER_LOAD_THRESHOLD = 0f; - private static final float UNDER_VOLTAGE_AUTOMATON_GENERATOR_THRESHOLD = 0f; - - private final Map lockedTapChangerLoads; - - private final Map stoppedTapChangerLoads; - - private final Map underVoltageAutomatonGenerators; - - private final Set underVoltageBuses; - - public static MultiCriteriaVoltageStabilityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - Map lockedTapChangerLoads = new LinkedHashMap<>(); - Map stoppedTapChangerLoads = new LinkedHashMap<>(); - Map underVoltageAutomatonGenerators = new LinkedHashMap<>(); - Set underVoltageBuses = new LinkedHashSet<>(); - String id = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.START_ELEMENT: - switch (xmlsr.getLocalName()) { - case "lockedTapChangerLoad": - case "stoppedTapChangerLoad": - case "underVoltageAutomatonGenerator": - id = xmlsr.getAttributeValue(null, "id"); - break; - } - break; - - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "lockedTapChangerLoad": - if (id == null) { - throw new AssertionError(); - } - lockedTapChangerLoads.put(id, Float.parseFloat(text)); - id = null; - break; - case "stoppedTapChangerLoad": - if (id == null) { - throw new AssertionError(); - } - stoppedTapChangerLoads.put(id, Float.parseFloat(text)); - id = null; - break; - case "underVoltageAutomatonGenerator": - if (id == null) { - throw new AssertionError(); - } - underVoltageAutomatonGenerators.put(id, Float.parseFloat(text)); - id = null; - break; - case "underVoltageBus": - underVoltageBuses.add(text); - break; - case "index": - return new MultiCriteriaVoltageStabilityIndex(contingencyId, lockedTapChangerLoads, stoppedTapChangerLoads, - underVoltageAutomatonGenerators, underVoltageBuses); - } - break; - } - } - throw new AssertionError("Should not happened"); - } - - public MultiCriteriaVoltageStabilityIndex(String contingencyId, Map lockedTapChangerLoads, - Map stoppedTapChangerLoads, Map underVoltageAutomatonGenerators, - Set underVoltageBuses) { - super(contingencyId, SecurityIndexType.MULTI_CRITERIA_VOLTAGE_STABILITY); - this.lockedTapChangerLoads = Objects.requireNonNull(lockedTapChangerLoads); - this.stoppedTapChangerLoads = Objects.requireNonNull(stoppedTapChangerLoads); - this.underVoltageAutomatonGenerators = Objects.requireNonNull(underVoltageAutomatonGenerators); - this.underVoltageBuses = Objects.requireNonNull(underVoltageBuses); - } - - public Map getLockedTapChangerLoads() { - return lockedTapChangerLoads; - } - - public Map getStoppedTapChangerLoads() { - return stoppedTapChangerLoads; - } - - public Map getUnderVoltageAutomatonGenerators() { - return underVoltageAutomatonGenerators; - } - - public Set getUnderVoltageBuses() { - return underVoltageBuses; - } - - @Override - public boolean isOk() { - return lockedTapChangerLoads.entrySet().stream().mapToDouble(Map.Entry::getValue).sum() <= LOCKED_TAP_CHANGER_LOAD_THRESHOLD - && stoppedTapChangerLoads.entrySet().stream().mapToDouble(Map.Entry::getValue).sum() <= STOPPED_TAP_CHANGER_LOAD_THRESHOLD - && underVoltageAutomatonGenerators.entrySet().stream().mapToDouble(Map.Entry::getValue).sum() <= UNDER_VOLTAGE_AUTOMATON_GENERATOR_THRESHOLD - && underVoltageBuses.isEmpty(); - } - - @Override - protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - for (Map.Entry e : lockedTapChangerLoads.entrySet()) { - String id = e.getKey(); - float p = e.getValue(); - xmlWriter.writeStartElement("lockedTapChangerLoad"); - xmlWriter.writeAttribute("id", id); - xmlWriter.writeCharacters(Float.toString(p)); - xmlWriter.writeEndElement(); - } - for (Map.Entry e : stoppedTapChangerLoads.entrySet()) { - String id = e.getKey(); - float p = e.getValue(); - xmlWriter.writeStartElement("stoppedTapChangerLoad"); - xmlWriter.writeAttribute("id", id); - xmlWriter.writeCharacters(Float.toString(p)); - xmlWriter.writeEndElement(); - } - for (Map.Entry e : underVoltageAutomatonGenerators.entrySet()) { - String id = e.getKey(); - float p = e.getValue(); - xmlWriter.writeStartElement("underVoltageAutomatonGenerators"); - xmlWriter.writeAttribute("id", id); - xmlWriter.writeCharacters(Float.toString(p)); - xmlWriter.writeEndElement(); - } - for (String underVoltageBus : underVoltageBuses) { - xmlWriter.writeStartElement("underVoltageBus"); - xmlWriter.writeCharacters(underVoltageBus); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("lockedTapChangerLoads", lockedTapChangerLoads.toString(), - "stoppedTapChangerLoads", stoppedTapChangerLoads.toString(), - "underVoltageAutomatonGenerators", underVoltageAutomatonGenerators.toString(), - "underVoltageBuses", underVoltageBuses.toString()); - } -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex2.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex2.java deleted file mode 100644 index c9c7933c..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/MultiCriteriaVoltageStabilityIndex2.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -/** - * @author Geoffroy Jamgotchian - */ -public class MultiCriteriaVoltageStabilityIndex2 extends AbstractSecurityIndex { - - static final String XML_NAME = "multi-criteria-voltage-stability2"; - - private static final float CRITERIA1_THRESHOLD = 200f; - private static final float CRITERIA2_THRESHOLD = 1500f; - - private boolean converge; - - private final Map criteria1; - - private final Map criteria2; - - private final Set criteria3; - - public static MultiCriteriaVoltageStabilityIndex2 fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - Boolean converge = null; - Map criteria1 = null; - Map criteria2 = null; - Set criteria3 = null; - - String text = null; - String id = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.START_ELEMENT: - switch (xmlsr.getLocalName()) { - case "criteria1": - criteria1 = new LinkedHashMap<>(); - break; - - case "criteria2": - criteria2 = new LinkedHashMap<>(); - break; - - case "criteria3": - criteria3 = new LinkedHashSet<>(); - break; - - case "bus": - id = xmlsr.getAttributeValue(null, "id"); - break; - } - break; - - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "converge": - converge = Boolean.parseBoolean(text); - break; - - case "criteria1": - criteria1 = null; - break; - - case "criteria2": - criteria2 = null; - break; - - case "criteria3": - criteria3 = null; - break; - - case "bus": - if (criteria1 != null) { - criteria1.put(id, Float.parseFloat(text)); - } else if (criteria2 != null) { - criteria2.put(id, Float.parseFloat(text)); - } else if (criteria3 != null) { - criteria3.add(id); - } else { - throw new AssertionError(); - } - break; - - case "index": - return new MultiCriteriaVoltageStabilityIndex2(contingencyId, converge, criteria1, criteria2, criteria3); - } - break; - } - } - throw new AssertionError("Should not happened"); - } - - public MultiCriteriaVoltageStabilityIndex2(String contingencyId, boolean converge, Map criteria1, Map criteria2, Set criteria3) { - super(contingencyId, SecurityIndexType.MULTI_CRITERIA_VOLTAGE_STABILITY2); - this.converge = converge; - this.criteria1 = criteria1; - this.criteria2 = criteria2; - this.criteria3 = criteria3; - } - - public boolean isConverge() { - return converge; - } - - public static boolean areCriteriaOk(Map criteria1, Map criteria2, Set criteria3) { - return criteria1.entrySet().stream().mapToDouble(Map.Entry::getValue).sum() <= CRITERIA1_THRESHOLD - && criteria2.entrySet().stream().mapToDouble(Map.Entry::getValue).sum() <= CRITERIA2_THRESHOLD - && criteria3.isEmpty(); - } - - public Map getCriteria1() { - return criteria1; - } - - public Map getCriteria2() { - return criteria2; - } - - public Set getCriteria3() { - return criteria3; - } - - @Override - public boolean isOk() { - return converge && areCriteriaOk(criteria1, criteria2, criteria3); - } - - @Override - protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - - xmlWriter.writeStartElement("converge"); - xmlWriter.writeCharacters(Boolean.toString(converge)); - xmlWriter.writeEndElement(); - - xmlWriter.writeStartElement("criteria1"); - for (Map.Entry e : criteria1.entrySet()) { - String id = e.getKey(); - float p = e.getValue(); - xmlWriter.writeStartElement("bus"); - xmlWriter.writeAttribute("id", id); - xmlWriter.writeCharacters(Float.toString(p)); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - - xmlWriter.writeStartElement("criteria2"); - for (Map.Entry e : criteria2.entrySet()) { - String id = e.getKey(); - float p = e.getValue(); - xmlWriter.writeStartElement("bus"); - xmlWriter.writeAttribute("id", id); - xmlWriter.writeCharacters(Float.toString(p)); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - - xmlWriter.writeStartElement("criteria3"); - for (String underVoltageBus : criteria3) { - xmlWriter.writeStartElement("bus"); - xmlWriter.writeCharacters(underVoltageBus); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("converge", Boolean.toString(converge), - "criteria1", criteria1.toString(), - "criteria2", criteria2.toString(), - "criteria3", criteria3.toString()); - } -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndex.java deleted file mode 100644 index 3131b287..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndex.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.Map; - -/** - * - * @author Quinary - */ -public class OverloadSecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "overload"; - private static final double INDEX_THRESHOLD = 1.0; - - private final double indexValue; - - public static OverloadSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.END_ELEMENT: - if ("fx".equals(xmlsr.getLocalName())) { - return new OverloadSecurityIndex(contingencyId, Double.parseDouble(text)); - } - break; - } - } - throw new InternalError("Should not have happened"); - } - - public OverloadSecurityIndex(String contingencyId, double indexValue) { - super(contingencyId, SecurityIndexType.OVERLOAD); - this.indexValue = indexValue; - } - - public double getIndexValue() { - return indexValue; - } - - @Override - public boolean isOk() { - return !(indexValue > INDEX_THRESHOLD); - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - xmlWriter.writeStartElement("fx"); - xmlWriter.writeCharacters(Double.toString(indexValue)); - xmlWriter.writeEndElement(); - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("fx", Double.toString(indexValue)); - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndex.java deleted file mode 100755 index 33db0e61..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndex.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.util.Map; - -/** - * Based class for all security indexes. - * - * @author Geoffroy Jamgotchian - */ -public interface SecurityIndex { - - /** - * Get security index id. - * @return security index type - */ - SecurityIndexId getId(); - - /** - * Get the security index synthetic value. - * @return the security index synthetic value - */ - boolean isOk(); - - Map toMap(); - - String toXml(); - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexId.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexId.java deleted file mode 100644 index be233fef..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexId.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; -import java.nio.charset.StandardCharsets; -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class SecurityIndexId implements Serializable, Comparable { - - public static final String SIMULATION_PREFIX = "SIM_"; - public static final String SECURITY_INDEX_SEPARATOR = "__IDX__"; - - private final String contingencyId; - - private final SecurityIndexType securityIndexType; - - public SecurityIndexId(String contingencyId, SecurityIndexType securityIndexType) { - Objects.requireNonNull(contingencyId); - Objects.requireNonNull(securityIndexType); - this.contingencyId = contingencyId; - this.securityIndexType = securityIndexType; - } - - public String getContingencyId() { - return contingencyId; - } - - public SecurityIndexType getSecurityIndexType() { - return securityIndexType; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof SecurityIndexId) { - SecurityIndexId other = (SecurityIndexId) obj; - return contingencyId.equals(other.contingencyId) - && securityIndexType == other.securityIndexType; - } - return false; - } - - @Override - public int hashCode() { - return Objects.hash(contingencyId, securityIndexType); - } - - public static String toString(String contingencyId, SecurityIndexType securityIndexType) { - try { - String enc = StandardCharsets.UTF_8.toString(); - return SIMULATION_PREFIX + URLEncoder.encode(contingencyId, enc) - + SECURITY_INDEX_SEPARATOR + URLEncoder.encode(securityIndexType.getLabel(), enc); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - public static SecurityIndexId fromString(String str) { - try { - String enc = StandardCharsets.UTF_8.toString(); - int sepIdx = str.indexOf(SECURITY_INDEX_SEPARATOR); - String contingencyId = URLDecoder.decode(str.substring(SIMULATION_PREFIX.length(), sepIdx), enc); - String securityIndexLabel = URLDecoder.decode(str.substring(sepIdx + SECURITY_INDEX_SEPARATOR.length()), enc); - return new SecurityIndexId(contingencyId, SecurityIndexType.fromLabel(securityIndexLabel)); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - - @Override - public String toString() { - return toString(contingencyId, securityIndexType); - } - - @Override - public int compareTo(SecurityIndexId o) { - int c = contingencyId.compareTo(o.contingencyId); - if (c == 0) { - c = securityIndexType.compareTo(o.securityIndexType); - } - return c; - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexParser.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexParser.java deleted file mode 100644 index 33448e65..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexParser.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.events.XMLEvent; -import java.io.Reader; -import java.util.ArrayList; -import java.util.List; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class SecurityIndexParser { - - private final static Supplier XML_INPUT_FACTORY_SUPPLIER = Suppliers.memoize(XMLInputFactory::newInstance); - - private SecurityIndexParser() { - } - - public static List fromXml(String contingencyId, Reader reader) { - List indexes = new ArrayList<>(); - try { - XMLStreamReader xmlsr = XML_INPUT_FACTORY_SUPPLIER.get().createXMLStreamReader(reader); - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.START_ELEMENT: - switch (xmlsr.getLocalName()) { - case "index": - switch(xmlsr.getAttributeValue(null, "name")) { - case OverloadSecurityIndex.XML_NAME: - indexes.add(OverloadSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case UnderOverVoltageSecurityIndex.XML_NAME: - indexes.add(UnderOverVoltageSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case SmallSignalSecurityIndex.XML_NAME: - indexes.add(SmallSignalSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case TransientSecurityIndex.XML_NAME: - indexes.add(TransientSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case TsoOverloadSecurityIndex.XML_NAME: - indexes.add(TsoOverloadSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case TsoOvervoltageSecurityIndex.XML_NAME: - indexes.add(TsoOvervoltageSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case TsoUndervoltageSecurityIndex.XML_NAME: - indexes.add(TsoUndervoltageSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case TsoFrequencySecurityIndex.XML_NAME: - indexes.add(TsoFrequencySecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case TsoSynchroLossSecurityIndex.XML_NAME: - indexes.add(TsoSynchroLossSecurityIndex.fromXml(contingencyId, xmlsr)); - break; - case TsoGeneratorVoltageAutomaton.XML_NAME: - indexes.add(TsoGeneratorVoltageAutomaton.fromXml(contingencyId, xmlsr)); - break; - case TsoGeneratorSpeedAutomaton.XML_NAME: - indexes.add(TsoGeneratorSpeedAutomaton.fromXml(contingencyId, xmlsr)); - break; - case TsoDisconnectedGenerator.XML_NAME: - indexes.add(TsoDisconnectedGenerator.fromXml(contingencyId, xmlsr)); - break; - case MultiCriteriaVoltageStabilityIndex.XML_NAME: - indexes.add(MultiCriteriaVoltageStabilityIndex.fromXml(contingencyId, xmlsr)); - break; - } - break; - } - break; - } - } - } catch (XMLStreamException e) { - throw new RuntimeException(e); - } - return indexes; - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexType.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexType.java deleted file mode 100644 index eeac8927..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SecurityIndexType.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.Serializable; - -/** - * - * @author Geoffroy Jamgotchian - */ -public enum SecurityIndexType implements Serializable { - - OVERLOAD("Overload", false), - OVERUNDERVOLTAGE("OverUnderVoltage", false), - SMALLSIGNAL("SmallSignal", true), - TRANSIENT("Transient", true), - TSO_OVERLOAD("TSO_overload", false), - TSO_OVERVOLTAGE("TSO_overvoltage", false), - TSO_UNDERVOLTAGE("TSO_undervoltage", false), - TSO_SYNCHROLOSS("TSO_synchro_loss", true), - TSO_FREQUENCY("TSO_frequency", true), - TSO_GENERATOR_VOLTAGE_AUTOMATON("TSO_generator_voltage_automaton", true), - TSO_GENERATOR_SPEED_AUTOMATON("TSO_generator_speed_automaton", true), - TSO_DISCONNECTED_GENERATOR("TSO_disconnected_generator", true), - MULTI_CRITERIA_VOLTAGE_STABILITY("Multi criteria voltage stability", true), - MULTI_CRITERIA_VOLTAGE_STABILITY2("Multi criteria voltage stability 2", true); - - private final String label; - - private final boolean dynamic; - - public static SecurityIndexType fromLabel(String label) { - for (SecurityIndexType securityIndexType : SecurityIndexType.values()) { - if (securityIndexType.getLabel().equals(label)) { - return securityIndexType; - } - } - throw new IllegalArgumentException("No security index found with label " + label); - } - - private SecurityIndexType(String label, boolean dynamic) { - this.label = label; - this.dynamic = dynamic; - } - - public String getLabel() { - return label; - } - - public boolean isDynamic() { - return dynamic; - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndex.java deleted file mode 100644 index 11105337..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndex.java +++ /dev/null @@ -1,332 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.Unmarshaller; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; -import javax.xml.bind.annotation.adapters.XmlAdapter; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -/** - * - * @author Quinary - */ -public class SmallSignalSecurityIndex extends AbstractSecurityIndex{ - - static final String XML_NAME = "smallsignal"; - - private double gmi=Double.NaN; - private double ami[]=null; - private double smi[][]=null; - - private static final JAXBContext jc; - static { - JAXBContext tmpJc=null; - try { - tmpJc=JAXBContext.newInstance( Index.class ); - } catch (JAXBException e) { - e.printStackTrace(); - } - jc=tmpJc; - } - - public static SmallSignalSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - try { - Unmarshaller u = jc.createUnmarshaller(); - Index index=(Index) u.unmarshal(xmlsr); - - double gmi=Double.NaN; - double ami[]= null; - double smi[][]=null; - for (Matrix m: index.getMatrices()) { - switch(m.getName()) { - case "gmi": - double gmiIndexData[][]=m.getMatrix(); - if ((gmiIndexData != null) && (gmiIndexData[0].length>0)) { - gmi=gmiIndexData[0][0]; - } - break; - case "ami": - double amiIndexData[][]=m.getMatrix(); - if (amiIndexData != null) { - ami=amiIndexData[0]; - } - break; - case "smi": - double smiIndexData[][]=m.getMatrix(); - smi=smiIndexData; - break; - } - } - return new SmallSignalSecurityIndex(contingencyId, gmi, ami, smi); - } catch (JAXBException e) { - e.printStackTrace(); - throw new InternalError("Should not have happened"); - } - } - - - public SmallSignalSecurityIndex(String contingencyId, double gmi, double ami[], double smi[][]) { - super(contingencyId, SecurityIndexType.SMALLSIGNAL); - this.gmi = gmi; - this.ami = ami; - this.smi = smi; - } - - public SmallSignalSecurityIndex(String contingencyId, double gmi) { - this(contingencyId, gmi, null, null); - } - - public double getGmi() { - return gmi; - } - - public double[] getAmi() { - return ami; - } - - public double[][] getSmi() { - return smi; - } - - @Override - public boolean isOk() { - return ((Double.isNaN(gmi)) || (gmi >= 0.0000)); - } - - @Override - public Map toMap() { - return ImmutableMap.of("gmi", Double.toString(gmi), "ami", Arrays.toString(ami), "smi", Arrays.deepToString(smi)); - } - - public static void toXml(SmallSignalSecurityIndex index, XMLStreamWriter writer) throws XMLStreamException, JAXBException { - JAXBContext jc; - jc = JAXBContext.newInstance( Index.class ); - SmallSignalSecurityIndex.Index lindex=new Index(index.getId().getSecurityIndexType().getLabel().toLowerCase()); - double aGmi[][]=new double[1][1]; - aGmi[0][0]=index.getGmi(); - SmallSignalSecurityIndex.Matrix lmatGmi=new Matrix("gmi", aGmi); - double aAmi[][]; - if (! Double.isNaN(index.getGmi())) { - aAmi=new double[1][index.getAmi().length]; - aAmi[0]=index.getAmi(); - } else { - aAmi=new double[0][0]; - } - SmallSignalSecurityIndex.Matrix lmatAmi=new Matrix("ami", aAmi); - SmallSignalSecurityIndex.Matrix lmatSmi=new Matrix("smi", index.getSmi()); - - lindex.setMatrices(Arrays.asList(lmatGmi,lmatAmi,lmatSmi)); - - Marshaller m = jc.createMarshaller(); - m.marshal(lindex, writer); - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - try { - toXml(this, xmlWriter); - } catch (JAXBException e) { - throw new RuntimeException(e); - } - } - - /* - * xml serialization handling, e.g. - * - - - 0.0225 - 0.1227 0.0726 0.0225 - - - 0.1227 0.0726 0.0225 - 0.1866 0.1366 0.0864 - - - - */ - - @XmlRootElement(name="index") - public static class Index { - private String name; - - private List matrices=new ArrayList<>(); - - public Index(String name) { - this.name = name; - } - - public Index(String name, List matrices) { - this.name = name; - this.matrices = matrices; - } - - - @XmlAttribute - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @XmlElement(name="matrix") - public List getMatrices() { - return matrices; - } - - public void setMatrices(List matrices) { - this.matrices = matrices; - } - - public Index() { - } - - @Override - public String toString() { - String retString="["; - retString+=getName()+":"; - for (Matrix m : getMatrices()) { - - retString+=m.toString(); - } - retString+="]"; - return retString; - } - } - - - public static class Matrix { - private String name; - private double[][] matrix; - - public Matrix(String name,double[][] matrix) { - this.name = name; - this.matrix=matrix; - } - - @XmlAttribute - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public String toString() { - String retString="["; - retString+=getName()+": ["; - if (matrix!=null) { - for (int i = 0; i < matrix.length; i++) { - retString+="["; - for (int j = 0; j < matrix[0].length; j++) { - retString+=matrix[i][j]+" " ; - } - retString+="]"; - } - } - retString+="]]"; - return retString; - } - - - @XmlElement(name="m") - @XmlJavaTypeAdapter(MatrixAdapter.class) - public double[][] getMatrix() { - return matrix; - } - - public void setMatrix(double[][] matrix) { - this.matrix = matrix; - } - - public Matrix() { - } - - } - - //http://stackoverflow.com/questions/17119708/csv-as-text-node-of-an-xml-element - public static class MatrixAdapter extends XmlAdapter{ - - public static class AdaptedMatrix { - @XmlElement(name="r") - public List rows; - } - - public static class AdaptedRow { - - @XmlValue - public double[] row; - } - - @Override - public AdaptedMatrix marshal(double[][] matrix) throws Exception { - AdaptedMatrix adaptedMatrix = new AdaptedMatrix(); - if (matrix!=null) { - adaptedMatrix.rows = new ArrayList(matrix.length); - for(double[] row : matrix) { - if ((matrix[0].length == 1) && (Double.isNaN(matrix[0][0]))) - break; - AdaptedRow adaptedRow = new AdaptedRow(); - adaptedRow.row = row; - adaptedMatrix.rows.add(adaptedRow); - } - } - return adaptedMatrix; - } - - @Override - public double[][] unmarshal(AdaptedMatrix adaptedMatrix) throws Exception { - List adaptedRows = adaptedMatrix.rows; - double[][] matrix = new double[adaptedRows.size()][]; - for(int x=0; x - */ -public class TransientSecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "transient"; - - private static final double TRANSIENT_THRESHOLD = 1.0; - private final double j; - - public static TransientSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.END_ELEMENT: - if ("j".equals(xmlsr.getLocalName())) { - return new TransientSecurityIndex(contingencyId, Double.parseDouble(text)); - } - break; - } - } - throw new InternalError("Should not have happened"); - } - - public TransientSecurityIndex(String contingencyId, double j) { - super(contingencyId, SecurityIndexType.TRANSIENT); - this.j = j; - } - - public double getJ() { - return j; - } - - @Override - public boolean isOk() { - return j < TRANSIENT_THRESHOLD; - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - xmlWriter.writeStartElement("j"); - xmlWriter.writeCharacters(Double.toString(j)); - xmlWriter.writeEndElement(); - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("j", Double.toString(j)); - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoDisconnectedGenerator.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoDisconnectedGenerator.java deleted file mode 100644 index b0ce5280..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoDisconnectedGenerator.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.HashMap; -import java.util.Map; - -/** - * @author Geoffroy Jamgotchian - */ -public class TsoDisconnectedGenerator extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-disconnected-generator"; - - private static final float GENERATION_LOST_THRESHOLD = 0; - - private final Map disconnectedGenerators; - - public static TsoDisconnectedGenerator fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - Map disconnectedGenerators = new HashMap<>(); - String id = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.START_ELEMENT: - if ("generator".equals(xmlsr.getLocalName())) { - id = xmlsr.getAttributeValue(null, "id"); - } - break; - - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "generator": - if (id == null) { - throw new AssertionError(); - } - float p = Float.parseFloat(text); - disconnectedGenerators.put(id, p); - id = null; - break; - case "index": - return new TsoDisconnectedGenerator(contingencyId, disconnectedGenerators); - } - break; - } - } - throw new AssertionError("Should not happened"); - } - - public TsoDisconnectedGenerator(String contingencyId, Map disconnectedGenerators) { - super(contingencyId, SecurityIndexType.TSO_DISCONNECTED_GENERATOR); - this.disconnectedGenerators = disconnectedGenerators; - } - - public Map getDisconnectedGenerators() { - return disconnectedGenerators; - } - - @Override - public boolean isOk() { - return disconnectedGenerators.entrySet().stream().mapToDouble(Map.Entry::getValue).sum() <= GENERATION_LOST_THRESHOLD; - } - - @Override - protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - for (Map.Entry e : disconnectedGenerators.entrySet()) { - String id = e.getKey(); - float p = e.getValue(); - xmlWriter.writeStartElement("generator"); - xmlWriter.writeAttribute("id", id); - xmlWriter.writeCharacters(Float.toString(p)); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("disconnectedGenerators", disconnectedGenerators.toString()); - } -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndex.java deleted file mode 100644 index f9649649..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndex.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoFrequencySecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-frequency"; - - private static final int MAX_FREQ_OUT_COUNT = 10; - - private final int freqOutCount; - - public static TsoFrequencySecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.END_ELEMENT: - if ("freq-out-count".equals(xmlsr.getLocalName())) { - return new TsoFrequencySecurityIndex(contingencyId, Integer.parseInt(text)); - } - break; - } - } - throw new InternalError("Should not happened"); - } - - public TsoFrequencySecurityIndex(String contingencyId, int freqOutCount) { - super(contingencyId, SecurityIndexType.TSO_FREQUENCY); - this.freqOutCount = freqOutCount; - } - - public int getFreqOutCount() { - return freqOutCount; - } - - @Override - public boolean isOk() { - return freqOutCount < MAX_FREQ_OUT_COUNT; - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - xmlWriter.writeStartElement("freq-out-count"); - xmlWriter.writeCharacters(Integer.toString(freqOutCount)); - xmlWriter.writeEndElement(); - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("freqOutCount", Integer.toString(freqOutCount)); - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomaton.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomaton.java deleted file mode 100644 index 23366371..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomaton.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * @author Geoffroy Jamgotchian - */ -public class TsoGeneratorSpeedAutomaton extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-generator-speed-automaton"; - - private final List onUnderSpeedDiconnectedGenerators; - private final List onOverSpeedDiconnectedGenerators; - - public static TsoGeneratorSpeedAutomaton fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - boolean under = false; - boolean over = false; - String text = null; - List onUnderSpeedDiconnectedGenerators = new ArrayList<>(); - List onOverSpeedDiconnectedGenerators = new ArrayList<>(); - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.START_ELEMENT: - switch (xmlsr.getLocalName()) { - case "onUnderSpeedDisconnectedGenerators": - under = true; - break; - case "onOverSpeedDisconnectedGenerators": - over = true; - break; - } - break; - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "onUnderSpeedDisconnectedGenerators": - under = false; - break; - case "onOverSpeedDisconnectedGenerators": - over = false; - break; - case "gen": - if (under) { - onUnderSpeedDiconnectedGenerators.add(text); - } else if (over) { - onOverSpeedDiconnectedGenerators.add(text); - } else { - throw new AssertionError(); - } - break; - case "index": - return new TsoGeneratorSpeedAutomaton(contingencyId, onUnderSpeedDiconnectedGenerators, onOverSpeedDiconnectedGenerators); - } - break; - } - } - throw new AssertionError("Should not happened"); - } - - public TsoGeneratorSpeedAutomaton(String contingencyId, List onUnderSpeedDiconnectedGenerators, List onOverSpeedDiconnectedGenerators) { - super(contingencyId, SecurityIndexType.TSO_GENERATOR_SPEED_AUTOMATON); - this.onUnderSpeedDiconnectedGenerators = onUnderSpeedDiconnectedGenerators; - this.onOverSpeedDiconnectedGenerators = onOverSpeedDiconnectedGenerators; - } - - public List getOnOverSpeedDiconnectedGenerators() { - return onOverSpeedDiconnectedGenerators; - } - - public List getOnUnderSpeedDiconnectedGenerators() { - return onUnderSpeedDiconnectedGenerators; - } - - @Override - public boolean isOk() { - return (onUnderSpeedDiconnectedGenerators.size() + onOverSpeedDiconnectedGenerators.size()) == 0; - } - - @Override - protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - xmlWriter.writeStartElement("onUnderSpeedDisconnectedGenerators"); - for (String gen : onUnderSpeedDiconnectedGenerators) { - xmlWriter.writeStartElement("gen"); - xmlWriter.writeCharacters(gen); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - xmlWriter.writeStartElement("onOverSpeedDisconnectedGenerators"); - for (String gen : onOverSpeedDiconnectedGenerators) { - xmlWriter.writeStartElement("gen"); - xmlWriter.writeCharacters(gen); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("onUnderSpeedDiconnectedGenerators", onUnderSpeedDiconnectedGenerators.toString(), - "onOverSpeedDiconnectedGenerators", onOverSpeedDiconnectedGenerators.toString()); - } -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomaton.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomaton.java deleted file mode 100644 index ee114be1..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomaton.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * @author Geoffroy Jamgotchian - */ -public class TsoGeneratorVoltageAutomaton extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-generator-voltage-automaton"; - - private final List onUnderVoltageDiconnectedGenerators; - private final List onOverVoltageDiconnectedGenerators; - - public static TsoGeneratorVoltageAutomaton fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - boolean under = false; - boolean over = false; - String text = null; - List onUnderVoltageDiconnectedGenerators = new ArrayList<>(); - List onOverVoltageDiconnectedGenerators = new ArrayList<>(); - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.START_ELEMENT: - switch (xmlsr.getLocalName()) { - case "onUnderVoltageDisconnectedGenerators": - under = true; - break; - case "onOverVoltageDisconnectedGenerators": - over = true; - break; - } - break; - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "onUnderVoltageDisconnectedGenerators": - under = false; - break; - case "onOverVoltageDisconnectedGenerators": - over = false; - break; - case "gen": - if (under) { - onUnderVoltageDiconnectedGenerators.add(text); - } else if (over) { - onOverVoltageDiconnectedGenerators.add(text); - } else { - throw new AssertionError(); - } - break; - case "index": - return new TsoGeneratorVoltageAutomaton(contingencyId, onUnderVoltageDiconnectedGenerators, onOverVoltageDiconnectedGenerators); - } - break; - } - } - throw new AssertionError("Should not happened"); - } - - public TsoGeneratorVoltageAutomaton(String contingencyId, List onUnderVoltageDiconnectedGenerators, List onOverVoltageDiconnectedGenerators) { - super(contingencyId, SecurityIndexType.TSO_GENERATOR_VOLTAGE_AUTOMATON); - this.onUnderVoltageDiconnectedGenerators = onUnderVoltageDiconnectedGenerators; - this.onOverVoltageDiconnectedGenerators = onOverVoltageDiconnectedGenerators; - } - - public List getOnOverVoltageDiconnectedGenerators() { - return onOverVoltageDiconnectedGenerators; - } - - public List getOnUnderVoltageDiconnectedGenerators() { - return onUnderVoltageDiconnectedGenerators; - } - - @Override - public boolean isOk() { - return (onUnderVoltageDiconnectedGenerators.size() + onOverVoltageDiconnectedGenerators.size()) == 0; - } - - @Override - protected void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - xmlWriter.writeStartElement("onUnderVoltageDisconnectedGenerators"); - for (String gen : onUnderVoltageDiconnectedGenerators) { - xmlWriter.writeStartElement("gen"); - xmlWriter.writeCharacters(gen); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - xmlWriter.writeStartElement("onOverVoltageDisconnectedGenerators"); - for (String gen : onOverVoltageDiconnectedGenerators) { - xmlWriter.writeStartElement("gen"); - xmlWriter.writeCharacters(gen); - xmlWriter.writeEndElement(); - } - xmlWriter.writeEndElement(); - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("onUnderVoltageDiconnectedGenerators", onUnderVoltageDiconnectedGenerators.toString(), - "onOverVoltageDiconnectedGenerators", onOverVoltageDiconnectedGenerators.toString()); - } -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndex.java deleted file mode 100644 index 8bc97173..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndex.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoOverloadSecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-overload"; - - private final int overloadCount; - - private final List overloadedBranches; - - private final boolean computationSucceed; - - public static TsoOverloadSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - int overloadCount = -1; - List overloadedBranches = new ArrayList<>(); - boolean computationSucceed = true; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "overload-count": - overloadCount = Integer.parseInt(text); - break; - - case "overloaded-branch": - overloadedBranches.add(text); - break; - - case "computation-succeed": - computationSucceed = Boolean.parseBoolean(text); - break; - - case "index": - return new TsoOverloadSecurityIndex(contingencyId, overloadCount, overloadedBranches, computationSucceed); - } - break; - } - } - throw new InternalError("Should not happened"); - } - - public TsoOverloadSecurityIndex(String contingencyId, int overloadCount) { - this(contingencyId, overloadCount, Collections.emptyList(), true); - } - - public TsoOverloadSecurityIndex(String contingencyId, int overloadCount, List overloadedBranches) { - this(contingencyId, overloadCount, overloadedBranches, true); - } - - public TsoOverloadSecurityIndex(String contingencyId, int overloadCount, List overloadedBranches, boolean computationSucceed) { - super(contingencyId, SecurityIndexType.TSO_OVERLOAD); - this.overloadCount = overloadCount; - this.overloadedBranches = overloadedBranches; - this.computationSucceed = computationSucceed; - } - - public boolean isComputationSucceed() { - return computationSucceed; - } - - public int getOverloadCount() { - return overloadCount; - } - - @Override - public boolean isOk() { - return computationSucceed && overloadCount == 0; - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - - xmlWriter.writeStartElement("computation-succeed"); - xmlWriter.writeCharacters(Boolean.toString(computationSucceed)); - xmlWriter.writeEndElement(); - - xmlWriter.writeStartElement("overload-count"); - xmlWriter.writeCharacters(Integer.toString(overloadCount)); - xmlWriter.writeEndElement(); - - for (String overloadedBranch : overloadedBranches) { - xmlWriter.writeStartElement("overloaded-branch"); - xmlWriter.writeCharacters(overloadedBranch); - xmlWriter.writeEndElement(); - } - - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("computationSucceed", Boolean.toString(computationSucceed), - "overloadCount", Integer.toString(overloadCount), - "overloadedBranches", overloadedBranches.toString()); - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndex.java deleted file mode 100644 index 3bc39915..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndex.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoOvervoltageSecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-overvoltage"; - - private final boolean computationSucceed; - - private final int overvoltageCount; - - public static TsoOvervoltageSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - boolean computationSucceed = true; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "computation-succeed": - computationSucceed = Boolean.parseBoolean(text); - break; - - case "overvoltage-count": - return new TsoOvervoltageSecurityIndex(contingencyId, Integer.parseInt(text), computationSucceed); - } - break; - } - } - throw new InternalError("Should not happened"); - } - - public TsoOvervoltageSecurityIndex(String contingencyId, int overvoltageCount) { - this(contingencyId, overvoltageCount, true); - } - - public TsoOvervoltageSecurityIndex(String contingencyId, int overvoltageCount, boolean computationSucceed) { - super(contingencyId, SecurityIndexType.TSO_OVERVOLTAGE); - this.overvoltageCount = overvoltageCount; - this.computationSucceed = computationSucceed; - } - - public boolean isComputationSucceed() { - return computationSucceed; - } - - public int getOvervoltageCount() { - return overvoltageCount; - } - - @Override - public boolean isOk() { - return computationSucceed && overvoltageCount == 0; - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - - xmlWriter.writeStartElement("computation-succeed"); - xmlWriter.writeCharacters(Boolean.toString(computationSucceed)); - xmlWriter.writeEndElement(); - - xmlWriter.writeStartElement("overvoltage-count"); - xmlWriter.writeCharacters(Integer.toString(overvoltageCount)); - xmlWriter.writeEndElement(); - - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("computationSucceed", Boolean.toString(computationSucceed), - "overvoltageCount", Integer.toString(overvoltageCount)); - } -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndex.java deleted file mode 100644 index 40754248..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndex.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoSynchroLossSecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-synchro-loss"; - - private final int synchroLossCount; - - private final Map desynchronizedGenerators; - - public static TsoSynchroLossSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - int synchroLossCount = -1; - Map desynchronizedGenerators = new HashMap<>(); - String id = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.START_ELEMENT: - if ("generator".equals(xmlsr.getLocalName())) { - id = xmlsr.getAttributeValue(null, "id"); - } - break; - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "generator": - if (id == null) { - throw new AssertionError(); - } - float p = Float.parseFloat(text); - desynchronizedGenerators.put(id, p); - id = null; - break; - case "synchro-loss-count": - synchroLossCount = Integer.parseInt(text); - break; - case "index": - return new TsoSynchroLossSecurityIndex(contingencyId, synchroLossCount, desynchronizedGenerators); - } - break; - } - } - throw new InternalError("Should not happened"); - } - - public TsoSynchroLossSecurityIndex(String contingencyId, int synchroLossCount, Map desynchronizedGenerators) { - super(contingencyId, SecurityIndexType.TSO_SYNCHROLOSS); - this.synchroLossCount = synchroLossCount; - this.desynchronizedGenerators = Objects.requireNonNull(desynchronizedGenerators); - } - - public int getSynchroLossCount() { - return synchroLossCount; - } - - public Map getDesynchronizedGenerators() { - return desynchronizedGenerators; - } - - @Override - public boolean isOk() { - return synchroLossCount == 0; - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - - xmlWriter.writeStartElement("synchro-loss-count"); - xmlWriter.writeCharacters(Integer.toString(synchroLossCount)); - xmlWriter.writeEndElement(); - - for (Map.Entry e : desynchronizedGenerators.entrySet()) { - String id = e.getKey(); - float p = e.getValue(); - xmlWriter.writeStartElement("generator"); - xmlWriter.writeAttribute("id", id); - xmlWriter.writeCharacters(Float.toString(p)); - xmlWriter.writeEndElement(); - } - - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("synchroLossCount", Integer.toString(synchroLossCount), - "desynchronizedGenerators", desynchronizedGenerators.toString()); - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndex.java deleted file mode 100644 index a250d4f6..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndex.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.Map; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoUndervoltageSecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "tso-undervoltage"; - - private final boolean computationSucceed; - - private final int undervoltageCount; - - public static TsoUndervoltageSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - boolean computationSucceed = true; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.END_ELEMENT: - switch (xmlsr.getLocalName()) { - case "computation-succeed": - computationSucceed = Boolean.parseBoolean(text); - break; - - case "undervoltage-count": - return new TsoUndervoltageSecurityIndex(contingencyId, Integer.parseInt(text), computationSucceed); - } - break; - } - } - throw new InternalError("Should not happened"); - } - - public TsoUndervoltageSecurityIndex(String contingencyId, int undervoltageCount) { - this(contingencyId, undervoltageCount, true); - } - - public TsoUndervoltageSecurityIndex(String contingencyId, int undervoltageCount, boolean computationSucceed) { - super(contingencyId, SecurityIndexType.TSO_UNDERVOLTAGE); - this.undervoltageCount = undervoltageCount; - this.computationSucceed = computationSucceed; - } - - public boolean isComputationSucceed() { - return computationSucceed; - } - - public int getUndervoltageCount() { - return undervoltageCount; - } - - @Override - public boolean isOk() { - return computationSucceed && undervoltageCount == 0; - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - - xmlWriter.writeStartElement("computation-succeed"); - xmlWriter.writeCharacters(Boolean.toString(computationSucceed)); - xmlWriter.writeEndElement(); - - xmlWriter.writeStartElement("undervoltage-count"); - xmlWriter.writeCharacters(Integer.toString(undervoltageCount)); - xmlWriter.writeEndElement(); - - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("computationSucceed", Boolean.toString(computationSucceed), - "undervoltageCount", Integer.toString(undervoltageCount)); - } - -} diff --git a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndex.java b/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndex.java deleted file mode 100644 index 72f790e6..00000000 --- a/simulation-api/src/main/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndex.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import com.google.common.collect.ImmutableMap; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.stream.events.XMLEvent; -import java.util.Map; - -/** - * - * @author Quinary - */ -public class UnderOverVoltageSecurityIndex extends AbstractSecurityIndex { - - static final String XML_NAME = "underovervoltage"; - - private static final double INDEX_THRESHOLD = 1.0; - private final double indexValue; - - public static UnderOverVoltageSecurityIndex fromXml(String contingencyId, XMLStreamReader xmlsr) throws XMLStreamException { - String text = null; - while (xmlsr.hasNext()) { - int eventType = xmlsr.next(); - switch (eventType) { - case XMLEvent.CHARACTERS: - text = xmlsr.getText(); - break; - case XMLEvent.END_ELEMENT: - if ("vx".equals(xmlsr.getLocalName())) { - return new UnderOverVoltageSecurityIndex(contingencyId, Double.parseDouble(text)); - } - break; - } - } - throw new InternalError("Should not have happened"); - } - - public UnderOverVoltageSecurityIndex(String contingencyId, double indexValue) { - super(contingencyId, SecurityIndexType.OVERUNDERVOLTAGE); - this.indexValue = indexValue; - } - - public double getIndexValue() { - return indexValue; - } - - @Override - public boolean isOk() { - return !(indexValue > INDEX_THRESHOLD); - } - - @Override - public void toXml(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - xmlWriter.writeStartElement("index"); - xmlWriter.writeAttribute("name", XML_NAME); - xmlWriter.writeStartElement("vx"); - xmlWriter.writeCharacters(Double.toString(indexValue)); - xmlWriter.writeEndElement(); - xmlWriter.writeEndElement(); - xmlWriter.writeEndDocument(); - } - - @Override - public Map toMap() { - return ImmutableMap.of("vx", Double.toString(indexValue)); - } -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndexTest.java deleted file mode 100644 index 9045a509..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/OverloadSecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class OverloadSecurityIndexTest { - - public OverloadSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "0.5"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - OverloadSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = OverloadSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getIndexValue() == 0.5d); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndexTest.java deleted file mode 100644 index e057f0cb..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/SmallSignalSecurityIndexTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.util.Arrays; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class SmallSignalSecurityIndexTest { - - public SmallSignalSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException { - String xml = "0.51.0 2.03.0 4.05.0 6.0"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - SmallSignalSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = SmallSignalSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getGmi() == 0.5d); - assertTrue(Arrays.equals(index.getAmi(), new double[] {1, 2})); - assertTrue(Arrays.deepEquals(index.getSmi(), new double[][] { new double[] {3, 4}, new double[] {5, 6}})); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TransientSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TransientSecurityIndexTest.java deleted file mode 100644 index 5004df8f..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TransientSecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TransientSecurityIndexTest { - - public TransientSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "0.5"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TransientSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TransientSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getJ() == 0.5d); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndexTest.java deleted file mode 100644 index 7d383209..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoFrequencySecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoFrequencySecurityIndexTest { - - public TsoFrequencySecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "1"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TsoFrequencySecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TsoFrequencySecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getFreqOutCount() == 1); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomatonTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomatonTest.java deleted file mode 100644 index fd86478b..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorSpeedAutomatonTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import org.junit.Test; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * @author Geoffroy Jamgotchian - */ -public class TsoGeneratorSpeedAutomatonTest { - - @Test - public void testXml() throws IOException, XMLStreamException { - String xml = "abc"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TsoGeneratorSpeedAutomaton index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TsoGeneratorSpeedAutomaton.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getOnUnderSpeedDiconnectedGenerators().equals(Arrays.asList("a", "b"))); - assertTrue(index.getOnOverSpeedDiconnectedGenerators().equals(Arrays.asList("c"))); - assertEquals(xml, index.toXml()); - } -} \ No newline at end of file diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomatonTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomatonTest.java deleted file mode 100644 index 348c5d05..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoGeneratorVoltageAutomatonTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import org.junit.Test; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import java.util.Arrays; - -import static org.junit.Assert.*; - -/** - * @author Geoffroy Jamgotchian - */ -public class TsoGeneratorVoltageAutomatonTest { - - @Test - public void testXml() throws IOException, XMLStreamException { - String xml = "abc"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TsoGeneratorVoltageAutomaton index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TsoGeneratorVoltageAutomaton.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getOnUnderVoltageDiconnectedGenerators().equals(Arrays.asList("a", "b"))); - assertTrue(index.getOnOverVoltageDiconnectedGenerators().equals(Arrays.asList("c"))); - assertEquals(xml, index.toXml()); - } -} \ No newline at end of file diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndexTest.java deleted file mode 100644 index 53937b82..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOverloadSecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoOverloadSecurityIndexTest { - - public TsoOverloadSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "true1"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TsoOverloadSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TsoOverloadSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getOverloadCount() == 1); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndexTest.java deleted file mode 100644 index 7f8d1eae..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoOvervoltageSecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoOvervoltageSecurityIndexTest { - - public TsoOvervoltageSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "true1"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TsoOvervoltageSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TsoOvervoltageSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getOvervoltageCount() == 1); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndexTest.java deleted file mode 100644 index 6e8dc6b6..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoSynchroLossSecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoSynchroLossSecurityIndexTest { - - public TsoSynchroLossSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "1"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TsoSynchroLossSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TsoSynchroLossSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getSynchroLossCount() == 1); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndexTest.java deleted file mode 100644 index e7ad310c..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/TsoUndervoltageSecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class TsoUndervoltageSecurityIndexTest { - - public TsoUndervoltageSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "true1"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - TsoUndervoltageSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = TsoUndervoltageSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getUndervoltageCount() == 1); - assertEquals(xml, index.toXml()); - } - -} diff --git a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndexTest.java b/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndexTest.java deleted file mode 100644 index ecc90009..00000000 --- a/simulation-api/src/test/java/eu/itesla_project/simulation/securityindexes/UnderOverVoltageSecurityIndexTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium) - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ -package eu.itesla_project.simulation.securityindexes; - -import java.io.IOException; -import java.io.Reader; -import java.io.StringReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import org.junit.Test; -import static org.junit.Assert.*; - -/** - * - * @author Geoffroy Jamgotchian - */ -public class UnderOverVoltageSecurityIndexTest { - - public UnderOverVoltageSecurityIndexTest() { - } - - @Test - public void testXml() throws IOException, XMLStreamException{ - String xml = "0.5"; - XMLInputFactory xmlif = XMLInputFactory.newInstance(); - UnderOverVoltageSecurityIndex index; - try (Reader reader = new StringReader(xml)) { - XMLStreamReader xmlReader = xmlif.createXMLStreamReader(reader); - try { - index = UnderOverVoltageSecurityIndex.fromXml("c1", xmlReader); - } finally { - xmlReader.close(); - } - } - assertTrue(index.getIndexValue() == 0.5d); - assertEquals(xml, index.toXml()); - } - -} diff --git a/ucte-import/pom.xml b/ucte-import/pom.xml index fda2045b..ebe7e83d 100644 --- a/ucte-import/pom.xml +++ b/ucte-import/pom.xml @@ -21,6 +21,10 @@ UCTE import + + com.google.auto.service + auto-service + org.slf4j slf4j-api @@ -28,13 +32,12 @@ ${project.groupId} iidm-network-api - ${project.version} ${project.groupId} iidm-converter-api - ${project.version} + ${project.groupId} ucte-network From 76b1c2da9e51b4e2b830c06d1647f2f249e49bb2 Mon Sep 17 00:00:00 2001 From: Mathieu Bague Date: Tue, 29 Nov 2016 13:54:13 +0100 Subject: [PATCH 3/6] Compile iPST core modules before compiling iPST modules --- .travis.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4f8dcaae..3a9f30ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,13 @@ language: java + jdk: - - oraclejdk8 -after_success: - - mvn clean test jacoco:report coveralls:report \ No newline at end of file +- oraclejdk8 + +install: +# Build iPST core +- git clone https://github.com/itesla/ipst-core itesla/ipst-core +- cd itesla/ipst-core && mvn install + +script: +- mvn clean test jacoco:report coveralls:report + From 72435c3e705cce083ada1fde788806749152c38b Mon Sep 17 00:00:00 2001 From: Mathieu Bague Date: Tue, 29 Nov 2016 14:00:49 +0100 Subject: [PATCH 4/6] Change directory to TRAVIS_BUILD_DIR before commit --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 3a9f30ac..6b25a010 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,5 +9,6 @@ install: - cd itesla/ipst-core && mvn install script: +- cd ${TRAVIS_BUILD_DIR} - mvn clean test jacoco:report coveralls:report From de22e091b3929b75105af24aac39bb30cd007b6b Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Tue, 29 Nov 2016 16:38:58 +0100 Subject: [PATCH 5/6] Remove unnecessary graph dependency --- ampl-export/pom.xml | 5 ----- eurostag-ech-export/pom.xml | 5 ----- mmap-offline-db/pom.xml | 5 ----- modules/pom.xml | 5 ----- 4 files changed, 20 deletions(-) diff --git a/ampl-export/pom.xml b/ampl-export/pom.xml index f952715f..a5303409 100644 --- a/ampl-export/pom.xml +++ b/ampl-export/pom.xml @@ -54,10 +54,5 @@ iidm-network-impl test - - eu.itesla_project - graph - test - diff --git a/eurostag-ech-export/pom.xml b/eurostag-ech-export/pom.xml index c3078caf..f58c76ec 100644 --- a/eurostag-ech-export/pom.xml +++ b/eurostag-ech-export/pom.xml @@ -55,11 +55,6 @@ iidm-network-impl test - - eu.itesla_project - graph - test - eu.itesla_project iidm-network-test diff --git a/mmap-offline-db/pom.xml b/mmap-offline-db/pom.xml index 9919c590..56d40aef 100644 --- a/mmap-offline-db/pom.xml +++ b/mmap-offline-db/pom.xml @@ -90,11 +90,6 @@ iidm-network-impl test - - eu.itesla_project - graph - test - diff --git a/modules/pom.xml b/modules/pom.xml index 7aee52c4..6eafcbf0 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -144,11 +144,6 @@ iidm-network-impl test - - eu.itesla_project - graph - test - org.slf4j log4j-over-slf4j From 90e6102dc2458d63febf7df1e3c49310774ab8ca Mon Sep 17 00:00:00 2001 From: Mathieu Bague Date: Tue, 29 Nov 2016 18:51:06 +0100 Subject: [PATCH 6/6] Rename logback.xml and logback-wp5.xml to logback-offline.xml and logback-online.xml --- config/{logback.xml => logback-offline.xml} | 0 config/{logback-wp5.xml => logback-online.xml} | 0 scripts/offline-mpi-task.sh | 4 ++-- scripts/online-mpi-task.sh | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) rename config/{logback.xml => logback-offline.xml} (100%) rename config/{logback-wp5.xml => logback-online.xml} (100%) diff --git a/config/logback.xml b/config/logback-offline.xml similarity index 100% rename from config/logback.xml rename to config/logback-offline.xml diff --git a/config/logback-wp5.xml b/config/logback-online.xml similarity index 100% rename from config/logback-wp5.xml rename to config/logback-online.xml diff --git a/scripts/offline-mpi-task.sh b/scripts/offline-mpi-task.sh index f87846cd..354c3409 100755 --- a/scripts/offline-mpi-task.sh +++ b/scripts/offline-mpi-task.sh @@ -35,8 +35,8 @@ if [ $rank = 0 ]; then options+=" -Dcom.sun.management.jmxremote.authenticate=false" options+=" -Dcom.sun.management.jmxremote.ssl=false" options+=" -Dlogback.configurationFile=" - [ -f "$itesla_config_dir/logback.xml" ] && options+="$itesla_config_dir" || options+="$installDir/etc" - options+="/logback.xml" + [ -f "$itesla_config_dir/logback-offline.xml" ] && options+="$itesla_config_dir" || options+="$installDir/etc" + options+="/logback-offline.xml" $JAVA_HOME/bin/java \ -Xmx8G \ -verbose:gc -XX:+PrintGCTimeStamps -Xloggc:$tmpdir/gc.log \ diff --git a/scripts/online-mpi-task.sh b/scripts/online-mpi-task.sh index 81f0395f..6fdb292c 100755 --- a/scripts/online-mpi-task.sh +++ b/scripts/online-mpi-task.sh @@ -40,8 +40,8 @@ if [ $rank = 0 ]; then options+=" -Dcom.sun.management.jmxremote.ssl=false" options+=" -Djava.io.tmpdir=$installDir/tmp" options+=" -Dlogback.configurationFile=" - [ -f "$itesla_config_dir/logback-wp5.xml" ] && options+="$itesla_config_dir" || options+="$installDir/etc" - options+="/logback-wp5.xml" + [ -f "$itesla_config_dir/logback-online.xml" ] && options+="$itesla_config_dir" || options+="$installDir/etc" + options+="/logback-online.xml" $JAVA_HOME/bin/java \ -Xmx2048m \ -verbose:gc -XX:+PrintGCTimeStamps -Xloggc:$installDir/logs/gc.log \