Skip to content

Commit

Permalink
First runnable service
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkleiven committed Sep 23, 2023
1 parent add1d7c commit 11c13a5
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
78 changes: 78 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.statnett</groupId>
<artifactId>load-flow-service</artifactId>
<version>0.0.0</version>
<properties>
<kotlin.version>1.9.10</kotlin.version>
<ktor.version>2.3.4</ktor.version>
<main.class>com.github.statnett.loadflowservice.AppKt</main.class>
</properties>

<repositories>
<repository>
<id>ktor-eap</id>
<url>https://maven.pkg.jetbrains.space/public/p/ktor/eap</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.powsybl</groupId>
<artifactId>powsybl-starter</artifactId>
<version>2023.2.4</version>
</dependency>

<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-server-core-jvm</artifactId>
<version>${ktor.version}</version>
</dependency>
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-server-netty-jvm</artifactId>
<version>${ktor.version}</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>${project.basedir}/src/main</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>

<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals> <goal>single</goal> </goals>
<configuration>
<archive>
<manifest>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
17 changes: 17 additions & 0 deletions src/main/app.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.github.statnett.loadflowservice

import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*

fun main() {
embeddedServer(Netty, port = 8080) {
routing {
get("/") {
call.respondText("Hello, world!")
}
}
}.start(wait = true)
}
14 changes: 14 additions & 0 deletions src/main/solver.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.github.statnett.loadflowservice

import com.powsybl.iidm.network.Network
import com.powsybl.loadflow.LoadFlowParameters
import com.powsybl.loadflow.LoadFlow
import java.io.InputStream

fun networkFromStream(fname: String, content: InputStream): Network {
return Network.read(fname, content)
}

fun solve(network: Network, parameters: LoadFlowParameters) {
LoadFlow.run(network, parameters);
}

0 comments on commit 11c13a5

Please sign in to comment.