csrc/Therac.h

ExtCallType BeamType CollimatorPosition StateInfoRequest wrap_external_call request_state_info

1#pragma once2#include <HsFFI.h>34#ifdef __cplusplus5#endif67/* Values are part of the ABI: only ever append. 0 is never a valid value and is ignored. */8typedef enum ExtCallType {9  CheekyPadding,10  ExtCallSendMEOS,                 /* 1: prescription edited on screen */11  ExtCallToggleDatentComplete,     /* 2: cursor reached the command line ("Begin"). Sets the12                                          flag; only a reset clears it (that is one of the races) */13  ExtCallToggleEditingTakingPlace, /* 3: cursor moved off the command line to edit. Sets the flag;14                                          SendMEOS also sets it */15  ExtCallReset,                    /* 4: R - drops the prescription at once; the machine itself resets16                                          when Treat gets to it, which after Begin is only once the17                                          magnets are set (as in the original Datent). A prescription18                                          sent in between is kept */19  ExtCallProceed,                  /* 5: P - only during a treatment pause */20  ExtCallHardReset,                /* 6: power cycle */21  ExtCallSet,                      /* 7: set button on the hand control / "set" typed at the console */22  ExtCallFieldLight,               /* 8: hand control rotates the turntable to the field-light position */23  ExtCallBeamOn,                   /* 9: "B" typed at the console - fires the beam once it says BEAM READY.24                                          Only needed after ExtCallUseBeamOnKey */25  ExtCallUseBeamOnKey,             /* 10: this UI has a "B" command: from now on Set-Up Done waits for26                                          ExtCallBeamOn instead of firing by itself (without it, Begin27                                          doubles as B). Survives resets */28  ExtCallPrescribeDose,            /* 11: prescribed monitor units, passed in the beam_energy argument */29  /* clearer aliases for 2 and 3 */30  ExtCallDataEntryComplete = ExtCallToggleDatentComplete,31  ExtCallEditingTakingPlace = ExtCallToggleEditingTakingPlace32} ExtCallType;3334typedef enum BeamType {35  BTCheekyPadding,36  BeamTypeXRay,37  BeamTypeElectron,38  BeamTypeUndefined39} BeamType;40typedef enum CollimatorPosition {41  CPCheekyPadding,42  CollimatorPositionXRay,43  CollimatorPositionElectronBeam,44  CollimatorPositionUndefined /* "nothing requested": the turntable follows the beam type */45} CollimatorPosition;46typedef enum StateInfoRequest {47  SIRCheekyPadding,48  RequestTreatmentOutcome,  /* 1: "", "TREATMENT OK", "MALFUNCTION 54", "FLATNESS", ... */49  RequestActiveSubsystem,   /* 2: "DATA ENTRY" / "TREAT" */50  RequestTreatmentState,    /* 3: "TP_Datent", "TP_PauseTreatment", ... TP_TerminateTreatment with an51                                  outcome other than "TREATMENT OK" means treatment suspend */52  RequestReason,            /* 4: "OPERATOR" or the outcome */53  RequestBeamMode,          /* 5: beam type the hardware was actually set up for */54  RequestBeamEnergy,        /* 6: energy the hardware was actually set up for */55  RequestDumpFullState,     /* 7: the whole state record */56  RequestClass3,            /* 8: the one-byte Class3 counter, "0".."255" */57  RequestTurntablePosition, /* 9: where the turntable physically is, e.g. "CollimatorPositionFieldLight" */58  RequestDisplayedDose,     /* 10: monitor units the dose monitor showed for the last attempt */59  RequestPatientDose,       /* 11: rads the patient actually received since the last reset (the real console couldn't show this) */60  RequestSetButtonPrompt,   /* 12: "PRESS SET BUTTON" while the field light is on, else "" */61  RequestMagnetBeingSet,    /* 13: bending magnet being set, "1".."4", "0" when none */62  RequestBendingMagnetFlag  /* 14: "1" while Ptime still looks for edits (the first magnet), else "0" */63} StateInfoRequest;64#ifdef __cplusplus65extern "C" { // only need to export C interface if66             // used by C++ source code67#endif68#if mingw32_HOST_OS || _WIN3269__declspec(dllexport) HsStablePtr start_machine();70/* After kill_machine the Haskell runtime cannot be started again in the same process.71   Use ExtCallHardReset to restart the simulation instead. */72__declspec(dllexport) void kill_machine();73__declspec(dllexport) void wrap_external_call(74    HsStablePtr wrapped_comms,75    ExtCallType ext_call_type,76    BeamType beam_type,77    CollimatorPosition collimator_position,78    HsInt beam_energy79);80/* The returned string is malloc'd by the library; release it with free_state_info. */81__declspec(dllexport) HsPtr request_state_info(82    HsStablePtr wrapped_comms,83    StateInfoRequest state_info_request84);85__declspec(dllexport) void free_state_info(HsPtr state_info);86#else87HsStablePtr start_machine();88/* After kill_machine the Haskell runtime cannot be started again in the same process.89   Use ExtCallHardReset to restart the simulation instead. */90void kill_machine();91void wrap_external_call(92    HsStablePtr wrapped_comms,93    ExtCallType ext_call_type,94    BeamType beam_type,95    CollimatorPosition collimator_position,96    HsInt beam_energy97);98/* The returned string is malloc'd by the library; release it with free_state_info. */99HsPtr request_state_info(100    HsStablePtr wrapped_comms,101    StateInfoRequest state_info_request102);103void free_state_info(HsPtr state_info);104#endif105#ifdef __cplusplus106}107#endif