#ifndef IVDRIVER_CAN_NVIDIA_AGX_H
#define IVDRIVER_CAN_NVIDIA_AGX_H

#include "ivdriver_can.h"

#include <QThread>
#include <QMutex>
#include <memory>
#include <QTimer>
#include <array>
#include <vector>
#include <iostream>
#include "nvcan.h"
#include "modulecomm.h"
#include "canmsg.pb.h"
#include "canraw.pb.h"
#include "canstate.pb.h"
#include "xmlparam.h"

namespace  iv {


class ivdriver_can_nvidia_agx : public ivdriver_can
{
public:
    ivdriver_can_nvidia_agx(std::string strxmlpath);

public:
    virtual void modulerun();

private:
    basecan * mpcan;
    std::shared_ptr<basecan> mspcan;
    bool mbCANOpen = false;

    std::vector<basecan_msg> msendmsgvector1;
    std::vector<basecan_msg> msendmsgvector2;
    const int SENDMSGBUFSIZE = 3000;

    QMutex mMutexcan1;
    QMutex mMutexcan2;

    int mindex[2];

    void * mpasend0, * mpasend1, * mparecv0, * mparecv1, *mpcanState;

public:
    void sendmsg(int index,iv::can::canmsg xmsg);
    void sharecanmsg(void * xpa,basecan_msg * pxmsg,int ncount,int nch);
};

}
#endif // IVDRIVER_CAN_NVIDIA_AGX_H