macsbug

Just another WordPress.com site

ALTITUDE PROCESSOR FLAG WORD MONITOR demo for Processeing

leave a comment »

ALTITUDE PROCESSOR FLAG WORD demo for Processeing                                     2014.09.21

Without Monitor Circuit(Arinc 429 Receiver) of Arduino

//---------------------------------------------------------------------------
// A429RX_ALT_FLAG_demo_140915
// XXX-XXX RADIO ALT TRANSCEIVER : Altitude Processor Flag Word Minitor
// ORG SerialEvent                                      2010.10.10    S.mac
// REV Color bar,Hi Speed,SerialEvent->Draw,Vertical    2010.10.11-13 S.mac
// REV Waveform display,PAUSE Button & Key              2010.10.18    S.mac
// REV x display size  set, Demo mode                   2014.09.21    S.mac
// INFO PortA.available()>=34
// REC DISABLE on=9.8msec/off=25ms,A429 32bit=2.54ms,Serial=2ms
//---------------------------------------------------------------------------
import processing.serial.*;         // serial liblary include
Serial PortA;                       // seria read position
int c=1;                            // Read data count
int d=2;                            // xline width
int x1=350;                         // xline start position
int xw=1020;                        // x width 700,1020,
int pwr=0;                          // PAUSE Position
int pcg=0;                          // Pause memo
char [] bit = new char [33];        // A429 SERIAL RECEIVE DATA Buffer
char [] bix = new char [33];        // before 32bit
String [] m = {                     // FLAG WORD 32BIT LIST(0 to 31)
  "PAD (always high)","ALTIMETER STATUS","MONITOR STATUS","COUNTER MODES",
  "PAD (always low)","INPUT (Discreate:Arinc,AID,ANT,flag)",
  "UART","BINARY ALTITUDE COMPARISION","SELF-TEST","SELF-TEST DELTA",
  "SELF-TEST ERROR","LIFSPDR","HIFSPDR","LIFSPST","LO IF SIGNAL PRESENCE",
  "HI IF SIGNAL PRESENCE","40 FOOT AID","57 FOOT AID","80 FOOT AID",
  "RAM TEST (RAM CHECKS OK)","ROM TEST (ROM CHECKS OK)","SDI-(LSB)",
  "SDI-(MSB)","FRONT PANEL SELF-TEST","MATH","VALID DATA",
  "CURRENT ALTIMETER MODE-(LSB)","CURRENT ALTIMETER MODE-(MSB)",
  "BAND SWITCHES-(LSB)","BAND SWITCHES","BAND SWITCHES-(MSB)","PARITY"};
String [] n = {"01","02","03","04","05","06","07","08","09","10",
               "11","12","13","14","15","16","17","18","19","20",
               "21","22","23","24","25","26","27","28","29","30","31","32"};
//---------------------------------------------------------------------------
void setup(){                                    // Windows : COM*
  PortA=new Serial(this,"/dev/cu.usbserial-A900acDW",115200);// 2msec(32bit)
  size(xw,740);                                  // Graphic area size(x,y)
  noStroke();background(0);                      // BackGround Color=Black
  fill(255); text( "XXX-XXX ALTITUDE PROCESSOR FLAG WORD",100,0,600,48);
  //fill(255); text( "*.*.*.co.,Ltd. / RA Group",480,0,600,48);
  //fill(255); text( "by oono 2010",492,20,600,48);                       
  for ( int i=0; i<32; i=i+1 ){ fill(255); text( n[i],20,60+20*i,600,48);
        fill(255); text( m[i],100,60+20*i,600,48);}
  for ( int i=0; i<640; i=i+20 ){ fill(153,255,0); rect(50,60+i,34,12);}
  fill(255,0,0); rect(50,20,17,12); fill(120,140,255); rect(67,20,17,12);
  fill(255); text( "bit    1   0     FLAG WORD",20,19,600,48);  
  noStroke();fill(120,140,255);rect(x1-d,60,d*2,635);  
  setButton(120,140,255);                        // PAUSE Button color set
}
//---------------------------------------------------------------------------
// ARINC429 SERIAL DATA RECEIVE AND DATA STORE   //
void draw(){                                     //
  if ( pwr==0 ){ noStroke();                     // PAUSE ON/OFF pwr=0(OFF)
  fill(120,140,255);rect(x1+d,60,d*2,635);       // wave start bar
  stroke(255); 
                                                 // Line Set
  //if (PortA.available()>=34){                    // 32+2Bit(end data)   *****
    for ( int i=0; i<32; i=i+1 ){                // 32bit = 0 to 31
     // bit[i] = PortA.readChar();                 // SerialRead & Store  *****
     if ( random(10) < 5 ){ bit[i]  = '0';}      //                       *****
     if ( random(10) > 4 ){ bit[i]  = '1';}      //                       *****
   
      int HI=62+i*20; int LO=70+i*20;            // LOGIC Level HI/LO pos
      if (bit[i] != bix[i]){line(x1,LO,x1,HI);}  // bit changed V-line
      if (bit[i] == '0'){fill(120,140,255);      // bit 0 --------------
       line(x1,LO,x1+d,LO);                      // bit 0 level set LO
      }else{ println(m[i]);fill(255,0,0);        // bit 1 , STATUS print
       line(x1,HI,x1+d,HI);                      // bit 1 level set HI
      }                                          // --------------------
      rect(50,60+i*20,34,12);                    // Draw bit
      bix[i]=bit[i];                             // store bit "0" or "1"
    }                                            // --------------------
    x1=x1+d;                                     // next x1
    if ( x1 > xw-10 ){ x1=350;}                  // x line reset
    PortA.clear();                               // Serial Port Clear
    println (c);                                 // Nomen display
    c=c+1;                                       // Read data count up
  //}                                              //                    *****
  }                                              // --------------------
   if(keyPressed) {                              // PAUSE Key ( p or P )
    if(key == 'p' || key == 'P'){ PauseSet();}   // PAUSE ON/OFF Button set
   }                                             //
  PortA.clear();                                 // Serial Port Clear
}                                                //
//---------------------------------------------------------------------------
void mousePressed(){                             // Mouse press
  if(mouseX>340 && mouseX<420 && mouseY>35 && mouseY<55){
    PauseSet();}                                 // PAUSE ON/OFF Button set
}                                                //
//---------------------------------------------------------------------------
void setButton(color c1,color c2,color c3){      // PAUSE Button Bar set
  fill(c1,c2,c3); rect(345,35,73,20);            // Bar color set
  fill(255); text("PAUSE",363,50);               // text set
}                                                //
//---------------------------------------------------------------------------
void PauseSet(){                                 // PAUSE ON/OFF set
  if ( pwr==0) { pcg=1; setButton(255,0,0);}     // PAUSE ON  Button set
  else { pcg=0; setButton(120,140,255);}         // PAUSE OFF Button set
  pwr = pcg; delay(500); PortA.clear();          // PAUSE memo, chataring
}                                                //
//---------------------------------------------------------------------------

Written by macsbug

9月 21, 2014 @ 3:26 am

カテゴリー: Processing

コメントを残す

以下に詳細を記入するか、アイコンをクリックしてログインしてください。

WordPress.com ロゴ

WordPress.com アカウントを使ってコメントしています。 ログアウト / 変更 )

Twitter 画像

Twitter アカウントを使ってコメントしています。 ログアウト / 変更 )

Facebook の写真

Facebook アカウントを使ってコメントしています。 ログアウト / 変更 )

Google+ フォト

Google+ アカウントを使ってコメントしています。 ログアウト / 変更 )

%s と連携中

%d人のブロガーが「いいね」をつけました。