def transportMessage(self, message, Input, Output): ''' obj1 = Sensor(None) obj2 = Network() if type(Input)==type(obj1): dist = np.sqrt(Input.x**2 + Input.y**2) elif type(Input)==type(obj2): dist = np.sqrt(Output.x**2 + Output.y**2) ''' if self.type == 'no-fading': self.channel = ch.SISOFlatChannel(self.stdDev, (1j, 0)) elif self.type == 'rayleigh': self.channel = ch.SISOFlatChannel(self.stdDev, (1j, 0)) received = self.channel.propagate(message) Output.receiveMessage(received)
decoded_bits[:len(message_bits)]) if num_bit_errors != 0: print(num_bit_errors, "Bit Errors found!") elif i == 9: print("No Bit Errors :)") # ================================================================================================== # Complete example using Commpy features and compare hard and soft demodulation. Example with code 1 # ================================================================================================== # Modem : QPSK modem = mod.QAMModem(4) # AWGN channel channels = chan.SISOFlatChannel(None, (1 + 0j, 0j)) # SNR range to test SNRs = np.arange(0, 6) + 10 * math.log10(modem.num_bits_symbol) # Modulation function def modulate(bits): return modem.modulate(cc.conv_encode(bits, trellis1, 'cont')) # Receiver function (no process required as there are no fading) def receiver_hard(y, h, constellation, noise_var): return modem.demodulate(y, 'hard')