forked from reinierl/docile-charge-point
-
Notifications
You must be signed in to change notification settings - Fork 32
/
do-a-transaction.scala
59 lines (46 loc) · 1.91 KB
/
do-a-transaction.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
val testIdToken = IdToken("01020304", IdTokenType.ISO14443, None)
say("Booting...")
bootNotification()
say("Setting EVSE 1 available")
statusNotification() // EVSE 1 available
val authRes = authorize(List(1), testIdToken, List())
if (authRes.idTokenInfo.status != AuthorizationStatus.Accepted) {
fail("Token not accepted")
} else {
say ("Authorized, starting transaction...")
statusNotification(connectorStatus = ConnectorStatus.Occupied)
val (tx, req) = startTransactionAtAuthorized(idToken = testIdToken)
sendSync(req)
prompt("Press ENTER to plug in cable")
sendSync(tx.plugInCable())
say("Starting to deliver energy...")
sendSync(tx.startEnergyOffer())
say("Sending some frivolous meter values")
sendSync(tx.update(tx.data, triggerReason = TriggerReason.MeterValuePeriodic, meterValue = Some(List(
MeterValue(List(
SampledValue(
value = BigDecimal(1400),
context = None,
measurand = None,
phase = None,
location = None,
signedMeterValue = None,
unitOfMeasure = None
)), Instant.now()),
MeterValue(List(
SampledValue(
value = BigDecimal(-4.3),
context = Some(ReadingContext.SamplePeriodic),
measurand = Some(Measurand.Frequency),
phase = Some(Phase.`L1-N`),
location = Some(Location.Inlet),
signedMeterValue = Some(SignedMeterValue("jfalksdjfl;asj", signatureMethod = SignatureMethod.ECDSAP256SHA256, encodingMethod = EncodingMethod.DLMSMessage, encodedMeterValue = "lkjklsa")),
unitOfMeasure = Some(UnitOfMeasure(unit = Some("Hertz"), multiplier = Some(3)))
)), Instant.ofEpochSecond(2)
)))))
prompt("Press ENTER to stop charging")
sendSync(tx.stopAuthorized(idToken = testIdToken))
sendSync(tx.end(stoppedReason = Reason.Local, triggerReason = TriggerReason.StopAuthorized))
statusNotification(connectorStatus = ConnectorStatus.Available)
}
// vim: set ts=4 sw=4 et: