-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfrom sdv_model import Vehicle 2.py
More file actions
48 lines (29 loc) · 1.18 KB
/
from sdv_model import Vehicle 2.py
File metadata and controls
48 lines (29 loc) · 1.18 KB
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
from sdv_model import Vehicle
from browser import timer
from browser import aio
import plugins
EV_Plugin = plugins.get_plugin("EVPowerOptimizationPLUSDev")
vehicle = Vehicle()
# EV_Plugin.load_signals()
async def low_battery_notify():
current_soc = await vehicle.Powertrain.TractionBattery.StateOfCharge.Current.get()
if current_soc < 30:
plugins.notifyPhone("The current electric vehicle is low on power, please use the power optimization policy")
def start_with_JS(seconds):
EV_Plugin.start_simulation(seconds)
EV_Plugin.notifyPhone("Your car is on the way to the nearest charging station.")
def stop_with_JS():
EV_Plugin.stop_simulation()
EV_Plugin.notifyPhone("Congratulations! Arrived!")
await vehicle.Powertrain.TractionBattery.StateOfCharge.Current.subscribe(low_battery_notify)
start_with_JS(10)
# The default running time for this prototype/simulation is the 30s
timer.set_timeout(stop_with_JS, 600000)
# await vehicle.Next.get()
# EV_Plugin.update_simulation()
# def update_signals():
# print("hi")
# EV_Plugin.update_simulation()
# vehicle.Next.get()
# def start_with_python(seconds):
# timer.set_interval(update_signals, seconds)