Fix for bug 78: AmNodeStateCommunicatorTest throws a runtime exception
[profile/ivi/genivi/genivi-audio-manager.git] / AudioManagerDaemon / test / AmNodeStateCommunicatorTest / send2nsm.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2012, BMW AG
4 #
5 # This file is part of GENIVI Project AudioManager.
6 #
7 # Contributions are licensed to the GENIVI Alliance under one or more
8 # Contribution License Agreements.
9 #
10 # \copyright
11 # This Source Code Form is subject to the terms of the
12 # Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
13 # this file, You can obtain one at http://mozilla.org/MPL/2.0/.
14 #
15 #
16 # \author Christian Linke, christian.linke@bmw.de BMW 2012
17 #
18 # For further information see http://www.genivi.org/.
19 #
20
21 import sys
22 import traceback
23 import gobject
24 import math
25 import dbus
26 import dbus.service
27
28 def nodeState (nodeState):
29         bus = dbus.SessionBus()
30         remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
31         iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
32         iface.sendNodeState(int(nodeState))
33         
34 def appMode (appMode):
35         bus = dbus.SessionBus()
36         remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
37         iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
38         iface.sendNodeApplicationMode(int(appMode))
39         
40 def sessionState (SessionStateName,SeatID,SessionState):
41         bus = dbus.SessionBus()
42         remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
43         iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
44         iface.sendSessionState(SessionStateName,int(SeatID),int(SessionState))
45         
46 def finish():
47         bus = dbus.SessionBus()
48         remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
49         iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
50         iface.finish()
51
52 def LifecycleRequest(Request,RequestID):
53         bus = dbus.SessionBus()
54         remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager')
55         iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control')
56         iface.sendLifeCycleRequest(dbus.UInt32(Request),dbus.UInt32(RequestID))
57
58 command=sys.argv[1]
59 if command=="nodeState":
60         nodeState(sys.argv[2])  
61 if command=="finish":
62         finish()
63 if command=="appMode":
64         appMode(sys.argv[2])
65 if command=="sessionState":
66         sessionState(sys.argv[2],sys.argv[3],sys.argv[4])
67 if command=="LifecycleRequest":
68         LifecycleRequest(sys.argv[2],sys.argv[3])