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') then
61 m:load_plugin('ivi-resource-manager')
64 -- define application classes
111 application_class { name="event" , priority=4 , modal=false, share=true , order="fifo" }
112 application_class { name="game" , priority=3 , modal=false, share=false, order="lifo" }
113 --# doesn't need to be created here, ivi-resource-manager creates it if loaded
114 --#application_class { name="basic" , priority=2 , modal=false, share=false, order="lifo" }
115 application_class { name="player" , priority=1 , modal=false, share=true , order="lifo" }
116 application_class { name="implicit" , priority=0 , modal=false, share=false, order="lifo" }
118 -- define zone attributes
120 type = {mdb.string, "common", "rw"},
121 location = {mdb.string, "anywhere", "rw"}
129 location = "front-left"
137 location = "front-right"
145 location = "back-left"
153 location = "back-right"
161 location = "back-left"
166 -- define resource classes
167 if not m:plugin_exists('ivi-resource-manager') then
169 name = "audio_playback",
172 role = { mdb.string, "music", "rw" },
173 pid = { mdb.string, "<unknown>", "rw" },
174 policy = { mdb.string, "relaxed", "rw" }
180 name = "audio_recording",
183 role = { mdb.string, "music" , "rw" },
184 pid = { mdb.string, "<unknown>", "rw" },
185 policy = { mdb.string, "relaxed" , "rw" }
190 name = "video_playback",
195 name = "video_recording",
199 if not m:plugin_exists('ivi-resource-manager') then
200 resource.method.veto = {
201 function(zone, rset, grant, owners)
202 rset_priority = application_class[rset.application_class].priority
204 owner_id = owners.audio_playback.resource_set
207 if (rset_priority >= 50 and owner_id ~= rset_id) then
208 print("*** resource-set "..rset_id.." - veto")
217 -- test for creating selections
219 name = "audio_owner",
220 table = "audio_playback_owner",
221 columns = {"application_class"},
222 condition = "zone_name = 'driver'"
226 name = "vehicle_speed",
227 table = "amb_vehicle_speed",
229 condition = "key = 'VehicleSpeed'"
233 name = "speed2volume",
234 inputs = { speed = mdb.select.vehicle_speed, param = 9 },
235 outputs = { mdb.table { name = "speedvol",
236 index = {"zone", "device"},
237 columns = {{"zone", mdb.string, 16},
238 {"device", mdb.string, 16},
239 {"value", mdb.floating}},
244 update = function(self)
245 speed = self.inputs.speed.single_value
247 volume = (speed - 144.0) / 7.0
251 diff = volume - self.oldvolume
252 if (diff*diff > self.inputs.param) then
253 print("*** element "..self.name.." update "..volume)
254 self.oldvolume = volume
255 mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
260 -- Night mode processing chain
263 name = "exterior_brightness",
264 table = "amb_exterior_brightness",
265 columns = { "value" },
266 condition = "key = 'ExteriorBrightness'"
270 name = "amb_nightmode",
274 { "id", mdb.unsigned },
275 { "night_mode", mdb.unsigned }
281 inputs = { brightness = mdb.select.exterior_brightness },
285 name = "mandatory_placeholder_to_prevent_spurious_updates",
287 columns = { { "id", mdb.unsigned } }
290 update = function(self)
291 -- This is a trivial function to calculate night mode. Later, we will
292 -- need a better threshold value and hysteresis to prevent oscillation.
294 brightness = self.inputs.brightness.single_value
296 if not brightness then
300 print("*** element "..self.name.." update brightness: "..brightness)
302 if brightness > 300 then
308 print("*** resulting mode: ".. mode)
310 if not (mode == self.oldmode) then
311 mdb.table.amb_nightmode:replace({ id = 0, night_mode = mode })
319 name = "select_night_mode",
320 table = "amb_nightmode",
321 columns = { "night_mode" },
327 inputs = { owner = mdb.select.select_night_mode },
328 property = "NightMode",
330 initiate = builtin.method.amb_initiate,
331 update = builtin.method.amb_update
335 -- Driving mode processing chain
338 name = "amb_drivingmode",
342 { "id", mdb.unsigned },
343 { "driving_mode", mdb.unsigned }
348 name = "drivingmode",
349 inputs = { speed = mdb.select.vehicle_speed },
353 name = "another_mandatory_placeholder_to_prevent_spurious_updates",
355 columns = { { "id", mdb.unsigned } }
358 update = function(self)
360 speed = self.inputs.speed.single_value
372 if not (mode == self.oldmode) then
373 mdb.table.amb_drivingmode:replace({ id = 0, driving_mode = mode })
381 name = "select_driving_mode",
382 table = "amb_drivingmode",
383 columns = { "driving_mode" },
388 name = "driving_mode",
389 inputs = { owner = mdb.select.select_driving_mode },
390 property = "DrivingMode",
392 initiate = builtin.method.amb_initiate,
393 update = builtin.method.amb_update
396 -- load the telephony plugin
397 m:try_load_plugin('telephony')