示例#1
0
    def create_objects(self):
        ## DEFINE PARAMETERS ###########
        self.CharSet = 'lowerCaseLiterals'
        self.CharactersPerMessage = 5
        self.SourceEncodeMethod = 'basic'
        self.errorCorrection = 'HardHamming'

        # NOTE: Only use frequencies From the following Set:
        # [23.26, 23.81, 24.39, 25, 25.64, 26.36, 27.03, 27.78, 28.57, 29.41, 30.30, 31.25, 32.26, 33.33,
        #  34.48, 35.71, 37.04, 38.46 ]
        self.TransmissionFrequenciesIdeal = [
            23.26, 25, 26.36, 27.78, 28.57, 30.30, 31.25, 33.33
        ]

        self.TimePerSymbolSeconds = 4

        self.ValidDictionary = IL.loadCharacterSet(self.CharSet)
        self.InputValidationObject = IL.InputValidation(
            self.ValidDictionary, self.CharactersPerMessage)
        self.SrcEncoder = IL.SrcEncoder(self.ValidDictionary,
                                        self.SourceEncodeMethod)
        self.FEC = IL.ChannelEncoder(self.errorCorrection, 7, 4)
        self.Chan = IL.Channel('FixedFrequencyAndDuty',
                               self.TransmissionFrequenciesIdeal,
                               self.TimePerSymbolSeconds, True, 28.57, 30.30)
示例#2
0
def RunSender(file_name, config_parameters, test_option):
    # function which will execute on the sender

    sendHeader = True
    if config_parameters["SYNC_METHOD"] == "KeyPress":
        sendHeader = False

    characterSet = Sender.loadCharacterSet(config_parameters["CHARACTER_SET"])
    sourceEncoder = Sender.SrcEncoder(characterSet,
                                      config_parameters["SOURCE_ENCODER"])

    channelEncoder = Sender.ChannelEncoder(config_parameters["ERROR_CORRECTION"],\
                config_parameters["FEC_BLOCK_SIZE"],\
                config_parameters["FEC_MESSAGE_SIZE"])

    channel = Sender.Channel('FixedFrequencyAndDuty',\
           config_parameters["TRANSMISSION_FREQUENCIES"],\
           config_parameters["TIME_PER_SYMBOL"],\
           sendHeader,\
           HOLD_FREQUENCY,\
           HEADER_FREQUENCY)

    # need to do the actual sending here
    symbols = []
    if config_parameters["CHARACTERS_PER_MESSAGE"] != 0:

        message = raw_input("Enter a Message (" +
                            str(config_parameters["CHARACTERS_PER_MESSAGE"]) +
                            ") characters \n")
        sendBits = sourceEncoder.EncodeData(message)
        encodedBits = channelEncoder.EncodeData(sendBits)
        intBits = channelEncoder.interleave(encodedBits)
        symbols = Sender.SymbolMapping(
            intBits, len(config_parameters["TRANSMISSION_FREQUENCIES"]))
        print("Symbols to Transmit " + str(symbols))

    raw_input("ready ... press Enter to Start")
    if sendHeader:
        channel.sendHeaderV2()
    sendStartTime = time.time()
    print("Starting to Send message at time " + str(sendStartTime))
    for symbol in symbols:
        channel.send(symbol)
    channel.re_header()

    results = {}
    results["CONFIGURATION"] = config_parameters
    results["SEND_START_TIME"] = sendStartTime

    if test_option != 'protocol_only':
        results["SENT_SYMBOLS"] = symbols
        results["INTERLEAVED_BITS"] = intBits
        results["ENCODED_BITS"] = encodedBits
        results["BINARY_MESSAGE"] = sendBits
        results["STRING_MESSAGE"] = message

    print(results)
    with open(file_name, 'w') as outfile:
        json.dump(results, outfile)
示例#3
0
	def create_objects(self):
		self.CharSet = 'lowerCaseLiterals'
		self.CharactersPerMessage = 7
		self.SourceEncodeMethod = 'basic'
		self.errorCorrection = 'HardHamming'
		self.FEC_blockSize = 15
		self.FEC_msgSize = 11
###########################
		self.ValidDictionary = IL.loadCharacterSet(self.CharSet)
		self.InputValidationObject = IL.InputValidation(self.ValidDictionary,self.CharactersPerMessage)
		self.SrcEncoder  = IL.SrcEncoder(self.ValidDictionary , self.SourceEncodeMethod)
		self.FEC = IL.ChannelEncoder(self.errorCorrection, self.FEC_blockSize , self.FEC_msgSize)
################################
		self.CharSet = RL.loadCharacterSet(self.CharSet)
		self.CD = RL.ChannelDecoder(self.errorCorrection,'HARD', self.FEC_blockSize, self.FEC_msgSize)
		self.SD = RL.sourceDecoder(self.CharSet, self.SourceEncodeMethod)
示例#4
0
# change this for each participant
user = raw_input('Enter Subject ID :')

option = raw_input("1 - wholeSystem; 2 - transmissionOnly;  3 - timingOnly \n")
if option == "1":
	testType = 'WithSync'
	CharSet = 'lowerCaseLiterals'
	CharactersPerMessage = 5
	SourceEncodeMethod = 'basic'
	errorCorrection = 'HardHamming'
	transFrequencies = [23.26, 25, 26.36, 27.78 ,28.57, 30.30, 31.25, 33.33]
	period = 4
	ValidDictionary = IL.loadCharacterSet(CharSet)
	SrcEncoder  = IL.SrcEncoder(ValidDictionary , SourceEncodeMethod)
	FEC = IL.ChannelEncoder(errorCorrection,7,4)
	Chan = IL.Channel('FixedFrequencyAndDuty',transFrequencies,period, True, 28.57,30.30)
	while True:
		run = raw_input('Enter Run Number: ')
		path = TL.makePath(user, testType, run)
		TL.quickRunSender(path,Chan, FEC, SrcEncoder,transFrequencies,option)

		



elif option == "2":
	testType = 'SelfSync'
	CharSet = 'lowerCaseLiterals'
	CharactersPerMessage = 5
	SourceEncodeMethod = 'basic'