Esempio n. 1
0
void ICACHE_FLASH_ATTR processPump(void) { // Every 100mS
	updatePressure();
	checkLevel();
	switch (pumpState()) {
	case MANUAL_OFF:
		easygpio_outputSet(PUMP, 0);
		pumpOnCount = 0;
		checkNotFlowing();
		break;
	case MANUAL_ON:
		if (secondsNotFlowing() > 30) {
			pumpState_OffManual();
			easygpio_outputSet(PUMP, 0);
			sounderAlarm(3); // No flow for 30S in Manual
		} else {
			easygpio_outputSet(PUMP, 1);
		}
		break;
	case AUTO_OFF:
		if (getCurrentPressure() < sysCfg.settings[SET_PUMP_ON]) {
			startCheckIsFlowing();
			pumpState_OnAuto();
			easygpio_outputSet(PUMP, 1);
		} else {
			easygpio_outputSet(PUMP, 0);
			pumpOnCount = 0;
			checkNotFlowing();
		}
		sounderClear();
		break;
	case AUTO_ON:
		if (getCurrentPressure() > sysCfg.settings[SET_PUMP_OFF]) {
			pumpState_OffAuto();
			easygpio_outputSet(PUMP, 0);
		} else {
			if (secondsNotFlowing() > sysCfg.settings[SET_NO_FLOW_AUTO_ERROR]) {
				publishAlarm(1, flowAverageReading()); // No flow for SET_NO_FLOW_AUTO_ERROR (10S) in Auto
				sounderAlarm(1);
				publishAlarm(6, secondsNotFlowing()); // No flow for SET_NO_FLOW_AUTO_ERROR (10S) in Auto
				pumpState_OffManual();
			} else {
				pumpOnCount++;
				if (pumpOnCount >= sysCfg.settings[SET_MAX_PUMP_ON_WARNING]
						&& getCurrentPressure() < sysCfg.settings[SET_LOW_PRESSURE_WARNING]) {
					publishError(3, getCurrentPressure()); // Low pressure and Pump On > SET_MAX_PUMP_ON_WARNING
				}
				if (pumpOnCount >= sysCfg.settings[SET_MAX_PUMP_ON_WARNING]) { // 1 minute
					publishError(1, sysCfg.settings[SET_MAX_PUMP_ON_WARNING]);
				} else if (pumpOnCount == sysCfg.settings[SET_MAX_PUMP_ON_ERROR]) { // 5 minutes
					publishAlarm(2, pumpOnCount); // Running for SET_MAX_PUMP_ON_ERROR (5 Minutes) in Auto
					sounderAlarm(2);
				} else if (pumpOnCount > sysCfg.settings[SET_MAX_PUMP_ON_ERROR]) {
					pumpOnCount = sysCfg.settings[SET_MAX_PUMP_ON_ERROR] + 1;
				}
			}
		}
		break;
	}
}
Esempio n. 2
0
void ICACHE_FLASH_ATTR checkSetOutput(uint8 op, bool newSetting) {
	if (op < OUTPUTS) {
		if (currentOutputs[op] != newSetting) {
			publishOutput(op, newSetting);
			currentOutputs[op] = newSetting;
		}
		switch (outputOverrides[op]) {
		case OR_NOT_SET: easygpio_outputSet(PUMP, !newSetting); break;
		case OR_OFF: easygpio_outputSet(PUMP, true); break;
		case OR_ON: easygpio_outputSet(PUMP, false); break;
		}
		return;
	}
	publishError(92, op); // Invalid Output ID
	return;
}
Esempio n. 3
0
bool ICACHE_FLASH_ATTR checkPirActive(enum pir_t actionPir) {
	enum pir_t pir;

	for (pir = PIR1; pir <= PIR2; pir++) {
		if (pirState(pir)) {
			setPirFanActive(pir);
			setPirLightActive(pir);
		}
	}
	switch (actionPir) {
	case PIR1:
	case PIR2:
		return pirFanStatus[actionPir];
	}
	publishError(2, actionPir);
	return false;
}
PublishDialog::PublishDialog(QWidget *parent)
	: MoodBoxDialog(parent), publishRequestId(0), publishRecipientId(-1), loginsLoaded(false)
{
	TimeMeasure t("PublishDialog");

	setupUi(this);

	t.showTimePassedAfterSetupUi();

	UiTools::moveWindowToScreenCenter(this);

	typeCombo->addItem(tr(PUBLISHING_TYPE_LIVEJOURNAL_TEXT));
#ifdef RUSSIAN_VERSION
	typeCombo->addItem(tr(PUBLISHING_TYPE_LIVEINTERNET_TEXT));
	typeCombo->addItem(tr(PUBLISHING_TYPE_DAIRY_TEXT));
#endif

	restorePublishParameters();

	// Control signals
	connect(closeToolButton, SIGNAL(clicked()), this, SLOT(reject()));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
	connect(cancelPublishingButton, SIGNAL(clicked()), this, SLOT(reject()));
	connect(closeButton, SIGNAL(clicked()), this, SLOT(accept()));

	connect(moodstripNameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(publishEnabled()));
	connect(typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(loadPublishingParameters(int)));

	// Publishing signals
	connect(MESSAGEMANAGER, SIGNAL(publishing(qint32, qint32)), this, SLOT(onPublishProgress(qint32, qint32)));
	connect(MESSAGEMANAGER, SIGNAL(publishCompleted(qint32, qint32, const QList<PublishingWay> &)),
		this, SLOT(onPublishCompleted(qint32, qint32, const QList<PublishingWay> &)));
	connect(MESSAGEMANAGER, SIGNAL(publishError(qint32)), this, SLOT(onPublishError(qint32)));

	// Update values
	on_blogCheckBox_stateChanged(blogCheckBox->checkState());
	openOptionsPage();
}