void store_rel_data() { clear_data_buffer(); if (data_available == TRUE) { strcat(data_buffer, time_stmp_str); strcat(data_buffer, comma); strcat(data_buffer, chem); strcat(data_buffer, comma); strcat(data_buffer, abs_str); strcat(data_buffer, comma); strcat(data_buffer, coeff_str); strcat(data_buffer, comma); strcat(data_buffer, real_str); if (nv_report_mode == 4) fprintf(COM_A, "%s\r\n", data_buffer); if(sd_status==0){ buffer_select = 0; heartbeat(FALSE); append_data(file_ptr_rel_all); heartbeat(TRUE); heartbeat(FALSE); append_data(file_ptr_rel_new); heartbeat(TRUE); } } }
void store_aws_data(int8 macro, int16 mmacro_var) { char comma[2] = {',' , '\0'}; char endofline[3] = {'\r' , '\n' , '\0'}; char config_str[30]; clear_data_buffer(); time_stamp(); strcat(data_buffer, time_stmp_str); strcat(data_buffer, comma); sprintf(config_str, "%u,%Lu",macro,mmacro_var); strcat(data_buffer, config_str); strcat(data_buffer, endofline); if (nv_report_mode == 4) fprintf(COM_A, "%s\r\n", data_buffer); if(sd_status==0){ buffer_select = 0; heartbeat(FALSE); append_data(file_ptr_raw_all); heartbeat(TRUE); heartbeat(FALSE); append_data(file_ptr_raw_new); heartbeat(TRUE); } }
void store_wms_data(int8 macro) { char comma[2] = {',' , '\0'}; char endofline[3] = {'\r' , '\n' , '\0'}; char config_str[30]; clear_data_buffer(); time_stamp(); strcat(data_buffer, time_stmp_str); strcat(data_buffer, comma); sprintf(config_str, "%u,%Lu,%Lu,%Lu,%Lu,%Lu,%Lu,%Ld", macro,nv_macro_mode, nv_interval, nv_volume, nv_port, nv_sample, e_target_port[0],m_lin_pos[1]); // changed from e_port[0] strcat(data_buffer, config_str); strcat(data_buffer, endofline); fprintf(COM_A, "%s\r\n", data_buffer); if(sd_status==0){ buffer_select = 0; heartbeat(FALSE); append_data(file_ptr_raw_all); heartbeat(TRUE); heartbeat(FALSE); append_data(file_ptr_raw_new); heartbeat(TRUE); } }
int16 probe_read(int8 store, int8 display){ // get detector reading and write to a file on the SD card // the string to be stored is compiled into "data_buffer" // first the data_buffer is cleared // then time_stamp_str, flags, results & end-of-line are concatenated // append_data writes "data_buffer" to the file "all" and "new" files char comma[2] = {',' , '\0'}; char endofline[3] = {'\r' , '\n' , '\0'}; char tempstr[4] = {'T','m','p','\0'}; int16 temp = 0; clear_slave_reply(); clear_data_buffer(); time_stamp(); strcat(data_buffer, time_stmp_str); strcat(data_buffer, comma); strcat(data_buffer, tempstr); strcat(data_buffer, comma); //*** READ TEMP PROBE ***// temp=temp_probe(); //*** PUT INTO slave_reply ***// //itoa(temp,10,slave_reply); sprintf (slave_reply, "%05.3w",temp); strcat(slave_reply, endofline); strcat(data_buffer, slave_reply); if (nv_report_mode == 0 && display == TRUE) fprintf(COM_A, "%s", data_buffer); else if (nv_report_mode >= 4) fprintf(COM_A, "%s", data_buffer); if (store == TRUE && sd_status==0) { buffer_select = 0; heartbeat(FALSE); append_data(file_ptr_raw_all); heartbeat(TRUE); heartbeat(FALSE); append_data(file_ptr_raw_new); heartbeat(TRUE); } macro_flag = 900; return (temp); }
void record_event() { if(sd_status==0){ strcopy(event_buffer,""); time_stamp(); strcat(event_buffer, time_stmp_str); strcat(event_buffer, event_str); buffer_select = 1; heartbeat(FALSE); append_data(file_ptr_events); heartbeat(TRUE); } }
void write() { unsigned long now = millis(); heartbeat(now); readNativeSensors(now); }
void loop() { if (Serial) { if (!serialConnected) { serialConnected = true; DEBUG_PRINT(F("LongName: ")); DEBUG_PRINTLN(BleLongName); } } else { if (serialConnected) serialConnected = false; } // poll peripheral blePeripheral.poll(); if (valueCharacteristic.subscribed()) { int sensorValue = 0; if (pin_type == ANALOG) { sensorValue = analogRead(pin); } else if (pin_type == DIGITAL) { sensorValue = digitalRead(pin); } else { sensorValue = 666; } send_data(valueCharacteristic, millis(), sensorValue); } #ifdef GOOSCI_DEVELOPER_MODE heartbeat(); #endif }
static int message_handler(struct skynet_context * ctx, void *ud, int type, int session, uint32_t source, const void * msg, size_t sz) { struct package *P = ud; switch (type) { case PTYPE_TEXT: command(ctx, P, session, source, msg, sz); break; case PTYPE_CLIENT: send_out(ctx, P, msg, sz); break; case PTYPE_RESPONSE: // It's timer heartbeat(ctx, P); break; case PTYPE_SOCKET: socket_message(ctx, P, msg); break; case PTYPE_ERROR: // ignore error break; default: if (session > 0) { // unsupport type, raise error skynet_send(ctx, 0, source, PTYPE_ERROR, session, NULL, 0); } break; } return 0; }
void tst_set_timeout(int timeout) { char *mul = getenv("LTP_TIMEOUT_MUL"); if (timeout == -1) { tst_res(TINFO, "Timeout per run is disabled"); return; } results->timeout = timeout; if (mul) { float m = atof(mul); if (m < 1) tst_brk(TBROK, "Invalid timeout multiplier '%s'", mul); results->timeout = results->timeout * m + 0.5; } tst_res(TINFO, "Timeout per run is %uh %02um %02us", results->timeout/3600, (results->timeout%3600)/60, results->timeout % 60); if (getpid() == lib_pid) alarm(results->timeout); else heartbeat(); }
void QDSActionPrivate::connectToChannel() { // Connect slots to response messages if ( mResponseChannel == 0 ) { mResponseChannel = new QtopiaIpcAdaptor( responseChannel() ); QtopiaIpcAdaptor::connect( mResponseChannel, MESSAGE( heartbeat() ), this, SLOT(heartbeatSlot()), QtopiaIpcAdaptor::SenderIsChannel ); QtopiaIpcAdaptor::connect( mResponseChannel, MESSAGE( response() ), this, SLOT(responseSlot()), QtopiaIpcAdaptor::SenderIsChannel ); QtopiaIpcAdaptor::connect( mResponseChannel, MESSAGE( response( const QDSData& ) ), this, SLOT(responseSlot(QDSData)), QtopiaIpcAdaptor::SenderIsChannel ); QtopiaIpcAdaptor::connect( mResponseChannel, MESSAGE( error( const QString& ) ), this, SLOT(errorSlot(QString)), QtopiaIpcAdaptor::SenderIsChannel ); }
int main(int argc, char** argv) { ros::init(argc, argv, "heartbeat"); HeartBeat heartbeat("oruga/command"); double frequency = 1; // Default value: 1Hz int c; // Parse command-line options while ((c = getopt (argc, argv, "f:")) != -1) { switch (c) { case 'f': frequency = atof(optarg); break; case '?': if (optopt == 'c') fprintf (stderr, "Option -%c requires an argument.\n", optopt); else if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); else fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); return 1; default: abort(); } } ros::Rate r(frequency); while (ros::ok()) { heartbeat.toggleLeds(); ros::spinOnce(); r.sleep(); } }
static void testrun(void) { unsigned int i = 0; unsigned long long stop_time = 0; int cont = 1; add_paths(); do_test_setup(); if (duration > 0) stop_time = get_time_ms() + (unsigned long long)(duration * 1000); for (;;) { cont = 0; if (i < (unsigned int)iterations) { i++; cont = 1; } if (stop_time && get_time_ms() < stop_time) cont = 1; if (!cont) break; run_tests(); heartbeat(); } do_test_cleanup(); exit(0); }
ClientHeartbeat::ClientHeartbeat(zmq::context_t& context, const HeartbeatSettings& settings) : msFrequency_(settings.msRate), msPollingFrequency_(settings.msPollRate), msTimeout_(settings.msTimeout) { // Create the router's socket std::unique_ptr<zmq::socket_t> heartbeat(new zmq::socket_t(context, ZMQ_PAIR)); heartbeat->connect(CLIENT_HB_SOCKET_ADDR.c_str()); router_.add_socket(SocketID::HEARTBEAT, heartbeat); // Specify functionality auto onRcvHEARTBEAT = [&] (const Message&m) { heartbeatArrived(lastReceivedTime_);}; auto onRcvGOODBYE = [&] (const Message&m) { router_.stop();}; auto timeout = [&] () { monitorTimeout(lastReceivedTime_, router_, msTimeout_);}; auto send = [&] () { sendHeartbeat(lastSendTime_, router_, msFrequency_);}; // Bind to router router_(SocketID::HEARTBEAT).onRcvHEARTBEAT.connect(onRcvHEARTBEAT); router_(SocketID::HEARTBEAT).onRcvGOODBYE.connect(onRcvGOODBYE); router_(SocketID::HEARTBEAT).onPoll.connect(timeout); router_(SocketID::HEARTBEAT).onPoll.connect(send); router_(SocketID::HEARTBEAT).onFailedSend.connect(failedSend); }
void loop(void) { heartbeat(); if (Serial.available()) avrisp(); }
ServerHeartbeat::ServerHeartbeat(zmq::context_t& context, const HeartbeatSettings& settings) : msFrequency_(settings.msRate), msPollingFrequency_(settings.msPollRate), msTimeout_(settings.msTimeout), running_(true) { // Create the router's socket std::unique_ptr<zmq::socket_t> heartbeat(new zmq::socket_t(context, ZMQ_PAIR)); heartbeat->connect(SERVER_HB_SOCKET_ADDR.c_str()); router_.add_socket(SocketID::HEARTBEAT, heartbeat); // Specify functionality auto onRcvHELLO = [&] (const Message&m) { insertClient(m, clients_, lastHeartbeats_);}; auto onRcvGOODBYE = [&] (const Message&m) { deleteClient(m, clients_, lastHeartbeats_);}; auto onRcvHEARTBEAT = [&] (const Message&m) { receiveHeartbeat(m, lastHeartbeats_);}; auto timeouts = [&] () { monitorTimeouts(clients_, lastHeartbeats_, router_, msTimeout_);}; auto send = [&] () { sendHeartbeats(clients_, lastSendTime_, router_, msFrequency_);}; // Bind to router router_(SocketID::HEARTBEAT).onRcvHELLO.connect(onRcvHELLO); router_(SocketID::HEARTBEAT).onRcvGOODBYE.connect(onRcvGOODBYE); router_(SocketID::HEARTBEAT).onRcvHEARTBEAT.connect(onRcvHEARTBEAT); router_(SocketID::HEARTBEAT).onPoll.connect(timeouts); router_(SocketID::HEARTBEAT).onPoll.connect(send); router_(SocketID::HEARTBEAT).onFailedSend.connect(failedSendServer); LOG(INFO)<< "Server heartbeat initialising"; lastSendTime_ = std::chrono::high_resolution_clock::now(); router_.start(msPollingFrequency_, running_); // milliseconds between polling loops }
FileTransferWindow::FileTransferWindow( #if 0 KviModuleExtensionDescriptor * d #endif ) : KviWindow(KviWindow::Tool, "file transfer window", nullptr) #if 0 , KviModuleExtension(d) #endif { g_pFileTransferWindow = this; setAutoFillBackground(false); m_pContextPopup = nullptr; m_pLocalFilePopup = nullptr; m_pOpenFilePopup = nullptr; m_pTimer = new QTimer(this); connect(m_pTimer, SIGNAL(timeout()), this, SLOT(heartbeat())); m_pSplitter = new KviTalSplitter(Qt::Horizontal, this); m_pSplitter->setObjectName("transferwindow_hsplitter"); m_pSplitter->setChildrenCollapsible(false); m_pVertSplitter = new KviTalSplitter(Qt::Vertical, m_pSplitter); m_pVertSplitter->setObjectName("transferwindow_vsplitter"); m_pVertSplitter->setChildrenCollapsible(false); m_pTableWidget = new FileTransferWidget(m_pVertSplitter); //ad-hoc itemdelegate for this view m_pItemDelegate = new FileTransferItemDelegate(m_pTableWidget); m_pTableWidget->setItemDelegate(m_pItemDelegate); /* * TODO KviDynamicToolTip * tp = new KviDynamicToolTip(m_pTableWidget->viewport()); connect(tp,SIGNAL(tipRequest(KviDynamicToolTip *,const QPoint &)),this,SLOT(tipRequest(KviDynamicToolTip *,const QPoint &))); */ QFontMetrics fm(font()); m_iLineSpacing = fm.lineSpacing(); m_pIrcView = new KviIrcView(m_pVertSplitter, this); m_pTableWidget->installEventFilter(this); connect(m_pTableWidget, SIGNAL(rightButtonPressed(FileTransferItem *, QPoint)), this, SLOT(rightButtonPressed(FileTransferItem *, QPoint))); connect(m_pTableWidget, SIGNAL(doubleClicked(FileTransferItem *, const QPoint &)), this, SLOT(doubleClicked(FileTransferItem *, const QPoint &))); fillTransferView(); connect(KviFileTransferManager::instance(), SIGNAL(transferRegistered(KviFileTransfer *)), this, SLOT(transferRegistered(KviFileTransfer *))); connect(KviFileTransferManager::instance(), SIGNAL(transferUnregistering(KviFileTransfer *)), this, SLOT(transferUnregistering(KviFileTransfer *))); KviFileTransferManager::instance()->setTransferWindow(this); m_pTimer->start(2000); }
void TrashcanLabel::flash() { m_uFlashCount = 0; if(m_pFlashTimer)return; m_pFlashTimer = new QTimer(); connect(m_pFlashTimer,SIGNAL(timeout()),this,SLOT(heartbeat())); m_pFlashTimer->start(200); }
void SetDigitalOutLevel(int pin, int value) { heartbeat(); //ANDROID THERMOSTAT MOD log_printf("SetDigitalOutLevel(%d, %d)", pin, value); SAVE_PIN_FOR_LOG(pin); BYTE prev = SyncInterruptLevel(4); PinSetLat(pin, value); SyncInterruptLevel(prev); }
/* Function: al_is_event_queue_empty */ bool al_is_event_queue_empty(ALLEGRO_EVENT_QUEUE *queue) { ASSERT(queue); heartbeat(); return is_event_queue_empty(queue); }
void display_rec(int8 store, int8 display) { if (nv_report_mode == 0 && display == TRUE) fprintf(COM_A, "%s", data_buffer); else if (nv_report_mode >= 4) fprintf(COM_A, "%s", data_buffer); if (store==TRUE && sd_status==0) { buffer_select = 0; heartbeat(FALSE); // restarts WD & stops timer = 4 seconds to complete append_data(file_ptr_raw_all); heartbeat(TRUE); heartbeat(FALSE); // restarts WD & stops timer = 4 seconds to complete append_data(file_ptr_raw_new); heartbeat(TRUE); } }
WebEngine::WebEngine() : m_timeout(DefaultTimeout) { DEBUG("WebEngine created"); QObject::connect(&m_qnam, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*))); QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(heartbeat())); }
int32_t CDaemonServer::handle_timeout(const void *act, uint32_t timer_id) { if(time_id_ == timer_id) { time_id_ = 0; heartbeat(); } return 0; }
static irqreturn_t timer_interrupt(int irq, void *dev_id) { struct clock_event_device *evt = &clockevent_xilinx_timer; #ifdef CONFIG_HEART_BEAT heartbeat(); #endif timer_ack(); evt->event_handler(evt); return IRQ_HANDLED; }
int msg_udp_handler(int sockfd,struct online_list *clientlist) { char buf[ UDP_BUFFER_SIZE ]; char server_buf[1024]; char msgtype[32]; struct sockaddr_in client_address; int ret; memset(buf, '\0',UDP_BUFFER_SIZE); socklen_t client_addrlength = sizeof(client_address); ret = recvfrom(sockfd,buf,UDP_BUFFER_SIZE-1,0,(struct sockaddr*)&client_address, &client_addrlength); if(ret <= 0) { return -1; } /* debug */ // printf("udp buf: %s\n",buf); cJSON *msg = cJSON_Parse(buf); if(!msg) { return -1; } memset(msgtype,'\0',strlen(msgtype)); strcpy(msgtype,cJSON_GetObjectItem(msg,"MsgType")->valuestring); if(strcmp(MSG_ONLINE,msgtype) == 0) { /* msg online */ struct client_info client; json_to_msg_client_info(buf,&client); /* convert buf to json */ add_to_online_list(clist,&client); /* add into online client list */ struct server_info server; strcpy(server.ip,server_ip); strcpy(server.reserved,"nulled"); server_info_to_json(server_buf,&server); /* convert server info to json */ /* debug */ // printf("send buf: %s\n",server_buf); sendto(sockfd,server_buf,strlen(server_buf)+1,0,(struct sockaddr*)&client_address,client_addrlength); cJSON_Delete(msg); return 0; } else if(strcmp(MSG_HEARTBEAT,msgtype) == 0) { /* msg heartbeat */ char *clientmac; clientmac = cJSON_GetObjectItem(msg,"ClientMAC")->valuestring; heartbeat(clist,clientmac); /* heartbeat test */ free(clientmac); return 0; } return -1; }
void RUDPSocket::process(uint8_t msg_id, uint16_t check_sum, BinStream& strm, const Inet_Addr& remote_addr) { if(check_sum != check_sum_) return ; keeplive_count_ = 0; //地址学习 if(remote_addr_ != remote_addr) { RUDP()->delete_peer_index(remote_rudp_id_, remote_addr_); remote_addr_ = remote_addr; } switch(msg_id) { case RUDP_DATA: process_data(strm, remote_addr); break; case RUDP_DATA_ACK: process_data_ack(strm, remote_addr); break; case RUDP_DATA_NACK: process_data_nack(strm, remote_addr); break; case RUDP_SYN2: process_syn2(strm, remote_addr); break; case RUDP_SYN_ACK: process_syn_ack(strm, remote_addr); break; case RUDP_FIN: process_fin(strm, remote_addr); break; case RUDP_FIN2: process_fin2(strm, remote_addr); break; case RUDP_KEEPALIVE: process_keeplive(strm, remote_addr); break; case RUDP_KEEPALIVE_ACK: process_keeplive_ack(strm, remote_addr); break; } heartbeat(); }
int32_t RUDPObject::handle_timeout(const void *act, uint32_t timer_id) { if(timer_id == timer_id_) { heartbeat(); timer_id_ = REACTOR_INSTANCE()->set_timer(this, NULL, RUDP_TIMER_DELAY); } return 0; }
JobModel::JobModel(QObject *parent) : QAbstractTableModel(parent) ,blinkStateOn(true) { connect( JobManager::instance(), SIGNAL(jobStarted(JobInterface*)), this, SLOT(jobStarted(JobInterface*))); connect( JobManager::instance(), SIGNAL(jobEnded(JobInterface*)), this, SLOT(jobEnded(JobInterface*))); // Make the current task blink QTimer* timer = new QTimer(this); timer->start(500); connect(timer, SIGNAL(timeout()), this, SLOT(heartbeat())); }
int heartbeat_thread_function(void* data) { pPlayer player = data; while (player->heartbeat_message != -1) { heartbeat(player); int start = SDL_GetTicks(); while (SDL_GetTicks() - start < 10000 && player->heartbeat_message != -1) spSleep(100000); } return 0; }
int main() { char* buf; struct message* header = new struct message; db_connection* conn = new db_connection; net_connection* net_conn = new net_connection; while ( 1 ){ buf = net_conn->receive( ); memcpy( header, buf, sizeof( struct message)); /** Only allow DCP messages */ if ( header->proto != Proto_Dispatcher ) { log_err() << header->num << ": unhandled protocol " << header->proto; continue; } log_err() << header->num << ": " << header->type; switch ( header->type ) { case Msg_Heartbeat: if ( checksum<struct msg_heartbeat>( (const uint8_t*)buf) ) { log_err() << "Incorrect checksum"; continue; } heartbeat( buf, conn); break; case Msg_ReqConfirm: conf_request( buf); break; case Msg_Confirm: confirm( buf); break; case Msg_Report: report( buf); break; default: log_err() << header->num << ": unhandled message type " << header->type; continue; } delete buf; } log_norm() << "Server terminated"; return 0; }
RC OutputThread::run() { tsetup(); printf("Running OutputThread %ld\n",_thd_id); while (!simulation->is_done()) { heartbeat(); messager->run(); } printf("FINISH %ld:%ld\n",_node_id,_thd_id); fflush(stdout); return FINISH; }