Пример #1
0
Date::Date(bool utc)
{
	//logger = //logger::get//logger("Date");
	time_t rawtime;
	struct tm * timeinfo;
	time (&rawtime);
	if(utc)
		timeinfo = gmtime(&rawtime);
	else
		timeinfo = localtime(&rawtime);
	timespec en;
	clock_gettime(CLOCK_REALTIME, &en);
	this->nanoseconds = en.tv_nsec;
	this->timeZoneOffset = timeinfo->tm_isdst;
	string tem;
	tem.append(asctime(timeinfo));
	StringUtil::replaceAll(tem,"\n","");
	StringUtil::replaceAll(tem,"  "," ");
	vector<string> temp,vemp;
	StringUtil::split(temp,tem,(" "));
	this->dayw = StringUtil::toUpperCopy(temp.at(0));
	this->monthw = StringUtil::toUpperCopy(temp.at(1));
	this->month = getMon(monthw);
	this->day = temp.at(2);
	StringUtil::split(vemp,temp.at(3),(":"));
	this->hh = vemp.at(0);
	this->mm = vemp.at(1);
	this->ss = vemp.at(2);
	this->year = temp.at(4);
	this->weekday = getWeekDayVal(this->dayw);
}
Пример #2
0
Date::Date(int yyyy,string mmm,int dd)
{
	string mm = getMon(mmm);
	if(mm=="-1")throw "Invalid month";
	if(!validateDate(dd,CastUtil::lexical_cast<int>(mm),yyyy))throw "Invalid date";
	long g = getDays(yyyy,CastUtil::lexical_cast<long>(mm),dd);
	*this = getDateFromDays(g);
	this->nanoseconds = 0;
	this->timeZoneOffset = 0;
}
Пример #3
0
Date::Date(const int& yyyy, const std::string& mmm, const int& dd)
{
	std::string mm = getMon(mmm);
	if(mm=="-1")throw std::runtime_error("Invalid month");
	if(!validateDate(dd,CastUtil::lexical_cast<int>(mm),yyyy))throw std::runtime_error("Invalid date");
	long g = getDays(yyyy,CastUtil::lexical_cast<long>(mm),dd);
	*this = getDateFromDays(g);
	populateDay();
	populateMonth();
	populateEpochAndTimeZone(false);
}
Пример #4
0
Date::Date(int yy,string mmm,int dd,bool te)
{
	Date d;
	string syyyy = d.year.substr(0,2) + CastUtil::lexical_cast<string>(yy);
	int yyyy = CastUtil::lexical_cast<int>(syyyy);
	string mm = getMon(mmm);
	if(mm=="-1")throw "Invalid month";
	if(!validateDate(dd,CastUtil::lexical_cast<int>(mm),yyyy))throw "Invalid date";
	long g = getDays(yyyy,CastUtil::lexical_cast<long>(mm),dd);
	*this = getDateFromDays(g);
	this->nanoseconds = 0;
	this->timeZoneOffset = 0;
}
Пример #5
0
void FormMainWindow::timerEvent(QTimerEvent *event)
{
    if(event->timerId() == m_nCloseTimer)
    {
        //抬杆
        getDeviceFactory()->getIOBoard()->SetBar(1);
        //关闭所有设备
        getDeviceFactory()->ReleaseAllDevice();
        //qDebug() << "shut down get here 4";
        //关闭参数下载线程
        //qDebug() << "shut down get here 1";

        getReqParam()->StopExcute();
        getReqParam()->wait();
        //qDebug() << "shut down get here 2";

        //关闭校时线程
        getReqTime()->Stop();
        //qDebug() << "shut down get here 3";



        //释放监控线程
        getMon()->Stop();
        //qDebug() << "shut down get here 5";

        //关闭数据库
        getDataFileMgr()->Close();
        //qDebug() << "shut down get here";
        QApplication::instance()->quit();
        ////qDebug() <<getLaneInfo()->getCloseType();
        switch(getLaneInfo()->getCloseType())
        {
        case emCloseApp:
            break;
        case emClosePC:
            QProcess::execute(SZCLOSEPC);
            break;
        case emRestartApp:
            QProcess::startDetached(QApplication::applicationFilePath() + " -qws");
            break;
        case emRestartPC:
            QProcess::execute(SZRESTARTPC);
            break;
        default:
            break;
        }
    }
}
Пример #6
0
void LoadParamTransition::onTransition(QEvent */*event*/)
{
    //加载参数完成后,根据systeminfo,orgcode查询本站站编号,车道编码是否合法
    QSysParaDicParamFile* pSys =(QSysParaDicParamFile*)getParamMgr()->GetParamFile(cfSysParaDic);
    QOrgCodeParamFile * orgCode = (QOrgCodeParamFile*)getParamMgr()->GetParamFile(cfOrgCode);
    SOrgCodeValue orgValue;
    bool ret = orgCode->queryOrgCodeValue(orgValue, pSys->GetSysParamInfo().m_nStationID);
    if(!ret)
    {
        QMessageBox::warning(NULL, tr("错误"), tr("加载参数错误,机构参数中查询不到本站代码:%1")
                             .arg(pSys->GetSysParamInfo().m_nStationID));
        LogMsg("lane", tr("加载参数错误,机构参数中查询不到本站代码:%1")
               .arg(pSys->GetSysParamInfo().m_nStationID));

        //程序退出
        QApplication::exit(-1);
        return;
    }
    //保存orgvalue
    getLaneInfo()->setOrgInfo(orgValue);

    //设置计重
    getWtDataMgr()->setWtDev(getDeviceFactory()->getWtDev());

    //界面显示站名、车道号
    FormMTCTitle* pTitle = NULL;
    getWidgetByType(emFormTitle, (QWidget**)&pTitle);
    pTitle->setStaName(orgValue.sOrgSName);
    pTitle->setStaType(getLaneInfo()->getLaneType(), getLaneInfo()->getLaneCode());
    FormBottomBar* pBottom = NULL;
    getWidgetByType(emFormBottomBar, (QWidget**)&pBottom);
    //出口显示费率版本
    if(!getLaneInfo()->isEntryLane())
    {
        QBaseParamFile* pAll = getParamMgr()->GetParamFile(cfAllRate);
        if(pBottom)
        {
            pBottom->setRateVersion(pAll->GetVersionCode());
        }
    }

    //打开数据库
    if(!getDataSaver()->Init(getLaneInfo()->getOrgInfo().sOrgCode.toInt(), getLaneInfo()->getLaneCode()))
    {
        ////qDebug() << tr("初始化业务数据库失败");
        QMessageBox::warning(NULL, tr("错误"), tr("初始化业务数据库失败"));
        qApp->quit();
        return;
    }
    LogMsg("lane", tr("初始化业务数据库成功"));
    //获取大工班
    if(!getShiftSum()->LoadFromFile())
    {
        LogMsg("lane", tr("读取工班数据失败,工班合计清零!"));
    }
    else
    {
        LogMsg("lane", tr("读取工班数据成功!"));
    }
    //显示未上传的数据条数
    pBottom->ShowUnUpWaste();
    //初始化LaneCtrl
    getLaneCtrl()->Init();
    FormDeviceState* devState = NULL;
    getWidgetByType(emFormDevice,(QWidget**)&devState);
    //devState->Init();
    //初始化报文发送对象
    getDataSendMgr()->SetDataSaver(getDataSaver());
    getDataSendMgr()->InitSendDataClient(getLaneInfo()->getDataSrvIp(), getLaneInfo()->getDataSrvPort());
    //初始化监控对象
    getMon()->WriteServerIP(getLaneInfo()->getMonSrvIp());
    getMon()->WriteServerPort(getLaneInfo()->getMonSrvPort());
    getMon()->SetStaId(getLaneInfo()->getOrgInfo().sOrgCode.toInt());
    getMon()->SetLaneId(getLaneInfo()->getLaneCode());
    //getMon()->Resume();
    devState->Init();
    //初始化数据消息接收对象(被动校时,接收参数文件)
    getLaneMsgServer()->init(MSG_LISTEN_PORT);

    //加载票据卡盒
    bool bRet = getDataFileMgr()->Init();
    if(bRet)
    {
        LogMsg("lane", tr("加载票据、卡盒记录成功!"));
    }
    else
    {
        LogMsg("lane", tr("加载票据、卡盒记录失败!"));
    }

    //设置大班记录
    getLaneInfo()->UpdateShiftDateWhenUnlogin();

    //发送程序启动报文
    getLaneCtrl()->getTollItem()->SendStartMsg();

    //启动定时器,(参数判断是否生效,校时判断,参数文件更新,更新大工班)
    getLaneCtrl()->StartNewParamTimer();
    getLaneCtrl()->StartDownLoadTimer();
    getLaneCtrl()->StartVerifyTimer();
    getLaneCtrl()->StartBigShiftTimer();
    //liujian
    getLaneCtrl()->StartDelDBDataTimer();
    getLaneCtrl()->StartDelPicDataTimer();
    getLaneCtrl()->startUpdateTimer();

    //设置雨棚灯状态
    getDeviceFactory()->getIOBoard()->SetCanopy(0);
    //设置上班状态
    getLaneInfo()->setShiftState(lsUnlogin);
    LogMsg("lane", tr("程序启动完成!"));
}