<commit_before>#!/usr/bin/env python 

import time
import random

class Sensor(object):
    def __init__(self, name):
        self.id = name
        self.value = 0

    def readvalue(self):
        # We simulate a sensor by generating random values
        self.value = random.randint(0,100)
        self.timestamp = time.time()
        return self.value
        

if __name__ == '__main__':
    
    import rticonnextdds_connector as rti
    import time
    import argparse
    

    cliparser = argparse.ArgumentParser(description="Connect Sensor simulator")
    cliparser.add_argument("--id", help="sensor identifier", default=0)

    args = cliparser.parse_args()

    connector = rti.Connector("MyParticipantLibrary::Sensor", 'Tutorial.xml')
    writer = connector.getOutput("TempPublisher::TempWriter")


    # Create a sensor
    sensor = Sensor("SENSOR#{}".format(args.id))
        
    while 1:
        sensor.readvalue() 
        writer.instance.setString('id', sensor.id)
        writer.instance.setNumber('value', sensor.value)
        writer.instance.setNumber('timestamp', sensor.timestamp)

        print "Updating sensor {id} value: {value}".format(id=sensor.id, value=sensor.value)
        writer.write()
        time.sleep(1)
<commit_msg>Added timestamp to output message<commit_after>#!/usr/bin/env python 

import time
import random

class Sensor(object):
    def __init__(self, name):
        self.id = name
        self.value = 0

    def readvalue(self):
        # We simulate a sensor by generating random values
        self.value = random.randint(0,100)
        self.timestamp = time.time()
        return self.value
        

if __name__ == '__main__':
    
    import rticonnextdds_connector as rti
    import time
    import argparse
    

    cliparser = argparse.ArgumentParser(description="Connect Sensor simulator")
    cliparser.add_argument("--id", help="sensor identifier", default=0)

    args = cliparser.parse_args()

    connector = rti.Connector("MyParticipantLibrary::Sensor", 'Tutorial.xml')
    writer = connector.getOutput("TempPublisher::TempWriter")


    # Create a sensor
    sensor = Sensor("SENSOR#{}".format(args.id))
        
    while 1:
        sensor.readvalue() 
        writer.instance.setString('id', sensor.id)
        writer.instance.setNumber('value', sensor.value)
        writer.instance.setNumber('timestamp', sensor.timestamp)

        print "[{ts}] Updating sensor {id} value: {value}".format(ts=sensor.timestamp,id=sensor.id, value=sensor.value)
        writer.write()
        time.sleep(1)

{'fraction_non_alphanumeric': 0.11684251660805002, 'fraction_numerical': 0.0062524423602969914, 'mean_word_length': 2.9203675344563553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2086662', 'n_tokens_mistral': 786, 'n_tokens_neox': 741, 'n_words': 165}