1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#!/usr/bin/env python
#
# Copyright 2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Radio; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
import Ice, Glacier2
from PyQt4 import QtGui, QtCore
import sys, time, Ice
from gnuradio import gr
from gnuradio.ctrlport import GNURadio
class IceRadioClient(Ice.Application):
def __init__(self, parentClass):
self.parentClass = parentClass
def getRadio(self, host, port):
radiostr = "gnuradio -t:tcp -h " + host + " -p " + port + " -t 3000"
base = self.communicator().stringToProxy(radiostr).ice_twoway()
radio = GNURadio.ControlPortPrx.checkedCast(base)
if not radio:
sys.stderr.write("{0} : invalid proxy.\n".format(args[0]))
return None
return radio
def run(self,args):
if len(args) < 2:
print "useage: [glacierinstance glacierhost glacierport] host port"
return
if len(args) == 8:
self.useglacier = True
guser = args[1]
gpass = args[2]
ginst = args[3]
ghost = args[4]
gport = args[5]
host = args[6]
port = args[7]
else:
self.useglacier = False
host = args[1]
port = args[2]
if self.useglacier:
gstring = ginst + "/router -t:tcp -h " + ghost + " -p " + gport
print "GLACIER: {0}".format(gstring)
setrouter = Glacier2.RouterPrx.checkedCast(self.communicator().stringToProxy(gstring))
self.communicator().setDefaultRouter(setrouter)
defaultRouter = self.communicator().getDefaultRouter()
#defaultRouter = self.communicator().stringToProxy(gstring)
if not defaultRouter:
print self.appName() + ": no default router set"
return 1
else:
print str(defaultRouter)
router = Glacier2.RouterPrx.checkedCast(defaultRouter)
if not router:
print self.appName() + ": configured router is not a Glacier2 router"
return 1
while True:
print "This demo accepts any user-id / password combination."
if not guser == '' and not gpass == '':
id = guser
pw = gpass
else:
id = raw_input("user id: ")
pw = raw_input("password: ")
try:
router.createSession(id, pw)
break
except Glacier2.PermissionDeniedException, ex:
print "permission denied:\n" + ex.reason
radio = self.getRadio(host, port)
if(radio is None):
return 1
app = QtGui.QApplication(sys.argv)
ex = self.parentClass(radio, port, self)
ex.show();
app.exec_()
|