示例#1
0
 def run(self):
     """
     the threading main loop in dependency of the exchanged programstate variable.
     calling the data dictionary of the DataExchange for values as well as keys
     to write the subjects and the corresponding values into the logfile 
     ###
     RETURNS (void)
     """
     self.exchange.log("[+] running Log Thread")
     # creating the logfile, as every sensor is registered by now 
     jtos.createfile(self.src_path+"/log"+str(self.index))
     self.logfile = jtfiles.ExcelLogfile(self.src_path+"/log"+str(self.index), ["time"]+list(self.exchange.data.keys()), overwrite=False)
     # main loop with exchanged programstate condition
     t_start = time.time()
     once = True
     try:
         while self.exchange.programstate:
             t_delta = time.time() - t_start
             if t_delta >= self.interval:
                 self.t_total += t_delta
                 once = True
                 self.logfile.writelog([int(self.t_total)]+list(self.exchange.data.values()))
                 t_start = time.time()
             if int(self.t_total) in range(60,6000000,60) and once == True:
                 self.logfile.end()
                 self.index += 1
                 jtos.createfile(self.src_path+"/log"+str(self.index))
                 self.logfile = jtfiles.ExcelLogfile(self.src_path+"/log"+str(self.index), ["time"]+list(self.exchange.data.keys()), overwrite=False) 
                 once = False
     finally:
         self.logfile.end()
         self.exchange.log("[*] terminated Log thread")
def createfile(filepath):
    """
    creates a file independant from the used operating system
    ###
    filepath - (string) the string of the file to create
    ###
    RETURNS (void)
    """
    operating_system = platform.system()
    if operating_system == "Linux":
        jtlinux.createfile(filepath)
    elif operating_system == "Windows":
        jtwindows.createfile(filepath)