<< Previous Post..

Table of Contents

Next Post >>


A Promise is Promise......


I have promised that I will release all the content of my project under Creative Commons BY-SA License so other interested people can replicate my work or even contribute to it...

 

Today, I am releasing all my GUI Design related Work of Real Time Player Monitoring System for open source community...

 

1. GUI Application: Main features of this Application are,

  • Can monitor entire team up to 11 players
  • Uses UDP protocol for communication to CC3200 Mod based Chest Strap.
  • Currently works with 100Hz Update Rate but you can increase it also.
  • All the received data logged and saved in to file with time stamp for future analysis
  • Thresholds can be changed real time
  • Provides audio notification and popup when certain threshold cross with player id
  • Easy to use/modify because it is designed around processing
  • no initial setup needed just turn on module and get real time data on GUI Application
  • Graphing facility also available in 1.2 and 1.4 application

 

1.1. PC GUI Application: These Application designed with Processing-2.2.1

https://gist.github.com/ravibutani/dfd7153569aa14866fad

/*
  Realtime Player Monitoring System
  
  Sudden Impact Wearable Design Challenge
  
  Sponsered By element14 , Analog Devices, Tektronix and Electrolube
  Special Thanks to Texas Instruments for providing CC3200MOD, MSP430, TLV3402 Samples free of cost
  
  Source code for PC Remote Team Monitoring Application 
  Works with Linux-32, linux-64, windows-32 and windows-64

  Source compiled with processing-2.2.1
   
  By: Ravi Butani
  Date: 23rd April,2015
  e-mail: ravi_butani@yahoo.com
  Source Code is Released Under Creative Commons Attribution-ShareAlike 3.0 Unported Licence
 */

import hypermedia.net.*; //udp
import static javax.swing.JOptionPane.*;//popup
import ddf.minim.*;
Minim minim;
AudioPlayer player;

PImage bg_frame1,bg_frame0,bg_frame2,bg_frame0_tmp,bg_frame1_tmp,bg_frame2_tmp;//tmpadded
//Thresholds for sensors
int h_acc_TH = 50;
int b_acc_TH = 50;
int h_ret_UTH= 120;
int h_ret_LTH= 60;
int b_tmp_UTH= 40;
int b_tmp_LTH= 20;

//Variables to hold sensor reading
int h_acc = 0, h_acc_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int b_acc = 0,b_acc_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int h_ret = 0,h_ret_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int b_tmp = 0,b_tmp_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int player_id = 0,player_id_show=0; //added

String summary[]={"0 --- --- --- ---","1 --- --- --- ---","2 --- --- --- ---","3 --- --- --- ---","4 --- --- --- ---","5 --- --- --- ---","6 --- --- --- ---","7 --- --- --- ---","8 --- --- --- ---","9 --- --- --- ---","10 --- --- --- ---"};

int show_frame = 0;
int game_type = 0; //0=single player and 1=multiplayer

UDP udp;  // define the UDP object
PrintWriter udp_log;
String Player1 = "Player-";
int alert_flag = 0;
int alert_flag_ack = 0,flag_ack = 0;
int activity_flag[] = {0,0,0,0,0,0,0,0,0,0,0};
int leads_off_flag = 0;

void setup(){
//size(540,960);
   size(470,700);
   orientation(PORTRAIT);
   textAlign(CENTER);
   textSize(23);
   stroke(0);
   //udp_log = createWriter("//sdcard//rtpms_monitor_log//rtpms_monitor_log_"+year()+"_"+month()+"_"+day()+"//rtpms_monitor_log_"+hour()+"_"+minute()+"_"+second()+".txt");
  udp_log = createWriter("rtpms_monitor_log/rtpms_monitor_log_"+year()+"_"+month()+"_"+day()+"/rtpms_monitor_log_"+hour()+"_"+minute()+"_"+second()+".txt");
udp = new UDP( this, 2390 );
  udp.listen( true );
  bg_frame2_tmp = loadImage("about.png");
  bg_frame1_tmp = loadImage("sudden_player.png");
  bg_frame0_tmp = loadImage("simpact.png");
  bg_frame2 = new PImage(width, height);//added
  bg_frame2.copy(bg_frame2_tmp, 0, 0, bg_frame2_tmp.width, bg_frame2_tmp.height, 0, 0, width, height);//added
  bg_frame1 = new PImage(width, height);//added
  bg_frame1.copy(bg_frame1_tmp, 0, 0, bg_frame1_tmp.width, bg_frame1_tmp.height, 0, 0, width, height);//added
  bg_frame0 = new PImage(width, height);//added
  bg_frame0.copy(bg_frame0_tmp, 0, 0, bg_frame0_tmp.width, bg_frame0_tmp.height, 0, 0, width, height);//added
  minim = new Minim(this);
  player = minim.loadFile("alert.mp3"); //create new APMediaPlayer
   delay(50);

}

void draw()
{
  if(show_frame == 0)
   draw_frame0();
  if(show_frame == 1)
   draw_frame1();
  if(show_frame == 2)
   draw_frame2();
  if(show_frame == 3)
   draw_frame3();
  if(show_frame == 4)
   draw_frame4();

}

void draw_frame0() //main frame
{
   background(bg_frame0);
   pushStyle();
   textSize(38);
   if(game_type == 0)fill(color(255,90,90));
   else fill(160);
   rect(width/4, height/2, width/4, 80);
   fill(0);
   pushStyle();
   textSize(30);
   text("Single", width/4+width/8, height/2+32 );
   text("Player", width/4+width/8, height/2+68 );
   popStyle();
   if(game_type == 1)fill(color(255,90,90));
   else fill(160);
   rect(width/2, height/2, width/4, 80);
   fill(0);
   pushStyle();
   textSize(30);
   text("Multi", width/2+width/8, height/2+32 );
   text("Player", width/2+width/8, height/2+68 );
   popStyle();
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("About", width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("Next", 5*width/6, 5*height/6 + height/12-18);
   popStyle();
}

void draw_frame2()//monitor window
{
   background(bg_frame1);
   pushStyle();
   textSize(31);
   if(activity_flag[player_id_show] == 0)fill(color(255,90,90));
   else fill(color(130,130,255));
   rect(20,20,width/3,height/16);
   fill(0);
   text(Player1+player_id_show,20+width/6, height/16+10);
   popStyle();

   fill(color(200,180,210));
   rect(width/9, height/3, width/9, height/3);
   if(h_acc > h_acc_TH) fill(color(255,50,50));
   else fill(color(0,255,0));
   rect(width/9, 2*height/3 - map(h_acc,0,100,0,height/3) , width/9, map(h_acc,0,100,0,height/3));
   fill(0);
   text("HALMET", width/9 + width/18, height/3 - 5 );
   pushStyle();
   textSize(38);
   text(h_acc,width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_____"+h_acc_TH, width/9 , 2*height/3 - map(h_acc_TH,0,100,0,height/3));
   textAlign(CENTER);
   text("0-100G",width/9 + width/18, 2*height/3 + 30);

   fill(color(200,180,210));
   rect(3*width/9, height/3, width/9, height/3);
   if(b_acc > b_acc_TH) fill(color(255,50,50));
   else fill(color(0,255,0));
   rect(3*width/9, 2*height/3 - map(b_acc,0,100,0,height/3) , width/9, map(b_acc,0,100,0,height/3));
   fill(0);
   text("CHEST", 3*width/9 + width/18, height/3 - 5 );
   pushStyle();
   textSize(38);
   text(b_acc,3*width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_____"+b_acc_TH, 3*width/9 , 2*height/3 - map(b_acc_TH,0,100,0,height/3));
   textAlign(CENTER);
   text("0-100G",3*width/9 + width/18, 2*height/3 + 30);

   fill(color(200,180,210));
   rect(5*width/9, height/3, width/9, height/3);
   if(b_tmp > b_tmp_UTH) fill(color(255,50,50));
   else if(b_tmp < b_tmp_UTH && b_tmp > b_tmp_LTH) fill(color(0,255,0));
   else fill(color(130,130,255));
   rect(5*width/9, 2*height/3 - map(b_tmp,0,60,0,height/3) , width/9, map(b_tmp,0,60,0,height/3));
   fill(0);
   text("TEMP", 5*width/9 + width/18, height/3 - 5);
   pushStyle();
   textSize(42);
   text(b_tmp, 5*width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_____"+b_tmp_UTH, 5*width/9 , 2*height/3 - map(b_tmp_UTH,0,60,0,height/3));
   text("_____"+b_tmp_LTH, 5*width/9 , 2*height/3 - map(b_tmp_LTH,0,60,0,height/3));
   textAlign(CENTER);
   text("0-60C",5*width/9 + width/18, 2*height/3 + 30);

   fill(color(200,180,210));
   rect(7*width/9, height/3, width/9, height/3);
   if(h_ret > h_ret_UTH) fill(color(255,50,50));
   else if(h_ret < h_ret_UTH && h_ret > h_ret_LTH) fill(color(0,255,0));
   else fill(color(130,130,255));
   rect(7*width/9, 2*height/3 - map(h_ret,0,200,0,height/3) , width/9, map(h_ret,0,200,0,height/3));
   fill(0);
   text("HEART", 7*width/9 + width/18, height/3 - 5 );
   pushStyle();
   textSize(38);
   text(h_ret, 7*width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_____"+h_ret_UTH, 7*width/9 , 2*height/3 - map(h_ret_UTH,0,200,0,height/3));
   text("_____"+h_ret_LTH, 7*width/9 , 2*height/3 - map(h_ret_LTH,0,200,0,height/3));
   textAlign(CENTER);
   text("0-200BPM",7*width/9 + width/18, 2*height/3 + 30);
   if(leads_off_flag == 1)
  {
   fill(color(0,0,0));
   rect(7*width/9, height/3, width/9, height/3);
  }
   pushStyle();
   textSize(38);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Back", width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("About", 5*width/6, 5*height/6 + height/12-18);
   popStyle();
}

void draw_frame1()//Thresholds setting
{
   background(255);
   pushStyle();
   textSize(40);
   fill(0);
   text("Set Thresholds", width/2, height/16);
   textSize(30);
   fill(color(0,255,0));
   rect(10, height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, height/8, map(h_acc_TH,0,100,0,width-20), height/16);
   fill(0);
   text("Helmet Impact Th (G)", width/2, height/8+height/16 - 13 );
   text(h_acc_TH, 10+map(h_acc_TH,0,100,0,width-20) , height/8 - 5);

   fill(color(0,255,0));
   rect(10, 2*height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, 2*height/8, map(b_acc_TH,0,100,0,width-20), height/16);
   fill(0);
   text("Chest Impact Th (G)", width/2, 2*height/8+height/16 - 13 );
   text(b_acc_TH, 10+map(b_acc_TH,0,100,0,width-20) , 2*height/8-5);

   fill(color(0,255,0));
   rect(10, 3*height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, 3*height/8, map(b_tmp_UTH,0,60,0,width-20), height/16);
   fill(0);
   text("Temp High Th (C)", width/2, 3*height/8+height/16 - 13 );
   text(b_tmp_UTH, 10+map(b_tmp_UTH,0,60,0,width-20) ,3*height/8-5);

   fill(color(0,255,0));
   rect(10, 4*height/8, width-20, height/16);
   fill(color(90,90,255));
   rect(10, 4*height/8, map(b_tmp_LTH,0,60,0,width-20), height/16);
   fill(0);
   text("Temp Low Th (C)", width/2, 4*height/8+height/16 - 13 );
   text(b_tmp_LTH, 10+map(b_tmp_LTH,0,60,0,width-20) ,4*height/8-5);

   fill(color(0,255,0));
   rect(10, 5*height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, 5*height/8, map(h_ret_UTH,0,200,0,width-20), height/16);
   fill(0);
   text("Heart Rate High Th (BPM)", width/2, 5*height/8+height/16 - 13 );
   text(h_ret_UTH, 10+map(h_ret_UTH,0,200,0,width-20) ,5*height/8-5);

   fill(color(0,255,0));
   rect(10, 6*height/8, width-20, height/16);
   fill(color(90,90,255));
   rect(10, 6*height/8, map(h_ret_LTH,0,200,0,width-20), height/16);
   fill(0);
   text("Heart Rate Low Th (BPM)", width/2, 6*height/8+height/16 - 13 );
   text(h_ret_LTH, 10+map(h_ret_LTH,0,200,0,width-20) ,6*height/8 - 5);

   textSize(38);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Back", width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("Next", 5*width/6, 5*height/6 + height/12-18);
   popStyle();
}

void draw_frame3()//about
{
   background(bg_frame2);
   pushStyle();
   textSize(38);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/2-20, height/12);
   fill(0);
   text("Back", width/4, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(width/2+10, 5*height/6, width/2-20, height/12);
   fill(0);
   text("Exit", 3*width/4, 5*height/6 + height/12-18 );
   popStyle();
}

void draw_frame4()//dashboard
{
   background(255);
   pushStyle();

   textSize(40);
   fill(0);
   textAlign(CENTER,CENTER);
   text("Dash Board", width/2, height/32);
   textAlign(LEFT,CENTER);
   textSize(24);
   rectMode(CENTER);
   fill(color(150,150,250));
   rect(width/2, height/16+height/32, width-10, height/16-5);
   fill(0);
   text(" Player Halmet Chest Temp Heart", 8, height/16+height/32 );

   textSize(32);
   if(flag_ack == 1)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 2*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[0], 30, 2*height/16+height/32 );
   if(flag_ack == 2)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 3*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[1], 30, 3*height/16+height/32 );
   if(flag_ack == 3)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 4*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[2], 30, 4*height/16+height/32 );
   if(flag_ack == 4)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 5*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[3], 30, 5*height/16+height/32 );
   if(flag_ack == 5)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 6*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[4], 30, 6*height/16+height/32 );
   if(flag_ack == 6)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 7*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[5], 30, 7*height/16+height/32 );
   if(flag_ack == 7)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 8*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[6], 30, 8*height/16+height/32 );
   if(flag_ack == 8)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 9*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[7], 30, 9*height/16+height/32 );
   if(flag_ack == 9)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 10*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[8], 30, 10*height/16+height/32 );
   if(flag_ack == 10)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 11*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[9], 30, 11*height/16+height/32 );
   if(flag_ack == 11)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 12*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[10], 30, 12*height/16+height/32 );

   rectMode(CORNER);
   textAlign(CENTER);
   textSize(38);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Back", width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-18 );

   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("Next", 5*width/6, 5*height/6 + height/12-18);
   popStyle();
}
void mousePressed()
{
if(show_frame == 0)
{
if(mouseY > height/2 && mouseY < height/2+80)
  {
   if(mouseX > width/4 && mouseX < 2*width/4)
  {
  game_type=0;
   println("Single");
  }
   if(mouseX > 2*width/4 && mouseX < 3*width/4)
  {
  game_type=1;
   println("Multi");
  }
  }
else if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("aboutus");
  show_frame=3;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("next");
  show_frame = 1;
  }

  }
}
else if(show_frame == 1)
{

   if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("back");
  show_frame = 0;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("next");
   //h_acc = h_acc_TH/2;
   //b_acc = b_acc_TH/2;
   //h_ret = (h_ret_UTH + h_ret_LTH)/2;
   //b_tmp = (b_tmp_UTH + b_tmp_LTH)/2;
   if(game_type ==1) show_frame=4;
   else show_frame = 2;
  }
  }

}
else if(show_frame == 2)
{
   if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("back");
   if(game_type ==1) show_frame=4;
   else show_frame = 1;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("aboutus");
  show_frame = 3;
  }

  }

}

else if(show_frame == 3)
{
   if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/2)
  {
   println("back");
  show_frame = 0;
  }
   else if(mouseX > width/2 && mouseX < width)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
  }
}

else if(show_frame == 4)
{
   if(mouseY > 2*height/16 && mouseY < 3*height/16)
  {
  player_id_show = 0;
  show_frame = 2;
  }
   else if(mouseY > 3*height/16 && mouseY < 4*height/16)
  {
  player_id_show = 1;
  show_frame = 2;
  }
   else if(mouseY > 4*height/16 && mouseY < 5*height/16)
  {
  player_id_show = 2;
  show_frame = 2;
  }
   else if(mouseY > 5*height/16 && mouseY < 6*height/16)
  {
  player_id_show = 3;
  show_frame = 2;
  }
   else if(mouseY > 6*height/16 && mouseY < 7*height/16)
  {
  player_id_show = 4;
  show_frame = 2;
  }
   else if(mouseY > 7*height/16 && mouseY < 8*height/16)
  {
  player_id_show = 5;
  show_frame = 2;
  }
   else if(mouseY > 8*height/16 && mouseY < 9*height/16)
  {
  player_id_show = 6;
  show_frame = 2;
  }
   else if(mouseY > 9*height/16 && mouseY < 10*height/16)
  {
  player_id_show = 7;
  show_frame = 2;
  }
   else if(mouseY > 10*height/16 && mouseY < 11*height/16)
  {
  player_id_show = 8;
  show_frame = 2;
  }
   else if(mouseY > 11*height/16 && mouseY < 12*height/16)
  {
  player_id_show = 9;
  show_frame = 2;
  }
   else if(mouseY > 12*height/16 && mouseY < 13*height/16)
  {
  player_id_show = 10;
  show_frame = 2;
  }

   else if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("back");
  show_frame = 1;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("next");
  show_frame=2;
  }

  }

}

if(alert_flag_ack == 1 && mouseX > width/3 && mouseX < 2*width/3 && mouseY > 2*height/3 && mouseY < height)
{
  player.pause();
  alert_flag_ack = 0;
  flag_ack=0;

}
}

void mouseDragged()
{
if(show_frame == 1)
  {
   if(mouseX > 10 && mouseX < width-20)
  {
   if(mouseY > height/8 && mouseY < height/8 + height/16) h_acc_TH = (mouseX-10)*10/52;
   else if(mouseY > 2*height/8 && mouseY < 2*height/8 + height/16) b_acc_TH = (mouseX-10)*10/52;
   else if(mouseY > 3*height/8 && mouseY < 3*height/8 + height/16) {if(b_tmp_LTH < (mouseX-10)*10/87) b_tmp_UTH = (mouseX-10)*10/87;}
   else if(mouseY > 4*height/8 && mouseY < 4*height/8 + height/16) {if(b_tmp_UTH > (mouseX-10)*10/87) b_tmp_LTH = (mouseX-10)*10/87;}
   else if(mouseY > 5*height/8 && mouseY < 5*height/8 + height/16) {if(h_ret_LTH < (mouseX-10)*10/26) h_ret_UTH = (mouseX-10)*10/26;}
   else if(mouseY > 6*height/8 && mouseY < 6*height/8 + height/16) {if(h_ret_UTH > (mouseX-10)*10/26) h_ret_LTH = (mouseX-10)*10/26;}
  }
  }
}
// UDP Packet receive extended handler
void receive( byte[] data, String ip, int port )
{
  String Alert_type = "alert type";
  data = subset(data, 0, data.length);
  String inString = new String( data );
   if (inString != null)
  {

  udp_log.println(hour()+":"+minute()+":"+second()+ " " + inString);
   int[] nums = int(split(inString, ' '));
  player_id = nums[0];
  h_acc_ar[player_id] = nums[1];
  b_acc_ar[player_id] = nums[2];
  b_tmp_ar[player_id] = nums[3];
  h_ret_ar[player_id] = nums[4];

  summary[player_id] = nums[0]+"   "+nums[1]+"   "+nums[2]+"   "+nums[3]+"   "+nums[4];
   println(summary[player_id]);

  h_acc=h_acc_ar[player_id_show] ;
  b_acc=b_acc_ar[player_id_show] ;
  b_tmp=b_tmp_ar[player_id_show] ;
  h_ret=h_ret_ar[player_id_show] ;

   if(h_acc_ar[player_id] >= h_acc_TH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Head Impact..player"+player_id;}
   else if(b_acc_ar[player_id] >= b_acc_TH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Chest Impact..player"+player_id;}
   else if(h_ret_ar[player_id] == 0 && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; leads_off_flag = 1; Alert_type = "Heart Sensor Leads off..player"+player_id;}
   else if(h_ret_ar[player_id] >= h_ret_UTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Heart Rate too High..player"+player_id;}
   else if(h_ret_ar[player_id] <= h_ret_LTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Heart Rate too Low..player"+player_id;}
   else if(b_tmp_ar[player_id] >= b_tmp_UTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Body Temperture too High ..player"+player_id;}
   else if(b_tmp_ar[player_id] <= b_tmp_LTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Body Temperture too Low..player"+player_id;}
   if(h_ret_ar[player_id_show] != 0){leads_off_flag = 0;}
   if(alert_flag == 1)
  {
  player.loop();
   showMessageDialog(null, "Attention IT'S ALERT ..!!"+Alert_type,"Alert", ERROR_MESSAGE);
  alert_flag = 0;
  alert_flag_ack = 1;
  }
   if(activity_flag[player_id] == 0) activity_flag[player_id] = 1;
   else activity_flag[player_id] =0;



  }
}

//The MediaPlayer must be released when the app closes
void stop()
{
player.close();
minim.stop();
super.stop();
}


 

 

1.2 PC GUI Application with Graphs:These Application designed with Processing-2.2.1.

https://gist.github.com/ravibutani/847400e96ac1d7502cf3

 

/*
  Realtime Player Monitoring System
  
  Sudden Impact Wearable Design Challenge
  
  Sponsered By element14 , Analog Devices, Tektronix and Electrolube
  Special Thanks to Texas Instruments for providing CC3200MOD, MSP430, TLV3402 Samples free of cost
  
  Source code for PC Remote Team Monitoring Application 
  Works with Linux-32, linux-64, windows-32 and windows-64

  Source compiled with processing-2.2.1
   
  By: Ravi Butani
  Date: 23rd April,2015
  e-mail: ravi_butani@yahoo.com
  Source Code is Released Under Creative Commons Attribution-ShareAlike 3.0 Unported Licence
 */

import hypermedia.net.*;
import org.gwoptics.graphics.graph2D.Graph2D;
import org.gwoptics.graphics.graph2D.traces.ILine2DEquation;
import org.gwoptics.graphics.graph2D.traces.RollingLine2DTrace;

PrintWriter udp_log;
int acc1,acc2,temp,hret,pid,ecg=0;
int acc1_flag = 1,acc2_flag = 1,temp_flag = 1,hret_flag = 1;

class eq1 implements ILine2DEquation{
  public double computePoint(double x,int pos) {
   return (int)acc1;
  } 
}

class eq2 implements ILine2DEquation{
  public double computePoint(double x,int pos) {
   return (int)acc2;
  } 
}

class eq3 implements ILine2DEquation{
  public double computePoint(double x,int pos) {
   return (int)temp;
  } 
}
class eq4 implements ILine2DEquation{
  public double computePoint(double x,int pos) {
   return (int)hret;
  } 
}
class eq5  implements ILine2DEquation{
  public double computePoint(double x,int pos) {
   return (int)ecg;
  } 
}

RollingLine2DTrace r1,r2,r3,r4,r5;
Graph2D g;
UDP udp;  // define the UDP object

void setup(){
  size(600,700);
  udp = new UDP( this, 2390 );
   //udp_log = createWriter("//sdcard//rtpms_graph_log//rtpms_graph_log_"+year()+"_"+month()+"_"+day()+"/rtpms_graph_log_"+hour()+"_"+minute()+"_"+second()+".txt");
  udp_log = createWriter("rtpms_graph_log/rtpms_graph_log_"+year()+"_"+month()+"_"+day()+"/rtpms_graph_log_"+hour()+"_"+minute()+"_"+second()+".txt");
  
  udp.listen( true );
  r1 = new RollingLine2DTrace(new eq1() ,100,0.1f);
  r1.setTraceColour(255,0,0);
  r1.setLineWidth(3);

  r2 = new RollingLine2DTrace(new eq2(),100,0.1f);
  r2.setTraceColour(0,255,0);
  r2.setLineWidth(3);

  r3 = new RollingLine2DTrace(new eq3(),100,0.1f);
  r3.setTraceColour(0, 0, 255);
  r3.setLineWidth(3);
  
  r4 = new RollingLine2DTrace(new eq4(),100,0.1f);
  r4.setTraceColour(0, 255, 200);
  r4.setLineWidth(3);
  
  r5 = new RollingLine2DTrace(new eq5(),100,0.1f);
  r5.setTraceColour(255,200,0);
  r5.setLineWidth(2);
  
  g = new Graph2D(this, 5*width/7, 2*height/5, false);
  g.setYAxisMax(100);
  g.setYAxisMin(0);
  g.addTrace(r1);
  g.addTrace(r2);
  g.addTrace(r3);
  g.addTrace(r4);
  g.addTrace(r5);
  g.position.y = height/5;
  g.position.x = width/7;
  g.setYAxisTickSpacing(10);
  g.setXAxisMax(5f);
  g.setXAxisLabel("Time(sec)");
  g.setYAxisLabel("Sensor Readings");
   delay(50);
  
}

void draw(){
  
  background(255);
  g.draw();
   textSize(23);
   textAlign(CENTER, CENTER);
   fill(0);
   text("Realtime Player Monitoring System\nSudden Impact Wearable Design Challenge\nReleased under CC-BY-SA License\nBy Ravi Butani", width/2, height/12+10);
   textSize(24);
   if (acc1_flag == 1)fill(color(255,60,60));
   else fill(color(160,160,160));
   rect(0, 5*height/7, width/4, height/7);
   fill(0);
   text("Head\nImapct\n"+acc1+"(g)", width/8, 5*height/7+height/14);
  
   if (acc2_flag == 1)fill(color(0,255,0));
   else fill(color(160,160,160));
   rect(width/4, 5*height/7, width/4, height/7);
   fill(0);
   text("Chest\nImpact\n"+acc2+"(g)",width/4+width/8, 5*height/7+height/14 );
  
   if (temp_flag == 1)fill(color(60,60,255));
   else fill(color(160,160,160));
   rect(2*width/4, 5*height/7, width/4, height/7);
   fill(0);
   text("Body\nTemperature\n"+temp+"(C)",2*width/4+width/8, 5*height/7+height/14);
  
   if (hret_flag == 1)fill(color(0,255,200));
   else fill(color(160,160,160));
   rect(3*width/4, 5*height/7, width/4, height/7);
   fill(0);
   if(hret == 0) {text("Heart Rate\nLeads Off", 3*width/4+width/8, 5*height/7+height/14);}
   else {text("Heart Rate\n"+hret+"(BMP)", 3*width/4+width/8, 5*height/7+height/14);}
  
   fill(color(250,120,120));
   rect(width/4, 6*height/7+15, width/2, height/7-15);
   fill(0);
   textSize(50);
   text("EXIT", width/2, 6*height/7+height/14+8);
  
}
void receive( byte[] data, String ip, int port ) {  // <-- extended handler

  data = subset(data, 0, data.length);
  String inString = new String( data );
  
   if (inString != null) {
  udp_log.println(hour()+":"+minute()+":"+second()+ " " + inString);
  int[] nums = int(split(inString, ' '));
  pid = nums[0];
  acc1 = nums[1];
  acc2 = nums[2];
  temp = nums[3];
  hret = nums[4];
  ecg = nums[5];


print(nums[0]);
print("\t");
print(nums[1]);
print("\t");
print(nums[2]);
print("\t");
print(nums[3]);
print("\t");
print(nums[4]);
print("\t");
println(nums[5]);

}
}
void mousePressed()
{
if(mouseY > 5*height/7 && mouseY < 6*height/7)
  {
   if(mouseX > 0 && mouseX < width/4)
  {
   if(acc1_flag == 1)acc1_flag=0;
   else acc1_flag = 1;
   if(acc1_flag == 1) r1.setTraceColour(255, 0, 0);
   else r1.setTraceColour(255, 255, 255);
  
  }
   else if(mouseX > width/4 && mouseX < 2*width/4)
  {
   if(acc2_flag == 1)acc2_flag=0;
   else acc2_flag = 1;
   if(acc2_flag == 1) r2.setTraceColour(0, 255, 0);
   else r2.setTraceColour(255, 255, 255);
  
  }
   else if(mouseX > 2*width/4 && mouseX < 3*width/4)
  {
   if(temp_flag == 1)temp_flag=0;
   else temp_flag = 1;
   if(temp_flag == 1) r3.setTraceColour(0, 0,255);
   else r3.setTraceColour(255, 255, 255);
  
  }
   else if(mouseX > 3*width/4 && mouseX < width)
  {
   if(hret_flag == 1)hret_flag=0;
   else hret_flag = 1;
   if(hret_flag == 1) r4.setTraceColour(0, 255, 255);
   else r4.setTraceColour(255, 255, 255);
  
  }
  }
  if(mouseY > 6*height/7 && mouseY < 7*height/7 && mouseX > width/4 && mouseX < 3*width/4)
  {
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
}

 

1.3 Android GUI Monitor Application:These Application designed with Processing-2.0b7 with Google ADK

https://gist.github.com/ravibutani/eb618e7d22cae1ef72af

/*
  Realtime Player Monitoring System
  
  Sudden Impact Wearable Design Challenge
  
  Sponsered By element14 , Analog Devices, Tektronix and Electrolube
  Special Thanks to Texas Instruments for providing CC3200MOD, MSP430, TLV3402 Samples free of cost
  
  Source code for Android Remote Team Monitoring Application 
  Works with Android 4.1.1 or latest

  Source compiled with processing-2.0b7
   
  By: Ravi Butani
  Date: 23rd April,2015
  e-mail: ravi_butani@yahoo.com
  Source Code is Released Under Creative Commons Attribution-ShareAlike 3.0 Unported Licence
 */
import hypermedia.net.*;
import ketai.ui.*;
import apwidgets.*;
APMediaPlayer player;
KetaiVibrate vibe;
PImage bg_frame1,bg_frame0,bg_frame2,bg_frame0_tmp,bg_frame1_tmp,bg_frame2_tmp;//tmpadded
//Thresholds for sensors
int h_acc_TH = 50;
int b_acc_TH = 50;
int h_ret_UTH= 120;
int h_ret_LTH= 60;
int b_tmp_UTH= 40;
int b_tmp_LTH= 20;

//Variables to hold sensor reading
int h_acc = 0, h_acc_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int b_acc = 0,b_acc_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int h_ret = 0,h_ret_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int b_tmp = 0,b_tmp_ar[]={0,0,0,0,0,0,0,0,0,0,0};
int player_id = 0,player_id_show=0; //added

String summary[]={"0 --- --- --- ---","1 --- --- --- ---","2 --- --- --- ---","3 --- --- --- ---","4 --- --- --- ---","5 --- --- --- ---","6 --- --- --- ---","7 --- --- --- ---","8 --- --- --- ---","9 --- --- --- ---","10 --- --- --- ---"};

int show_frame = 0;
int game_type = 0; //0=single player and 1=multiplayer

UDP udp;  // define the UDP object
PrintWriter udp_log;
String Player1 = "Player-";
int alert_flag = 0; 
int alert_flag_ack = 0,flag_ack = 0;
int activity_flag[] = {0,0,0,0,0,0,0,0,0,0,0};
int leads_off_flag = 0;

void setup(){
size(displayWidth,displayHeight);
   orientation(PORTRAIT);
   textAlign(CENTER);
   textSize(23);
   stroke(0);
  udp_log = createWriter("//sdcard//rtpms_monitor_log//rtpms_monitor_log_"+year()+"_"+month()+"_"+day()+"//rtpms_monitor_log_"+hour()+"_"+minute()+"_"+second()+".txt");
   //udp_log = createWriter("rtpms_monitor_log/rtpms_monitor_log_"+year()+"_"+month()+"_"+day()+"/rtpms_monitor_log_"+hour()+"_"+minute()+"_"+second()+".txt");
udp = new UDP( this, 2390 );
  udp.listen( true );
  bg_frame2_tmp = loadImage("about.png");
  bg_frame1_tmp = loadImage("sudden_player.png");
  bg_frame0_tmp = loadImage("simpact.png");
  bg_frame2 = new PImage(width, height);//added
  bg_frame2.copy(bg_frame2_tmp, 0, 0, bg_frame2_tmp.width, bg_frame2_tmp.height, 0, 0, width, height);//added
  bg_frame1 = new PImage(width, height);//added
  bg_frame1.copy(bg_frame1_tmp, 0, 0, bg_frame1_tmp.width, bg_frame1_tmp.height, 0, 0, width, height);//added
  bg_frame0 = new PImage(width, height);//added
  bg_frame0.copy(bg_frame0_tmp, 0, 0, bg_frame0_tmp.width, bg_frame0_tmp.height, 0, 0, width, height);//added
  vibe = new KetaiVibrate(this);
  player = new APMediaPlayer(this); //create new APMediaPlayer
  player.setMediaFile("alert.mp3"); //set the file (files are in data folder)
  player.setVolume(1.0, 1.0);
  player.setLooping(true);
   delay(50);
  
}

void draw()
{
  if(show_frame == 0)
   draw_frame0();
  if(show_frame == 1)
   draw_frame1();
  if(show_frame == 2)
   draw_frame2();
  if(show_frame == 3)
   draw_frame3();
  if(show_frame == 4)
   draw_frame4();
  
}

void draw_frame0() //main frame
{
   background(bg_frame0);
   pushStyle();
   textSize(42);
   if(game_type == 0)fill(color(255,90,90));
   else fill(160);
   rect(width/4, height/2, width/4, 80);
   fill(0);
   pushStyle();
   textSize(34);
   text("Single", width/4+width/8, height/2+32 );
   text("Player", width/4+width/8, height/2+68 );
   popStyle();
   if(game_type == 1)fill(color(255,90,90));
   else fill(160);
   rect(width/2, height/2, width/4, 80);
   fill(0);
   pushStyle();
   textSize(34);
   text("Multi", width/2+width/8, height/2+32 );
   text("Player", width/2+width/8, height/2+68 );
   popStyle();
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("About", width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("Next", 5*width/6, 5*height/6 + height/12-24);
   popStyle();
}

void draw_frame2()//monitor window
{
   background(bg_frame1);
   pushStyle();
   textSize(35);
   if(activity_flag[player_id_show] == 0)fill(color(255,90,90));
   else fill(color(130,130,255));
   rect(20,20,width/3,height/16);
   fill(0);
   text(Player1+player_id_show,20+width/6, height/16);
   popStyle();
  
   fill(color(200,180,210));
   rect(width/9, height/3, width/9, height/3);
   if(h_acc > h_acc_TH) fill(color(255,50,50));
   else fill(color(0,255,0));
   rect(width/9, 2*height/3 - map(h_acc,0,100,0,height/3) , width/9, map(h_acc,0,100,0,height/3));
   fill(0);
   text("HALMET", width/9 + width/18, height/3 - 5 );
   pushStyle();
   textSize(42);
   text(h_acc,width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_______"+h_acc_TH, width/9 , 2*height/3 - map(h_acc_TH,0,100,0,height/3));
   textAlign(CENTER);
   text("0-100G",width/9 + width/18, 2*height/3 + 35);
  
   fill(color(200,180,210));
   rect(3*width/9, height/3, width/9, height/3);
   if(b_acc > b_acc_TH) fill(color(255,50,50));
   else fill(color(0,255,0));
   rect(3*width/9, 2*height/3 - map(b_acc,0,100,0,height/3) , width/9, map(b_acc,0,100,0,height/3));
   fill(0);
   text("CHEST", 3*width/9 + width/18, height/3 - 5 );
   pushStyle();
   textSize(42);
   text(b_acc,3*width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_______"+b_acc_TH, 3*width/9 , 2*height/3 - map(b_acc_TH,0,100,0,height/3));
   textAlign(CENTER);
   text("0-100G",3*width/9 + width/18, 2*height/3 + 35);
  
   fill(color(200,180,210));
   rect(5*width/9, height/3, width/9, height/3);
   if(b_tmp > b_tmp_UTH) fill(color(255,50,50));
   else if(b_tmp < b_tmp_UTH && b_tmp > b_tmp_LTH) fill(color(0,255,0));
   else fill(color(130,130,255));
   rect(5*width/9, 2*height/3 - map(b_tmp,0,60,0,height/3) , width/9, map(b_tmp,0,60,0,height/3));
   fill(0);
   text("TEMP", 5*width/9 + width/18, height/3 - 5);
   pushStyle();
   textSize(42);
   text(b_tmp, 5*width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_______"+b_tmp_UTH, 5*width/9 , 2*height/3 - map(b_tmp_UTH,0,60,0,height/3));
   text("_______"+b_tmp_LTH, 5*width/9 , 2*height/3 - map(b_tmp_LTH,0,60,0,height/3));
   textAlign(CENTER);
   text("0-60C",5*width/9 + width/18, 2*height/3 + 35);
  
   fill(color(200,180,210));
   rect(7*width/9, height/3, width/9, height/3);
   if(h_ret > h_ret_UTH) fill(color(255,50,50));
   else if(h_ret < h_ret_UTH && h_ret > h_ret_LTH) fill(color(0,255,0));
   else fill(color(130,130,255));
   rect(7*width/9, 2*height/3 - map(h_ret,0,200,0,height/3) , width/9, map(h_ret,0,200,0,height/3));
   fill(0);
   text("HEART", 7*width/9 + width/18, height/3 - 5 );
   pushStyle();
   textSize(42);
   text(h_ret, 7*width/9 + width/18, 2*height/3 - 10);
   popStyle();
   textAlign(LEFT);
   text("_______"+h_ret_UTH, 7*width/9 , 2*height/3 - map(h_ret_UTH,0,200,0,height/3));
   text("_______"+h_ret_LTH, 7*width/9 , 2*height/3 - map(h_ret_LTH,0,200,0,height/3));
   textAlign(CENTER);
   text("0-200BPM",7*width/9 + width/18, 2*height/3 + 35);
   if(leads_off_flag == 1)
  {
   fill(color(0,0,0));
   rect(7*width/9, height/3, width/9, height/3);
  }
   pushStyle();
   textSize(42);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Back", width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("About", 5*width/6, 5*height/6 + height/12-24);
   popStyle();
}

void draw_frame1()//Thresholds setting
{
   background(255);
   pushStyle();
   textSize(45);
   fill(0);
   text("Set Thresholds", width/2, height/16);
   textSize(35);
   fill(color(0,255,0));
   rect(10, height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, height/8, map(h_acc_TH,0,100,0,width-20), height/16);
   fill(0);
   text("Helmet Impact Th (G)", width/2, height/8+height/16 - 18 );
   text(h_acc_TH, 10+map(h_acc_TH,0,100,0,width-20) , height/8 - 8);
  
   fill(color(0,255,0));
   rect(10, 2*height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, 2*height/8, map(b_acc_TH,0,100,0,width-20), height/16);
   fill(0);
   text("Chest Impact Th (G)", width/2, 2*height/8+height/16 - 18 );
   text(b_acc_TH, 10+map(b_acc_TH,0,100,0,width-20) , 2*height/8-8);
  
   fill(color(0,255,0));
   rect(10, 3*height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, 3*height/8, map(b_tmp_UTH,0,60,0,width-20), height/16);
   fill(0);
   text("Temp High Th (C)", width/2, 3*height/8+height/16 - 18 );
   text(b_tmp_UTH, 10+map(b_tmp_UTH,0,60,0,width-20) ,3*height/8-8);
  
   fill(color(0,255,0));
   rect(10, 4*height/8, width-20, height/16);
   fill(color(90,90,255));
   rect(10, 4*height/8, map(b_tmp_LTH,0,60,0,width-20), height/16);
   fill(0);
   text("Temp Low Th (C)", width/2, 4*height/8+height/16 - 18 );
   text(b_tmp_LTH, 10+map(b_tmp_LTH,0,60,0,width-20) ,4*height/8-8);
  
   fill(color(0,255,0));
   rect(10, 5*height/8, width-20, height/16);
   fill(color(255,90,90));
   rect(10, 5*height/8, map(h_ret_UTH,0,200,0,width-20), height/16);
   fill(0);
   text("Heart Rate High Th (BPM)", width/2, 5*height/8+height/16 - 18 );
   text(h_ret_UTH, 10+map(h_ret_UTH,0,200,0,width-20) ,5*height/8-8);
  
   fill(color(0,255,0));
   rect(10, 6*height/8, width-20, height/16);
   fill(color(90,90,255));
   rect(10, 6*height/8, map(h_ret_LTH,0,200,0,width-20), height/16);
   fill(0);
   text("Heart Rate Low Th (BPM)", width/2, 6*height/8+height/16 - 18 );
   text(h_ret_LTH, 10+map(h_ret_LTH,0,200,0,width-20) ,6*height/8 - 8);
  
   textSize(42);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Back", width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("Next", 5*width/6, 5*height/6 + height/12-24);
   popStyle();
}

void draw_frame3()//about
{
   background(bg_frame2);
   pushStyle();
   textSize(42);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/2-20, height/12);
   fill(0);
   text("Back", width/4, 5*height/6 + height/12-23 );
  
   fill(color(90,200,200));
   rect(width/2+10, 5*height/6, width/2-20, height/12);
   fill(0);
   text("Exit", 3*width/4, 5*height/6 + height/12-23 );
   popStyle();
}
void draw_frame4()//dashboard
{
   background(255);
   pushStyle();
  
   textSize(45);
   fill(0);
   textAlign(CENTER,CENTER);
   text("Dash Board", width/2, height/32);
   textAlign(LEFT,CENTER);
   textSize(33);
   rectMode(CENTER);
   fill(color(150,150,250));
   rect(width/2, height/16+height/32, width-10, height/16-5);
   fill(0);
   text(" Player Halmet Chest Temp Heart", 8, height/16+height/32 );
  
   textSize(40);
   if(flag_ack == 1)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 2*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[0], 30, 2*height/16+height/32 );
   if(flag_ack == 2)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 3*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[1], 30, 3*height/16+height/32 );
   if(flag_ack == 3)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 4*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[2], 30, 4*height/16+height/32 );
   if(flag_ack == 4)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 5*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[3], 30, 5*height/16+height/32 );
   if(flag_ack == 5)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 6*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[4], 30, 6*height/16+height/32 );
   if(flag_ack == 6)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 7*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[5], 30, 7*height/16+height/32 );
   if(flag_ack == 7)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 8*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[6], 30, 8*height/16+height/32 );
   if(flag_ack == 8)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 9*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[7], 30, 9*height/16+height/32 );
   if(flag_ack == 9)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 10*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[8], 30, 10*height/16+height/32 );
   if(flag_ack == 10)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 11*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[9], 30, 11*height/16+height/32 );
   if(flag_ack == 11)fill(color(255,90,90));
   else fill(color(90,255,90));
   rect(width/2, 12*height/16+height/32, width-10, height/16-5);
   fill(0);
   text(summary[10], 30, 12*height/16+height/32 );
  
   rectMode(CORNER);
   textAlign(CENTER);
   textSize(42);
   fill(color(90,200,200));
   rect(10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Back", width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(width/3+10, 5*height/6, width/3-20, height/12);
   fill(0);
   text("Exit", 3*width/6, 5*height/6 + height/12-24 );
  
   fill(color(90,200,200));
   rect(2*width/3+10, 5*height/6, width/3-20 , height/12);
   fill(0);
   text("Next", 5*width/6, 5*height/6 + height/12-24);
   popStyle();
}
void mousePressed()
{
if(show_frame == 0)
{
if(mouseY > height/2 && mouseY < height/2+80)
  {
   if(mouseX > width/4 && mouseX < 2*width/4)
  {
  game_type=0;
   println("Single");
  }
   if(mouseX > 2*width/4 && mouseX < 3*width/4)
  {
  game_type=1;
   println("Multi");
  }
  }
else if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("aboutus");
  show_frame=3;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("next");
  show_frame = 1;
  }
  
  }
} 
else if(show_frame == 1)
{
  
   if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("back");
  show_frame = 0;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("next");
   //h_acc = h_acc_TH/2;
   //b_acc = b_acc_TH/2;
   //h_ret = (h_ret_UTH + h_ret_LTH)/2;
   //b_tmp = (b_tmp_UTH + b_tmp_LTH)/2;
   if(game_type ==1) show_frame=4;
   else show_frame = 2; 
  }
  }
  
} 
else if(show_frame == 2)
{
   if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("back");
   if(game_type ==1) show_frame=4;
   else show_frame = 1;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("aboutus");
  show_frame = 3;
  }
  
  }

} 

else if(show_frame == 3)
{
   if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/2)
  {
   println("back");
  show_frame = 0;
  }
   else if(mouseX > width/2 && mouseX < width)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  
  }
  }
}
else if(show_frame == 4)
{
   if(mouseY > 2*height/16 && mouseY < 3*height/16)
  {
  player_id_show = 0;
  show_frame = 2;
  }
   else if(mouseY > 3*height/16 && mouseY < 4*height/16)
  {
  player_id_show = 1;
  show_frame = 2;
  }
   else if(mouseY > 4*height/16 && mouseY < 5*height/16)
  {
  player_id_show = 2;
  show_frame = 2;
  }
   else if(mouseY > 5*height/16 && mouseY < 6*height/16)
  {
  player_id_show = 3;
  show_frame = 2;
  }
   else if(mouseY > 6*height/16 && mouseY < 7*height/16)
  {
  player_id_show = 4;
  show_frame = 2;
  }
   else if(mouseY > 7*height/16 && mouseY < 8*height/16)
  {
  player_id_show = 5;
  show_frame = 2;
  }
   else if(mouseY > 8*height/16 && mouseY < 9*height/16)
  {
  player_id_show = 6;
  show_frame = 2;
  }
   else if(mouseY > 9*height/16 && mouseY < 10*height/16)
  {
  player_id_show = 7;
  show_frame = 2;
  }
   else if(mouseY > 10*height/16 && mouseY < 11*height/16)
  {
  player_id_show = 8;
  show_frame = 2;
  }
   else if(mouseY > 11*height/16 && mouseY < 12*height/16)
  {
  player_id_show = 9;
  show_frame = 2;
  }
   else if(mouseY > 12*height/16 && mouseY < 13*height/16)
  {
  player_id_show = 10;
  show_frame = 2;
  }
  
   else if(mouseY > 5*height/6 && mouseY < 5*height/6+height/12)
  {
   if(mouseX > 0 && mouseX < width/3)
  {
   println("back");
  show_frame = 1;
  }
   else if(mouseX > width/3 && mouseX < 2*width/3)
  {
   println("exit");
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
   else if(mouseX > 2*width/3 && mouseX < width)
  {
   println("next");
  show_frame=2;
  }
  
  }

} 

if(alert_flag_ack == 1 && mouseX > width/3 && mouseX < 2*width/3 && mouseY > 2*height/3 && mouseY < height)
{
  player.pause();
  alert_flag_ack = 0;
  flag_ack=0;
}
}

void mouseDragged()
{
if(show_frame == 1)
  {
   if(mouseX > 10 && mouseX < width-20)
  {
   if(mouseY > height/8 && mouseY < height/8 + height/16) h_acc_TH = (mouseX-10)*10/52;
   else if(mouseY > 2*height/8 && mouseY < 2*height/8 + height/16) b_acc_TH = (mouseX-10)*10/52;
   else if(mouseY > 3*height/8 && mouseY < 3*height/8 + height/16) {if(b_tmp_LTH < (mouseX-10)*10/87) b_tmp_UTH = (mouseX-10)*10/87;}
   else if(mouseY > 4*height/8 && mouseY < 4*height/8 + height/16) {if(b_tmp_UTH > (mouseX-10)*10/87) b_tmp_LTH = (mouseX-10)*10/87;}
   else if(mouseY > 5*height/8 && mouseY < 5*height/8 + height/16) {if(h_ret_LTH < (mouseX-10)*10/26) h_ret_UTH = (mouseX-10)*10/26;}
   else if(mouseY > 6*height/8 && mouseY < 6*height/8 + height/16) {if(h_ret_UTH > (mouseX-10)*10/26) h_ret_LTH = (mouseX-10)*10/26;}
  }
  }
}
// UDP Packet receive extended handler
void receive( byte[] data, String ip, int port )
{ 
  String Alert_type = "alert type";
  data = subset(data, 0, data.length);
  String inString = new String( data );
   if (inString != null)
  {
  
  udp_log.println(hour()+":"+minute()+":"+second()+ " " + inString);
   int[] nums = int(split(inString, ' '));
  player_id = nums[0];
  h_acc_ar[player_id] = nums[1];
  b_acc_ar[player_id] = nums[2];
  b_tmp_ar[player_id] = nums[3];
  h_ret_ar[player_id] = nums[4];
  
  summary[player_id] = nums[0]+"   "+nums[1]+"   "+nums[2]+"   "+nums[3]+"   "+nums[4];
   println(summary[player_id]);
  
  h_acc=h_acc_ar[player_id_show] ;
  b_acc=b_acc_ar[player_id_show] ;
  b_tmp=b_tmp_ar[player_id_show] ;
  h_ret=h_ret_ar[player_id_show] ;
  
   if(h_acc_ar[player_id] >= h_acc_TH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Head Impact..player"+player_id;}
   else if(b_acc_ar[player_id] >= b_acc_TH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Chest Impact..player"+player_id;}
   else if(h_ret_ar[player_id] == 0 && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; leads_off_flag = 1; Alert_type = "Heart Sensor Leads off..player"+player_id;} 
   else if(h_ret_ar[player_id] >= h_ret_UTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Heart Rate too High..player"+player_id;} 
   else if(h_ret_ar[player_id] <= h_ret_LTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Heart Rate too Low..player"+player_id;} 
   else if(b_tmp_ar[player_id] >= b_tmp_UTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Body Temperture too High ..player"+player_id;}
   else if(b_tmp_ar[player_id] <= b_tmp_LTH && alert_flag_ack == 0 && flag_ack == 0){flag_ack=player_id+1; alert_flag = 1; Alert_type = "Body Temperture too Low..player"+player_id;}
   if(h_ret_ar[player_id_show] != 0){leads_off_flag = 0;}
   if(alert_flag == 1)
  {
  KetaiAlertDialog.popup(this, "Attention IT'S ALERT ..!!",Alert_type);
  vibe.vibrate(1000);
  player.start();
  alert_flag = 0;
  alert_flag_ack = 1;
  }
   if(activity_flag[player_id] == 0) activity_flag[player_id] = 1;
   else activity_flag[player_id] =0;
  }
}
//The MediaPlayer must be released when the app closes
public void onDestroy() {

  super.onDestroy(); //call onDestroy on super class
  if(player!=null) { //must be checked because or else crash when return from landscape mode
  player.release(); //release the player

  }
}


 

1.4 Android GUI Application with Graphs:These Application designed with Processing-2.0b7 with Google ADK

https://gist.github.com/ravibutani/0a440b6cacb87ee6b598

 

/*
  Realtime Player Monitoring System
  
  Sudden Impact Wearable Design Challenge
  
  Sponsered By element14 , Analog Devices, Tektronix and Electrolube
  Special Thanks to Texas Instruments for providing CC3200MOD, MSP430, TLV3402 Samples free of cost
  
  Source code for Android Remote Team Monitoring Application with realtime graph 
  Works with Android 4.1.1 or latest

  Source compiled with processing-2.0b7
   
  By: Ravi Butani
  Date: 23rd April,2015
  e-mail: ravi_butani@yahoo.com
  Source Code is Released Under Creative Commons Attribution-ShareAlike 3.0 Unported Licence
 */
import hypermedia.net.*;
import org.gwoptics.graphics.graph2D.Graph2D;
import org.gwoptics.graphics.graph2D.traces.ILine2DEquation;
import org.gwoptics.graphics.graph2D.traces.RollingLine2DTrace;

PrintWriter udp_log;
int acc1,acc2,temp,hret,pid,ecg=0;
int acc1_flag = 1,acc2_flag = 1,temp_flag = 1,hret_flag = 1;

class eq1 implements ILine2DEquation{
public double computePoint(double x,int pos) {
return (int)acc1;
}
}

class eq2 implements ILine2DEquation{
public double computePoint(double x,int pos) {
return (int)acc2;
}
}

class eq3 implements ILine2DEquation{
public double computePoint(double x,int pos) {
return (int)temp;
}
}
class eq4 implements ILine2DEquation{
  public double computePoint(double x,int pos) {
   return (int)hret;
  } 
}
class eq5  implements ILine2DEquation{
  public double computePoint(double x,int pos) {
   return (int)ecg;
  } 
}

RollingLine2DTrace r1,r2,r3,r4,r5;
Graph2D g;
UDP udp;  // define the UDP object

void setup(){
size(displayWidth,displayHeight);
   orientation(PORTRAIT);
  udp = new UDP( this, 2390 );
  udp_log = createWriter("//sdcard//rtpms_graph_log//rtpms_graph_log_"+year()+"_"+month()+"_"+day()+"/rtpms_graph_log_"+hour()+"_"+minute()+"_"+second()+".txt");
   //udp_log = createWriter("rtpms_graph_log/rtpms_graph_log_"+year()+"_"+month()+"_"+day()+"//rtpms_graph_log_"+hour()+"_"+minute()+"_"+second()+".txt");
  
  udp.listen( true );
r1 = new RollingLine2DTrace(new eq1() ,100,0.1f);
r1.setTraceColour(255,0,0);
r1.setLineWidth(3);

r2 = new RollingLine2DTrace(new eq2(),100,0.1f);
r2.setTraceColour(0,255,0);
r2.setLineWidth(3);

r3 = new RollingLine2DTrace(new eq3(),100,0.1f);
r3.setTraceColour(0, 0, 255);
  r3.setLineWidth(3);
  
  r4 = new RollingLine2DTrace(new eq4(),100,0.1f);
  r4.setTraceColour(0, 255, 200);
  r4.setLineWidth(3);
  
  r5 = new RollingLine2DTrace(new eq5(),100,0.1f);
  r5.setTraceColour(255,200,0);
  r5.setLineWidth(2);
  
  g = new Graph2D(this, 5*width/7, 2*height/5, false);
g.setYAxisMax(100);
  g.setYAxisMin(0);
g.addTrace(r1);
g.addTrace(r2);
g.addTrace(r3);
  g.addTrace(r4);
  g.addTrace(r5);
  g.position.y = height/5;
g.position.x = width/7;
g.setYAxisTickSpacing(10);
g.setXAxisMax(5f);
  g.setXAxisLabel("Time(sec)");
  g.setYAxisLabel("Sensor Readings");
   delay(50);
  
}

void draw(){
  
background(255);
  g.draw();
   textSize(25);
   textAlign(CENTER, CENTER);
   fill(0);
   text("Realtime Player Monitoring System\nSudden Impact Wearable Design Challenge\nReleased under CC-BY-SA License\nBy Ravi Butani", width/2, height/12);
   textSize(24);
   if (acc1_flag == 1)fill(color(255,60,60));
   else fill(color(160,160,160));
   rect(0, 5*height/7, width/4, height/7);
   fill(0);
   text("Head\nImapct\n"+acc1+"(g)", width/8, 5*height/7+height/14);
  
   if (acc2_flag == 1)fill(color(0,255,0));
   else fill(color(160,160,160));
   rect(width/4, 5*height/7, width/4, height/7);
   fill(0);
   text("Chest\nImpact\n"+acc2+"(g)",width/4+width/8, 5*height/7+height/14 );
  
   if (temp_flag == 1)fill(color(60,60,255));
   else fill(color(160,160,160));
   rect(2*width/4, 5*height/7, width/4, height/7);
   fill(0);
   text("Body\nTemperature\n"+temp+"(C)",2*width/4+width/8, 5*height/7+height/14);
  
   if (hret_flag == 1)fill(color(0,255,200));
   else fill(color(160,160,160));
   rect(3*width/4, 5*height/7, width/4, height/7);
   fill(0);
   if(hret == 0) {text("Heart Rate\nLeads Off", 3*width/4+width/8, 5*height/7+height/14);}
   else {text("Heart Rate\n"+hret+"(BMP)", 3*width/4+width/8, 5*height/7+height/14);}
  
   fill(color(250,120,120));
   rect(width/4, 6*height/7+15, width/2, height/7-15);
   fill(0);
   textSize(50);
   text("EXIT", width/2, 6*height/7+height/14+8);
  
}
void receive( byte[] data, String ip, int port ) {  // <-- extended handler

  data = subset(data, 0, data.length);
  String inString = new String( data );
  
   if (inString != null) {
  udp_log.println(hour()+":"+minute()+":"+second()+ " " + inString);
  int[] nums = int(split(inString, ' '));
  pid = nums[0];
  acc1 = nums[1];
  acc2 = nums[2];
  temp = nums[3];
  hret = nums[4];
  ecg = nums[5];


print(nums[0]);
print("\t");
print(nums[1]);
print("\t");
print(nums[2]);
print("\t");
print(nums[3]);
print("\t");
print(nums[4]);
print("\t");
println(nums[5]);

}
}
void mousePressed()
{
if(mouseY > 5*height/7 && mouseY < 6*height/7)
  {
   if(mouseX > 0 && mouseX < width/4)
  {
   if(acc1_flag == 1)acc1_flag=0;
   else acc1_flag = 1;
   if(acc1_flag == 1) r1.setTraceColour(255, 0, 0);
   else r1.setTraceColour(255, 255, 255);
  
  }
   else if(mouseX > width/4 && mouseX < 2*width/4)
  {
   if(acc2_flag == 1)acc2_flag=0;
   else acc2_flag = 1;
   if(acc2_flag == 1) r2.setTraceColour(0, 255, 0);
   else r2.setTraceColour(255, 255, 255);
  
  }
   else if(mouseX > 2*width/4 && mouseX < 3*width/4)
  {
   if(temp_flag == 1)temp_flag=0;
   else temp_flag = 1;
   if(temp_flag == 1) r3.setTraceColour(0, 0,255);
   else r3.setTraceColour(255, 255, 255);
  
  }
   else if(mouseX > 3*width/4 && mouseX < width)
  {
   if(hret_flag == 1)hret_flag=0;
   else hret_flag = 1;
   if(hret_flag == 1) r4.setTraceColour(0, 255, 255);
   else r4.setTraceColour(255, 255, 255);
  
  }
  }
  if(mouseY > 6*height/7 && mouseY < 7*height/7 && mouseX > width/4 && mouseX < 3*width/4)
  {
  udp_log.flush(); // Writes the remaining data to the file
  udp_log.close(); // Finishes the file
   exit();
  }
}

 

Why to worry About Big Codes...??

 

I am Attaching here executable of All above codes So you can easily try and evaluate these application...

Also I am attaching my entire Processing Sketchbook here so You can just change Sketchbook location for processing and start the development where I have done so far...


Attachment1: ANDROID_APK.rar has two *.apk file

    1. RTPMS_AD_debug.apk (Multiplayer support and No Graphs)

    2. RTPMS_GRAPH_AD_debug.apk (Singleplayer support and With Graphs)

    Just move these .apk file to your android devices and install all done....

    (May be for few android devices font size will changed in this app...)


Attachment2: RTPMS_GRAPH_PC_MIN.rar

This attachment contain executable for Singleplayer support and With Graphs GUI App for windows32/64 and Linux32/64. You needs Java7 or later to run these executable.


Attachment3: RTPMS_PC_MIN.rar

This attachment contain executable for Multiplayer support and No Graphs GUI App for windows32/64 and Linux32/64. You needs Java7 or later to run these executable.


Attachment4: PROCESSING_RTPMS_SKETCHBOOK.rar

want to change the app for your need just unzip and change sketchbook location of your processing and make changes and build...Android related sketches have _AD and they needs

processing-2.0b7 with Android Development kit from Google. Sketch with _PC runs with Processing 2.2.1 or later on any windows/Linux PC.. I haven't test these on Mac but you can if you have access of Mac pc..


Testing of PC Application in Stand Alone Mode..


I have usd https://packetsender.com/ and Packet format in ascii is ..

Player_id Head_acc Body_Acc Body_Temp Heart_Rate (Each Separated With single Space)

e.g. 2 3 5 34 78


Port is 2390

Communication is UDP

ipaddress : localhost or ::1

aa.png


bb.png

Note all application uses same port 2390 so on a system only one can run at a time.. on mutiple system multiple can run at a time..


in next post I will show feature of all these app in short video and release mcu related code and hardware circuit schematic in CC-BY-SA


Please Try these. Your Valuable feedback/suggestion are welcome here...


Thanks


Ravi