packaging: fixed lost application classes, added AMB plugin config file.
[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 -- load the dbus plugin
10 if m:plugin_exists('dbus') then
11     m:load_plugin('dbus')
12 end
13
14 -- load the native resource plugin
15 if m:plugin_exists('resource-native') then
16     m:load_plugin('resource-native')
17     m:info("native resource plugin loaded")
18 else
19     m:info("No native resource plugin found...")
20 end
21
22 -- load the dbus resource plugin
23 m:try_load_plugin('resource-dbus', {
24     dbus_bus = "system",
25     dbus_service = "org.Murphy",
26     dbus_track = true,
27     default_zone = "driver",
28     default_class = "implicit"
29 })
30
31 -- load the domain control plugin
32 if m:plugin_exists('domain-control') then
33     m:load_plugin('domain-control')
34 else
35     m:info("No domain-control plugin found...")
36 end
37
38 -- load the AMB plugin
39 if m:plugin_exists('amb') then
40     m:load_plugin('amb')
41 else
42     m:info("No amb plugin found...")
43 end
44
45 -- load the ASM resource plugin
46 if m:plugin_exists('resource-asm') then
47     m:load_plugin('resource-asm', { zone = "driver" })
48 else
49     m:info("No audio session manager plugin found...")
50 end
51
52 -- define application classes
53 application_class { name = "navigator", priority = 8 }
54 application_class { name = "event"    , priority = 7 }
55 application_class { name = "phone"    , priority = 6 }
56 application_class { name = "camera"   , priority = 5 }
57 application_class { name = "alert"    , priority = 4 }
58 application_class { name = "game"     , priority = 3 }
59 application_class { name = "radio"    , priority = 2 }
60 application_class { name = "player"   , priority = 1 }
61 application_class { name = "implicit" , priority = 0 }
62
63 -- define zone attributes
64 zone.attributes {
65     type = {mdb.string, "common", "rw"},
66     location = {mdb.string, "anywhere", "rw"}
67 }
68
69 -- define zones
70 zone {
71      name = "driver",
72      attributes = {
73          type = "common",
74          location = "front-left"
75      }
76 }
77
78 zone {
79      name = "passanger1",
80      attributes = {
81          type = "private",
82          location = "front-right"
83      }
84 }
85
86 zone {
87      name = "passanger2",
88      attributes = {
89          type = "private",
90          location = "back-left"
91      }
92 }
93
94 zone {
95      name = "passanger3",
96      attributes = {
97          type = "private",
98          location = "back-right"
99      }
100 }
101
102 zone {
103      name = "passanger4",
104      attributes = {
105          type = "private",
106          location = "back-left"
107      }
108 }
109
110
111 -- define resource classes
112 resource.class {
113      name = "audio_playback",
114      shareable = true,
115      attributes = {
116          role = { mdb.string, "music", "rw" }
117      }
118 }
119
120 resource.class {
121      name = "audio_recording",
122      shareable = true
123 }
124
125 resource.class {
126      name = "video_playback",
127      shareable = false,
128 }
129
130 resource.class {
131      name = "video_recording",
132      shareable = false
133 }
134
135 -- test for creating selections
136 --[[
137 mdb.select {
138            name = "audio_owner",
139            table = "audio_playback_owner",
140            columns = {"application_class"},
141            condition = "zone_name = 'driver'"
142 }
143 --]]
144
145 mdb.select {
146            name = "vehicle_speed",
147            table = "amb_vehicle_speed",
148            columns = {"value"},
149            condition = "key = 'VehicleSpeed'"
150 }
151
152 element.lua {
153    name    = "speed2volume",
154    inputs  = { speed = mdb.select.vehicle_speed, param = 9 },
155    outputs = {  mdb.table { name = "speedvol",
156                             index = {"zone", "device"},
157                             columns = {{"zone", mdb.string, 16},
158                                        {"device", mdb.string, 16},
159                                        {"value", mdb.floating}},
160                             create = true
161                            }
162              },
163    oldvolume = 0.0,
164    update  = function(self)
165                 speed = self.inputs.speed.single_value
166                 if (speed) then
167                     volume = (speed - 144.0) / 7.0
168                 else
169                     volume = 0.0
170                 end
171                 diff = volume - self.oldvolume
172                 if (diff*diff > self.inputs.param) then
173                     print("*** element "..self.name.." update "..volume)
174                     self.oldvolume = volume
175                     mdb.table.speedvol:replace({zone = "driver", device = "speakers", value = volume})
176                 end
177              end
178 }
179
180 -- load the telephony plugin
181 m:try_load_plugin('telephony')