Exemplo n.º 1
0
void chunk_write(struct output_stream *out, const struct chunk *c)
{
  static char sendbuf[BUFSIZE];
  static int pos = 0;
  int ret;
  uint32_t size;

  size = encodeChunk(c, sendbuf + pos + sizeof(size), BUFSIZE - pos);
  if (size <= 0) {
    fprintf(stderr,"output-chunkstream: Error encoding chunk or no space in output buffer, skipping\n");
  } else {
    *((uint32_t*)(sendbuf + pos)) = htonl(size);
    pos += sizeof(size) + size;
  }

  if (mode == TCP_MODE && fd < 0) {
    fprintf(stderr,"output-chunkstream: reconnecting ...\n");
    output_connect();
  }
  if (fd < 0) {
    fprintf(stderr,"output-chunkstream: not conected\n");
    return;
  }

  if (mode == TCP_MODE) {  //distiction needed by Win32
    ret = send(fd, sendbuf, pos, 0);
  } else {
    ret = write(fd, sendbuf, pos);
  }
  if (ret < 0) {
#ifndef _WIN32
    if (ret == -1 &&  (errno == EAGAIN || errno == EWOULDBLOCK)) {
#else
    if (ret == -1 &&  WSAGetLastError() == WSAEWOULDBLOCK) {
#endif
      fprintf(stderr,"output-chunkstream: Output stalled ...\n");
    } else {
      perror("output-chunkstream: Error writing to output");
      close(fd);
      pos = 0;
      fd = -1;
    }
  } else {
    dprintf("output-chunkstream: written %d bytes\n", ret);
    pos -= ret;
    memmove(sendbuf, sendbuf + ret, pos);
  }
}
Exemplo n.º 2
0
struct output_stream *out_stream_init(const char *fn, const char *config)
{
  if (fn) fname = strdup(fn);
  output_connect();
  return 1;	//TODO: create real output_stream structure
}
Exemplo n.º 3
0
Arquivo: ita.c Projeto: LCAD-UFES/MAE
void build_network (void)
{
NUM_ISOLATE_NEURON_LAYERS = 12;
NUM_INPUTS = 2;
NUM_OUTPUTS = 6;
NUM_FILTERS = 2;
srand (5); 
memset((void *) &(nl_ita_lp_f), 0, sizeof(NEURON_LAYER));
nl_ita_lp_f.name = "nl_ita_lp_f";
memset((void *) &(nl_prediction), 0, sizeof(NEURON_LAYER));
nl_prediction.name = "nl_prediction";
memset((void *) &(nl_test), 0, sizeof(NEURON_LAYER));
nl_test.name = "nl_test";
memset((void *) &(nl_result), 0, sizeof(NEURON_LAYER));
nl_result.name = "nl_result";
memset((void *) &(nl_ita2_lp_f), 0, sizeof(NEURON_LAYER));
nl_ita2_lp_f.name = "nl_ita2_lp_f";
memset((void *) &(nl_prediction2), 0, sizeof(NEURON_LAYER));
nl_prediction2.name = "nl_prediction2";
memset((void *) &(ita), 0, sizeof(INPUT_DESC));
ita.name = "ita";
memset((void *) &(ita2), 0, sizeof(INPUT_DESC));
ita2.name = "ita2";
memset((void *) &(out_ita_lp_f), 0, sizeof(OUTPUT_DESC));
out_ita_lp_f.name = "out_ita_lp_f";
memset((void *) &(out_prediction), 0, sizeof(OUTPUT_DESC));
out_prediction.name = "out_prediction";
memset((void *) &(out_test), 0, sizeof(OUTPUT_DESC));
out_test.name = "out_test";
memset((void *) &(out_result), 0, sizeof(OUTPUT_DESC));
out_result.name = "out_result";
memset((void *) &(out_ita2_lp_f), 0, sizeof(OUTPUT_DESC));
out_ita2_lp_f.name = "out_ita2_lp_f";
memset((void *) &(out_prediction2), 0, sizeof(OUTPUT_DESC));
out_prediction2.name = "out_prediction2";

__line = 2;
NEURON_MEMORY_SIZE = 10000;
__line = 4;
TYPE_SHOW = SHOW_FRAME;
__line = 5;
TYPE_MOVING_FRAME = STOP;
__line = 8;
//;
__line = 9;
//;
__line = 11;
//;
__line = 12;
//;
__line = 14;
//;
__line = 16;
//;
__line = 17;
//;
__line = 18;
//;
__line = 19;
//;
__line = 20;
//;
__line = 21;
//;
__line = 22;
//;
__line = 25;
create_neuron_layer (&nl_ita_lp_f, NULL, NOT_SPECIFIED, GREYSCALE_FLOAT, INPUT_WIDTH,INPUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE);
__line = 26;
create_neuron_layer (&nl_prediction, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE);
__line = 27;
create_neuron_layer (&nl_test, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE);
__line = 28;
create_neuron_layer (&nl_result, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE);
__line = 30;
create_neuron_layer (&nl_ita2_lp_f, NULL, NOT_SPECIFIED, GREYSCALE_FLOAT, INPUT_WIDTH,INPUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE);
__line = 31;
create_neuron_layer (&nl_prediction2, &minchinton, GREYSCALE_FLOAT, GREYSCALE_FLOAT, OUT_WIDTH,OUT_HEIGHT,DISTRIBUTED_MEMORY, NEURON_MEMORY_SIZE);
__line = 34;
create_output (&out_ita_lp_f, INPUT_WIDTH,INPUT_HEIGHT, NULL, 0);
__line = 35;
create_output (&out_prediction, OUT_WIDTH,OUT_HEIGHT, output_handler, " ");
__line = 36;
create_output (&out_test, OUT_WIDTH,OUT_HEIGHT, NULL, 0);
__line = 37;
create_output (&out_result, OUT_WIDTH,OUT_HEIGHT, NULL, 0);
__line = 39;
create_output (&out_ita2_lp_f, INPUT_WIDTH,INPUT_HEIGHT, NULL, 0);
__line = 40;
create_output (&out_prediction2, OUT_WIDTH,OUT_HEIGHT, output_handler, " ");
__line = 43;
create_input (&ita, INPUT_WIDTH,INPUT_HEIGHT, GREYSCALE_FLOAT, 0, REGULAR_PYRAMID, input_generator, input_controler, " ", " ");
__line = 45;
create_input (&ita2, INPUT_WIDTH,INPUT_HEIGHT, GREYSCALE_FLOAT, 0, REGULAR_PYRAMID, input_generator, input_controler, " ", " ");
__line = 49;
create_filter (copy_nl_filter, &nl_ita_lp_f, 1, ita.neuron_layer, "");
__line = 51;
create_filter (copy_nl_filter, &nl_ita2_lp_f, 1, ita2.neuron_layer, "");
__line = 54;
output_connect (&nl_ita_lp_f, &out_ita_lp_f);
__line = 55;
output_connect (&nl_prediction, &out_prediction);
__line = 56;
output_connect (&nl_test, &out_test);
__line = 57;
output_connect (&nl_result, &out_result);
__line = 59;
output_connect (&nl_ita2_lp_f, &out_ita2_lp_f);
__line = 60;
output_connect (&nl_prediction2, &out_prediction2);
__line = 63;
associate_neurons (&nl_prediction, &nl_prediction);
__line = 65;
associate_neurons (&nl_prediction2, &nl_prediction2);
__line = 68;
connect_neurons (GAU2, &nl_ita_lp_f, &nl_prediction, SYNAPSES, 0.0, 9.32433, 0.0, -1,-1,-1,-1, -1,-1,-1,-1, DIFFERENT_INTERCONNECTION_PATTERN);
__line = 74;
connect_neurons (GAU2, &nl_ita2_lp_f, &nl_prediction2, SYNAPSES, 0.0, 9.32433, 0.0, -1,-1,-1,-1, -1,-1,-1,-1, DIFFERENT_INTERCONNECTION_PATTERN);
__line = 77;
create_interpreter_user_function (INT_TYPE, GetRandomReturns, "GetRandomReturns", "%d");
;
__line = 78;
create_interpreter_user_function (INT_TYPE, ShowStatistics, "ShowStatistics", "%d");
;
__line = 79;
create_interpreter_user_function (INT_TYPE, ResetStatistics, "ResetStatistics", "%d");
;
__line = 80;
create_interpreter_user_function (INT_TYPE, SetNetworkStatus, "SetNetworkStatus", "%d");
;
__line = 81;
create_interpreter_user_function (INT_TYPE, LoadReturns, "LoadReturns", "%s");
;
__line = 82;
create_interpreter_user_function (INT_TYPE, LoadDayFileName, "LoadDayFileName", "%s");
;
__line = 83;
create_interpreter_user_function (INT_TYPE, LoadDay, "LoadDay", "%d");
;
__line = 84;
create_interpreter_user_function (INT_TYPE, ShowStatisticsExp, "ShowStatisticsExp", "%d");
;
__line = 85;
create_interpreter_user_function (INT_TYPE, MeanStatisticsExp, "MeanStatisticsExp", "%d");
;
__line = 86;
create_interpreter_user_function (INT_TYPE, SetLongShort, "SetLongShort", "%d");
;
map_layers2id (); 
count_num_neurons (); 
initialise_memory (); 
create_io_windows (); 
}