<*-CSTDLIB  *>
<*+NOHEADER *>
<*+M2EXTENSIONS *>
DEFINITION MODULE ["C"] sem;

FROM SYSTEM IMPORT CARD16, CARD8, ADDRESS;

(*
TYPE SEM_structAlmanac=RECORD
    toa:CARDINAL;          (* almanac time of applicability (reference time [s]*)
    week,                  (* 10 bit gps week 0-1023 (user must account for week rollover) [week] *)   
    prn,                   (* GPS prn number *)  
    reserved,              (* reserved *)
    svn:CARD16;            (* Satellite vehicle number *)
    ura,                   (* User Range Accuracy lookup code, [0-15], see p. 83 GPSICD200C, 0 is excellent, 15 is use at own risk *)
    health,                (* 0=healthy, unhealthy otherwise  [], subframe 4 and 5, page 25 six-bit health code *)
    config_code:CARD8;      (* configuration code   [], if >=9 Anti-Spoofing is on *)
  
  (* this inicator is not part of the SEM standard but is added by the user if known *)
    is_af0_af1_high_precision:CHAR;  (* indicates precision of af0 and af1 [1=high precision,0=low precision] (22&16 bits, ephemeris source) vs (11&11 bits, almanac source), 0 is typical for most SEM sources *)

    ecc,          (* eccentricity *)
    i0,           (* orbital inclination at reference time                        [rad] *)
    omegadot,     (* rate of right ascension                                      [rad/s] *)
    sqrta,        (* square root of the semi-major axis                           [m^(1/2)]*)
    omega0,       (* longitude of ascending node of orbit plane at weekly epoch   [rad] *)
    w,            (* argument of perigee                                          [rad] *)
    m0,           (* mean anomaly at reference time                               [rad] *)
    af0,          (* polynomial clock correction coefficient (clock bias)         [s],   Note: parameters from ephemeris preferred vs almanac (22 vs 11 bits) *)
    af1:LONGREAL; (* polynomial clock correction coefficient (clock drift)        [s/s], Note: parameters from ephemeris preferred vs almanac (16 vs 11 bits) *)
  END;

PROCEDURE SEM_ReadAlmanacDataFromFile(fn:ARRAY OF CHAR; VAR alm:ARRAY OF SEM_structAlmanac;
                                      almsize:CARD8; VAR rdsize:CARD8):BOOLEAN;
*)
PROCEDURE SEM_ReadAlmanacDataFromFile(fn:ARRAY OF CHAR; palm:ADDRESS;
                                      almsize:CARD8; VAR rdsize:CARD8):BOOLEAN;

(*  const char* semFilePath,  //!< path to the input SEM ASCII file
  SEM_structAlmanac* alm,     //!< pointer to an array of SEM almanac structs
  unsigned char  max_to_read, //!< length of the array
  unsigned char* number_read  //!< number of almanac items read
*)  

END sem.
