diff options
author | manojgudi | 2014-02-07 16:23:36 +0530 |
---|---|---|
committer | manojgudi | 2014-02-07 16:23:36 +0530 |
commit | 9f1489439f891a5c82b3d48999d70ac64a592488 (patch) | |
tree | 4d7216b031a56bdf76862ef80a4b9f868662df0a /gr-sbhs/python | |
parent | 324438b65f3a2c58227fb0a304ba36e57a8a1b01 (diff) | |
download | gnuradio-9f1489439f891a5c82b3d48999d70ac64a592488.tar.gz gnuradio-9f1489439f891a5c82b3d48999d70ac64a592488.tar.bz2 gnuradio-9f1489439f891a5c82b3d48999d70ac64a592488.zip |
Made Serial block as Hierarchical Block with Constant Source embedded
Diffstat (limited to 'gr-sbhs/python')
-rw-r--r-- | gr-sbhs/python/gr_sbhs.py | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/gr-sbhs/python/gr_sbhs.py b/gr-sbhs/python/gr_sbhs.py index a3070962e..9f93d61b5 100644 --- a/gr-sbhs/python/gr_sbhs.py +++ b/gr-sbhs/python/gr_sbhs.py @@ -7,61 +7,61 @@ from scan_machines import * class gr_sbhs(gras.Block): - def __init__(self): - - gras.Block.__init__(self, - name="gr_sbhs", - in_sig=[numpy.float32, numpy.float32], - out_sig=[numpy.float32]) - - from scan_machines import * - print "Scanning Machines" - scan_machines() + def __init__(self): + + gras.Block.__init__(self, + name="gr_sbhs", + in_sig=[numpy.float32, numpy.float32], + out_sig=[numpy.float32]) + + from scan_machines import * + print "Scanning Machines" + scan_machines() - # SBHS init - self.new_device = Sbhs() - self.new_device.connect(1) - self.new_device.connect_device(0) + # SBHS init + self.new_device = Sbhs() + self.new_device.connect(1) + self.new_device.connect_device(0) - def set_parameters(self,window): - self.n = window - - # Check if value of window is integral of length of input source vector - # For cases like -> input = [3 , 4, 5 ,6] & window = 3 - def isIntegralWin(self, input_item, window): - if (len(input_item) % window ): - raise Exception("Value of Window should be an integral value of length of input items") - - - def work(self, input_items, output_items): - - # Assuming input_items[0] and input_items[1] have same LENGTH - for heat_items, fan_items in zip(input_items[0], input_items[1]): - - print "HEAT WRITTEN", heat_items - - # Set heat as 0 for negative values of heat - if heat_items < 0: - self.new_device.setHeat(0) - else: - self.new_device.setHeat(heat_items) + def set_parameters(self,window): + self.n = window + + # Check if value of window is integral of length of input source vector + # For cases like -> input = [3 , 4, 5 ,6] & window = 3 + def isIntegralWin(self, input_item, window): + if (len(input_item) % window ): + raise Exception("Value of Window should be an integral value of length of input items") + + + def work(self, input_items, output_items): + + # Assuming input_items[0] and input_items[1] have same LENGTH + for heat_items, fan_items in zip(input_items[0], input_items[1]): + + print "HEAT WRITTEN", heat_items + + # Set heat as 0 for negative values of heat + if heat_items < 0: + self.new_device.setHeat(0) + else: + self.new_device.setHeat(heat_items) - time.sleep(0.5) - self.new_device.setFan(fan_items) - time.sleep(0.5) - - # For Zero Temperatures - if not self.new_device.getTemp(): - raise Exception("Check SBHS connection, try re-plugging it and run scan_machines.py") + time.sleep(0.5) + self.new_device.setFan(fan_items) + time.sleep(0.5) + + # For Zero Temperatures + if not self.new_device.getTemp(): + raise Exception("Check SBHS connection, try re-plugging it and run scan_machines.py") - # Get temperature - output_items[0][:1] = self.new_device.getTemp() + # 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)): - self.consume(i,1) # Consume from port 0 input_items + #Write a for loop for n_inputs + for i in range(len(input_items)): + self.consume(i,1) # Consume from port 0 input_items - self.produce(0,self.n) # Produce from port 0 output_items + self.produce(0,self.n) # Produce from port 0 output_items |