コード例 #1
0
    def __init__(self, context, acstate, ipaddr):
        self.log_data_dict = self.DATA_COLUMN_DICT
        self._csvfile = context["experimentLogCSVFilePath"]

        # Get timestamp
        self.log_data_dict["01_timestamp"] = utils.nowTimeToString()

        # Get ACState
        try:
            self.log_data_dict["02_ac_onoff"] = acstate.onoff
            self.log_data_dict["03_ac_operating"] = acstate.operating
            self.log_data_dict["04_ac_temperature"] = acstate.temperature
            self.log_data_dict["05_ac_wind"] = acstate.wind
        except:
            pass

        # Get environmental data if we have sensors
        try:
            ed = EnvironData()
            self.log_data_dict["06_room_temperature"] = ed.get_temperature()
            self.log_data_dict["07_room_humidity"] = ed.get_humidity()
            self.log_data_dict["08_room_pressure"] = ed.get_pressure()
        except:
            pass

        # Get Visitor IP Address
        self.log_data_dict["09_ope_ip_addr"] = ipaddr
コード例 #2
0
    def _writeFiles(self):
        """
        method to write csv files
        """
        timestamp = utils.nowTimeToString()
        data_list = [timestamp, self.onoff, self.settime]
        # TODO: ↑この部分だけがACStateのものと異なるのだが、
        # メソッドを抽象化するにはどうしたら良いか

        # write to 1 line csv file that has current A/C state
        with open(self._fileName, 'w') as f:
            writer = csv.writer(f, lineterminator='\n')
            writer.writerow(data_list)

        # write to logs csv file
        with open(self._logFileName, 'a') as f:
            writer = csv.writer(f, lineterminator='\n')
            writer.writerow(data_list)
コード例 #3
0
    def _writeFiles(self):
        """
        method to write csv files
        """
        timestamp = utils.nowTimeToString()
        data_list = [timestamp,
                     self._onoff,
                     self._operating,
                     self._temperature,
                     self._wind]

        # write to 1 line csv file that has current A/C state
        with open(self._fileName, 'w') as f:
            writer = csv.writer(f, lineterminator='\n')
            writer.writerow(data_list)

        # write to logs csv file
        with open(self._logFileName, 'a') as f:
            writer = csv.writer(f, lineterminator='\n')
            writer.writerow(data_list)