Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into mb/#42-ba-feature-branch
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgent.scala
#	src/main/scala/edu/ie3/simona/agent/participant/evcs/EvcsAgentFundamentals.scala
  • Loading branch information
ckittl committed Jan 19, 2022
2 parents 270112e + bf84784 commit 793d0dd
Show file tree
Hide file tree
Showing 22 changed files with 202 additions and 171 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 @@ -10,4 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Consolidate request replies for different sub grid gates in one message
- Await and send responses for distinct pairs of sender reference and target node

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

[Unreleased]: https://github.com/ie3-institute/simona
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
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.2.0'// 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.1" // 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.8"
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.12"
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.2.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 @@ -8,20 +8,17 @@ package edu.ie3.simona.agent.participant.evcs

import akka.actor.{ActorRef, Props}
import edu.ie3.datamodel.models.input.system.EvcsInput
import edu.ie3.simona.agent.participant.{
ParticipantAgent,
ParticipantAgentFundamentals
}
import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{
ApparentPower,
ZERO_POWER
}
import edu.ie3.simona.agent.participant.{ParticipantAgent, ParticipantAgentFundamentals}
import edu.ie3.simona.agent.participant.data.Data.PrimaryData.{ApparentPower, ZERO_POWER}
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.evcs.EvcsModel
import edu.ie3.simona.model.participant.evcs.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 +54,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 @@ -49,7 +49,6 @@ import edu.ie3.simona.ontology.messages.services.EvMessage.{
CurrentPriceRequest,
CurrentPriceResponse,
DepartedEvsResponse,
EvFreeLotsRequest,
EvMovementData,
FreeLotsResponse
}
Expand Down Expand Up @@ -275,12 +274,6 @@ protected trait EvcsAgentFundamentals
modelBaseStateData,
evcsData
)
case (_, Some(EvFreeLotsRequest)) =>
handleFreeLotsRequestAndGoIdle(
currentTick,
scheduler,
modelBaseStateData
)
case (_, Some(CurrentPriceRequest)) =>
handleCurrentPriceRequestAndGoIdle(
currentTick,
Expand All @@ -302,26 +295,20 @@ 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
)
Expand All @@ -335,11 +322,6 @@ protected trait EvcsAgentFundamentals
evcsModel.uuid,
evcsModel.chargingPoints - lastEvs.size
)

goToIdleReplyCompletionAndScheduleTriggerForNextAction(
modelBaseStateData,
scheduler
)
}

private def handleCurrentPriceRequestAndGoIdle(
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/edu/ie3/simona/api/ExtMessageUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ object ExtMessageUtils {
) {
def toSimona(triggerId: Long, triggerActor: ActorRef): CompletionMessage = {
val newTriggers =
Option.when(!extCompl.getNewTriggers.isEmpty) {
extCompl.getNewTriggers.asScala.map { tick =>
Option.when(!extCompl.newTriggers.isEmpty) {
extCompl.newTriggers.asScala.map { tick =>
ScheduleTriggerMessage(ActivityStartTrigger(tick), triggerActor)
}.toSeq
}
Expand Down
Loading

0 comments on commit 793d0dd

Please sign in to comment.