#include "cstatussensor.h"
#include "ui_cstatussensor.h"
#include "logic.h"
#include "cctrlsensoranalog.h"
#include "gui.h"
CStatusSensor::CStatusSensor(QWidget *parent) :
    CMWidget(parent),
    ui(new Ui::CStatusSensor)
{
    ui->setupUi(this);
    m_pLayout=new QGridLayout(this);
    m_pLayout->setMargin(2);
    m_pLayout->setSpacing(2);
    m_iTimerInterval=30;
}

CStatusSensor::~CStatusSensor()
{
    delete ui;
}

void CStatusSensor::MInit()
{
//    CCtrlSensorAnalog* pCtrlSensor;
//    pCtrlSensor=new CCtrlSensorAnalog(this,AIN_MAINPRESS);
//    m_pLayout->addWidget(pCtrlSensor,0,0);
//    mchildwidgets[int(pCtrlSensor)]=pCtrlSensor;
}

void CStatusSensor::MTimeFresh()
{
    CMWidget::MTimeFresh();
    static int iIndex=6;
    V_State* m_pState=m_gSystem.FindSM(SM_IO)->GetIdleState();
    if(m_pState->QueueSize()<100)
    {
    m_pState->pushback_Msg(VarMsg_Driver_ID,QObject::tr("Fresh  AIN Sig"),
                         QVariantList()<<MOTOR_DRIVER<<CMotorDriver::FRESHIO
                         <<IO_INPUT_ANALOG<<IN_ANALOG_BEAM_LENS_AIR);
    }

    CMotorDriver_Base* pMotorDriver = GET_CARD(MOTOR_DRIVER,CMotorDriver_Base);
	if(!pMotorDriver) return;
    float dValue = pMotorDriver->get_iodata_analog(IO_INPUT_ANALOG, IN_ANALOG_BEAM_LENS_AIR, false);
    ui->lblFlowVolume->setText(QString::number(dValue, 'f', 2));
}
