macsbug

Just another WordPress.com site

MONITOR PROCESSOR FLAG WORD MONITOR demo of Processing

leave a comment »

「32bit デジタル・アナライザー」のデモ版で、Arinc 429 Receiver Board は不要です。       2014.09.21

Processing 言語により、Mac 叉はWindows に表示します。

MONITOR PROCESSOR FLAG WORD MONITOR demo of Processing
Without Monitor Circuit( Arinc 429 Receiver) of Arduino

//---------------------------------------------------------------------------
// A429RX_MON_FLAG_demo_140915
// XXX-XXX RADIO ALT TRANSCEIVER MONITOR Processor Flag Word MONITOR
// ORG ALTITUDE FLAG WORD Copy                          2010.12.21    S.mac
// REV Mode 0,2,3 , PAD check & info                    2010.12.22    S.mac
// REV x display size, demo mode                        2014.09.21    S.mac
// 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;                        // 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","MATH","COUNTER MODE",
  "PAD (always low)","SELF-TEST","SELF-TEST DELTA","SELF-TEST ERROR",
  "MONITOR","PASS COUNTER","MODE ERROR","UART","SSM",
  "BINALY ALTITUDE COMPARISION","VALID DATA","LIFSPST","INPUT",
  "CURRENT ALTIMETER MODE-(LSB)","CURRENT ALTIMETER MODE-(MSB)",
  "LO IF SIGNAL PRESENCE","HI IF SIGNAL PRESENCE","LIFSPDR","HIFSPDR",
  "PAD","40 FOOT AID","57 FOOT AID","80 FOOT AID","RAM PASS LOW",
  "RAM PASS HIGH","ROM PASS","POWER","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"};      // bit No 01-32
//---------------------------------------------------------------------------
void setup(){                                    // Windows : COM*
  //PortA=new Serial(this,"COM4",115200);          // 2msec(32bit)
  PortA=new Serial(this,"/dev/cu.usbserial-A900acDW",115200);// Mac
  size(xw,740);                                  // Graphic area size(x,y)
  noStroke();background(0);                      // BackGround Color=Black
  fill(255); text("XXX-XXX MONITOR 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,22,17,12); fill(120,140,255); rect(67,22,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 DISPLAY      //
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)    *****
  //---------------------------------------------// 32bit Reading
    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';}      //                       *****
    //PortA.clear();                               // Serial Port Clear    *****
    }                                            //                        *****
  //---------------------------------------------//
    if ( bit[0]=='1' && bit[4]=='0'){            // PAD 1 or 2 check
  //---------------------------------------------// 32bit Display
    for ( int i=0; i<32; i=i+1 ){                // 32bit = 0 to 31
      int HI=62+i*20; int LO=70+i*20;            //_LOGIC 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);      // bit0 fill color set
       line(x1,LO,x1+d,LO);                      //_bit0 LO Line draw
      }                                          // END bit 0
      else{ println(m[i]);fill(255,0,0);         // bit1 print,fill set
       line(x1,HI,x1+d,HI);                      //_bit1 HI line draw
      }                                          // END bit 1
      rect(50,60+i*20,34,12);                    // flag word bit 0-31
      bix[i]=bit[i];                             //_store bit "0" or "1"
    }                                            // END 32bit Display
  //---------------------------------------------// MODE Display Info
    fill(0,0,0); rect(200,22,50,12);             // disply & Proc window
    if (bit[17]=='0' && bit[18]=='0'){           // CAM L=0,CAM H=0
      println("MODE 0");                         // Processing window PRT
      fill(255);text("MODE 0",200,19,600,48);}   // display Print
    if (bit[17]=='0' && bit[18]=='1'){           // CAM L=0,CAM H=1
      println("MODE 2");                         // Processing window PRT
      fill(255);text("MODE 2",200,19,600,48);}   // display Print
    if (bit[17]=='1' && bit[18]=='1'){           // CAM L=1,CAM H=1
      println("MODE 3");                         // Processing window PRT
      fill(255);text("MODE 3",200,19,600,48);}   // display Print
  //---------------------------------------------//
    x1=x1+d;                                     //_next x1
    if ( x1>xw-10 ){ x1=350;}                    //_x line reset
    println (c);                                 // Count display
    c=c+1;                                       // Read data count up
  //---------------------------------------------//
    }                                            // END PAD check
  //---------------------------------------------//   
  //}                                              // END PortA.available   *****
  }                                              // END PAUSE
  //---------------------------------------------//  
   if(keyPressed) {                              // PAUSE Key ( p or P )
    if(key == 'p' || key == 'P'){ PauseSet();}   // PAUSE ON/OFF Button set
   }                                             //
  //PortA.clear();                               // Serial Port Clear
}                                                // END Void draw
//---------------------------------------------------------------------------
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:45 am

カテゴリー: Processing

コメントを残す

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

WordPress.com ロゴ

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

Twitter 画像

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

Facebook の写真

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

Google+ フォト

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

%s と連携中

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