10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-11-07 14:43:39 +01:00
qmcchem/ocaml/Status.ml

56 lines
917 B
OCaml
Raw Normal View History

2015-12-19 02:35:13 +01:00
open Qputils
type t =
| Stopped
| Queued
| Running
| Stopping
;;
let of_string = function
| "Stopped" -> Stopped
| "Queued" -> Queued
| "Running" -> Running
| "Stopping" -> Stopping
| _ -> failwith "Invalid status"
;;
let of_int = function
| 0 -> Stopped
| 1 -> Queued
| 2 -> Running
| 3 -> Stopping
| _ -> failwith "Invalid status"
;;
let to_string = function
| Stopped -> "Stopped"
| Queued -> "Queued"
| Running -> "Running"
| Stopping -> "Stopping"
;;
let to_int = function
| Stopped -> 0
| Queued -> 1
| Running -> 2
| Stopping -> 3
;;
2020-04-15 23:24:54 +02:00
let is_set = ref false
2015-12-19 02:35:13 +01:00
let read () =
2020-04-15 23:24:54 +02:00
if not !is_set then
(Ezfio.set_file (Lazy.force ezfio_filename); is_set := true);
2015-12-19 02:35:13 +01:00
Ezfio.get_simulation_do_run ()
|> of_int
;;
let write x =
2020-04-15 23:24:54 +02:00
if not !is_set then
(Ezfio.set_file (Lazy.force ezfio_filename); is_set := true);
2015-12-19 02:35:13 +01:00
to_int x
|> Ezfio.set_simulation_do_run
;;