void Aquaduino::initNetwork() { int8_t status = 0; m_MAC[0] = 0xDE; m_MAC[1] = 0xAD; m_MAC[2] = 0xBE; m_MAC[3] = 0xEF; m_MAC[4] = 0xDE; m_MAC[5] = 0xAD; if (m_DHCP) { Serial.println(F("Waiting for DHCP reply...")); status = Ethernet.begin(m_MAC); } if (!m_DHCP || !status) { Serial.println(F("Using static network configuration...")); Ethernet.begin(m_MAC, m_IP, m_DNSServer, m_Gateway, m_Netmask); } m_IP = Ethernet.localIP(); m_DNSServer = Ethernet.dnsServerIP(); m_Gateway = Ethernet.gatewayIP(); m_Netmask = Ethernet.subnetMask(); Serial.print(F("IP: ")); Serial.println(m_IP); Serial.print(F("Netmask: ")); Serial.println(m_Netmask); Serial.print(F("Gateway: ")); Serial.println(m_Gateway); Serial.print(F("DNS Server: ")); Serial.println(m_DNSServer); Serial.print(F("NTP Server: ")); Serial.println(m_NTPServer); //Init Time. If NTP Sync fails this will be used. setTime(0, 0, 0, 1, 1, 2013); if (isNTPEnabled()) { Serial.println(F("Syncing time using NTP...")); enableNTP(); } m_GUIServer = new GUIServer(4242); }
void *WeatherPlugin::processEvent(Event *e) { if (e->type() == EventLanguageChanged) updateButton(); if (e->type() == EventInit) showBar(); if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->id == CmdWeather) && *getID()){ string url = "http://www.weather.com/outlook/travel/pastweather/"; url += getID(); Event eGo(EventGoURL, (void*)url.c_str()); eGo.process(); return e->param(); } } if (e->type() == EventFetchDone){ fetchData *d = (fetchData*)(e->param()); if (d->req_id != m_fetch_id) return NULL; m_fetch_id = 0; if (d->result != 200) return NULL; m_data = ""; m_day = 0; m_bBar = false; m_bWind = false; m_bUv = false; m_bCC = false; m_context = xmlCreatePushParserCtxt(&m_handler, this, "", 0, ""); if (xmlParseChunk(m_context, d->data->data(), d->data->size(), 0)){ log(L_WARN, "XML parse error"); xmlFreeParserCtxt(m_context); return NULL; } xmlFreeParserCtxt(m_context); time_t now; time(&now); setTime(now); updateButton(); Event eUpdate(EventWeather); eUpdate.process(); } return NULL; }
int * put_1_svc(struct clientData *argp, struct svc_req *rqstp) { int *result = (int *)malloc(sizeof(int)); if (result == NULL) { perror("Error: Result failed."); int n; result = &n; } *result = -1; setTime(); printf("[%s]\n A put request is received %d.\n", currTime, argp->id); fflush(stdout); if (index1 < Limit){ int CID = -1; for (int i = 0; i < 3; i++) { if (clientList[i] == argp->id){ CID = i; break; } } if (strcpy(client_msgs[index1].message, argp->message) != NULL){ client_msgs[index1].id = argp->id; client_msg_ids[index1] = argp->id; if (CID == -1){ clientList[numClient] = argp->id; numClient += 1; } index1 += 1; *result = 0; } else { perror("Error: Putting message Failure."); } } return result; }
Bitmap& Movie::bitmap() { if (m_currentTime == -1) setTime(0); if (m_needBitmap) { m_needBitmap = false; if (!internalBitmap(m_bitmap)) { BitmapLock bmp(m_bitmap); if (bmp.locked()) bmp.reset(); } } return m_bitmap; }
void main ( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer setTime( 0x12, 0, 0, 0); // initialize time to 12:00:00 AM P1DIR |= 0x01; // Set P1.0 to output direction CCR0 = 32768-1; TACTL = TASSEL_1+MC_1; // ACLK, upmode CCTL0 |= CCIE; // enable CCRO interrupt _EINT(); while( 1 ) { LPM3; // enter LPM3, clock will be updated P1OUT ^= 0x01; // do any other needed items in loop _NOP(); // set breakpoint here to see 1 second interrupt } }
void Mode0Irq::mode3CyclesChange() { unsigned long nextTime = lyCounter.time() - lyCounter.lineTime(); unsigned nextLy = lyCounter.ly(); if (time() > lyCounter.time()) { nextTime += lyCounter.lineTime(); ++nextLy; if (nextLy > 143) { nextTime += lyCounter.lineTime() * (154 - nextLy); nextLy = 0; } } nextTime += (baseCycle(lyCounter.isDoubleSpeed()) + m3ExtraCycles(nextLy)) << lyCounter.isDoubleSpeed(); setTime(nextTime); }
void MainWindow::resetTimeSlider() { if(dataSet_ != NULL) { timeSlider_->setMinimum(0); timeSlider_->setMaximum(dataSet_->getNumTimes() - 1); if(time_ >= dataSet_->getNumTimes()) { setTime(0); } } else { timeSlider_->setMinimum(0); timeSlider_->setMaximum(0); } }
NxCursor::NxCursor(NxObjectFactoryInterface *parent, QTreeWidgetItem *ccParentItem, UiRenderOptions *_renderOptions) : NxObject(parent, ccParentItem, _renderOptions) { glListCursor = glGenLists(1); curve = 0; setTimeLocal(0); nextTimeOld = 0; timeOld = 0; time = 0; timeLocal = 0; timeLocalOld = 0; timeLocalAbsolute = 0; previousCursorReliable = false; previousPreviousCursorReliable = false; cursorAngleCacheSinZ = cursorAngleCacheCosZ = cursorAngleCacheSinY = cursorAngleCacheCosY = 0; cursorPoly = NxPolygon(4); cursorPoly[0] = NxPoint(); cursorPoly[1] = NxPoint(); cursorPoly[2] = NxPoint(); cursorPoly[3] = NxPoint(); cursorPolyOld = NxPolygon(4); cursorPolyOld[0] = NxPoint(); cursorPolyOld[1] = NxPoint(); cursorPolyOld[2] = NxPoint(); cursorPolyOld[3] = NxPoint(); setNbLoop(0); setStart("1 0"); setTimeFactor(1); setTimeFactorF(1); setWidth(1); setDepth(0); setTime(0); setSize(1.2); setLineFactor(1); setLineStipple(0xFFFF); setColorActive("cursor_active"); setColorInactive("cursor_inactive"); setTimeStartOffset(0); setTimeEndOffset(0); setTimeInitialOffset(0); setEasing(0); setBoundsSource("-10 10 -10 10 -10 10"); setBoundsTarget("0 1 0 1 0 1"); boundsSourceIsBoundingRect = true; }
bool QCamQHY5::updateFrame() { // get the frame buffer void* YBuff=NULL; YBuff=inputBuffer_.YforOverwrite(); // read picture datas if(camera->read((unsigned char*)YBuff,shootMode_,denoise_)) { setTime(); camera->configure(xstart_,ystart_,width_,height_,gainG1_,gainB_,gainR_,gainG2_,&width_,&height_); // count the usb transfer time. Rate is 24M pixels / second shootMode_=(frameExposure_<1000); int poseTime=frameExposure_-(1558*(height_+26)/PIXEL_RATE); if(poseTime<0) poseTime=0; camera->shoot(poseTime,shootMode_); shooting_=TRUE; // gives a new shot for the timer timer_->setSingleShot(true); timer_->start(frameExposure_); // set the output frame if((targetWidth_==1280)&&(targetHeight_==1024)) { // nothing to resize yuvBuffer_=inputBuffer_; } else { switch(croppingMode) { case SCALING : yuvBuffer_.scaling(inputBuffer_,targetWidth_,targetHeight_); break; case CROPPING : // cropping allready done by driver yuvBuffer_=inputBuffer_; break; case BINNING : yuvBuffer_.binning(inputBuffer_,targetWidth_,targetHeight_); break; } } // publish the frame newFrameAvaible(); // update progress bar if needed if(frameExposure_>(3*PROGRESS_TIME)) { progressBar->reset(); progress_=0; } } }
void dtg::setDtg( time_t cttime ) { struct tm * tms = localtime( &cttime ); // NB static data area! if ( tms->tm_isdst != 0 ) tms->tm_hour -= 1; std::string curTime; std::string curDate; curTime = ( boost::format( "%02.2d:%02.2d:%02.2d" ) % tms->tm_hour % tms->tm_min % tms->tm_sec ).str(); int year = tms->tm_year; while ( year > 99 ) year -= 100; // take it back to two chars curDate = ( boost::format( "%02.2d/%02.2d/%02.2d" ) % tms->tm_mday % ( tms->tm_mon + 1 ) % year ).str(); setTime( curTime, DTGDISP ); setDate( curDate, DTGDISP ); }
void Wait::loadData(const QVariantMap & data, bool internal) { if (!internal) Action::loadData(data, internal); if (data.contains("time") && data.value("time").canConvert(QVariant::Double)) setTime(data.value("time").toDouble()); if (data.contains("waitType") && data.value("waitType").type() == QVariant::String) { QString type = data.value("waitType").toString(); if (type == "Timed") setWaitType(Wait::Timed); else if (type == "Forever") setWaitType(Wait::Forever); else setWaitType(Wait::MouseClick); } }
time_t now(){ while( millis() - prevMillis >= 1000){ sysTime++; prevMillis += 1000; #ifdef TIME_DRIFT_INFO sysUnsyncedTime++; // this can be compared to the synced time to measure long term drift #endif } if(nextSyncTime <= sysTime){ if(getTimePtr != 0){ time_t t = getTimePtr(); if( t != 0) setTime(t); else Status = (Status == timeNotSet) ? timeNotSet : timeNeedsSync; } } return sysTime; }
void DigitalTube::invoke(long command){ if(isDigital(command)){ setTime(getDigital(command)); return; } if(command==KEY_BACK){ leftMove(); return; } if(command==KEY_FORWARD){ rightMove(); return; } if(command==KEY_PLAY){ startTimer(); return; } }
void testMissingParam(CuTest *tc) { // The 3 parameters are required, so we should get an HTTP error if they are missing struct Request req = {"GET", "/query", NULL, NULL}; time_t now = makeTs("2009-11-08 10:00:00"); setTime(now); int tmpFd = makeTmpFile(); processQueryRequest(tmpFd, &req); char* result = readTmpFile(); CuAssertStrEquals(tc, "HTTP/1.0 500 Bad/missing parameter" HTTP_EOL "Server: BitMeterOS " VERSION " Web Server" HTTP_EOL "Date: Sun, 08 Nov 2009 10:00:00 +0000" HTTP_EOL "Connection: Close" HTTP_EOL HTTP_EOL , result); }
void startRec() { if(RecFlag == 0) { setWindow(window,"mohnish/gb-drum-kit record1.jpg"); printf("%d-Tempo \n",Tempo); setTempo(Tempo); setTime(4,4); openOutput(SongName,0,0); RecFlag = 1; PlayFlag = 1; } else { closeOutput(); setWindow(window,"mohnish/gb-drum-kit changed1.jpg"); RecFlag = 0; } }
void Validity::hideTime(bool hide) { if (hide) { QString format; if (!endDate) format = QTime(0,0,0).toString(formatDate); else format = QTime(23,59,59).toString(formatDate); if (!midnight && endDate) setDateTime(dateTime().addDays(-1)); midnight = true; setDisplayFormat(format); } else { setDisplayFormat(formatDate); if (midnight && endDate) setDateTime(dateTime().addDays(1)); midnight = false; setTime(mytime); } }
void AutoDragger::autoDrag(DisplayElement *dragElement, const Common::Point &startPoint, const Common::Point &stopPoint, TimeValue dragTime, TimeScale dragScale) { _draggingElement = dragElement; if (_draggingElement) { _startLocation = startPoint; _stopLocation = stopPoint; _lastTime = 0; _done = false; _draggingElement->moveElementTo(_startLocation.x, _startLocation.y); setScale(dragScale); setSegment(0, dragTime); setTime(0); scheduleCallBack(kTriggerAtStop, 0, 0); startIdling(); start(); } else { stopDragging(); } }
int * get_1_svc(int *argp, struct svc_req *rqstp) { int *result = (int *)malloc(sizeof(int)); if (result == NULL) { perror("Error: Result failed."); int n; result = &n; } *result = -1; setTime(); printf("[%s]\n A Get:%d request received from client.\n", currTime, *argp); fflush(stdout); int CID = -1; // RCID: real client id int RCID = *argp; for (int i = 0; i < 3; i++) { if (clientList[i] == RCID){ CID = i; break; } } for (i = 0; i < Limit; i++){ if (i > clientIndex[CID] && CID >= 0 && CID <= 2 ){ if (client_msg_ids[i] >= 0 && client_msg_ids[i] != RCID ){ *result = 0; clientIndex[CID] = i; return result; } } } return result; }
int NTPClient::receive() { int nbyte = m_udp->parsePacket(); if (nbyte > 0) { // We've received a packet, read the data from it m_udp->read(m_packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer //the timestamp starts at byte 40 of the received packet and is four bytes, // or two words, long. First, esxtract the two words: unsigned long highWord = word(m_packetBuffer[40], m_packetBuffer[41]); unsigned long lowWord = word(m_packetBuffer[42], m_packetBuffer[43]); /* DEBUG */ unsigned long secsSince1900 = highWord << 16 | lowWord; // now convert NTP time into everyday time: // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: const unsigned long seventyYears = 2208988800UL; // subtract seventy years: unsigned long epoch = secsSince1900 - seventyYears; // combine the four bytes (two words) into a long integer // this is NTP time (seconds since Jan 1 1900): time_t ntptime = highWord << 16 | lowWord; // now convert NTP time into everyday time: // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: // const unsigned long seventyYears = 2208988800UL; // subtract seventy years: ntptime -= seventyYears; setTime(ntptime); } else { return 0; } return 1; }
bool CalAnimationAction::execute(float delayIn, float delayOut, float weightTarget, bool autoLock) { // You cannot execute a manual action. if( m_sequencingMode == SequencingModeManual ) { return false; } setState(STATE_IN); setWeight(0.0f); m_delayIn = delayIn; m_delayOut = delayOut; setTime(0.0f); m_weightTarget = weightTarget; m_autoLock = autoLock; m_sequencingMode = SequencingModeAutomatic; m_manualOn = false; // Irrelevant since not manual. m_rampValue = 1.0; m_compositionFunction = CompositionFunctionNull; // Initially NULL so we can recognize when it changes. return true; }
//Function to calculate the time elapsed void TimeClock::calcTimeElapsed(int start, int end) { int tempHours; //Temporary variable to hold the difference in time int tempMinutes; //Temporary stores the minutes int tempTime; //Time to be passed to the setTime function int stHours; //Starting hours int enHours; //Ending hours int stMinutes; //Starting Minutes int enMinutes; //Ending minutes //Separating hours from minutes stHours = start/100; enHours = end/100; stMinutes = start % 100; enMinutes = end % 100; //Calculating difference between hours if(stHours <= enHours) tempHours = enHours - stHours; else if(stHours > enHours) tempHours = (24 - stHours) + enHours; //Calculating difference between minutes if(stMinutes <= enMinutes) tempMinutes = enMinutes - stMinutes; else if(stMinutes > enMinutes) { tempMinutes = (60 - stMinutes) + enMinutes; tempHours -= 1; } //Putting difference in minutes and hours together tempTime = (tempHours * 100) + tempMinutes; //Function from the MilTime class setTime(tempTime, 0); }
MEvent::MEvent(unsigned tick, int port, int channel, const Event& e, MidiTrack* trk) { m_track = trk; m_source = SystemSource; setChannel(channel); setTime(tick); setPort(port); setLoopNum(0); switch (e.type()) { case Note: setType(ME_NOTEON); setA(e.dataA()); setB(e.dataB()); break; case Controller: setType(ME_CONTROLLER); setA(e.dataA()); // controller number setB(e.dataB()); // controller value break; case PAfter: setType(ME_POLYAFTER); setA(e.dataA()); setB(e.dataB()); break; case CAfter: setType(ME_AFTERTOUCH); setA(e.dataA()); setB(0); break; case Sysex: setType(ME_SYSEX); setData(e.eventData()); break; default: printf("MEvent::MEvent(): event type %d not implemented\n", type()); break; } }
void setTimeUsingTimeServer() { unsigned long epoch; int numberOfTries = 0, maxTries = 6; do { epoch = readLinuxEpochUsingNTP(); numberOfTries++; } while ((epoch == 0) || (numberOfTries > maxTries)); if (numberOfTries > maxTries) { Serial.print("NTP unreachable!!"); while (1); } else { Serial.print("Epoch received: "); Serial.println(epoch); setTime( epoch ); Serial.println(); } }
void TimeSyncComponent::processSyncMessage() { // if time sync available from serial port, update time and return true while(Serial.available() >= TIME_MSG_LEN ){ // time message consists of a header and ten ascii digits char c = Serial.read() ; Serial.print(c); if( c == TIME_HEADER ) { time_t pctime = 0; for(int i=0; i < TIME_MSG_LEN -1; i++){ c = Serial.read(); if( c >= '0' && c <= '9'){ pctime = (10 * pctime) + (c - '0') ; // convert digits to a number } Serial.println("Time received, thx!"); printTime(); } else if (c == TIME_PRINT_REQUEST) { printTime(); } setTime(pctime); // Sync Arduino clock to the time received on the serial port }
void longPressA() { switch(fsmState) { case EDIT_TIME_MODE: int h; int m; h = digitValues[0]*10 + digitValues[1]; m = digitValues[2]*10 + digitValues[3]; setTime(h, m, 0, 1, 1, 2016); RTC.set(now()); fsmState = SHOW_TIME_MODE; break; case EDIT_ALARM_MODE: if (isRtcAlarmOn()) { disableRtcAlarm(); for (int i = 0; i < N; i++) display.disableDecimalPoint(i); } else { enableRtcAlarm(); for (int i = 0; i < N; i++) display.enableDecimalPoint(i); } break; case SHOW_TIME_MODE: case SHOW_TEMP_MODE: fsmState = EDIT_TIME_MODE; break; case SHOW_ALARM_MODE: stopAlarmCallback(); break; } }
VESPERSTimeScanConfiguration::VESPERSTimeScanConfiguration(QObject *parent) : AMTimedRegionScanConfiguration(parent), VESPERSScanConfiguration() { setName("Timed Scan"); setUserScanName("Timed Scan"); dbObject_->setParent(this); setIncomingChoice(VESPERS::Imini); setFluorescenceDetector(VESPERS::SingleElement); setCCDDetector(VESPERS::NoCCD); setCCDFileName(""); setExportSpectraSources(true); setExportSpectraInRows(true); setTime(1); setTimePerAcquisition(10); setIterations(1); computeTotalTime(); connect(this, SIGNAL(timeChanged(double)), this, SLOT(computeTotalTime())); connect(this, SIGNAL(timePerAcquisitionChanged(double)), this, SLOT(computeTotalTime())); connect(this, SIGNAL(iterationsChanged(int)), this, SLOT(computeTotalTime())); connect(dbObject_, SIGNAL(ccdDetectorChanged(int)), this, SLOT(computeTotalTime())); }
int NTPClient::setSystemTime() { //the timestamp starts at byte 40 of the received packet and is four bytes, // or two words, long. First, esxtract the two words: unsigned long highWord = word(m_packetBuffer[40], m_packetBuffer[41]); unsigned long lowWord = word(m_packetBuffer[42], m_packetBuffer[43]); // combine the four bytes (two words) into a long integer // this is NTP time (seconds since Jan 1 1900): time_t ntptime = highWord << 16 | lowWord; // now convert NTP time into everyday time: // Unix time starts on Jan 1 1970. In seconds, that's 2208988800: const unsigned long seventyYears = 2208988800UL; // subtract seventy years: ntptime -= seventyYears; setTime(ntptime); return 1; }
File& Directory :: cd( File& other ) { //if this is not a directory if(other.isDir() == false) cerr << "This is not a directory" << endl; //change the directory else { Directory * temp; temp = dynamic_cast<Directory *> (&other); setName(other.getName()); setOwner(other.getOwner()); setSize(other.getSize()); setTime(other.getTime()); files = temp->files; } return *this; }
arlCore::Point::Point( unsigned int dim, ARLCORE_POINT_TYPE type, long int date, long int time ): Object(ARLCORE_CLASS_POINT), m_type(type), m_confidence(0), m_visibility(true), m_status(ARLCORE_POINT_STATUS_UNKNOWN), m_scalar(-1.0), m_isColored(false), m_colour(0,0,0), m_ponderation(1.0), m_error(-1.0) { unsigned int i; setOK(true); setTime(date,time); m_coordinates.set_size(dim); m_coordinates.fill(0.0); m_stat.resize(size()); for( i=0 ; i<size() ; ++i ) m_stat[i].fill(0.0); initUncertainty(); }
bool QTimeEdit::qt_property( int id, int f, QVariant* v) { switch ( id - staticMetaObject()->propertyOffset() ) { case 0: switch( f ) { case 0: setTime(v->asTime()); break; case 1: *v = QVariant( this->time() ); break; case 3: case 4: case 5: break; default: return FALSE; } break; case 1: switch( f ) { case 0: setAutoAdvance(v->asBool()); break; case 1: *v = QVariant( this->autoAdvance(), 0 ); break; case 3: case 4: case 5: break; default: return FALSE; } break; case 2: switch( f ) { case 0: setMaxValue(v->asTime()); break; case 1: *v = QVariant( this->maxValue() ); break; case 3: case 4: case 5: break; default: return FALSE; } break; case 3: switch( f ) { case 0: setMinValue(v->asTime()); break; case 1: *v = QVariant( this->minValue() ); break; case 3: case 4: case 5: break; default: return FALSE; } break; case 4: switch( f ) { case 0: setDisplay(v->asUInt()); break; case 1: *v = QVariant( (int)this->display() ); break; case 3: case 4: case 5: break; default: return FALSE; } break; default: return QDateTimeEditBase::qt_property( id, f, v ); } return TRUE; }