tlguti_h

/*
 * Copyright 2014,  Fermi Research Alliance, LLC.  All rights reserved.
 * $Id: tlguti.h,v 1.8 2016/11/17 18:09:23 hendricks Exp $
 */

#ifndef TLGUTI_H
#define TLGUTI_H

#include <vector>
#include <string>

namespace TlgUti {
    enum machine_t {
	    TLG_BOOSTER		= 0,
	    TLG_MI		= 1,
	    TLG_TEVATRON	= 2,
	    TLG_ACCUMULATOR	= 3,
	    TLG_DEBUNCHER	= 4,
	    TLG_RECYCLER	= 5,
	    TLG_SWITCHYARD	= 6,
	    TLG_NUMI		= 7,
	    TLG_MTA		= 8	// Added 2009-09-17 (JD)
    };

    static const machine_t TLG_MAX_MACHINE = TLG_MTA;

    static const int TLG_EVENT_ALL = 0x1234;	// Request all events

    enum tlg_t {Oper = 0, Test};

    struct TLG_RESET_INFO {
	int event;
	int state;
	float time;
    };

    float SupercycleLength(tlg_t);
    void CycleLength(tlg_t, machine_t, std::vector<int>&, std::vector<float>&);
    std::vector<TLG_RESET_INFO> GetResetInfo(tlg_t, machine_t);
    std::vector<float> EventTimes(tlg_t, int);
    float MinCycleLength(tlg_t, machine_t, int);
    float MaxCycleLength(tlg_t, machine_t, int);
    void Check(tlg_t);

    inline float SupercycleLength() {
	return SupercycleLength(Oper);
    }
    inline void CycleLength(machine_t const machine, std::vector<int>& events,
						std::vector<float>& length) {
	CycleLength(Oper, machine, events, length);
    }
    inline std::vector<TLG_RESET_INFO> GetResetInfo(machine_t const machine) {
	return GetResetInfo(Oper, machine);
    }
    inline std::vector<float> EventTimes(int const event) {
	return EventTimes(Oper, event);
    }
    inline float MinCycleLength(machine_t const machine, int const event) {
	return MinCycleLength(Oper, machine, event);
    }
    inline float MaxCycleLength(machine_t const machine, int const event) {
	return MaxCycleLength(Oper, machine, event);
    }
    inline void Check() {
	Check(Oper);
    }
}

using TlgUti::TLG_BOOSTER;
using TlgUti::TLG_MI;
using TlgUti::TLG_TEVATRON;
using TlgUti::TLG_ACCUMULATOR;
using TlgUti::TLG_DEBUNCHER;
using TlgUti::TLG_RECYCLER;
using TlgUti::TLG_SWITCHYARD;
using TlgUti::TLG_NUMI;
using TlgUti::TLG_MTA;
using TlgUti::TLG_EVENT_ALL;
using TlgUti::TLG_RESET_INFO;
using TlgUti::TLG_MAX_MACHINE;

int tlg_supercycle_length(float*, TlgUti::tlg_t = TlgUti::Oper);
int tlg_cycle_length(TlgUti::machine_t, int**, float**,
						TlgUti::tlg_t = TlgUti::Oper);
int tlg_get_reset_info_c(TlgUti::machine_t, TlgUti::TLG_RESET_INFO**, int*,
						TlgUti::tlg_t = TlgUti::Oper);
int tlg_event_times_c(int, float*, int, TlgUti::tlg_t = TlgUti::Oper);
int tlg_init_c(TlgUti::tlg_t tlg=TlgUti::Oper);
int tlg_min_cycle_length_c(TlgUti::machine_t, int, float*,
						TlgUti::tlg_t = TlgUti::Oper);
int tlg_max_cycle_length_c(TlgUti::machine_t, int, float*,
						TlgUti::tlg_t = TlgUti::Oper);
int tlg_sanity_check_c(std::string&, TlgUti::tlg_t = TlgUti::Oper);
#endif