3 -- try loading the various logging plugins
4 m:try_load_plugin('systemd')
5 m:try_load_plugin('dlog')
7 -- load the console plugin
8 m:try_load_plugin('console')
10 m:try_load_plugin('console.disabled', 'webconsole', {
11 address = 'wsck:127.0.0.1:3000/murphy',
12 httpdir = '/usr/share/murphy/webconsole' });
14 -- load the dbus plugin
15 if m:plugin_exists('dbus') then
19 -- load the native resource plugin
20 if m:plugin_exists('resource-native') then
21 m:load_plugin('resource-native')
22 m:info("native resource plugin loaded")
24 m:info("No native resource plugin found...")
27 -- load the dbus resource plugin
28 m:try_load_plugin('resource-dbus', {
30 dbus_service = "org.Murphy",
32 default_zone = "driver",
33 default_class = "implicit"
36 -- load the domain control plugin
37 if m:plugin_exists('domain-control') then
38 m:load_plugin('domain-control')
40 m:info("No domain-control plugin found...")
43 -- load the AMB plugin
44 if m:plugin_exists('amb') then
47 m:info("No amb plugin found...")
50 -- load the ASM resource plugin
51 if m:plugin_exists('resource-asm') then
52 m:load_plugin('resource-asm', {
54 share_mmplayer = "player:AVP,mandatory,exclusive,relaxed"
57 m:info("No audio session manager plugin found...")
60 if m:plugin_exists('ivi-resource-manager.disabled') then
61 m:load_plugin('ivi-resource-manager')
64 -- define application classes
65 application_class { name="interrupt", priority=99, modal=true , share=false, order="fifo" }
66 application_class { name="emergency", priority=80, modal=false, share=false, order="fifo" }
67 application_class { name="alert" , priority=51, modal=false, share=false, order="fifo" }
68 application_class { name="navigator", priority=50, modal=false, share=true , order="fifo" }
69 application_class { name="phone" , priority=6 , modal=false, share=true , order="lifo" }
70 application_class { name="camera" , priority=5 , modal=false, share=false, order="lifo" }
71 application_class { name="event" , priority=4 , modal=false, share=true , order="fifo" }
72 application_class { name="game" , priority=3 , modal=false, share=false, order="lifo" }
73 --# doesn't need to be created here, ivi-resource-manager creates it if loaded
74 --#application_class { name="basic" , priority=2 , modal=false, share=false, order="lifo" }
75 application_class { name="player" , priority=1 , modal=false, share=true , order="lifo" }
76 application_class { name="implicit" , priority=0 , modal=false, share=false, order="lifo" }
78 -- define zone attributes
80 type = {mdb.string, "common", "rw"},
81 location = {mdb.string, "anywhere", "rw"}
89 location = "front-left"
97 location = "front-right"
105 location = "back-left"
113 location = "back-right"
121 location = "back-left"
126 -- define resource classes
127 if not m:plugin_exists('ivi-resource-manager.disabled') then
129 name = "audio_playback",
132 role = { mdb.string, "music", "rw" },
133 pid = { mdb.string, "<unknown>", "rw" },
134 policy = { mdb.string, "relaxed", "rw" }
140 name = "audio_recording",
143 role = { mdb.string, "music" , "rw" },
144 pid = { mdb.string, "<unknown>", "rw" },
145 policy = { mdb.string, "relaxed" , "rw" }
150 name = "video_playback",
155 name = "video_recording",
159 if not m:plugin_exists('ivi-resource-manager.disabled') then
160 resource.method.veto = {
161 function(zone, rset, grant, owners)
162 rset_priority = application_class[rset.application_class].priority
164 owner_id = owners.audio_playback.resource_set
167 if (rset_priority >= 50 and owner_id ~= rset_id) then
168 print("*** resource-set "..rset_id.." - veto")
177 -- test for creating selections
179 name = "audio_owner",
180 table = "audio_playback_owner",
181 columns = {"application_class"},
182 condition = "zone_name = 'driver'"
186 name = "vehicle_speed",
187 table = "amb_vehicle_speed",
189 condition = "key = 'VehicleSpeed'"
193 name = "speed2volume",
194 inputs = { speed = mdb.select.vehicle_speed, param = 9 },
195 outputs = { mdb.table { name = "speedvol",
196 index = {"zone", "device"},
197 columns = {{"zone", mdb.string, 16},
198 {"device", mdb.string, 16},
199 {"value", mdb.floating}},
204 update = function(self)
205 speed = self.inputs.speed.single_value
207 volume = (speed - 144.0) / 7.0
211 diff = volume - self.oldvolume
212 if (diff*diff > self.inputs.param) then
213 print("*** element "..self.name.." update "..volume)
214 self.oldvolume = volume
215 mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
220 -- Night mode processing chain
223 name = "exterior_brightness",
224 table = "amb_exterior_brightness",
225 columns = { "value" },
226 condition = "key = 'ExteriorBrightness'"
230 name = "amb_nightmode",
234 { "id", mdb.unsigned },
235 { "night_mode", mdb.unsigned }
241 inputs = { brightness = mdb.select.exterior_brightness },
245 name = "mandatory_placeholder_to_prevent_spurious_updates",
247 columns = { { "id", mdb.unsigned } }
250 update = function(self)
251 -- This is a trivial function to calculate night mode. Later, we will
252 -- need a better threshold value and hysteresis to prevent oscillation.
254 brightness = self.inputs.brightness.single_value
256 if not brightness then
260 print("*** element "..self.name.." update brightness: "..brightness)
262 if brightness > 300 then
268 print("*** resulting mode: ".. mode)
270 if not (mode == self.oldmode) then
271 mdb.table.amb_nightmode:replace({ id = 0, night_mode = mode })
279 name = "select_night_mode",
280 table = "amb_nightmode",
281 columns = { "night_mode" },
287 inputs = { owner = mdb.select.select_night_mode },
288 property = "NightMode",
290 initiate = builtin.method.amb_initiate,
291 update = builtin.method.amb_update
295 -- Driving mode processing chain
298 name = "amb_drivingmode",
302 { "id", mdb.unsigned },
303 { "driving_mode", mdb.unsigned }
308 name = "drivingmode",
309 inputs = { speed = mdb.select.vehicle_speed },
313 name = "another_mandatory_placeholder_to_prevent_spurious_updates",
315 columns = { { "id", mdb.unsigned } }
318 update = function(self)
320 speed = self.inputs.speed.single_value
332 if not (mode == self.oldmode) then
333 mdb.table.amb_drivingmode:replace({ id = 0, driving_mode = mode })
341 name = "select_driving_mode",
342 table = "amb_drivingmode",
343 columns = { "driving_mode" },
348 name = "driving_mode",
349 inputs = { owner = mdb.select.select_driving_mode },
350 property = "DrivingMode",
352 initiate = builtin.method.amb_initiate,
353 update = builtin.method.amb_update
356 -- load the telephony plugin
357 m:try_load_plugin('telephony')