packaging: updated configuration.
[profile/ivi/murphy.git] / packaging.in / murphy.lua
1 m = murphy.get()
2
3 -- load the dlog plugin
4 m:try_load_plugin('dlog')
5
6 -- load the console plugin
7 m:try_load_plugin('console')
8
9 m:try_load_plugin('console.disabled', 'webconsole', {
10                   address = 'wsck:127.0.0.1:3000/murphy',
11                   httpdir = '/usr/share/murphy/webconsole' });
12
13 -- load the dbus plugin
14 if m:plugin_exists('dbus') then
15     m:load_plugin('dbus')
16 end
17
18 -- load the native resource plugin
19 if m:plugin_exists('resource-native') then
20     m:load_plugin('resource-native')
21     m:info("native resource plugin loaded")
22 else
23     m:info("No native resource plugin found...")
24 end
25
26 -- load the dbus resource plugin
27 m:try_load_plugin('resource-dbus', {
28     dbus_bus = "system",
29     dbus_service = "org.Murphy",
30     dbus_track = true,
31     default_zone = "driver",
32     default_class = "implicit"
33 })
34
35 -- load the domain control plugin
36 if m:plugin_exists('domain-control') then
37     m:load_plugin('domain-control')
38 else
39     m:info("No domain-control plugin found...")
40 end
41
42 -- load the AMB plugin
43 if m:plugin_exists('amb') then
44     m:load_plugin('amb')
45 else
46     m:info("No amb plugin found...")
47 end
48
49 -- load the ASM resource plugin
50 if m:plugin_exists('resource-asm') then
51     m:load_plugin('resource-asm', {
52         zone = "driver",
53     })
54 else
55     m:info("No audio session manager plugin found...")
56 end
57
58 -- define application classes
59 application_class { name="interrupt", priority=99, modal=true , share=false, order="fifo" }
60 application_class { name="alert"    , priority=51, modal=false, share=false, order="fifo" }
61 application_class { name="navigator", priority=50, modal=false, share=true , order="fifo" }
62 application_class { name="phone"    , priority=6 , modal=false, share=true , order="lifo" }
63 application_class { name="camera"   , priority=5 , modal=false, share=false, order="lifo" }
64 application_class { name="event"    , priority=4 , modal=false, share=true , order="fifo" }
65 application_class { name="game"     , priority=3 , modal=false, share=false, order="lifo" }
66 application_class { name="player"   , priority=1 , modal=false, share=true , order="lifo" }
67 application_class { name="implicit" , priority=0 , modal=false, share=false, order="lifo" }
68
69 -- define zone attributes
70 zone.attributes {
71     type = {mdb.string, "common", "rw"},
72     location = {mdb.string, "anywhere", "rw"}
73 }
74
75 -- define zones
76 zone {
77      name = "driver",
78      attributes = {
79          type = "common",
80          location = "front-left"
81      }
82 }
83
84 zone {
85      name = "passanger1",
86      attributes = {
87          type = "private",
88          location = "front-right"
89      }
90 }
91
92 zone {
93      name = "passanger2",
94      attributes = {
95          type = "private",
96          location = "back-left"
97      }
98 }
99
100 zone {
101      name = "passanger3",
102      attributes = {
103          type = "private",
104          location = "back-right"
105      }
106 }
107
108 zone {
109      name = "passanger4",
110      attributes = {
111          type = "private",
112          location = "back-left"
113      }
114 }
115
116
117 -- define resource classes
118 resource.class {
119      name = "audio_playback",
120      shareable = true,
121      attributes = {
122          role   = { mdb.string, "music"    , "rw" },
123          pid    = { mdb.string, "<unknown>", "rw" },
124          policy = { mdb.string, "strict"   , "rw" }
125      }
126 }
127
128 resource.class {
129      name = "audio_recording",
130      shareable = true,
131      attributes = {
132          role   = { mdb.string, "music"    , "rw" },
133          pid    = { mdb.string, "<unknown>", "rw" },
134          policy = { mdb.string, "relaxed"  , "rw" }
135      }
136 }
137
138 resource.class {
139      name = "video_playback",
140      shareable = false,
141 }
142
143 resource.class {
144      name = "video_recording",
145      shareable = false
146 }
147
148 resource.method.veto = {
149     function(zone, rset, grant, owners)
150         rset_priority = application_class[rset.application_class].priority
151
152         owner_id = owners.audio_playback.resource_set
153         rset_id = rset.id
154
155         if (rset_priority >= 50 and owner_id ~= rset_id) then
156             print("*** resource-set "..rset_id.." - veto")
157             return false
158         end
159
160         return true
161     end
162 }
163
164 -- test for creating selections
165 mdb.select {
166            name = "audio_owner",
167            table = "audio_playback_owner",
168            columns = {"application_class"},
169            condition = "zone_name = 'driver'"
170 }
171
172 mdb.select {
173            name = "vehicle_speed",
174            table = "amb_vehicle_speed",
175            columns = {"value"},
176            condition = "key = 'VehicleSpeed'"
177 }
178
179 element.lua {
180    name    = "speed2volume",
181    inputs  = { speed = mdb.select.vehicle_speed, param = 9 },
182    outputs = {  mdb.table { name = "speedvol",
183                             index = {"zone", "device"},
184                             columns = {{"zone", mdb.string, 16},
185                                        {"device", mdb.string, 16},
186                                        {"value", mdb.floating}},
187                             create = true
188                            }
189              },
190    oldvolume = 0.0,
191    update  = function(self)
192                 speed = self.inputs.speed.single_value
193                 if (speed) then
194                     volume = (speed - 144.0) / 7.0
195                 else
196                     volume = 0.0
197                 end
198                 diff = volume - self.oldvolume
199                 if (diff*diff > self.inputs.param) then
200                     print("*** element "..self.name.." update "..volume)
201                     self.oldvolume = volume
202                     mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
203                 end
204              end
205 }
206
207 -- load the telephony plugin
208 m:try_load_plugin('telephony')