<commit_before>#include <joyos.h>
#include <Point.h>

Point fake_active_target;
struct lock fake_data_lock;

bool fake_daemon_has_run = false;

Point generate_new_target() {
  Point target = {(rand()%4096-2048)*UNITS_VPS_TO_MM, (rand()%4096-2048)*UNITS_VPS_TO_MM};
  return target;
}

void first_run() {
  acquire(&fake_data_lock);
    fake_active_target = generate_new_target();
  release(&fake_data_lock);
}

float dist(Point a, Point b) {
  return sqrt(pow(a.x-b.x, 2) + pow(a.y-b.y, 2));
}

void generate_data() {
  acquire(&vps_data_lock);
  acquire(&fake_data_lock);
  if (dist(vps_position, fake_active_target) < TARGET_TOLERANCE) {
    fake_active_target = generate_new_target();
  }  

  fake_daemon_has_run = true;

  release(&fake_data_lock);
  release(&vps_data_lock);
}

int fake_data_daemon() {
  srand(8);
  first_run();
  while(1) {
    pause(20); // safety interval (arbitrary time)
    generate_data();
  }

  return 0;
}

void fake_data_daemon_init() {
  init_lock(&fake_data_lock, "fake_data_lock");
  create_thread(fake_data_daemon, STACK_DEFAULT, 0, "fake_daemon");
}<commit_msg>accessor for vps_fake_active_target<commit_after>#include <joyos.h>
#include <Point.h>

Point fake_active_target;
struct lock fake_data_lock;

bool fake_daemon_has_run = false;

Point generate_new_target() {
  Point target = {(rand()%4096-2048)*UNITS_VPS_TO_MM, (rand()%4096-2048)*UNITS_VPS_TO_MM};
  return target;
}

void first_run() {
  acquire(&fake_data_lock);
    fake_active_target = generate_new_target();
  release(&fake_data_lock);
}

float dist(Point a, Point b) {
  return sqrt(pow(a.x-b.x, 2) + pow(a.y-b.y, 2));
}

void generate_data() {
  acquire(&vps_data_lock);
  acquire(&fake_data_lock);
  if (dist(vps_position, fake_active_target) < TARGET_TOLERANCE) {
    fake_active_target = generate_new_target();
  }  

  fake_daemon_has_run = true;

  release(&fake_data_lock);
  release(&vps_data_lock);
}

int fake_data_daemon() {
  srand(gettime());
  first_run();
  while(1) {
    pause(20); // safety interval (arbitrary time)
    generate_data();
  }

  return 0;
}

void fake_data_daemon_init() {
  init_lock(&fake_data_lock, "fake_data_lock");
  create_thread(fake_data_daemon, STACK_DEFAULT, 0, "fake_daemon");
}

Point get_fake_vps_active_target() {
  acquire(&fake_data_lock);
  Point ret = fake_active_target;
  release(&fake_data_lock);
  return ret;
}
{'fraction_non_alphanumeric': 0.1367845117845118, 'fraction_numerical': 0.01978114478114478, 'mean_word_length': 5.424324324324324, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '5882542', 'n_tokens_mistral': 977, 'n_tokens_neox': 944, 'n_words': 153}