#include "arr_desc.h"

// Numpy data type holding a cluster
PyArray_Descr* cluster_dt(){
    import_array();
    PyObject *dict;
    PyArray_Descr *dtype = NULL;
    dict = Py_BuildValue("[(s, s),(s, s),(s, s, (i))]", "x", "u2", "y",
                            "u2", "data", "i4", 9);
    PyArray_DescrConverter(dict, &dtype);
    Py_DECREF(dict);
    return dtype;
}

// Numpy data type holding the result of a cluster analysis
PyArray_Descr *cluster_analysis_dt() {
    import_array(); //TODO! Correct placement for this?
    PyObject *dict;
    PyArray_Descr *dtype;
    dict = Py_BuildValue("[(s, s),(s, s),(s, s),(s,s)]", "corner", "u4","tot", "i4", "etax",
			 "d", "etay","d");

    PyArray_DescrConverter(dict, &dtype);
    Py_DECREF(dict);
    return dtype;
}

PyArray_Descr *frame_header_dt() {
    import_array();
    // Move this to a function that gets run on init??
    PyObject *dtype_dict;
    PyArray_Descr *dtype;
    dtype_dict = Py_BuildValue(
        "[(s, s), (s, s), (s, s), (s, s), (s, s), (s, s), (s, s), (s, s), (s, "
        "s), (s, s), (s, s), (s, s), (s, s), (s, s)]",
        "Frame Number", "u8", "SubFrame Number/ExpLength", "u4",
        "Packet Number", "u4", "Bunch ID", "u8", "Timestamp", "u8", "Module Id",
        "u2", "Row", "u2", "Column", "u2", "Reserved", "u2", "Debug", "u4",
        "Round Robin Number", "u2", "Detector Type", "u1", "Header Version",
        "u1", "Packets Caught Mask", "V64");

    PyArray_DescrConverter(dtype_dict, &dtype);
    Py_DECREF(dtype_dict);
    return dtype;
}
