Skip to content

Commit

Permalink
Merge branch 'sp/#000-em-combined' into sp/#339-em-it
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-peter committed Oct 14, 2022
2 parents f5e1e63 + 3c23dc3 commit 25df077
Show file tree
Hide file tree
Showing 15 changed files with 214 additions and 79 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Await and send responses for distinct pairs of sender reference and target node
- Removed deprecations from `CsvGridSource` and added `TestGridFactory` [#304](https://github.com/ie3-institute/simona/issues/304)
- Fixed config of vn_146_lv_small [#290](https://github.com/ie3-institute/simona/issues/290)
- Adapted to changes of EvcsInput in PSDM [#377](https://github.com/ie3-institute/simona/pull/377)

### Removed
- Remove workaround for tscfg tmp directory [#178](https://github.com/ie3-institute/simona/issues/178)
Expand Down
14 changes: 7 additions & 7 deletions input/samples/pcm/grid/evcs_input.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
uuid,cos_phi_rated,id,node,operates_from,operates_until,operator,q_characteristics,chargingpoints,type,location_type
925c13f9-f82a-4010-ac12-92e1e8a0f419,1.0,evcs_home,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,home
06ca05f8-e4ac-4d4d-ad1c-67e6604b395a,1.0,evcs_work,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,work
d625249e-8e60-4318-837e-a0cfa9b91f3e,1.0,evcs_customer_parking,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,customer_parking
9c20507d-f5d5-4d61-b98d-0542e7d68f1b,1.0,evcs_street,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,street
58b78eed-ae99-44b5-b817-2e990018edb9,1.0,evcs_charging_hub_town,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,charging_hub_town
6e219da2-b233-48e7-9960-6aad29b39dc8,1.0,evcs_charging_hub_highway,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,charging_hub_highway
uuid,cos_phi_rated,id,node,operates_from,operates_until,operator,q_characteristics,chargingpoints,type,location_type,"v2gsupport"
925c13f9-f82a-4010-ac12-92e1e8a0f419,1.0,evcs_home,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,home,true
06ca05f8-e4ac-4d4d-ad1c-67e6604b395a,1.0,evcs_work,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,work,true
d625249e-8e60-4318-837e-a0cfa9b91f3e,1.0,evcs_customer_parking,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,customer_parking,true
9c20507d-f5d5-4d61-b98d-0542e7d68f1b,1.0,evcs_street,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,street,true
58b78eed-ae99-44b5-b817-2e990018edb9,1.0,evcs_charging_hub_town,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,charging_hub_town,true
6e219da2-b233-48e7-9960-6aad29b39dc8,1.0,evcs_charging_hub_highway,2a5e9609-b66c-428d-a67a-a1437130ffb0,,,,cosPhiFixed:{(0.00,1.0)},100000,cee16,charging_hub_highway,true
6 changes: 3 additions & 3 deletions input/samples/vn_simona/fullGrid/evcs_input.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"uuid","cos_phi_rated","id","node","operates_from","operates_until","operator","q_characteristics","chargingpoints","type","location_type"
06a14909-366e-4e94-a593-1016e1455b30,0.9,test_evcs_1,5f1c776c-6935-40f7-ba9e-60646e08992b,,,,cosPhiFixed:{(0.00,1.0)},4,ChargingStationType1,HOME
104acdaa-5dc5-4197-aed2-2fddb3c4f237,0.9,test_evcs_2,ed4697fd-016c-40c2-a66b-e793878dadea,,,,cosPhiFixed:{(0.00,1.0)},4,ChargingStationType1,HOME
"uuid","cos_phi_rated","id","node","operates_from","operates_until","operator","q_characteristics","chargingpoints","type","location_type","v2gsupport"
06a14909-366e-4e94-a593-1016e1455b30,0.9,test_evcs_1,5f1c776c-6935-40f7-ba9e-60646e08992b,,,,cosPhiFixed:{(0.00,1.0)},4,ChargingStationType1,HOME,true
104acdaa-5dc5-4197-aed2-2fddb3c4f237,0.9,test_evcs_2,ed4697fd-016c-40c2-a66b-e793878dadea,,,,cosPhiFixed:{(0.00,1.0)},4,ChargingStationType1,HOME,true
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected trait ParticipantAgentFundamentals[
try {
/* Register for services */
val awaitRegistrationResponsesFrom =
registerForServices(inputModel, services)
registerForServices(inputModel, services, self, maybeEmAgent)

// always request flex options for first sim tick
maybeEmAgent.foreach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import edu.ie3.simona.model.participant.{
ModelState,
SystemParticipant
}
import edu.ie3.simona.ontology.messages.SchedulerMessage.ScheduleTriggerMessage
import edu.ie3.simona.ontology.messages.services.EvMessage.RegisterForEvDataMessage
import edu.ie3.simona.ontology.messages.services.WeatherMessage.RegisterForWeatherMessage
import edu.ie3.simona.ontology.trigger.Trigger.ActivityStartTrigger

trait ServiceRegistration[
PD <: PrimaryDataWithApparentPower[PD],
Expand All @@ -45,27 +47,42 @@ trait ServiceRegistration[
* Input model definition
* @param services
* Definition of where to get what
* @param agentRef
* The participant agent actor
* @param maybeEmAgent
* The EmAgent if the participant is controlled by an EMS
* @return
* a vector of actor references to wait for responses
*/
def registerForServices(
inputModel: I,
services: Option[Vector[SecondaryDataService[_ <: SecondaryData]]]
): Vector[ActorRef] =
services: Option[Seq[SecondaryDataService[_ <: SecondaryData]]],
agentRef: ActorRef,
maybeEmAgent: Option[ActorRef]
): Seq[ActorRef] =
services
.map(sources =>
sources.flatMap(service =>
registerForSecondaryService(service, inputModel)
registerForSecondaryService(
service,
inputModel,
agentRef,
maybeEmAgent
)
)
)
.getOrElse(Vector.empty[ActorRef])
.getOrElse(Seq.empty[ActorRef])

/** Register for the distinct secondary service
*
* @param serviceDefinition
* Definition of the service
* @param inputModel
* Input model that is interested in the information
* @param agentRef
* The participant agent actor
* @param maybeEmAgent
* The EmAgent if the participant is controlled by an EMS
* @tparam S
* Type of the secondary data, that is awaited
* @return
Expand All @@ -76,20 +93,22 @@ trait ServiceRegistration[
S <: SecondaryData
](
serviceDefinition: SecondaryDataService[S],
inputModel: I
inputModel: I,
agentRef: ActorRef,
maybeEmAgent: Option[ActorRef]
): Option[ActorRef] = serviceDefinition match {
case SecondaryDataService.ActorPriceService(_) =>
log.debug(
s"Attempt to register for {}. This is currently not supported.",
ActorPriceService
)
None
case ActorWeatherService(actorRef) =>
registerForWeather(actorRef, inputModel)
Some(actorRef)
case ActorEvMovementsService(actorRef) =>
registerForEvMovements(actorRef, inputModel)
Some(actorRef)
case ActorWeatherService(serviceRef) =>
registerForWeather(serviceRef, inputModel)
Some(serviceRef)
case ActorEvMovementsService(serviceRef) =>
registerForEvMovements(serviceRef, inputModel, agentRef, maybeEmAgent)
Some(serviceRef)
}

/** Register for the weather service
Expand Down Expand Up @@ -122,19 +141,42 @@ trait ServiceRegistration[

/** Register for the EV movement service
*
* @param actorRef
* @param serviceRef
* Actor reference of the EV movements service
* @param inputModel
* Input model of the simulation mode
* @param maybeEmAgent
* The EmAgent if the participant is controlled by an EMS
* @return
*/
private def registerForEvMovements(
actorRef: ActorRef,
inputModel: I
serviceRef: ActorRef,
inputModel: I,
evcsRef: ActorRef,
maybeEmAgent: Option[ActorRef]
): Unit = {
inputModel match {
case evcsInput: EvcsInput =>
actorRef ! RegisterForEvDataMessage(evcsInput.getUuid)
val scheduleParticipant = (tick: Long) =>
ScheduleTriggerMessage(
ActivityStartTrigger(
tick
),
evcsRef
)

// when using an EmAgent, activation schedules have to be stacked
val scheduleFunc = (tick: Long) =>
maybeEmAgent
.map { emAgent =>
ScheduleTriggerMessage(
scheduleParticipant(tick),
emAgent
)
}
.getOrElse(scheduleParticipant(tick))

serviceRef ! RegisterForEvDataMessage(evcsInput.getUuid, scheduleFunc)
case _ =>
throw new ServiceRegistrationException(
s"Cannot register for EV movements information at node ${inputModel.getNode.getId} " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ object ParticipantStateData {
+PD <: PrimaryDataWithApparentPower[PD]
](
baseStateData: BaseStateData[PD],
pendingResponses: Vector[ActorRef],
pendingResponses: Seq[ActorRef],
foreseenNextDataTicks: Map[ActorRef, Long] = Map.empty
) extends ParticipantStateData[PD]
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ final case class EvcsModel(
cosPhiRated: Double,
chargingPoints: Int,
locationType: EvcsLocationType,
vehicle2grid: Boolean,
strategy: ChargingStrategy.Value
) extends SystemParticipant[EvcsRelevantData, EvcsState](
uuid,
Expand Down Expand Up @@ -602,7 +603,7 @@ final case class EvcsModel(
zeroKW

val maxDischarging =
if (!isEmpty(ev))
if (!isEmpty(ev) && vehicle2grid)
maxPower.multiply(-1)
else
zeroKW
Expand Down Expand Up @@ -970,6 +971,7 @@ object EvcsModel {
inputModel.getCosPhiRated,
inputModel.getChargingPoints,
inputModel.getLocationType,
inputModel.getV2gSupport,
ChargingStrategy(chargingStrategy)
)
}
Expand Down Expand Up @@ -1013,6 +1015,7 @@ object EvcsModel {
cosPhiRated: Double,
chargingPoints: Int,
locationType: EvcsLocationType,
vehicle2grid: Boolean,
chargingStrategy: ChargingStrategy.Value
): EvcsModel = {
val model = new EvcsModel(
Expand All @@ -1027,6 +1030,7 @@ object EvcsModel {
cosPhiRated,
chargingPoints,
locationType,
vehicle2grid,
chargingStrategy
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ object SchedulerMessage {
) extends SchedulerMessage

/** schedule a new trigger TO the [[SimScheduler]]. This message should send
* only to the [[SimScheduler]]
* only to the [[SimScheduler]].
*
* Interface Trigger is extended so that ScheduleTriggerMessages can be
* stacked.
*
* @param trigger
* to schedule
Expand All @@ -42,6 +45,9 @@ object SchedulerMessage {
trigger: Trigger,
actorToBeScheduled: ActorRef
) extends SchedulerMessage
with Trigger {
override def tick: Long = trigger.tick
}

/** Confirm the end of an action e.g. fsm state transitions for one tick to
* and ONLY to the [[SimScheduler]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package edu.ie3.simona.ontology.messages.services
import edu.ie3.simona.agent.participant.data.Data.SecondaryData
import edu.ie3.simona.api.data.ev.model.EvModel
import edu.ie3.simona.api.data.ev.ontology.EvMovementsMessage.EvcsMovements
import edu.ie3.simona.ontology.messages.SchedulerMessage.ScheduleTriggerMessage
import edu.ie3.simona.ontology.messages.services.ServiceMessage.{
ProvisionMessage,
ServiceRegistrationMessage
Expand All @@ -25,9 +26,12 @@ object EvMessage {
*
* @param evcs
* the charging station
* @param scheduleFunc
* function providing the proper ScheduleTriggerMessage for a given tick
*/
final case class RegisterForEvDataMessage(
evcs: UUID
evcs: UUID,
scheduleFunc: Long => ScheduleTriggerMessage
) extends EvMessage
with ServiceRegistrationMessage

Expand Down
Loading

0 comments on commit 25df077

Please sign in to comment.