<commit_before>/*!  \file 

$Id: glue_stub.c,v 1.1 2004-07-28 13:09:44 mia Exp $

-----------------------------------------------------------------------

TSP Library - core components for a generic Transport Sampling Protocol.

Copyright (c) 2002 <NAME>, <NAME>, <NAME> and <NAME> 

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

-----------------------------------------------------------------------

Project   : TSP
Maintainer: <EMAIL>
Component : Provider

-----------------------------------------------------------------------

Purpose   : Implementation for the glue_server, for stub test
	    Allow the output of a datapool of 1000 symbols, 
	    cyclically generated at 100Hz

-----------------------------------------------------------------------
*/

#include <string.h>
#include <stdio.h>
#include <assert.h>

#include "tsp_sys_headers.h"
#include "glue_sserver.h"
#include "tsp_ringbuf.h"
#include "tsp_time.h"
#include "calc_func.h"

RINGBUF_DECLARE_TYPE_DYNAMIC(glu_ringbuf,glu_item_t);

/* TSP glue server defines */
#define TSP_STUB_FREQ 100 /*Hz*/
#define TSP_USLEEP_PERIOD_US /*(long long)*/(1000000/TSP_STUB_FREQ) /*given in S, value 10ms*/
#define GLU_MAX_SYMBOLS 1000

/* Glue server ringbuf size */
#define GLU_RING_BUFSIZE (TSP_STUB_FREQ * GLU_MAX_SYMBOLS)


/* Nasty static variables */
static TSP_sample_symbol_info_t *X_sample_symbol_info_list_val;
static glu_ringbuf* glu_ring = 0;
pthread_t thread_id = 0;
static char* X_server_name = "StubbedServer";
static time_stamp_t my_time = 0;

/* protypes declarations */
int  GLU_get_symbol_number(void) ;

char* GLU_get_server_name(void)
{
  return X_server_name;
}

int  GLU_get_symbol_number(void)

{
  int i = 0;
  TSP_sample_symbol_info_t* p  = X_sample_symbol_info_list_val;
	
  for( p=X_sample_symbol_info_list_val; p->name!=0 ; p++)
    {
      i++;
    }

  return i;
}

int data_missed = FALSE;
void* GLU_thread(void* arg)
{
  
  SFUNC_NAME(GLU_thread);

  int i, symbols_nb;
  tsp_hrtime_t current_time, next_time;
  unsigned long tickNow;
  glu_item_t item;
  double memo_val[GLU_MAX_SYMBOLS]; /* for building calc_function % 10 */

  symbols_nb  = GLU_get_symbol_number();
  current_time = tsp_gethrtime();

  /* infinite loop for symbols generation */
  while(1)
    {
     tickNow = tickGet();
      next_time = current_time + (TSP_USLEEP_PERIOD_US)*1000;
      while((current_time = tsp_gethrtime()) < next_time)
	{ 
	  taskDelay(1);
	}
 
      for(i = 0 ; i < symbols_nb ; i++)
	{
	  if(my_time%X_sample_symbol_info_list_val[i].period == 0)
	    {
	      item.time = my_time;
	      item.provider_global_index = i;
	      if (i!=0)
		item.value = calc_func(i, my_time);
	      else
		item.value = (double)(my_time) / (double)(TSP_STUB_FREQ);
	      memo_val[i]=item.value;

	      RINGBUF_PTR_PUT(glu_ring, item);
	    }
	}
      

      if(RINGBUF_PTR_MISSED(glu_ring))
	{
	  data_missed = TRUE;
	  STRACE_ERROR(("TOP %d, data missed : %d ticks\n", my_time, tickGet() - tickNow));
	}
      
      if (!(my_time%1000))  STRACE_INFO(("TOP %d : %s=%g \t%s=%g \t%s=%g \t%s=%g", my_time,
					 X_sample_symbol_info_list_val[0].name, memo_val[0],
					 X_sample_symbol_info_list_val[1].name, memo_val[1],
					 X_sample_symbol_info_list_val[2].name, memo_val[2],
					 X_sample_symbol_info_list_val[3].name, memo_val[3]
					));
      my_time++;    
    }
    
  return arg;

}<commit_msg>Log RINGBUF missed only once ...<commit_after>/*!  \file 

$Id: glue_stub.c,v 1.2 2004-07-30 09:20:42 mia Exp $

-----------------------------------------------------------------------

TSP Library - core components for a generic Transport Sampling Protocol.

Copyright (c) 2002 <NAME>, <NAME>, <NAME> and <NAME> 

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

-----------------------------------------------------------------------

Project   : TSP
Maintainer: <EMAIL>
Component : Provider

-----------------------------------------------------------------------

Purpose   : Implementation for the glue_server, for stub test
	    Allow the output of a datapool of 1000 symbols, 
	    cyclically generated at 100Hz

-----------------------------------------------------------------------
*/

#include <string.h>
#include <stdio.h>
#include <assert.h>

#include "tsp_sys_headers.h"
#include "glue_sserver.h"
#include "tsp_ringbuf.h"
#include "tsp_time.h"
#include "calc_func.h"

RINGBUF_DECLARE_TYPE_DYNAMIC(glu_ringbuf,glu_item_t);

/* TSP glue server defines */
#define TSP_STUB_FREQ 100 /*Hz*/
#define TSP_USLEEP_PERIOD_US /*(long long)*/(1000000/TSP_STUB_FREQ) /*given in S, value 10ms*/
#define GLU_MAX_SYMBOLS 1000

/* Glue server ringbuf size */
#define GLU_RING_BUFSIZE (TSP_STUB_FREQ * GLU_MAX_SYMBOLS)


/* Nasty static variables */
static TSP_sample_symbol_info_t *X_sample_symbol_info_list_val;
static glu_ringbuf* glu_ring = 0;
pthread_t thread_id = 0;
static char* X_server_name = "StubbedServer";
static time_stamp_t my_time = 0;

/* protypes declarations */
int  GLU_get_symbol_number(void) ;

char* GLU_get_server_name(void)
{
  return X_server_name;
}

int  GLU_get_symbol_number(void)

{
  int i = 0;
  TSP_sample_symbol_info_t* p  = X_sample_symbol_info_list_val;
	
  for( p=X_sample_symbol_info_list_val; p->name!=0 ; p++)
    {
      i++;
    }

  return i;
}

int data_missed = FALSE;
void* GLU_thread(void* arg)
{
  
  SFUNC_NAME(GLU_thread);

  int i, symbols_nb;
  tsp_hrtime_t current_time, next_time;
  unsigned long tickNow;
  glu_item_t item;
  double memo_val[GLU_MAX_SYMBOLS]; /* for building calc_function % 10 */

  symbols_nb  = GLU_get_symbol_number();
  current_time = tsp_gethrtime();

  /* infinite loop for symbols generation */
  while(1)
    {
     tickNow = tickGet();
      next_time = current_time + (TSP_USLEEP_PERIOD_US)*1000;
      while((current_time = tsp_gethrtime()) < next_time)
	{ 
	  taskDelay(1);
	}
 
      for(i = 0 ; i < symbols_nb ; i++)
	{
	  if(my_time%X_sample_symbol_info_list_val[i].period == 0)
	    {
	      item.time = my_time;
	      item.provider_global_index = i;
	      if (i!=0)
		item.value = calc_func(i, my_time);
	      else
		item.value = (double)(my_time) / (double)(TSP_STUB_FREQ);
	      memo_val[i]=item.value;

	      RINGBUF_PTR_PUT(glu_ring, item);
	    }
	}
      

      if(RINGBUF_PTR_MISSED(glu_ring) && !data_missed)
	{
	  data_missed = TRUE;
	  STRACE_ERROR(("TOP %d, data missed : %d ticks\n", my_time, tickGet() - tickNow));
	}
      
      if (!(my_time%1000))  STRACE_INFO(("TOP %d : %s=%g \t%s=%g \t%s=%g \t%s=%g", my_time,
					 X_sample_symbol_info_list_val[0].name, memo_val[0],
					 X_sample_symbol_info_list_val[1].name, memo_val[1],
					 X_sample_symbol_info_list_val[2].name, memo_val[2],
					 X_sample_symbol_info_list_val[3].name, memo_val[3]
					));
      my_time++;    
    }
    
  return arg;

}
{'fraction_non_alphanumeric': 0.16911855606379034, 'fraction_numerical': 0.021510693534429474, 'mean_word_length': 2.7999060591827147, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2342033', 'n_tokens_mistral': 3035, 'n_tokens_neox': 2779, 'n_words': 720}