Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ready({set_picture_sequence, PatientId, ExamPictureSequence}, State) ->
- lager:debug("gsd_exam_fsm: set_picture_sequence"),
- store_last_exam_config({PatientId, ExamPictureSequence}, State),
- Exam = proplists:get_value(image, ExamPictureSequence),
- RetakeImageId = proplists:get_value(retake_image_id, Exam),
- PreviewOption = case proplists:get_value(preview, Exam) of
- true -> with_preview;
- _ -> no_preview
- end,
- %TODO: handle the lens check examination before the protocol execution
- LensCheck = case proplists:get_value(protocol, Exam) of
- undefined ->
- ?NOTICE("[~p] No protocol defined", [?MODULE]);
- Protocol ->
- case proplists:get_value(lens_check, Protocol) of
- true ->
- true;
- false ->
- false;
- _ ->
- ?NOTICE("[~p] No lens_check parameter defined", [?MODULE])
- end
- end,
- case proplists:get_value(fovea_finder_cx, Exam) of
- undefined ->
- ?NOTICE("[~p]Running standard preview", [?MODULE]),
- gsd_image_validation:prepare_for_exam(PreviewOption);
- FoveaFinderCx ->
- FoveaFinderCy = proplists:get_value(fovea_finder_cy, Exam),
- FoveaFinderRadius = proplists:get_value(fovea_finder_radius, Exam),
- FoveaFinderRedValue = proplists:get_value(fovea_finder_red_value, Exam),
- FoveaFinderGreenValue = proplists:get_value(fovea_finder_green_value, Exam),
- FoveaFinderBlueValue = proplists:get_value(fovea_finder_blue_value, Exam),
- ?NOTICE("[~p]Running preview with fovea finder", [?MODULE]),
- gsd_image_validation:prepare_for_exam(FoveaFinderCx, FoveaFinderCy, FoveaFinderRadius, FoveaFinderRedValue,
- FoveaFinderGreenValue, FoveaFinderBlueValue)
- end,
- RetakeImage = case RetakeImageId of
- undefined ->
- undefined;
- _ ->
- BossImageId = case RetakeImageId of
- "image-" ++ _DbId -> RetakeImageId;
- _ -> "image-" ++ RetakeImageId
- end,
- boss_db:find(BossImageId)
- end,
- NextStateName = case RetakeImage of
- undefined when RetakeImageId /= undefined ->
- ?WARNING("Retake of ~p was requested, but image was not found", [RetakeImageId]),
- ready;
- _ ->
- configured
- end,
- NextState = case NextStateName of
- configured ->
- ExposureMultiplier = State#state.exposure_multiplier,
- gsd_hardware_core:set_exposure_multiplier(ExposureMultiplier),
- OdFocus = patient_lib:get_focus_from_todays_images(PatientId, right),
- OsFocus = patient_lib:get_focus_from_todays_images(PatientId, left),
- gsd_tablet:notify_event(?SERVER, eye_focus, [od, OdFocus]),
- gsd_tablet:notify_event(?SERVER, eye_focus, [os, OsFocus]),
- PatientState = #patient_state{od = #eye_state{diopters = OdFocus},
- os = #eye_state{diopters = OsFocus}},
- ModifiedState = State#state{
- sequence = ExamPictureSequence,
- patient_id = PatientId,
- exposure_multiplier = ExposureMultiplier,
- current_patient_state = PatientState
- },
- NewState = gsd_exam:handle_event({on_exam_sequence_started, [ModifiedState]}, Exam, State#state{exposure_multiplier=ExposureMultiplier}, ready),
- gsd_hardware_core:set_ready_for_task(exam),
- gsd_tablet:notify_event(?SERVER, configured, []),
- NewState;
- _ ->
- State
- end,
- {next_state, NextStateName, NextState};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement