summaryrefslogtreecommitdiff
path: root/gr-sbhs/python
diff options
context:
space:
mode:
Diffstat (limited to 'gr-sbhs/python')
-rw-r--r--gr-sbhs/python/gr_controller.py5
-rw-r--r--gr-sbhs/python/gr_sbhs.py5
-rwxr-xr-xgr-sbhs/python/qa_dsim.py68
-rw-r--r--gr-sbhs/python/que.py2
-rwxr-xr-xgr-sbhs/python/sbhs.py1
-rwxr-xr-xgr-sbhs/python/testing.py60
6 files changed, 5 insertions, 136 deletions
diff --git a/gr-sbhs/python/gr_controller.py b/gr-sbhs/python/gr_controller.py
index a661e0b74..5269148d9 100644
--- a/gr-sbhs/python/gr_controller.py
+++ b/gr-sbhs/python/gr_controller.py
@@ -63,8 +63,7 @@ class sbhs_controller(gras.Block):
out[:1] = self.o_0
- #print output_items[0]
- self.consume(0,1) # Consume from port 0 input_items
- self.consume(1,1)
+ self.consume(0,1) # Consumuption from port 0 input_items
+ self.consume(1,1)
self.produce(0,1) # Produce from port 0 output_items
diff --git a/gr-sbhs/python/gr_sbhs.py b/gr-sbhs/python/gr_sbhs.py
index 3441c1f7f..28a8dee2d 100644
--- a/gr-sbhs/python/gr_sbhs.py
+++ b/gr-sbhs/python/gr_sbhs.py
@@ -31,9 +31,6 @@ class gr_sbhs(gras.Block):
def work(self, input_items, output_items):
- # if len(input_items[0]) != len(input_items[1]):
- # raise Exception("Heat value vector and Fan Speed Value vector should be of equal length")
-
# Assuming input_items[0] and input_items[1] have same LENGTH
for heat_items, fan_items in zip(input_items[0], input_items[1]):
@@ -56,7 +53,7 @@ class gr_sbhs(gras.Block):
# Get temperature
output_items[0][:1] = self.new_device.getTemp()
- print "Temperature",output_items[0][:1]
+ print "Temperature: ",output_items[0][:1]
#Write a for loop for n_inputs
for i in range(len(input_items)):
diff --git a/gr-sbhs/python/qa_dsim.py b/gr-sbhs/python/qa_dsim.py
deleted file mode 100755
index 3d1db0f60..000000000
--- a/gr-sbhs/python/qa_dsim.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2013 <+YOU OR YOUR COMPANY+>.
-#
-# This 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.
-#
-# This software 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 this software; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr, gr_unittest
-#import mymod_swig as mymod
-from dsim import dsim
-
-
-class qa_dsim (gr_unittest.TestCase):
-
- def setUp (self):
- self.tb = gr.top_block ()
-
- def tearDown (self):
- self.tb = None
-
- def test_001_t (self):
-
- src_data = [0]*10
- src_data1 = [1]*20
- src_data = src_data+src_data1
-
- #expected_result = (-2.0, 0.0, 5.0, 8.0, 9.0, 11.0, 14.0, 18.0)
-
- src0 = gr.vector_source_f(src_data)
- sqr = dsim()
- sqr.set_parameters(2,0.5,1,.1,10,1)
-
- #Preload
- sqr.input_config(1).preload_items = 1
- dst = gr.vector_sink_f()
-
- self.tb.connect(src0, (sqr,0)) # src0(vector_source) -> sqr_input_0
- self.tb.connect((sqr,0), (sqr,1)) # sqr_output_0 -> sqr_input_1
- self.tb.connect(sqr,dst) # sqr_output_0 -> dst (vector_source)
-
- self.tb.run()
-
- result_data = dst.data()
-
-
- import matplotlib.pyplot as plt
- plt.plot(result_data)
- #print "result", result_data
- plt.show()
- #self.assertFloatTuplesAlmostEqual(expected_result, result_data, 6)
-
-
-if __name__ == '__main__':
- gr_unittest.main()
- #gr_unittest.run(qa_dsim, "qa_dsim.xml")
diff --git a/gr-sbhs/python/que.py b/gr-sbhs/python/que.py
index f5031a131..70db2838a 100644
--- a/gr-sbhs/python/que.py
+++ b/gr-sbhs/python/que.py
@@ -14,9 +14,11 @@ class Queue:
self.queue.append(obj)
else:
print "Queue full"
+
### To discard first in queue and append obj anyway ###
#self.queue.pop(0)
#self.queue.append(obj)
+
def pop(self):
try:
return (self.queue.pop(0))
diff --git a/gr-sbhs/python/sbhs.py b/gr-sbhs/python/sbhs.py
index b1ff44933..7eea4a0b1 100755
--- a/gr-sbhs/python/sbhs.py
+++ b/gr-sbhs/python/sbhs.py
@@ -3,7 +3,6 @@ import os
from time import localtime, strftime, sleep
MAP_FILE = './map_machine_ids.txt'
-#MAP_FILE = '/var/sbhspyserver/sbhshw/map_machine_ids.txt'
LOG_FILE = '/var/sbhspylog/sbhserr.log'
OUTGOING_MACHINE_ID = 252
diff --git a/gr-sbhs/python/testing.py b/gr-sbhs/python/testing.py
deleted file mode 100755
index a71655b40..000000000
--- a/gr-sbhs/python/testing.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/python -tt
-
-import serial
-import time
-from time import sleep
-
-ser = serial.Serial('/dev/ttyUSB0', baudrate=9600, timeout=1)
-ser.open()
-
-
-from time import sleep
-
-import urllib
-import urllib2
-from sbhs import *
-#from bottle import *
-from scan_machines import *
-
-
-new_device = Sbhs()
-new_device.connect(252)
-new_device.connect_device(0)
-
-
-for i in range(10):
- #new_device.setHeat(10)
- #new_device.setFan(30)
- f=new_device.getTemp()
- print f
- time.sleep(3)
-ser.close()
-#f = 10
-
-#@route('/temp')
-#def hello():
-# return str(f)
-#run(host='localhost', port=8080, debug=True)
-'''
-#writing to google app-engine
- data = {}
- data['temp'] = '30'#float value not int
- data['heat'] = '200'
- data['fan'] = '100'
- url_val = urllib.urlencode(data)
- print url_val
-
- url = 'http://remote-cloudlabs.appspot.com/hello'
- full_url = url + '?' + url_val
- data = urllib2.urlopen(full_url)
-
-#reading from url
- req = urllib2.Request('http://remote-cloudlabs.appspot.com/display')
- response = urllib2.urlopen(req)
- data = response.read()
- print data
-
-
- time.sleep(10)
-
-'''