forked from xin/TowerOptoSifAndSpectral
- 程序名从 TowerOptoSifAndSpectral 更名为 AirOptoSifAndSpectral - 版本从 2.1.5 更新至 2.1.9 - GPIO 控制逻辑修改:引脚 1 和 12 输出改为 0 - 新增 dpkg preinst 脚本处理冲突文件
95 lines
2.0 KiB
C++
95 lines
2.0 KiB
C++
#include "Scheduler.h"
|
||
|
||
Scheduler::Scheduler(QObject* parent /*= nullptr*/)
|
||
{
|
||
m_iFlagIsOnRestart = 0;
|
||
m_GrabTimer = new QTimer(this);
|
||
connect(m_GrabTimer, &QTimer::timeout, this, &Scheduler::OnTimeCounter);
|
||
connect(this, &Scheduler::SignalSelfStart, this, &Scheduler::StartAsPlanned);
|
||
}
|
||
|
||
Scheduler::~Scheduler()
|
||
{
|
||
if (m_GrabTimer != NULL)
|
||
{
|
||
m_GrabTimer->stop();
|
||
delete m_GrabTimer;
|
||
}
|
||
}
|
||
|
||
void Scheduler::SetAcqTimeParams(AcqTimeSettings struAcqTime)
|
||
{
|
||
m_struAcqTime = struAcqTime;
|
||
}
|
||
|
||
void Scheduler::Preheating()
|
||
{
|
||
qDebug() << "Start Preheating";
|
||
//QThread::msleep(5000);
|
||
#ifdef _DEBUG
|
||
QThread::msleep(5000);
|
||
#else
|
||
QThread::msleep(900000);//NEED TO CHANGE BEFOR HAND TO CUSTOMER
|
||
#endif
|
||
qDebug() << "Preheating Finished";
|
||
}
|
||
|
||
void Scheduler::SelfStart()
|
||
{
|
||
emit SignalSelfStart();
|
||
}
|
||
|
||
void Scheduler::StartAsPlanned()
|
||
{
|
||
bool bStopWait = false;
|
||
|
||
while (!bStopWait)
|
||
{
|
||
QThread::msleep(10000);
|
||
QTime qtTime = QTime::currentTime();
|
||
if (m_struAcqTime.qtStartTime <= qtTime && qtTime < m_struAcqTime.qtStopTime)
|
||
{
|
||
bStopWait = true;
|
||
}
|
||
}
|
||
|
||
int iIntervalInMS = m_struAcqTime.qtInterval.hour() * 3600 * 1000 + m_struAcqTime.qtInterval.minute() * 60 * 1000 + m_struAcqTime.qtInterval.second() * 1000;
|
||
//iIntervalInMS =1000;
|
||
m_GrabTimer->start(iIntervalInMS);
|
||
|
||
QThread::msleep(1000);
|
||
qDebug() << "it's time to start work.";
|
||
emit SignalGrabOnce();
|
||
//this->OnTimeCounter();
|
||
//emit &QTimer::timeout;
|
||
}
|
||
|
||
int Scheduler::OnTimeCounter()
|
||
{
|
||
QTime qtTime = QTime::currentTime();
|
||
if (m_struAcqTime.qtStartTime <= qtTime && qtTime < m_struAcqTime.qtStopTime)
|
||
{
|
||
if (m_iFlagIsOnRestart)
|
||
{
|
||
|
||
}
|
||
|
||
// qDebug() << "it's time to work...work work.";
|
||
emit SignalGrabOnce();
|
||
return 0;
|
||
}
|
||
else
|
||
{
|
||
if (!m_iFlagIsOnRestart)
|
||
{
|
||
m_iFlagIsOnRestart = 1;
|
||
}
|
||
emit SignalZeroHoldCurrent();
|
||
system("gpio write 1 1");//<2F>豸<EFBFBD>ϵ<EFBFBD>
|
||
system("gpio write 12 1");//<2F>豸<EFBFBD>ϵ<EFBFBD>
|
||
qDebug() << "gpio write 1 1......"<<endl;
|
||
qDebug() << "Non working time. Idling......";
|
||
return 0;
|
||
}
|
||
}
|