bool ApplicationProperties::testWriteAccess (const bool testUserSettings, const bool testCommonSettings, const bool showWarningDialogOnFailure) { const bool userOk = (! testUserSettings) || getUserSettings()->save(); const bool commonOk = (! testCommonSettings) || getCommonSettings (false)->save(); if (! (userOk && commonOk)) { if (showWarningDialogOnFailure) { String filenames; if (userProps != nullptr && ! userOk) filenames << '\n' << userProps->getFile().getFullPathName(); if (commonProps != nullptr && ! commonOk) filenames << '\n' << commonProps->getFile().getFullPathName(); AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, options.applicationName + TRANS(" - Unable to save settings"), TRANS("An error occurred when trying to save the application's settings file...\n\nIn order to save and restore its settings, ") + options.applicationName + TRANS(" needs to be able to write to the following files:\n") + filenames + TRANS("\n\nMake sure that these files aren't read-only, and that the disk isn't full.")); } return false; } return true; }
Device::AddressSettings AddressBoolSettingsWidget::getSettings() const { auto settings = getCommonSettings(); settings.value.val = m_cb->currentData().toBool(); return settings; }
// -- the function below should be called one time per second void Ar_CAN_checkBusActivity(void) { if (_freeze_counter && _freeze_counter < CANBUS_FREEZE_THRESHOLD) { ++_freeze_counter; if (_freeze_counter < CANBUS_FREEZE_THRESHOLD) { // checking attempts threshold OUT_DEBUG_3("CAN Tx buffer freeze\r\n"); CREATE_UNIT_IDENT(u, OBJ_MASTERBOARD, getCommonSettings(NULL)->p_masterboard->uin, OBJ_CAN_CONTROLLER, 0x01); s32 ret = sendToMCU(&u, CMD_GetValue, 0, 0); if (ret < RETURN_NO_ERRORS) OUT_DEBUG_1("Ar_CAN_checkBusActivity(): sendToMCU() = %d error\r\n", ret); } else { s32 ret = reportToPult(0,0, PMC_CANBusFreeze, PMQ_NewMsgOrSetDisarmed); if (ret < RETURN_NO_ERRORS) { OUT_DEBUG_1("Ar_CAN_checkBusActivity(): reportToPult() = %d error\r\n", ret); return; } } } }
virtual AddressSettings getSettings() const override { auto settings = getCommonSettings(); settings.value = T(m_valueSBox->value()); settings.domain.min = T(m_minSBox->value()); settings.domain.max = T(m_maxSBox->value()); return settings; }
// -- handlers s32 handler_zone(ZoneEvent *event) { OUT_DEBUG_2("handler_zone() for %s\r\n", state_armed.state_name); CommonSettings *cs = getCommonSettings(NULL); Zone *pZone = event->p_zone; ArmingGroup *pGroup = getArmingGroupByID(pZone->group_id); // -- classify the event if (ZONE_EVENT_NORMAL == event->zone_event_type || ZONE_EVENT_DISABLED == event->zone_event_type) { Ar_System_setZoneAlarmedFlag(pZone, FALSE); batchSetETRLedIndicatorsLedState(pZone, UnitStateOff); // if (ZONE_ENTRY_DELAY == pZone->zone_type) { // if (pGroup->disarming_zoneDelay_counter > 0 && // pGroup->disarming_zoneDelay_counter < cs->entry_delay_sec) // { // ParentDevice *pPrev_ETR = getParentDeviceByID(pGroup->change_status_ETR->id, OBJ_ETR); // if(pPrev_ETR){ // ETR *pEtr = &pPrev_ETR->d.etr; // OUT_DEBUG_7("ENTRY zone normal\r\n"); // OUT_DEBUG_7("enter counter=%d \r\n", // pGroup->change_status_ETR->d.etr.buzzer.counter); // if(pPrev_ETR->d.etr.buzzer.counter>0) // --pPrev_ETR->d.etr.buzzer.counter; // OUT_DEBUG_7("enter counter=%d \r\n", // pGroup->change_status_ETR->d.etr.buzzer.counter); // } // } // } } else { Ar_System_setZoneAlarmedFlag(pZone, TRUE); batchSetETRLedIndicatorsLedState(pZone, UnitStateOn); } // -- perform predefined operations // -- process the reactions list processReactions(pZone->events[event->zone_event_type], &state_armed); OUT_DEBUG_7("ENTRY() 1\r\n"); // -- check that the zone is in delay or not if (isArmingDelayActive(event->p_zone)) { OUT_DEBUG_3("Zone %d is in delayed state now\r\n", event->p_zone->humanized_id); return RETURN_NO_ERRORS; } OUT_DEBUG_7("ENTRY() 2\r\n"); if (isDisarmingDelayActive(event->p_zone)) { OUT_DEBUG_3("Zone %d is in delayed state now\r\n", event->p_zone->humanized_id); return RETURN_NO_ERRORS; } OUT_DEBUG_7("ENTRY() 3\r\n"); if (ZONE_ENTRY_DELAY == pZone->zone_type) { OUT_DEBUG_7("ENTRY() \r\n"); OUT_DEBUG_7("AG =%d \r\n",pGroup->id); Ar_System_startEtrBuzzer(pGroup, 6, 4, 0, TRUE); Ar_System_setPrevETRLed(pGroup, UnitStateMultivibrator); } if (ZONE_ENTRY_DELAY != pZone->zone_type) { if (ZONE_WALK_THROUGH != pZone->zone_type ) { Ar_System_setBellState(UnitStateMultivibrator); } else if(pGroup->disarming_zoneDelay_counter == 0 && pGroup->arming_zoneDelay_counter == 0) { Ar_System_setBellState(UnitStateMultivibrator); } } OUT_DEBUG_3("Zone counter= %d \r\n", pGroup->arming_zoneDelay_counter); // -- create message for the pult PultMessage msg; if (1 /*pZone->bus_type == ZBT_SerialLine*/) { msg.identifier = pZone->humanized_id; msg.group_id = pZone->group_id; switch (event->zone_event_type) { case ZONE_EVENT_NORMAL: msg.msg_code = PMC_Burglary; msg.msg_qualifier = PMQ_RestoralOrSetArmed; break; case ZONE_EVENT_BREAK: if (ZONE_ENTRY_DELAY == pZone->zone_type) { // e.g. open door startDisarmingDelay(event->p_group, event->p_zone); msg.msg_code = PMC_UserOnPremise; } else { // all other zones msg.msg_code = PMC_Burglary; } msg.msg_qualifier = PMQ_NewMsgOrSetDisarmed; break; case ZONE_EVENT_SHORT: msg.msg_code = PMC_PollingLoop_Short; msg.msg_qualifier = PMQ_NewMsgOrSetDisarmed; break; case ZONE_EVENT_FITTING: msg.msg_code = PMC_PollingLoop_Fitting; msg.msg_qualifier = PMQ_NewMsgOrSetDisarmed; break; case ZONE_EVENT_DISABLED: OUT_DEBUG_3("Zone %d has been disabled. The message will not send.", msg.identifier); return RETURN_NO_ERRORS; default: msg.msg_code = (PultMessageCode)0; msg.msg_qualifier = (PultMessageQualifier)0; } } else if (0 /*pZone->bus_type == ZBT_ParallelLine*/) { // _TODO: describe the same for parallel protection loop } s32 ret = reportToPult(msg.identifier, msg.group_id, msg.msg_code, msg.msg_qualifier); if (ret < RETURN_NO_ERRORS) { OUT_DEBUG_1("reportToPult() = %d error\r\n", ret); return ret; } return RETURN_NO_ERRORS; }