Premier commit suite au crash du repo le 10 juillet 2017
This commit is contained in:
@@ -0,0 +1,125 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Classe d'interface avec le pilote Linux COMEDILib pour la carte d'I/O PCI.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121219 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Comedilibinterface.h"
|
||||
#include <QString>
|
||||
|
||||
CComediLibInterface::CComediLibInterface():
|
||||
mOpened(false)
|
||||
{
|
||||
mInputBuf = 0;
|
||||
}
|
||||
|
||||
CComediLibInterface::~CComediLibInterface()
|
||||
{
|
||||
#ifndef NO_PCI_CARD_INSTALLED
|
||||
comedi_close(mComediDevice);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
unsigned int CComediLibInterface::OpenPCIInterface()
|
||||
{
|
||||
|
||||
if(mOpened)
|
||||
return PCIIO_DEVICE_ALREADY_OPENED;
|
||||
|
||||
QString comediFilename = "/dev/comedi0";
|
||||
|
||||
|
||||
CEngLog::instance()->AddLogString(QString("Ouverture de la carte PCI :") + comediFilename,3);
|
||||
mComediDevice = comedi_open(comediFilename.toAscii().data());
|
||||
if(!mComediDevice)
|
||||
{
|
||||
|
||||
CEngLog::instance()->AddLogString("L'ouverture de la carte PCI a échouée",1);
|
||||
return PCIIO_CANNOT_OPEN_DEVICE;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString boardname;
|
||||
boardname = comedi_get_board_name(mComediDevice);
|
||||
|
||||
//Check that we have the good board installed.
|
||||
if(boardname != PCI_DEVICE_NAME)
|
||||
{
|
||||
CEngLog::instance()->AddLogString(QString("").sprintf("Erreur. Incohérence du type de carte; Voulu: %s, Réel: %s",PCI_DEVICE_NAME,boardname.toAscii().data()),1);
|
||||
return PCIIO_DEVICE_MISMATCH;
|
||||
}
|
||||
else
|
||||
{
|
||||
CEngLog::instance()->AddLogString(QString("Carte PCI initialisée :") + boardname,3);
|
||||
}
|
||||
|
||||
// int NbSubDevices = comedi_get_n_subdevices(mComediDevice);
|
||||
// qDebug("Nb Subdevices: %d",NbSubDevices);
|
||||
|
||||
//Check that the inputs and outputs subdevices are correct.
|
||||
int SubDeviceType = comedi_get_subdevice_type(mComediDevice,PCI_OUTPUTS_SUBDEVICE_ID);
|
||||
if(SubDeviceType != COMEDI_SUBD_DO)
|
||||
{
|
||||
CEngLog::instance()->AddLogString(QString("").sprintf("Erreur. Incohérence du type de Output Subdevice; Voulu: %d, Réel: %d",SubDeviceType,PCI_OUTPUTS_SUBDEVICE_ID),1);
|
||||
return PCIIO_OUTPUTS_SUBDEVICE_MISMATCH;
|
||||
}
|
||||
|
||||
SubDeviceType = comedi_get_subdevice_type(mComediDevice,PCI_INPUTS_SUBDEVICE_ID);
|
||||
if(SubDeviceType != COMEDI_SUBD_DI)
|
||||
{
|
||||
CEngLog::instance()->AddLogString(QString("").sprintf("Erreur. Incohérence du type de Output Subdevice; Voulu: %d, Réel: %d",SubDeviceType,PCI_INPUTS_SUBDEVICE_ID),1);
|
||||
return PCIIO_INPUTS_SUBDEVICE_MISMATCH;
|
||||
}
|
||||
//qDebug("type");
|
||||
}
|
||||
|
||||
CEngLog::instance()->AddLogString("Carte PCI ouverte avec succès",3);
|
||||
mOpened = true;
|
||||
return PCIIO_OK;
|
||||
}
|
||||
|
||||
unsigned int CComediLibInterface::GetInputs()
|
||||
{
|
||||
unsigned int Buf;
|
||||
mMutex.lock();
|
||||
comedi_dio_bitfield2(mComediDevice,0,0xFFFFFFFF,&Buf,0);
|
||||
// Buf = mInputBuf;
|
||||
mMutex.unlock();
|
||||
|
||||
return Buf;
|
||||
}
|
||||
|
||||
comedi_t *CComediLibInterface::GetPCIDevice()
|
||||
{
|
||||
if(mOpened == false)
|
||||
return NULL;
|
||||
|
||||
return mComediDevice;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121219 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef COMEDILIBINTERFACE_H
|
||||
#define COMEDILIBINTERFACE_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include "PCI1756Definitions.h"
|
||||
#include <comedilib.h>
|
||||
#include "PCIIOMgr.h"
|
||||
#include <QMutex>
|
||||
|
||||
|
||||
|
||||
class CComediLibInterface : public CPCIIOMgr
|
||||
{
|
||||
public:
|
||||
CComediLibInterface();
|
||||
~CComediLibInterface();
|
||||
|
||||
virtual unsigned int OpenPCIInterface(void);
|
||||
virtual unsigned int GetInputs(void);
|
||||
|
||||
comedi_t *GetPCIDevice(void);
|
||||
|
||||
private:
|
||||
comedi_t *mComediDevice;
|
||||
bool mOpened;
|
||||
QMutex mMutex;
|
||||
unsigned int mInputBuf;
|
||||
|
||||
};
|
||||
|
||||
#endif // COMEDILIBINTERFACE_H
|
||||
@@ -0,0 +1,38 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121219 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PCI1756DEFINITIONS_H
|
||||
#define PCI1756DEFINITIONS_H
|
||||
|
||||
// Subdevice parameters for the Advantech PCI1756
|
||||
#define PCI_INPUTS_SUBDEVICE_ID 2
|
||||
#define PCI_OUTPUTS_SUBDEVICE_ID 1
|
||||
|
||||
#define PCI_DEVICE_NAME "pci1756"
|
||||
#define PCI_DAQNAVI_NAME "PCI-1756"
|
||||
|
||||
#endif // PCI1756DEFINITIONS_H
|
||||
@@ -0,0 +1,121 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Classe d'interface avec la carte d'I/O PCI1756.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20121219 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "PCI1756Interface.h"
|
||||
#include "PCI1756Definitions.h"
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
CPCI1756Interface::CPCI1756Interface():
|
||||
mOpened(false)
|
||||
{
|
||||
mInputBuf = 0;
|
||||
}
|
||||
|
||||
CPCI1756Interface::~CPCI1756Interface()
|
||||
{
|
||||
#ifndef NO_PCI_CARD_INSTALLED
|
||||
if(mOpened)
|
||||
mInputCtrl->Dispose();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
unsigned int CPCI1756Interface::OpenPCIInterface()
|
||||
{
|
||||
|
||||
if(mOpened)
|
||||
return PCIIO_DEVICE_ALREADY_OPENED;
|
||||
|
||||
|
||||
|
||||
CEngLog::instance()->AddLogString(QString("Ouverture de la carte PCI :"),3);
|
||||
|
||||
mInputCtrl = AdxInstantDiCtrlCreate();
|
||||
ICollection<DeviceTreeNode> *supportedDevices = mInputCtrl->getSupportedDevices();
|
||||
if(supportedDevices->getCount() == 0)
|
||||
{
|
||||
CEngLog::instance()->AddLogString("L'ouverture de la carte PCI a échouée (Aucune carte n'est installée)",1);
|
||||
return PCIIO_CANNOT_OPEN_DEVICE;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (int i = 0; i < supportedDevices->getCount(); i++)
|
||||
{
|
||||
DeviceTreeNode const &node = supportedDevices->getItem(i);
|
||||
QString DeviceDescription(QString::fromWCharArray(node.Description));
|
||||
qDebug() << "Device Nbr: " << node.DeviceNumber << " : "<< DeviceDescription;
|
||||
|
||||
if(QString::fromWCharArray(node.Description).contains(PCI_DAQNAVI_NAME))
|
||||
{
|
||||
if(mInputCtrl->setSelectedDevice(DeviceInformation(node.Description)) != Success)
|
||||
{
|
||||
CEngLog::instance()->AddLogString("L'ouverture de la carte PCI a échouée (Carte occupée)",1);
|
||||
supportedDevices->Dispose();
|
||||
mInputCtrl->Dispose();
|
||||
return PCIIO_CANNOT_OPEN_DEVICE;
|
||||
}
|
||||
CEngLog::instance()->AddLogString(QString("Carte PCI initialisée :") + QString::fromWCharArray(node.Description),3);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(found == false)
|
||||
{
|
||||
CEngLog::instance()->AddLogString(QString("").sprintf("Erreur. Incohérence du type de carte"),1);
|
||||
return PCIIO_DEVICE_MISMATCH;
|
||||
}
|
||||
|
||||
supportedDevices->Dispose();
|
||||
CEngLog::instance()->AddLogString("Carte PCI ouverte avec succès",3);
|
||||
mOpened = true;
|
||||
return PCIIO_OK;
|
||||
|
||||
}
|
||||
|
||||
unsigned int CPCI1756Interface::GetInputs()
|
||||
{
|
||||
unsigned int Buf = 0;
|
||||
unsigned char data[4];
|
||||
memset(data,0,4);
|
||||
mMutex.lock();
|
||||
ErrorCode errorCode = Success;
|
||||
errorCode = mInputCtrl->Read(0,4,(unsigned char *)&Buf);
|
||||
if(errorCode != Success)
|
||||
{
|
||||
qDebug("PCI read Error");
|
||||
}
|
||||
|
||||
mMutex.unlock();
|
||||
|
||||
|
||||
return Buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### 20140828 JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PCI1756INTERFACE_H
|
||||
#define PCI1756INTERFACE_H
|
||||
|
||||
#include <bdaqctrl.h>
|
||||
#include "GlobalDefine.h"
|
||||
#include "PCIIOMgr.h"
|
||||
#include <QMutex>
|
||||
|
||||
using namespace Automation::BDaq;
|
||||
|
||||
class CPCI1756Interface : public CPCIIOMgr
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
|
||||
CPCI1756Interface();
|
||||
~CPCI1756Interface();
|
||||
|
||||
virtual unsigned int OpenPCIInterface(void);
|
||||
virtual unsigned int GetInputs(void);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
InstantDiCtrl *mInputCtrl;
|
||||
bool mOpened;
|
||||
QMutex mMutex;
|
||||
unsigned int mInputBuf;
|
||||
|
||||
};
|
||||
|
||||
#endif // DAQNAVIINTERFACE_H
|
||||
@@ -0,0 +1,277 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Description du fichier si nécessaire.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include "ZT2AnalysisThread.h"
|
||||
#include "PCIIOMgr.h"
|
||||
#include "AbstractLazerProbe.h"
|
||||
#include <QElapsedTimer>
|
||||
#include "ZTconfigmgr.h"
|
||||
|
||||
//const char * ErrorString[25] = {"Erreur de comptage S1-S2",
|
||||
// "Déclenchement frotteur négatif",
|
||||
// "Déclenchement pneu de guidage intérieur",
|
||||
// "Déclenchement pneu de guidage extérieur",
|
||||
// "Déclenchement pneu porteur intérieur",
|
||||
// "Déclenchement pneu porteur extérieur",
|
||||
// "Pré-détection frotteur négatif"};
|
||||
|
||||
CZT2AnalysisThread::CZT2AnalysisThread()
|
||||
{
|
||||
mLastInputs = 0;
|
||||
mZT2TrainState = ZT2_PRE_DETECTION_STATE;
|
||||
|
||||
mPCIInputsHandle = 0;
|
||||
mExitLoop = false;
|
||||
mZT2Analyzing = false;
|
||||
}
|
||||
|
||||
unsigned int CZT2AnalysisThread::Init(CPCIIOMgr *PCIIOHandle,GenericInputMasks_t *InputMasks,QElapsedTimer *RefTimer)
|
||||
{
|
||||
mPCIInputsHandle = PCIIOHandle;
|
||||
mInputMasksPtr = InputMasks;
|
||||
mReferenceTimer = RefTimer;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void CZT2AnalysisThread::AnalyzeZT2Train()
|
||||
{
|
||||
|
||||
qDebug("ZT2 Thread started!");
|
||||
mExitLoop = false;
|
||||
mZT2Analyzing = true;
|
||||
|
||||
|
||||
mZT2TrainState = ZT2_PRE_DETECTION_STATE;
|
||||
unsigned int PCIInputs = 0;
|
||||
bool Run = true;
|
||||
|
||||
//inputs
|
||||
unsigned int S1 = 0, Pint = 0, Pext = 0;
|
||||
|
||||
//Train analysis variables
|
||||
unsigned int Bogie = 0;
|
||||
unsigned int Rank = 0;
|
||||
unsigned int CountS1 = 0;
|
||||
|
||||
|
||||
bool PPIDetected = false;
|
||||
bool PPEDetected = false;
|
||||
|
||||
|
||||
while(Run == true)
|
||||
{
|
||||
PCIInputs = mPCIInputsHandle->GetInputs();
|
||||
|
||||
if(PCIInputs != mLastInputs)
|
||||
{
|
||||
//Extract useful flags
|
||||
|
||||
S1 = ((PCIInputs & mInputMasksPtr->InputZT2S1Mask) != 0);
|
||||
Pint = ((PCIInputs & mInputMasksPtr->InputZT2PIMask) != 0);
|
||||
Pext = ((PCIInputs & mInputMasksPtr->InputZT2PEMask) != 0);
|
||||
|
||||
if(mZT2TrainState == ZT2_PRE_DETECTION_STATE)
|
||||
{
|
||||
if(/*S1 != 0 || */Pint != 0 || Pext != 0)
|
||||
{
|
||||
RegisterDetection(DETECTION_ZT1_FN_PRE_DETECTION,0,mReferenceTimer->nsecsElapsed());
|
||||
}
|
||||
mZT2TrainState = ZT2_WAIT_FOR_S1_STATE;
|
||||
}
|
||||
|
||||
switch(mZT2TrainState)
|
||||
{
|
||||
case ZT2_PRE_DETECTION_STATE:
|
||||
{
|
||||
qDebug("ZT2AnalysisThread::Logic error, in ZT2 Pre detection state and should not...");
|
||||
mZT2TrainState = ZT2_WAIT_FOR_S1_STATE;
|
||||
break;
|
||||
}
|
||||
case ZT2_WAIT_FOR_S1_STATE:
|
||||
{
|
||||
if(Pint != 0)
|
||||
{
|
||||
if(PPIDetected == false)
|
||||
{
|
||||
PPIDetected = true;
|
||||
RegisterDetection(DETECTION_ZT2_PPI_DETECTION,Rank,mReferenceTimer->nsecsElapsed());
|
||||
}
|
||||
}
|
||||
if(Pext != 0)
|
||||
{
|
||||
if(PPEDetected == false)
|
||||
{
|
||||
PPEDetected = true;
|
||||
RegisterDetection(DETECTION_ZT2_PPE_DETECTION,Rank,mReferenceTimer->nsecsElapsed());
|
||||
}
|
||||
}
|
||||
|
||||
if(S1 == 1)
|
||||
{
|
||||
Rank++;
|
||||
CountS1++;
|
||||
if(Rank %2 == 1)
|
||||
Bogie++;
|
||||
|
||||
PPIDetected = false;
|
||||
PPEDetected = false;
|
||||
|
||||
mZT2TrainState = ZT2_S1_ACTIVE_STATE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ZT2_S1_ACTIVE_STATE:
|
||||
{
|
||||
if(Pint != 0)
|
||||
{
|
||||
if(PPIDetected == false)
|
||||
{
|
||||
PPIDetected = true;
|
||||
RegisterDetection(DETECTION_ZT2_PPI_DETECTION,Rank,mReferenceTimer->nsecsElapsed());
|
||||
}
|
||||
}
|
||||
if(Pext != 0)
|
||||
{
|
||||
if(PPEDetected == false)
|
||||
{
|
||||
PPEDetected = true;
|
||||
RegisterDetection(DETECTION_ZT2_PPE_DETECTION,Rank,mReferenceTimer->nsecsElapsed());
|
||||
}
|
||||
}
|
||||
|
||||
if(S1 == 0)
|
||||
{
|
||||
mZT2TrainState = ZT2_WAIT_FOR_S1_STATE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}//switch(mZT2TrainState)
|
||||
|
||||
mLastInputs = PCIInputs;
|
||||
|
||||
CZT2ThreadData *Data = new CZT2ThreadData();
|
||||
Data->mTimeStamp = mReferenceTimer->nsecsElapsed();
|
||||
// Data->mDateTime = QDateTime::currentDateTime();
|
||||
Data->mS1 = S1;
|
||||
Data->mPPExt = Pext;
|
||||
Data->mPPInt = Pint;
|
||||
|
||||
Data->mBogie = Bogie;
|
||||
Data->mRank = Rank;
|
||||
Data->mS1Count = CountS1;
|
||||
|
||||
|
||||
emit ZT2DataUpdate(Data);
|
||||
|
||||
}//if(PCIInputs != mLastInputs)
|
||||
|
||||
|
||||
mMutex.lock();
|
||||
if(mExitLoop == true)
|
||||
Run = false;
|
||||
mMutex.unlock();
|
||||
|
||||
}//while
|
||||
|
||||
mZT2Analyzing = false;
|
||||
|
||||
}
|
||||
|
||||
void CZT2AnalysisThread::TerminateAnalysis()
|
||||
{
|
||||
mMutex.lock();
|
||||
mExitLoop = true;
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
bool CZT2AnalysisThread::UpdateDetectionConfig(CZTDetectionFunctionConfig *NewConfig)
|
||||
{
|
||||
//do not update in the middle of a train analysis.
|
||||
bool Go;
|
||||
mMutex.lock();
|
||||
Go = mZT2Analyzing;
|
||||
mMutex.unlock();
|
||||
|
||||
if(Go == true)
|
||||
return false;
|
||||
|
||||
//No need for a Mutex here since the thread is
|
||||
//not analyzing.
|
||||
mDetectionConfig = *NewConfig;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CZT2AnalysisThread::RegisterDetection(unsigned int DetectionID, unsigned int Rank,qint64 TimeStamp)
|
||||
{
|
||||
if(mDetectionConfig.mZTDetectionConfig[DETECTION_FCT_ZT2].AnalysisActive == false)
|
||||
return;
|
||||
|
||||
|
||||
switch(DetectionID)
|
||||
{
|
||||
case DETECTION_ZT2_PRE_DETECTION:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case DETECTION_ZT2_MAGNETIC_SENCOR_COUNT:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case DETECTION_ZT2_PPI_DETECTION:
|
||||
{
|
||||
if(mDetectionConfig.mZTDetectionConfig[DETECTION_FCT_PP2].AnalysisActive == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DETECTION_ZT2_PPE_DETECTION:
|
||||
{
|
||||
if(mDetectionConfig.mZTDetectionConfig[DETECTION_FCT_PP2].AnalysisActive == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CZTDetectionData *DetectData = new CZTDetectionData;
|
||||
DetectData->mTimeStap = TimeStamp;
|
||||
DetectData->mRank = Rank;
|
||||
DetectData->mDetectionID = DetectionID;
|
||||
|
||||
emit DetectionTriggered(DetectData);
|
||||
|
||||
|
||||
qDebug("%s -> Rang %d",CZTData::GetErrorString(DetectionID),Rank);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*******************************************************************************
|
||||
* *
|
||||
* Société de Transports de Montréal. *
|
||||
* 2012 - 2013 *
|
||||
* *
|
||||
* Projet Zones Tests *
|
||||
* *
|
||||
* *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
/*
|
||||
Description:
|
||||
Cette classe est un thread qui lit la carte PCI d'I/O sur laquelle sont
|
||||
branchées les entrées à haute fréquence. La machine à états analyse le
|
||||
passage du train et détecte les déclenchements (sondes, frotteur négatif,
|
||||
pneu porteur). On utilise un thread car l'analyse doit se faire à très
|
||||
haute fréquence sans être ralentie par l'interface graphique.
|
||||
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* Revision:
|
||||
### YYYMMDD JFM
|
||||
Verision d'origine.
|
||||
|
||||
### YYYYMMDD Description du besoin ou du bug
|
||||
Description du changement.
|
||||
*/
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef ZT2ANALYSISTHREAD_H
|
||||
#define ZT2ANALYSISTHREAD_H
|
||||
|
||||
#include <QObject>
|
||||
#include "GlobalDefine.h"
|
||||
#include "Station.h"
|
||||
#include <QMutex>
|
||||
#include "ZTData.h"
|
||||
#include "QElapsedTimer"
|
||||
|
||||
class CPCIIOMgr;
|
||||
//class CAbstractLazerProbe;
|
||||
|
||||
class CZT2AnalysisThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CZT2AnalysisThread();
|
||||
unsigned int Init(CPCIIOMgr *PCIIOHandle,GenericInputMasks_t *InputMasks,QElapsedTimer *RefTimer);
|
||||
void TerminateAnalysis();
|
||||
bool UpdateDetectionConfig(CZTDetectionFunctionConfig*);
|
||||
|
||||
private:
|
||||
enum eTrainState
|
||||
{
|
||||
ZT2_PRE_DETECTION_STATE,
|
||||
ZT2_WAIT_FOR_S1_STATE,
|
||||
ZT2_S1_ACTIVE_STATE,
|
||||
|
||||
ZT1_TRAIN_TRANSIT_FINISHED_STATE
|
||||
|
||||
};
|
||||
|
||||
void RegisterDetection(unsigned int DetectionID, unsigned int Rank, qint64 TimeStamp);
|
||||
|
||||
unsigned int mZT2TrainState;
|
||||
unsigned int mLastInputs;
|
||||
|
||||
bool mExitLoop;
|
||||
QMutex mMutex;
|
||||
bool mZT2Analyzing;
|
||||
|
||||
CPCIIOMgr *mPCIInputsHandle;
|
||||
GenericInputMasks_t *mInputMasksPtr;
|
||||
|
||||
QElapsedTimer *mReferenceTimer;
|
||||
|
||||
CZTDetectionFunctionConfig mDetectionConfig;
|
||||
|
||||
|
||||
public slots:
|
||||
void AnalyzeZT2Train();
|
||||
|
||||
signals:
|
||||
void ZT2DataUpdate(CZT2ThreadData* );
|
||||
void DetectionTriggered(CZTDetectionData* );
|
||||
};
|
||||
|
||||
#endif // ZT2ANALYSISTHREAD_H
|
||||
Reference in New Issue
Block a user