Beispiel #1
0
void WeatherStation::disableBeforeSleep()
{
    volatile uint8_t *out, *ddr;
    uint8_t i;

    setCurrentDate();

    lcd.noBacklight();

    sensorMgt.stop();

    overTime = 0;

    delay(100);

    /**close ports**/
    for( i = 0; i < PALETTE_PORT_NUM; i++ )
    {
        ddr = portModeRegister(ioPort[i]);
        out = portOutputRegister(ioPort[i]);

        ioPreDDRValue[i] = *ddr;
        ioPrePORTValue[i] = *out;

        (*ddr) &= ioDisableMask[i];
        (*out) &= ioDisableMask[i];
    }


}
Beispiel #2
0
void WeatherStation::processRTCAlarm()
{

    runHours++;

    /**eliminate disturbance**/
#if !_DEBUG
    setCurrentDate();

    if ( currentMinute <= 2 )
    {

#else
        currentHour++;
        currentHour = currentHour % 24;

        if ( 0 == currentHour )
        {
            currentDate++;
            currentDate = currentDate % 31;
        }

        DBG_PRINTLN_VAR(overTime,DEC);
#endif

        addAction(ACTION_SAMPLE_DATA);
        addAction(ACTION_SAVE_DATA);

#if !_DEBUG
    }
#endif


}
Beispiel #3
0
void WeatherStation::processButton()
{
    #define GOTOSLEEP_TIME 2 //s

    setCurrentDate();
    buttonPressHours = runHours;
    buttonPressMinute = currentMinute;

    if ( DISPLAY_STATE_INIT == displayMgt.state )
    {
        lcd.backlight();

        lcd.setCursor(0,0);
        lcd.print("Weather Station");  //16
        lcd.setCursor(0,1);
        lcd.print("*** DFRobot ***");  //16

        addAction(ACTION_SAMPLE_DATA);
    }

    addAction(ACTION_DISPLAY);


    overTime = SLEEP_OVERTIME;
    /**to avoid RTC interrupt when goto sleep **/
    if ( (59 == currentMinute) && ( (currentSecond + overTime + GOTOSLEEP_TIME) >= 60 ))
    {
        overTime += (GOTOSLEEP_TIME + 1);
    }


}
Beispiel #4
0
void DCalendar::updateCurrentDate()
{
    const QDate &date = QDate::currentDate();

    if (date != m_currentDate)
        setCurrentDate(date);
}
void FilterDateOrderWidget::populate()
{
    QDate date = QDate::currentDate().addDays(PLUS_DAYS);
    if (m_currentIndex != -1) {
        date = currentDate();
    }

    m_currentIndex = -1;

    m_quickDates.clear();

    QSqlQuery sql;
    sql.exec(QString("SELECT mo_date FROM manufacture_orders "
                     "WHERE mo_state <> %1 AND mo_station = %2 AND "
                     "mo_date >= CURRENT_DATE "
                     "GROUP BY mo_date")
             .arg(ManufactureOrder::CompletedState)
             .arg(m_station->id()));

    if (sql.lastError().isValid()) {
        qCritical() << sql.lastError();
        QMessageBox::critical(this, "Error", sql.lastError().text());
        return;
    }

    while(sql.next()) {
        m_quickDates.append(sql.value(0).toDate());
    }

    if (m_quickDates.isEmpty()) {
        return;
    }

    qSort(m_quickDates);

    if (m_quickDates.contains(date)) {
        setCurrentDate(date);
    } else {
        setCurrentDate(m_quickDates.last());
    }

}
void FilterDateOrderWidget::showCalendar()
{
    if (!m_chooseDateDlg) {
        m_chooseDateDlg = new ChooseDateDialog(this);
    }


    if (m_chooseDateDlg->exec() == QDialog::Accepted) {
        setCurrentDate(m_chooseDateDlg->date());
    }
}
void TMailMessage::init(const QByteArray &encoding)
{
    QTextCodec *codec = QTextCodec::codecForName(encoding);
    textCodec = (codec) ? codec : QTextCodec::codecForName("UTF-8");
    // Sets default values
    setCurrentDate();
    QByteArray type = DEFAULT_CONTENT_TYPE;
    type += "; charset=\"";
    type += codec->name();
    type += '\"';
    setContentType(type);
}
Beispiel #8
0
void WeatherStation::enableAfterSleep()
{
    uint8_t i;
    volatile uint8_t *out, *ddr;
    uint16_t diffMinutes;

    //enable power
    digitalWrite( PALETTE_PIN_MVCC, LOW );
    pinMode( PALETTE_PIN_MVCC, OUTPUT );
    delay(50);  //waiting power stable

    /**recovery ports**/
    for( i = 0; i < PALETTE_PORT_NUM; i++ )
    {
        ddr = portModeRegister(ioPort[i]);
        out = portOutputRegister(ioPort[i]);

        *ddr = ioPreDDRValue[i];
        *out = ioPrePORTValue[i];
    }


    sensorMgt.start();
    lcd.init();  //need sometimes

    if ( EVENT_STATE_SET == eventButtonState )
    {
        lcd.backlight();

        setCurrentDate();

        diffMinutes = (uint16_t)(runHours - buttonPressHours) * 60 + currentMinute - buttonPressMinute;

        if ( (!displayMgt.statisticFlag) || (diffMinutes >= RESTART_DISPLAY_OVERTIME) )
        {
            clrDisplayMgt();
        }
    }


    for ( i = 0; i < ACTION_NUMBER; i++ )
    {
        a_actionList[i].state = STATE_INIT;
    }

    startTime = (uint8_t)(millis()/1000);

}
Beispiel #9
0
/*****************************************************
**
**   Document   ---   OnTimer
**
******************************************************/
void Document::OnTimer( wxTimerEvent& )
{
	double sw;
	if ( config->animation->mode )
	{
		sw = config->animation->stepLength;
		switch ( config->animation->stepDimension )
		{
		case 0:  // seconds
			sw /= 86400;
			break;
		case 1:  // minutes
			sw /= 1400;
			break;
		case 2:  // hours
			sw /= 24;
			break;
		case 3:  // days
			break;
		case 4:  // months
			sw *= 30.6;
			break;
		case 5:  // years
			sw *= 365.25;
			break;
		default:  // seconds
			sw /= 86400;
			break;
		}
		setDate( getJD() + sw );
	}
	else
	{
		setCurrentDate();
	}
	update();
	updateAllChildWindows();

	// see if interval param has changed, so restart timer
	if ( config->animation->interval != myAniInterval )	StartTimer( true );
}
Beispiel #10
0
//----------------------------------------------------
void GribPlot::loadFile (QString fileName,
						 LongTaskProgress * taskProgress)
{
	this->fileName = fileName;
	listDates.clear();
    
    if (gribReader != NULL) {
    	delete gribReader;
        gribReader = NULL;
    }
	
	gribReader = new GribReader ();
    if (gribReader != NULL)
    {
		gribReader->openFile (qPrintable(fileName), taskProgress);
		if (gribReader->isOk())
		{
			listDates = gribReader->getListDates();
			setCurrentDate ( listDates.size()>0 ? *(listDates.begin()) : 0);
		}
	}
}
Beispiel #11
0
void WeatherStation::init( DataConfig *p_dataConfig, uint8_t dataNum )
{
    uint8_t i, index;
    DataConfig *p_dataConfigRecord = NULL;

    /**init config table**/
    p_dataConfigRecord = p_dataConfig;
    index = 0;

    DBG_PRINTLN("measure table:");

    for( i = 0; i < dataNum; i++ )
    {
        a_measureData[index].p_sensor = sensorMgt.creatObject( p_dataConfigRecord->sensorID, p_dataConfigRecord->attachPin, p_dataConfigRecord->auxiliaryPin );
        if ( NULL == a_measureData[index].p_sensor )
        {
            String info;

            info = "Error: Rule No.";
            info += (i+1);

            showErrInfo( info );

            break;
        }

        a_measureData[index].dataType = p_dataConfigRecord->type;
        a_measureData[index].valid = true;

        dataHouse.addDataTypeIndex(a_measureData[index].dataType);

        DBG_PRINTLN_VAR(index, DEC);
        DBG_PRINTLN_VAR((word)a_measureData[index].p_sensor, HEX);

        index++;
        p_dataConfigRecord++;


    }

    measureNum = index;

    //todo enable power
    digitalWrite( PALETTE_PIN_MVCC, LOW );
    pinMode( PALETTE_PIN_MVCC, OUTPUT );
    delay(500);  //waiting power stable

    /**init devices**/
	Wire.begin();
	RTCObj.begin();
    lcd.init();
    lcd.backlight();

    setCurrentDate();
    dataHouse.init( currentYear, currentMonth, currentDate, currentHour );

    sensorMgt.start();

    /**get the state of Switch**/
    pinMode(PALETTE_PIN_SW, INPUT_PULLUP);
    switchState = digitalRead(PALETTE_PIN_SW);

    /**attach interrupt**/
    pinMode(STAION_PIN_RTC_INT, INPUT_PULLUP);
    pinMode(STAION_PIN_BUTTON, INPUT );

    PCattachInterrupt( STAION_PIN_RTC_INT );
    PCattachInterrupt( STAION_PIN_BUTTON );

    RTCObj.clearINTStatus();

#if _DEBUG
	RTCObj.enableInterrupts(EveryMinute);
#else
	RTCObj.enableInterrupts(EveryHour);
#endif

    /**Start**/
    pinMode(PALETTE_PIN_BLK, OUTPUT);
    digitalWrite(PALETTE_PIN_BLK,HIGH);

    startTime = (uint8_t)(millis()/1000);

    /**emulate pushing button**/
    setEvent( STAION_PIN_BUTTON );


}
Beispiel #12
0
DUI_BEGIN_NAMESPACE

DCalendar::DCalendar(QWidget *parent) : QWidget(parent)
{
    D_THEME_INIT_WIDGET(DCalendar);

    m_detailLabel = new QLabel;
    m_yearEdt = new QLineEdit;
    m_yearEdt->setEnabled(false);
    m_yearEdt->setFixedWidth(40);
    m_yearEdt->setAlignment(Qt::AlignCenter);
    m_monEdt = new QLineEdit;
    m_monEdt->setEnabled(false);
    m_monEdt->setFixedWidth(25);
    m_monEdt->setAlignment(Qt::AlignCenter);
    m_resetBtn = new DLinkButton;
    m_resetBtn->setText("Reset");
    m_resetBtn->hide();
    m_viewLeft = new CalendarView;
    m_viewLeft->setObjectName("CalendarView");
    m_viewCurrent = m_viewLeft;
    m_viewRight = new CalendarView;
//    m_viewRight->setCurrentDate(QDate::currentDate());
    m_viewRight->setObjectName("CalendarView");
    m_viewOuterWidget = new QWidget;
    m_viewOuterWidget->installEventFilter(this);
    m_viewOuterWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    m_viewInnerWidget = new QWidget(m_viewOuterWidget);
    m_currentDate = QDate::currentDate();
    m_showDate = m_currentDate;
    m_animation = new QPropertyAnimation(m_viewInnerWidget, "geometry");

    DImageButton *prevYear = new DImageButton;
    prevYear->setNormalPic(":/images/arrow_left_normal.png");
    prevYear->setHoverPic(":/images/arrow_left_hover.png");
    prevYear->setPressPic(":/images/arrow_left_press.png");
    DImageButton *nextYear = new DImageButton;
    nextYear->setNormalPic(":/images/arrow_right_normal.png");
    nextYear->setHoverPic(":/images/arrow_right_hover.png");
    nextYear->setPressPic(":/images/arrow_right_press.png");
    DImageButton *prevMon = new DImageButton;
    prevMon->setNormalPic(":/images/arrow_left_normal.png");
    prevMon->setHoverPic(":/images/arrow_left_hover.png");
    prevMon->setPressPic(":/images/arrow_left_press.png");
    DImageButton *nextMon = new DImageButton;
    nextMon->setNormalPic(":/images/arrow_right_normal.png");
    nextMon->setHoverPic(":/images/arrow_right_hover.png");
    nextMon->setPressPic(":/images/arrow_right_press.png");

    QHBoxLayout *topCtrlLayout = new QHBoxLayout;
    topCtrlLayout->addWidget(prevYear);
    topCtrlLayout->addWidget(m_yearEdt);
    topCtrlLayout->addWidget(nextYear);
    topCtrlLayout->addWidget(prevMon);
    topCtrlLayout->addWidget(m_monEdt);
    topCtrlLayout->addWidget(nextMon);
    topCtrlLayout->addStretch();
    topCtrlLayout->addWidget(m_resetBtn);
    topCtrlLayout->setMargin(0);
    topCtrlLayout->setSpacing(0);

    m_topControlPanel = new QWidget;
    m_topControlPanel->setLayout(topCtrlLayout);

    m_solarLabel = new QLabel;
    m_lunarLabel = new QLabel;
    QHBoxLayout *solarLunarWidget = new QHBoxLayout;
    solarLunarWidget->addWidget(m_solarLabel);
    solarLunarWidget->addStretch();
    solarLunarWidget->addWidget(m_lunarLabel);
    solarLunarWidget->setSpacing(0);
    solarLunarWidget->setMargin(0);

    m_solarLunarWidget = new QWidget;
    m_solarLunarWidget->setLayout(solarLunarWidget);

    QHBoxLayout *viewsLayout = new QHBoxLayout;
    viewsLayout->addWidget(m_viewLeft);
    viewsLayout->addWidget(m_viewRight);
    viewsLayout->setMargin(0);
    viewsLayout->setSpacing(0);

    m_viewInnerWidget->setLayout(viewsLayout);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(m_topControlPanel);
    mainLayout->addWidget(m_solarLunarWidget);
    mainLayout->addWidget(m_detailLabel);
    mainLayout->addSpacing(10);
    mainLayout->addWidget(m_viewOuterWidget);

    connect(m_viewLeft, &CalendarView::dateSelected, this, &DCalendar::viewDateChanged, Qt::QueuedConnection);
    connect(m_viewRight, &CalendarView::dateSelected, this, &DCalendar::viewDateChanged, Qt::QueuedConnection);
    connect(m_resetBtn, &DLinkButton::clicked, [this] {selectDate(m_currentDate);});
    connect(prevYear, &DImageButton::clicked, [this] {selectDate(m_showDate.addYears(-1));});
    connect(prevMon, &DImageButton::clicked, [this] {selectDate(m_showDate.addMonths(-1));});
    connect(nextYear, &DImageButton::clicked, [this] {selectDate(m_showDate.addYears(1));});
    connect(nextMon, &DImageButton::clicked, [this] {selectDate(m_showDate.addMonths(1));});

    setDateInfoVisible(false);
    setCurrentDate(m_currentDate);
    setLayout(mainLayout);
}
Beispiel #13
0
void setOrderActualDeliveryDate(Order *orders, int pos) {
    setCurrentDate(&orders[pos].actualDeliveryDate);
}
Beispiel #14
0
void setOrderApprovalDate(Order *orders, int pos) {
    setCurrentDate(&orders[pos].approvalDate);
}
Beispiel #15
0
void setOrderDate(Order *orders, int pos){
    setCurrentDate(&orders[pos].orderDate);
}