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,strict",
55 ignored_argv0 = "WebProcess"
58 m:info("No audio session manager plugin found...")
61 if m:plugin_exists('ivi-resource-manager') then
62 m:load_plugin('ivi-resource-manager')
65 -- define application classes
112 application_class { name="event" , priority=4 , modal=false, share=true , order="fifo" }
113 application_class { name="game" , priority=3 , modal=false, share=false, order="lifo" }
114 --# doesn't need to be created here, ivi-resource-manager creates it if loaded
115 --#application_class { name="basic" , priority=2 , modal=false, share=false, order="lifo" }
116 application_class { name="player" , priority=1 , modal=false, share=true , order="lifo" }
117 application_class { name="implicit" , priority=0 , modal=false, share=false, order="lifo" }
119 -- define zone attributes
121 type = {mdb.string, "common", "rw"},
122 location = {mdb.string, "anywhere", "rw"}
130 location = "front-left"
138 location = "front-right"
146 location = "back-left"
154 location = "back-right"
162 location = "back-left"
167 -- define resource classes
168 if not m:plugin_exists('ivi-resource-manager') then
170 name = "audio_playback",
173 role = { mdb.string, "music", "rw" },
174 pid = { mdb.string, "<unknown>", "rw" },
175 policy = { mdb.string, "relaxed", "rw" }
181 name = "audio_recording",
184 role = { mdb.string, "music" , "rw" },
185 pid = { mdb.string, "<unknown>", "rw" },
186 policy = { mdb.string, "relaxed" , "rw" }
191 name = "video_playback",
196 name = "video_recording",
200 if not m:plugin_exists('ivi-resource-manager') then
201 resource.method.veto = {
202 function(zone, rset, grant, owners)
203 rset_priority = application_class[rset.application_class].priority
205 owner_id = owners.audio_playback.resource_set
208 if (rset_priority >= 50 and owner_id ~= rset_id) then
209 print("*** resource-set "..rset_id.." - veto")
218 -- test for creating selections
220 name = "audio_owner",
221 table = "audio_playback_owner",
222 columns = {"application_class"},
223 condition = "zone_name = 'driver'"
227 name = "vehicle_speed",
228 table = "amb_vehicle_speed",
230 condition = "key = 'VehicleSpeed'"
234 name = "speed2volume",
235 inputs = { speed = mdb.select.vehicle_speed, param = 9 },
236 outputs = { mdb.table { name = "speedvol",
237 index = {"zone", "device"},
238 columns = {{"zone", mdb.string, 16},
239 {"device", mdb.string, 16},
240 {"value", mdb.floating}},
245 update = function(self)
246 speed = self.inputs.speed.single_value
248 volume = (speed - 144.0) / 7.0
252 diff = volume - self.oldvolume
253 if (diff*diff > self.inputs.param) then
254 print("*** element "..self.name.." update "..volume)
255 self.oldvolume = volume
256 mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
261 -- Night mode processing chain
264 name = "exterior_brightness",
265 table = "amb_exterior_brightness",
266 columns = { "value" },
267 condition = "key = 'ExteriorBrightness'"
271 name = "amb_nightmode",
275 { "id", mdb.unsigned },
276 { "night_mode", mdb.unsigned }
282 inputs = { brightness = mdb.select.exterior_brightness },
286 name = "mandatory_placeholder_to_prevent_spurious_updates",
288 columns = { { "id", mdb.unsigned } }
291 update = function(self)
292 -- This is a trivial function to calculate night mode. Later, we will
293 -- need a better threshold value and hysteresis to prevent oscillation.
295 brightness = self.inputs.brightness.single_value
297 if not brightness then
301 print("*** element "..self.name.." update brightness: "..brightness)
303 if brightness > 300 then
309 print("*** resulting mode: ".. mode)
311 if not (mode == self.oldmode) then
312 mdb.table.amb_nightmode:replace({ id = 0, night_mode = mode })
320 name = "select_night_mode",
321 table = "amb_nightmode",
322 columns = { "night_mode" },
328 inputs = { owner = mdb.select.select_night_mode },
329 property = "NightMode",
331 initiate = builtin.method.amb_initiate,
332 update = builtin.method.amb_update
336 -- Driving mode processing chain
339 name = "amb_drivingmode",
343 { "id", mdb.unsigned },
344 { "driving_mode", mdb.unsigned }
349 name = "drivingmode",
350 inputs = { speed = mdb.select.vehicle_speed },
354 name = "another_mandatory_placeholder_to_prevent_spurious_updates",
356 columns = { { "id", mdb.unsigned } }
359 update = function(self)
361 speed = self.inputs.speed.single_value
373 if not (mode == self.oldmode) then
374 mdb.table.amb_drivingmode:replace({ id = 0, driving_mode = mode })
382 name = "select_driving_mode",
383 table = "amb_drivingmode",
384 columns = { "driving_mode" },
389 name = "driving_mode",
390 inputs = { owner = mdb.select.select_driving_mode },
391 property = "DrivingMode",
393 initiate = builtin.method.amb_initiate,
394 update = builtin.method.amb_update
397 -- load the telephony plugin
398 m:try_load_plugin('telephony')