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