Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into ck/#22-dbfsMultipleCon…
Browse files Browse the repository at this point in the history
…nections

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
ckittl committed Jan 12, 2022
2 parents ba62812 + 5074110 commit a5bf9c5
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 158 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ updates:
- johanneshiry
- t-ober
- sensarmad
ignore:
- dependency-name: org.spockframework:spock-core
versions:
- 2.1-groovy-3.0-SNAPSHOT
- 2.1-groovy-2.5-SNAPSHOT
- dependency-name: org.scalatest:scalatest_2.13
versions:
- 3.3.0-SNAP+
- dependency-name: org.scalatestplus:mockito-3-4_2.13
versions:
- 3.3.0.0-SNAP+
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- Improving code readability in EvcsAgent by moving FreeLotsRequest to separate methods

### Fixed
- Fix power exchange between grids
- Consolidate request replies for different sub grid gates in one message
Expand Down
9 changes: 4 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
////////////////////////////////

/* project configuration */
String javaVersionId = 'jdk-8' // id that matches the java tool with the java version that should be used set as jenkins property
String javaVersionId = 'jdk-17' // id that matches the java tool with the java version that should be used set as jenkins property

/* git configuration */
String projectName = 'simona' // name of the repository, is case insensitive
Expand Down Expand Up @@ -114,8 +114,7 @@ node {

gradle('--refresh-dependencies clean spotlessCheck pmdMain pmdTest reportScoverage checkScoverage', projectName)

// due to an issue with openjdk-8 we use openjdk-11 for javadocs generation
sh(script: """set +x && cd $projectName""" + ''' set +x; ./gradlew javadoc -Dorg.gradle.java.home=/opt/java/openjdk''', returnStdout: true)
sh(script: """set +x && cd $projectName""" + ''' set +x; ./gradlew javadoc''', returnStdout: true)
}

// sonarqube analysis
Expand Down Expand Up @@ -158,7 +157,7 @@ node {
*/
sh(
script: """set +x && cd $projectName""" +
''' set +x; ./gradlew javadoc -Dorg.gradle.java.home=/opt/java/openjdk''',
''' set +x; ./gradlew javadoc''',
returnStdout: true
)

Expand Down Expand Up @@ -388,7 +387,7 @@ def deployJavaDocs(String projectName, String sshCredentialsId, String gitChecko
"git config user.name 'Johannes Hiry' && " +
"git fetch --depth=1 origin api-docs && " +
"git checkout api-docs && " +
"cd .. && ./gradlew javadoc -Dorg.gradle.java.home=/opt/java/openjdk && " +
"cd .. && ./gradlew javadoc && " +
"cp -R build/docs/javadoc/* tmp-api-docs && " +
"cd tmp-api-docs &&" +
"git add --all && git commit -m 'updated api-docs' && git push origin api-docs:api-docs" +
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<p align="center">
<img src="docs/logo/logo_tightcrop_transparent.png" width="200px" alt="simona logo" align="center"/>
</p>

# SIMONA
[![Build Status](https://simona.ie3.e-technik.tu-dortmund.de/ci/buildStatus/icon?job=ie3-institute%2Fsimona%2Fdev)](https://simona.ie3.e-technik.tu-dortmund.de/ci/job/ie3-institute/job/simona/job/dev/)
[![Quality Gate Status](https://simona.ie3.e-technik.tu-dortmund.de/sonar/api/project_badges/measure?project=edu.ie3%3Asimona&metric=alert_status)](https://simona.ie3.e-technik.tu-dortmund.de/sonar/dashboard?id=edu.ie3%3Asimona)
[![codecov](https://codecov.io/gh/ie3-institute/simona/branch/main/graph/badge.svg?token=pDg4Pbbp9L)](https://codecov.io/gh/ie3-institute/simona)
[![Documentation Status](https://readthedocs.org/projects/simona/badge/?version=latest)](https://simona.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/github/license/ie3-institute/simona)](https://github.com/ie3-institute/simona/blob/main/LICENSE)
[![Maven Central](https://img.shields.io/maven-central/v/com.github.ie3-institute/simona.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.github.ie3-institute%22%20AND%20a:%22simona%22)
<p align="center">
<img src="docs/logo/logo_tightcrop_transparent.png" width="200px" alt="simona logo" align="center"/>
</p>

# SIMONA
The agent-based simulation environment SIMONA provides a simulation toolbox to run and implement large-scale agent-based
electricity grid simulations with focus on distribution grids. As a result, close-to-reality time series are
generated from various system participants and grid assets that can be used to analyze a given power grid.
Expand Down
39 changes: 23 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ plugins {
id 'signing'
id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
id 'pmd' // code check, working on source code
id 'com.diffplug.spotless' version '6.0.4'// code format
id 'com.diffplug.spotless' version '6.1.2'// code format
id 'com.github.onslip.gradle-one-jar' version '1.0.6' // pack a self contained jar
id "com.github.ben-manes.versions" version '0.39.0'
id "com.github.ben-manes.versions" version '0.41.0'
id "de.undercouch.download" version "4.1.2" // downloads plugin
id "kr.motd.sphinx" version "2.10.1" // documentation generation
id "com.github.johnrengelman.shadow" version "7.1.0" // fat jar
id "com.github.johnrengelman.shadow" version "7.1.2" // fat jar
id "org.sonarqube" version "3.3" // sonarqube
id "org.scoverage" version "7.0.0" // scala code coverage scoverage
id "com.github.maiflai.scalatest" version "0.31" // run scalatest without specific spec task
id "com.github.maiflai.scalatest" version "0.32" // run scalatest without specific spec task
id 'org.hidetake.ssh' version '2.10.1'
id 'net.thauvin.erik.gradle.semver' version '1.0.4' // semantic versioning
}

ext {
//version (changing these should be considered thoroughly!)
javaVersion = JavaVersion.VERSION_1_8
javaVersion = JavaVersion.VERSION_17

scalaVersion = '2.13'
scalaBinaryVersion = '2.13.5'
akkaVersion = '2.6.17'
scalaBinaryVersion = '2.13.7'
akkaVersion = '2.6.18'
tscfgVersion = '0.9.996'

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator // location of script plugins
Expand Down Expand Up @@ -61,13 +61,13 @@ repositories {

dependencies {
// ie³ internal repository
implementation('com.github.ie3-institute:PowerSystemUtils:1.5.3') {
implementation('com.github.ie3-institute:PowerSystemUtils:1.6') {
exclude group: 'org.apache.logging.log4j'
exclude group: 'org.slf4j'
/* Exclude our own nested dependencies */
exclude group: 'com.github.ie3-institute'
}
implementation('com.github.ie3-institute:PowerSystemDataModel:2.1-SNAPSHOT') {
implementation('com.github.ie3-institute:PowerSystemDataModel:2.1.0') {
exclude group: 'org.apache.logging.log4j'
exclude group: 'org.slf4j'
/* Exclude our own nested dependencies */
Expand All @@ -89,12 +89,12 @@ dependencies {

/* logging */
implementation "com.typesafe.scala-logging:scala-logging_${scalaVersion}:3.9.4" // akka scala logging
implementation "ch.qos.logback:logback-classic:1.2.7"
implementation "ch.qos.logback:logback-classic:1.2.10"

/* testing */
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
testImplementation 'org.scalatestplus:mockito-3-4_2.13:3.2.9.0'
implementation 'org.mockito:mockito-core:4.1.0' // mocking framework
testImplementation 'org.spockframework:spock-core:2.1-M2-groovy-3.0'
testImplementation 'org.scalatestplus:mockito-3-4_2.13:3.2.10.0'
implementation 'org.mockito:mockito-core:4.2.0' // mocking framework
testImplementation "org.scalatest:scalatest_${scalaVersion}:3.2.10"
testRuntimeClasspath 'com.vladsch.flexmark:flexmark-all:0.62.2'
testImplementation group: 'org.pegdown', name: 'pegdown', version: '1.6.0'
Expand All @@ -108,7 +108,7 @@ dependencies {
implementation "com.typesafe.akka:akka-actor_${scalaVersion}:${akkaVersion}"
implementation "com.typesafe.akka:akka-slf4j_${scalaVersion}:${akkaVersion}"
implementation "com.typesafe.akka:akka-cluster_${scalaVersion}:${akkaVersion}"
implementation "com.lightbend.akka:akka-stream-alpakka-csv_${scalaVersion}:1.1.2"
implementation "com.lightbend.akka:akka-stream-alpakka-csv_${scalaVersion}:3.0.4"
implementation "com.typesafe.akka:akka-actor_${scalaVersion}:${akkaVersion}"
implementation "com.typesafe.akka:akka-cluster-sharding_${scalaVersion}:${akkaVersion}"
implementation "com.typesafe.akka:akka-cluster-tools_${scalaVersion}:${akkaVersion}"
Expand All @@ -118,11 +118,18 @@ dependencies {
implementation "com.github.carueda:tscfg_2.13:$tscfgVersion"
implementation "com.github.scopt:scopt_${scalaVersion}:4.0.1" // cmd args parser

// JTS
implementation ('org.locationtech.jts:jts-core:1.18.2'){
exclude group: 'junit', module: 'junit'
}
implementation 'org.locationtech.jts.io:jts-io-common:1.18.2'

/* Scala compiler plugin for static code analysis */
implementation "com.sksamuel.scapegoat:scalac-scapegoat-plugin_${scalaBinaryVersion}:1.4.10"
scalaCompilerPlugin "com.sksamuel.scapegoat:scalac-scapegoat-plugin_${scalaBinaryVersion}:1.4.8"
implementation "com.sksamuel.scapegoat:scalac-scapegoat-plugin_${scalaBinaryVersion}:1.4.11"
scalaCompilerPlugin "com.sksamuel.scapegoat:scalac-scapegoat-plugin_${scalaBinaryVersion}:1.4.11"

implementation 'org.apache.commons:commons-math3:3.6.1' // apache commons math3
implementation 'org.apache.poi:poi-ooxml:5.1.0' // used for FilenameUtils
implementation 'javax.measure:unit-api:2.1.3'
implementation 'tech.units:indriya:2.1.2' // quantities
implementation 'org.apache.commons:commons-csv:1.9.0'
Expand Down
11 changes: 10 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx4096m

# Workaround to make spotless work with java 17 -
# see https://github.com/diffplug/spotless/tree/main/plugin-gradle#google-java-format and
# https://github.com/ie3-institute/simona/issues/59 for details
org.gradle.jvmargs=-Xmx4096m \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
1 change: 1 addition & 0 deletions gradle/scripts/scoverage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// https://github.com/scoverage/gradle-scoverage/issues/109 for details

scoverage {
scoverageVersion = "1.4.10"
scoverageScalaVersion = scalaBinaryVersion
coverageOutputHTML = false
coverageOutputXML = true
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion src/main/resources/config/config-template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RefSystemConfig {
gridIds: [string] # Sub grid numbers to apply to, expl.: 1,2,4..10
}

#@define abstract
#@define abstract extends !java.io.Serializable
BaseRuntimeConfig {
uuids: [string] # Unique id to identify the system participant models this config applies for
scaling: double # General scaling factor of the system participant model
Expand Down
12 changes: 10 additions & 2 deletions src/main/scala/edu/ie3/simona/agent/ValueStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ final case class ValueStore[+D](
*/
def last(requestedTick: Long): Option[(Long, D)] =
store
.filter(entry => entry._1 <= requestedTick)
.maxByOption(entry => entry._1)
.filter(_._1 <= requestedTick)
.maxByOption(_._1)

/** Get the last known entry (with the highest tick)
*
* @return
* An Option to the last entry
*/
def last(): Option[(Long, D)] =
store.maxByOption(_._1)

/** Acquires the stored information within the specified tick window
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{
}
import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService
import edu.ie3.simona.agent.participant.data.secondary.SecondaryDataService.ActorEvMovementsService
import edu.ie3.simona.agent.participant.statedata.BaseStateData.ParticipantModelBaseStateData
import edu.ie3.simona.agent.participant.statedata.ParticipantStateData
import edu.ie3.simona.agent.state.AgentState.Idle
import edu.ie3.simona.config.SimonaConfig.EvcsRuntimeConfig
import edu.ie3.simona.model.participant.EvcsModel
import edu.ie3.simona.model.participant.EvcsModel.EvcsRelevantData
import edu.ie3.simona.ontology.messages.services.EvMessage.EvFreeLotsRequest
import tech.units.indriya.ComparableQuantity

import javax.measure.quantity.Power
Expand Down Expand Up @@ -57,6 +60,19 @@ class EvcsAgent(
with EvcsAgentFundamentals {
override val alternativeResult: ApparentPower = ZERO_POWER

when(Idle) {
case Event(
EvFreeLotsRequest(tick),
modelBaseStateData: ParticipantModelBaseStateData[
ApparentPower,
EvcsRelevantData,
EvcsModel
]
) =>
handleFreeLotsRequest(tick, modelBaseStateData)
stay()
}

/** Determine the average result within the given tick window
*
* @param tickToResults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import edu.ie3.simona.model.participant.EvcsModel
import edu.ie3.simona.model.participant.EvcsModel.EvcsRelevantData
import edu.ie3.simona.ontology.messages.services.EvMessage.{
DepartedEvsResponse,
EvFreeLotsRequest,
EvMovementData,
FreeLotsResponse
}
Expand Down Expand Up @@ -264,12 +263,6 @@ protected trait EvcsAgentFundamentals
modelBaseStateData,
evcsData
)
case (_, Some(EvFreeLotsRequest)) =>
handleFreeLotsRequestAndGoIdle(
currentTick,
scheduler,
modelBaseStateData
)
}
.getOrElse(
throw new InconsistentStateException(
Expand All @@ -285,44 +278,33 @@ protected trait EvcsAgentFundamentals
}

/** Returns the number of free parking lots based on the last available state
* data. Sends completion message to scheduler without scheduling new
* activations.
* @param currentTick
* The current tick that has been triggered
* @param scheduler
* The scheduler ref
* data.
* @param tick
* The tick that free lots have been requested for
* @param modelBaseStateData
* The state data
* @return
* [[Idle]] state
*/
private def handleFreeLotsRequestAndGoIdle(
currentTick: Long,
scheduler: ActorRef,
protected def handleFreeLotsRequest(
tick: Long,
modelBaseStateData: ParticipantModelBaseStateData[
_ <: ApparentPower,
_,
_
]
): FSM.State[AgentState, ParticipantStateData[ApparentPower]] = {
): Unit = {
val evServiceRef = getService[ActorEvMovementsService](
modelBaseStateData.services
)

val (_, lastEvs) =
getTickIntervalAndLastEvs(currentTick, modelBaseStateData)
getTickIntervalAndLastEvs(tick, modelBaseStateData)

val evcsModel = getEvcsModel(modelBaseStateData)

evServiceRef ! FreeLotsResponse(
evcsModel.uuid,
evcsModel.chargingPoints - lastEvs.size
)

goToIdleReplyCompletionAndScheduleTriggerForNextAction(
modelBaseStateData,
scheduler
)
}

/** Handles a evcs movements message that contains information on arriving and
Expand Down
Loading

0 comments on commit a5bf9c5

Please sign in to comment.