Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
sd_node.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
open! Core type t = { logic : Robot_state.t Sd_lang.t ; sds_estimating : Set.M(Sd.Packed).t } let create logic sds_estimating = { logic; sds_estimating } type safety = | Safe | Warnings | Unsafe exception Missing_sd of string exception Extra_sd of string let execute ~safety t rsh = let estimated_state = Sd_lang.execute t.logic rsh in let expected_keys = t.sds_estimating in (match safety with | Unsafe -> () | Safe | Warnings -> let missing = Set.find ~f:(fun key -> not (Robot_state.memp estimated_state key)) expected_keys in let extra = Set.find ~f:(fun key -> not (Set.mem expected_keys key)) (Robot_state.keys estimated_state) in (match safety, missing, extra with | Unsafe, _, _ -> (* should never reach here *) () | Safe, Some sd, _ -> raise (Missing_sd (Sd.Packed.to_string sd)) | Safe, None, Some sd -> raise (Extra_sd (Sd.Packed.to_string sd)) | Warnings, Some sd, _ -> printf "Sd_node.Applicable warning: Detected missing sd %s during application" (Sd.Packed.to_string sd) | Warnings, None, Some sd -> printf "Sd_node.Applicable warning: Detected extra sd %s during application" (Sd.Packed.to_string sd) | _, None, None -> ())); estimated_state ;;