Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 2.48 KB | None | 0 0
  1. handle_image_capture_event(start_capture, State) ->
  2.    
  3.     ImageParams = State#state.current_image_params,
  4.     ImageStateFlags = State#state.current_image_state_flags,
  5.  
  6.     lager:info("[~s:handle_image_capture_event] ~p => ~p, ~p", [?MODULE_STRING, start_capture, ImageParams, ImageStateFlags]),
  7.  
  8.     LightSource = proplists:get_value(light_source, ImageParams),
  9.  
  10.  
  11.     PreAcquisitionRestMs = proplists:get_value(pre_acquisition_rest_ms, ImageParams),
  12.     PreAcquisitionRealignment = proplists:get_value(pre_acquisition_realign, ImageParams),
  13.     RestIntervalElapsed = lists:member(rest_interval_elapsed, ImageStateFlags),
  14.     Realigned = lists:member(realigned, ImageStateFlags),
  15.  
  16.     UpdatedState = handle_capture_message_playback(State),
  17.  
  18.     if
  19.         PreAcquisitionRestMs /= undefined andalso RestIntervalElapsed == false ->
  20.             {ok, ResumeTimer} = timer:apply_after(PreAcquisitionRestMs, gsd_exam_fsm, on_continue_to_next_step, [resume_capture]),
  21.  
  22.             PendingTimers = UpdatedState#state.pending_timers,
  23.  
  24.             lager:debug("[~s:handle_image_capture_event] Resting before next image", [?MODULE_STRING]),
  25.  
  26.             { paused, UpdatedState#state{pending_timers = PendingTimers ++ [{resume_capture, ResumeTimer}]} };
  27.  
  28.         PreAcquisitionRealignment /= undefined andalso Realigned == false ->
  29.             lager:debug("[~s:handle_image_capture_event] Reactivating pupil alignment", [?MODULE_STRING]),
  30.             NextStateName = gsd_exam_fsm:resume_pupil_alignment(),
  31.             { NextStateName, UpdatedState };
  32.  
  33.         LightSource == ir ->
  34.             lager:debug("[~s:handle_image_capture_event] Autoexposure", [?MODULE_STRING]),
  35.  
  36.             Mode = proplists:get_value(mode, ImageParams, automatic),
  37.  
  38.             gsd_programs:start_brightness_control(),
  39.  
  40.             case Mode of
  41.                 automatic ->
  42.                     lager:debug("[~s:handle_image_capture_event] Resume pp motors", [?MODULE_STRING]),
  43.                     gsd_programs:pupil_alignment_resume_motors();
  44.                 _ -> ok
  45.             end,
  46.            
  47.             gsd_tablet:notify_event(?SERVER, autoexposure, []),
  48.  
  49.             { autoexposure, UpdatedState };
  50.  
  51.        
  52.         true -> %vis; af100; af75; af50; af25 ->
  53.             lager:debug("[~s:handle_image_capture_event] Taking ~p picture", [?MODULE_STRING, LightSource]),
  54.  
  55.             NextState = take_current_image(UpdatedState),
  56.            
  57.             { still_picture_acquisition, NextState }
  58.     end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement