/*
* iPad_UI.java
*
* Created on 2011年6月24日, 下午9:22
*/
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
/**
*
* @author Administrator
*/
public class iPad_UI extends javax.swing.JFrame implements Runnable {
portfixture fixture;
Thread t=null;
boolean active=false;
int item=0,itemold;
boolean teststate=true;
//====================================================================
String[][] test_item={
{"Check SN"},
{"Debug on/off test"},
{"Diag enter and exit test"},
{"Buzzer on/off test"},
{"Battary power on/off test"},
{"All button cycle test"},
{"Hallsensor on/off test"},
{"1k tone to HP test"},
{"Detect HP to mikey test"},
{"Detect Gloal headset test"},
{"Detect China headset test"},
{"By pass model test(270,330)mA"},
{"Nomal model test(90,110)mA"},
{"1k tone to SPK test"},
{"Firewire on/off test"},
};
//====================================================================
/** Creates new form iPad_UI */
public iPad_UI() {
initComponents();
jTextArea1.setForeground(Color.RED);
jTable3.setEnabled(false);
jTable3.clearSelection();
fixture=new portfixture();
Table_Init();
this.setLocation((this.getToolkit().getScreenSize().width-this.getWidth())/2,(this.getToolkit().getScreenSize().height-this.getHeight())/2);
}
//====================================================================
public void delay(int time){
try{
t.sleep(time);
}catch(Exception e){}
}
//====================================================================
public void PrintLog(String s){
StringBuffer buffer = new StringBuffer();
buffer.append(jTextArea1.getText());
buffer.append(s);
jTextArea1.setText(buffer.toString());
jTextArea1.setCaretPosition(jTextArea1.getText().length());
}
//====================================================================
public String GetSN(int snlength,int row,int col){
//jTable3.clearSelection();
//jTable3.setRowSelectionInterval(row,col);
if(jTextField1.getText().length()==snlength){
this.PrintLog("Record SN (");
this.PrintLog(jTextField1.getText());
this.PrintLog(")pass\n");
jTextField1.setEditable(false);
jTable3.setValueAt("pass",row,col);
return jTextField1.getText();
}else{
this.PrintLog("Record SN (");
this.PrintLog(jTextField1.getText());
this.PrintLog(")error\n");
jTextField1.setText("");
jTextField1.setEditable(true);
jTable3.setValueAt("fail",row,col);
teststate=false;
return null;
}
}
//====================================================================
public void Debug(int row,int col){
//jTable3.clearSelection();
//jTable3.setRowSelectionInterval(row,col);
//-----------------------------------------
this.PrintLog("PC send to Fixture:DEBUGON\r\n");
String s1=fixture.send_and_get("DEBUGON\r\n",50);
this.PrintLog("PC get from Fixture:"+s1);
//-----------------------------------------
this.PrintLog("PC send to Fixture:DEBUGOFF\r\n");
String s2=fixture.send_and_get("DEBUGOFF\r\n",50);
this.PrintLog("PC get from Fixture:"+s2);
//-----------------------------------------
if((s1.equals("ENTER DEBUG MODE\r\n"))&&(s2.equals("DEBUGOFF\r\nOUT DEBUG MODE\r\n"))){
this.PrintLog("Result:pass\n");
jTable3.setValueAt("pass",row,col);
}else{
this.PrintLog("Result:fail\n");
jTable3.setValueAt("fail",row,col);
teststate=false;
}
}
//====================================================================
public void Diag(int row,int col){
//jTable3.clearSelection();
//jTable3.setRowSelectionInterval(row,col);
//-----------------------------------------
this.PrintLog("PC send to Fixture:ENTERDIAGSTART\r\n");
String s1=fixture.send_and_get("ENTERDIAGSTART\r\n",50);
this.PrintLog("PC get from Fixture:"+s1);
//-----------------------------------------
this.PrintLog("PC send to Fixture:ENTERDIAGSTOP\r\n");
String s2=fixture.send_and_get("ENTERDIAGSTOP\r\n",50);
this.PrintLog("PC get from Fixture:"+s2);
//-----------------------------------------
if((s1.equals("OK\r\n"))&&(s2.equals("OK\r\n"))){
this.PrintLog("Result:pass\n");
jTable3.setValueAt("pass",row,col);
}else{
this.PrintLog("Result:fail\n");
jTable3.setValueAt("fail",row,col);
teststate=false;
}
}
//====================================================================
public void Buzzer(int row,int col){
//jTable3.clearSelection();
//jTable3.setRowSelectionInterval(row,col);
//-----------------------------------------
this.PrintLog("PC send to Fixture:BUZRON\r\n");
String s1=fixture.send_and_get("BUZRON\r\n",50);
this.PrintLog("PC get from Fixture:"+s1);
//-----------------------------------------
this.PrintLog("PC send to Fixture:BUZROFF\r\n");
String s2=fixture.send_and_get("BUZROFF\r\n",50);
this.PrintLog("PC get from Fixture:"+s2);
//-----------------------------------------
if((s1.equals("OK\r\n"))&&(s2.equals("OK\r\n"))){
this.PrintLog("Result:pass\n");
jTable3.setValueAt("pass",row,col);
}else{
this.PrintLog("Result:fail\n");
jTable3.setValueAt("fail",row,col);
teststate=false;
}
}
//====================================================================
public void Battary(int row,int col){
//jTable3.clearSelection();
//jTable3.setRowSelectionInterval(row,col);
//-----------------------------------------
this.PrintLog("PC send to Fixture:POWERON\r\n");
String s1=fixture.send_and_get("POWERON\r\n",50);
this.PrintLog("PC get from Fixture:"+s1);
//-----------------------------------------
this.PrintLog("PC send to Fixture:POWEROFF\r\n");
String s2=fixture.send_and_get("POWEROFF\r\n",50);
this.PrintLog("PC get from Fixture:"+s2);
//-----------------------------------------
if((s1.equals("OK\r\n"))&&(s2.equals("OK\r\n"))){
this.PrintLog("Result:pass\n");
jTable3.setValueAt("pass",row,col);
}else{
this.PrintLog("Result:fail\n");
jTable3.setValueAt("fail",row,col);
teststate=false;
}
}
//====================================================================
public void Button(int row,int col){
//jTable3.clearSelection();
//jTable3.setRowSelectionInterval(row,col);
//-----------------------------------------
this.PrintLog("PC send to Fixture:BUTTONON\r\n");
String s1=fixture.send_and_get("BUTTONON\r\n",50);
this.PrintLog("PC get from Fixture:"+s1);
//-----------------------------------------
this.PrintLog("PC send to Fixture:BUTTONOFF\r\n");
String s2=fixture.send_and_get("BUTTONOFF\r\n",50);
this.PrintLog("PC get from Fixture:"+s2);
//-----------------------------------------
if((s1.equals("OK\r\n"))&&(s2.equals("OK\r\n"))){
this.PrintLog("Result:pass\n");