void StoreDataVessel::calculate( const unsigned& current, MultiValue& myvals, std::vector<double>& buffer, std::vector<unsigned>& der_list ) const { if( myvals.get(0)>epsilon ){ storeValues( current, myvals, buffer ); if( !(getAction()->lowmem) && getAction()->derivativesAreRequired() ) storeDerivatives( current, myvals, buffer, der_list ); } return; }
bool StoreDataVessel::calculate(){ unsigned myelem = getAction()->getCurrentPositionInTaskList(); // Normalize vector if it is required finishTask( myelem ); // Store the values if( !hard_cut ){ storeValues( myelem ); // Store the derivatives if we are not using low memory if( !(getAction()->lowmem) && getAction()->derivativesAreRequired() ) storeDerivativesHighMem( myelem ); } else { if( getAction()->getElementValue(getAction()->getIndexOfWeight())>wtol ){ storeValues( myelem ); // Store the derivatives if we are not using low memory if( !(getAction()->lowmem) && getAction()->derivativesAreRequired() ) storeDerivativesHighMem( myelem ); } } return true; }
void QucsTranscalc::closeEvent(QCloseEvent *Event) { int tmp; tmp = x(); // call size and position function in order to ... tmp = y(); // ... set them correctly before closing the ... tmp = width(); // dialog !!! Otherwise the frame of the window ... tmp = height(); // will not be recognized (a X11 problem). storeValues (); Event->accept(); }
void NewProjectWizard::run() { do { if (!execute(PLACEMENT_OWNER)) { return; } } while (!check()); storeValues(); }
bool PersistantConfig::Serialize(QString filename) { QVariantMap values = storeValues(); QFile f(filename); if(f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) return SaveToJSON(values, f, JSON_ID, JSON_VER); qWarning() << "Couldn't write to " << filename << " " << f.errorString(); return false; }
bool PersistantConfig::Serialize(const rdcstr &filename) { if(!filename.isEmpty()) m_Filename = filename; QVariantMap values = storeValues(); QFile f(m_Filename); if(f.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) return SaveToJSON(values, f, JSON_ID, JSON_VER); qWarning() << "Couldn't write to " << QString(m_Filename) << " " << f.errorString(); return false; }
/* Switches to the current type of transmission line layout. */ void QucsTranscalc::setMode (int _mode) { // change necessary? if (mode == _mode) return; storeValues (); mode = _mode; setUpdatesEnabled(false); updateMode (); // update selection and results updateSelection (); updateResultItems (); slotAnalyze(); setUpdatesEnabled(true); repaint(); }
// Saves current transmission line values into the given file. bool QucsTranscalc::saveFile(QString fname) { QFile file (QDir::convertSeparators (fname)); if(!file.open (QIODevice::WriteOnly)) return false; // file not writable QTextStream stream (&file); // some lines of documentation stream << "# QucsTranscalc " << PACKAGE_VERSION << " " << fname << "\n"; stream << "# Generated on " << QDate::currentDate().toString() << " at " << QTime::currentTime().toString() << ".\n"; stream << "# It is not suggested to edit the file, use QucsTranscalc " << "instead.\n\n"; storeValues (); saveMode (stream); file.close (); return true; }
void PrintDialog::previewButtonClicked() { storeValues(); emit doPreview(); }
void PrintDialog::okButtonClicked() { storeValues(); accept(); }
int main(void) { // Alles TriState DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; // save power MCUCR |= _BV(JTD); PRR |= _BV(PRTWI) | _BV(PRSPI) | _BV(PRADC); //ADCSRA &= ~_BV(ADEN); //ACSR |=_BV(ACD); // Power Led DDRA|=_BV(7); PIN_SET(A,7); sei(); // Init: Subsysteme uart_init(UART_BAUD_SELECT(BAUD,F_CPU)); stella_init(); // curtain_init(); //sensors_init(); // Init: Variablen enum stateEnum { StateCommands, StateCurtainValue, StateLedChannel, StateLedValue } laststate, state = StateCommands; uint8_t slowdown_counter = 0; uint8_t slowdown_counter2 = 0; uint8_t panic_counter = 0; uint8_t panic_counter_led = 0; uint8_t panic_counter_brightness = 0; uint8_t stella_channel = 0; enum stella_set_function stella_fading = STELLA_SET_IMMEDIATELY; uint8_t packetPosition = 0; unsigned char lastChar, haslastChar = 0; slowdown_counter = 0; slowdown_counter2 = 0; stella_setValue(STELLA_SET_IMMEDIATELY, 0, 0); stella_process(); wdt_enable(WDTO_250MS); #define PANIC_THRESHOLD 150 // Hauptprogramm while (1) { wdt_reset(); stella_process(); curtain_process(); //sensors_process(); //panic counter if (++slowdown_counter == 0) { if (++slowdown_counter2==0) { if (panic_counter < PANIC_THRESHOLD) ++panic_counter; } if (panic_counter == PANIC_THRESHOLD) { panic_counter = PANIC_THRESHOLD+1; panic_counter_led = 0; panic_counter_brightness = 0; packetPosition = 0; storeValues(); PIN_SET(A,6); } if (panic_counter == PANIC_THRESHOLD+1) { if (panic_counter_brightness==255) { panic_counter=PANIC_THRESHOLD+2; continue; } stella_setValue(STELLA_SET_FADE, panic_counter_led, ++panic_counter_brightness); } if (panic_counter == PANIC_THRESHOLD+2) { if (panic_counter_brightness==0) { panic_counter=PANIC_THRESHOLD+1; if (++panic_counter_led >= STELLA_CHANNELS) panic_counter_led = 0; continue; } stella_setValue(STELLA_SET_FADE, panic_counter_led, --panic_counter_brightness); } } uint16_t r = uart_getc(); uint8_t info = r >> 8; if (r == UART_NO_DATA) continue; else if (info!=0) { PIN_SET(A,6); PIN_SET(A,7); packetPosition = 0; continue; } const unsigned char temp = haslastChar ? lastChar : 0; haslastChar = 1; lastChar = r & 0xff; if (lastChar == 0xff && temp == 0xff) { // two proceeding 255-values start a valid packet packetPosition = 1; state = StateCommands; continue; } if (!packetPosition) continue; // reset panic counter if (panic_counter) { if (panic_counter>=110) { restoreValues(); PIN_CLEAR(A,6); } panic_counter = 0; } laststate = state; switch (state) { case StateCommands: switch (lastChar) { case 0xef: // get values sendInit(); sendStella(); //sendSensor(); sendMotor(); break; case 0xdf: // prepare for a curtain value state = StateCurtainValue; break; case 0xcf: // prepare for a led channel and value (fade:immediately) state = StateLedChannel; stella_fading = STELLA_SET_IMMEDIATELY; break; case 0xbf: // prepare for a led channel and value (fade:fade) state = StateLedChannel; stella_fading = STELLA_SET_FADE; break; case 0xaf: // prepare for a led channel and value (fade:fade flashy) state = StateLedChannel; stella_fading = STELLA_SET_FLASHY; break; case 0x9f: // prepare for a led channel and value (fade:fade immediately+relative) state = StateLedChannel; stella_fading = STELLA_SET_IMMEDIATELY_RELATIVE; break; case 0x00: // reset panic counter and acknowdlegde sendAck(); break; } break; case StateCurtainValue: state = StateCommands; curtain_setPosition(lastChar); break; case StateLedChannel: state = StateLedValue; stella_channel = lastChar; break; case StateLedValue: state = StateCommands; stella_setValue(stella_fading, stella_channel, lastChar); break; } // the state has not changed -> a full packet has been received -> prepare for the next one if (laststate==state) { packetPosition=0; } } return 0; }