Advertisement
Guest User

Untitled

a guest
May 13th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 3.62 KB | None | 0 0
  1. ready({set_picture_sequence, PatientId, ExamPictureSequence}, State) ->
  2.     lager:debug("gsd_exam_fsm: set_picture_sequence"),
  3.  
  4.     store_last_exam_config({PatientId, ExamPictureSequence}, State),
  5.  
  6.     Exam = proplists:get_value(image, ExamPictureSequence),
  7.  
  8.     RetakeImageId = proplists:get_value(retake_image_id, Exam),
  9.  
  10.     PreviewOption = case proplists:get_value(preview, Exam) of
  11.         true -> with_preview;
  12.         _ -> no_preview
  13.     end,
  14.  
  15.     %TODO: handle the lens check examination before the protocol execution
  16.     LensCheck = case proplists:get_value(protocol, Exam) of
  17.         undefined ->
  18.             ?NOTICE("[~p] No protocol defined", [?MODULE]);
  19.         Protocol ->
  20.             case proplists:get_value(lens_check, Protocol) of
  21.                 true ->
  22.                     true;
  23.                 false ->
  24.                     false;
  25.                 _ ->
  26.                     ?NOTICE("[~p] No lens_check parameter defined", [?MODULE])
  27.             end
  28.     end,
  29.  
  30.     case proplists:get_value(fovea_finder_cx, Exam) of
  31.         undefined ->
  32.             ?NOTICE("[~p]Running standard preview", [?MODULE]),
  33.             gsd_image_validation:prepare_for_exam(PreviewOption);
  34.         FoveaFinderCx ->
  35.             FoveaFinderCy = proplists:get_value(fovea_finder_cy, Exam),
  36.             FoveaFinderRadius = proplists:get_value(fovea_finder_radius, Exam),
  37.             FoveaFinderRedValue = proplists:get_value(fovea_finder_red_value, Exam),
  38.             FoveaFinderGreenValue = proplists:get_value(fovea_finder_green_value, Exam),
  39.             FoveaFinderBlueValue = proplists:get_value(fovea_finder_blue_value, Exam),
  40.             ?NOTICE("[~p]Running preview with fovea finder", [?MODULE]),
  41.             gsd_image_validation:prepare_for_exam(FoveaFinderCx, FoveaFinderCy, FoveaFinderRadius, FoveaFinderRedValue,
  42.                 FoveaFinderGreenValue, FoveaFinderBlueValue)
  43.     end,
  44.  
  45.     RetakeImage = case RetakeImageId of
  46.         undefined ->
  47.             undefined;
  48.  
  49.         _ ->
  50.             BossImageId = case RetakeImageId of
  51.                 "image-" ++ _DbId  -> RetakeImageId;
  52.                 _ -> "image-" ++ RetakeImageId
  53.             end,
  54.  
  55.             boss_db:find(BossImageId)
  56.     end,
  57.  
  58.     NextStateName = case RetakeImage of
  59.         undefined when RetakeImageId /= undefined ->
  60.             ?WARNING("Retake of ~p was requested, but image was not found", [RetakeImageId]),
  61.             ready;
  62.        
  63.         _ ->    
  64.             configured
  65.     end,
  66.  
  67.     NextState = case NextStateName of
  68.         configured ->
  69.             ExposureMultiplier = State#state.exposure_multiplier,
  70.  
  71.             gsd_hardware_core:set_exposure_multiplier(ExposureMultiplier),
  72.  
  73.             OdFocus = patient_lib:get_focus_from_todays_images(PatientId, right),
  74.             OsFocus = patient_lib:get_focus_from_todays_images(PatientId, left),
  75.  
  76.             gsd_tablet:notify_event(?SERVER, eye_focus, [od, OdFocus]),
  77.             gsd_tablet:notify_event(?SERVER, eye_focus, [os, OsFocus]),
  78.  
  79.             PatientState = #patient_state{od = #eye_state{diopters = OdFocus},
  80.                                           os = #eye_state{diopters = OsFocus}},
  81.          
  82.             ModifiedState = State#state{
  83.                 sequence = ExamPictureSequence,
  84.                 patient_id = PatientId,
  85.                 exposure_multiplier = ExposureMultiplier,
  86.                 current_patient_state = PatientState
  87.             },
  88.  
  89.             NewState = gsd_exam:handle_event({on_exam_sequence_started, [ModifiedState]}, Exam, State#state{exposure_multiplier=ExposureMultiplier}, ready),
  90.             gsd_hardware_core:set_ready_for_task(exam),
  91.             gsd_tablet:notify_event(?SERVER, configured, []),
  92.             NewState;
  93.  
  94.         _ ->
  95.             State
  96.     end,
  97.     {next_state, NextStateName, NextState};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement