last modifications for OMF6 before test
[nepi.git] / examples / omf / nepi_omf_stdin_iminds.py
1 """
2     NEPI, a framework to manage network experiments
3     Copyright (C) 2013 INRIA
4
5     This program is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18     Author: Julien Tribino <julien.tribino@inria.fr>
19
20     Example :
21       - Testbed : iMinds
22       - Explanation :
23
24        Test the STDIN Message
25                    
26      Node Zotack
27      node0.nepi-robot.nepi.wilab2.ilabt.iminds.be
28      0 
29      |
30      |
31      0
32      Application RobotCTRLComm.rb
33    
34       - Experiment:
35         - t0 : Deployment
36         - t1 : After the application started, send the message START_DRIVE
37         - t2 (t1 + 83s) : Open Left eye of robot 1
38         - t3 (t2 + 2s) : Open Left eye of robot 2
39
40 """
41
42 from nepi.execution.resource import ResourceFactory, ResourceAction, ResourceState
43 from nepi.execution.ec import ExperimentController
44
45 import time
46
47 # Create the EC
48 ec = ExperimentController()
49
50 # Create and Configure the Node
51 node1 = ec.register_resource("OMFNode")
52     # If the hostname is not declared, Nepi will take SFA to provision one.
53 ec.set(node1, 'hostname', 'node0.nepi-robot.nepi.wilab2.ilabt.iminds.be')
54     # XMPP credentials
55 ec.set(node1, 'xmppSlice', "default_slice_iminds")
56 ec.set(node1, 'xmppHost', "am.wilab2.ilabt.iminds.be")
57 ec.set(node1, 'xmppPort', "5222")
58 ec.set(node1, 'xmppPassword', "1234")
59
60 # Create and Configure the Application
61 app1 = ec.register_resource("OMFRobotApplication")
62 ec.set(app1, 'appid', "robot")
63 ec.set(app1, 'path', "/users/jtribino/RobotCTRLComm.rb") # /users/username/RobotCTRLComm.rb
64 ec.set(app1, 'args', "/users/jtribino/coordinate.csv")   #/users/username/coordinate.csv
65 ec.set(app1, 'env', " ")
66 ec.set(app1, 'sources', "/home/wlab18/Desktop/coordinate.csv")  # local path
67 ec.set(app1, 'sshUser', "jtribino")  # username
68
69 # Connection
70 ec.register_connection(app1, node1)
71
72 # The Application should run during 350sec
73 ec.register_condition(app1, ResourceAction.STOP, app1, ResourceState.STARTED , "350s")
74
75 # Deploy
76 ec.deploy()
77
78 ec.wait_started([app1])
79
80 ec.set(app1, 'stdin', "START_DRIVE")
81
82 time.sleep(83)
83 ec.set(app1, 'stdin', "1;openlefteye")
84
85 time.sleep(2)
86 ec.set(app1, 'stdin', "2;openlefteye")
87
88 ec.wait_finished([app1])
89
90 # Stop Experiment
91 ec.shutdown()