예제 #1
0
파일: master.py 프로젝트: hif/TwistedBrew
 def handle_done(self, body):
     data = str(body).split(MessageSplit)
     worker_name = data[1]
     session_detail_id = int(data[2])
     session_detail = SessionDetail.objects.get(pk=session_detail_id)
     session_detail.end_work()
     done_measurement = Measurement()
     done_measurement.timestamp = dt.now()
     done_measurement.worker_name = worker_name
     done_measurement.session_detail_id = session_detail_id
     done_measurement.value = 0
     done_measurement.set_point = 0
     done_measurement.work = "Done"
     done_measurement.remaining = "0";
     done_measurement.save()
예제 #2
0
파일: master.py 프로젝트: hif/TwistedBrew
 def handle_measurement(self, worker_measurement_data):
     #log.debug('Receiving worker measurement...')
     try:
         with self.measurements_lock:
             worker_measurement = WorkerMeasurement.deserialize_message(worker_measurement_data)
             measurement = Measurement()
             measurement.worker = worker_measurement.worker_name
             session_detail_id = worker_measurement.session_detail_id
             session_detail = SessionDetail.objects.get(pk=session_detail_id)
             measurement.session_detail = session_detail
             measurement.device = worker_measurement.device_name
             measurement.value = worker_measurement.value
             measurement.set_point = worker_measurement.set_point
             measurement.work = worker_measurement.work
             measurement.remaining = worker_measurement.remaining
             if not worker_measurement.debug_timer is None:   # In simulation mode, use fake timestamps
                 #measurement.timestamp = datetime.strptime(worker_measurement.debug_timer, "%Y-%m-%d %H:%M:%S.%f")
                 #measurement.timestamp = dt.get_current_timezone.localize(measurement.timestamp)
                 measurement.timestamp = worker_measurement.debug_timer
             else:
                 measurement.timestamp = dt.now()
             measurement.save()
     except Exception as e:
         log.error('Master could not save measurement to database ({0})'.format(e.args[0]))
예제 #3
0
 def handle_measurement(self, worker_measurement_data):
     #log.debug('Receiving worker measurement...')
     try:
         with self.measurements_lock:
             worker_measurement = WorkerMeasurement.deserialize_message(
                 worker_measurement_data)
             measurement = Measurement()
             measurement.worker = worker_measurement.worker_name
             session_detail_id = worker_measurement.session_detail_id
             session_detail = SessionDetail.objects.get(
                 pk=session_detail_id)
             measurement.session_detail = session_detail
             measurement.device = worker_measurement.device_name
             measurement.value = worker_measurement.value
             measurement.set_point = worker_measurement.set_point
             measurement.work = worker_measurement.work
             measurement.remaining = worker_measurement.remaining
             if not worker_measurement.debug_timer is None:  # In simulation mode, use fake timestamps
                 #measurement.timestamp = datetime.strptime(worker_measurement.debug_timer, "%Y-%m-%d %H:%M:%S.%f")
                 #measurement.timestamp = dt.get_current_timezone.localize(measurement.timestamp)
                 measurement.timestamp = worker_measurement.debug_timer
             else:
                 measurement.timestamp = dt.now()
             measurement.save()
     except Exception as e:
         log.error(
             'Master could not save measurement to database ({0})'.format(
                 e.args[0]))
예제 #4
0
 def handle_done(self, body):
     data = str(body).split(MessageSplit)
     worker_name = data[1]
     session_detail_id = int(data[2])
     session_detail = SessionDetail.objects.get(pk=session_detail_id)
     session_detail.end_work()
     done_measurement = Measurement()
     done_measurement.timestamp = dt.now()
     done_measurement.worker_name = worker_name
     done_measurement.session_detail_id = session_detail_id
     done_measurement.value = 0
     done_measurement.set_point = 0
     done_measurement.work = "Done"
     done_measurement.remaining = "0"
     done_measurement.save()