Beispiel #1
0
    def test_calculate_steps_with_end_offsets(self):

        steps_per_declination, \
            steps_per_rotation, \
            declination_start = util.calculate_steps(declination=8,
                                                     rotation=7,
                                                     declination_travel=2000,
                                                     rotation_travel=200,
                                                     start_pos=50,
                                                     end_pos=0)

        assert (steps_per_declination == int(1000 / 7 + 0.5))
        assert (steps_per_rotation == int(200 / 7 + 0.5))
        assert (declination_start == 1000)
Beispiel #2
0
    def test_calculate_steps_with_start_offset(self):

        steps_per_declination, \
            steps_per_rotation, \
            declination_start = util.calculate_steps(declination=8,
                                                     rotation=7,
                                                     declination_travel=3287,
                                                     rotation_travel=200,
                                                     start_pos=62,
                                                     end_pos=0)

        assert (steps_per_declination == 291)
        assert (steps_per_rotation == int(200 / 7 + 0.5))
        assert (declination_start == 1249)
Beispiel #3
0
    def test_calculate_steps_no_offset(self):

        steps_per_declination, \
            steps_per_rotation, \
            declination_start = util.calculate_steps(declination=9,
                                                     rotation=8,
                                                     declination_travel=3474,
                                                     rotation_travel=200,
                                                     start_pos=100,
                                                     end_pos=0)

        assert (steps_per_declination == int(3474 / 8))
        assert (steps_per_rotation == int(200 / 8))
        assert (declination_start == 0)
Beispiel #4
0
def process_scan_command(job_dict: dict, camera_controller: CameraControl,
                         declination_travel_steps: int) -> int:
    """Process the scan command -> take a bunch of pictures
    if we return 0, then the rig is no longer 'homed'. If there's
    an error which doesn't affect homing, we will return the
    input travel steps"""
    try:
        post_status(camera_controller.queue, "scan command received!")
        session_start(camera_controller.queue)  # start a scan session
        declination_divisions = int(job_dict['steps']['declination'])
        rotation_divisions = int(job_dict['steps']['rotation'])
        start = int(job_dict['offsets']['start'])
        stop = int(job_dict['offsets']['stop'])

        max_pictures = 200  # maximum # of pictures we can take (sanity check)
        if (declination_divisions * rotation_divisions) > max_pictures:
            post_status(camera_controller.queue,
                        "too many pictures, exceeded {0}".format(max_pictures))
            return declination_travel_steps

        # okay here's what the inputs mean:
        # ...declination_steps - # of divisions of camera travel (declination)
        # ...rotation_steps - # of divisions in single rotation of model
        # ...start/stop : starting/ending offsets from homed positions.
        #
    except ValueError:
        post_status(camera_controller.queue, "error in scan input value")
        return declination_travel_steps  # leave homing intact since no work done
    except KeyError:
        post_status(camera_controller.queue, "error with input JSON")
        post_status(camera_controller.queue,
                    "/scan JSON failed! : {0}".format(json.dumps(job_dict)))
        return declination_travel_steps  # leave homing intact since no work done

    print('...calculating steps for {0} pictures'.format(
        declination_divisions * rotation_divisions))

    if declination_travel_steps == 0:
        post_status(camera_controller.queue, 'homing system prior to scan...')
        declination_travel_steps = camera_controller.home_camera()

    # okay we have valid parameters, time to scan the object
    steps_per_declination, \
        steps_per_rotation, \
        declination_start = calculate_steps(declination_divisions,
                                            rotation_divisions,
                                            declination_travel_steps,
                                            200,  # number steps in one rotation
                                            start,
                                            stop)

    print('declination_divisions={0}\nrotation_divisions={1}'
          '\ntravel={2}\nstart={3}\nstop={4}'.format(declination_divisions,
                                                     rotation_divisions,
                                                     declination_travel_steps,
                                                     start, stop))
    print(
        '... {0} declination steps, {1} rotation steps, declination start {2}'.
        format(steps_per_declination, steps_per_rotation, declination_start))

    # move camera to starting position for pictures
    forced_exit = camera_controller.move_to_start(declination_start)
    if not forced_exit:
        camera_controller.\
            photograph_model(declination_divisions,
                             rotation_divisions,
                             declination_travel_steps - declination_start,
                             steps_per_declination,
                             steps_per_rotation)

    return 0  # this basically makes us "un-homed'