packaging: declare a pid audio playback attribute.
[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', { zone = "driver" })
52 else
53     m:info("No audio session manager plugin found...")
54 end
55
56 -- define application classes
57 application_class { name = "navigator", priority = 8 }
58 application_class { name = "event"    , priority = 7 }
59 application_class { name = "phone"    , priority = 6 }
60 application_class { name = "camera"   , priority = 5 }
61 application_class { name = "alert"    , priority = 4 }
62 application_class { name = "game"     , priority = 3 }
63 application_class { name = "radio"    , priority = 2 }
64 application_class { name = "player"   , priority = 1 }
65 application_class { name = "implicit" , priority = 0 }
66
67 -- define zone attributes
68 zone.attributes {
69     type = {mdb.string, "common", "rw"},
70     location = {mdb.string, "anywhere", "rw"}
71 }
72
73 -- define zones
74 zone {
75      name = "driver",
76      attributes = {
77          type = "common",
78          location = "front-left"
79      }
80 }
81
82 zone {
83      name = "passanger1",
84      attributes = {
85          type = "private",
86          location = "front-right"
87      }
88 }
89
90 zone {
91      name = "passanger2",
92      attributes = {
93          type = "private",
94          location = "back-left"
95      }
96 }
97
98 zone {
99      name = "passanger3",
100      attributes = {
101          type = "private",
102          location = "back-right"
103      }
104 }
105
106 zone {
107      name = "passanger4",
108      attributes = {
109          type = "private",
110          location = "back-left"
111      }
112 }
113
114
115 -- define resource classes
116 resource.class {
117      name = "audio_playback",
118      shareable = true,
119      attributes = {
120          role = { mdb.string, "music"  , "rw" },
121          pid  = { mdb.string, "unknown", "rw" }
122      }
123 }
124
125 resource.class {
126      name = "audio_recording",
127      shareable = true
128 }
129
130 resource.class {
131      name = "video_playback",
132      shareable = false,
133 }
134
135 resource.class {
136      name = "video_recording",
137      shareable = false
138 }
139
140 -- test for creating selections
141 --[[
142 mdb.select {
143            name = "audio_owner",
144            table = "audio_playback_owner",
145            columns = {"application_class"},
146            condition = "zone_name = 'driver'"
147 }
148 --]]
149
150 mdb.select {
151            name = "vehicle_speed",
152            table = "amb_vehicle_speed",
153            columns = {"value"},
154            condition = "key = 'VehicleSpeed'"
155 }
156
157 element.lua {
158    name    = "speed2volume",
159    inputs  = { speed = mdb.select.vehicle_speed, param = 9 },
160    outputs = {  mdb.table { name = "speedvol",
161                             index = {"zone", "device"},
162                             columns = {{"zone", mdb.string, 16},
163                                        {"device", mdb.string, 16},
164                                        {"value", mdb.floating}},
165                             create = true
166                            }
167              },
168    oldvolume = 0.0,
169    update  = function(self)
170                 speed = self.inputs.speed.single_value
171                 if (speed) then
172                     volume = (speed - 144.0) / 7.0
173                 else
174                     volume = 0.0
175                 end
176                 diff = volume - self.oldvolume
177                 if (diff*diff > self.inputs.param) then
178                     print("*** element "..self.name.." update "..volume)
179                     self.oldvolume = volume
180                     mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
181                 end
182              end
183 }
184
185 -- load the telephony plugin
186 m:try_load_plugin('telephony')