diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-02-20 16:15:32 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-02-20 16:15:32 +0200 |
| commit | fcdc6fb98b59c6c2da99b1f3c57542e3e0af8fb8 (patch) | |
| tree | 72e249f2f8d9a6c6f906aa5af167737fec7a7804 /Software/Stubs Collection | |
| parent | 893f6576cc6806c1efeaf46e1bae767adf4c0c9e (diff) | |
| download | Tango-fcdc6fb98b59c6c2da99b1f3c57542e3e0af8fb8.tar.gz Tango-fcdc6fb98b59c6c2da99b1f3c57542e3e0af8fb8.zip | |
stubs updated from scripts, new head tpf from rapid
Diffstat (limited to 'Software/Stubs Collection')
75 files changed, 14042 insertions, 198 deletions
diff --git a/Software/Stubs Collection/stubs/Read Dancer.cs b/Software/Stubs Collection/stubs/Read Dancer.cs index 58f302d53..8fcfc94b0 100644 --- a/Software/Stubs Collection/stubs/Read Dancer.cs +++ b/Software/Stubs Collection/stubs/Read Dancer.cs @@ -12,27 +12,21 @@ using Tango.Stubs; public void OnExecute(StubManager stubManager) { - stubManager.RequestTimeout = 2000; - //for (int i = 0; i < 100; i++) - { -// Request ---- -// UInt32 : DancerID - -// Response ---- -// UInt32 : DancerID -// UInt32 : Position -// UInt32 : GeneralStatus -// UInt32 : DetailedStatus - //var response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,1); + var response1 = stubManager.ShowResponseWindow("Please Enter Password:"); + if (response1=="Aa123456") + { + stubManager.WriteLine(response1); + -//var response = stubManager.Run<StubMotorSpeedResponse>("StubMotorSpeedRequest" ,22); -//var response; -//var response = stubManager.Run<StubMotorStatusResponse>("StubMotorStatusRequest" ,18, true); - var response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,0); - Thread.Sleep(1000); - response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,1); - Thread.Sleep(1000); - response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,2); - Thread.Sleep(1000); + stubManager.RequestTimeout = 2000; + //for (int i = 0; i < 100; i++) + { + var response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,0); + Thread.Sleep(1000); + response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,1); + Thread.Sleep(1000); + response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,2); + Thread.Sleep(1000); + } } }
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/11.cs b/Software/Stubs Collection/stubs/Scripts/11.cs new file mode 100644 index 000000000..9b7b1097e --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/11.cs @@ -0,0 +1,42 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_GET_PARAM = 0x20; +const Int32 x_MOVE_PARAM = 0x40; + +const Int32 F1_MOTO_DRYER_LOADARM_A1_TX_00 = 0x60000240 ; +const Int32 F1_MOTO_DRYER_LOADARM_A1_TX_01 = 0x60000242 ; +const Int32 F1_MOTO_DRYER_LOADARM_A1_RX_00 = 0x60000244 ; +const Int32 F1_MOTO_DRYER_LOADARM_A1_RX_01 = 0x60000246 ; + +public void OnExecute(StubManager stubManager) +{ + + + +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_TX_01,0X4100); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_TX_00,32000); + + + + + + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/12345.cs b/Software/Stubs Collection/stubs/Scripts/12345.cs new file mode 100644 index 000000000..354c349cc --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/12345.cs @@ -0,0 +1,63 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +/*** Dryer Motors ***/ +const Int32 F1_MOTO_DRYER_LOADARM_A1_TX_00 = 0x60000240 ; +const Int32 F1_MOTO_DRYER_LOADARM_A1_TX_01 = 0x60000242 ; +const Int32 F1_MOTO_DRYER_LOADARM_A1_RX_00 = 0x60000244 ; +const Int32 F1_MOTO_DRYER_LOADARM_A1_RX_01 = 0x60000246 ; + + +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_GET_PARAM = 0x20; +const Int32 x_MOVE_PARAM = 0x40; + + + + +public void OnExecute(StubManager stubManager) +{ + +// Request ---- +// UInt32 : Address +// UInt32 : Value + +// Response ---- +// String : Status +// UInt32 : StatusWord + +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_TX_01,0); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_TX_00,(x_GET_PARAM | x_ABS_POS)<<8); + + + +var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_RX_00); + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_RX_01); + +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_TX_01,0); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_TX_00,0); + + + +response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_RX_00); + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_MOTO_DRYER_LOADARM_A1_RX_01); + + + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser ByPass - getout from loewer safety.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser ByPass - getout from loewer safety.cs new file mode 100644 index 000000000..34dce79fe --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser ByPass - getout from loewer safety.cs @@ -0,0 +1,46 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + UInt32 Dispenser_ID = 3; //Software Dispensers 0..7, BP Dispensers 1..8 (4 for bp disp 5) + + stubManager.Write("ByPass + TestRelay + read inputs "); + stubManager.WriteLine(""); + var response = stubManager.Run<StubDispenserResponse>("StubDispenserRequest" ,Dispenser_ID, true, false, 0, 0);//ByPass + read inputs + stubManager.Write("MSB for Disp_UP, LSB for Disp_Down "); + stubManager.WriteHex((response.DispenserPosition),4); + stubManager.WriteLine(""); + stubManager.Write("MSB for Realy_On, LSB for Over_Press "); + stubManager.WriteHex((response.InkWorningLevel),4); + stubManager.WriteLine(""); + stubManager.WriteLine("----"); + stubManager.WriteLine(""); + + stubManager.Run("StubMotorRunRequest" ,(Dispenser_ID + 6), true, 1200 );//Dispenser ID -> motor ID + + Thread.Sleep(30000); //Sleep + stubManager.Run("StubMotorStopRequest" ,15, 3); + + stubManager.Write("Remove ByPass ( + read inputs) "); + stubManager.WriteLine(""); + response = stubManager.Run<StubDispenserResponse>("StubDispenserRequest" ,Dispenser_ID, false, false, 0, 0);// read inputs + stubManager.Write("MSB for Disp_UP, LSB for Disp_Down "); + stubManager.WriteHex((response.DispenserPosition),4); + stubManager.WriteLine(""); + stubManager.Write("MSB for Realy_On, LSB for Over_Press "); + stubManager.WriteHex((response.InkWorningLevel),4); + stubManager.WriteLine(""); + stubManager.WriteLine("----"); + stubManager.WriteLine(""); + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser ByPass - getout from upper safety.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser ByPass - getout from upper safety.cs new file mode 100644 index 000000000..1887d433c --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser ByPass - getout from upper safety.cs @@ -0,0 +1,46 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + UInt32 Dispenser_ID = 1; //Software Dispensers 0..7, BP Dispensers 1..8 (4 for bp disp 5) + + stubManager.Write("ByPass + TestRelay + read inputs "); + stubManager.WriteLine(""); + var response = stubManager.Run<StubDispenserResponse>("StubDispenserRequest" ,Dispenser_ID, true, false, 0, 0);//ByPass + read inputs + stubManager.Write("MSB for Disp_UP, LSB for Disp_Down "); + stubManager.WriteHex((response.DispenserPosition),4); + stubManager.WriteLine(""); + stubManager.Write("MSB for Realy_On, LSB for Over_Press "); + stubManager.WriteHex((response.InkWorningLevel),4); + stubManager.WriteLine(""); + stubManager.WriteLine("----"); + stubManager.WriteLine(""); + + stubManager.Run("StubMotorRunRequest" ,(Dispenser_ID + 6), false, 1200 );//Dispenser ID -> motor ID + + Thread.Sleep(30000); //Sleep + stubManager.Run("StubMotorStopRequest" ,15, 3); + + stubManager.Write("Remove ByPass ( + read inputs) "); + stubManager.WriteLine(""); + response = stubManager.Run<StubDispenserResponse>("StubDispenserRequest" ,Dispenser_ID, false, false, 0, 0);// read inputs + stubManager.Write("MSB for Disp_UP, LSB for Disp_Down "); + stubManager.WriteHex((response.DispenserPosition),4); + stubManager.WriteLine(""); + stubManager.Write("MSB for Realy_On, LSB for Over_Press "); + stubManager.WriteHex((response.InkWorningLevel),4); + stubManager.WriteLine(""); + stubManager.WriteLine("----"); + stubManager.WriteLine(""); + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_LimitSwitch.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_LimitSwitch.cs index 90ad540f9..7eb048556 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_LimitSwitch.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_LimitSwitch.cs @@ -37,6 +37,8 @@ int LimitSW_Dispenser(Int32 Fpga, Int32 Adr, int DispenserNo) counter = counter + 1; } Thread.Sleep(100); + Temp = RetVal.Value; + } diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_PressureSensor.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_PressureSensor.cs index 11a419576..342d2fdb2 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_PressureSensor.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dispenser/Dispenser_PressureSensor.cs @@ -27,7 +27,7 @@ public void OnExecute(StubManager stubManager) for (int i=2; i<10; i++) { - Thread.Sleep(1000); + Thread.Sleep(100); var response = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,i); stubManager.Write("\nADC VALUE, DISPENSER "); stubManager.Write(i-1); stubManager.Write("\t"); stubManager.WriteHex(response.SamplingInBits, 4); stubManager.Write("\t"); stubManager.Write(response.VoltageSamplingMv); stubManager.Write(" mV"); } diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_Jig.cs new file mode 100644 index 000000000..42f35b8ef --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_Jig.cs @@ -0,0 +1,542 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_LimitSwitch.cs" +include "Tango_Defines_SSR.cs" +include "Tango_Defines_Tacho.cs" + + +const int UNIT_UNDER_TEST=3+1+2+6; +//-------------------------------------------------------------------------------- +string path1="P:\\Scripts\\Assemblies\\Dryer\\DryerLog\\"; +string path2="C:\\DryerLog\\"; + +string File_Name1 ; +string Status; +//--------------------------- +Int32 last_14bit_position; +Int32 position_32bit=0; +float [] DryerTemp = new float[3] ; + + +string [,] Units_status = new string[UNIT_UNDER_TEST,2] { + {"Lid_Motor","Not Test"}, + {"LS_Lid_Open","Not Test"}, + {"LS_Lid_Close","Not Test"}, + {"DRIVING_Motor","Not Test"}, + {"SSI_Encoder","Not Test"}, + {"LoadArm_Motor","Not Test"}, + {"Blower_test","Not Test"}, + {"Air_PT100_test","Not Test"}, + {"Main_PT100_test","Not Test"}, + {"Sec.PT100","Not Test"}, + {"SSR1_heater","Not Test"}, + {"SSR2_heater","Not Test"}, + }; + + + +//----------------------------------------------------- +string Dryer_Sn; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + +// Set the caption bar text of the form. + form1.TopMost = true; + form1.Text = "Dryer Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----Dryer Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" Dryer S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { +if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } +else +path=path1; + + +File_Name1=path + TextBox1.Text +"_Dryer_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + +stubManager.Write(File_Name1 +"\n"); +stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); +stubManager.Write(DateTime.Now +"\n" ); + +stubManager.AppendToFile(File_Name1,"Dryer Test Report" ); +stubManager.Write("Dryer Test Report\n" ); + +stubManager.AppendToFile(File_Name1,"Dryer S/N: \t" + TextBox1.Text ); +stubManager.Write("Dryer S/N:" + TextBox1.Text +"\n" ); + + +stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); +stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + +Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; +Label5.Location = new Point (300, 100); +Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + +Label5.Text="Pros"; +Label5.Font = new Font("Arial", 24,FontStyle.Bold); +form1.Controls.Add(Label5); + + +//------------------------------- start test ----------- +// Test_LId(); +// Test_motor_driving(); +// Test_Load_Arm (); + Test_Blower_heaters_pt100(); + Status=write_to_file(); + + Label5.Text=Status; + TextBox1.Text=""; +}; + + form1.ShowDialog(); + + return ; + } +//------------------------------------------ +int Test_Blower_heaters_pt100() +{ + + float ftemp=0; + float ftemp1=0; + + SetBit(FPGA1,0x3d2,5,1); //turn off Blower + Thread.Sleep(500); + + var RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg8, 0); + + DialogResult result = MessageBox.Show("Close Dryer Door", "Warning"); + RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg8, 0); + if(RetVal.Value>20) + { + Units_status[6,1]="Fail"; + stubManager.Write("Error,Fan rotate\n"); + return 0; + } + + SetBit(FPGA1,0x3d2,4,1); //Dir + SetBit(FPGA1,0x3d2,3,1); //Torqer High + SetBit(FPGA1,0x3d2,5,0); //turn on Blower + + const int LOW = 70;//0 - 100% + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000400 | 0x112, 0xFF);//Freq 8 bit + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000400 | 0x3EC, LOW+1);//Low 8 bit + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000400 | 0x3EE, 101 - LOW);//High 8 bit + + Thread.Sleep(1000); + RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg8, 0); + stubManager.Write("blower Speed- " + RetVal.Value + "\n"); + if ((RetVal.Value<150)||(RetVal.Value>250) ) + { + Units_status[6,1]="Fail"; + stubManager.Write("Error,Fan rotate\n"); + return 0; + } + Units_status[6,1]="Pass"; + + + stubManager.Write("Temp Befor heating \n"); + if (test_pt100()!=0) + return 0; + +float temp=0; +float temp1=4096*95*5; + + //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + SetBit (FPGA2, F2_CTRL, 10, 1); //turn SSR1 on + stubManager.Write("\tTesting SSR no. 1\t"); + Thread.Sleep(1000); +var response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,16); + temp=Convert.ToUInt32 (response1.SamplingInBits); + temp=temp*800*3*100; + temp=temp/(4096*95*50); + stubManager.Write("Current = "+ temp + "A\n"); + if ((temp>6) || (temp<3)) + Units_status[10,1]="Fail"; + else + Units_status[10,1]="Pass"; + + //Write GPO_DRYER_SSR2_CTRL SSR/SSR no. 2 + SetBit (FPGA2, F2_CTRL, 9, 1); + stubManager.Write("\tTesting SSR no. 2\t"); + Thread.Sleep(1000); + response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,17); + temp=Convert.ToUInt32 (response1.SamplingInBits); + stubManager.WriteLine(temp); + temp=temp*800*3*100; + temp=temp/(4096*95*120); + stubManager.Write("Current = "+ temp + "A\n"); + if ((temp>3) || (temp<1)) + Units_status[11,1]="Fail"; + else + Units_status[11,1]="Pass"; + + Thread.Sleep(50000); + +//check air temp + ftemp=Read_pt100(0); + stubManager.Write("After heating air temp is " + ftemp + "\n"); + ftemp = ftemp - DryerTemp[0]; + if ((ftemp<5)||(ftemp>25)) + Units_status[7,1]="Fail"; + else + Units_status[7,1]="Pass"; + + + +//check Main temp + ftemp=Read_pt100(1); + stubManager.Write("After heating Main temp is " + ftemp + "\n"); + ftemp = ftemp - DryerTemp[1]; + if ((ftemp<5)||(ftemp>40)) + Units_status[8,1]="Fail"; + else + Units_status[8,1]="Pass"; + +//check Sec. temp + ftemp=Read_pt100(2); + stubManager.Write("After heating Sec. temp is " + ftemp + "\n"); + ftemp = ftemp - DryerTemp[2]; + if ((ftemp<5)||(ftemp>40)) + Units_status[9,1]="Fail"; + else + Units_status[9,1]="Pass"; + + SetBit (FPGA2, F2_CTRL, 10, 0); //turn SSR1 off + SetBit (FPGA2, F2_CTRL, 9, 0); //turn SSR2 off + + SetBit(FPGA1,0x3d2,5,1); //turn off Blower + return 1; + +} + + int test_pt100() + { + float ftemp=0; + int temp=0; + int j=0; + for (int i = 0; i < 3; i++) + { + DryerTemp[i]=Read_pt100(i); + ftemp=DryerTemp[i]; + if ((ftemp>100)|| (ftemp<10)) + { + Units_status[i+7,1]="Fail"; + } + else + { + Units_status[i+7,1]="Pass"; + } + stubManager.Write(Units_status[i+7,0] +"\t"+ ftemp.ToString("F2")); + stubManager.Write("°C\n"); + + } + return 0; + } +//------------------------------------------------ +float Read_pt100(int i) +{ + int j=i+6; + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,j); // + float ftemp = (float)response.TemperatureCMultBy100; + ftemp = ftemp / 100; + return (ftemp); +} + + +//------------------------------------------ +int Test_motor_driving () + +{ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,3, true, 500); //rotate Dryer Motor. + stubManager.Write("Dryer Motor rotate \n "); + DialogResult result = MessageBox.Show("Are Dryer Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("Dryer Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("Dryer Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,3,3); //stop motor + + return 0; +} +//---------------------------------- +int Test_Load_Arm() +{ + + Int32 temp3=0; + Int32 j=0; + Int32 i=0; + position_32bit=0; + Int32 temp=position_32bit; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,5, false, 60);//40 + Thread.Sleep(50); + temp=ReadEncoder(); + while ((temp3==0)&& (i<600) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + Thread.Sleep(50); + ReadEncoder(); +// stubManager.Write("position_32bit " + position_32bit +"\t"); + + if (Math.Abs(position_32bit)> (50*0x4000)) + temp3=1; + if ((position_32bit-temp)>20) + temp3=2; +// stubManager.Write("Temp " + temp +"\n"); + temp=position_32bit; +// stubManager.Write("Temp3 " + temp3 +"\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,5, 3); + + DialogResult result1 = MessageBox.Show("Arm Motor rotate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[5,1]="Fail"; + stubManager.Write("Arm Motor Not rotate\n"); + return 0; + } + Units_status[5,1]="Pass"; + + DialogResult result2 = MessageBox.Show("Did Arm Motor arrive to mecahnicl stopper ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[4,1]="Fail"; + stubManager.Write("Arm Motor arrive to mecahnicl stopper \n"); + return 0; + } + + position_32bit=0; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,5, true, 60); + Thread.Sleep(50); + i=0; + while ((Math.Abs(ReadEncoder())< (30*0x4000))&& (i<4500)) + + { + Thread.Sleep(50); + i++; +// stubManager.Write("position_32bit " + position_32bit +"\t" + i + "\n" ); + + + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,5, 3); + + DialogResult result3 = MessageBox.Show("Did Arm Motor make 30 rounds?", "Warning",MessageBoxButtons.YesNo); + if(result3 == DialogResult.No) + { + Units_status[4,1]="Fail"; + stubManager.Write("Arm Motor not make 30 rounds\n"); + return 0; + } + Units_status[4,1]="Pass"; + return 1; +} + +Int32 ReadEncoder() +{ + Int32 temp; + Int32 temp1; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x6000019e, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000190); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000192); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + if (temp>last_14bit_position) + { + temp1=temp-last_14bit_position; + position_32bit=position_32bit+temp1; + if (temp1>0x2000) + position_32bit=position_32bit-0x4000; + } + else if (temp<last_14bit_position) + + { + temp1=last_14bit_position-temp; + position_32bit=position_32bit-temp1; + if (temp1>0x2000) + position_32bit=position_32bit+0x4000; + } + + last_14bit_position=temp; + + return position_32bit; +} +//----------------------------------- +int Test_LId () +{ + Int32 Bit = 1; + int i = 0; + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,4, false, 0x800000+2); //mov Dryer Lid motor down + Thread.Sleep(2000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,4, 2); //Hard stop hiZ motor + Thread.Sleep(1000); + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,4, false, 0x800000+0); //mov Dryer Lid motor up + + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,4); + Thread.Sleep(50); + i++; + } + stubManager.Write("\n--------1-Lid Open--------"); + + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,4, 2); //Hard stop hiZ motor + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_Lid_Open Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,4, false, 0x800000+2); //mov Dryer Lid motor down + + Bit = 1; + i=0; + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,5); + Thread.Sleep(50); + i++; + } + stubManager.Write("\n--------2-Lid Close--------"); + + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,4, 2); //Hard stop hiZ motor + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[2,1]="Fail"; + stubManager.Write("LS_Lid_Close Not calibrate\n"); + return 0; + } + Units_status[2,1]="Pass"; + Units_status[0,1]="Pass"; + return 1; + +} + + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<UNIT_UNDER_TEST;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------Dryer Fail ------------ "); + stubManager.Write("-------------Dryer Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------Dryer Pass ------------ )"); + stubManager.Write("-------------Dryer Pass ------------ "); + } + + return Stemp; + +} + diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_LimitSwitch.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_LimitSwitch.cs index 46849f051..4d9f116bb 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_LimitSwitch.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_LimitSwitch.cs @@ -22,12 +22,13 @@ public void OnExecute(StubManager stubManager) uint Temp = 0; int counter = 0; +// stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,23, false,0x800000+2); - stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,4, false, 2); //mov Dryer Lid motor up + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,4, false, 0x800000+0); //mov Dryer Lid motor up while (Bit != 0x0) //wait until Dryer Lid open { - Bit = GetBit(FPGA1, F1_LS_01_Direct,5); + Bit = GetBit(FPGA1, F1_LS_01_Direct,4); Thread.Sleep(10); } stubManager.Write("\n--------1-Lid Open--------"); @@ -38,12 +39,12 @@ stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,4, 2); //Hard st + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,4, false, 0x800000+2); //mov Dryer Lid motor up -stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,4, true, 2); //mov Dryer Lid motor down Bit = 1; while (Bit != 0x0) //wait until Dryer Lid open { - Bit = GetBit(FPGA1, F1_LS_01_Direct,4); + Bit = GetBit(FPGA1, F1_LS_01_Direct,5); Thread.Sleep(10); } stubManager.Write("\n--------2-Lid Close--------"); diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_SSR.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_SSR.cs index da391cfb2..c5bcb93e5 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_SSR.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_SSR.cs @@ -19,21 +19,54 @@ include "Tango_Defines_SSR.cs" public void OnExecute(StubManager stubManager) { //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,6); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); SetBit (FPGA2, F2_CTRL, 10, 1); - stubManager.Write("\nTesting SSR no. 1"); - Thread.Sleep(4000); + stubManager.Write("\tTesting SSR no. 1\t"); + Thread.Sleep(10000); + + // Request ---- +// UInt32 : ADCDevice + +// Response ---- +// UInt32 : ADCDevice +// Int32 : SamplingInBits +// Int32 : VoltageSamplingMv +// String : Status +// UInt32 : StatusWord +var response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,16); + stubManager.WriteLine(response1.SamplingInBits); + stubManager.WriteLine(response1.VoltageSamplingMv); + + + SetBit (FPGA2, F2_CTRL, 10, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,6); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + stubManager.Write("\n"); + //Write GPO_DRYER_SSR2_CTRL SSR/SSR no. 2 + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,7); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); SetBit (FPGA2, F2_CTRL, 9, 1); - stubManager.Write("\nTesting SSR no. 2"); - Thread.Sleep(4000); + stubManager.Write("\tTesting SSR no. 2\t"); + Thread.Sleep(10000); SetBit (FPGA2, F2_CTRL, 9, 0); - + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,7); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + stubManager.Write("\n"); + //Write GPO_DRYER_SSR3_CTRL SSR/SSR no. 3 + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,8); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); SetBit (FPGA2, F2_CTRL, 8, 1); - stubManager.Write("\nTesting SSR no. 3"); - Thread.Sleep(4000); + stubManager.Write("\tTesting SSR no. 3\t"); + Thread.Sleep(10000); SetBit (FPGA2, F2_CTRL, 8, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,8); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + stubManager.Write("\n"); + }
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_SSR1.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_SSR1.cs new file mode 100644 index 000000000..b059a170f --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Dryer_SSR1.cs @@ -0,0 +1,72 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Interfaces\Tango_Defines_SSR.cs" + + +public void OnExecute(StubManager stubManager) +{ +float temp=0; +float temp1=4096*95*5; + + //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,6); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + SetBit (FPGA2, F2_CTRL, 10, 1); + stubManager.Write("\tTesting SSR no. 1\t"); + Thread.Sleep(1000); + + +var response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,16); + + temp=Convert.ToUInt32 (response1.SamplingInBits); + temp=temp*800*3*100; + temp=temp/(4096*95*50); + stubManager.Write("Current = "+ temp + "A\n"); + temp=temp*60; + stubManager.Write("Voltage = "+ temp + " Volt\n"); + + + SetBit (FPGA2, F2_CTRL, 10, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,6); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + stubManager.Write("\n"); + + + //Write GPO_DRYER_SSR2_CTRL SSR/SSR no. 2 + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,7); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + SetBit (FPGA2, F2_CTRL, 9, 1); + stubManager.Write("\tTesting SSR no. 2\t"); + Thread.Sleep(1000); + +response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,17); + + temp=Convert.ToUInt32 (response1.SamplingInBits); + stubManager.WriteLine(temp); + temp=temp*800*3*100; + temp=temp/(4096*95*120); + stubManager.Write("Current = "+ temp + "A\n"); + temp=temp*120; + stubManager.Write("Voltage = "+ temp + " Volt\n"); + + + SetBit (FPGA2, F2_CTRL, 9, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,7); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + stubManager.Write("\n"); + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/GPO_Blower_PWM.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/GPO_Blower_PWM.cs index d7c4894c6..8ac0d41dc 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/GPO_Blower_PWM.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/GPO_Blower_PWM.cs @@ -12,14 +12,19 @@ using Tango.Stubs; include "..\..\Defines\Tango_Defines_Basic.cs" include "Tango_Defines_SSR.cs" +include "Tango_Defines_Tacho.cs" public void OnExecute(StubManager stubManager) { + + var RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg8, 0); + + SetBit(FPGA1,0x3d2,5,0); //turn on Blower - SetBit(FPGA1,0x3d2,4,0); //Dir + SetBit(FPGA1,0x3d2,4,1); //Dir SetBit(FPGA1,0x3d2,3,1); //Torqer High @@ -30,6 +35,10 @@ public void OnExecute(StubManager stubManager) var response2 = stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000400 | 0x3EE, 101 - LOW);//High 8 bit Thread.Sleep(4000); + RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg8, 0); + stubManager.Write("\nFan5 Speed-"); + stubManager.WriteHex(RetVal.Value,4); + SetBit(FPGA1,0x3d2,5,1); //turn off Blower // low + high = 100 % in order use the same freq diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Load_Dryer_Arm.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Load_Dryer_Arm.cs new file mode 100644 index 000000000..1ce0a515f --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Load_Dryer_Arm.cs @@ -0,0 +1,224 @@ +//------------------------------------------- +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "..\Defines\Tango_Defines_Motors.cs" + + //-------------------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- +Int32 last_14bit_position; +Int32 position_32bit; + + +public void OnExecute(StubManager stubManager) +{ + + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x6000019e, 0x0000); //triggers a TX transmission + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000190); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000192); + last_14bit_position = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + position_32bit=0; + + +//Create form + Form form1 = new Form(); + +//-------------------------------------------------------------------------------- + +// Create buttons to use as the accept and cancel buttons. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + + Button button2 = new Button () + { + Width = 100, + Height = 100, + }; +//-------------------------------------------------------------------------------- +// Set the text of button + + button1.Text = "ARM HOME"; + + button2.Text = "ARM STRART"; + +//-------------------------------------------------------------------------------- +// Set the position of the button on the form. + + button1.Location = new Point (40, 100); + + button2.Location + = new Point (button1.Left + button1.Width + 10, 100); + +//-------------------------------------------------------------------------------- + // Add button to the form. + + form1.Controls.Add(button1); + + form1.Controls.Add(button2); + +//-------------------------------------------------------------------------------- + +// Set the caption bar text of the form. + + form1.Text = "Load Dryer Arm"; + +//-------------------------------------------------------------------------------- + + // Define the border style of the form to a dialog box. + + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + + // Set the MaximizeBox to false to remove the maximize box. + + form1.MaximizeBox = false; + + // Set the MinimizeBox to false to remove the minimize box. + + form1.MinimizeBox = false; + + // Set the start position of the form to the center of the screen. + + form1.StartPosition = FormStartPosition.CenterScreen; + + + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +//-------------------------------------------------------------------------------- + + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="20" + }; +TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); +Label Label1 = new Label () + { + Width = 150, + Height = 100, + Text ="Number round" + }; +Label1.Location = new Point (20, 10); + form1.Controls.Add(Label1); + + + +//-------------------------------------------------------------------------------- + + + + button2.Click += (_,__) => + + { + position_32bit=0; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,5, true, 40); + Thread.Sleep(200); + + while (Math.Abs(ReadEncoder())< (UInt32.Parse(TextBox1.Text)*0x4000)) + + { + Thread.Sleep(200); + + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,5, 3); + + }; + + + +//-------------------------------------------------------------------------------- + + button1.Click += (_,__) => + { + Int32 temp3=0; + Int32 j=0; + position_32bit=0; + Int32 temp=position_32bit; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,5, false, 40); + Thread.Sleep(200); + + while (temp3==0) + + { + Thread.Sleep(200); + ReadEncoder(); + stubManager.Write("position_32bit " + position_32bit +"\t"); + + if (Math.Abs(position_32bit)> (UInt32.Parse(TextBox1.Text)*0x4000)) + temp3=1; + if (Math.Abs(position_32bit-temp)<0x40) + j=j+1; + else + j=0; + temp=position_32bit; + if (j>3) + temp3=2; + + stubManager.Write("Temp3 " + temp3 +"\n"); + + + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,5, 3); + + }; + +//-------------------------------------------------------------------------------- + +// Display the form as a modal dialog box. + form1.ShowDialog(); + + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,5, 3); + + + return; +} + +Int32 ReadEncoder() +{ + Int32 temp; + Int32 temp1; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x6000019e, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000190); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000192); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + if (temp>last_14bit_position) + { + temp1=temp-last_14bit_position; + position_32bit=position_32bit+temp1; + if (temp1>0x2000) + position_32bit=position_32bit-0x4000; + } + else if (temp<last_14bit_position) + + { + temp1=last_14bit_position-temp; + position_32bit=position_32bit-temp1; + if (temp1>0x2000) + position_32bit=position_32bit+0x4000; + } + + last_14bit_position=temp; + + return position_32bit; +} + + + diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Loading_arm_center_calibration.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Loading_arm_center_calibration.cs new file mode 100644 index 000000000..bb502309e --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dryer/Loading_arm_center_calibration.cs @@ -0,0 +1,22 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + + +ProgressRequest progressRequest = new ProgressRequest(); +progressRequest.Amount = 0xB1; + +var response = stubManager.Run<ProgressResponse>(progressRequest); + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/1.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/1.cs new file mode 100644 index 000000000..4100a770c --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/1.cs @@ -0,0 +1,28 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" + +public void OnExecute(StubManager stubManager) +{ + + + //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + SetBit (FPGA2, F2_CTRL, 0, 1); + stubManager.Write("\nTesting SSR no. 13 of magnet"); + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHeadJig.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHeadJig.cs new file mode 100644 index 000000000..2baedf7c2 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHeadJig.cs @@ -0,0 +1,548 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +include "Tango_Defines_LimitSwitch.cs" + + +//-------------------------------------------------------------------------------- + const Int32 I2C_ID = 2; + +//-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +//string path1=@"P:\Scripts\Assemblies\Dye head\DyeHeadLog\"; +string path1="P:\\Scripts\\Assemblies\\Dye head\\DyeHeadLog\\"; +string path2=@"C:\DyeHeadLog"; + +string File_Name1 ; +string Status; +//--------------------------- + +float [] DyeHeadTemp = new float[6] ; + +string [,] Units_status = new string[16,2] { + {"Pt100_Zone_1","Not Test"}, + {"Pt100_Zone_2","Not Test"}, + {"Pt100_Zone_3","Not Test"}, + {"Pt100_Zone_4","Not Test"}, + {"Pt100_Zone_5","Not Test"}, + {"Pt100_Zone_6","Not Test"}, + {"Heater_Zone_1","Not Test"}, + {"Heater_Zone_2","Not Test"}, + {"Heater_Zone_3","Not Test"}, + {"Heater_Zone_4","Not Test"}, + {"Heater_Zone_5","Not Test"}, + {"Heater_Zone_6","Not Test"}, + {"Magnet","Not Test"}, + {"LS_DH_LID_Open","Not Test"}, + {"LS_DH_LID_Close","Not Test"}, + {"DH_LID_Motor","Not Test"}, + }; + + + +//----------------------------------------------------- +string DyeHead_Sn; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + +// Set the caption bar text of the form. + + form1.Text = "DyeHead Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----DyeHead Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" DyeHead S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { +if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } +else +path=path1; + + +File_Name1=path + TextBox1.Text +"_DyeHead_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + +stubManager.Write(File_Name1 +"\n"); +stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); +stubManager.Write(DateTime.Now +"\n" ); + +stubManager.AppendToFile(File_Name1,"DyeHead Test Report" ); +stubManager.Write("DyeHead Test Report\n" ); + +stubManager.AppendToFile(File_Name1,"RTFU S/N: \t" + TextBox1.Text ); +stubManager.Write("DyeHead S/N:" + TextBox1.Text +"\n" ); + + +stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); +stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + +Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; +Label5.Location = new Point (300, 100); +Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + +Label5.Text="Pros"; +Label5.Font = new Font("Arial", 24,FontStyle.Bold); +form1.Controls.Add(Label5); + + +//------------------------------- start test ----------- + + DialogResult result = MessageBox.Show("Make shure, Dyehead is not hot", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + stubManager.AppendToFile(File_Name1,"Dyehead is too hot \tFail"); + stubManager.Write("Dyehead is too hot \tFail\n"); + return ; + } + Test_Magnet_Motor_LS_DyeHead(); + Test_heaters_pt100 (); + Status=write_to_file(); + + Label5.Text=Status; + TextBox1.Text=""; +}; + + form1.ShowDialog(); + + stubManager.Write("Counter is \n"); + + + return; + } + +//-------------------------------------------- + int Test_Magnet_Motor_LS_DyeHead() +{ + Int32 Bit = 1; + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,23, false,0x800000+0); + stubManager.Write("\nTesting SSR no. 13 of magnet or motor driver"); + + DialogResult result = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[12,1]="Fail"; + stubManager.Write("Magnet Not Open\n"); + return 0; + } + Units_status[12,1]="Pass"; + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 250); + stubManager.Write("\n*** Open Lid Head "); + + Bit = 1; + int i=0; + while ((Bit != 0x0)&& (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,7); + Thread.Sleep(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,23,3); //stop motor + + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result1 == DialogResult.Cancel) + { + Units_status[15,1]="Fail"; + Units_status[13,1]="Fail"; + stubManager.Write("LS_DH_LID_Open Not calibrate\n"); + return 0; + } + Units_status[13,1]="Pass"; + stubManager.Write("\n*** Close Lid Head "); + Bit = 1; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, false, 250); + i=0; + while ((Bit != 0x0)&& (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,8); + Thread.Sleep(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,23,3); //stop motor + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[14,1]="Fail"; + Units_status[15,1]="Fail"; + stubManager.Write("LS_DH_LID_Close Not calibrate\n"); + return 0; + } + Units_status[14,1]="Pass"; + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,23, false,0x800000+2); + DialogResult result3 = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[12,1]="Fail"; + stubManager.Write("Magnet Not Open\n"); + return 0; + } + Units_status[12,1]="Pass"; + Units_status[15,1]="Pass"; + + return 0; +} + + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<16;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + return Stemp; +} +//------------------------------------ +int Test_heaters_pt100() +{ +// uint utemp=0; + uint temp=0; + float ftemp=0; + float ftemp1=0; + + stubManager.Write("\nTemp Befor heating \n"); + if (test_pt100()!=0) + return 0; + +//------------Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 8 + SetBit (FPGA2, F2_CTRL, 3, 1); + stubManager.Write("Testing SSR no. 8\tHeadZone-1\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x10); //a2d_address 0x40 channel 3 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + SetBit (FPGA2, F2_CTRL, 3, 0); + ftemp=Read_pt100(0); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+ temp + "\n"); + ftemp = ftemp - DyeHeadTemp[0]; + if ((temp>0x860)|| (temp<0x7e0)||(ftemp<5)||(ftemp>20)) + Units_status[6,1]="Fail"; + else + Units_status[6,1]="Pass"; + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 7 + ftemp=Read_pt100(1); + ftemp1 = ftemp - DyeHeadTemp[1]; + if ( ftemp1>4) + Units_status[7,1]="Fail"; + else + { + SetBit (FPGA2, F2_CTRL, 4, 1); + stubManager.Write("Testing SSR no. 7\tHeadZone-2\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x08); //a2d_address 0x40 channel 4 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + SetBit (FPGA2, F2_CTRL, 4, 0); + ftemp=Read_pt100(1); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+temp + "\n"); + ftemp = ftemp - DyeHeadTemp[1]; + if ((temp>0x660)|| (temp<0x600)||(ftemp<5)||(ftemp>20)) + Units_status[7,1]="Fail"; + else + Units_status[7,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 6 + + ftemp=Read_pt100(2); + ftemp1 = ftemp - DyeHeadTemp[2]; + if ( ftemp1>4) + Units_status[7,1]="Fail"; + else + { + SetBit (FPGA2, F2_CTRL, 5, 1); + stubManager.Write("Testing SSR no. 6\tHeadZone-3\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x04); //a2d_address 0x40 channel 5 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + SetBit (FPGA2, F2_CTRL, 5, 0); + ftemp=Read_pt100(2); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+temp +"\n"); + ftemp = ftemp - DyeHeadTemp[2]; + if ((temp>0x660)|| (temp<0x600)||(ftemp<5)||(ftemp>20)) + Units_status[8,1]="Fail"; + else + Units_status[8,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 5 + ftemp=Read_pt100(3); + ftemp1 = ftemp - DyeHeadTemp[3]; + if ( ftemp1>4) + Units_status[9,1]="Fail"; + else + { + SetBit (FPGA2, F2_CTRL, 6, 1); + stubManager.Write("Testing SSR no. 5\tHeadZone-4\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x80); //a2d_address 0x44 channel 0 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + SetBit (FPGA2, F2_CTRL, 6, 0); + ftemp=Read_pt100(3); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+temp + "\n"); + ftemp = ftemp - DyeHeadTemp[3]; + if ((temp>0x1100)|| (temp<0xf90)||(ftemp<5)||(ftemp>20)) + Units_status[9,1]="Fail"; + else + Units_status[9,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 10 + ftemp=Read_pt100(4); + ftemp1 = ftemp - DyeHeadTemp[4]; + if ( ftemp1>4) + Units_status[10,1]="Fail"; + else + { + SetBit (FPGA1, F1_gpo_01, 2, 1); + stubManager.Write("Testing SSR no. 10\tHeadZone-5\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + SetBit (FPGA1, F1_gpo_01, 2, 0); + ftemp=Read_pt100(4); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+temp + "\n"); + ftemp = ftemp - DyeHeadTemp[4]; + if ((temp>0xa80)|| (temp<0xa20)||(ftemp<5)||(ftemp>20)) + Units_status[10,1]="Fail"; + else + Units_status[10,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 11 + ftemp=Read_pt100(5); + ftemp1 = ftemp - DyeHeadTemp[5]; + if ( ftemp1>4) + Units_status[11,1]="Fail"; + else + { + SetBit (FPGA3, F3_GPO_01_bus, 4, 1); + stubManager.Write("Testing SSR no. 11\tHeadZone-6\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + SetBit (FPGA3, F3_GPO_01_bus, 4, 0); + ftemp=Read_pt100(5); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+temp + "\n"); + ftemp = ftemp - DyeHeadTemp[5]; + if ((temp>0x660)|| (temp<0x600)||(ftemp<5)||(ftemp>20)) + Units_status[11,1]="Fail"; + else + Units_status[11,1]="Pass"; + } + return 0; +} +//------------------------------------------------ + int test_pt100() + { + float ftemp=0; + int temp=0; + int j=0; + for (int i = 0; i < 6; i++) + { + DyeHeadTemp[i]=Read_pt100(i); + ftemp=DyeHeadTemp[i]; + if ((ftemp>100)|| (ftemp<10)) + { + Units_status[i,1]="Fail"; + } + else + { + Units_status[i,1]="Pass"; + } + stubManager.Write("Zone-"+(i+1)+ "\t" + ftemp.ToString("F2")); + stubManager.Write("°C\n"); + + } + return 0; + } +//------------------------------------------------ +float Read_pt100(int i) +{ + int j= i+1; + if (i==5) + j=11; + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,j); // + float ftemp = (float)response.TemperatureCMultBy100; + ftemp = ftemp / 100; + return (ftemp); +} +//--------------------------- +int adc_configuration(uint I2C_Slave_Add,uint channel ) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(channel);//Byte 1 to Write, must be 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 or 0x01 for different channels + stubI2CWriteBytesRequest.BytesTWrite.Add(0x80);//Byte 2 to Write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//----------------------------------- +int adc_set_for_read_temp(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x02);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//----------------------------------- +int adc_read_temp(uint I2C_Slave_Add) + { + + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + stubManager.WriteLineHex(response1.ReadBytes[i],2); + } + + + return 1; + } +//----------------------------------- +int adc_set_for_read_ch(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x01);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//----------------------------------- +uint adc_read_ch(uint I2C_Slave_Add) + { + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + uint templ=0; + uint temp=0; + temph=response1.ReadBytes[0]; + templ=response1.ReadBytes[1]; + temp = (temph << 8) | templ; + temp=temp & 0x0fff; + return temp; + } diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHeadJig1.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHeadJig1.cs new file mode 100644 index 000000000..b3513ac55 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHeadJig1.cs @@ -0,0 +1,575 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +include "Tango_Defines_LimitSwitch.cs" + + +//-------------------------------------------------------------------------------- + const Int32 I2C_ID = 2; + +//-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +//string path1=@"P:\Scripts\Assemblies\Dye head\DyeHeadLog\"; +string path1="P:\\Scripts\\Assemblies\\Dye head\\DyeHeadLog\\"; +string path2="C:\\DyeHeadLog\\"; + +string File_Name1 ; +string Status; +//--------------------------- + +float [] DyeHeadTemp = new float[6] ; + +string [,] Units_status = new string[16,2] { + {"Pt100_Zone_1","Not Test"}, + {"Pt100_Zone_2","Not Test"}, + {"Pt100_Zone_3","Not Test"}, + {"Pt100_Zone_4","Not Test"}, + {"Pt100_Zone_5","Not Test"}, + {"Pt100_Zone_6","Not Test"}, + {"Heater_Zone_1","Not Test"}, + {"Heater_Zone_2","Not Test"}, + {"Heater_Zone_3","Not Test"}, + {"Heater_Zone_4","Not Test"}, + {"Heater_Zone_5","Not Test"}, + {"Heater_Zone_6","Not Test"}, + {"Magnet ","Not Test"}, + {"LS_DH_LID_Open","Not Test"}, + {"LS_DH_LID_Close","Not Test"}, + {"DH_LID_Motor","Not Test"}, + }; + + + +//----------------------------------------------------- +string DyeHead_Sn; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + +// Set the caption bar text of the form. + + form1.Text = "DyeHead Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----DyeHead Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" DyeHead S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { +if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } +else +path=path1; + + +File_Name1=path + TextBox1.Text +"_DyeHead_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + +stubManager.Write(File_Name1 +"\n"); +stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); +stubManager.Write(DateTime.Now +"\n" ); + +stubManager.AppendToFile(File_Name1,"DyeHead Test Report" ); +stubManager.Write("DyeHead Test Report\n" ); + +stubManager.AppendToFile(File_Name1,"DyeHead S/N: \t" + TextBox1.Text ); +stubManager.Write("DyeHead S/N:" + TextBox1.Text +"\n" ); + + +stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); +stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + +Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; +Label5.Location = new Point (300, 100); +Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + +Label5.Text="Pros"; +Label5.Font = new Font("Arial", 24,FontStyle.Bold); +form1.Controls.Add(Label5); + + +//------------------------------- start test ----------- + + DialogResult result = MessageBox.Show("Make shure, Dyehead is not hot", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + stubManager.AppendToFile(File_Name1,"Dyehead is too hot \tFail"); + stubManager.Write("Dyehead is too hot \tFail\n"); + return ; + } + Test_Magnet_Motor_LS_DyeHead(); + Test_heaters_pt100 (); + Status=write_to_file(); + + Label5.Text=Status; + TextBox1.Text=""; +}; + + form1.ShowDialog(); + +// stubManager.Write("Counter is \n"); + + + return; + } + +//-------------------------------------------- + int Test_Magnet_Motor_LS_DyeHead() +{ + Int32 Bit = 1; + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,23, false,0x800000+0); + stubManager.Write("\nTesting SSR no. 13 of magnet or motor driver"); + + DialogResult result = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[12,1]="Fail"; + stubManager.Write("Magnet Not Open\n"); + return 0; + } + Units_status[12,1]="Pass"; + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 250); + stubManager.Write("\n*** Open Lid Head "); + + Bit = 1; + int i=0; + while ((Bit != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,7); + Thread.Sleep(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,2,3); //stop motor + + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result1 == DialogResult.Cancel) + { + Units_status[15,1]="Fail"; + Units_status[13,1]="Fail"; + stubManager.Write("LS_DH_LID_Open Not calibrate\n"); + return 0; + } + Units_status[13,1]="Pass"; + stubManager.Write("\n*** Close Lid Head "); + Bit = 1; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, false, 250); + i=0; + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,8); + Thread.Sleep(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,2,3); //stop motor + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[14,1]="Fail"; + Units_status[15,1]="Fail"; + stubManager.Write("LS_DH_LID_Close Not calibrate\n"); + return 0; + } + Units_status[14,1]="Pass"; + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,23, false,0x800000+2); + DialogResult result3 = MessageBox.Show("Make shure, Magnet is close", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[12,1]="Fail"; + stubManager.Write("Magnet Not close\n"); + return 0; + } + Units_status[12,1]="Pass"; + Units_status[15,1]="Pass"; + + return 0; +} + + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<16;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------Dye Head Fail ------------ )"); + stubManager.Write("-------------Dye Head Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------Dye Head Pass ------------ )"); + stubManager.Write("-------------Dye Head Pass ------------ "); + } + + return Stemp; +} +//------------------------------------ +int Test_heaters_pt100() +{ + +// uint utemp=0; + uint temp=0; + float ftemp=0; + float ftemp1=0; + float current=0; + + stubManager.Write("\nTemp Befor heating \n"); + if (test_pt100()!=0) + return 0; + +//------------Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 8 + SetBit (FPGA2, F2_CTRL, 3, 1); + stubManager.Write("Testing SSR no. 8\tHeadZone-1\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x10); //a2d_address 0x40 channel 3 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + current= (float)(temp); + current=( float) (0.001221) * current; + SetBit (FPGA2, F2_CTRL, 3, 0); + ftemp=Read_pt100(0); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+ current + "\n"); + ftemp = ftemp - DyeHeadTemp[0]; + + if ((current>1.5)|| (current<0.9)||(ftemp<5)||(ftemp>25)) + Units_status[6,1]="Fail"; + else + Units_status[6,1]="Pass"; + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 7 + ftemp=Read_pt100(1); + ftemp1 = ftemp - DyeHeadTemp[1]; + if ( ftemp1>4) + Units_status[7,1]="Fail"; + else + { + SetBit (FPGA2, F2_CTRL, 4, 1); + stubManager.Write("Testing SSR no. 7\tHeadZone-2\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x08); //a2d_address 0x40 channel 4 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + current= (float)(temp); + current=( float) (0.001221) * current; + SetBit (FPGA2, F2_CTRL, 4, 0); + ftemp=Read_pt100(1); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+ current + "\n"); + ftemp = ftemp - DyeHeadTemp[1]; + if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>25)) + Units_status[7,1]="Fail"; + else + Units_status[7,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 6 + + ftemp=Read_pt100(2); + ftemp1 = ftemp - DyeHeadTemp[2]; + if ( ftemp1>4) + Units_status[8,1]="Fail"; + else + { + SetBit (FPGA2, F2_CTRL, 5, 1); + stubManager.Write("Testing SSR no. 6\tHeadZone-3\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x04); //a2d_address 0x40 channel 5 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + current= (float)(temp); + current=( float) (0.001221) * current; + SetBit (FPGA2, F2_CTRL, 5, 0); + ftemp=Read_pt100(2); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current +"\n"); + ftemp = ftemp - DyeHeadTemp[2]; + if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>25)) + Units_status[8,1]="Fail"; + else + Units_status[8,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 5 + ftemp=Read_pt100(3); + ftemp1 = ftemp - DyeHeadTemp[3]; + if ( ftemp1>4) + Units_status[9,1]="Fail"; + else + { + SetBit (FPGA2, F2_CTRL, 6, 1); + stubManager.Write("Testing SSR no. 5\tHeadZone-4\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x80); //a2d_address 0x44 channel 0 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + current= (float)(temp); + current=( float) (0.001221) * current; + + SetBit (FPGA2, F2_CTRL, 6, 0); + ftemp=Read_pt100(3); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n"); + ftemp = ftemp - DyeHeadTemp[3]; + if ((current<2.9)|| (current>3.4)||(ftemp<5)||(ftemp>25)) + Units_status[9,1]="Fail"; + else + Units_status[9,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 10 + ftemp=Read_pt100(4); + ftemp1 = ftemp - DyeHeadTemp[4]; + if ( ftemp1>4) + Units_status[10,1]="Fail"; + else + { + SetBit (FPGA1, F1_gpo_01, 2, 1); + stubManager.Write("Testing SSR no. 10\tHeadZone-5\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + current= (float)(temp); + current=( float) (0.001526) * current; + SetBit (FPGA1, F1_gpo_01, 2, 0); + ftemp=Read_pt100(4); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n"); + ftemp = ftemp - DyeHeadTemp[4]; + if ((current<2.9)|| (current>3.4)||(ftemp<5)||(ftemp>25)) + Units_status[10,1]="Fail"; + else + Units_status[10,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 11 + ftemp=Read_pt100(5); + ftemp1 = ftemp - DyeHeadTemp[5]; + if ( ftemp1>4) + Units_status[11,1]="Fail"; + else + { + SetBit (FPGA3, F3_GPO_01_bus, 4, 1); + stubManager.Write("Testing SSR no. 11\tHeadZone-6\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + current= (float)(temp); + current=( float) (0.001526) * current; + SetBit (FPGA3, F3_GPO_01_bus, 4, 0); + ftemp=Read_pt100(5); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n"); + ftemp = ftemp - DyeHeadTemp[5]; + if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>20)) + Units_status[11,1]="Fail"; + else + Units_status[11,1]="Pass"; + } + return 0; +} +//------------------------------------------------ + int test_pt100() + { + float ftemp=0; + int temp=0; + int j=0; + for (int i = 0; i < 6; i++) + { + DyeHeadTemp[i]=Read_pt100(i); + ftemp=DyeHeadTemp[i]; + if ((ftemp>100)|| (ftemp<10)) + { + Units_status[i,1]="Fail"; + } + else + { + Units_status[i,1]="Pass"; + } + stubManager.Write("Zone-"+(i+1)+ "\t" + ftemp.ToString("F2")); + stubManager.Write("°C\n"); + + } + return 0; + } +//------------------------------------------------ +float Read_pt100(int i) +{ + int j= i+1; + if (i==5) + j=11; + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,j); // + float ftemp = (float)response.TemperatureCMultBy100; + ftemp = ftemp / 100; + return (ftemp); +} +//--------------------------- +int adc_configuration(uint I2C_Slave_Add,uint channel ) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(channel);//Byte 1 to Write, must be 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 or 0x01 for different channels + stubI2CWriteBytesRequest.BytesTWrite.Add(0x80);//Byte 2 to Write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//----------------------------------- +int adc_set_for_read_temp(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x02);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//----------------------------------- +int adc_read_temp(uint I2C_Slave_Add) + { + + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + stubManager.WriteLineHex(response1.ReadBytes[i],2); + } + + + return 1; + } +//----------------------------------- +int adc_set_for_read_ch(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x01);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//----------------------------------- +uint adc_read_ch(uint I2C_Slave_Add) + { + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + uint templ=0; + uint temp=0; + temph=response1.ReadBytes[0]; + templ=response1.ReadBytes[1]; + temp = (temph << 8) | templ; + temp=temp & 0x0fff; + return temp; + } diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHead_SSR.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHead_SSR.cs new file mode 100644 index 000000000..cb01a86c4 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHead_SSR.cs @@ -0,0 +1,117 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Interfaces\Tango_Defines_SSR.cs" + + +public void OnExecute(StubManager stubManager) +{ + + + UInt32 temp=0; + + + + stubManager.Write("\n"); + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,1); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 8 + SetBit (FPGA2, F2_CTRL, 3, 1); + stubManager.Write("\tTesting SSR no. 8\tHeadZone-1"); + Thread.Sleep(10000); + SetBit (FPGA2, F2_CTRL, 3, 0); + var response1 = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,1); // + stubManager.WriteHex(response1.TemperatureCMultBy100,4); + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,2); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 7 + SetBit (FPGA2, F2_CTRL, 4, 1); + stubManager.Write("\tTesting SSR no. 7\tHeadZone-2"); + Thread.Sleep(10000); + SetBit (FPGA2, F2_CTRL, 4, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,2); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,3); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 6 + SetBit (FPGA2, F2_CTRL, 5, 1); + stubManager.Write("\tTesting SSR no. 6\tHeadZone-3"); + Thread.Sleep(10000); + SetBit (FPGA2, F2_CTRL, 5, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,3); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,4); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 5 + SetBit (FPGA2, F2_CTRL, 6, 1); + stubManager.Write("\tTesting SSR no. 6\tHeadZone-4"); + Thread.Sleep(10000); + SetBit (FPGA2, F2_CTRL, 6, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,4); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,5); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 10 + SetBit (FPGA1, F1_gpo_01, 2, 1); + stubManager.Write("\tTesting SSR no. 6\tHeadZone-5"); + Thread.Sleep(10000); + SetBit (FPGA1, F1_gpo_01, 2, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,5); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,11); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 11 + SetBit (FPGA3, F3_GPO_01_bus, 4, 1); + stubManager.Write("\tTesting SSR no. 6\tHeadZone-6"); + Thread.Sleep(10000); + SetBit (FPGA3, F3_GPO_01_bus, 4, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,11 + ); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,0); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write F2_GPO_MIXCHIP_SSR4_CTRL SSR/SSR no. 4 + SetBit (FPGA2, F2_CTRL, 7, 1); + stubManager.Write("Testing SSR no. 4\tMIXCHIP "); + Thread.Sleep(10000); + SetBit (FPGA2, F2_CTRL, 7, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,0); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHead_SSR_CURRENT_SENSE.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHead_SSR_CURRENT_SENSE.cs new file mode 100644 index 000000000..b9793a336 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/DyeHead_SSR_CURRENT_SENSE.cs @@ -0,0 +1,237 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Interfaces\Tango_Defines_SSR.cs" + +//---------------------- +const Int32 I2C_ID = 2; +//const Int32 I2C_Slave_Add = 0x46; //must be 0x40, 0x44 or 0x46 +//---------------------- + + +public void OnExecute(StubManager stubManager) +{ + + + UInt32 temp=0; + + + stubManager.Write("\n"); + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,1); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 8 + SetBit (FPGA2, F2_CTRL, 3, 1); + stubManager.Write("\tTesting SSR no. 8\tHeadZone-1\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x10); //a2d_address 0x40 channel 3 + adc_set_for_read_ch(0x40); + adc_read_ch(0x40); + SetBit (FPGA2, F2_CTRL, 3, 0); + var response1 = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,1); // + stubManager.WriteHex(response1.TemperatureCMultBy100,4); + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,2); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 7 + SetBit (FPGA2, F2_CTRL, 4, 1); + stubManager.Write("\tTesting SSR no. 7\tHeadZone-2\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x08); //a2d_address 0x40 channel 4 + adc_set_for_read_ch(0x40); + adc_read_ch(0x40); + SetBit (FPGA2, F2_CTRL, 4, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,2); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,3); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 6 + SetBit (FPGA2, F2_CTRL, 5, 1); + stubManager.Write("\tTesting SSR no. 6\tHeadZone-3\t"); + Thread.Sleep(10000); + adc_configuration(0x40,0x04); //a2d_address 0x40 channel 5 + adc_set_for_read_ch(0x40); + adc_read_ch(0x40); + SetBit (FPGA2, F2_CTRL, 5, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,3); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,4); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 5 + SetBit (FPGA2, F2_CTRL, 6, 1); + stubManager.Write("\tTesting SSR no. 5\tHeadZone-4\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x80); //a2d_address 0x44 channel 0 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44); + SetBit (FPGA2, F2_CTRL, 6, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,4); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,5); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 10 + SetBit (FPGA1, F1_gpo_01, 2, 1); + stubManager.Write("\tTesting SSR no. 10\tHeadZone-5\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44); + SetBit (FPGA1, F1_gpo_01, 2, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,5); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,11); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 11 + SetBit (FPGA3, F3_GPO_01_bus, 4, 1); + stubManager.Write("\tTesting SSR no. 11\tHeadZone-6\t"); + Thread.Sleep(10000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44); + SetBit (FPGA3, F3_GPO_01_bus, 4, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,11); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + + stubManager.Write("\n"); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,0); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + //Write F2_GPO_MIXCHIP_SSR4_CTRL SSR/SSR no. 4 + SetBit (FPGA2, F2_CTRL, 7, 1); + stubManager.Write("Testing SSR no. 4\tMIXCHIP \t"); + Thread.Sleep(10000); + adc_configuration(0x46,0x08); //a2d_address 0x46 channel 4 + adc_set_for_read_ch(0x46); + adc_read_ch(0x46); + + SetBit (FPGA2, F2_CTRL, 7, 0); + response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,0); // + stubManager.WriteHex(response.TemperatureCMultBy100,4); + + +} + +//---------------------- + +int adc_configuration(uint I2C_Slave_Add,uint channel ) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(channel);//Byte 1 to Write, must be 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 or 0x01 for different channels + stubI2CWriteBytesRequest.BytesTWrite.Add(0x80);//Byte 2 to Write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } + + + + +int adc_set_for_read_temp(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x02);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } + + + + +int adc_read_temp(uint I2C_Slave_Add) + { + + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + stubManager.WriteLineHex(response1.ReadBytes[i],2); + } + + + return 1; + } + + + + +int adc_set_for_read_ch(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x01);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } + + +int adc_read_ch(uint I2C_Slave_Add) + { + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + uint templ=0; + uint temp; + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i=i+2) + { + temph=response1.ReadBytes[i]; + templ=response1.ReadBytes[i+1]; + temp = (temph << 8) | templ; + temp=temp & 0x0fff; + stubManager.WriteHex(temp,4); + + } + + return 1; + } + + diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/Jig/DyeHeadJig.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/Jig/DyeHeadJig.cs new file mode 100644 index 000000000..3e5ccf085 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/Jig/DyeHeadJig.cs @@ -0,0 +1,384 @@ +//-------------------------------------------------------------------------------- + +//include "Dispenser_setup_mbar1.cs" +//include "C:\Dispenser_setup\Dispenser_setup_seal_test.cs" + +//-------------------------------------------------------------------------------- +//include "Dispenser_Motor_stop.cs" +//include "Dispenser_setup_form_valve close_1.cs" +//include "Dispenser_setup_form_valve open_1.cs" +//include "Dispenser_Motor_run.cs" +//include "Dispenser_Motor_Up.cs" +//include "Dispenser_Motor_Down.cs" +//-------------------------------------------------------------------------------- +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//-------------------------------------------------------------------------------- +const Int32 RDANCER_Motor = 21; +const Int32 RDRIVING_Motor = 22; +const Int32 RLOADING_Motor = 24; + +//-------- + +const Int32 F1_LS_RLOADMOTOR_UP = 0x0040 ; +const Int32 F1_LS_RLOADMOTOR_DN = 0x0080 ; + + + + + + +const Int32 F1_MOTO_RLOADING_TX1 = 0x60000202; +const Int32 F1_MOTO_RLOADING_TX0 = 0x60000200; +const Int32 F1_MOTO_RLOADING_RX1 = 0x60000206; +const Int32 F1_MOTO_RLOADING_RX0 = 0x60000204; + + +const Int32 F1_LS_03_Direct =0x60000040; +//-------------------------------------------------------------------------------- +string path1="M:\\RTFU\\Reports\\"; +string File_Name1 ; +string Status; + + + +//----------------------------------------------------- + +//int SealTest=0; +//int Characterization; +string RTFU_Sn; +//int dispenserNumber=1; +//string Dtype=""; +//int Table=0; +///string shortDateString; + +//UInt32 Type_card; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ + stubManager.Write("Counter is 1 \n"); + +//----------------------------------------------------------------------------------------------------------------------------------------------------- +//stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0X60000522, 0X128);//0X128 EQULE 50 MSEC + + //-----------------------------detect card ---------------------------- + + +//--------------------------------------------------------------------------------------------------------------------------------------------------------- + + +//Create form + Form form1 = new Form(); + +//-------------------------------------------------------------------------------- + +// Create buttons to use as the accept and cancel buttons. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + +//-------------------------------------------------------------------------------- +// Set the text of button + + button1.Text = "Run"; + + +//-------------------------------------------------------------------------------- +// Set the position of the button on the form. + + button1.Location = new Point (40, 100); + + + + +//-------------------------------------------------------------------------------- + // Add button to the form. + + form1.Controls.Add(button1); + + + +//-------------------------------------------------------------------------------- + +// Set the caption bar text of the form. + + form1.Text = "RTFU Test"; + +//-------------------------------------------------------------------------------- + + // Define the border style of the form to a dialog box. + + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + + // Set the MaximizeBox to false to remove the maximize box. + + form1.MaximizeBox = false; + + // Set the MinimizeBox to false to remove the minimize box. + + form1.MinimizeBox = false; + + // Set the start position of the form to the center of the screen. + + form1.StartPosition = FormStartPosition.CenterScreen; + + + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; + +//-----RTFU Serial Number ----------- + +Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" RTFU S/N" + }; +Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + + +TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + +//-----USER NAME ----------- + +Label Label2 = new Label () + { + Width = 150, + Height = 20, + Text ="USER NAME" + }; +Label2.Location = new Point (190, 10); + form1.Controls.Add(Label2); + + +TextBox TextBox2 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox2.Location = new Point (200, 40); + form1.Controls.Add(TextBox2); + +//----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { + +//File_Name1=path1 +"RTFU.log" ; +File_Name1=path1 + TextBox1.Text +"_RTFU_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; +//File_Name1=path1 + DateTime.Now+"RTFU.log" ; + +stubManager.Write(File_Name1 +"\n"); +stubManager.WriteToFile(File_Name1,DateTime.Now +"\n" ); +stubManager.Write(DateTime.Now +"\n" ); + +stubManager.AppendToFile(File_Name1,"RTFU Test Report\n" ); +stubManager.Write("RTFU Test Report\n" ); + +stubManager.AppendToFile(File_Name1,"RTFU S/N: \t" + TextBox1.Text +"\n" ); +stubManager.Write("RTFU S/N:" + TextBox1.Text +"\n" ); + +stubManager.AppendToFile(File_Name1,"User Name:\t" + TextBox2.Text +"\n" ); +stubManager.Write("User Name:" + TextBox2.Text +"\n" ); + + +stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text +"\n" ); +stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + + + + +Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; +Label5.Location = new Point (300, 100); +Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + +Label5.Text="Pros"; +Label5.Font = new Font("Arial", 24,FontStyle.Bold); +form1.Controls.Add(Label5); + +Status=Test_RLOADING_RTFU (); + Label5.Text=Status; + TextBox1.Text=""; +}; + + form1.ShowDialog(); + + stubManager.Write("Counter is \n"); + + + return; + } + //------------------------------------ +string Test_RLOADING_RTFU() +{ + int temp=1; + int counter; + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x2c000000); //set kval ran to 0x2c + Thread.Sleep(100); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,100); //move Rloading down + Thread.Sleep(3000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading + Thread.Sleep(1000); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor,false,100); //move Rloading up + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RLOADMOTOR_UP) !=F1_LS_RLOADMOTOR_UP ) //if LS_RLOADMOTOR_UP is up then error + { + stubManager.AppendToFile(File_Name1,"LS_RLOADMOTOR_UP\tFail"); + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return "Fail"; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_UP) != F1_LS_RLOADMOTOR_UP ) + counter=150; + Thread.Sleep(100); + } + if (counter >= 150) + { + stubManager.AppendToFile(File_Name1,"LS_RLOADMOTOR_UP or Motors RLOADING \tFail"); + stubManager.Write("LS_RLOADMOTOR_UP or Motors RLOADING \tFail\n"); + return "Fail"; + } + stubManager.AppendToFile(File_Name1,"LS_RLOADMOTOR_UP\tPass"); + stubManager.Write("LS_RLOADMOTOR_UP or Motors RLOADING \tPass\n"); +//----------------------------------------------------------------------------------------------------- + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,100); //move Rloading down + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + + if ((response.Value & F1_LS_RLOADMOTOR_DN) !=F1_LS_RLOADMOTOR_DN ) //if LS_RLOADMOTOR_DN is up then error + { + stubManager.AppendToFile(File_Name1,"LS_RLOADMOTOR_DN\tFail"); + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return "Fail"; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_DN) != F1_LS_RLOADMOTOR_DN ) + counter=150; + Thread.Sleep(100); + } + if (counter >= 150) + { + stubManager.AppendToFile(File_Name1,"LS_RLOADMOTOR_DN \tFail"); + stubManager.Write("LS_RLOADMOTOR_UP RLOADING \tFail\n"); + return "Fail"; + } + Thread.Sleep(1000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading + Thread.Sleep(1000); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14 + + return "Pass";; + +} +//------------------------------------------------------------- +int Test_RDRIVING_RTFU() +{ + int temp=1; + int counter; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDRIVING_Motor, true,200); //move Rdriving clockwise + + DialogResult result1 = MessageBox.Show("Are RDRIVING_Motor move clockwise ?","Important Question",MessageBoxButtons.YesNo); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDRIVING_Motor, 3); //hold Rloading + if (result1==DialogResult.Yes) + { + stubManager.AppendToFile(File_Name1,"RDRIVING_RTFU\tPass"); + stubManager.Write("RDRIVING_RTFU\tPass\n"); + return 1; + } + else + { + stubManager.AppendToFile(File_Name1,"RDRIVING_RTFU\tFail"); + stubManager.Write("RDRIVING_RTFU\tFail\n"); + return 0; + } +} +//-------------------------------------------------------------------------------- + + +//-------------------------------------------------------------------------------- + +//-------------------------------------------------------------------------------- + + +//-------------------------------------------------------------------------------- + +// Display the form as a modal dialog box. + +// ParaData1 shall be left justified i.e. <cmd><Byte0><Byte1><Byte2> +int Motor_SetParam(Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr, uint ParaData1) +{ + + Int32 Temp = 0; + Temp = (ParaAddr << 8 ) + ( (Int32) ParaData1 >> 24); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,HighAdr, (Temp & 0xffff)); + Temp = ((Int32)ParaData1 >> 8) & 0xffff; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,LowAdr, (Temp)); + //Fpga_Read_Reg(Fpga, HighAdr+4, 1); + //Fpga_Read_Reg(Fpga, LowAdr+4, 1); + + return 1; +} diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/header_LimitSwitch.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/header_LimitSwitch.cs new file mode 100644 index 000000000..4454e9c63 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/header_LimitSwitch.cs @@ -0,0 +1,48 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_LimitSwitch.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\LAB_Tests\Main_PCB\ATP_Test\Scripts\Defines\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\LAB_Tests\Main_PCB\ATP_Test\Scripts\Defines\Tango_Defines_LimitSwitch.cs" + + + + +public void OnExecute(StubManager stubManager) +{ + + uint Temp = 0; + int counter = 0; + stubManager.Write("\nReading register F1_LS_01_Direct: "); + var RetVal = Fpga_Read_Reg(FPGA1, F1_LS_01_Direct, 0); + stubManager.WriteHex(RetVal.Value,4); + Temp = RetVal.Value; + stubManager.Write("\nActivate limit switches one-by-one"); + + while ( counter != 10000) + { + RetVal = Fpga_Read_Reg(FPGA1, F1_LS_01_Direct, 0); + if (RetVal.Value != Temp) + { + stubManager.Write("\nRegister F1_LS_01_Direct new value: "); + stubManager.WriteHex(RetVal.Value,4); + counter = counter + 1; + } + Thread.Sleep(100); + Temp = RetVal.Value; + + } + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magner_ssr.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magner_ssr.cs new file mode 100644 index 000000000..54e3f4844 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magner_ssr.cs @@ -0,0 +1,68 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Interfaces\Tango_Defines_SSR.cs" + + +public void OnExecute(StubManager stubManager) +{ +Int32 Bit = 1; + + //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + //SetBit (FPGA2, F2_CTRL, 0, 1); + stubManager.Write("\nTesting SSR no. 13 of magnet"); + //Thread.Sleep(4000); + +//var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 50); + + + stubManager.Write("\n*** Open Lid Head "); + Bit = 1; + + /*while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,7); + Thread.Sleep(10); + } + Thread.Sleep(100); + stubManager.Write("\n--------1--------"); + + + stubManager.Write("\n*** Close Lid Head "); + Bit = 1; + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, false, 50); + + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,8); + Thread.Sleep(10); + } + Thread.Sleep(100); + stubManager.Write("\n--------2--------"); + + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 0);*/ + + SetBit (FPGA2, F2_CTRL, 0, 1);//open + SetBit (FPGA2, F2_CTRL, 0, 0);//close + + +// var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,0, true, 50); motor clean + +//response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,1, true, 50); motor clean + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magnet_motor_limit_switch.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magnet_motor_limit_switch.cs new file mode 100644 index 000000000..0dcf29853 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magnet_motor_limit_switch.cs @@ -0,0 +1,69 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +include "Tango_Defines_LimitSwitch.cs" + +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Interfaces\Tango_Defines_SSR.cs" + + +public void OnExecute(StubManager stubManager) +{ +Int32 Bit = 1; + + //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + SetBit (FPGA2, F2_CTRL, 0, 1); + stubManager.Write("\nTesting SSR no. 13 of magnet"); + Thread.Sleep(4000); + +var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 50); + + + stubManager.Write("\n*** Open Lid Head "); + Bit = 1; + + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,7); + Thread.Sleep(10); + } + Thread.Sleep(100); + stubManager.Write("\n--------1--------"); + + + stubManager.Write("\n*** Close Lid Head "); + Bit = 1; + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, false, 50); + + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,8); + Thread.Sleep(10); + } + Thread.Sleep(100); + stubManager.Write("\n--------2--------"); + + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 0); + + SetBit (FPGA2, F2_CTRL, 0, 0); + + +// var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,0, true, 50); motor clean + +//response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,1, true, 50); motor clean + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magnet_motor_limit_switch1.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magnet_motor_limit_switch1.cs new file mode 100644 index 000000000..a5a43f137 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Dye head/magnet_motor_limit_switch1.cs @@ -0,0 +1,75 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_SSR.cs" +include "Tango_Defines_LimitSwitch.cs" + +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\Software\Stub_scripts\Interfaces\Tango_Defines_SSR.cs" + + +public void OnExecute(StubManager stubManager) +{ +Int32 Bit = 1; + + //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + SetBit (FPGA2, F2_CTRL, 0, 1); + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,23, false,0x800000+0); + + stubManager.Write("\nTesting SSR no. 13 of magnet or motor driver"); + Thread.Sleep(1000); + +var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 150); + + + stubManager.Write("\n*** Open Lid Head "); + Bit = 1; + + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,7); + Thread.Sleep(50); + } + Thread.Sleep(2000); + stubManager.Write("\n--------1--------"); + + + stubManager.Write("\n*** Close Lid Head "); + Bit = 1; + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, false, 150); + + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_01_Direct,8); + Thread.Sleep(50); + } + Thread.Sleep(100); + stubManager.Write("\n--------2--------"); + + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,2, true, 0); + + SetBit (FPGA2, F2_CTRL, 0, 0); + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,23, false,0x800000+2); + Thread.Sleep(1000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,23,3); + + +// var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,0, true, 50); motor clean + +//response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,1, true, 50); motor clean + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/ElectricalEnclosure/ElectricalEnclosure_Fans1.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/ElectricalEnclosure/ElectricalEnclosure_Fans1.cs index 264400e64..af5a07543 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/ElectricalEnclosure/ElectricalEnclosure_Fans1.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/ElectricalEnclosure/ElectricalEnclosure_Fans1.cs @@ -83,31 +83,55 @@ public void OnExecute(StubManager stubManager) var RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg0, 0); stubManager.Write("\nFan5 Speed-"); stubManager.WriteHex(RetVal.Value,4); + + + + + RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg1, 0); + stubManager.Write("\nFan1 Speed-"); + stubManager.WriteHex(RetVal.Value,4); RetVal = Fpga_Read_Reg(FPGA1, F1_gpi_FANS, 0); Temp1=RetVal.Value & 0x0001; if (Temp1 !=0x0001) - stubManager.Write("\nFan1 Running "); + stubManager.Write("\tFan1 Running "); else - stubManager.Write("\nFan1 Stop"); + stubManager.Write("\tFan1 Stop"); + + + RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg2, 0); + stubManager.Write("\nFan2 Speed-"); + stubManager.WriteHex(RetVal.Value,4); + Temp1=RetVal.Value & 0x0002; if (Temp1 !=0x0002) - stubManager.Write("\nFan2 Running "); + stubManager.Write("\tFan2 Running "); else - stubManager.Write("\nFan2 Stop"); + stubManager.Write("\tFan2 Stop"); + + RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg3, 0); + stubManager.Write("\nFan3 Speed-"); + stubManager.WriteHex(RetVal.Value,4); + Temp1=RetVal.Value & 0x0004; if (Temp1 !=0x0004) - stubManager.Write("\nFan3 Running "); + stubManager.Write("\tFan3 Running "); else - stubManager.Write("\nFan3 Stop"); + stubManager.Write("\tFan3 Stop"); + + + RetVal=Fpga_Read_Reg(FPGA1, F1_Tacho_reg4, 0); + stubManager.Write("\nFan4 Speed-"); + stubManager.WriteHex(RetVal.Value,4); + Temp1=RetVal.Value & 0x0008; if (Temp1 !=0x0008) - stubManager.Write("\nFan4 Running "); + stubManager.Write("\tFan4 Running "); else - stubManager.Write("\nFan4 Stop"); + stubManager.Write("\tFan4 Stop"); Fpga_Read_Reg(FPGA1, F1_Tacho_reg5, 1); stubManager.Write("\n"); diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_JIG.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_JIG.cs new file mode 100644 index 000000000..f961158e9 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_JIG.cs @@ -0,0 +1,574 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +//-------------------------------------------------------------------------------- + +//-------------------DEFINE Motors------------------ +const Int32 LDANCER_Motor = 16; +const Int32 LDRIVING_Motor = 18; +const Int32 LLOADING_Motor = 19; + +//-------------------DEFINE Motors Parameters------------------ + +const Int32 F1_MOTO_LLOADING_TX1 = 0x60000232; +const Int32 F1_MOTO_LLOADING_TX0 = 0x60000230; + + +//-------------------DEFINE Limit Switch--------------- +const Int32 F1_LS_02_Direct =0x60000030; + +const Int32 F1_LS_LLOADMOTOR_UP = 0x0100 ; +const Int32 F1_LS_LLOADMOTOR_DN = 0x0200 ; +const Int32 F1_LS_LDANCER1_UP = 0x1000; +const Int32 F1_LS_LDANCER1_DN = 0x2000; +const Int32 F1_LS_LDANCER2_UP = 0x0400; +const Int32 F1_LS_LDANCER2_DN = 0x0800; +const Int32 F1_LS_LLOADRAM_LF = 0x0080; +const Int32 F1_LS_LLOADRAM_RT = 0x0040; + + +const Int32 F1_LDANCER1_ROTENC_MSB = 0x600001c2; +const Int32 F1_LDANCER1_ROTENC_LSB = 0x600001c0; +const Int32 F1_LDANCER1_ROTENC_TX = 0x600001ce; + +const Int32 F1_LDANCER2_ROTENC_MSB = 0x600001b2; +const Int32 F1_LDANCER2_ROTENC_LSB = 0x600001b0; +const Int32 F1_LDANCER2_ROTENC_TX = 0x600001be; + +const int UNIT_UNDER_TEST=3+1+5; +//-------------------------------------------------------------------------------- +string path1="P:\\Scripts\\Assemblies\\LTFU\\LTFULog\\"; +string path2="C:\\LTFULog\\"; + +string File_Name1 ; +string Status; +//--------------------------- + +string [,] Units_status = new string[UNIT_UNDER_TEST,2] { + {"LS_LLOADMOTOR_Up","Not Test"}, //0 + {"LS_LLOADMOTOR_DOWN","Not Test"}, //1 + {"LLOADING_Motor","Not Test"}, //2 + {"LDRIVING_Motor","Not Test"}, //3 + {"LS_LDANCER1_DOWN","Not Test"}, //4 + {"LS_LDANCER1_UP","Not Test"}, //5 + {"LDANCER_Motor","Not Test"}, //6 + {"LDANCER1_ROTENC","Not Test"}, //7 + {"LDANCER1_ROTENC","Not Test"}, //8 + }; +//----------------------------------------------------- +string LTFU_Sn; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + Motor_SetParam(F1_MOTO_LLOADING_TX1,F1_MOTO_LLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + +// Set the caption bar text of the form. + form1.TopMost = true; + form1.Text = "LTFU Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----LTFU Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" LTFU S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + + + + + Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; + Label5.Location = new Point (300, 100); + Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + + Label5.Text=""; + Label5.Font = new Font("Arial", 24,FontStyle.Bold); + form1.Controls.Add(Label5); + + + + +//-------------------------------------------------------------------------------- + + button1.Click += (_,__) => + + { + + Label5.Text="Pros"; + + if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } + else + path=path1; + + File_Name1=path + TextBox1.Text +"_LTFU_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + + stubManager.Write(File_Name1 +"\n"); + stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); + stubManager.Write(DateTime.Now +"\n" ); + + stubManager.AppendToFile(File_Name1,"LTFU Test Report" ); + stubManager.Write("LTFU Test Report\n" ); + + stubManager.AppendToFile(File_Name1,"LTFU S/N: \t" + TextBox1.Text ); + stubManager.Write("LTFU S/N:" + TextBox1.Text +"\n" ); + + + stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); + stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + +//------------------------------- start test ----------- + Test_LLOADING_LTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold LRoading high z + Thread.Sleep(100); + Motor_SetParam(F1_MOTO_LLOADING_TX1,F1_MOTO_LLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + + Test_LDRIVING_LTFU(); + + Test_DANCER_LTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDANCER_Motor, 3); //hold Lloading high z + + Status=write_to_file(); + stubManager.Write(Status +"\n"); + + Label5.Text=Status; + TextBox1.Text=""; + }; + + form1.ShowDialog(); + + return ; + } + + //------------------------------------ +int Test_LLOADING_LTFU() +{ + int temp=1; + int counter; + + Motor_SetParam(F1_MOTO_LLOADING_TX1,F1_MOTO_LLOADING_TX0,0x0a,0x2c000000); //set kval ran to 0x2c- 1.3A + Thread.Sleep(100); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor, false,200); //move Rloading down + Thread.Sleep(3000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(1000); +//------------------------------------------ check F1_LS_LLOADMOTOR_UP------------------------------------------------ + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + if ((response.Value & F1_LS_LLOADMOTOR_UP) !=F1_LS_LLOADMOTOR_UP ) //if LS_RLOADMOTOR_UP is up then error + { + DialogResult result = MessageBox.Show("Did LLOADIN MOTOR Move?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.Yes) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_UP\tFail\n"); + return 0; + } + else + { + Units_status[2,1]="Fail"; + stubManager.Write("LLOADMOTOR\tFail\n"); + return 0; + } + } +//----------------------------------------- mov LLOADING up ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor,true,200); //move Lloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if LS_LLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_LLOADMOTOR_UP) != F1_LS_LLOADMOTOR_UP ) + counter=250; + + Thread.Sleep(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Lloading high z + + if (counter == 150) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_UP\tFail\n"); + return 0; + } + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_UP Not calibrate\n"); + return 0; + } + Units_status[0,1]="Pass"; + Units_status[2,1]="Pass"; + +//------------------------------------------ check F1_LS_LLOADMOTOR_DN------------------------------------------------ + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + + if ((response.Value & F1_LS_LLOADMOTOR_DN) !=F1_LS_LLOADMOTOR_DN ) //if LS_LLOADMOTOR_DN is up then error + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_DN\tFail\n"); + return 0; + } +//------------------------------------------ mov LLOADING dn ------------------------------------------------ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor, false,200); //move Lloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if LS_LLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_LLOADMOTOR_DN) != F1_LS_LLOADMOTOR_DN ) + counter=250; + + Thread.Sleep(100); + } + + if (counter == 150) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_DN\tFail\n"); + return 0; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Lloading high z + + DialogResult result4 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result4 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_DN Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + stubManager.Write("LLOADMOTOR\tPass\n"); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor, false,200); //move Lloading down + Thread.Sleep(2000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Lloading high z + + return 1 ; + +} + + +Int32 ReadEncoder(int i) +{ + Int32 temp; + + if (i==0) //LDANCER1_ROTENC + { + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_LDANCER1_ROTENC_TX, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER1_ROTENC_LSB); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER1_ROTENC_MSB); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + + + return temp; + } + //LDANCER2_ROTENC + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_LDANCER2_ROTENC_TX, 0x0000); //triggers a TX transmission + var response2 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER2_ROTENC_LSB); + var response3 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER2_ROTENC_MSB); + + temp = Convert.ToInt32 (((((response3.Value <<16) + response2.Value)>>10 ) & 0x3fff)); + + + return temp; +} +//-------------------------------------------------------------------------------- +int Test_DANCER_LTFU() +{ + int counter; + Int32 temp; + Int32 temp1; + Int32 temp2; + Int32 temp3; + + +//------------------------------------------ check F1_LS_LDANCER1_DN ------------------------------------------------ + + MessageBox.Show("Make sure LDANCER Doun"); + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + + + if ((response.Value & F1_LS_LDANCER1_UP) !=F1_LS_LDANCER1_UP ) //if F1_LS_LDANCER1_UP is up then error + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_LDANCER_UP\tFail\n"); + return 0; + } + +//----------------------------------------- check F1_LS_LDANCER1_UP ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LDANCER_Motor,false,400); //move Lloading up + counter =0; + while ( counter < 250) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if F1_LS_LDANCER1_UP is up then move down + if ((response.Value & F1_LS_LDANCER1_UP) != F1_LS_LDANCER1_UP ) + counter=350; + + Thread.Sleep(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDANCER_Motor, 3); //hold Ldancer high z + + + if (counter == 250) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_LDANCER1_UP\tFail\n"); + return 0; + } + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + if ((response.Value & F1_LS_LDANCER1_DN) !=F1_LS_LDANCER1_DN ) //if F1_LS_LDANCER1_DN is up then error + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_LDANCER1_DOWN\tFail\n"); + return 0; + } + + DialogResult result5= MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + + if(result5== DialogResult.No) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_LDANCER1_UP Not calibrate\n"); + return 0; + } + + Units_status[5,1]="Pass"; + stubManager.Write("LS_LDANCER1_UP\tPass\n"); + +//----------------------------------------- mov LDANCER_Motor down and check Ldancer encoder ------------------------------------------------- + temp= ReadEncoder(0); + temp2= ReadEncoder(1); + + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LDANCER_Motor,true,400); //move Rloading down + counter =0; + while ( counter < 250) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if LS_LDANCER1_DN is dn then move stop + if ((response.Value & F1_LS_LDANCER1_DN) != F1_LS_LDANCER1_DN ) + counter=350; + + Thread.Sleep(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDANCER_Motor, 3); //hold Rloading high z + if (counter == 250) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_LDANCER1_DOWN\tFail\n"); + return 0; + } + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + + if(result2 == DialogResult.No) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_LDANCER1_DN Not calibrate\n"); + return 0; + } + + Units_status[4,1]="Pass"; + stubManager.Write("LS_LDANCER1_DN\tPass\n"); + + Units_status[6,1]="Pass"; + stubManager.Write("LDANCER_Motor\tPass\n"); + + temp1= ReadEncoder(0); + temp3= ReadEncoder(1); + + stubManager.Write("temp="+temp + "\temp1="+temp1 +"\n"); + + DialogResult result = MessageBox.Show("SSI Dancer1 led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[7,1]="Fail"; + stubManager.Write("LDANCER1_SSI\tFail\n"); + } + else + { + if (temp>temp1) + temp1=temp1+0x4000; + temp1=temp1-temp; + if ((temp1> 4000) || (temp1 <200)) + { + Units_status[7,1]="Fail"; + stubManager.Write("LDANCER1_SSI\tFail\n"); + } + else + { + Units_status[7,1]="Pass"; + stubManager.Write("LDANCER1_SSI\tPass\n"); + } + } + stubManager.Write("temp2="+temp2 + "\temp3="+temp3 +"\n"); + + DialogResult result3 = MessageBox.Show("SSI Dancer2 led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result3 == DialogResult.No) + { + Units_status[8,1]="Fail"; + stubManager.Write("LDANCER2_SSI\tFail\n"); + } + else + { + if (temp3>temp2) + temp2=temp2+0x4000; + temp2=temp2-temp3; + if ((temp1> 4000) || (temp1 <2000)) + { + Units_status[8,1]="Fail"; + stubManager.Write("LDANCER2_SSI\tFail\n"); + } + else + { + Units_status[8,1]="Pass"; + stubManager.Write("LDANCER2_SSI\tPass\n"); + } + } + return 1; +} + + +//------------------------------------------------------------- +int Test_LDRIVING_LTFU() +{ + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LDRIVING_Motor, true,200); //move Ldriving clockwise + stubManager.Write("LDRIVING_Motor Motor rotate \n "); + + DialogResult result = MessageBox.Show("Are LDRIVING Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("LDRIVING Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("LDRIVING Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDRIVING_Motor,3); //stop motor + + return 0; +} + + + +//-------------------------------------------------------------------------------- +int Motor_SetParam(Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr, uint ParaData1) +{ + + Int32 Temp = 0; + Temp = (ParaAddr << 8 ) + ( (Int32) ParaData1 >> 24); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,HighAdr, (Temp & 0xffff)); + Temp = ((Int32)ParaData1 >> 8) & 0xffff; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,LowAdr, (Temp)); + + return 1; +} + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<UNIT_UNDER_TEST;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------LTFU Fail ------------ "); + stubManager.Write("-------------LTFU Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------LTFU Pass ------------ )"); + stubManager.Write("-------------LTFU Pass ------------ "); + } + + return Stemp; + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_Motors_Switch.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_Motors_Switch.cs index 7578e825d..9955e0e5d 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_Motors_Switch.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_Motors_Switch.cs @@ -14,6 +14,8 @@ using Tango.Stubs; include "..\..\Defines\Tango_Defines_Basic.cs" include "Tango_Defines_Motors.cs" +include "Tango_Defines_LimitSwitch.cs" + //include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\LAB_Tests\Main_PCB\ATP_Test\Scripts\Defines\Tango_Defines_Basic.cs" //include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\LAB_Tests\Main_PCB\ATP_Test\Scripts\Defines\Tango_Defines_Motors.cs" @@ -21,15 +23,108 @@ include "Tango_Defines_Motors.cs" public void OnExecute(StubManager stubManager) { - +Int32 Bit = 1; stubManager.Write("\n*** LTFU Motor + limit switch Test ***"); -// stubManager.Write("\n*** Pulling motor drivers out of reset"); SetBit(FPGA1, F1_Moto_Driver_NSTBYRST1, 0, 1); SetBit(FPGA1, F1_Moto_Driver_NSTBYRST1, 1, 1); SetBit(FPGA1, F1_Moto_Driver_NSTBYRST1, 2, 1); SetBit(FPGA1, F1_Moto_Driver_NSTBYRST1, 4, 1); - stubManager.Write("\n*** F1_MOTO_LPIVOT1 is moving back and forth "); + stubManager.Write("\n*** Moving motor F1_MOTO_LLOADING back and for"); + Bit = 1; + + var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,19,true , 500); + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_02_Direct,8); + Thread.Sleep(10); + } + Thread.Sleep(100); + stubManager.Write("\n--------1--------"); + + +response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,19, false, 500); + Bit = 1; + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_02_Direct,9); + Thread.Sleep(10); + } + stubManager.Write("\n--------2--------"); + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,19, false, 0); + + Thread.Sleep(100); + var response1 = stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,19, false, 5000); + Thread.Sleep(1000); + Motor_HighZ(FPGA1, F1_MOTO_LLOADING_TX1, F1_MOTO_LLOADING_TX0); + stubManager.Write("\n*** Stopped motor F1_MOTO_LLOADING"); + + + //mov ldriving - + stubManager.Write("\n*** Running motor F1_MOTO_LDRIVING for 4 seconds... "); + Motor_Run(FPGA1, F1_MOTO_LDRIVING_TX1, F1_MOTO_LDRIVING_TX0, 0xffff, 0x1); + Thread.Sleep(4000); + Motor_HighZ(FPGA1, F1_MOTO_LDRIVING_TX1, F1_MOTO_LDRIVING_TX0); + + + + + + + + + stubManager.Write("\n\n*** Moving motor F1_MOTO_LDANCER1 back and for ..."); + + Bit = 1; + response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,16,false ,500); + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_02_Direct,12); + Thread.Sleep(10); + } + Thread.Sleep(100); + stubManager.Write("\n--------1--------"); + + +response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,16, true, 500); + Bit = 1; + while (Bit != 0x0) //wait until LTFU LOADRAM Down + { + Bit = GetBit(FPGA1, F1_LS_02_Direct,13); + Thread.Sleep(10); + } + + Thread.Sleep(1000); + Motor_HighZ(FPGA1, F1_MOTO_LDANCER1_TX1, F1_MOTO_LDANCER1_TX0); + + + + + +/* + + + + + + + + + + + + + + + + + + + + + + + @@ -107,7 +202,7 @@ public void OnExecute(StubManager stubManager) // Thread.Sleep(4000); stubManager.Write("\n\n*** RTFU Motor Test Ended ***"); - + */ } diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_SSI.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_SSI.cs index 3218dbd83..94873f9f4 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_SSI.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_SSI.cs @@ -31,18 +31,64 @@ public void OnExecute(StubManager stubManager) for (int i = 0; i < 100; i++) { - - SSI_Read_Write(FPGA1, F1_LDANCER1_ROTENC_MSB, F1_LDANCER1_ROTENC_LSB, F1_LDANCER1_ROTENC_TX); - SSI_Read_Write(FPGA1, F1_LDANCER2_ROTENC_MSB, F1_LDANCER2_ROTENC_LSB, F1_LDANCER2_ROTENC_TX); - stubManager.Write("\n"); - k++; - if ( (k & 0x8) == 0x08 ) { - k = 0; - stubManager.Write(" LDANCER1 LDANCER2 \n"); - } + + stubManager.Write("LDANCER1 - "+ ReadEncoder(0)+ "\t\t LDANCER2 - " + ReadEncoder(1) + "\n" ); + + + Thread.Sleep(400); } } + + +Int32 ReadEncoder(int i) +{ + Int32 temp; + + if (i==0) //LDANCER1_ROTENC + { + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x600001ce, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x600001c0); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x600001c2); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + + + return temp; + } + //LDANCER2_ROTENC + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x600001be, 0x0000); //triggers a TX transmission + var response2 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x600001b0); + var response3 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x600001b2); + + temp = Convert.ToInt32 (((((response3.Value <<16) + response2.Value)>>10 ) & 0x3fff)); + + + return temp; +} + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/Calibrate_Midtank_pressure_sensors.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/Calibrate_Midtank_pressure_sensors.cs new file mode 100644 index 000000000..9af524c88 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/Calibrate_Midtank_pressure_sensors.cs @@ -0,0 +1,347 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.PMR.EmbeddedParameters; +using Tango.Stubs; + +//---------------------- +const double MIN_SLOP=0.8; +const double MAX_SLOP=1.4; +const double ERROR_SLOP=-1; +const double MIN_50cc_on_volt=2.3; +const double MAX_50cc_on_volt=3.2; +const double ERROR_50cc_on_volt=-1; + + + +const Int32 F3_VALVE_OUT = 0x600008E2 ; +string Machine_SN ; +private const string FILE_PATH = "P:\\Operations\\Log\\Midtanlk\\"; +string File_name; +double [,] voltage_array = new double[9,9]; +string [] Parameter = new string[5] {"\t","Empty [V]","100cc [V]","800cc [V]"," b [L/V] "}; + +//---------------------- +const Int32 I2C_ID = 2; +//const Int32 I2C_Slave_Add = 0x46; //must be 0x40, 0x44 or 0x46 +//---------------------- + + + + + +public void OnExecute(StubManager stubManager) +{ + + + voltage_array[1,0]=1; + voltage_array[2,0]=2; + voltage_array[3,0]=3; + voltage_array[4,0]=4; + voltage_array[5,0]=5; + voltage_array[6,0]=6; + voltage_array[7,0]=7; + voltage_array[8,0]=8; + + var response = stubManager.ShowResponseWindow("Enter Machine S/N: ", ""); + stubManager.Write("\n"); + Machine_SN = response; + stubManager.Write(Machine_SN); + File_name= FILE_PATH +Machine_SN + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".LOG"; + stubManager.Write(File_name); + stubManager.WriteToFile(File_name,"Machine S/N:" + Machine_SN); + + string box_msg = "Make Sure all Midatnk empty"; + // string box_title = "Midatnk empty"; +// MessageBox.Show(box_msg, box_title); + MessageBox.Show(box_msg); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F3_VALVE_OUT, 0x000f); // open all valve air of midtank and close all ink of midtank + Thread.Sleep(500); + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F3_VALVE_OUT, 0x00ff); // open all valve air of midtank and close all ink of midtank + Thread.Sleep(500); + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F3_VALVE_OUT, 0x0fff); // open all valve air of midtank and close all ink of midtank + Thread.Sleep(500); + stubManager.Run<StubFpgaWriteRegResponse>("stubFpgaWriteRegRequest" ,F3_VALVE_OUT, 0xffff); // open all valve air and ink of midtank + + Thread.Sleep(2500); + + Thread.Sleep(1000); + + read_pressure_sensor(1); + + box_msg ="Insert 100cc of appropriate ink/lube to each midtank\n\t1.black ink\n\t2. Magenta ink\n\t3. Transparent ink\n\t4. Cleaner\n\t5. Cyan ink\n\t6. Yellow ink\n\t7. Spot color\n\t8. Lubricant/n"; + MessageBox.Show(box_msg); + + read_pressure_sensor(2); + + // voltage_array[3,2]=2.5; + + box_msg = "Add another 700cc for ink and TI \nFor Lubbricant add 500cc only."; + MessageBox.Show(box_msg); + read_pressure_sensor(3); + stubManager.Run<StubFpgaWriteRegResponse>("stubFpgaWriteRegRequest" ,F3_VALVE_OUT, 0x0000); // close all valve air and ink of midtank + // voltage_array[3,3]=4.5; + + calc_slop(); + print_table(); + + insert_slop_t_eeprom(); + box_msg ="Turn Power Off and On to finish the calibration."; + MessageBox.Show(box_msg); + + } + +int calc_slop() + { + stubManager.Write("\n "); + + double delta; + for (uint i=1;i<9;i++) + { + delta=voltage_array[i,3]-voltage_array[i,2]; + + stubManager.Write("\nMidtank No:"+i +"="+delta); + if (i==8) + delta=0.5/delta; //0.5 litter on lubricant + else + delta=0.7/delta; //0.7 litter + + if ((delta<MIN_SLOP) || (delta >MAX_SLOP)) + { + voltage_array[i,4]=ERROR_SLOP; + // stubManager.Write("123"); + } + else if ((voltage_array[i,2]<MIN_50cc_on_volt) || (voltage_array[i,2]>MAX_50cc_on_volt )) + voltage_array[i,4]=ERROR_SLOP; + else + voltage_array[i,4]=delta; + } + return 1; + } + + + int insert_slop_t_eeprom() +{ + stubManager.Write("\n "); + + MidTankDataSetupRequest midTankDataSetupRequest = new MidTankDataSetupRequest(); + + + for (uint i=1;i<9;i++) + { + if (voltage_array[i,4]!= ERROR_SLOP) + { + MidTankData midTankData = new MidTankData(); + midTankData.MidTankId = i-1; + midTankData.InitialOffsetA = voltage_array[i,2]; + midTankData.SlopeB = voltage_array[i,4]; + + stubManager.Write("\nMidtank No:" + i+ "=\tA="+voltage_array[i,2]+"\tSlop="+voltage_array[i,4]); + + + midTankDataSetupRequest.MidTankInfo.Add(midTankData); + + } +var response = stubManager.Run<MidTankDataSetupResponse>(midTankDataSetupRequest); + + + + } + + + + +/* +MidTankData midTankData = new MidTankData(); +midTankData.MidTankId = 0; +midTankData.InitialOffsetA = 0.1; +midTankData.SlopeB = 0.1; + +MidTankData midTankData1 = new MidTankData(); +midTankData1.MidTankId = 1; +midTankData1.InitialOffsetA = 0.11; +midTankData1.SlopeB = 0.11; + +MidTankData midTankData2 = new MidTankData(); +midTankData2.MidTankId = 2; +midTankData2.InitialOffsetA = 0.2; +midTankData2.SlopeB = 0.2; + +MidTankData midTankData3 = new MidTankData(); +midTankData3.MidTankId = 3; +midTankData3.InitialOffsetA = 0.3; +midTankData3.SlopeB = 0.3; + +MidTankData midTankData4 = new MidTankData(); +midTankData4.MidTankId = 4; +midTankData4.InitialOffsetA = 0.4; +midTankData4.SlopeB = 0.4; + +MidTankData midTankData5 = new MidTankData(); +midTankData5.MidTankId = 5; +midTankData5.InitialOffsetA = 0.5; +midTankData5.SlopeB = 0.5; + +MidTankData midTankData6 = new MidTankData(); +midTankData6.MidTankId = 6; +midTankData6.InitialOffsetA = 0.6; +midTankData6.SlopeB = 0.6; + + +MidTankData midTankData7 = new MidTankData(); +midTankData6.MidTankId = 7; +midTankData6.InitialOffsetA = 0.7; +midTankData6.SlopeB = 0.7; + + +midTankDataSetupRequest.MidTankInfo.Add(midTankData); +midTankDataSetupRequest.MidTankInfo.Add(midTankData1); +midTankDataSetupRequest.MidTankInfo.Add(midTankData2); +midTankDataSetupRequest.MidTankInfo.Add(midTankData3); +midTankDataSetupRequest.MidTankInfo.Add(midTankData4); +midTankDataSetupRequest.MidTankInfo.Add(midTankData5); +midTankDataSetupRequest.MidTankInfo.Add(midTankData6); +midTankDataSetupRequest.MidTankInfo.Add(midTankData7); +*/ +return 1; +} + + + +int print_table() + { + + for (uint i=0;i<5;i++) + { + stubManager.AppendToFile(File_name,Parameter[i]+"\t"+voltage_array[1,i]+"\t"+voltage_array[2,i]+"\t"+voltage_array[3,i]+"\t"+voltage_array[4,i]+"\t"+voltage_array[5,i]+"\t"+voltage_array[6,i]+"\t"+voltage_array[7,i]+"\t"+voltage_array[8,i]) ; + } + + + return 1; + + } + + + +int adc_configuration(uint I2C_Slave_Add,uint channel ) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(channel);//Byte 1 to Write, must be 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 or 0x01 for different channels + stubI2CWriteBytesRequest.BytesTWrite.Add(0x80);//Byte 2 to Write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } + + +int adc_set_for_read_ch(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x01);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } + + + + +int adc_read_ch(uint I2C_Slave_Add,uint table_index_x,uint table_index_y) + { + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + uint templ=0; + uint temp; + double calc; + double calc1; + double calc2; + temph=response1.ReadBytes[0]; + templ=response1.ReadBytes[1]; + temp = (temph << 8) | templ; + temp=temp & 0x0fff; + + calc = (double)temp *2.5 / 4096.0; + stubManager.Write("ADC [volts]:\t"); + stubManager.Write(calc+"\t"); + + calc1 = (1.96- calc) * 4.64 + 1.96; + stubManager.Write("Vsensor [volts]:\t"); + stubManager.Write(calc1); + + voltage_array[table_index_x,table_index_y]=calc1; + + return 1; + } + +int read_pressure_sensor(uint i ) + { + + stubManager.Write("\n-----------MIDTANK_PRESSESENS-------test_no= "+i); + + stubManager.Write("\n1_1= "); + + adc_configuration(0x44,0x20); //a2d_address 0x44 channel channel 2 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44,1,i); + + stubManager.Write("\n2_1= "); + adc_configuration(0x44,0x08); //a2d_address 0x44 channel channel 4 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44,2,i); + + stubManager.Write("\n3_1= "); + adc_configuration(0x46,0x80); //a2d_address 0x46 channel channel 0 + adc_set_for_read_ch(0x46); + adc_read_ch(0x46,3,i); + + stubManager.Write("\n4_1= "); + adc_configuration(0x46,0x20); //a2d_address 0x46 channel channel 2 + adc_set_for_read_ch(0x46); + adc_read_ch(0x46,4,i); + + stubManager.Write("\n1_2= "); + adc_configuration(0x44,0x10); //a2d_address 0x44 channel channel 3 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44,5,i); + + stubManager.Write("\n2_2= "); + adc_configuration(0x44,0x04); //a2d_address 0x44 channel channel 5 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44,6,i); + + stubManager.Write("\n3_2= "); + adc_configuration(0x46,0x40); //a2d_address 0x46 channel channel 1 + adc_set_for_read_ch(0x46); + adc_read_ch(0x46,7,i); + + stubManager.Write("\n4_2= "); + adc_configuration(0x46,0x10); //a2d_address 0x46 channel channel 3 + adc_set_for_read_ch(0x46); + adc_read_ch(0x46,8,i); + + return 1; + } diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/MIDTANK_JIG.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/MIDTANK_JIG.cs new file mode 100644 index 000000000..6b864dfee --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/MIDTANK_JIG.cs @@ -0,0 +1,480 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +using System.Timers; + + +// private static System.Timers.Timer aTimer; + +//-------------------------------------------------------------------------------- +const Int32 I2C_ID = 2; +const int UNIT_UNDER_TEST =3*8; +const Int32 F3_VALVE_OUT = 0x600008e2; +//-------------------------------------------------------------------------------- +string path1="P:\\Scripts\\Assemblies\\MidTank\\MidTankLog\\"; +string path2="C:\\MidTankLog\\"; + +string File_Name1 ; +string Status; +//--------------------------- +int [] Convert_Midtank_No = new Int32 [8] {1,3,5,7,2,4,6,8}; +uint [,] ADC_Add_Chnl = new uint [8,2] { + {0x44,0x20}, + {0x44,0x08}, + {0x46,0x80}, + {0x46,0x20}, + {0x44,0x10}, + {0x44,0x04}, + {0x46,0x40}, + {0x46,0x10}, + }; + + +string [,] Units_status = new string[UNIT_UNDER_TEST,2] { + {"Midtank1_Valve_Air","Not Test"}, //0 + {"Midtank1_Valve_Ink","Not Test"}, //1 + {"Midtank1_Pressure_Sensor","Not Test"}, //2 + {"Midtank2_Valve_Air","Not Test"}, //3 + {"Midtank2_Valve_Ink","Not Test"}, //4 + {"Midtank2_Pressure_Sensor","Not Test"}, //5 + {"Midtank3_Valve_Air","Not Test"}, //6 + {"Midtank3_Valve_Ink","Not Test"}, //7 + {"Midtank3_Pressure_Sensor","Not Test"}, //8 + {"Midtank4_Valve_Air","Not Test"}, //9 + {"Midtank4_Valve_Ink","Not Test"}, //10 + {"Midtank4_Pressure_Sensor","Not Test"}, //11 + {"Midtank5_Valve_Air","Not Test"}, //12 + {"Midtank5_Valve_Ink","Not Test"}, //13 + {"Midtank5_Pressure_Sensor","Not Test"}, //14 + {"Midtank6_Valve_Air","Not Test"}, //15 + {"Midtank6_Valve_Ink","Not Test"}, //16 + {"Midtank6_Pressure_Sensor","Not Test"}, //17 + {"Midtank7_Valve_Air","Not Test"}, //18 + {"Midtank7_Valve_Ink","Not Test"}, //19 + {"Midtank7_Pressure_Sensor","Not Test"}, //20 + {"Midtank8_Valve_Air","Not Test"}, //21 + {"Midtank8_Valve_Ink","Not Test"}, //22 + {"Midtank8_Pressure_Sensor","Not Test"}, //23 + }; +//----------------------------------------------------- +string MIDTANK_Sn; +//-------------------------------------------------------------------------------- + // private static void SetTimer() + // { + // // Create a timer with a one second interval. + // aTimer = new System.Timers.Timer(1000); +// // Hook up the Elapsed event for the timer. +// aTimer.Elapsed += OnTimedEvent; +// aTimer.AutoReset = true; +// aTimer.Enabled = true; +// } + +// private static void OnTimedEvent(Object source, ElapsedEventArgs e) + // { +// bool x=0; +// if (x==true) +// Label5.Text="Pros"; +// else +//// Label5.Text=" "; +// x = !x ; +// +// } + + + + + + + + + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + +// Set the caption bar text of the form. + form1.TopMost = true; + form1.Text = "MIDTANK Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----MIDTANK Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" MIDTANK S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + + + + + Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; + Label5.Location = new Point (300, 100); + Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + + Label5.Text=""; + Label5.Font = new Font("Arial", 24,FontStyle.Bold); + form1.Controls.Add(Label5); + +//---------------------------- + +bool BlinkOn = false; + + + +//-------------------------------------------------------------------------------- + + button1.Click += (_,__) => + + { +// SetTimer(); + +// Label5.Text="Pros"; + + + + +//-------------------------------------------------------------------------------- + + + + + Label5.Text = "Pros"; + // if (_click) + // _show_text.Text = "Fail"; + // else + // _show_text.Text = "Pass"; + + // _click = !_click; + // TextBox1.Text = ""; + + + +//-------------------------------------------------------------------------------- + + + + if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } + else + path=path1; + + File_Name1=path + TextBox1.Text +"_MIDTANK_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + + stubManager.Write(File_Name1 +"\n"); + stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); + stubManager.Write(DateTime.Now +"\n" ); + + stubManager.AppendToFile(File_Name1,"MIDTANK Test Report" ); + stubManager.Write("MIDTANK Test Report\n" ); + + stubManager.AppendToFile(File_Name1,"MIDTANK S/N: \t" + TextBox1.Text ); + stubManager.Write("MIDTANK S/N:" + TextBox1.Text +"\n" ); + + + stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); + stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + +//------------------------------- start test ----------- + Test_MIDTANK(); + + Status=write_to_file(); + stubManager.Write(Status +"\n"); + + Label5.Text=Status; + + // _show_text.Text =Status; + + TextBox1.Text=""; + }; + + form1.ShowDialog(); + + return ; + } + + //------------------------------------ +int Test_MIDTANK() +{ + double Pressur_Volt; + double temp; + for (Int32 i=1;i<9;i++) + { + open_valve(i,0,1) ; //open Air valve + open_valve(i,1,1) ; //open Ink valve + Thread.Sleep(2000); + Pressur_Volt=read_pressuere_sense(i); + if ((Pressur_Volt>3 )||(Pressur_Volt<2)) + { + Units_status[(i-1)*3+2,1]="Fail"; + stubManager.Write("pressuere_sense of midtank" + i +"\tFail\n"); + } + else + { + close_valve(i,1,0) ; //close Ink valve + DialogResult result = MessageBox.Show("ADD 20cc air thru Air valve of Midtank"+ i, "Warning"); + close_valve(i,0,0) ; //close Air valve + Thread.Sleep(2000); + + temp=read_pressuere_sense(i); + temp=temp-Pressur_Volt; + if ((temp>0.5) && ( temp <2)) + Units_status[(i-1)*3+2,1]="Pass"; + else + Units_status[(i-1)*3+2,1]="Fail"; + } + + close_valve(i,0,0) ; //close Air valve + close_valve(i,1,0) ; //close Ink valve + } + return 1; +} + +double read_pressuere_sense(Int32 Midtank_Nm) +{ +double Pressur_Volt; + adc_configuration((ADC_Add_Chnl[Midtank_Nm-1,0]),(ADC_Add_Chnl[Midtank_Nm-1,1]) ); //configure address and channel of midtank + adc_set_for_read_ch(ADC_Add_Chnl[Midtank_Nm-1,0]); + Pressur_Volt =adc_read_ch(ADC_Add_Chnl[Midtank_Nm-1,0]); + + stubManager.Write("pressure sense of midtank " + Midtank_Nm + "is " + Pressur_Volt+ "Volt\n"); + return Pressur_Volt; +} + + +//-------------------------------- +int adc_configuration(uint I2C_Slave_Add,uint channel ) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(channel);//Byte 1 to Write, must be 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 or 0x01 for different channels + stubI2CWriteBytesRequest.BytesTWrite.Add(0x80);//Byte 2 to Write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//-------------------------------- +int adc_set_for_read_ch(uint I2C_Slave_Add) + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x01);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; + } +//-------------------------------- + +double adc_read_ch(uint I2C_Slave_Add) + { + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + uint templ=0; + uint temp; + double calc; + double calc1; + temph=response1.ReadBytes[0]; + templ=response1.ReadBytes[1]; + temp = (temph << 8) | templ; + temp=temp & 0x0fff; + + calc = (double)temp *2.5 / 4096.0; + calc1 = (1.96- calc) * 4.64 + 1.96; + return calc1; + } +//-------------------------------- +int open_valve (int valve_nm,int valve_type,int check_valve) //valve_type=0 is Air ,1 is Ink ; check_valve=1 send feedbak +{ + int temp1=Convert_Midtank_No[valve_nm-1] ; + + string temp; + SetBit (F3_VALVE_OUT,((valve_type+1)*8)- temp1, 1); + if (check_valve!=0) + { + temp="Air"; + if (valve_type==1) + temp="Ink"; + + DialogResult result = MessageBox.Show("Did " + temp + "Valve of Midtank " + valve_nm +" open?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[(valve_nm-1)*3+valve_type,1]="Fail"; + stubManager.Write(temp +"Valve\tFail\n"); + return 0; + } + else + { + Units_status[(valve_nm-1)*3+valve_type,1]="Pass"; + stubManager.Write(temp +"Valve\tOpen\n"); + return 1; + } + + } + return 1; + +} +//-------------------------------- +int close_valve (int valve_nm,int valve_type,int check_valve) +{ + int temp1=Convert_Midtank_No[valve_nm-1]; + + string temp; + SetBit (F3_VALVE_OUT,((valve_type+1)*8)- temp1, 0); + if (check_valve!=0) + { + temp="Air"; + if (valve_type==1) + temp="Ink"; + + DialogResult result = MessageBox.Show("Did " + temp +" Valve of Midtank " + valve_nm +" close?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[(valve_nm-1)*3+valve_type,1]="Fail"; + stubManager.Write(temp +"Valve\tFail\n"); + return 0; + } + else + { + Units_status[(valve_nm-1)*3+valve_type,1]="Pass"; + stubManager.Write(temp +"Valve\tclose\n"); + return 1; + } + } + return 1; + + + + +} +//-------------------------------- +Int32 SetBit(Int32 Adr, Int32 BitNo, Int32 Bit) +{ + Int32 BitMask; + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" , F3_VALVE_OUT); + Int32 RV = (Int32) response.Value & 0xffff; + + + if (Bit == 0x1) + { + BitMask = 0x1 << BitNo; + RV = RV | BitMask; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F3_VALVE_OUT , RV); + } + else if (Bit == 0x0) + { + BitMask = ~(0x1 << BitNo); + RV = RV & BitMask; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F3_VALVE_OUT , RV); + } + return 1; +} + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<UNIT_UNDER_TEST;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------MidTank Fail ------------ "); + stubManager.Write("-------------MidTank Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------MidTank Pass ------------ )"); + stubManager.Write("-------------MidTank Pass ------------ "); + } + + return Stemp; + +} diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/Midtank_pressure_sensors.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/Midtank_pressure_sensors.cs index 682ef322d..e2bacf5f4 100644 --- a/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/Midtank_pressure_sensors.cs +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/Midtank_pressure_sensors.cs @@ -90,6 +90,7 @@ int adc_set_for_read_ch(uint I2C_Slave_Add) } + int adc_read_ch(uint I2C_Slave_Add) { StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); @@ -98,16 +99,27 @@ int adc_read_ch(uint I2C_Slave_Add) stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); - uint temph=0; - uint templ=0; - uint temp; + UInt32 temph=0; + UInt32 templ=0; + UInt32 temp; + double calc; + double calc1; for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i=i+2) { temph=response1.ReadBytes[i]; templ=response1.ReadBytes[i+1]; temp = (temph << 8) | templ; temp=temp & 0x0fff; - stubManager.WriteHex(temp,4); + + calc = (double)temp *2.5 / 4096.0; + calc1 = (1.96- calc) * 4.64 + 1.96; + + + // temp=temp*3300; + // temp=temp/4096; + + stubManager.Write(calc1); + stubManager.Write("mV\n"); } @@ -121,47 +133,49 @@ public void OnExecute(StubManager stubManager) { - stubManager.Write("\n-----------MIDTANK_PRESSESENS----------- "); + stubManager.Write("-----------MIDTANK_PRESSESENS-----------\n "); - stubManager.Write("\n1_1= "); + stubManager.Write("Midtank-1= "); adc_configuration(0x44,0x20); //a2d_address 0x44 channel channel 2 -// adc_set_for_read_temp(0x44); -// adc_read_temp(0x44); - adc_set_for_read_ch(0x44); - adc_read_ch(0x44); - - stubManager.Write("\n1_2= "); - adc_configuration(0x44,0x10); //a2d_address 0x44 channel channel 3 adc_set_for_read_ch(0x44); adc_read_ch(0x44); - stubManager.Write("\n2_1= "); + + stubManager.Write("Midtank-2= "); adc_configuration(0x44,0x08); //a2d_address 0x44 channel channel 4 adc_set_for_read_ch(0x44); adc_read_ch(0x44); - stubManager.Write("\n2_2= "); - adc_configuration(0x44,0x04); //a2d_address 0x44 channel channel 5 - adc_set_for_read_ch(0x44); - adc_read_ch(0x44); - stubManager.Write("\n3_1= "); + stubManager.Write("Midtank-3= "); adc_configuration(0x46,0x80); //a2d_address 0x46 channel channel 0 adc_set_for_read_ch(0x46); adc_read_ch(0x46); - - stubManager.Write("\n3_2= "); - adc_configuration(0x46,0x40); //a2d_address 0x46 channel channel 1 + + stubManager.Write("Midtank-4= "); + adc_configuration(0x46,0x20); //a2d_address 0x46 channel channel 2 adc_set_for_read_ch(0x46); adc_read_ch(0x46); + + + stubManager.Write("Midtank-5= "); + adc_configuration(0x44,0x10); //a2d_address 0x44 channel channel 3 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44); - stubManager.Write("\n4_1= "); - adc_configuration(0x46,0x20); //a2d_address 0x46 channel channel 2 + + stubManager.Write("Midtank-6= "); + adc_configuration(0x44,0x04); //a2d_address 0x44 channel channel 5 + adc_set_for_read_ch(0x44); + adc_read_ch(0x44); + + stubManager.Write("Midtank-7= "); + adc_configuration(0x46,0x40); //a2d_address 0x46 channel channel 1 adc_set_for_read_ch(0x46); adc_read_ch(0x46); - stubManager.Write("\n4_2= "); + stubManager.Write("Midtank-8= "); adc_configuration(0x46,0x10); //a2d_address 0x46 channel channel 3 adc_set_for_read_ch(0x46); adc_read_ch(0x46); diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/midtanksetparams.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/midtanksetparams.cs new file mode 100644 index 000000000..2208ee094 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/midtanksetparams.cs @@ -0,0 +1,84 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +using Tango.PMR.EmbeddedParameters; + +public void OnExecute(StubManager stubManager) +{ + + +MidTankDataSetupRequest midTankDataSetupRequest = new MidTankDataSetupRequest(); + +//50cc [V] 1.93242734375 1.94375546875 1.9295953125 1.935259375 1.92109921875 2.8245171875 1.92676328125 1.92676328125 + //b [mL/V] -1 -1 -1 -1 -1 0.885922630082808 -1 -1 + +MidTankData midTankData = new MidTankData(); +midTankData.MidTankId = 0; +midTankData.InitialOffsetA = 1.93242734375; +midTankData.SlopeB = 1; + +MidTankData midTankData1 = new MidTankData(); +midTankData1.MidTankId = 1; +midTankData1.InitialOffsetA = 1.94375546875; +midTankData1.SlopeB = 2; + +MidTankData midTankData2 = new MidTankData(); +midTankData2.MidTankId = 2; +midTankData2.InitialOffsetA = 1.935259375; +midTankData2.SlopeB = 3; + +MidTankData midTankData3 = new MidTankData(); +midTankData3.MidTankId = 3; +midTankData3.InitialOffsetA = 1.935259375; +midTankData3.SlopeB = 4; + + +MidTankData midTankData4 = new MidTankData(); +midTankData4.MidTankId = 4; +midTankData4.InitialOffsetA = 1.92109921875; +midTankData4.SlopeB = 5; + + +MidTankData midTankData5 = new MidTankData(); +midTankData5.MidTankId = 5; +midTankData5.InitialOffsetA = 2.8245171875; +midTankData5.SlopeB = 6; + + +MidTankData midTankData6 = new MidTankData(); +midTankData6.MidTankId = 6; +midTankData6.InitialOffsetA = 1.92676328125; +midTankData6.SlopeB = 7; + +MidTankData midTankData7 = new MidTankData(); +midTankData7.MidTankId = 7; +midTankData7.InitialOffsetA = 1.92676328125; +midTankData7.SlopeB = 8; + + + +midTankDataSetupRequest.MidTankInfo.Add(midTankData); +midTankDataSetupRequest.MidTankInfo.Add(midTankData1); +midTankDataSetupRequest.MidTankInfo.Add(midTankData2); +midTankDataSetupRequest.MidTankInfo.Add(midTankData3); +midTankDataSetupRequest.MidTankInfo.Add(midTankData4); +midTankDataSetupRequest.MidTankInfo.Add(midTankData5); +midTankDataSetupRequest.MidTankInfo.Add(midTankData6); +midTankDataSetupRequest.MidTankInfo.Add(midTankData7); + + +var response = stubManager.Run<MidTankDataSetupResponse>(midTankDataSetupRequest); + + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/read_midtank_calibration.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/read_midtank_calibration.cs new file mode 100644 index 000000000..469772888 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/MidTank/read_midtank_calibration.cs @@ -0,0 +1,37 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + int i; + + for(i=0;i<8;i++) + { + + var response = stubManager.Run<ProgressResponse>("ProgressRequest" ,0xA, i); + stubManager.Write("\n Initial_Offset_A [#"); + stubManager.Write(i); + stubManager.Write("] = "); + stubManager.WriteLine(response.Progress); + } + + for(i=0;i<8;i++) + { + var response1 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0xB, i); + stubManager.Write("\n Slope_B [#"); + stubManager.Write(i); + stubManager.Write("] = "); + stubManager.WriteLine(response1.Progress); + } + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/RTFU/RTFU_JIG.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/RTFU/RTFU_JIG.cs new file mode 100644 index 000000000..9ffd0d9d5 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/RTFU/RTFU_JIG.cs @@ -0,0 +1,537 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +//-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +//string path1="P:\\Scripts\\Assemblies\\RTFU\\RTFULog\\"; +//string path2="C:\\RTFULog\\"; + +//string File_Name1 ; +//string Status; + +//-------------------DEFINE Motors------------------ +const Int32 RDANCER_Motor = 21; +const Int32 RDRIVING_Motor = 22; +const Int32 RLOADING_Motor = 24; + +//-------------------DEFINE Motors Parameters------------------ + +const Int32 F1_MOTO_RLOADING_TX1 = 0x60000202; +const Int32 F1_MOTO_RLOADING_TX0 = 0x60000200; +const Int32 F1_MOTO_RLOADING_RX1 = 0x60000206; +const Int32 F1_MOTO_RLOADING_RX0 = 0x60000204; + +//-------------------DEFINE Limit Switch--------------- +const Int32 F1_LS_03_Direct =0x60000040; + +const Int32 F1_LS_RLOADMOTOR_UP = 0x0040 ; +const Int32 F1_LS_RLOADMOTOR_DN = 0x0080 ; +const Int32 F1_LS_RDANCER_UP = 0x0100; +const Int32 F1_LS_RDANCER_DOWN = 0x0200; +const Int32 F1_LS_RLOADRAM_DOWN = 0x0020; + +const Int32 F1_RDANCER_ROTENC_DATA_p_RX_lsb = 0x600001a0; +const Int32 F1_RDANCER_ROTENC_DATA_p_RX_msb = 0x600001a2; +const Int32 F1_RDANCER_ROTENC_DATA_p_TX = 0x600001ae; + + +const int UNIT_UNDER_TEST=3+1+5; +//-------------------------------------------------------------------------------- +string path1="P:\\Scripts\\Assemblies\\RTFU\\RTFULog\\"; +string path2="C:\\RTFULog\\"; + +string File_Name1 ; +string Status; +//--------------------------- + +string [,] Units_status = new string[UNIT_UNDER_TEST,2] { + {"LS_RLOADMOTOR_Up","Not Test"}, //0 + {"LS_RLOADMOTOR_DOWN","Not Test"}, //1 + {"RLOADING_Motor","Not Test"}, //2 + {"DRIVING_Motor","Not Test"}, //3 + {"LS_RDANCER_DOWN","Not Test"}, //4 + {"LS_RDANCER_UP","Not Test"}, //5 + {"LS_RLOADRAM_DOWN","Not Test"}, //6 + {"RDANCER_Motor","Not Test"}, //7 + {"RDANCER_ROTENC","Not Test"}, //8 + }; + + + +//----------------------------------------------------- +string RTFU_Sn; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + +// Set the caption bar text of the form. + form1.TopMost = true; + form1.Text = "RTFU Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----RTFU Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" RTFU S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { + if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } + else + path=path1; + + File_Name1=path + TextBox1.Text +"_RTFU_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + + stubManager.Write(File_Name1 +"\n"); + stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); + stubManager.Write(DateTime.Now +"\n" ); + + stubManager.AppendToFile(File_Name1,"RTFU Test Report" ); + stubManager.Write("RTFU Test Report\n" ); + + stubManager.AppendToFile(File_Name1,"RTFU S/N: \t" + TextBox1.Text ); + stubManager.Write("RTFU S/N:" + TextBox1.Text +"\n" ); + + + stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); + stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + + Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; + Label5.Location = new Point (300, 100); + Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + + Label5.Text="Pros"; + Label5.Font = new Font("Arial", 24,FontStyle.Bold); + form1.Controls.Add(Label5); + + +//------------------------------- start test ----------- + Test_RLOADING_RTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(100); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + + Test_RDRIVING_RTFU(); + Test_DANCER_RTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + Status=write_to_file(); + + Label5.Text=Status; + TextBox1.Text=""; + }; + + form1.ShowDialog(); + + return ; + } + //------------------------------------ +int Test_RLOADING_RTFU() +{ + int temp=1; + int counter; + + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x2c000000); //set kval ran to 0x2c- 1.3A + Thread.Sleep(100); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,100); //move Rloading down + Thread.Sleep(3000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(1000); +//------------------------------------------ check F1_LS_RLOADMOTOR_up------------------------------------------------ + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RLOADMOTOR_UP) !=F1_LS_RLOADMOTOR_UP ) //if LS_RLOADMOTOR_UP is up then error + { + DialogResult result = MessageBox.Show("Did RLOADIN MOTOR Move?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.Yes) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + else + { + Units_status[2,1]="Fail"; + stubManager.Write("RLOADMOTOR\tFail\n"); + return 0; + } + } + +//----------------------------------------- mov RLOADING up ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor,false,100); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_UP) != F1_LS_RLOADMOTOR_UP ) + counter=250; + + Thread.Sleep(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + if (counter == 150) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP Not calibrate\n"); + return 0; + } + Units_status[0,1]="Pass"; + Units_status[2,1]="Pass"; + +//------------------------------------------ check F1_LS_RLOADMOTOR_DN------------------------------------------------ + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + + if ((response.Value & F1_LS_RLOADMOTOR_DN) !=F1_LS_RLOADMOTOR_DN ) //if LS_RLOADMOTOR_DN is up then error + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } +//------------------------------------------ mov RLOADING dn ------------------------------------------------ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,100); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_DN) != F1_LS_RLOADMOTOR_DN ) + counter=250; + + Thread.Sleep(100); + } + + if (counter == 150) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + stubManager.Write("RLOADMOTOR\tPass\n"); + + return 1 ; + +} + +//---------------------------------- + +Int32 ReadEncoder() +{ + Int32 temp; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_RDANCER_ROTENC_DATA_p_TX, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_lsb); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_msb); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + + + return temp; +} +//-------------------------------------------------------------------------------- +int Test_DANCER_RTFU() +{ + int counter; + Int32 temp; + Int32 temp1; + +//------------------------------------------ check F1_LS_RDANCER_DOWN ------------------------------------------------ + + MessageBox.Show("Make sure RDANCER Doun"); + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RDANCER_DOWN) !=F1_LS_RDANCER_DOWN ) //if F1_LS_RDANCER_DOWN is up then error + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } +//----------------------------------------- mov RDANCER_Motor up and check F1_LS_RDANCER_DOWN ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,true,10); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[4,1]="Pass"; + stubManager.Write("LS_RDANCER_DOWN\tPass\n"); + +//----------------------------------------- check F1_LS_RDANCER_UP ------------------------------------------------- + + if ((response.Value & F1_LS_RDANCER_UP) !=F1_LS_RDANCER_UP ) //if F1_LS_RDANCER_UP is up then error + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RDANCER_UP is up then move down + if ((response.Value & F1_LS_RDANCER_UP) != F1_LS_RDANCER_UP ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + Units_status[5,1]="Pass"; + stubManager.Write("LS_RDANCER_UP\tPass\n"); + +//----------------------------------------- check F1_LS_RLOADRAM_DOWN ------------------------------------------------- + + if ((response.Value & F1_LS_RLOADRAM_DOWN) !=F1_LS_RLOADRAM_DOWN ) //if F1_LS_RLOADRAM_DOWN is up then error + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RLOADRAM_DOWN is up then move down + if ((response.Value & F1_LS_RLOADRAM_DOWN) != F1_LS_RLOADRAM_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + Units_status[6,1]="Pass"; + stubManager.Write("LS_RLOADRAM_DOWN\tPass\n"); + +//----------------------------------------- mov RDANCER_Motor down and check rdancer encoder ------------------------------------------------- + temp= ReadEncoder(); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,false,10); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[7,1]="Pass"; + stubManager.Write("RDANCER_Motor\tPass\n"); + + temp1= ReadEncoder(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + stubManager.Write("temp="+temp + "\temp1="+temp1 +"\n"); + + DialogResult result = MessageBox.Show("SSI Dancer led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + + if (temp>temp1) + temp1=temp1+0x4000; + + temp1=temp1-temp; + if ((temp1> 15000) || (temp1 <1000)) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + Units_status[8,1]="Pass"; + stubManager.Write("RDANCER_SSI\tPass\n"); + + return 1; +} + + +//------------------------------------------------------------- +int Test_RDRIVING_RTFU() +{ + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDRIVING_Motor, true,200); //move Rdriving clockwise + stubManager.Write("RDRIVING_Motor Motor rotate \n "); + + DialogResult result = MessageBox.Show("Are RDRIVING Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("RDRIVING Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("RDRIVING Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDRIVING_Motor,3); //stop motor + + return 0; +} + + + +//-------------------------------------------------------------------------------- +int Motor_SetParam(Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr, uint ParaData1) +{ + + Int32 Temp = 0; + Temp = (ParaAddr << 8 ) + ( (Int32) ParaData1 >> 24); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,HighAdr, (Temp & 0xffff)); + Temp = ((Int32)ParaData1 >> 8) & 0xffff; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,LowAdr, (Temp)); + + return 1; +} + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<UNIT_UNDER_TEST;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------RTFU Fail ------------ "); + stubManager.Write("-------------RTFU Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------RTFU Pass ------------ )"); + stubManager.Write("-------------RTFU Pass ------------ "); + } + + return Stemp; + +} + diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/RTFU/RTFU_JIG1.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/RTFU/RTFU_JIG1.cs new file mode 100644 index 000000000..500e153c4 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/RTFU/RTFU_JIG1.cs @@ -0,0 +1,552 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +//-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- +//string path1="P:\\Scripts\\Assemblies\\RTFU\\RTFULog\\"; +//string path2="C:\\RTFULog\\"; + +//string File_Name1 ; +//string Status; + +//-------------------DEFINE Motors------------------ +const Int32 RDANCER_Motor = 21; +const Int32 RDRIVING_Motor = 22; +const Int32 RLOADING_Motor = 24; + +//-------------------DEFINE Motors Parameters------------------ + +const Int32 F1_MOTO_RLOADING_TX1 = 0x60000202; +const Int32 F1_MOTO_RLOADING_TX0 = 0x60000200; +const Int32 F1_MOTO_RLOADING_RX1 = 0x60000206; +const Int32 F1_MOTO_RLOADING_RX0 = 0x60000204; + +//-------------------DEFINE Limit Switch--------------- +const Int32 F1_LS_03_Direct =0x60000040; + +const Int32 F1_LS_RLOADMOTOR_UP = 0x0040 ; +const Int32 F1_LS_RLOADMOTOR_DN = 0x0080 ; +const Int32 F1_LS_RDANCER_UP = 0x0100; +const Int32 F1_LS_RDANCER_DOWN = 0x0200; +const Int32 F1_LS_RLOADRAM_DOWN = 0x0020; + +const Int32 F1_RDANCER_ROTENC_DATA_p_RX_lsb = 0x600001a0; +const Int32 F1_RDANCER_ROTENC_DATA_p_RX_msb = 0x600001a2; +const Int32 F1_RDANCER_ROTENC_DATA_p_TX = 0x600001ae; + + +const int UNIT_UNDER_TEST=3+1+5; +//-------------------------------------------------------------------------------- +string path1="P:\\Scripts\\Assemblies\\RTFU\\RTFULog\\"; +string path2="C:\\RTFULog\\"; + +string File_Name1 ; +string Status; +//--------------------------- + +string [,] Units_status = new string[UNIT_UNDER_TEST,2] { + {"LS_RLOADMOTOR_Up","Not Test"}, //0 + {"LS_RLOADMOTOR_DOWN","Not Test"}, //1 + {"RLOADING_Motor","Not Test"}, //2 + {"DRIVING_Motor","Not Test"}, //3 + {"LS_RDANCER_DOWN","Not Test"}, //4 + {"LS_RDANCER_UP","Not Test"}, //5 + {"LS_RLOADRAM_DOWN","Not Test"}, //6 + {"RDANCER_Motor","Not Test"}, //7 + {"RDANCER_ROTENC","Not Test"}, //8 + }; + + + +//----------------------------------------------------- +string RTFU_Sn; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + +// Set the caption bar text of the form. + form1.TopMost = true; + form1.Text = "RTFU Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----RTFU Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" RTFU S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + + + + + Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; + Label5.Location = new Point (300, 100); + Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + + Label5.Text=""; + Label5.Font = new Font("Arial", 24,FontStyle.Bold); + form1.Controls.Add(Label5); + + + + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { + + Label5.Text="Pros"; + + if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } + else + path=path1; + + File_Name1=path + TextBox1.Text +"_RTFU_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + + stubManager.Write(File_Name1 +"\n"); + stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); + stubManager.Write(DateTime.Now +"\n" ); + + stubManager.AppendToFile(File_Name1,"RTFU Test Report" ); + stubManager.Write("RTFU Test Report\n" ); + + stubManager.AppendToFile(File_Name1,"RTFU S/N: \t" + TextBox1.Text ); + stubManager.Write("RTFU S/N:" + TextBox1.Text +"\n" ); + + + stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); + stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + +//------------------------------- start test ----------- + Test_RLOADING_RTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(100); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + + Test_RDRIVING_RTFU(); + Test_DANCER_RTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + Status=write_to_file(); + stubManager.Write(Status +"\n"); + + Label5.Text=Status; + TextBox1.Text=""; + }; + + form1.ShowDialog(); + + return ; + } + //------------------------------------ +int Test_RLOADING_RTFU() +{ + int temp=1; + int counter; + + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x2c000000); //set kval ran to 0x2c- 1.3A + Thread.Sleep(100); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + Thread.Sleep(3000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(1000); +//------------------------------------------ check F1_LS_RLOADMOTOR_up------------------------------------------------ + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RLOADMOTOR_UP) !=F1_LS_RLOADMOTOR_UP ) //if LS_RLOADMOTOR_UP is up then error + { + DialogResult result = MessageBox.Show("Did RLOADIN MOTOR Move?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.Yes) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + else + { + Units_status[2,1]="Fail"; + stubManager.Write("RLOADMOTOR\tFail\n"); + return 0; + } + } + +//----------------------------------------- mov RLOADING up ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor,false,200); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_UP) != F1_LS_RLOADMOTOR_UP ) + counter=250; + + Thread.Sleep(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + if (counter == 150) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP Not calibrate\n"); + return 0; + } + Units_status[0,1]="Pass"; + Units_status[2,1]="Pass"; + +//------------------------------------------ check F1_LS_RLOADMOTOR_DN------------------------------------------------ + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + + if ((response.Value & F1_LS_RLOADMOTOR_DN) !=F1_LS_RLOADMOTOR_DN ) //if LS_RLOADMOTOR_DN is up then error + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } +//------------------------------------------ mov RLOADING dn ------------------------------------------------ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_DN) != F1_LS_RLOADMOTOR_DN ) + counter=250; + + Thread.Sleep(100); + } + + if (counter == 150) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + stubManager.Write("RLOADMOTOR\tPass\n"); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + Thread.Sleep(2000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + return 1 ; + +} + +//---------------------------------- + +Int32 ReadEncoder() +{ + Int32 temp; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_RDANCER_ROTENC_DATA_p_TX, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_lsb); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_msb); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + + + return temp; +} +//-------------------------------------------------------------------------------- +int Test_DANCER_RTFU() +{ + int counter; + Int32 temp; + Int32 temp1; + +//------------------------------------------ check F1_LS_RDANCER_DOWN ------------------------------------------------ + + MessageBox.Show("Make sure RDANCER Doun"); + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RDANCER_DOWN) !=F1_LS_RDANCER_DOWN ) //if F1_LS_RDANCER_DOWN is up then error + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } +//----------------------------------------- mov RDANCER_Motor up and check F1_LS_RDANCER_DOWN ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,true,10); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[4,1]="Pass"; + stubManager.Write("LS_RDANCER_DOWN\tPass\n"); + +//----------------------------------------- check F1_LS_RDANCER_UP ------------------------------------------------- + + if ((response.Value & F1_LS_RDANCER_UP) !=F1_LS_RDANCER_UP ) //if F1_LS_RDANCER_UP is up then error + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RDANCER_UP is up then move down + if ((response.Value & F1_LS_RDANCER_UP) != F1_LS_RDANCER_UP ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + Units_status[5,1]="Pass"; + stubManager.Write("LS_RDANCER_UP\tPass\n"); + +//----------------------------------------- check F1_LS_RLOADRAM_DOWN ------------------------------------------------- + + if ((response.Value & F1_LS_RLOADRAM_DOWN) !=F1_LS_RLOADRAM_DOWN ) //if F1_LS_RLOADRAM_DOWN is up then error + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RLOADRAM_DOWN is up then move down + if ((response.Value & F1_LS_RLOADRAM_DOWN) != F1_LS_RLOADRAM_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + Units_status[6,1]="Pass"; + stubManager.Write("LS_RLOADRAM_DOWN\tPass\n"); + +//----------------------------------------- mov RDANCER_Motor down and check rdancer encoder ------------------------------------------------- + temp= ReadEncoder(); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,false,10); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[7,1]="Pass"; + stubManager.Write("RDANCER_Motor\tPass\n"); + + temp1= ReadEncoder(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + stubManager.Write("temp="+temp + "\temp1="+temp1 +"\n"); + + DialogResult result = MessageBox.Show("SSI Dancer led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + + if (temp>temp1) + temp1=temp1+0x4000; + + temp1=temp1-temp; + if ((temp1> 15000) || (temp1 <1000)) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + Units_status[8,1]="Pass"; + stubManager.Write("RDANCER_SSI\tPass\n"); + + return 1; +} + + +//------------------------------------------------------------- +int Test_RDRIVING_RTFU() +{ + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDRIVING_Motor, true,200); //move Rdriving clockwise + stubManager.Write("RDRIVING_Motor Motor rotate \n "); + + DialogResult result = MessageBox.Show("Are RDRIVING Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("RDRIVING Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("RDRIVING Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDRIVING_Motor,3); //stop motor + + return 0; +} + + + +//-------------------------------------------------------------------------------- +int Motor_SetParam(Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr, uint ParaData1) +{ + + Int32 Temp = 0; + Temp = (ParaAddr << 8 ) + ( (Int32) ParaData1 >> 24); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,HighAdr, (Temp & 0xffff)); + Temp = ((Int32)ParaData1 >> 8) & 0xffff; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,LowAdr, (Temp)); + + return 1; +} + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<UNIT_UNDER_TEST;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------RTFU Fail ------------ "); + stubManager.Write("-------------RTFU Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------RTFU Pass ------------ )"); + stubManager.Write("-------------RTFU Pass ------------ "); + } + + return Stemp; + +} + diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/WHS/pump2.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/WHS/pump2.cs new file mode 100644 index 000000000..c72a7cd33 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/WHS/pump2.cs @@ -0,0 +1,32 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + Int32 i=0 ; + while (i==0) +{ + DialogResult result = MessageBox.Show("Do you want to open (Yes) or close (No) valve ?", "Warning", + MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); + if(result == DialogResult.Yes) + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x600000d2, 0x800); + + else if(result == DialogResult.No) + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x600000d2, 0x000); + else if(result == DialogResult.Cancel) + i=1; + +} + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Screw_Encoder.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Screw_Encoder.cs new file mode 100644 index 000000000..88a2e703a --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Screw_Encoder.cs @@ -0,0 +1,44 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + +UInt32 temp ; + + + + + + // Request ---- +// UInt32 : Address + +// Response ---- +// UInt32 : Address +// UInt32 : Value +// String : Status +// UInt32 : StatusWord + +while (true) + { +var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000100); +var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000102); + +temp=(response.Value & 0xffff )+((response1.Value & 0xffff )<<16); +temp=temp&0x0fffffff; +stubManager.WriteHex(temp,8); +stubManager.Write("\n"); + + Thread.Sleep(100); + +} +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Winder_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Winder_Jig.cs new file mode 100644 index 000000000..518cd5be3 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Winder_Jig.cs @@ -0,0 +1,370 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +//include "..\..\Defines\Tango_Defines_Basic.cs" +//include "Tango_Defines_LimitSwitch.cs" + +const Int32 FPGA1 = 0x60000000; +const Int32 FPGA2 = 0x60000400; +const Int32 FPGA3 = 0x60000800; +const Int32 F1_LS_03_Direct = 0x040 ; // Reads the direct values that are currently being sent to the fpga. rsv rsv rsv rsv F1_SW_SPOOL_EXISTS F1_SW_SPARE F1_LS_RDANCER_DOWN F1_LS_RDANCER_UP F1_LS_RLOADMOTOR_DOWN F1_LS_RLOADMOTOR_UP F1_LS_RLOADRAM_DOWN F1_LS_RLOADRAM_UP F1_LS_RSPARE1 F1_LS_RSPARE2 F1_LS_SCREW_LEFT F1_LS_SCREW_RIGHT + + + + +const int UNIT_UNDER_TEST=6; +//-------------------------------------------------------------------------------- +string path1="P:\\Scripts\\Assemblies\\Winder\\WinderLog\\"; +string path2="C:\\WinderLog\\"; + +string File_Name1 ; +string Status; +//--------------------------- + + +string [,] Units_status = new string[UNIT_UNDER_TEST,2] { + {"Winder_Motor","Not Test"}, + {"Screw_Motor","Not Test"}, + {"LS_Screw_Right","Not Test"}, + {"LS_Screw_Left","Not Test"}, + {"Screw_Encoder","Not Test"}, + {"SW_Spool_Exist","Not Test"}, + }; + + + +//----------------------------------------------------- +string Winder_Sn; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + +// Set the caption bar text of the form. + + form1.Text = "Winder Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----Winder Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" Winder S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { +if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } +else +path=path1; + + +File_Name1=path + TextBox1.Text +"_Winder_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + +stubManager.Write(File_Name1 +"\n"); +stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); +stubManager.Write(DateTime.Now +"\n" ); + +stubManager.AppendToFile(File_Name1,"Winder Test Report" ); +stubManager.Write("Winder Test Report\n" ); + +stubManager.AppendToFile(File_Name1,"Winder S/N: \t" + TextBox1.Text ); +stubManager.Write("Winder S/N:" + TextBox1.Text +"\n" ); + + +stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); +stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + + +Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; +Label5.Location = new Point (300, 100); +Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + +Label5.Text="Pros"; +Label5.Font = new Font("Arial", 24,FontStyle.Bold); +form1.Controls.Add(Label5); + + +//------------------------------- start test ----------- + Test_Winder_motor(); + Test_Screw_LS_Motor_Encoder (); + Test_Pooler_Exist (); + + + + Status=write_to_file(); + + Label5.Text=Status; + TextBox1.Text=""; +}; + + form1.ShowDialog(); + + return ; + } +//------------------------------------------ +int Test_Winder_motor () + +{ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,15, true, 500); //rotate Winder Motor. + stubManager.Write("Winder Motor rotate \n "); + DialogResult result = MessageBox.Show("Are Winder Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("Winder Motor not rotate\n"); + } + else + { + Units_status[0,1]="Pass"; + stubManager.Write("Winder Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,15,3); //stop motor + + return 0; +} + + +//-------------------------------------------- + int Test_Screw_LS_Motor_Encoder() +{ + UInt32 temp ; + Int32 Bit = 1; + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,14, false, 250); //rotate screw Motor out. + Thread.Sleep(1000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,14,3); //stop motor + + DialogResult result2 = MessageBox.Show("Did screw Motor move ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("Screw Motor not move\n"); + return 0; + } + Units_status[1,1]="Pass"; + + stubManager.Write("Screw Motor rotate \n "); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,14, true, 250); + stubManager.Write("\nMove screw in "); + + Bit = 1; + int i=0; + while ((Bit != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_03_Direct,0); + Thread.Sleep(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,14,3); //stop motor + + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[2,1]="Fail"; + stubManager.Write("LS_SCREW_RIGHT Not calibrate\n"); + return 0; + } + Units_status[2,1]="Pass"; + stubManager.Write("\nMove screw out \n"); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000100, 0x0000); //clear encoder + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000102, 0x0000); //clear encoder + + Bit = 1; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,14, false, 250); + i=0; + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(FPGA1, F1_LS_03_Direct,1); + Thread.Sleep(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,14,3); //stop motor + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result3 == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("LS_SCREW_LEFT Not calibrate\n"); + return 0; + } + Units_status[3,1]="Pass"; + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000100); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000102); + + temp=(response.Value & 0xffff )+((response1.Value & 0xffff )<<16); + temp=temp&0x0fffffff; + temp= 0x4000000-temp; + stubManager.Write("Encoder positio:" +temp+"\n"); + + if ((temp>20000) && temp<28000) + Units_status[4,1]="Pass"; + else + Units_status[4,1]="Fail"; + + return 1; +} + //--------------------------------------- +int Test_Pooler_Exist() +{ + if ( (GetBit(FPGA1, F1_LS_03_Direct,11))==0) + { + Units_status[5,1]="Fail"; + return 0; + } + + DialogResult result2 = MessageBox.Show("Remove Spool"); + if ( (GetBit(FPGA1, F1_LS_03_Direct,11))!=0) + Units_status[5,1]="Fail"; + else + Units_status[5,1]="Pass"; + + return 0 ; + + +} + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<UNIT_UNDER_TEST;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------Winder Fail ------------ "); + stubManager.Write("-------------Winder Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------Winder Pass ------------ )"); + stubManager.Write("-------------Winder Pass ------------ "); + } + + return Stemp; + +} + + + +Int32 GetBit(Int32 Fpga, Int32 Adr, Int32 BitNo) +{ + Int32 BitMask; + var RetVal = Fpga_Read_Reg(Fpga, Adr, 0); + BitMask = 0x1 << BitNo; + if ( ( (Int32) RetVal.Value & BitMask) == BitMask ) + { + return 1; + } + else + { + return 0; + } + +} + + +StubFpgaReadRegResponse Fpga_Read_Reg(Int32 Fpga, Int32 Addr, Int32 Verbose) +{ + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" , Fpga + Addr); + response.Value = response.Value & 0xffff; + + if (Verbose == 1) { + stubManager.Write("FPGA Reg. Read (FPGA Base, Addr, Data): ("); + stubManager.WriteHex(Fpga,4); + stubManager.Write(", "); + stubManager.WriteHex(Addr,4); + stubManager.Write(", "); + stubManager.WriteHex(response.Value,4); + stubManager.Write(")"); + } + + return response; +} diff --git a/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Winder_spoll_exist.cs b/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Winder_spoll_exist.cs new file mode 100644 index 000000000..c0ada87e1 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Assemblies/Winder/Winder_spoll_exist.cs @@ -0,0 +1,65 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "..\..\Defines\Tango_Defines_Basic.cs" +include "Tango_Defines_LimitSwitch.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\LAB_Tests\Main_PCB\ATP_Test\Scripts\Defines\Tango_Defines_Basic.cs" +//include "C:\To_Backup\Mulberry\Mulberry_current\Customers\Twine\Tango\LAB_Tests\Main_PCB\ATP_Test\Scripts\Defines\Tango_Defines_LimitSwitch.cs" + +public void OnExecute(StubManager stubManager) +{ + + uint Temp = 0; + int counter = 0; + stubManager.Write("\nReading register F1_LS_03_Direct: "); + var RetVal = Fpga_Read_Reg(FPGA1, F1_LS_03_Direct, 0); + Temp=RetVal.Value & 0x0800; + if (Temp==0x0800) + { + stubManager.Write("\nWinder Spoll Exist "); + } + else + { + stubManager.Write("\nWinder Spoll NOT Exist "); + } + Temp = RetVal.Value; + stubManager.Write("\nActivate limit switches one-by-one"); + + while ( counter != 100) + { + RetVal = Fpga_Read_Reg(FPGA1, F1_LS_03_Direct, 0); + if (RetVal.Value != Temp) + { +// stubManager.Write("\nRegister F1_LS_03_Direct new value: "); +// stubManager.WriteHex(RetVal.Value,4); + + Temp=RetVal.Value & 0x0800; + if (Temp==0x0800) + { + stubManager.Write("\nWinder Spoll Exist "); + } + else + { + stubManager.Write("\nWinder Spoll NOT Exist "); + } + + + + counter = counter + 1; + } + Thread.Sleep(50); + Temp=RetVal.Value; + } + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/I2C_RW_Dispenser_EEPROM.cs b/Software/Stubs Collection/stubs/Scripts/I2C_RW_Dispenser_EEPROM.cs new file mode 100644 index 000000000..3c4a1d70a --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/I2C_RW_Dispenser_EEPROM.cs @@ -0,0 +1,134 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//---------------------- +const Int32 I2C_ID = 4; //MCU_I2C4 +const Int32 TCA9548A_address = 0xE2; +//const Int32 I2C_Slave_Add = 0xA0; // //eeprom address - 32kByte & 128kByte +const Int32 I2C_Slave_Add = 0xA2; //eeprom address - only in the eeprom of 128kByte +int Dispenser_ID = 6; //Software Dispensers 0..7, BP Dispensers 1..8 +//---------------------- + +int enable_all_channel() +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address; + + stubI2CWriteBytesRequest.BytesTWrite.Add(0xff);//enable all 8 i2c channel + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int enable_channel(int Channel_ID) +{ + uint Const_temp = 0x01; + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address; + + Const_temp = Const_temp << Channel_ID; + stubI2CWriteBytesRequest.BytesTWrite.Add(Const_temp);//enable i2c channel 0 Dispenser 1 + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + + +int adc_write(uint I2C_Slave_Add) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + //-------------------------------------------------------------- + stubI2CWriteBytesRequest.BytesTWrite.Add(0x12);//Data 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0x34);//Data 1 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0x56);//Data 2 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0x78);//Data 3 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0x90);//Data 4 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0xAB);//Data 5 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0xCD);//Data 6 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0xEF);//Data 7 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0x01);//Data 8 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0x02);//Data 9 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int adc_set_for_read_ch(uint I2C_Slave_Add) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int adc_read_ch(uint I2C_Slave_Add) +{ + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add + 1; + stubI2CReadBytesRequest.NumberOfBytesToRead = 10; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + temph=response1.ReadBytes[i]; + stubManager.WriteHex(temph,2); + } + + return 1; +} + + +public void OnExecute(StubManager stubManager) +{ + + //enable_all_channel(); + enable_channel(Dispenser_ID); // Chanel 0-7 => Disp0enser 0-7 + + for (int i = 0; i<100; i++) + { + + adc_write(I2C_Slave_Add); + Thread.Sleep(5); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + stubManager.Write("\n#"); + stubManager.Write(i); + stubManager.Write("\t- The Buffer is: "); + adc_set_for_read_ch(I2C_Slave_Add); + //Thread.Sleep(1); //Sleep for 10 milli. + adc_read_ch(I2C_Slave_Add); + + Thread.Sleep(1000); + + } +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/I2C_RW_Main_Card_EEPROM_Save_Main_SN.cs b/Software/Stubs Collection/stubs/Scripts/I2C_RW_Main_Card_EEPROM_Save_Main_SN.cs new file mode 100644 index 000000000..6ec538758 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/I2C_RW_Main_Card_EEPROM_Save_Main_SN.cs @@ -0,0 +1,98 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//---------------------- +const Int32 I2C_ID = 2; //MCU_I2C2 + +const Int32 I2C_Slave_Add = 0xA0; //Slave (EEPROM) address + +string str = "UM181700004";//main card S/N + +uint length = 11; +int i = 0; + +//---------------------- + +int adc_write(uint I2C_Slave_Add) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + //-------------------------------------------------------------- + + for(i=0;i<length;i++) + stubI2CWriteBytesRequest.BytesTWrite.Add(str[i]);//Data 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int adc_set_for_read_ch(uint I2C_Slave_Add) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int adc_read_ch(uint I2C_Slave_Add) +{ + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add + 1; + stubI2CReadBytesRequest.NumberOfBytesToRead = length; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + temph=response1.ReadBytes[i]; + stubManager.Write((char) temph); + } + + return 1; +} + + +public void OnExecute(StubManager stubManager) +{ + + for (int i = 0; i<1; i++) + { + + adc_write(I2C_Slave_Add); + Thread.Sleep(5); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + stubManager.Write("\n"); + + stubManager.Write("The eeprom data: "); + adc_set_for_read_ch(I2C_Slave_Add); + + adc_read_ch(I2C_Slave_Add); + + Thread.Sleep(1000); + + } +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig.cs new file mode 100644 index 000000000..deb9031fd --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Dryer_Jig.cs @@ -0,0 +1,395 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + + +const int Dryer_UNDER_TEST=12; +//-------------------------------------------------------------------------------- +//--------------------------- +Int32 last_14bit_position; +Int32 position_32bit=0; +float [] DryerTemp = new float[3] ; + + +string [,] Units_status_Dryer = new string[Dryer_UNDER_TEST,2] { + {"Lid_Motor","Not Test"}, + {"LS_Lid_Open","Not Test"}, + {"LS_Lid_Close","Not Test"}, + {"DRIVING_Motor","Not Test"}, + {"SSI_Encoder","Not Test"}, + {"LoadArm_Motor","Not Test"}, + {"Blower_test","Not Test"}, + {"Air_PT100_test","Not Test"}, + {"Main_PT100_test","Not Test"}, + {"Sec.PT100","Not Test"}, + {"SSR1_heater","Not Test"}, + {"SSR2_heater","Not Test"}, + }; + + + +//-------------------------------------------------------------------------------- + + +public Task<decimal> Dryer_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location ) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (Dryer_UNDER_TEST,Units_status_Dryer); + + settext("Test Dryer LId"); + Test_LId(); + + settext("Test Dryer motor Driving"); + Test_motor_driving(); + + settext("Test Dryer Load Arm"); + Test_Load_Arm (); + + settext("Test Dryer Blower heaters pt100"); + Test_Blower_heaters_pt100(); + + Status=write_to_file(SN,Location,Dryer_UNDER_TEST,"Dryer"); + + settext("End Test"); + + decimal result = 0; + + return result; + }); + return task; +} +//------------------------------------------ +int Test_Blower_heaters_pt100() +{ + + float ftemp=0; + float ftemp1=0; + + SetBit(F1_gpo_01,5,1); //turn off Blower + delay(500); + + var RetVal=Fpga_Read_Reg(F1_Tacho_reg8); + + DialogResult result = MessageBox.Show("Close Dryer Door", "Warning"); + RetVal=Fpga_Read_Reg(F1_Tacho_reg8); + if(RetVal.Value>20) + { + Units_status[6,1]="Fail"; + stubManager.Write("Error,Fan rotate\n"); + return 0; + } + + SetBit(F1_gpo_01,4,1); //Dir + SetBit(F1_gpo_01,3,1); //Torqer High + SetBit(F1_gpo_01,5,0); //turn on Blower + + const int LOW = 70;//0 - 100% + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F2_Prescaler1_reg11, 0xFF);//Freq 8 bit + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F2_BLOWER_PWM_LOW, LOW+1);//Low 8 bit + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F2_BLOWER_PWM_HIGH, 101 - LOW);//High 8 bit + + delay(1000); + RetVal=Fpga_Read_Reg(F1_Tacho_reg8); + stubManager.Write("blower Speed- " + RetVal.Value + "\n"); + if ((RetVal.Value<150)||(RetVal.Value>250) ) + { + Units_status[6,1]="Fail"; + stubManager.Write("Error,Fan rotate\n"); + return 0; + } + Units_status[6,1]="Pass"; + + + stubManager.Write("Temp Befor heating \n"); + if (test_pt100_dryer()!=0) + return 0; + +float temp=0; +float temp1=4096*95*5; + + //Write GPO_DRYER_SSR1_CTRL SSR/SSR no. 1 + SetBit (F2_CTRL, 10, 1); //turn SSR1 on + stubManager.Write("\tTesting SSR no. 1\t"); + delay(1000); +var response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,16); + temp=Convert.ToUInt32 (response1.SamplingInBits); + temp=temp*800*3*100; + temp=temp/(4096*95*50); + stubManager.Write("Current = "+ temp + "A\n"); + if ((temp>6) || (temp<3)) + Units_status[10,1]="Fail"; + else + Units_status[10,1]="Pass"; + + //Write GPO_DRYER_SSR2_CTRL SSR/SSR no. 2 + SetBit (F2_CTRL, 9, 1); + stubManager.Write("\tTesting SSR no. 2\t"); + delay(1000); + response1 = stubManager.Run<StubIntADCReadResponse>("StubIntADCReadRequest" ,17); + temp=Convert.ToUInt32 (response1.SamplingInBits); + stubManager.WriteLine(temp); + temp=temp*800*3*100; + temp=temp/(4096*95*120); + stubManager.Write("Current = "+ temp + "A\n"); + if ((temp>3) || (temp<1)) + Units_status[11,1]="Fail"; + else + Units_status[11,1]="Pass"; + + delay(50000); + +//check air temp + ftemp=Read_pt100(6); + stubManager.Write("After heating air temp is " + ftemp + "\n"); + ftemp = ftemp - DryerTemp[0]; + if ((ftemp<5)||(ftemp>25)) + Units_status[7,1]="Fail"; + else + Units_status[7,1]="Pass"; + + + +//check Main temp + ftemp=Read_pt100(7); + stubManager.Write("After heating Main temp is " + ftemp + "\n"); + ftemp = ftemp - DryerTemp[1]; + if ((ftemp<5)||(ftemp>40)) + Units_status[8,1]="Fail"; + else + Units_status[8,1]="Pass"; + +//check Sec. temp + ftemp=Read_pt100(8); + stubManager.Write("After heating Sec. temp is " + ftemp + "\n"); + ftemp = ftemp - DryerTemp[2]; + if ((ftemp<5)||(ftemp>40)) + Units_status[9,1]="Fail"; + else + Units_status[9,1]="Pass"; + + SetBit (F2_CTRL, 10, 0); //turn SSR1 off + SetBit (F2_CTRL, 9, 0); //turn SSR2 off + + SetBit(F1_gpo_01,5,1); //turn off Blower + return 1; + +} + + int test_pt100_dryer() + { + float ftemp=0; + int temp=0; + int j=0; + for (int i = 6; i < 9; i++) + { + DryerTemp[i]=Read_pt100(i); + ftemp=DryerTemp[i]; + if ((ftemp>100)|| (ftemp<10)) + { + Units_status[i+7,1]="Fail"; + } + else + { + Units_status[i+7,1]="Pass"; + } + stubManager.Write(Units_status[i+7,0] +"\t"+ ftemp.ToString("F2")); + stubManager.Write("°C\n"); + + } + return 0; + } +//------------------------------------------ +int Test_motor_driving () + +{ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DryerMain_Motor, true, 500); //rotate Dryer Motor. + stubManager.Write("Dryer Motor rotate \n "); + DialogResult result = MessageBox.Show("Are Dryer Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("Dryer Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("Dryer Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerMain_Motor,3); //stop motor + + return 0; +} +//---------------------------------- +int Test_Load_Arm() +{ + + Int32 temp3=0; + Int32 j=0; + Int32 i=0; + position_32bit=0; + Int32 temp=position_32bit; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DrierLoadingArm_Motor, false, 60);//40 + delay(50); + temp=ReadEncoder_Dryer(); + while ((temp3==0)&& (i<6000) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + delay(50); + ReadEncoder_Dryer(); +// stubManager.Write("position_32bit " + position_32bit +"\t"); + + if (Math.Abs(position_32bit)> (50*0x4000)) + temp3=1; + if ((position_32bit-temp)>20) + temp3=2; +// stubManager.Write("Temp " + temp +"\n"); + temp=position_32bit; +// stubManager.Write("Temp3 " + temp3 +"\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DrierLoadingArm_Motor, 3); + + DialogResult result1 = MessageBox.Show("Arm Motor rotate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[5,1]="Fail"; + stubManager.Write("Arm Motor Not rotate\n"); + return 0; + } + Units_status[5,1]="Pass"; + + DialogResult result2 = MessageBox.Show("Did Arm Motor arrive to mecahnicl stopper ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[4,1]="Fail"; + stubManager.Write("Arm Motor arrive to mecahnicl stopper \n"); + return 0; + } + + position_32bit=0; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DrierLoadingArm_Motor, true, 60); + delay(50); + i=0; + while ((Math.Abs(ReadEncoder_Dryer())< (30*0x4000))&& (i<6000)) + + { + delay(50); + i++; +// stubManager.Write("position_32bit " + position_32bit +"\t" + i + "\n" ); + + + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DrierLoadingArm_Motor, 3); + + DialogResult result3 = MessageBox.Show("Did Arm Motor make 30 rounds?", "Warning",MessageBoxButtons.YesNo); + if(result3 == DialogResult.No) + { + Units_status[4,1]="Fail"; + stubManager.Write("Arm Motor not make 30 rounds\n"); + return 0; + } + Units_status[4,1]="Pass"; + return 1; +} + +Int32 ReadEncoder_Dryer() +{ + Int32 temp; + Int32 temp1; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x6000019e, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000190); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000192); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + if (temp>last_14bit_position) + { + temp1=temp-last_14bit_position; + position_32bit=position_32bit+temp1; + if (temp1>0x2000) + position_32bit=position_32bit-0x4000; + } + else if (temp<last_14bit_position) + + { + temp1=last_14bit_position-temp; + position_32bit=position_32bit-temp1; + if (temp1>0x2000) + position_32bit=position_32bit+0x4000; + } + + last_14bit_position=temp; + + return position_32bit; +} +//----------------------------------- +int Test_LId () +{ + Int32 Bit = 1; + int i = 0; + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,DryerLid_Motor, false, 0x800000+2); //mov Dryer Lid motor down + delay(2000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor + delay(1000); + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,DryerLid_Motor, false, 0x800000+0); //mov Dryer Lid motor up + + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(F1_LS_01_Direct,4); + delay(50); + i++; + } + stubManager.Write("\n--------1-Lid Open--------"); + + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_Lid_Open Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,DryerLid_Motor, false, 0x800000+2); //mov Dryer Lid motor down + + Bit = 1; + i=0; + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(F1_LS_01_Direct,5); + delay(50); + i++; + } + stubManager.Write("\n--------2-Lid Close--------"); + + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[2,1]="Fail"; + stubManager.Write("LS_Lid_Close Not calibrate\n"); + return 0; + } + Units_status[2,1]="Pass"; + Units_status[0,1]="Pass"; + return 1; + +} diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/DyeHead_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/DyeHead_Jig.cs new file mode 100644 index 000000000..bf1a7d9c8 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/DyeHead_Jig.cs @@ -0,0 +1,344 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +const int DyeHead_UNDER_TEST=16; + +float [] DyeHeadTemp = new float[6] ; + +string [,] Units_status_DyeHead = new string[DyeHead_UNDER_TEST,2] { + {"Pt100_Zone_1","Not Test"}, + {"Pt100_Zone_2","Not Test"}, + {"Pt100_Zone_3","Not Test"}, + {"Pt100_Zone_4","Not Test"}, + {"Pt100_Zone_5","Not Test"}, + {"Pt100_Zone_6","Not Test"}, + {"Heater_Zone_1","Not Test"}, + {"Heater_Zone_2","Not Test"}, + {"Heater_Zone_3","Not Test"}, + {"Heater_Zone_4","Not Test"}, + {"Heater_Zone_5","Not Test"}, + {"Heater_Zone_6","Not Test"}, + {"Magnet ","Not Test"}, + {"LS_DH_LID_Open","Not Test"}, + {"LS_DH_LID_Close","Not Test"}, + {"DH_LID_Motor","Not Test"}, + }; + + + +//-------------------------------------------------------------------------------- + +public Task<decimal> DyeHead_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (DyeHead_UNDER_TEST,Units_status_DyeHead); + + DialogResult result1 = MessageBox.Show("Make shure, Dyehead is not hot", "Warning",MessageBoxButtons.OKCancel); + if(result1 == DialogResult.Cancel) + { + stubManager.AppendToFile(File_Name1,"Dyehead is too hot \tFail"); + stubManager.Write("Dyehead is too hot \tFail\n"); + return 0 ; + } + else + { + +//------------------------------- start test ----------- + settext("Test Magnet Motor LS"); + Test_Magnet_Motor_LS_DyeHead(); + settext("Test heaters &pt100"); + Test_heaters_pt100 (); + + Status=write_to_file(SN,Location,DyeHead_UNDER_TEST,"Dyehead"); + + settext("End Test"); + } + decimal result = 0; + + return result; + }); + return task; +} + + + +//-------------------------------------------- + int Test_Magnet_Motor_LS_DyeHead() +{ + Int32 Bit = 1; + + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,MAGNET_Driver, false,0x800000+0); + stubManager.Write("\nTesting SSR no. 13 of magnet or motor driver"); + + DialogResult result = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[12,1]="Fail"; + stubManager.Write("Magnet Not Open\n"); + return 0; + } + Units_status[12,1]="Pass"; + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, true, 250); + stubManager.Write("\n*** Open Lid Head "); + + Bit = 1; + int i=0; + while ((Bit != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(F1_LS_01_Direct,7); + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result1 == DialogResult.Cancel) + { + Units_status[15,1]="Fail"; + Units_status[13,1]="Fail"; + stubManager.Write("LS_DH_LID_Open Not calibrate\n"); + return 0; + } + Units_status[13,1]="Pass"; + stubManager.Write("\n*** Close Lid Head "); + Bit = 1; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, false, 250); + i=0; + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(F1_LS_01_Direct,8); + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[14,1]="Fail"; + Units_status[15,1]="Fail"; + stubManager.Write("LS_DH_LID_Close Not calibrate\n"); + return 0; + } + Units_status[14,1]="Pass"; + stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,MAGNET_Driver, false,0x800000+2); + DialogResult result3 = MessageBox.Show("Make shure, Magnet is close", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[12,1]="Fail"; + stubManager.Write("Magnet Not close\n"); + return 0; + } + Units_status[12,1]="Pass"; + Units_status[15,1]="Pass"; + + return 0; +} + + +//------------------------------------ +public int Test_heaters_pt100() +{ + +// uint utemp=0; + uint temp=0; + float ftemp=0; + float ftemp1=0; + float current=0; + + stubManager.Write("\nTemp Befor heating \n"); + if (test_pt100_dyehead()!=0) + return 0; + +//------------Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 8 + SetBit (F2_CTRL, 3, 1); + stubManager.Write("Testing SSR no. 8\tHeadZone-1\t"); + delay(15000); + adc_configuration(0x40,0x10); //a2d_address 0x40 channel 3 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + current= (float)(temp); + current=( float) (0.001221) * current; + SetBit (F2_CTRL, 3, 0); + ftemp=Read_pt100(1); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+ current + "\n"); + ftemp = ftemp - DyeHeadTemp[0]; + + if ((current>1.5)|| (current<0.9)||(ftemp<5)||(ftemp>40)) + Units_status[6,1]="Fail"; + else + Units_status[6,1]="Pass"; + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 7 + ftemp=Read_pt100(2); + ftemp1 = ftemp - DyeHeadTemp[1]; + if ( ftemp1>4) + Units_status[7,1]="Fail"; + else + { + SetBit (F2_CTRL, 4, 1); + stubManager.Write("Testing SSR no. 7\tHeadZone-2\t"); + delay(15000); + adc_configuration(0x40,0x08); //a2d_address 0x40 channel 4 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + current= (float)(temp); + current=( float) (0.001221) * current; + SetBit (F2_CTRL, 4, 0); + ftemp=Read_pt100(2); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+ current + "\n"); + ftemp = ftemp - DyeHeadTemp[1]; + if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>40)) + Units_status[7,1]="Fail"; + else + Units_status[7,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 6 + + ftemp=Read_pt100(3); + ftemp1 = ftemp - DyeHeadTemp[2]; + if ( ftemp1>4) + Units_status[8,1]="Fail"; + else + { + SetBit (F2_CTRL, 5, 1); + stubManager.Write("Testing SSR no. 6\tHeadZone-3\t"); + delay(15000); + adc_configuration(0x40,0x04); //a2d_address 0x40 channel 5 + adc_set_for_read_ch(0x40); + temp=adc_read_ch(0x40); + current= (float)(temp); + current=( float) (0.001221) * current; + SetBit (F2_CTRL, 5, 0); + ftemp=Read_pt100(3); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current +"\n"); + ftemp = ftemp - DyeHeadTemp[2]; + if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>40)) + Units_status[8,1]="Fail"; + else + Units_status[8,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 5 + ftemp=Read_pt100(4); + ftemp1 = ftemp - DyeHeadTemp[3]; + if ( ftemp1>4) + Units_status[9,1]="Fail"; + else + { + SetBit (F2_CTRL, 6, 1); + stubManager.Write("Testing SSR no. 5\tHeadZone-4\t"); + delay(15000); + adc_configuration(0x44,0x80); //a2d_address 0x44 channel 0 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + current= (float)(temp); + current=( float) (0.001221) * current; + + SetBit (F2_CTRL, 6, 0); + ftemp=Read_pt100(4); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n"); + ftemp = ftemp - DyeHeadTemp[3]; + if ((current<2.9)|| (current>3.4)||(ftemp<5)||(ftemp>40 )) + Units_status[9,1]="Fail"; + else + Units_status[9,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 10 + ftemp=Read_pt100(5); + ftemp1 = ftemp - DyeHeadTemp[4]; + if ( ftemp1>4) + Units_status[10,1]="Fail"; + else + { + SetBit (F1_gpo_01, 2, 1); + stubManager.Write("Testing SSR no. 10\tHeadZone-5\t"); + delay(15000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + current= (float)(temp); + current=( float) (0.001526) * current; + SetBit (F1_gpo_01, 2, 0); + ftemp=Read_pt100(5); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n"); + ftemp = ftemp - DyeHeadTemp[4]; + if ((current<2.9)|| (current>3.4)||(ftemp<5)||(ftemp>40)) + Units_status[10,1]="Fail"; + else + Units_status[10,1]="Pass"; + } + + //Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 11 + ftemp=Read_pt100(11); + ftemp1 = ftemp - DyeHeadTemp[5]; + if ( ftemp1>4) + Units_status[11,1]="Fail"; + else + { + SetBit (F3_GPO_01_bus, 4, 1); + stubManager.Write("Testing SSR no. 11\tHeadZone-6\t"); + delay(15000); + adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1 + adc_set_for_read_ch(0x44); + temp=adc_read_ch(0x44); + current= (float)(temp); + current=( float) (0.001526) * current; + SetBit (F3_GPO_01_bus, 4, 0); + ftemp=Read_pt100(11); + stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n"); + ftemp = ftemp - DyeHeadTemp[5]; + if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>40)) + Units_status[11,1]="Fail"; + else + Units_status[11,1]="Pass"; + } + return 0; +} +//------------------------------------------------ + int test_pt100_dyehead() + { + float ftemp=0; + int temp=0; + int j=0; + for (int i = 0; i < 6; i++) + { + if (i==5) + j=11; + else + j=i+1; + DyeHeadTemp[i]=Read_pt100(j); + ftemp=DyeHeadTemp[i]; + if ((ftemp>100)|| (ftemp<10)) + { + Units_status[i,1]="Fail"; + } + else + { + Units_status[i,1]="Pass"; + } + stubManager.Write("Zone-"+(i+1)+ "\t" + ftemp.ToString("F2")); + stubManager.Write("°C\n"); + + } + return 0; + } diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/JIG_TESTER.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/JIG_TESTER.cs new file mode 100644 index 000000000..48a12dad2 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/JIG_TESTER.cs @@ -0,0 +1,853 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +include "Tango_define.cs" +include "MidTank_Jig.cs" +include "DyeHead_Jig.cs" +include "LTFU_Jig.cs" +include "RTFU_Jig.cs" +include "Winder_Jig.cs" +include "Dryer_Jig.cs" +include "Mixer_Jig.cs" +include "Location.cs" +include "New_DyeHead_Jig.cs" +include "New_Mixer_Jig.cs" + +//bool _click = false; +System.Timers.Timer timer; + + +string [,] Units_status = new string[50,2]; + +string File_Name1 ; +string Status; + + +const int Winder =0 ; +const int LTFU =1 ; + +string path; +string path1="C:\\Jig_Log\\";; + +bool BlinkOn = false; +bool timer_started = false; +CancellationTokenSource _cancellationTokenSource; + +int UNIT_UNDER_TEST ; + + +public void OnExecute(StubManager stubManager) +{ + Label Run_text = new Label () + { + Width = 110, + Height =35, + Text = "", + BackColor = Color.White + }; + + System.Windows.Forms.Label _calc_text= new Label() + { + Width = 350, + Height = 125, + Text = "" + }; + void setLabel1TextSafe(string txt) + { + if (_calc_text.InvokeRequired) + _calc_text.Invoke(new Action(() => _calc_text.Text = txt)); + else + _calc_text.Text = txt; + } + + void timer_Tick(object sender, EventArgs e) + { + if (BlinkOn) + { + Run_text.ForeColor = Color.Green; + Run_text.BackColor = Color.White; + } + else + { + Run_text.ForeColor = Color.Red; + Run_text.BackColor = Color.Black; + + } + BlinkOn = !BlinkOn; + } + + timer = new System.Timers.Timer(); + timer.Elapsed += timer_Tick; + timer.Interval = new TimeSpan(0, 0, 0, 0, 500).TotalMilliseconds; + //stubManager.WriteLine("OK!"); + Form form1 = new Form(); +// Set the caption bar text of the form. + //form1.TopMost = true; + form1.Text = "Tests"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; + form1.BackColor = Color.FromArgb(233, 245, 255); +//start mat +// Create buttons to Winder. + Button Winder_btm = new Button () + { + Width = 80, + Height = 40, + }; + Winder_btm.Text = "Winder"; + Winder_btm.Location = new Point (4, 70); + Winder_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(Winder_btm); + +// Create buttons to LTFU. + Button LTFU_btm = new Button () + { + Width = 80, + Height = 40, + }; + LTFU_btm.Text = "LTFU"; + LTFU_btm.Location = new Point (94, 70); + LTFU_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(LTFU_btm); + +// Create buttons to Dryer. + Button Dryer_btm = new Button () + { + Width = 80, + Height = 40, + }; + Dryer_btm.Text = "Dryer"; + Dryer_btm.Location = new Point (184, 70); + Dryer_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(Dryer_btm); + +// Create buttons to Dye head. + Button DyeHead_btm = new Button () + { + Width = 80, + Height = 40, + }; + DyeHead_btm.Text = "Dye head"; + DyeHead_btm.Location = new Point (4, 114); + DyeHead_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(DyeHead_btm); + +// Create buttons to RTFU. + Button RTFU_btm = new Button () + { + Width = 80, + Height = 40, + }; + RTFU_btm.Text = "RTFU"; + RTFU_btm.Location = new Point (94, 114); + RTFU_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(RTFU_btm); + +// Create buttons to Mid Tank. + Button MidTank_btm = new Button () + { + Width = 80, + Height = 40, + }; + MidTank_btm.Text = "Mid Tank"; + MidTank_btm.Location = new Point (184, 114); + MidTank_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(MidTank_btm); + +// Create buttons to WHS. + Button WHS_btm = new Button () + { + Width = 80, + Height = 40, + }; + WHS_btm.Text = "WHS"; + WHS_btm.Location = new Point (94, 158); + WHS_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(WHS_btm); + +// Create buttons to Mixer. + Button Mixer_btm = new Button () + { + Width = 80, + Height = 40, + }; + Mixer_btm.Text = "Mixer"; + Mixer_btm.Location = new Point (4, 158) ; + Mixer_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(Mixer_btm); + +// Create buttons to New Mixer . + Button NewMixer_btm = new Button () + { + Width = 80, + Height = 40, + }; + NewMixer_btm.Text = "New Mixer"; + NewMixer_btm.Location = new Point (4, 202); + NewMixer_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(NewMixer_btm); + +// Create buttons to NewDyeHead. + Button NewDyeHead_btm = new Button () + { + Width = 80, + Height = 40, + }; + NewDyeHead_btm.Text = "New Dye head"; + NewDyeHead_btm.Location = new Point (184, 158); + NewDyeHead_btm.BackColor = System.Drawing.Color.Gray; + form1.Controls.Add(NewDyeHead_btm); + +//-----Create Lable to Serial Number ----------- + + Label SN_lbl = new Label () + { + Width = 150, + Height = 20, + Text =" S/N" + }; + SN_lbl.Location = new Point (30, 10); + form1.Controls.Add(SN_lbl); + TextBox SN_TexstBox = new TextBox () + { + Width = 150, + Height = 20, + Text ="" + }; + SN_TexstBox.Location = new Point (40, 40); + form1.Controls.Add(SN_TexstBox); + //----------Create Lable to LOCATION---------- + Label Location_lbl = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; + Location_lbl.Location = new Point (300, 10); + form1.Controls.Add(Location_lbl); + + TextBox Location_TexstBox = new TextBox () + { + Width = 150, + Height = 20, + Text =Location_str + }; + Location_TexstBox.Location = new Point (300, 40); + form1.Controls.Add(Location_TexstBox); + + Run_text.Location = new System.Drawing.Point(300, 100); + Run_text.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + Run_text.Name = "blink_Text"; + Run_text.Font = new Font("Areal", 16, System.Drawing.FontStyle.Bold); + form1.Controls.Add(Run_text); +//-------------------------------------------------------------------------------- + Button Stop_btm = new Button() + { + Width = 260, + Height = 40, + }; + Stop_btm.Text = "Stop process"; + Stop_btm.BackColor = System.Drawing.Color.Red; + Stop_btm.Location = new System.Drawing.Point(4, 286); + Stop_btm.Enabled= false; + Stop_btm.Click += (_, __) => + { + timer.Stop(); + timer_started = false; + _cancellationTokenSource.Cancel(); + stubManager.WriteLine("stop "); + + }; + + form1.Controls.Add(Stop_btm); + + void disable_test() + { + Winder_btm.Enabled = false; + LTFU_btm.Enabled = false; + RTFU_btm.Enabled = false; + Dryer_btm.Enabled = false; + MidTank_btm.Enabled= false; + DyeHead_btm.Enabled= false; + WHS_btm.Enabled= false; + Mixer_btm.Enabled= false; + NewMixer_btm.Enabled= false; + NewDyeHead_btm.Enabled= false; + Stop_btm.Enabled= true; + } + + void enable_test() + { + Winder_btm.Enabled = true; + LTFU_btm.Enabled = true; + RTFU_btm.Enabled = true; + Dryer_btm.Enabled = true; + MidTank_btm.Enabled= true; + DyeHead_btm.Enabled= true; + WHS_btm.Enabled= true; + Mixer_btm.Enabled= true; + NewMixer_btm.Enabled= true; + NewDyeHead_btm.Enabled= true; + Stop_btm.Enabled= false; + } + void Timer_en() + { + if (timer_started == false) + { + timer.Start(); + timer_started = true; + } + } + void Timer_dis() + { + if (timer_started == true) + { + timer.Stop(); + timer_started = false; + } + } + void end_test() + { enable_test(); + Timer_dis(); + + Run_text.Text = Status; + if (Status=="Pass") + { + Run_text.ForeColor = Color.White;; + Run_text.BackColor = Color.Green; + } + else + { + Run_text.ForeColor = Color.Black; + Run_text.BackColor = Color.Red; + + } + } + +//----------------------------------------- + Winder_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- Winder "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Winder\\" ; + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await Winder_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,WINDER_Motor,3); //stop motor + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,SCREW,3); //stop motor + + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//----------------------------------------- + LTFU_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- LTFU "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\LTFU\\" ; + + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await LTFU_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold LRoading high z + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDANCER1_Motor, 3); //hold Lloading high z + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDRIVING_Motor,3); //stop motor + + Thread.Sleep(100); + Motor_SetParam(F1_MOTO_LLOADING_TX1,F1_MOTO_LLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + + + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//----------------------------------------- + Dryer_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- Dryer "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Dryer\\" ; + + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await Dryer_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + + enable_test(); + Status="Cancel"; + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DryerMain_Motor,3); //stop motor + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DrierLoadingArm_Motor, 3); + SetBit (F2_CTRL, 10, 0); //turn SSR1 off + SetBit (F2_CTRL, 9, 0); //turn SSR2 off + + + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//----------------------------------------- + DyeHead_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- DyeHead "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\DyeHead\\" ; + + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await DyeHead_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,MAGNET_Driver,3); //stop magnet + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + SetBit (F2_CTRL, 3, 0); + SetBit (F2_CTRL, 4, 0); + SetBit (F2_CTRL, 5, 0); + SetBit (F2_CTRL, 6, 0); + SetBit (F1_gpo_01, 2, 0); + SetBit (F3_GPO_01_bus, 4, 0); + + + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//----------------------------------------- + NewDyeHead_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- New DyeHead "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\NewDyeHead\\" ; + + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await NewDyeHead_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,MAGNET_Driver,3); //stop magnet + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + SetBit (F2_CTRL, 3, 0);//????????????????? + SetBit (F2_CTRL, 4, 0);//???????????????? + SetBit (F2_CTRL, 5, 0);//?????????????????/ + SetBit (F2_CTRL, 6, 0);//???????????????? + SetBit (F1_gpo_01, 2, 0);//??????????????? + SetBit (F3_GPO_01_bus, 4, 0);//???????????????????? + + + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//----------------------------------------- + RTFU_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- RTFU "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\RTFU\\" ; + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await RTFU_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(100); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDRIVING_Motor,3); //stop motor + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//----------------------------------------- + MidTank_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- MidTank "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\MidTank\\" ; + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await MidTank_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F3_VALVE_OUT, 0); //close all valve + + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//---------------------------Mixer-------------- + Mixer_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- Mixer "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Mixer\\" ; + + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await Mixer_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + SetBit (F1_gpo_01, 7, 0); //clear bit F1_VALVE_MIXCHIP_WASTECH + SetBit (F2_CTRL, 7, 0); //clear bit mixer SSR + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; +//---------------------------new Mixer-------------- + NewMixer_btm.Click += async(_,__) => + { + Run_text.Text = "Run"; + stubManager.WriteLine("DUT- New Mixer "); + path="%userprofile%\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Mixer\\" ; + + Timer_en(); + _cancellationTokenSource = new CancellationTokenSource(); + try + { + disable_test(); + var longRunningTask = await New_Mixer_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); + } + catch (OperationCanceledException) + { + enable_test(); + Status="Cancel"; + // SetBit (F1_gpo_01, 7, 0); ????????????//clear bit F1_VALVE_MIXCHIP_WASTECH + // SetBit (F2_CTRL, 7, 0); //????????????clear bit mixer SSR + stubManager.WriteLine("Task was cancelled"); + } + finally + { + _cancellationTokenSource.Dispose(); + } + end_test(); + }; + +//---------------------------WHS-------------- + +//---------------------------------------- + _calc_text.Location = new System.Drawing.Point(300, 150); + _calc_text.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + _calc_text.Name = ""; + _calc_text.Font = new Font("Areal", 16, System.Drawing.FontStyle.Bold); + form1.Controls.Add(_calc_text); +// stubManager.WriteLine("Start dialog!"); + form1.ShowDialog(); + + return ; + + +} + //--------------------------------------------------------------------------------------------------------------------- +string write_to_file(string s_n,string loocation,int unit_nm,string DUT) + +{ +string Stemp="Pass"; +string Stemp1="P"; + +int i; + + for ( i=0;i<unit_nm;i++) + { + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + { Stemp="Fail"; + Stemp1="F"; + } + } + +if (!Directory.Exists(path)) + { + if (!Directory.Exists(path1)) + Directory.CreateDirectory(path1); + path=path1; + } + + + +string File_Name2=Environment.ExpandEnvironmentVariables(path +Stemp1+"_"+ s_n +"_"+DUT +"_"+ DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ); + +stubManager.Write(File_Name2 +"\n"); + +stubManager.WriteToFile(File_Name2,DateTime.Now +" " ); +stubManager.Write(DateTime.Now +"\n" ); + +stubManager.AppendToFile(File_Name2,DUT + " Test Report" ); +stubManager.Write(DUT + " Test Report\n" ); + +stubManager.AppendToFile(File_Name2,DUT + " S/N: \t" + s_n ); +stubManager.Write(DUT + " S/N: \t" + s_n+"\n" ); + + +stubManager.AppendToFile(File_Name2,"Location:\t" + loocation +"\n" ); +stubManager.Write("Location:" + loocation+"\n\n" ); + + for ( i=0;i<unit_nm;i++) + { + stubManager.AppendToFile(File_Name2,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name2,"-------------"+DUT+ " Fail ------------ "); + stubManager.Write("-------------"+DUT+ " Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name2,"-------------"+DUT+ " Pass ------------ "); + stubManager.Write("-------------"+DUT+ " Pass ------------ "); + } + return Stemp; +} + +//------------------------------------------------------------------------------------- +void copy_table(int testing_nm,string [,]Units_status_DUT) +{ + for (int i=0;i<testing_nm;i++) + { +/// Units_status[i,0]=Units_status_Winder[i,0]; +// Units_status[i,1]=Units_status_Winder[i,1]; + Units_status[i,0]=Units_status_DUT[i,0]; + Units_status[i,1]=Units_status_DUT[i,1]; + + } +} + +public int delay(Int32 ms_delay) + { +int i; + for (i=0 ;i<ms_delay;i=i+10) + { + Thread.Sleep(10); + if (_cancellationTokenSource.Token.IsCancellationRequested) + { + _cancellationTokenSource.Token.ThrowIfCancellationRequested(); + throw new TaskCanceledException(); + return 0; + } + } + return 0; + + } + + +Int32 GetBit(Int32 Adr, Int32 BitNo) +{ + Int32 BitMask; + var RetVal = Fpga_Read_Reg(Adr); + BitMask = 0x1 << BitNo; + if ( ( (Int32) RetVal.Value & BitMask) == BitMask ) + { + return 1; + } + else + { + return 0; + } + +} + +public Int32 SetBit(Int32 Adr, Int32 BitNo, Int32 Bit) +{ + Int32 BitMask; + var RetVal = Fpga_Read_Reg(Adr); + Int32 RV = (Int32) RetVal.Value; + + if (Bit == 0x1) + { + BitMask = 0x1 << BitNo; + RV = RV | BitMask; + Fpga_Write_Reg( Adr, RV ); + } + else if (Bit == 0x0) + { + BitMask = ~(0x1 << BitNo); + RV = RV & BitMask; + Fpga_Write_Reg(Adr, RV ); + } + return 1; +} + + +int Fpga_Write_Reg(Int32 Addr, Int32 Data) +{ + var response = stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,Addr, Data); + + return 1; +} + + + +StubFpgaReadRegResponse Fpga_Read_Reg(Int32 Addr) +{ + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,Addr); + response.Value = response.Value & 0xffff; + + return response; +} + +float Read_pt100(int i) +{ + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" ,i); // + float ftemp = (float)response.TemperatureCMultBy100; + ftemp = ftemp / 100; + return (ftemp); +} +int Motor_SetParam(Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr, uint ParaData1) +{ + + Int32 Temp = 0; + Temp = (ParaAddr << 8 ) + ( (Int32) ParaData1 >> 24); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,HighAdr, (Temp & 0xffff)); + Temp = ((Int32)ParaData1 >> 8) & 0xffff; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,LowAdr, (Temp)); + + return 1; +} + +//-------------------------------- +int adc_configuration(uint I2C_Slave_Add,uint channel ) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID2; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(channel);//Byte 1 to Write, must be 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02 or 0x01 for different channels + stubI2CWriteBytesRequest.BytesTWrite.Add(0x80);//Byte 2 to Write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} +//-------------------------------- +int adc_set_for_read_ch(uint I2C_Slave_Add) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID2; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x01);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} +//-------------------------------- + +uint adc_read_ch(uint I2C_Slave_Add) +{ + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID2; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add; + stubI2CReadBytesRequest.NumberOfBytesToRead = 2; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + uint templ=0; + uint temp; + temph=response1.ReadBytes[0]; + templ=response1.ReadBytes[1]; + temp = (temph << 8) | templ; + temp=temp & 0x0fff; + + return temp; +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/LTFU_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/LTFU_Jig.cs new file mode 100644 index 000000000..e986e7942 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/LTFU_Jig.cs @@ -0,0 +1,392 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +//-------------------------------------------------------------------------------- + +const int LTFU_UNDER_TEST=9; +//--------------------------- + +string [,] Units_status_LTFU = new string[LTFU_UNDER_TEST,2] { + {"LS_LLOADMOTOR_Up","Not Test"}, //0 + {"LS_LLOADMOTOR_DOWN","Not Test"}, //1 + {"LLOADING_Motor","Not Test"}, //2 + {"LDRIVING_Motor","Not Test"}, //3 + {"LS_LDANCER1_DOWN","Not Test"}, //4 + {"LS_LDANCER1_UP","Not Test"}, //5 + {"LDANCER1_Motor","Not Test"}, //6 + {"LDANCER1_ROTENC","Not Test"}, //7 + {"LDANCER1_ROTENC","Not Test"}, //8 + }; +//----------------------------------------------------- +//-------------------------------------------------------------------------------- + + +public Task<decimal> LTFU_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (LTFU_UNDER_TEST,Units_status_LTFU); + + settext("Test LLOADING LTFU"); + Test_LLOADING_LTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold LRoading high z + delay(100); + Motor_SetParam(F1_MOTO_LLOADING_TX1,F1_MOTO_LLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + + settext("Test LDRIVING LTFU"); + Test_LDRIVING_LTFU(); + + settext("Test DANCER LTFU"); + + Test_DANCER_LTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDANCER1_Motor, 3); //hold Lloading high z + + Status=write_to_file(SN,Location,LTFU_UNDER_TEST,"LTFU"); + + settext("End Test"); + + decimal result = 0; + + return result; + }); + return task; +} + + + //------------------------------------ +int Test_LLOADING_LTFU() +{ + int temp=1; + int counter; + + Motor_SetParam(F1_MOTO_LLOADING_TX1,F1_MOTO_LLOADING_TX0,0x0a,0x2c000000); //set kval ran to 0x2c- 1.3A + delay(100); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor, false,200); //move Rloading down + delay(3000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Rloading high z + delay(1000); +//------------------------------------------ check F1_LS_LLOADMOTOR_UP------------------------------------------------ + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + if ((response.Value & F1_LS_LLOADMOTOR_UP) !=F1_LS_LLOADMOTOR_UP ) //if LS_RLOADMOTOR_UP is up then error + { + DialogResult result = MessageBox.Show("Did LLOADIN MOTOR Move?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.Yes) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_UP\tFail\n"); + return 0; + } + else + { + Units_status[2,1]="Fail"; + stubManager.Write("LLOADMOTOR\tFail\n"); + return 0; + } + } +//----------------------------------------- mov LLOADING up ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor,true,200); //move Lloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if LS_LLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_LLOADMOTOR_UP) != F1_LS_LLOADMOTOR_UP ) + counter=250; + + delay(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Lloading high z + + if (counter == 150) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_UP\tFail\n"); + return 0; + } + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_UP Not calibrate\n"); + return 0; + } + Units_status[0,1]="Pass"; + Units_status[2,1]="Pass"; + +//------------------------------------------ check F1_LS_LLOADMOTOR_DN------------------------------------------------ + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + + if ((response.Value & F1_LS_LLOADMOTOR_DN) !=F1_LS_LLOADMOTOR_DN ) //if LS_LLOADMOTOR_DN is up then error + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_DN\tFail\n"); + return 0; + } +//------------------------------------------ mov LLOADING dn ------------------------------------------------ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor, false,200); //move Lloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if LS_LLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_LLOADMOTOR_DN) != F1_LS_LLOADMOTOR_DN ) + counter=250; + + delay(100); + } + + if (counter == 150) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_DN\tFail\n"); + return 0; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Lloading high z + + DialogResult result4 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result4 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_LLOADMOTOR_DN Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + stubManager.Write("LLOADMOTOR\tPass\n"); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LLOADING_Motor, false,200); //move Lloading down + delay(2000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold Lloading high z + + return 1 ; + +} + + +Int32 ReadEncoder(int i) +{ + Int32 temp; + + if (i==0) //LDANCER1_ROTENC + { + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_LDANCER1_ROTENC_TX, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER1_ROTENC_LSB); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER1_ROTENC_MSB); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + + + return temp; + } + //LDANCER2_ROTENC + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_LDANCER2_ROTENC_TX, 0x0000); //triggers a TX transmission + var response2 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER2_ROTENC_LSB); + var response3 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LDANCER2_ROTENC_MSB); + + temp = Convert.ToInt32 (((((response3.Value <<16) + response2.Value)>>10 ) & 0x3fff)); + + + return temp; +} +//-------------------------------------------------------------------------------- +int Test_DANCER_LTFU() +{ + int counter; + Int32 temp; + Int32 temp1; + Int32 temp2; + Int32 temp3; + + +//------------------------------------------ check F1_LS_LDANCER1_DN ------------------------------------------------ + + MessageBox.Show("Make sure LDANCER Doun"); + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + + + if ((response.Value & F1_LS_LDANCER1_UP) !=F1_LS_LDANCER1_UP ) //if F1_LS_LDANCER1_UP is up then error + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_LDANCER_UP\tFail\n"); + return 0; + } + +//----------------------------------------- check F1_LS_LDANCER1_UP ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LDANCER1_Motor,false,400); //move Lloading up + counter =0; + while ( counter < 250) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if F1_LS_LDANCER1_UP is up then move down + if ((response.Value & F1_LS_LDANCER1_UP) != F1_LS_LDANCER1_UP ) + counter=350; + + delay(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDANCER1_Motor, 3); //hold Ldancer high z + + + if (counter == 250) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_LDANCER1_UP\tFail\n"); + return 0; + } + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //read LS + if ((response.Value & F1_LS_LDANCER1_DN) !=F1_LS_LDANCER1_DN ) //if F1_LS_LDANCER1_DN is up then error + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_LDANCER1_DOWN\tFail\n"); + return 0; + } + + DialogResult result5= MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + + if(result5== DialogResult.No) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_LDANCER1_UP Not calibrate\n"); + return 0; + } + + Units_status[5,1]="Pass"; + stubManager.Write("LS_LDANCER1_UP\tPass\n"); + +//----------------------------------------- mov LDANCER1_Motor down and check Ldancer encoder ------------------------------------------------- + temp= ReadEncoder(0); + delay(10); + + temp2= ReadEncoder(1); + + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LDANCER1_Motor,true,400); //move Rloading down + counter =0; + while ( counter < 250) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct); //if LS_LDANCER1_DN is dn then move stop + if ((response.Value & F1_LS_LDANCER1_DN) != F1_LS_LDANCER1_DN ) + counter=350; + + delay(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDANCER1_Motor, 3); //hold Rloading high z + if (counter == 250) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_LDANCER1_DOWN\tFail\n"); + return 0; + } + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + + if(result2 == DialogResult.No) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_LDANCER1_DN Not calibrate\n"); + return 0; + } + + Units_status[4,1]="Pass"; + stubManager.Write("LS_LDANCER1_DN\tPass\n"); + + Units_status[6,1]="Pass"; + stubManager.Write("LDANCER1_Motor\tPass\n"); + + temp1= ReadEncoder(0); + temp3= ReadEncoder(1); + + stubManager.Write("temp="+temp + "\temp1="+temp1 +"\n"); + + DialogResult result = MessageBox.Show("SSI Dancer1 led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[7,1]="Fail"; + stubManager.Write("LDANCER1_SSI\tFail\n"); + } + else + { + if (temp>temp1) + temp1=temp1+0x4000; + temp1=temp1-temp; + if ((temp1> 4000) || (temp1 <200)) + { + Units_status[7,1]="Fail"; + stubManager.Write("LDANCER1_SSI\tFail\n"); + } + else + { + Units_status[7,1]="Pass"; + stubManager.Write("LDANCER1_SSI\tPass\n"); + } + } + stubManager.Write("temp2="+temp2 + "\temp3="+temp3 +"\n"); + + DialogResult result3 = MessageBox.Show("SSI Dancer2 led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result3 == DialogResult.No) + { + Units_status[8,1]="Fail"; + stubManager.Write("LDANCER2_SSI\tFail\n"); + } + else + { + if (temp3>temp2) + temp2=temp2+0x4000; + temp2=temp2-temp3; + if ((temp2> 4000) || (temp2 <200)) + { + Units_status[8,1]="Fail"; + stubManager.Write("LDANCER2_SSI\tFail\n"); + } + else + { + Units_status[8,1]="Pass"; + stubManager.Write("LDANCER2_SSI\tPass\n"); + } + } + return 1; +} + + +//------------------------------------------------------------- +int Test_LDRIVING_LTFU() +{ + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,LDRIVING_Motor, true,200); //move Ldriving clockwise + stubManager.Write("LDRIVING_Motor Motor rotate \n "); + + DialogResult result = MessageBox.Show("Are LDRIVING Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("LDRIVING Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("LDRIVING Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,LDRIVING_Motor,3); //stop motor + + return 0; +} + + + diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/MidTank_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/MidTank_Jig.cs new file mode 100644 index 000000000..1a0a591bc --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/MidTank_Jig.cs @@ -0,0 +1,200 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +using System.Timers; + +const int MidTank_UNDER_TEST =24; +int [] Convert_Midtank_No = new Int32 [8] {1,3,5,7,2,4,6,8}; +uint [,] ADC_Add_Chnl = new uint [8,2] { + {0x44,0x20}, + {0x44,0x08}, + {0x46,0x80}, + {0x46,0x20}, + {0x44,0x10}, + {0x44,0x04}, + {0x46,0x40}, + {0x46,0x10}, + }; + + +string [,] Units_status_MidTank = new string[MidTank_UNDER_TEST,2] { + {"Midtank1_Valve_Air","Not Test"}, //0 + {"Midtank1_Valve_Ink","Not Test"}, //1 + {"Midtank1_Pressure_Sensor","Not Test"}, //2 + {"Midtank2_Valve_Air","Not Test"}, //3 + {"Midtank2_Valve_Ink","Not Test"}, //4 + {"Midtank2_Pressure_Sensor","Not Test"}, //5 + {"Midtank3_Valve_Air","Not Test"}, //6 + {"Midtank3_Valve_Ink","Not Test"}, //7 + {"Midtank3_Pressure_Sensor","Not Test"}, //8 + {"Midtank4_Valve_Air","Not Test"}, //9 + {"Midtank4_Valve_Ink","Not Test"}, //10 + {"Midtank4_Pressure_Sensor","Not Test"}, //11 + {"Midtank5_Valve_Air","Not Test"}, //12 + {"Midtank5_Valve_Ink","Not Test"}, //13 + {"Midtank5_Pressure_Sensor","Not Test"}, //14 + {"Midtank6_Valve_Air","Not Test"}, //15 + {"Midtank6_Valve_Ink","Not Test"}, //16 + {"Midtank6_Pressure_Sensor","Not Test"}, //17 + {"Midtank7_Valve_Air","Not Test"}, //18 + {"Midtank7_Valve_Ink","Not Test"}, //19 + {"Midtank7_Pressure_Sensor","Not Test"}, //20 + {"Midtank8_Valve_Air","Not Test"}, //21 + {"Midtank8_Valve_Ink","Not Test"}, //22 + {"Midtank8_Pressure_Sensor","Not Test"}, //23 + }; +//-------------------------------------------------------------------------------- + +public Task<decimal> MidTank_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + stubManager.Write("-----------------------\n"); + + copy_table (MidTank_UNDER_TEST,Units_status_MidTank); + stubManager.Write("+++++++++++++++++++\n"); + + settext("Test MidTank"); + Test_MIDTANK(); + + Status=write_to_file(SN,Location,MidTank_UNDER_TEST,"MidTank"); + settext("End Test"); + decimal result = 0; + + return result; + }); + return task; +} + + //------------------------------------ +int Test_MIDTANK() +{ + double Pressur_Volt; + double temp; + for (Int32 i=1;i<9;i++) + { + open_valve(i,0,1) ; //open Air valve + open_valve(i,1,1) ; //open Ink valve + delay(2000); + Pressur_Volt=read_pressuere_sense(i); + if ((Pressur_Volt>3 )||(Pressur_Volt<2)) + { + Units_status[(i-1)*3+2,1]="Fail"; + stubManager.Write("pressuere_sense of midtank" + i +"\tFail\n"); + } + else + { + close_valve(i,1,0) ; //close Ink valve + DialogResult result = MessageBox.Show("ADD 20cc air thru Air valve of Midtank"+ i, "Warning"); + close_valve(i,0,0) ; //close Air valve + delay(2000); + + temp=read_pressuere_sense(i); + temp=temp-Pressur_Volt; + if ((temp>0.5) && ( temp <2)) + Units_status[(i-1)*3+2,1]="Pass"; + else + Units_status[(i-1)*3+2,1]="Fail"; + } + + close_valve(i,0,0) ; //close Air valve + close_valve(i,1,0) ; //close Ink valve + } + return 1; +} + +double read_pressuere_sense(Int32 Midtank_Nm) +{ +double Pressur_Volt; +double calc; +uint temp; + + adc_configuration((ADC_Add_Chnl[Midtank_Nm-1,0]),(ADC_Add_Chnl[Midtank_Nm-1,1]) ); //configure address and channel of midtank + adc_set_for_read_ch(ADC_Add_Chnl[Midtank_Nm-1,0]); + temp =adc_read_ch(ADC_Add_Chnl[Midtank_Nm-1,0]); + calc= (double)temp *2.5 / 4096.0; + Pressur_Volt = (1.96- calc) * 4.64 + 1.96; + stubManager.Write("pressure sense of midtank " + Midtank_Nm + "is " + Pressur_Volt+ "Volt\n"); + return Pressur_Volt; +} + + +//-------------------------------- +int open_valve (int valve_nm,int valve_type,int check_valve) //valve_type=0 is Air ,1 is Ink ; check_valve=1 send feedbak +{ + int temp1=Convert_Midtank_No[valve_nm-1] ; + + string temp; + SetBit (F3_VALVE_OUT,((valve_type+1)*8)- temp1, 1); + if (check_valve!=0) + { + temp="Air"; + if (valve_type==1) + temp="Ink"; + + DialogResult result = MessageBox.Show("Did " + temp + "Valve of Midtank " + valve_nm +" open?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[(valve_nm-1)*3+valve_type,1]="Fail"; + stubManager.Write(temp +"Valve\tFail\n"); + return 0; + } + else + { + Units_status[(valve_nm-1)*3+valve_type,1]="Pass"; + stubManager.Write(temp +"Valve\tOpen\n"); + return 1; + } + + } + return 1; + +} +//-------------------------------- +int close_valve (int valve_nm,int valve_type,int check_valve) +{ + int temp1=Convert_Midtank_No[valve_nm-1]; + + string temp; + SetBit (F3_VALVE_OUT,((valve_type+1)*8)- temp1, 0); + if (check_valve!=0) + { + temp="Air"; + if (valve_type==1) + temp="Ink"; + + DialogResult result = MessageBox.Show("Did " + temp +" Valve of Midtank " + valve_nm +" close?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[(valve_nm-1)*3+valve_type,1]="Fail"; + stubManager.Write(temp +"Valve\tFail\n"); + return 0; + } + else + { + Units_status[(valve_nm-1)*3+valve_type,1]="Pass"; + stubManager.Write(temp +"Valve\tclose\n"); + return 1; + } + } + return 1; + + + + +} +//-------------------------------- diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Mixer_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Mixer_Jig.cs new file mode 100644 index 000000000..c5d14855e --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Mixer_Jig.cs @@ -0,0 +1,131 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +const int Mixer_UNDER_TEST=3; + +float MixerTemp ; + +string [,] Units_status_Mixer = new string[Mixer_UNDER_TEST,2] { + {"Pt100_Mixer","Not Test"}, + {"Heater_Mixer","Not Test"}, + {"VALVE_Mixer","Not Test"}, + }; + + + +//-------------------------------------------------------------------------------- + +public Task<decimal> Mixer_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (Mixer_UNDER_TEST,Units_status_Mixer); + + +//------------------------------- start test ----------- + settext("Test heaters & pt100"); + Test_Mixer_heaters_pt100 (); + settext("Test VALVE Mixer"); + Test_VALVE_Mixer (); + + Status=write_to_file(SN,Location,Mixer_UNDER_TEST,"Mixer"); + + settext("End Test"); + + decimal result = 0; + + return result; + }); + return task; +} + +//-------------------------------------------- + int Test_VALVE_Mixer () + { + SetBit (F1_gpo_01, 7, 1); //set bit F1_VALVE_MIXCHIP_WASTECH + + DialogResult result = MessageBox.Show("MixCHIP Valve Open ?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[2,1]="Fail"; + stubManager.Write("VALVE_MIXCHIP_WASTECH Not open\n"); + return 0; + } + SetBit (F1_gpo_01, 7, 0); //clear bit F1_VALVE_MIXCHIP_WASTECH + + DialogResult result1 = MessageBox.Show("MixCHIP Valve close ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[2,1]="Fail"; + stubManager.Write("VALVE_MIXCHIP_WASTECH Not close\n"); + return 0; + } + Units_status[2,1]="Pass"; + return 0; + } + +//------------------------------------ +public int Test_Mixer_heaters_pt100() +{ + +// uint utemp=0; + uint temp=0; + float ftemp=0; + float ftemp1=0; + float current=0; + + stubManager.Write("\nTemp Befor heating \n"); + + ftemp=Read_pt100(0); + if ((ftemp>100)|| (ftemp<10)) + { + Units_status[0,1]="Fail"; + return 0; + } + stubManager.Write("Temp Befor heating is"+ ftemp.ToString("F2")); + stubManager.Write("°C\n"); + + + + //Write F2_GPO_MIXCHIP_SSR4_CTRL SSR/SSR no. 4 + SetBit (F2_CTRL, 7, 1); + stubManager.Write("Testing SSR no. 4\tMIXCHIP \t"); + delay(10000); + adc_configuration(0x46,0x08); //a2d_address 0x46 channel 4 + adc_set_for_read_ch(0x46); + temp=adc_read_ch(0x46); + current= (float)(temp); + current=( float) (0.001221) * current; + SetBit (F2_CTRL, 7, 0); + + ftemp1=Read_pt100(0); + stubManager.Write("After heating " + ftemp1 +"c\tCurrent is "+ current + "\n"); + ftemp = ftemp1 - ftemp; + + if ((current>2.5)|| (current<1.5)||(ftemp<5)||(ftemp>25)) + { + Units_status[0,1]="Fail"; + Units_status[1,1]="Fail"; + } + else + { + Units_status[0,1]="Pass"; + Units_status[1,1]="Pass"; + } + return 0; +} diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/New_DyeHead_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/New_DyeHead_Jig.cs new file mode 100644 index 000000000..8d483b664 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/New_DyeHead_Jig.cs @@ -0,0 +1,651 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +const int New_DyeHead_UNDER_TEST=47; +const Int32 MGNET_OPEN=0x420301; +const Int32 MGNET_EN=0x420280; +const Int32 MGNET_CLOSE=0x420300; +const Int32 MGNET_DIS=0x420200; + +const Int32 ACTRST_DIS=0x420310; +const Int32 ACTRST_EN=0x420300; + + +const Int32 ACTDIR_ON=0x460200; +const Int32 ACTDIR_OFF=0x460280; + +const Int32 ACTIN_ON=0x460308; +const Int32 ACTOUT_ON=0x460304; + +const Int32 ACTIN_OFF=0x46030C; +const Int32 ACTOUT_OFF=0x46030C; + + + +const Int32 LS_FRONT=0X460110; +const Int32 LS_REAR=0X460120; +const Int32 LS_UPPER=0X460140; +const Int32 LS_SPARE=0X460180; +const Int32 ACTIN_EN=0X460101; +const Int32 ACTOUT_EN=0X460102; + + + +string EEPROM_Header="Header_1 "; //16 characters + +int Head_Mux_Channel_ID = 4; //Head MUX channel + char[] characters = new char[16]; + + +//float [] DyeHeadTemp = new float[6] ; + +string [,] Units_status_New_DyeHead = new string[New_DyeHead_UNDER_TEST,2] { + {"Pt100_Zone_1","Pass"}, //0 + {"Pt100_Zone_2","Pass"}, //1 + {"Pt100_Zone_3","Pass"}, //2 + {"Pt100_Zone_4","Pass"}, //3 + {"Pt100_Zone_5","Pass"}, //4 + {"Pt100_Zone_6","Pass"}, //5 + {"Pt100_Zone_7","Pass"}, //6 + {"Pt100_Zone_8","Pass"}, //7 + {"Pt100_Zone_9","Pass"}, //8 + {"Pt100_Zone_10","Pass"}, //9 + {"Pt100_Zone_11","Pass"}, //10 + {"Pt100_Zone_12","Pass"}, //11 + + {"Current_Zone_1","Pass"}, //12 + {"Current_Zone_2","Pass"}, //13 + {"Current_Zone_3","Pass"}, //14 + {"Current_Zone_4","Pass"}, //15 + {"Current_Zone_5","Pass"}, //16 + {"Current_Zone_6","Pass"}, //17 + {"Current_Zone_7","Pass"}, //18 + {"Current_Zone_8","Pass"}, //19 + {"Current_Zone_9","Pass"}, //20 + {"Current_Zone_10","Pass"}, //21 + {"Current_Zone_11","Pass"}, //22 + {"Current_Zone_12","Pass"}, //23 + + {"Break_Zone_1","Pass"}, //24 + {"Break_Zone_2","Pass"}, //25 + {"Break_Zone_3","Pass"}, //26 + {"Break_Zone_4","Pass"}, //27 + {"Break_Zone_5","Pass"}, //28 + {"Break_Zone_6","Pass"}, //29 + {"Break_Zone_7","Pass"}, //30 + {"Break_Zone_8","Pass"}, //31 + {"Break_Zone_9","Pass"}, //32 + {"Break_Zone_10","Pass"}, //33 + {"Break_Zone_11","Pass"}, //34 + {"Break_Zone_12","Pass"}, //35 + + {"Magnet ","Not Test"}, //36 + {"LS_REAR","Not Test"}, //37 + {"LS_FRONT","Not Test"}, //38 + {"DH_LID_Motor","Not Test"}, //39 + + {"EEPROM ","Pass"}, //40 + + {"ACTUATOR_IN","Not Test"}, //41 + {"LS_IN_UP","Not Test"}, //42 + {"LS_IN_DN","Not Test"}, //43 + {"ACTUATOR_OUT","Not Test"}, //44 + {"LS_OUT_UP","Not Test"}, //45 + {"LS_OUT_DN","Not Test"}, //46 + + + }; + + + +//-------------------------------------------------------------------------------- + +public Task<decimal> NewDyeHead_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (New_DyeHead_UNDER_TEST,Units_status_New_DyeHead); + DialogResult result1 = MessageBox.Show("Make shure, Dyehead is not hot", "Warning",MessageBoxButtons.OKCancel); + if(result1 == DialogResult.Cancel) + { + stubManager.AppendToFile(File_Name1,"Dyehead is too hot \tFail"); + stubManager.Write("Dyehead is too hot \tFail\n"); + return 0 ; + } + else + { + stubManager.Run<ProgressResponse>("ProgressRequest" ,0xC3,0); // disable i2c + +//------------------------------- start test ----------- + settext("Test Magnet Motor LS"); +// Test_Magnet_Motor_LS_New_DyeHead(); + settext("Test heaters &pt100"); +// Test_heaters_pt100 (); + settext("Test Head EEPROM"); +// Test_Head_EEPROM(SN); //pass + settext("Test Actuator In"); +// Test_Actuator_in(); + settext("Test Actuator Out"); + Test_Actuator_out(); + Status=write_to_file(SN,Location,New_DyeHead_UNDER_TEST,"Dyehead"); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0xC3,1); // disable i2c + + settext("End Test"); + } + decimal result = 0; + + return result; + }); + return task; +} + +//------------------------------------------------------------- + int Test_Actuator_in() +{ + Int32 temp; + int i=0; + + DialogResult result = MessageBox.Show("Make shure, ACTUATOR-IN is down", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[41,1]="Fail"; + stubManager.Write("ACTUATOR-IN is Up\n"); + return 0; + } +//---------------------- move ACTUATOR-IN Up ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_ON); // DIR=1 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_ON); // act_in enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_OFF); // act_in disable + stubManager.Write("ACTUATOR-IN moving Up\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTIN_EN); // read ACTIN_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[41,1]="Fail"; + stubManager.Write("CTUATOR-IN is not moving Up\n"); + return 0; + } + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[42,1]="Fail"; + stubManager.Write("LS_IN_UP Not calibrate\n"); + return 0; + } + Units_status[41,1]="Pass"; + Units_status[42,1]="Pass"; +//---------------------- move ACTUATOR-IN Dn ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_OFF); // DIR=0 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_ON); // act_in enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_OFF); // act_in disable + stubManager.Write("ACTUATOR-IN moving Dn\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTIN_EN); // read ACTIN_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[41,1]="Fail"; + stubManager.Write("CTUATOR-IN is not moving Down\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[43,1]="Fail"; + stubManager.Write("LS_IN_Down Not calibrate\n"); + return 0; + } + Units_status[43,1]="Pass"; + return 0; + +} +//------------------------------------------------------------- + int Test_Actuator_out() +{ + Int32 temp; + int i=0; + + DialogResult result = MessageBox.Show("Make shure, ACTUATOR-OUT is down", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[44,1]="Fail"; + stubManager.Write("ACTUATOR-OUT is Up\n"); + return 0; + } +//---------------------- move ACTUATOR-OUT Up ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_ON); // DIR=1 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTRST_DIS); // act_OUT enable + + DialogResult result_debug0 = MessageBox.Show("result_debug0", "Warning",MessageBoxButtons.OKCancel); + + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_ON); // act_OUT enable + + DialogResult result_debug1 = MessageBox.Show("result_debug1", "Warning",MessageBoxButtons.OKCancel); + + + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_OFF); // act_OUT disable + DialogResult result_debug2 = MessageBox.Show("result_debug2", "Warning",MessageBoxButtons.OKCancel); + + stubManager.Write("ACTUATOR-OUT moving Up\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTOUT_EN); // read ACTOUT_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[44,1]="Fail"; + stubManager.Write("CTUATOR-OUT is not moving Up\n"); + return 0; + } + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[45,1]="Fail"; + stubManager.Write("LS_OUT_UP Not calibrate\n"); + return 0; + } + Units_status[44,1]="Pass"; + Units_status[45,1]="Pass"; +//---------------------- move ACTUATOR-OUT Dn ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_OFF); // DIR=0 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_ON); // act_out enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_OFF); // act_out disable + stubManager.Write("ACTUATOR-OUT moving Dn\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTOUT_EN); // read ACTOUT_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[44,1]="Fail"; + stubManager.Write("CTUATOR-OUT is not moving Down\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[46,1]="Fail"; + stubManager.Write("LS_OUT_Down Not calibrate\n"); + return 0; + } + Units_status[46,1]="Pass"; + return 0; + +} + + + +//-------------------------------------------- + int Test_Magnet_Motor_LS_New_DyeHead() +{ + Int32 temp; + int i=0; + +//---------------------- open Magnet ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_OPEN); // turn magnet on + delay(100); + + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_EN); // magnet enable +// delay(100); + + stubManager.Write("Magnet is Open\n"); + delay(1000); +//---------------------- chekc Magnet is open ---------------------------- + temp=read_pio (LS_UPPER); // read LS_UPPER + if (temp != 0) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is close\n"); + return 0; + } + DialogResult result = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is close\n"); + return 0; + } +//---------------------- Move DyeingHead Lid Motor rear---------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, true, 250); + stubManager.Write("*** Open Lid Head \n"); + + temp = 0; + i=0; + while ((temp == 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (LS_REAR); // read LS_REAR + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + if(i == 200) + { + Units_status[37,1]="Fail"; + Units_status[39,1]="Fail"; + stubManager.Write("LS_REAR Not calibrate\n"); + return 0; + } + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[37,1]="Fail"; + Units_status[39,1]="Fail"; + stubManager.Write("LS_REAR Not calibrate\n"); + return 0; + } + Units_status[37,1]="Pass"; +//---------------------- Move DyeingHead Lid Motor front---------------------------- + stubManager.Write("*** Close Lid Head \n"); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, false, 250); + temp = 0; + i=0; + while ((temp == 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (LS_FRONT); // read LS_FRONT + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + if(i == 200) + { + Units_status[38,1]="Fail"; + stubManager.Write("LS_FRONT Not calibrate\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[38,1]="Fail"; + stubManager.Write("LS_FRONT Not calibrate\n"); + return 0; + } + Units_status[39,1]="Pass"; + Units_status[38,1]="Pass"; + +//---------------------- Close Magnet ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_CLOSE); // turn magnet off + delay(2000); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_DIS); // magnet Disable + + stubManager.Write("Magnet is Close\n"); + delay(1000); +//---------------------- chekc Magnet is close ---------------------------- + temp=read_pio (LS_UPPER); // read LS_UPPER + if (temp == 0) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is open\n"); + return 0; + } + DialogResult result4 = MessageBox.Show("Make shure, Magnet is close", "Warning",MessageBoxButtons.OKCancel); + if(result4 == DialogResult.Cancel) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is open\n"); + return 0; + } + Units_status[36,1]="Pass"; + stubManager.Write("Magnet is close\n"); + return 0; +} + + +//------------------------------------ +public int Test_new_heaters_pt100() +{ + +// uint utemp=0; + Int32 temp=0; + float ftemp=0; + float ftemp1=0; + float current=0; + Double current_sense; + + for (Int32 i = 0; i < 12; i++) + { + Int32 tdly=10000; +//---------------------- get tempurature of heaters---------------------------- + temp= 0x8000 +12+i/2+(i%2)*8; //HZone_1=12 + //HZone_2=20 + //HZone_3=13 + //HZone_4=21 + //HZone_5=14 + //HZone_6=22 + //HZone_7=15 + //HZone_8=23 + //HZone_9=16 + //HZone_10=24 + //HZone_11=17 + //HZone_11=25 + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , temp); //get temperature from the buffer + ftemp = (float)response.TemperatureCMultBy100; + ftemp = ftemp / 100; + + if ((ftemp>50)|| (ftemp<15)) + { + Units_status[i,1]="Fail"; + tdly=1000; + + } + stubManager.Write("Zone-"+(i+1)+ "\t" + ftemp.ToString("F2")+"°C\n"); +//---------------------- get current of heaters ---------------------------- + var response1 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + i); // get current + current_sense=response1.Pressure; + if (current_sense>0.1) + { + Units_status[i+12,1]="Fail"; + } + stubManager.Write("current is "+(i+1)+ "\t" + current_sense +"\n"); +//---------------------- get Break of heaters ---------------------------- + var response2 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x440000 +(i/8)*0x100+(1<<(i&7))); // read break + temp = (Int32) (response2.Progress); + if ((temp & (1<<(i&7))) !=0) //if break ok + { + Units_status[i+24,1]="Fail"; + stubManager.Write("Break Zone "+(i+1)+ "\t is Off\n"); + } + else + { + stubManager.Write("Break Zone "+(i+1)+ "\t is Off\n"); + } +//---------------------- turn heater on ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x400200 +(i/8)*0x100+(1<<(i&7))); // turn heater on + stubManager.Write("Heater - "+(i+1)+ "\t is On\n"); + delay(2000); //delay 20 second +//---------------------- get current of heaters ---------------------------- + var response3 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + i); // get current + current_sense=response3.Pressure; + if ((current_sense<1.1) ||(current_sense>1.4) ) //if current not 1.25A + { + Units_status[i+12,1]="Fail"; + } + stubManager.Write("current is "+(i+1)+ "\t" + current_sense +"\n"); +//---------------------- get Break of heaters ---------------------------- + var response4 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x440000 +(i/8)*0x100+(1<<(i&7))); // read break + temp = (Int32) (response4.Progress); + if ((temp & (1<<(i&7))) !=0) //if break ok + { + Units_status[i+24,1]="Fail"; + stubManager.Write("Break Zone "+(i+1)+ "\t is Off\n"); + } + else + { + stubManager.Write("Break Zone "+(i+1)+ "\t is On\n"); + } + delay(tdly); //delay 20 second + temp= 12+i/2+(i%2)*8; + var response5 = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , temp); //get temperature from the buffer + ftemp1 = (float)response5.TemperatureCMultBy100; + ftemp1 = ftemp1 / 100; + + if (((ftemp1-ftemp)<5)|| ((ftemp1-ftemp)>35)) + { + Units_status[i,1]="Fail"; + } + stubManager.Write("Zone-"+(i+1)+ "after heating is \t" + ftemp1.ToString("F2")+"°C\n"); +//---------------------- turn heater off ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x400200 +(i/8)*0x100); // turn heater off + stubManager.Write("Heater - "+(i+1)+ "\t is Off\n"); + + } + return 0; +} + +Int32 read_pio(Int32 i2c_input) +{ + Int32 temp=0; + var response = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,i2c_input); // read break + temp = (Int32) (response.Progress); + temp =temp & (i2c_input& 0xff); //if break ok + return temp; +} +//end mati + + //enable_all_channel(); +public int Test_Head_EEPROM(string s_n) +{ + stubManager.WriteLine("--debug -1"); + + enable_channel(Head_Mux_Channel_ID); // Chanel 0-7 => Disp0enser 0-7 + + Write_EEPROM(0xA0,s_n); + delay(200); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + +//------------ go to address 0 on eeprom -------------- + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID3; + stubI2CWriteBytesRequest.SlaveAddress = 0xA0; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + //Thread.Sleep(1); //Sleep for 10 milli. + Read_EEPROM(0xA0); + + delay(20); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + return 0; + +} + +int enable_channel(int Channel_ID) +{ + uint Const_temp = 0x01; + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID3; + stubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address; + + Const_temp = Const_temp << Channel_ID; + stubI2CWriteBytesRequest.BytesTWrite.Add(Const_temp); + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int Write_EEPROM (uint I2C_Slave_Add,string s_n ) +{ + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID3; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + + //-------------------------------------------------------------- + characters = EEPROM_Header.ToCharArray(); + + for (int i=0;i<16;i++) + { + stubI2CWriteBytesRequest.BytesTWrite.Add(characters[i]); //add header + // characters[i]=0x20; + } + characters = s_n.ToCharArray(); + + for (int i=0;i<characters.Length ;i++) + { + + stubI2CWriteBytesRequest.BytesTWrite.Add(characters[i]); //add s/n + + } + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int Read_EEPROM(uint I2C_Slave_Add) +{ + char temp; + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID3; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add + 1; + stubI2CReadBytesRequest.NumberOfBytesToRead = 16; // Number of header bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + char[] characters = EEPROM_Header.ToCharArray(); + stubManager.WriteLine("--debug --7 "); + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + temp = Convert.ToChar(response1.ReadBytes[i]); + + + } + + return 1; +} diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/New_Mixer_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/New_Mixer_Jig.cs new file mode 100644 index 000000000..949d0a194 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/New_Mixer_Jig.cs @@ -0,0 +1,168 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +const int New_Mixer_UNDER_TEST=4; +const Int32 Valve_EN=0x420220; +const Int32 Valve_DIS=0x420200; +const Int32 Mixer_ON=0x420210; +const Int32 Mixer_OFF=0x420200; + +float NewMixerTemp ; + +string [,] Units_status_New_Mixer = new string[New_Mixer_UNDER_TEST,2] { + {"Pt100_Mixer","Pass"}, //0 + {"Heater_Mixer","Pass"}, //1 + {"Break_Mixer","Pass"}, //2 + {"VALVE_Mixer","Not Test"}, //3 + }; + + + +//-------------------------------------------------------------------------------- + +public Task<decimal> New_Mixer_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (New_Mixer_UNDER_TEST,Units_status_New_Mixer); + + +//------------------------------- start test ----------- + settext("Test heater & pt100"); + Test_New_Mixer_heater_pt100 (); + settext("Test VALVE Mixer"); + Test_VALVE_New_Mixer (); + + Status=write_to_file(SN,Location,New_Mixer_UNDER_TEST,"Mixer"); + + settext("End Test"); + + decimal result = 0; + + return result; + }); + return task; +} + +//-------------------------------------------- + int Test_VALVE_New_Mixer () + { + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Valve_EN); // Valve enable + + DialogResult result = MessageBox.Show("MixCHIP Valve Open ?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("VALVE_MIXCHIP_WASTECH Not open\n"); + return 0; + } + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Valve_DIS); // Valve enable + + DialogResult result1 = MessageBox.Show("MixCHIP Valve close ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("VALVE_MIXCHIP_WASTECH Not close\n"); + return 0; + } + Units_status[3,1]="Pass"; + return 0; + } + +//------------------------------------ +public int Test_New_Mixer_heater_pt100() +{ + Int32 temp=0; + float ftemp=0; + float ftemp1=0; + float current=0; + Int32 tdly=10000; + Double current_sense; + +//---------------------- get tempurature of mixer---------------------------- + + stubManager.Write("\nTemp Befor heating \n"); + + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , 19); //get temperature from mixer + ftemp = (float)response.TemperatureCMultBy100; + if ((ftemp>100)|| (ftemp<10)) + { + Units_status[0,1]="Fail"; + tdly=1000; + } + stubManager.Write("Temp Befor heating is"+ ftemp.ToString("F2")); + stubManager.Write("°C\n"); +//---------------------- get current of mixer ---------------------------- + var response1 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + 20); // get current mixer + current_sense=response1.Pressure; + if (current_sense>0.1) + { + Units_status[1,1]="Fail"; + } + stubManager.Write("current is " + current_sense +"\n"); +//---------------------- get Break of Mixer ---------------------------- + var response2 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x460000 +0x10); // read break + temp = (Int32) (response2.Progress); + if ((temp & 0x10 )!=0) //if break ok + { + Units_status[2,1]="Fail"; + stubManager.Write("Break Mixer is Off\n"); + } + else + { + stubManager.Write("Break Mixer is On\n"); + } +//---------------------- turn Mixer on ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Mixer_ON); // turn mixer on + stubManager.Write("Mixer On\n"); + delay(2000); //delay 20 second +//---------------------- get current of mixer ---------------------------- + var response3 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + 20); // get current + current_sense=response3.Pressure; + if ((current_sense<2) ||(current_sense>3) ) //if current not 2.5A + { + Units_status[3,1]="Fail"; + } + stubManager.Write("current in Mixer is " + current_sense +"\n"); +//---------------------- get Break of Mixer ---------------------------- + var response4 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x460000 +0x10); // read break + temp = (Int32) (response4.Progress); + if ((temp & 0x10 )!=0) //if break ok + { + Units_status[2,1]="Fail"; + stubManager.Write("Break Mixer is Off\n"); + } + else + { + stubManager.Write("Break Mixer is On\n"); + } +//---------------------- get tempurature of mixer---------------------------- + var response5 = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , 19); //get temperature from the mixer + ftemp1 = (float)response5.TemperatureCMultBy100; + ftemp1 = ftemp1 / 100; + + if (((ftemp1-ftemp)<5)|| ((ftemp1-ftemp)>35)) + { + Units_status[0,1]="Fail"; + } + stubManager.Write("Mixer after heating is \t" + ftemp1.ToString("F2")+"°C\n"); +//---------------------- turn Mixer off ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Mixer_OFF); // turn mixer off + stubManager.Write("Mixer is Off\n"); + return 0; +} diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/RTFU_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/RTFU_Jig.cs new file mode 100644 index 000000000..d63cbe86c --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/RTFU_Jig.cs @@ -0,0 +1,367 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; +//-------------------------------------------------------------------------------- +//-------------------------------------------------------------------------------- + +const int RTFU_UNDER_TEST=9; + +string [,] Units_status_RTFU = new string[RTFU_UNDER_TEST,2] { + {"LS_RLOADMOTOR_Up","Not Test"}, //0 + {"LS_RLOADMOTOR_DOWN","Not Test"}, //1 + {"RLOADING_Motor","Not Test"}, //2 + {"DRIVING_Motor","Not Test"}, //3 + {"LS_RDANCER_DOWN","Not Test"}, //4 + {"LS_RDANCER_UP","Not Test"}, //5 + {"LS_RLOADRAM_DOWN","Not Test"}, //6 + {"RDANCER_Motor","Not Test"}, //7 + {"RDANCER_ROTENC","Not Test"}, //8 + }; + + + +//----------------------------------------------------- + +public Task<decimal> RTFU_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (RTFU_UNDER_TEST,Units_status_RTFU); + + settext("Test RLOADING RTFU"); + Test_RLOADING_RTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + delay(100); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + + settext("Test RDRIVING RTFU"); + Test_RDRIVING_RTFU(); + + settext("Test DANCER RTFU"); + + Test_DANCER_RTFU(); + + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + Status=write_to_file(SN,Location,RTFU_UNDER_TEST,"RTFU"); + + settext("End Test"); + decimal result = 0; + + return result; + }); + return task; +} + + + //------------------------------------ +int Test_RLOADING_RTFU() +{ + int temp=1; + int counter; + + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x40000000); //set kval ran to 0x40- 1.9A + delay(100); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + delay(3000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + delay(1000); +//------------------------------------------ check F1_LS_RLOADMOTOR_up------------------------------------------------ + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RLOADMOTOR_UP) !=F1_LS_RLOADMOTOR_UP ) //if LS_RLOADMOTOR_UP is up then error + { + DialogResult result = MessageBox.Show("Did RLOADIN MOTOR Move?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.Yes) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + else + { + Units_status[2,1]="Fail"; + stubManager.Write("RLOADMOTOR\tFail\n"); + return 0; + } + } + +//----------------------------------------- mov RLOADING up ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor,false,200); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_UP) != F1_LS_RLOADMOTOR_UP ) + counter=250; + + delay(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + if (counter == 150) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP Not calibrate\n"); + return 0; + } + Units_status[0,1]="Pass"; + Units_status[2,1]="Pass"; + +//------------------------------------------ check F1_LS_RLOADMOTOR_DN------------------------------------------------ + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + + if ((response.Value & F1_LS_RLOADMOTOR_DN) !=F1_LS_RLOADMOTOR_DN ) //if LS_RLOADMOTOR_DN is up then error + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } +//------------------------------------------ mov RLOADING dn ------------------------------------------------ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_DN) != F1_LS_RLOADMOTOR_DN ) + counter=250; + + delay(100); + } + + if (counter == 150) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + stubManager.Write("RLOADMOTOR\tPass\n"); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + delay(2000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + return 1 ; + +} + +//---------------------------------- + +Int32 ReadEncoder() +{ + Int32 temp; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_RDANCER_ROTENC_DATA_p_TX, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_lsb); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_msb); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + + + return temp; +} +//-------------------------------------------------------------------------------- +int Test_DANCER_RTFU() +{ + int counter; + Int32 temp; + Int32 temp1; + +//------------------------------------------ check F1_LS_RDANCER_DOWN ------------------------------------------------ + + MessageBox.Show("Make sure RDANCER Down"); + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RDANCER_DOWN) !=F1_LS_RDANCER_DOWN ) //if F1_LS_RDANCER_DOWN is up then error + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } +//----------------------------------------- mov RDANCER_Motor up and check F1_LS_RDANCER_DOWN ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,true,10); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + delay(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[4,1]="Pass"; + stubManager.Write("LS_RDANCER_DOWN\tPass\n"); + +//----------------------------------------- check F1_LS_RDANCER_UP ------------------------------------------------- + + if ((response.Value & F1_LS_RDANCER_UP) !=F1_LS_RDANCER_UP ) //if F1_LS_RDANCER_UP is up then error + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RDANCER_UP is up then move down + if ((response.Value & F1_LS_RDANCER_UP) != F1_LS_RDANCER_UP ) + counter=250; + + delay(100); + } + if (counter == 150) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + Units_status[5,1]="Pass"; + stubManager.Write("LS_RDANCER_UP\tPass\n"); + +//----------------------------------------- check F1_LS_RLOADRAM_DOWN ------------------------------------------------- + + if ((response.Value & F1_LS_RLOADRAM_DOWN) !=F1_LS_RLOADRAM_DOWN ) //if F1_LS_RLOADRAM_DOWN is up then error + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RLOADRAM_DOWN is up then move down + if ((response.Value & F1_LS_RLOADRAM_DOWN) != F1_LS_RLOADRAM_DOWN ) + counter=250; + + delay(100); + } + if (counter == 150) + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + Units_status[6,1]="Pass"; + stubManager.Write("LS_RLOADRAM_DOWN\tPass\n"); + +//----------------------------------------- mov RDANCER_Motor down and check rdancer encoder ------------------------------------------------- + temp= ReadEncoder(); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,false,10); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + delay(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[7,1]="Pass"; + stubManager.Write("RDANCER_Motor\tPass\n"); + + temp1= ReadEncoder(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + stubManager.Write("temp="+temp + "\temp1="+temp1 +"\n"); + + DialogResult result = MessageBox.Show("SSI Dancer led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + + if (temp>temp1) + temp1=temp1+0x4000; + + temp1=temp1-temp; + if ((temp1> 15000) || (temp1 <1000)) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + Units_status[8,1]="Pass"; + stubManager.Write("RDANCER_SSI\tPass\n"); + + return 1; +} + + +//------------------------------------------------------------- +int Test_RDRIVING_RTFU() +{ + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDRIVING_Motor, true,200); //move Rdriving clockwise + stubManager.Write("RDRIVING_Motor Motor rotate \n "); + + DialogResult result = MessageBox.Show("Are RDRIVING Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("RDRIVING Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("RDRIVING Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDRIVING_Motor,3); //stop motor + + return 0; +} + + diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Tango_define.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Tango_define.cs new file mode 100644 index 000000000..8f2d3b28f --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Tango_define.cs @@ -0,0 +1,122 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +const Int32 F1_LS_01_Direct = 0x60000020 ; +const Int32 F1_LS_02_Direct = 0x60000030 ; +const Int32 F1_LS_03_Direct = 0x60000040 ; + +const Int32 F1_gpo_01 = 0x600003D2 ; + + +const Int32 F2_CTRL = 0x600004E2 ; + +const Int32 F3_GPO_01_bus = 0x600008C2; + +const Int32 TCA9548A_address = 0xE2; + + +const Int32 I2C_ID2 = 2; +const Int32 I2C_ID3 = 3; + + + +const Int32 F1_SCREW_ROTENC_lsb = 0x60000100; +const Int32 F1_SCREW_ROTENC_msb = 0x60000102; + + + + + + + + + + +const Int32 F3_VALVE_OUT = 0x600008e2; + + +const Int32 F1_Tacho_reg8 = 0x600001e0 ; + + + + +//-------------------DEFINE Motors Parameters------------------ + +const Int32 F1_MOTO_RLOADING_TX1 = 0x60000202; +const Int32 F1_MOTO_RLOADING_TX0 = 0x60000200; +const Int32 F1_MOTO_RLOADING_RX1 = 0x60000206; +const Int32 F1_MOTO_RLOADING_RX0 = 0x60000204; + +//-------------------DEFINE Limit Switch--------------- + +const Int32 F1_LS_RLOADMOTOR_UP = 0x0040 ; +const Int32 F1_LS_RLOADMOTOR_DN = 0x0080 ; +const Int32 F1_LS_RDANCER_UP = 0x0100; +const Int32 F1_LS_RDANCER_DOWN = 0x0200; +const Int32 F1_LS_RLOADRAM_DOWN = 0x0020; + +const Int32 F1_RDANCER_ROTENC_DATA_p_RX_lsb = 0x600001a0; +const Int32 F1_RDANCER_ROTENC_DATA_p_RX_msb = 0x600001a2; +const Int32 F1_RDANCER_ROTENC_DATA_p_TX = 0x600001ae; + + + +const Int32 F2_Prescaler1_reg11 = 0x60000512 ; +const Int32 F2_BLOWER_PWM_LOW = 0x600007EC ; +const Int32 F2_BLOWER_PWM_HIGH = 0x600007EE ; + + +//-------------------DEFINE Motors------------------ +const Int32 CleaningHead_Motor = 0; +const Int32 CleaningMechanisim_Motor= 1; +const Int32 DyeingHeadLid_Motor = 2; +const Int32 DryerMain_Motor = 3; +const Int32 DryerLid_Motor = 4; +const Int32 DrierLoadingArm_Motor = 5; + +const Int32 SCREW = 14; +const Int32 WINDER_Motor = 15; + +const Int32 LDANCER1_Motor = 16; +const Int32 LDANCER2_Motor = 17; +const Int32 LDRIVING_Motor = 18; +const Int32 LLOADING_Motor = 19; + +const Int32 RDANCER_Motor = 21; +const Int32 RDRIVING_Motor = 22; +const Int32 MAGNET_Driver = 23; //replace RLOADARM +const Int32 RLOADING_Motor = 24; + + +//-------------------DEFINE Motors Parameters------------------ + +const Int32 F1_MOTO_LLOADING_TX1 = 0x60000232; +const Int32 F1_MOTO_LLOADING_TX0 = 0x60000230; + +const Int32 F1_LS_LLOADMOTOR_UP = 0x0100 ; +const Int32 F1_LS_LLOADMOTOR_DN = 0x0200 ; +const Int32 F1_LS_LDANCER1_UP = 0x1000; +const Int32 F1_LS_LDANCER1_DN = 0x2000; +const Int32 F1_LS_LDANCER2_UP = 0x0400; +const Int32 F1_LS_LDANCER2_DN = 0x0800; +const Int32 F1_LS_LLOADRAM_LF = 0x0080; +const Int32 F1_LS_LLOADRAM_RT = 0x0040; + + +const Int32 F1_LDANCER1_ROTENC_MSB = 0x600001c2; +const Int32 F1_LDANCER1_ROTENC_LSB = 0x600001c0; +const Int32 F1_LDANCER1_ROTENC_TX = 0x600001ce; + +const Int32 F1_LDANCER2_ROTENC_MSB = 0x600001b2; +const Int32 F1_LDANCER2_ROTENC_LSB = 0x600001b0; +const Int32 F1_LDANCER2_ROTENC_TX = 0x600001be; diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Winder_Jig.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Winder_Jig.cs new file mode 100644 index 000000000..9c52ee205 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/Winder_Jig.cs @@ -0,0 +1,188 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + +const int Winder_UNDER_TEST=6; + +string [,] Units_status_Winder = new string[Winder_UNDER_TEST,2] { + {"Winder_Motor","Not Test"}, + {"Screw_Motor","Not Test"}, + {"LS_Screw_Right","Not Test"}, + {"LS_Screw_Left","Not Test"}, + {"Screw_Encoder","Not Test"}, + {"SW_Spool_Exist","Not Test"}, + }; + + +//-------------------------------------------------------------------------------- + +public Task<decimal> Winder_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (Winder_UNDER_TEST,Units_status_Winder); + + settext("Test_Winder_motor"); + Test_Winder_motor(); + settext("Test_Screw_LS_Motor_Encoder"); + Test_Screw_LS_Motor_Encoder (); + settext("Test_Pooler_Exis"); + Test_Pooler_Exist (); + + Status=write_to_file(SN,Location,Winder_UNDER_TEST,"Winder"); + settext("End Test"); + decimal result = 0; + + return result; + }); + return task; +} + +//------------------------------------------ +public int Test_Winder_motor () + +{ + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,WINDER_Motor, true, 500); //rotate Winder Motor. + stubManager.Write("Winder Motor rotate \n"); + DialogResult result = MessageBox.Show("Are Winder Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if (_cancellationTokenSource.Token.IsCancellationRequested) + { + _cancellationTokenSource.Token.ThrowIfCancellationRequested(); + throw new TaskCanceledException(); + return 0; + } + if(result == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("Winder Motor not rotate\n"); + } + else + { + Units_status[0,1]="Pass"; + stubManager.Write("Winder Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,WINDER_Motor,3); //stop motor + + return 0; +} + + +//-------------------------------------------- + int Test_Screw_LS_Motor_Encoder() +{ + UInt32 temp ; + Int32 Bit = 1; + + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,SCREW, false, 250); //rotate screw Motor out. + delay(1000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,SCREW,3); //stop motor + + DialogResult result2 = MessageBox.Show("Did screw Motor move ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("Screw Motor not move\n"); + return 0; + } + Units_status[1,1]="Pass"; + + stubManager.Write("Screw Motor rotate \n"); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,SCREW, true, 250); + stubManager.Write("Move screw in\n"); + + Bit = 1; + int i=0; + while ((Bit != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(F1_LS_03_Direct,0); + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,SCREW,3); //stop motor + + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[2,1]="Fail"; + stubManager.Write("LS_SCREW_RIGHT Not calibrate\n"); + return 0; + } + Units_status[2,1]="Pass"; + stubManager.Write("Move screw out\n"); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_SCREW_ROTENC_lsb, 0x0000); //clear encoder + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_SCREW_ROTENC_msb, 0x0000); //clear encoder + + Bit = 1; + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,SCREW, false, 250); + i=0; + while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec + { + Bit = GetBit(F1_LS_03_Direct,1); + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,SCREW,3); //stop motor + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result3 == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("LS_SCREW_LEFT Not calibrate\n"); + return 0; + } + Units_status[3,1]="Pass"; + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_SCREW_ROTENC_lsb); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_SCREW_ROTENC_msb); + + temp=(response.Value & 0xffff )+((response1.Value & 0xffff )<<16); + temp=temp&0x0fffffff; + temp= 0x4000000-temp; + stubManager.Write("Encoder positio:" +temp+"\n"); + + if ((temp>20000) && temp<28000) + Units_status[4,1]="Pass"; + else + Units_status[4,1]="Fail"; + + return 1; +} + //--------------------------------------- +int Test_Pooler_Exist() +{ + if ( (GetBit(F1_LS_03_Direct,11))==0) + { + Units_status[5,1]="Fail"; + return 0; + } + + DialogResult result2 = MessageBox.Show("Remove Spool"); + if ( (GetBit(F1_LS_03_Direct,11))!=0) + Units_status[5,1]="Fail"; + else + Units_status[5,1]="Pass"; + + return 0 ; + + +} + diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/location.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/location.cs new file mode 100644 index 000000000..11bf6556a --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/location.cs @@ -0,0 +1 @@ +string Location_str = "Hameshabev";
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/span.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/span.cs new file mode 100644 index 000000000..1b31dbb4e --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/span.cs @@ -0,0 +1,615 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +const int New_DyeHead_UNDER_TEST=47; +const Int32 MGNET_OPEN=0x420301; +const Int32 MGNET_EN=0x420280; +const Int32 MGNET_CLOSE=0x420300; +const Int32 MGNET_DIS=0x420200; +const Int32 ACTDIR_ON=0x460280; +const Int32 ACTDIR_OFF=0x460200; + +const Int32 ACTIN_ON=0x460308; +const Int32 ACTOUT_ON=0x460304; + +const Int32 ACTIN_OFF=0x46030C; +const Int32 ACTOUT_OFF=0x46030C; + + + +const Int32 LS_FRONT=0X460110; +const Int32 LS_REAR=0X460120; +const Int32 LS_UPPER=0X460140; +const Int32 LS_SPARE=0X460180; +const Int32 ACTIN_EN=0X460101; +const Int32 ACTOUT_EN=0X460102; + + + +string EEPROM_Header="Header_1 "; //16 characters + +int Head_Mux_Channel_ID = 4; //Head MUX channel + + +//float [] DyeHeadTemp = new float[6] ; + +string [,] Units_status_New_DyeHead = new string[New_DyeHead_UNDER_TEST,2] { + {"Pt100_Zone_1","Pass"}, //0 + {"Pt100_Zone_2","Pass"}, //1 + {"Pt100_Zone_3","Pass"}, //2 + {"Pt100_Zone_4","Pass"}, //3 + {"Pt100_Zone_5","Pass"}, //4 + {"Pt100_Zone_6","Pass"}, //5 + {"Pt100_Zone_7","Pass"}, //6 + {"Pt100_Zone_8","Pass"}, //7 + {"Pt100_Zone_9","Pass"}, //8 + {"Pt100_Zone_10","Pass"}, //9 + {"Pt100_Zone_11","Pass"}, //10 + {"Pt100_Zone_12","Pass"}, //11 + + {"Current_Zone_1","Pass"}, //12 + {"Current_Zone_2","Pass"}, //13 + {"Current_Zone_3","Pass"}, //14 + {"Current_Zone_4","Pass"}, //15 + {"Current_Zone_5","Pass"}, //16 + {"Current_Zone_6","Pass"}, //17 + {"Current_Zone_7","Pass"}, //18 + {"Current_Zone_8","Pass"}, //19 + {"Current_Zone_9","Pass"}, //20 + {"Current_Zone_10","Pass"}, //21 + {"Current_Zone_11","Pass"}, //22 + {"Current_Zone_12","Pass"}, //23 + + {"Break_Zone_1","Pass"}, //24 + {"Break_Zone_2","Pass"}, //25 + {"Break_Zone_3","Pass"}, //26 + {"Break_Zone_4","Pass"}, //27 + {"Break_Zone_5","Pass"}, //28 + {"Break_Zone_6","Pass"}, //29 + {"Break_Zone_7","Pass"}, //30 + {"Break_Zone_8","Pass"}, //31 + {"Break_Zone_9","Pass"}, //32 + {"Break_Zone_10","Pass"}, //33 + {"Break_Zone_11","Pass"}, //34 + {"Break_Zone_12","Pass"}, //35 + + {"Magnet ","Not Test"}, //36 + {"LS_REAR","Not Test"}, //37 + {"LS_FRONT","Not Test"}, //38 + {"DH_LID_Motor","Not Test"}, //39 + + {"EEPROM ","Pass"}, //40 + + {"ACTUATOR_IN","Not Test"}, //41 + {"LS_IN_UP","Not Test"}, //42 + {"LS_IN_DN","Not Test"}, //43 + {"ACTUATOR_OUT","Not Test"}, //44 + {"LS_OUT_UP","Not Test"}, //45 + {"LS_OUT_DN","Not Test"}, //46 + + + }; + + + +//-------------------------------------------------------------------------------- + +public Task<decimal> NewDyeHead_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (New_DyeHead_UNDER_TEST,Units_status_New_DyeHead); + + DialogResult result1 = MessageBox.Show("Make shure, Dyehead is not hot", "Warning",MessageBoxButtons.OKCancel); + if(result1 == DialogResult.Cancel) + { + stubManager.AppendToFile(File_Name1,"Dyehead is too hot \tFail"); + stubManager.Write("Dyehead is too hot \tFail\n"); + return 0 ; + } + else + { + +//------------------------------- start test ----------- + settext("Test Magnet Motor LS"); + Test_Magnet_Motor_LS_New_DyeHead(); + settext("Test heaters &pt100"); + Test_heaters_pt100 (); + settext("Test Head EEPROM"); + Test_Head_EEPROM(SN); + settext("Test Actuator In"); + Test_Actuator_in(); + settext("Test Actuator Out"); + Test_Actuator_out(); + Status=write_to_file(SN,Location,DyeHead_UNDER_TEST,"Dyehead"); + + settext("End Test"); + } + decimal result = 0; + + return result; + }); + return task; +} + +//------------------------------------------------------------- + int Test_Actuator_in() +{ + Int32 temp; + int i=0; + + DialogResult result = MessageBox.Show("Make shure, ACTUATOR-IN is down", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[41,1]="Fail"; + stubManager.Write("ACTUATOR-IN is Up\n"); + return 0; + } +//---------------------- move ACTUATOR-IN Up ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_ON); // DIR=1 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_ON); // act_in enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_OFF); // act_in disable + stubManager.Write("ACTUATOR-IN moving Up\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTIN_EN); // read ACTIN_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[41,1]="Fail"; + stubManager.Write("CTUATOR-IN is not moving Up\n"); + return 0; + } + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[42,1]="Fail"; + stubManager.Write("LS_IN_UP Not calibrate\n"); + return 0; + } + Units_status[41,1]="Pass"; + Units_status[42,1]="Pass"; +//---------------------- move ACTUATOR-IN Dn ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_OFF); // DIR=0 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_ON); // act_in enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_OFF); // act_in disable + stubManager.Write("ACTUATOR-IN moving Dn\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTIN_EN); // read ACTIN_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[41,1]="Fail"; + stubManager.Write("CTUATOR-IN is not moving Down\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[43,1]="Fail"; + stubManager.Write("LS_IN_Down Not calibrate\n"); + return 0; + } + Units_status[43,1]="Pass"; + return 0; + +} +//------------------------------------------------------------- + int Test_Actuator_out() +{ + Int32 temp; + int i=0; + + DialogResult result = MessageBox.Show("Make shure, ACTUATOR-OUT is down", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[44,1]="Fail"; + stubManager.Write("ACTUATOR-OUT is Up\n"); + return 0; + } +//---------------------- move ACTUATOR-OUT Up ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_ON); // DIR=1 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_ON); // act_OUT enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_OFF); // act_OUT disable + stubManager.Write("ACTUATOR-OUT moving Up\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTOUT_EN); // read ACTOUT_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[44,1]="Fail"; + stubManager.Write("CTUATOR-OUT is not moving Up\n"); + return 0; + } + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[45,1]="Fail"; + stubManager.Write("LS_OUT_UP Not calibrate\n"); + return 0; + } + Units_status[44,1]="Pass"; + Units_status[45,1]="Pass"; +//---------------------- move ACTUATOR-OUT Dn ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_OFF); // DIR=0 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_ON); // act_out enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_OFF); // act_out disable + stubManager.Write("ACTUATOR-OUT moving Dn\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTOUT_EN); // read ACTOUT_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[44,1]="Fail"; + stubManager.Write("CTUATOR-OUT is not moving Down\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[46,1]="Fail"; + stubManager.Write("LS_OUT_Down Not calibrate\n"); + return 0; + } + Units_status[46,1]="Pass"; + return 0; + +} + + + +//-------------------------------------------- + int Test_Magnet_Motor_LS_New_DyeHead() +{ + Int32 temp; + int i=0; +//---------------------- open Magnet ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_OPEN); // turn magnet on + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_EN); // magnet enable + stubManager.Write("Magnet is Open\n"); + delay(1000); +//---------------------- chekc Magnet is open ---------------------------- + temp=read_pio (LS_UPPER); // read LS_UPPER + if (temp != 0) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is close\n"); + return 0; + } + DialogResult result = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is close\n"); + return 0; + } +//---------------------- Move DyeingHead Lid Motor rear---------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, true, 250); + stubManager.Write("*** Open Lid Head \n"); + + temp = 0; + i=0; + while ((temp == 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (LS_REAR); // read LS_REAR + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + if(i == 200) + { + Units_status[37,1]="Fail"; + Units_status[39,1]="Fail"; + stubManager.Write("LS_REAR Not calibrate\n"); + return 0; + } + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[37,1]="Fail"; + Units_status[39,1]="Fail"; + stubManager.Write("LS_REAR Not calibrate\n"); + return 0; + } + Units_status[37,1]="Pass"; +//---------------------- Move DyeingHead Lid Motor front---------------------------- + stubManager.Write("*** Close Lid Head \n"); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, false, 250); + temp = 0; + i=0; + while ((temp == 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (LS_FRONT); // read LS_FRONT + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + if(i == 200) + { + Units_status[38,1]="Fail"; + stubManager.Write("LS_FRONT Not calibrate\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[38,1]="Fail"; + stubManager.Write("LS_FRONT Not calibrate\n"); + return 0; + } + Units_status[37,1]="Pass"; + Units_status[38,1]="Pass"; +//---------------------- Close Magnet ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_CLOSE); // turn magnet off + delay(2000); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_DIS); // magnet Disable + + stubManager.Write("Magnet is Close\n"); + delay(1000); +//---------------------- chekc Magnet is close ---------------------------- + temp=read_pio (LS_UPPER); // read LS_UPPER + if (temp == 0) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is open\n"); + return 0; + } + DialogResult result4 = MessageBox.Show("Make shure, Magnet is close", "Warning",MessageBoxButtons.OKCancel); + if(result4 == DialogResult.Cancel) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is open\n"); + return 0; + } + Units_status[36,1]="Pass"; + stubManager.Write("Magnet is close\n"); + return 0; +} + + +//------------------------------------ +public int Test_new_heaters_pt100() +{ + +// uint utemp=0; + Int32 temp=0; + float ftemp=0; + float ftemp1=0; + float current=0; + Double current_sense; + + for (Int32 i = 0; i < 12; i++) + { + Int32 tdly=10000; +//---------------------- get tempurature of heaters---------------------------- + temp= 12+i/2+(i%2)*8; //HZone_1=12 + //HZone_2=20 + //HZone_3=13 + //HZone_4=21 + //HZone_5=14 + //HZone_6=22 + //HZone_7=15 + //HZone_8=23 + //HZone_9=16 + //HZone_10=24 + //HZone_11=17 + //HZone_11=25 + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , temp); //get temperature from the buffer + ftemp = (float)response.TemperatureCMultBy100; + ftemp = ftemp / 100; + + if ((ftemp>50)|| (ftemp<15)) + { + Units_status[i,1]="Fail"; + tdly=1000; + + } + stubManager.Write("Zone-"+(i+1)+ "\t" + ftemp.ToString("F2")+"°C\n"); +//---------------------- get current of heaters ---------------------------- + var response1 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + i); // get current + current_sense=response1.Pressure; + if (current_sense>0.1) + { + Units_status[i+12,1]="Fail"; + } + stubManager.Write("current is "+(i+1)+ "\t" + current_sense +"\n"); +//---------------------- get Break of heaters ---------------------------- + var response2 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x440000 +(i/8)*0x100+(1<<(i&7))); // read break + temp = (Int32) (response2.Progress); + if ((temp & (1<<(i&7))) !=0) //if break ok + { + Units_status[i+24,1]="Fail"; + stubManager.Write("Break Zone "+(i+1)+ "\t is Off\n"); + } + else + { + stubManager.Write("Break Zone "+(i+1)+ "\t is Off\n"); + } +//---------------------- turn heater on ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x400200 +(i/8)*0x100+(1<<(i&7))); // turn heater on + stubManager.Write("Heater - "+(i+1)+ "\t is On\n"); + delay(2000); //delay 20 second +//---------------------- get current of heaters ---------------------------- + var response3 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + i); // get current + current_sense=response3.Pressure; + if ((current_sense<1.1) ||(current_sense>1.4) ) //if current not 1.25A + { + Units_status[i+12,1]="Fail"; + } + stubManager.Write("current is "+(i+1)+ "\t" + current_sense +"\n"); +//---------------------- get Break of heaters ---------------------------- + var response4 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x440000 +(i/8)*0x100+(1<<(i&7))); // read break + temp = (Int32) (response4.Progress); + if ((temp & (1<<(i&7))) !=0) //if break ok + { + Units_status[i+24,1]="Fail"; + stubManager.Write("Break Zone "+(i+1)+ "\t is Off\n"); + } + else + { + stubManager.Write("Break Zone "+(i+1)+ "\t is On\n"); + } + delay(tdly); //delay 20 second + temp= 12+i/2+(i%2)*8; + var response5 = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , temp); //get temperature from the buffer + ftemp1 = (float)response5.TemperatureCMultBy100; + ftemp1 = ftemp1 / 100; + + if (((ftemp1-ftemp)<5)|| ((ftemp1-ftemp)>35)) + { + Units_status[i,1]="Fail"; + } + stubManager.Write("Zone-"+(i+1)+ "after heating is \t" + ftemp1.ToString("F2")+"°C\n"); +//---------------------- turn heater off ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x400200 +(i/8)*0x100); // turn heater off + stubManager.Write("Heater - "+(i+1)+ "\t is Off\n"); + + } + return 0; +} + +Int32 read_pio(Int32 i2c_input) +{ + Int32 temp=0; + var response = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,i2c_input); // read break + temp = (Int32) (response.Progress); + temp =temp & (i2c_input& 0xff); //if break ok + return temp; +} +//end mati + + //enable_all_channel(); +public int Test_Head_EEPROM(string s_n) +{ + + enable_channel(Head_Mux_Channel_ID); // Chanel 0-7 => Disp0enser 0-7 + + Write_EEPROM(0xA0,s_n); + delay(20); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + + adc_set_for_read_ch(0xA0); + //Thread.Sleep(1); //Sleep for 10 milli. + Read_EEPROM(0xA0); + + delay(20); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + return 0; + +} + + + +int enable_channel(int Channel_ID) +{ + uint Const_temp = 0x01; + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID3; + stubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address; + + Const_temp = Const_temp << Channel_ID; + stubI2CWriteBytesRequest.BytesTWrite.Add(Const_temp); + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int Write_EEPROM (uint I2C_Slave_Add,string s_n ) +{ + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID3; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + //-------------------------------------------------------------- + char[] characters = EEPROM_Header.ToCharArray(); + + for (int i=0;i<16;i++) + { + stubI2CWriteBytesRequest.BytesTWrite.Add(characters[i]); //add header + } + characters = s_n.ToCharArray(); + + for (int i=0;i<16;i++) + { + stubI2CWriteBytesRequest.BytesTWrite.Add(characters[i]); //add s/n + } + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int Read_EEPROM(uint I2C_Slave_Add) +{ + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID3; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add + 1; + stubI2CReadBytesRequest.NumberOfBytesToRead = 16; // Number of header bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + char[] characters = EEPROM_Header.ToCharArray(); + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + if (characters[i]!=response1.ReadBytes[i]); + Units_status[40,1]="Fail"; + } + stubManager.Write("EEprom "+ Units_status[40,1]+"\n"); + + return 1; +} diff --git a/Software/Stubs Collection/stubs/Scripts/Jig_Tester/stapele_span.cs b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/stapele_span.cs new file mode 100644 index 000000000..656786ad7 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Jig_Tester/stapele_span.cs @@ -0,0 +1,631 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +const int New_Stapele_Span_UNDER_TEST=47; +const Int32 MGNET_OPEN=0x420301; +const Int32 MGNET_EN=0x420280; +const Int32 MGNET_CLOSE=0x420300; +const Int32 MGNET_DIS=0x420200; +const Int32 ACTDIR_ON=0x460280; +const Int32 ACTDIR_OFF=0x460200; + +const Int32 ACTIN_ON=0x460308; +const Int32 ACTOUT_ON=0x460304; + +const Int32 ACTIN_OFF=0x46030C; +const Int32 ACTOUT_OFF=0x46030C; + + + +const Int32 LS_FRONT=0X460110; +const Int32 LS_REAR=0X460120; +const Int32 LS_UPPER=0X460140; +const Int32 LS_SPARE=0X460180; +const Int32 ACTIN_EN=0X460101; +const Int32 ACTOUT_EN=0X460102; + + + +string EEPROM_Header="Header_1 "; //16 characters + +int Head_Mux_Channel_ID = 4; //Head MUX channel + + +//float [] Stapele_SpanTemp = new float[6] ; + +string [,] Units_status_New_Stapele_Span = new string[New_Stapele_Span_UNDER_TEST,2] { + {"Pt100_HTIN","Pass"}, //0 + {"Pt100_HTOUT","Pass"}, //1 + + {"Current_HTIN1","Pass"}, //2 + {"Current_HTIN2","Pass"}, //3 + {"Current_HTIN3","Pass"}, //4 + {"Current_HTIN4","Pass"}, //5 + {"Current_HTOUT1","Pass"}, //6 + {"Current_HTOUT2","Pass"}, //7 + {"Current_HTOUT3","Pass"}, //8 + {"Current_HTOUT4","Pass"}, //9 + + {"Break_HTIN1","Pass"}, //10 + {"Break_HTIN2","Pass"}, //11 + {"Break_HTIN3","Pass"}, //12 + {"Break_HTIN4","Pass"}, //13 + {"Break_HTOUT1","Pass"}, //14 + {"Break_HTOUT2","Pass"}, //15 + {"Break_HTOUT3","Pass"}, //16 + {"Break_HTOUT4","Pass"}, //17 + + {"Fan_in","Not Test"}, //18 + {"Fan_out","Not Test"}, //19 + + + + {"Magnet ","Not Test"}, //18 + {"LS_REAR","Not Test"}, //19 + {"LS_FRONT","Not Test"}, //2 + {"DH_LID_Motor","Not Test"}, //39 + + {"EEPROM ","Pass"}, //40 + + {"ACTUATOR_IN","Not Test"}, //41 + {"LS_IN_UP","Not Test"}, //42 + {"LS_IN_DN","Not Test"}, //43 + {"ACTUATOR_OUT","Not Test"}, //44 + {"LS_OUT_UP","Not Test"}, //45 + {"LS_OUT_DN","Not Test"}, //46 + + + }; + + + +//-------------------------------------------------------------------------------- + +public Task<decimal> NewStapele_Span_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location) +{ + Task<decimal> task = null; + // Start a task and return it + task = Task.Run(() => + { + stubManager.Write("S/N:" +SN+ "\n"); + stubManager.Write("Location:" +Location+ "\n"); + + copy_table (New_Stapele_Span_UNDER_TEST,Units_status_New_Stapele_Span); + + DialogResult result1 = MessageBox.Show("Make shure, Stapele_Span is not hot", "Warning",MessageBoxButtons.OKCancel); + if(result1 == DialogResult.Cancel) + { + stubManager.AppendToFile(File_Name1,"Stapele_Span is too hot \tFail"); + stubManager.Write("Stapele_Span is too hot \tFail\n"); + return 0 ; + } + else + { + +//------------------------------- start test ----------- + settext("Test Magnet Motor LS"); + Test_Magnet_Motor_LS_New_Stapele_Span(); + settext("Test blowers &pt100"); + Test_blowers_pt100 (); + settext("Test Head EEPROM"); + Test_Head_EEPROM(SN); + settext("Test Actuator In"); + Test_Actuator_in(); + settext("Test Actuator Out"); + Test_Actuator_out(); + Status=write_to_file(SN,Location,Stapele_Span_UNDER_TEST,"Stapele_Span"); + + settext("End Test"); + } + decimal result = 0; + + return result; + }); + return task; +} + +//------------------------------------------------------------- + int Test_Actuator_in() +{ + Int32 temp; + int i=0; + + DialogResult result = MessageBox.Show("Make shure, ACTUATOR-IN is down", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[41,1]="Fail"; + stubManager.Write("ACTUATOR-IN is Up\n"); + return 0; + } +//---------------------- move ACTUATOR-IN Up ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_ON); // DIR=1 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_ON); // act_in enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_OFF); // act_in disable + stubManager.Write("ACTUATOR-IN moving Up\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTIN_EN); // read ACTIN_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[41,1]="Fail"; + stubManager.Write("CTUATOR-IN is not moving Up\n"); + return 0; + } + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[42,1]="Fail"; + stubManager.Write("LS_IN_UP Not calibrate\n"); + return 0; + } + Units_status[41,1]="Pass"; + Units_status[42,1]="Pass"; +//---------------------- move ACTUATOR-IN Dn ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_OFF); // DIR=0 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_ON); // act_in enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTIN_OFF); // act_in disable + stubManager.Write("ACTUATOR-IN moving Dn\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTIN_EN); // read ACTIN_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[41,1]="Fail"; + stubManager.Write("CTUATOR-IN is not moving Down\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[43,1]="Fail"; + stubManager.Write("LS_IN_Down Not calibrate\n"); + return 0; + } + Units_status[43,1]="Pass"; + return 0; + +} +//------------------------------------------------------------- + int Test_Actuator_out() +{ + Int32 temp; + int i=0; + + DialogResult result = MessageBox.Show("Make shure, ACTUATOR-OUT is down", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[44,1]="Fail"; + stubManager.Write("ACTUATOR-OUT is Up\n"); + return 0; + } +//---------------------- move ACTUATOR-OUT Up ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_ON); // DIR=1 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_ON); // act_OUT enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_OFF); // act_OUT disable + stubManager.Write("ACTUATOR-OUT moving Up\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTOUT_EN); // read ACTOUT_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[44,1]="Fail"; + stubManager.Write("CTUATOR-OUT is not moving Up\n"); + return 0; + } + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[45,1]="Fail"; + stubManager.Write("LS_OUT_UP Not calibrate\n"); + return 0; + } + Units_status[44,1]="Pass"; + Units_status[45,1]="Pass"; +//---------------------- move ACTUATOR-OUT Dn ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTDIR_OFF); // DIR=0 + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_ON); // act_out enable + delay(10); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,ACTOUT_OFF); // act_out disable + stubManager.Write("ACTUATOR-OUT moving Dn\n"); + + temp = 1; + i=0; + while ((temp != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (ACTOUT_EN); // read ACTOUT_EN + delay(50); + i++; + } + + if(i == 200) + { + Units_status[44,1]="Fail"; + stubManager.Write("CTUATOR-OUT is not moving Down\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[46,1]="Fail"; + stubManager.Write("LS_OUT_Down Not calibrate\n"); + return 0; + } + Units_status[46,1]="Pass"; + return 0; + +} + + + +//-------------------------------------------- + int Test_Magnet_Motor_LS_New_Stapele_Span() +{ + Int32 temp; + int i=0; +//---------------------- open Magnet ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_OPEN); // turn magnet on + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_EN); // magnet enable + stubManager.Write("Magnet is Open\n"); + delay(1000); +//---------------------- chekc Magnet is open ---------------------------- + temp=read_pio (LS_UPPER); // read LS_UPPER + if (temp != 0) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is close\n"); + return 0; + } + DialogResult result = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel); + if(result == DialogResult.Cancel) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is close\n"); + return 0; + } +//---------------------- Move DyeingHead Lid Motor rear---------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, true, 250); + stubManager.Write("*** Open Lid Head \n"); + + temp = 0; + i=0; + while ((temp == 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (LS_REAR); // read LS_REAR + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + if(i == 200) + { + Units_status[37,1]="Fail"; + Units_status[39,1]="Fail"; + stubManager.Write("LS_REAR Not calibrate\n"); + return 0; + } + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result2 == DialogResult.Cancel) + { + Units_status[37,1]="Fail"; + Units_status[39,1]="Fail"; + stubManager.Write("LS_REAR Not calibrate\n"); + return 0; + } + Units_status[37,1]="Pass"; +//---------------------- Move DyeingHead Lid Motor front---------------------------- + stubManager.Write("*** Close Lid Head \n"); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, false, 250); + temp = 0; + i=0; + while ((temp == 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec + { + temp=read_pio (LS_FRONT); // read LS_FRONT + delay(50); + i++; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor + if(i == 200) + { + Units_status[38,1]="Fail"; + stubManager.Write("LS_FRONT Not calibrate\n"); + return 0; + } + + DialogResult result3 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel); + if(result3 == DialogResult.Cancel) + { + Units_status[38,1]="Fail"; + stubManager.Write("LS_FRONT Not calibrate\n"); + return 0; + } + Units_status[37,1]="Pass"; + Units_status[38,1]="Pass"; +//---------------------- Close Magnet ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_CLOSE); // turn magnet off + delay(2000); + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,MGNET_DIS); // magnet Disable + + stubManager.Write("Magnet is Close\n"); + delay(1000); +//---------------------- chekc Magnet is close ---------------------------- + temp=read_pio (LS_UPPER); // read LS_UPPER + if (temp == 0) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is open\n"); + return 0; + } + DialogResult result4 = MessageBox.Show("Make shure, Magnet is close", "Warning",MessageBoxButtons.OKCancel); + if(result4 == DialogResult.Cancel) + { + Units_status[36,1]="Fail"; + stubManager.Write("Magnet is open\n"); + return 0; + } + Units_status[36,1]="Pass"; + stubManager.Write("Magnet is close\n"); + return 0; +} + + +//------------------------------------ +public int Test_blowers_pt100_fan() +{ + +// uint utemp=0; + Int32 temp=0; + float ftemp=0; + float ftemp1=0; + float current=0; + Double current_sense; + + for (Int32 i = 0; i < 2; i++) + { + //---------------------- check fans---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0xfac0+i, 0xff);//Fan Click Head Card , Fan 1 Setting - 0xFF Full PWM 0x80 = 50% FF = 100% 0 - STOP + delay(2000); //delay 2 second + + var response5 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0xfac0+i, 0xff);//Fan Click Head Card , Fan 1 Setting - 0xFF Full PWM 0x80 = 50% FF = 100% 0 - STOP + temp = (Int32) (response.Progress); + temp =temp & (response.Progress & 0xffff); // + if (temp>0xEC0) + { + Units_status[18+i,1]="Fail"; + return 0; + } + Units_status[18+i,1]="Pass"; + + //---------------------- get tempurature of heaters---------------------------- + if (i==0) + temp=18; + else + temp=16; + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , 0x8000 +temp); //get temperature from the buffer + ftemp = (float)response.TemperatureCMultBy100; + ftemp = ftemp / 100; + + if ((ftemp>50)|| (ftemp<15)) + { + Units_status[i,1]="Fail"; + tdly=1000; + + } + stubManager.Write("Hit-"+(i+1)+ "\t" + ftemp.ToString("F2")+"°C\n"); + + for (Int32 j = 0; j < 4; j++) + { + Int32 tdly=10000; + //---------------------- get current of heaters ---------------------------- + var response1 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 +12 + 4*i +j); // get current + current_sense=2*response1.Pressure; + if (current_sense>0.1) + { + Units_status[2+j+4*i,1]="Fail"; + } + stubManager.Write("current is "+(j+1+4*i )+ "\t" + current_sense +"\n"); + //---------------------- get Break of heaters ---------------------------- + var response2 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x440000 +0x20000*i +(1-i)*0x100); // read break + temp = (Int32) (response2.Progress); + if ((temp & (1<<((1-i)*4+j))) !=0) //if break ok + { + Units_status[10+j+4*i,1]="Fail"; + stubManager.Write("Break Zone "+(i*4+j+1)+ "\t is Off\n"); + } + else + { + stubManager.Write("Break Zone "+(i*4+j+1)+ "\t is On\n"); + } + //---------------------- turn heater on ---------------------------- + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x400300 +0x1fff00*i +(1<<((1-i)*4+j))); // turn heater on + stubManager.Write("Heater - "+(i*4+j+1)+ "\t is On\n"); + delay(2000); //delay 2 second + //---------------------- get current of heaters ---------------------------- + var response3 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + +12 + 4*i +j); // get current + current_sense=2*response3.Pressure; + if ((current_sense<1.1) ||(current_sense>1.4) ) //if current not 2.5A + { + Units_status[2+j+4*i,1]="Fail"; + } + stubManager.Write("current is "+(j+1+4*i )+"\t" + current_sense +"\n"); + //---------------------- get Break of heaters ---------------------------- + var response4 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x440000 +0x20000*i +(1-i)*0x100); // read break + temp = (Int32) (response4.Progress); + if ((temp & (1<<((1-i)*4+j))) !=0) //if break ok + { + Units_status[10+j+4*i,1]="Fail"; + stubManager.Write("Break Zone "+(i*4+j+1)+ "\t is Off\n"); + } + else + { + stubManager.Write("Break Zone "+(i*4+j+1)+ "\t is On\n"); + } + + delay(tdly); //delay 20 second + //---------------------- turn heater off ---------------------------- + + stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x400300 +0x1fff00*i ); // turn heater on + stubManager.Write("Heater - "+(i*4+j+1)+ "\t is Off\n"); + } + //---------------------- get tempurature of heaters---------------------------- + if (i==0) + temp=18; + else + temp=16; + var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , 0x8000 +temp); //get temperature from the buffer + ftemp1 = (float)response.TemperatureCMultBy100; + ftemp1 = ftemp1 / 100; + + if (((ftemp1-ftemp)<5)|| ((ftemp1-ftemp)>35)) + { + Units_status[i,1]="Fail"; + } + stubManager.Write("Zone-"+(i+1)+ "after heating is \t" + ftemp1.ToString("F2")+"°C\n"); + + //---------------------- check fan off---------------------------- + + stubManager.Run<ProgressResponse>("ProgressRequest" ,0xfac0+i, 0);//Fan Click Head Card , Fan 1 Setting - 0xFF Full PWM 0x80 = 50% FF = 100% 0 - STOP + delay(2000); //delay 2 second + var response6 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0xfac0+i, 0);//Fan Click Head Card , Fan 1 Setting - 0xFF Full PWM 0x80 = 50% FF = 100% 0 - STOP + temp = (Int32) (response6.Progress); + temp =temp & (response.Progress & 0xffff); // + if (temp<0x0xFF00) + { + Units_status[18+i,1]="Fail"; + return 0; + } + + } + return 0; +} + +Int32 read_pio(Int32 i2c_input) +{ + Int32 temp=0; + var response = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,i2c_input); // read break + temp = (Int32) (response.Progress); + temp =temp & (i2c_input& 0xff); //if break ok + return temp; +} +//end mati + + //enable_all_channel(); +public int Test_Head_EEPROM(string s_n) +{ + + enable_channel(Head_Mux_Channel_ID); // Chanel 0-7 => Disp0enser 0-7 + + Write_EEPROM(0xA0,s_n); + delay(20); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + + adc_set_for_read_ch(0xA0); + //Thread.Sleep(1); //Sleep for 10 milli. + Read_EEPROM(0xA0); + + delay(20); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + return 0; + +} + + + +int enable_channel(int Channel_ID) +{ + uint Const_temp = 0x01; + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID3; + stubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address; + + Const_temp = Const_temp << Channel_ID; + stubI2CWriteBytesRequest.BytesTWrite.Add(Const_temp); + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int Write_EEPROM (uint I2C_Slave_Add,string s_n ) +{ + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID3; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + //-------------------------------------------------------------- + char[] characters = EEPROM_Header.ToCharArray(); + + for (int i=0;i<16;i++) + { + stubI2CWriteBytesRequest.BytesTWrite.Add(characters[i]); //add header + } + characters = s_n.ToCharArray(); + + for (int i=0;i<16;i++) + { + stubI2CWriteBytesRequest.BytesTWrite.Add(characters[i]); //add s/n + } + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int Read_EEPROM(uint I2C_Slave_Add) +{ + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID3; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add + 1; + stubI2CReadBytesRequest.NumberOfBytesToRead = 16; // Number of header bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + char[] characters = EEPROM_Header.ToCharArray(); + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + if (characters[i]!=response1.ReadBytes[i]); + Units_status[40,1]="Fail"; + } + stubManager.Write("EEprom "+ Units_status[40,1]+"\n"); + + return 1; +} diff --git a/Software/Stubs Collection/stubs/Scripts/Moshe Copy Files.exe b/Software/Stubs Collection/stubs/Scripts/Moshe Copy Files.exe Binary files differnew file mode 100644 index 000000000..428ce300b --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Moshe Copy Files.exe diff --git a/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing.cs b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing.cs index 7e0d1ae38..6221ff388 100644 --- a/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing.cs +++ b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing.cs @@ -42,58 +42,6 @@ const Int32 x_GET_PARAM = 0x20; //------------------------------- const Int32 Max_Motor_ID = 25; - - -string[] Motor_ID = new string[30]; - - -Motor_ID[0] ="DH_CLEANHEAD "; -Motor_ID[1] ="DH_CLEANMECH "; -Motor_ID[2] ="DH_LID "; -Motor_ID[3] ="DRYER_DRIVING"; -Motor_ID[4] ="DRYER_LID "; -Motor_ID[5] ="DRYER_LOADARM"; -Motor_ID[6] ="DISPENCER_1 "; -Motor_ID[7] ="DISPENCER_2 "; -Motor_ID[8] ="DISPENCER_3 "; -Motor_ID[9] ="DISPENCER_4 "; -Motor_ID[10]="DISPENCER_5 "; -Motor_ID[11]="DISPENCER_6 "; -Motor_ID[12]="DISPENCER_7 "; -Motor_ID[13]="DISPENCER_8 "; -Motor_ID[14]="SCREW "; -Motor_ID[15]="WINDER "; -Motor_ID[16]="LDANCER1 "; -Motor_ID[17]="LDANCER2 "; -Motor_ID[18]="LDRIVING "; -Motor_ID[19]="LLODING "; -Motor_ID[20]="LPIVOT "; -Motor_ID[21]="RDANCER "; -Motor_ID[22]="RDRIVING "; -Motor_ID[23]="RLOADARM "; -Motor_ID[24]="RLODING "; -Motor_ID[25]="SPARE1_1 "; -Motor_ID[26]="SPARE1_2 "; -Motor_ID[27]="SPARE2_1 "; -Motor_ID[28]="SPARE2_2 "; -Motor_ID[29]="SPARE3 "; - - - - - - - - - - - - - - - - - Int32 i = 12; // to run only for specific motor public void OnExecute(StubManager stubManager) @@ -103,14 +51,11 @@ public void OnExecute(StubManager stubManager) if((i%8 ==0) ) { - stubManager.Write("\n\n"); - stubManager.Write("MoTor\t\t\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKVAL_HOLD\tKVAL_RUN\tKVAL_ACC\tKVAL_DEC\tOCD_TH\t\tSTALL_TH\tCONFIG\t\tFS_SPD\t\tADC_OUT\tDriver_Type\n"); - stubManager.Write("------\t\t\t--------\t--------\t----------\t---\t\t---\t\t---------\t--------\t--------\t--------\t------\t\t--------\t------\t\t------\t\t------\t\t------\n"); + stubManager.Write("MoTor\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKVAL_HOLD\tKVAL_RUN\tKVAL_ACC\tKVAL_DEC\tOCD_TH\t\tSTALL_TH\tCONFIG\t\tFS_SPD\t\tADC_OUT\n"); + stubManager.Write("------\t--------\t--------\t----------\t---\t\t---\t\t---------\t--------\t--------\t--------\t------\t\t--------\t------\t\t------\t\t------\n"); } - //stubManager.Write(i); - - stubManager.Write(Motor_ID[i]); - stubManager.Write("\t\t"); + stubManager.Write(i); + stubManager.Write("\t"); var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MIN_SPEED)<<16, 0, 0); stubManager.WriteHex(response.RecivedData,4); @@ -166,50 +111,8 @@ public void OnExecute(StubManager stubManager) response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); stubManager.WriteHex(response.RecivedData,4); - if( response.RecivedData > 12 ) - stubManager.Write("\t\tVolage_Driver"); - else if ( response.RecivedData > 8 ) - stubManager.Write("\t\tCurrent_Driver"); - else - stubManager.Write("\t\tNo_Driver"); - - stubManager.Write("\n\n"); } - - stubManager.Write("MoTor\t\t\tINT_SPD\tST_SLP\t\tSLP_ACC\tSLP_DEC\tSTATUS\n"); - stubManager.Write("-----\t\t\t-------\t------\t\t-------\t--------\t-----\n"); - - for (i = 0; i < Max_Motor_ID; i++) - { - stubManager.Write(Motor_ID[i]); - -// stubManager.Write(i); - stubManager.Write("\t\t"); - - var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_INT_SPD)<<16, 0, 0); - stubManager.WriteHex(response.RecivedData,4); - stubManager.Write("\t\t"); - - response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ST_SLP)<<8, 0, 0); - stubManager.WriteHex(response.RecivedData,4); - stubManager.Write("\t\t"); - - response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_ACC)<<8, 0, 0); - stubManager.WriteHex(response.RecivedData,4); - stubManager.Write("\t\t"); - - response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_DEC)<<8, 0, 0); - stubManager.WriteHex(response.RecivedData,4); - stubManager.Write("\t\t"); - - response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STATUS)<<16, 0, 0); - stubManager.WriteHex(response.RecivedData,4); - stubManager.Write("\n\n"); - - - - } }
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing1.cs b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing1.cs new file mode 100644 index 000000000..6221ff388 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing1.cs @@ -0,0 +1,118 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//unmark Auto logging ! + +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_ACC = 0x05; +const Int32 x_DEC = 0x06; +const Int32 x_MAX_SPEED = 0x07; +const Int32 x_MIN_SPEED = 0x08; +const Int32 x_FS_SPD = 0x15; +const Int32 x_KVAL_HOLD = 0x09; +const Int32 x_KVAL_RUN = 0x0A; +const Int32 x_KVAL_ACC = 0x0B; +const Int32 x_KVAL_DEC = 0x0C; +const Int32 x_INT_SPD = 0x0D; +const Int32 x_ST_SLP = 0x0E; +const Int32 x_FN_SLP_ACC = 0x0F; +const Int32 x_FN_SLP_DEC = 0x10; +const Int32 x_K_THERM = 0x11; +const Int32 x_ADC_OUT = 0x12; +const Int32 x_OCD_TH = 0x13; +const Int32 x_STALL_TH = 0x14; +const Int32 x_STEP_MODE = 0x16; +const Int32 x_ALARM_EN = 0x17; +const Int32 x_CONFIG = 0x18; +const Int32 x_STATUS = 0x19; +//------------------------------- +const Int32 x_GET_PARAM = 0x20; +//------------------------------- +const Int32 Max_Motor_ID = 25; + +Int32 i = 12; // to run only for specific motor + +public void OnExecute(StubManager stubManager) +{ + for (i = 0; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("MoTor\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKVAL_HOLD\tKVAL_RUN\tKVAL_ACC\tKVAL_DEC\tOCD_TH\t\tSTALL_TH\tCONFIG\t\tFS_SPD\t\tADC_OUT\n"); + stubManager.Write("------\t--------\t--------\t----------\t---\t\t---\t\t---------\t--------\t--------\t--------\t------\t\t--------\t------\t\t------\t\t------\n"); + } + stubManager.Write(i); + stubManager.Write("\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MIN_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MAX_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); stubManager.Write("\t"); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ACC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_DEC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_HOLD)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_RUN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_OCD_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STALL_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FS_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + + } + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing2.cs b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing2.cs new file mode 100644 index 000000000..09d22dea9 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing2.cs @@ -0,0 +1,233 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//unmark Auto logging ! + +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_ACC = 0x05; +const Int32 x_DEC = 0x06; +const Int32 x_MAX_SPEED = 0x07; +const Int32 x_MIN_SPEED = 0x08; +const Int32 x_FS_SPD = 0x15; +const Int32 x_KVAL_HOLD = 0x09; +const Int32 x_KVAL_RUN = 0x0A; +const Int32 x_KVAL_ACC = 0x0B; +const Int32 x_KVAL_DEC = 0x0C; +const Int32 x_INT_SPD = 0x0D; +const Int32 x_ST_SLP = 0x0E; +const Int32 x_FN_SLP_ACC = 0x0F; +const Int32 x_FN_SLP_DEC = 0x10; +const Int32 x_K_THERM = 0x11; +const Int32 x_ADC_OUT = 0x12; +const Int32 x_OCD_TH = 0x13; +const Int32 x_STALL_TH = 0x14; +const Int32 x_STEP_MODE = 0x16; +const Int32 x_ALARM_EN = 0x17; +const Int32 x_CONFIG = 0x18; +const Int32 x_STATUS = 0x19; +//------------------------------- +const Int32 x_GET_PARAM = 0x20; +//------------------------------- +const Int32 Max_Motor_ID = 25; + + + +string[] Motor_ID = new string[30]; + + +Motor_ID[0] ="DH_CLEANHEAD "; +Motor_ID[1] ="DH_CLEANMECH "; +Motor_ID[2] ="DH_LID "; +Motor_ID[3] ="DRYER_DRIVING"; +Motor_ID[4] ="DRYER_LID "; +Motor_ID[5] ="DRYER_LOADARM"; +Motor_ID[6] ="DISPENCER_1 "; +Motor_ID[7] ="DISPENCER_2 "; +Motor_ID[8] ="DISPENCER_3 "; +Motor_ID[9] ="DISPENCER_4 "; +Motor_ID[10]="DISPENCER_5 "; +Motor_ID[11]="DISPENCER_6 "; +Motor_ID[12]="DISPENCER_7 "; +Motor_ID[13]="DISPENCER_8 "; +Motor_ID[14]="SCREW "; +Motor_ID[15]="WINDER "; +Motor_ID[16]="LDANCER1 "; +Motor_ID[17]="LDANCER2 "; +Motor_ID[18]="LDRIVING "; +Motor_ID[19]="LLODING "; +Motor_ID[20]="LPIVOT "; +Motor_ID[21]="RDANCER "; +Motor_ID[22]="RDRIVING "; +Motor_ID[23]="RLOADARM "; +Motor_ID[24]="RLODING "; +Motor_ID[25]="SPARE1_1 "; +Motor_ID[26]="SPARE1_2 "; +Motor_ID[27]="SPARE2_1 "; +Motor_ID[28]="SPARE2_2 "; +Motor_ID[29]="SPARE3 "; + + + + + + + + + + + + + + + + + +Int32 i = 12; // to run only for specific motor + +public void OnExecute(StubManager stubManager) +{ + +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000380 , 0x06b9); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000390 , 0x003f); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000550 , 0x0003); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000b80 , 0x001f); + + + + + + + + + + + + for (i = 0; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + stubManager.Write("MoTor\t\t\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKVAL_HOLD\tKVAL_RUN\tKVAL_ACC\tKVAL_DEC\tOCD_TH\t\tSTALL_TH\tCONFIG\t\tFS_SPD\t\tADC_OUT\tDriver_Type\n"); + stubManager.Write("------\t\t\t--------\t--------\t----------\t---\t\t---\t\t---------\t--------\t--------\t--------\t------\t\t--------\t------\t\t------\t\t------\t\t------\n"); + } + //stubManager.Write(i); + + stubManager.Write(Motor_ID[i]); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MIN_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MAX_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); stubManager.Write("\t"); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ACC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_DEC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_HOLD)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_RUN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_OCD_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STALL_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FS_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + if( response.RecivedData > 0x15 ) + stubManager.Write("\t\tDual_Driver"); + else if ( response.RecivedData > 0x0b) + stubManager.Write("\t\tVolage_Driver"); + else if ( response.RecivedData > 8 ) + stubManager.Write("\t\tCurrent_Driver"); + else + stubManager.Write("\t\tNo_Driver"); + + + stubManager.Write("\n\n"); + + } + + stubManager.Write("MoTor\t\t\tINT_SPD\tST_SLP\t\tSLP_ACC\tSLP_DEC\tSTATUS\n"); + stubManager.Write("-----\t\t\t-------\t------\t\t-------\t--------\t-----\n"); + + for (i = 0; i < Max_Motor_ID; i++) + { + stubManager.Write(Motor_ID[i]); + +// stubManager.Write(i); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_INT_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ST_SLP)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + + + + } + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing3.cs b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing3.cs new file mode 100644 index 000000000..73042af54 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing3.cs @@ -0,0 +1,261 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//unmark Auto logging ! + +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_ACC = 0x05; +const Int32 x_DEC = 0x06; +const Int32 x_MAX_SPEED = 0x07; +const Int32 x_MIN_SPEED = 0x08; +const Int32 x_FS_SPD = 0x15; +const Int32 x_KVAL_HOLD = 0x09; +const Int32 x_KVAL_RUN = 0x0A; +const Int32 x_KVAL_ACC = 0x0B; +const Int32 x_KVAL_DEC = 0x0C; +const Int32 x_INT_SPD = 0x0D; +const Int32 x_ST_SLP = 0x0E; +const Int32 x_FN_SLP_ACC = 0x0F; +const Int32 x_FN_SLP_DEC = 0x10; +const Int32 x_K_THERM = 0x11; +const Int32 x_ADC_OUT = 0x12; +const Int32 x_OCD_TH = 0x13; +const Int32 x_STALL_TH = 0x14; +const Int32 x_STEP_MODE = 0x16; +const Int32 x_ALARM_EN = 0x17; +const Int32 x_CONFIG = 0x18; +const Int32 x_STATUS = 0x19; +//------------------------------- +const Int32 x_GET_PARAM = 0x20; +//------------------------------- +const Int32 Max_Motor_ID = 25; + + + +string[] Motor_ID = new string[30]; + + +Motor_ID[0] ="DH_CLEANHEAD "; +Motor_ID[1] ="DH_CLEANMECH "; +Motor_ID[2] ="DH_LID "; +Motor_ID[3] ="DRYER_DRIVING"; +Motor_ID[4] ="DRYER_LID "; +Motor_ID[5] ="DRYER_LOADARM"; +Motor_ID[6] ="DISPENCER_1 "; +Motor_ID[7] ="DISPENCER_2 "; +Motor_ID[8] ="DISPENCER_3 "; +Motor_ID[9] ="DISPENCER_4 "; +Motor_ID[10]="DISPENCER_5 "; +Motor_ID[11]="DISPENCER_6 "; +Motor_ID[12]="DISPENCER_7 "; +Motor_ID[13]="DISPENCER_8 "; +Motor_ID[14]="SCREW "; +Motor_ID[15]="WINDER "; +Motor_ID[16]="LDANCER1 "; +Motor_ID[17]="LDANCER2 "; +Motor_ID[18]="LDRIVING "; +Motor_ID[19]="LLODING "; +Motor_ID[20]="LPIVOT "; +Motor_ID[21]="RDANCER "; +Motor_ID[22]="RDRIVING "; +Motor_ID[23]="RLOADARM "; +Motor_ID[24]="RLODING "; +Motor_ID[25]="SPARE1_1 "; +Motor_ID[26]="SPARE1_2 "; +Motor_ID[27]="SPARE2_1 "; +Motor_ID[28]="SPARE2_2 "; +Motor_ID[29]="SPARE3 "; + + + + + + + + + + + + + + + + + +Int32 i = 12; // to run only for specific motor + +public void OnExecute(StubManager stubManager) +{ + +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000380 , 0x06b9); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000390 , 0x003f); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000550 , 0x0003); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000b80 , 0x001f); + + + + + + + + + + + + for (i = 0; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + stubManager.Write("MoTor\t\t\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKVAL_HOLD\tKVAL_RUN\tKVAL_ACC\tKVAL_DEC\tOCD_TH\t\tSTALL_TH\tCONFIG\t\tFS_SPD\t\tADC_OUT\tDriver_Type\n"); + stubManager.Write("------\t\t\t--------\t--------\t----------\t---\t\t---\t\t---------\t--------\t--------\t--------\t------\t\t--------\t------\t\t------\t\t------\t\t------\n"); + } + //stubManager.Write(i); + + stubManager.Write(Motor_ID[i]); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MIN_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MAX_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); stubManager.Write("\t"); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ACC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_DEC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_HOLD)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_RUN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_OCD_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STALL_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FS_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + if( response.RecivedData > 0x15 ) + stubManager.Write("\t\tDual_Driver"); + else if ( response.RecivedData > 0x0b) + stubManager.Write("\t\tVolage_Driver"); + else if ( response.RecivedData > 8 ) + stubManager.Write("\t\tCurrent_Driver"); + else + stubManager.Write("\t\tNo_Driver"); + + + stubManager.Write("\n\n"); + + } + + stubManager.Write("MoTor\t\t\tINT_SPD\tST_SLP\t\tSLP_ACC\tSLP_DEC\tSTATUS\n"); + stubManager.Write("-----\t\t\t-------\t------\t\t-------\t--------\t-----\n"); + + for (i = 0; i < Max_Motor_ID; i++) + { + stubManager.Write(Motor_ID[i]); + +// stubManager.Write(i); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_INT_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ST_SLP)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + + + + } + + stubManager.Write("--------------- New Driver POWERSTEP01 ---------------\n\n"); + stubManager.Write("MoTor\tPS01_CONFIG\t\tPS01_STATUS\t\tPS01_GATECFG1\t\tPS01_GATECFG2\n"); + stubManager.Write("-----\t------------\t\t-----------\t\t-------------\t\t------------\n"); + + for (i = 6; i < 14; i++)//Dispensers only + //for (i = 25; i < 29; i++)//Dispensers only + { + stubManager.Write(i); + stubManager.Write("\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG1)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG2)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + } + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing4.cs b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing4.cs new file mode 100644 index 000000000..5d6259cb4 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing4.cs @@ -0,0 +1,265 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//unmark Auto logging ! +const Int32 x_POWERSTEP01_CONFIG = 0x1A; +const Int32 x_POWERSTEP01_STATUS = 0x1B; +const Int32 x_POWERSTEP01_GATECFG1 = 0x18; +const Int32 x_POWERSTEP01_GATECFG2 = 0x19; + +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_ACC = 0x05; +const Int32 x_DEC = 0x06; +const Int32 x_MAX_SPEED = 0x07; +const Int32 x_MIN_SPEED = 0x08; +const Int32 x_FS_SPD = 0x15; +const Int32 x_KVAL_HOLD = 0x09; +const Int32 x_KVAL_RUN = 0x0A; +const Int32 x_KVAL_ACC = 0x0B; +const Int32 x_KVAL_DEC = 0x0C; +const Int32 x_INT_SPD = 0x0D; +const Int32 x_ST_SLP = 0x0E; +const Int32 x_FN_SLP_ACC = 0x0F; +const Int32 x_FN_SLP_DEC = 0x10; +const Int32 x_K_THERM = 0x11; +const Int32 x_ADC_OUT = 0x12; +const Int32 x_OCD_TH = 0x13; +const Int32 x_STALL_TH = 0x14; +const Int32 x_STEP_MODE = 0x16; +const Int32 x_ALARM_EN = 0x17; +const Int32 x_CONFIG = 0x18; +const Int32 x_STATUS = 0x19; +//------------------------------- +const Int32 x_GET_PARAM = 0x20; +//------------------------------- +const Int32 Max_Motor_ID = 25; + + + +string[] Motor_ID = new string[30]; + + +Motor_ID[0] ="DH_CLEANHEAD "; +Motor_ID[1] ="DH_CLEANMECH "; +Motor_ID[2] ="DH_LID "; +Motor_ID[3] ="DRYER_DRIVING"; +Motor_ID[4] ="DRYER_LID "; +Motor_ID[5] ="DRYER_LOADARM"; +Motor_ID[6] ="DISPENCER_1 "; +Motor_ID[7] ="DISPENCER_2 "; +Motor_ID[8] ="DISPENCER_3 "; +Motor_ID[9] ="DISPENCER_4 "; +Motor_ID[10]="DISPENCER_5 "; +Motor_ID[11]="DISPENCER_6 "; +Motor_ID[12]="DISPENCER_7 "; +Motor_ID[13]="DISPENCER_8 "; +Motor_ID[14]="SCREW "; +Motor_ID[15]="WINDER "; +Motor_ID[16]="LDANCER1 "; +Motor_ID[17]="LDANCER2 "; +Motor_ID[18]="LDRIVING "; +Motor_ID[19]="LLODING "; +Motor_ID[20]="LPIVOT "; +Motor_ID[21]="RDANCER "; +Motor_ID[22]="RDRIVING "; +Motor_ID[23]="RLOADARM "; +Motor_ID[24]="RLODING "; +Motor_ID[25]="SPARE1_1 "; +Motor_ID[26]="SPARE1_2 "; +Motor_ID[27]="SPARE2_1 "; +Motor_ID[28]="SPARE2_2 "; +Motor_ID[29]="SPARE3 "; + + + + + + + + + + + + + + + + + +Int32 i = 12; // to run only for specific motor + +public void OnExecute(StubManager stubManager) +{ + +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000380 , 0x06b9); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000390 , 0x003f); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000550 , 0x0003); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000b80 , 0x001f); + + + + + + + + + + + + for (i = 0; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + stubManager.Write("MoTor\t\t\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKVAL_HOLD\tKVAL_RUN\tKVAL_ACC\tKVAL_DEC\tOCD_TH\t\tSTALL_TH\tCONFIG\t\tFS_SPD\t\tADC_OUT\tDriver_Type\n"); + stubManager.Write("------\t\t\t--------\t--------\t----------\t---\t\t---\t\t---------\t--------\t--------\t--------\t------\t\t--------\t------\t\t------\t\t------\t\t------\n"); + } + //stubManager.Write(i); + + stubManager.Write(Motor_ID[i]); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MIN_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MAX_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); stubManager.Write("\t"); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ACC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_DEC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_HOLD)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_RUN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_OCD_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STALL_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FS_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + if( response.RecivedData > 0x15 ) + stubManager.Write("\t\tDual_Driver"); + else if ( response.RecivedData > 0x0b) + stubManager.Write("\t\tVolage_Driver"); + else if ( response.RecivedData > 8 ) + stubManager.Write("\t\tCurrent_Driver"); + else + stubManager.Write("\t\tNo_Driver"); + + + stubManager.Write("\n\n"); + + } + + stubManager.Write("MoTor\t\t\tINT_SPD\tST_SLP\t\tSLP_ACC\tSLP_DEC\tSTATUS\n"); + stubManager.Write("-----\t\t\t-------\t------\t\t-------\t--------\t-----\n"); + + for (i = 0; i < Max_Motor_ID; i++) + { + stubManager.Write(Motor_ID[i]); + +// stubManager.Write(i); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_INT_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ST_SLP)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + + + + } + + stubManager.Write("--------------- New Driver POWERSTEP01 ---------------\n\n"); + stubManager.Write("MoTor\tPS01_CONFIG\t\tPS01_STATUS\t\tPS01_GATECFG1\t\tPS01_GATECFG2\n"); + stubManager.Write("-----\t------------\t\t-----------\t\t-------------\t\t------------\n"); + + for (i = 6; i < 14; i++)//Dispensers only + //for (i = 25; i < 29; i++)//Dispensers only + { + stubManager.Write(i); + stubManager.Write("\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG1)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG2)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + } + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing_powerstep01.cs b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing_powerstep01.cs new file mode 100644 index 000000000..4188fe36b --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Motor_Get_Param_Horizontal_Printing_powerstep01.cs @@ -0,0 +1,266 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//unmark Auto logging ! + +const Int32 x_POWERSTEP01_CONFIG = 0x1A; +const Int32 x_POWERSTEP01_STATUS = 0x1B; +const Int32 x_POWERSTEP01_GATECFG1 = 0x18; +const Int32 x_POWERSTEP01_GATECFG2 = 0x19; + +const Int32 x_ABS_POS = 0x01; +const Int32 x_EL_POS = 0x02; +const Int32 x_MARK = 0x03; +const Int32 x_SPEED = 0x04; +const Int32 x_ACC = 0x05; +const Int32 x_DEC = 0x06; +const Int32 x_MAX_SPEED = 0x07; +const Int32 x_MIN_SPEED = 0x08; +const Int32 x_FS_SPD = 0x15; +const Int32 x_KVAL_HOLD = 0x09; +const Int32 x_KVAL_RUN = 0x0A; +const Int32 x_KVAL_ACC = 0x0B; +const Int32 x_KVAL_DEC = 0x0C; +const Int32 x_INT_SPD = 0x0D; +const Int32 x_ST_SLP = 0x0E; +const Int32 x_FN_SLP_ACC = 0x0F; +const Int32 x_FN_SLP_DEC = 0x10; +const Int32 x_K_THERM = 0x11; +const Int32 x_ADC_OUT = 0x12; +const Int32 x_OCD_TH = 0x13; +const Int32 x_STALL_TH = 0x14; +const Int32 x_STEP_MODE = 0x16; +const Int32 x_ALARM_EN = 0x17; +const Int32 x_CONFIG = 0x18; +const Int32 x_STATUS = 0x19; +//------------------------------- +const Int32 x_GET_PARAM = 0x20; +//------------------------------- +const Int32 Max_Motor_ID = 25; + + + +string[] Motor_ID = new string[30]; + + +Motor_ID[0] ="DH_CLEANHEAD "; +Motor_ID[1] ="DH_CLEANMECH "; +Motor_ID[2] ="DH_LID "; +Motor_ID[3] ="DRYER_DRIVING"; +Motor_ID[4] ="DRYER_LID "; +Motor_ID[5] ="DRYER_LOADARM"; +Motor_ID[6] ="DISPENCER_1 "; +Motor_ID[7] ="DISPENCER_2 "; +Motor_ID[8] ="DISPENCER_3 "; +Motor_ID[9] ="DISPENCER_4 "; +Motor_ID[10]="DISPENCER_5 "; +Motor_ID[11]="DISPENCER_6 "; +Motor_ID[12]="DISPENCER_7 "; +Motor_ID[13]="DISPENCER_8 "; +Motor_ID[14]="SCREW "; +Motor_ID[15]="WINDER "; +Motor_ID[16]="LDANCER1 "; +Motor_ID[17]="LDANCER2 "; +Motor_ID[18]="LDRIVING "; +Motor_ID[19]="LLODING "; +Motor_ID[20]="LPIVOT "; +Motor_ID[21]="RDANCER "; +Motor_ID[22]="RDRIVING "; +Motor_ID[23]="RLOADARM "; +Motor_ID[24]="RLODING "; +Motor_ID[25]="SPARE1_1 "; +Motor_ID[26]="SPARE1_2 "; +Motor_ID[27]="SPARE2_1 "; +Motor_ID[28]="SPARE2_2 "; +Motor_ID[29]="SPARE3 "; + + + + + + + + + + + + + + + + + +Int32 i = 12; // to run only for specific motor + +public void OnExecute(StubManager stubManager) +{ + +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000380 , 0x06b9); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000390 , 0x003f); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000550 , 0x0003); +stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000b80 , 0x001f); + + + + + + + + + + + + for (i = 0; i < Max_Motor_ID; i++) + { + + if((i%8 ==0) ) + { + stubManager.Write("\n\n"); + stubManager.Write("MoTor\t\t\tMIN_SPEED\tMAX_SPEED\tSTEP_MODE\tACC\t\tDEC\t\tKVAL_HOLD\tKVAL_RUN\tKVAL_ACC\tKVAL_DEC\tOCD_TH\t\tSTALL_TH\tCONFIG\t\tFS_SPD\t\tADC_OUT\tDriver_Type\n"); + stubManager.Write("------\t\t\t--------\t--------\t----------\t---\t\t---\t\t---------\t--------\t--------\t--------\t------\t\t--------\t------\t\t------\t\t------\t\t------\n"); + } + //stubManager.Write(i); + + stubManager.Write(Motor_ID[i]); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MIN_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_MAX_SPEED)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); stubManager.Write("\t"); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ACC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_DEC)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_HOLD)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_RUN)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_KVAL_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_OCD_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STALL_TH)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FS_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ADC_OUT)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + if( response.RecivedData > 0x15 ) + stubManager.Write("\t\tDual_Driver"); + else if ( response.RecivedData > 0x0b) + stubManager.Write("\t\tVolage_Driver"); + else if ( response.RecivedData > 8 ) + stubManager.Write("\t\tCurrent_Driver"); + else + stubManager.Write("\t\tNo_Driver"); + + + stubManager.Write("\n\n"); + + } + + stubManager.Write("MoTor\t\t\tINT_SPD\tST_SLP\t\tSLP_ACC\tSLP_DEC\tSTATUS\n"); + stubManager.Write("-----\t\t\t-------\t------\t\t-------\t--------\t-----\n"); + + for (i = 0; i < Max_Motor_ID; i++) + { + stubManager.Write(Motor_ID[i]); + +// stubManager.Write(i); + stubManager.Write("\t\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_INT_SPD)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_ST_SLP)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_ACC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_FN_SLP_DEC)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + + + + } + + + stubManager.Write("--------------- New Driver POWERSTEP01 ---------------\n\n"); + stubManager.Write("MoTor\tPS01_CONFIG\t\tPS01_STATUS\t\tPS01_GATECFG1\t\tPS01_GATECFG2\n"); + stubManager.Write("-----\t------------\t\t-----------\t\t-------------\t\t------------\n"); + + for (i = 6; i < 14; i++)//Dispensers only + //for (i = 25; i < 29; i++)//Dispensers only + { + stubManager.Write(i); + stubManager.Write("\t"); + + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_CONFIG)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_STATUS)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG1)<<16, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\t\t\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,i, (x_GET_PARAM | x_POWERSTEP01_GATECFG2)<<8, 0, 0); + stubManager.WriteHex(response.RecivedData,4); + stubManager.Write("\n\n"); + } + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Read Dancer.cs b/Software/Stubs Collection/stubs/Scripts/Read Dancer.cs new file mode 100644 index 000000000..8fcfc94b0 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Read Dancer.cs @@ -0,0 +1,32 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + var response1 = stubManager.ShowResponseWindow("Please Enter Password:"); + if (response1=="Aa123456") + { + stubManager.WriteLine(response1); + + + stubManager.RequestTimeout = 2000; + //for (int i = 0; i < 100; i++) + { + var response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,0); + Thread.Sleep(1000); + response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,1); + Thread.Sleep(1000); + response = stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,2); + Thread.Sleep(1000); + } + } +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Read_Version.cs b/Software/Stubs Collection/stubs/Scripts/Read_Version.cs index 3bc9eb929..b3e3e2c1f 100644 --- a/Software/Stubs Collection/stubs/Scripts/Read_Version.cs +++ b/Software/Stubs Collection/stubs/Scripts/Read_Version.cs @@ -53,7 +53,6 @@ public void OnExecute(StubManager stubManager) stubManager.Write("\n"); - var response_swid = stubManager.Run<StubReadEmbeddedVersionResponse>("StubReadEmbeddedVersionRequest" , true); stubManager.Write("\nTIVA MCU SW Version (Major, Minor, Patch, Build, Version String): ("); stubManager.WriteHex(response_swid.VerMajor,4); @@ -86,21 +85,7 @@ public void OnExecute(StubManager stubManager) //ReadFPGATestReg(FPGA3); stubManager.Write("\n"); - -var response1 = stubManager.Run<StubReadEmbeddedVersionResponse>("StubReadEmbeddedVersionRequest" ); - - stubManager.Write("\nCPU Version: "); - stubManager.Write("\nVerMajor:"); - stubManager.Write(response1.VerMajor); - stubManager.Write("\nVerMinor:"); - stubManager.Write(response1.VerMinor); - stubManager.Write("\nVerMinor:"); - stubManager.Write(response1.VerPatch); - stubManager.Write("\nVerPatch:"); - stubManager.Write(response1.VerBuild); - stubManager.Write("\nVerBuild:"); - stubManager.Write(response1.Version); - + } /* Example Script Output diff --git a/Software/Stubs Collection/stubs/Scripts/Tango_Main_PCB_ATP_sn_xxxxxxx.xlsx b/Software/Stubs Collection/stubs/Scripts/Tango_Main_PCB_ATP_sn_xxxxxxx.xlsx Binary files differnew file mode 100644 index 000000000..57fd92df9 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Tango_Main_PCB_ATP_sn_xxxxxxx.xlsx diff --git a/Software/Stubs Collection/stubs/Scripts/TestForVika.cs b/Software/Stubs Collection/stubs/Scripts/TestForVika.cs new file mode 100644 index 000000000..7861bae7a --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/TestForVika.cs @@ -0,0 +1,126 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + + bool i = true; +//-------------------------------------------------------------------------------- + +public void OnExecute(StubManager stubManager) +{ + Form form1 = new Form(); +// Set the caption bar text of the form. + form1.TopMost = true; + form1.Text = "RTFU Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----RTFU Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" RTFU S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + + + + + Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; + Label5.Location = new Point (300, 100); + Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + + Label5.Text=""; + Label5.Font = new Font("Arial", 24,FontStyle.Bold); + form1.Controls.Add(Label5); + + + + +//-------------------------------------------------------------------------------- + + + button1.Click += (_,__) => + + { + + + Label5.Text="Pros"; ///???? not working + + + + +//------------------------------- start test ----------- + Thread.Sleep(5000); //delay 10 second + +if (i==true) + Label5.Text="Fail"; +else + Label5.Text="Pass"; + + i= !i; + TextBox1.Text=""; + }; + + form1.ShowDialog(); + + return ; + } + diff --git a/Software/Stubs Collection/stubs/Scripts/Twine_Tango_Main_Test12.docx b/Software/Stubs Collection/stubs/Scripts/Twine_Tango_Main_Test12.docx Binary files differnew file mode 100644 index 000000000..f82f59d00 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Twine_Tango_Main_Test12.docx diff --git a/Software/Stubs Collection/stubs/Scripts/Twine_Tango_Main_Test13.docx b/Software/Stubs Collection/stubs/Scripts/Twine_Tango_Main_Test13.docx Binary files differnew file mode 100644 index 000000000..d56728507 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Twine_Tango_Main_Test13.docx diff --git a/Software/Stubs Collection/stubs/Scripts/Write SYLKO to head eeprom.cs b/Software/Stubs Collection/stubs/Scripts/Write SYLKO to head eeprom.cs new file mode 100644 index 000000000..6e9bfd83d --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Write SYLKO to head eeprom.cs @@ -0,0 +1,118 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//---------------------- +const Int32 I2C_ID = 3; //MCU_I2C3 +const Int32 TCA9548A_address = 0xE2; +const Int32 I2C_Slave_Add = 0xA0; // //eeprom address - 32kByte +int Head_Mux_Channel_ID = 4; //Head MUX channel +//---------------------- + +const Int32 SerialNum = 0x01; + + +int enable_channel(int Channel_ID) +{ + uint Const_temp = 0x01; + + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address; + + Const_temp = Const_temp << Channel_ID; + stubI2CWriteBytesRequest.BytesTWrite.Add(Const_temp); + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + + +int adc_write(uint I2C_Slave_Add, uint Page) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(Page);//Byte 0 to write + //-------------------------------------------------------------- + + stubI2CWriteBytesRequest.BytesTWrite.Add(SerialNum);//S/N + stubI2CWriteBytesRequest.BytesTWrite.Add(0x02);//HEAD_TYPE_SYLKO + //stubI2CWriteBytesRequest.BytesTWrite.Add(0x03);//HEAD_TYPE_STAPLE_SPUN + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int adc_set_for_read_ch(uint I2C_Slave_Add, uint Page) +{ + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = I2C_Slave_Add; + + + UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0);//Byte 0 to write + stubI2CWriteBytesRequest.BytesTWrite.Add(Page);//Byte 0 to write + + var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + + return 1; +} + +int adc_read_ch(uint I2C_Slave_Add) +{ + StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest(); + stubI2CReadBytesRequest.I2CId = I2C_ID; + stubI2CReadBytesRequest.SlaveAddress = I2C_Slave_Add + 1; + stubI2CReadBytesRequest.NumberOfBytesToRead = 10; // Number of bytes to read + + var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest); + uint temph=0; + + for(int i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead;i++) + { + temph=response1.ReadBytes[i]; + stubManager.WriteHex(temph,2); + } + + return 1; +} + + +public void OnExecute(StubManager stubManager) +{ + + //enable_all_channel(); + enable_channel(Head_Mux_Channel_ID); // Chanel 0-7 => Disp0enser 0-7 + + for (int i = 0; i<1; i++) + { + + adc_write(I2C_Slave_Add,0x00); + Thread.Sleep(10); //Sleep for 5 milli. - must! otherwise read 0xff (See data sheet ) + + stubManager.Write("\nPage 0x00 #"); + stubManager.Write(i); + stubManager.Write("\t- The Buffer is: "); + adc_set_for_read_ch(I2C_Slave_Add, 0x00); + //Thread.Sleep(1); //Sleep for 10 milli. + adc_read_ch(I2C_Slave_Add); + + Thread.Sleep(1000); + + } +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/blower_Q.cs b/Software/Stubs Collection/stubs/Scripts/blower_Q.cs new file mode 100644 index 000000000..cb4682531 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/blower_Q.cs @@ -0,0 +1,28 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ +// Request ---- +// Int32 : Amount +// Int32 : Delay + +// Response ---- +// Double : Progress + + +//fan test +/*var response1 =*/ stubManager.Run<ProgressResponse>("ProgressRequest" ,/*fan1*/0x3E7, /*Head_Q=*/9); // +//500=1F4 +//250=FA + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/check_kval_load_arm.cs b/Software/Stubs Collection/stubs/Scripts/check_kval_load_arm.cs new file mode 100644 index 000000000..8276ad449 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/check_kval_load_arm.cs @@ -0,0 +1,80 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +const Int32 x_KVAL_HOLD = 0x09; +const Int32 x_KVAL_RUN = 0x0A; +const Int32 x_KVAL_ACC = 0x0B; +const Int32 x_KVAL_DEC = 0x0C; + +const Int32 x_GET_PARAM = 0x20; + + + +public void OnExecute(StubManager stubManager) +{ + + while (true) + { + stubManager.Write("\nLeft Load KVAL \t"); + var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,19, (x_GET_PARAM | x_KVAL_HOLD)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,19, (x_GET_PARAM | x_KVAL_RUN)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,19, (x_GET_PARAM | x_KVAL_ACC)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,19, (x_GET_PARAM | x_KVAL_DEC)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\n"); + + + stubManager.Write("Right Load KVAL \t"); + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,24, (x_GET_PARAM | x_KVAL_HOLD)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,24, (x_GET_PARAM | x_KVAL_RUN)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,24, (x_GET_PARAM | x_KVAL_ACC)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\t"); + + response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,24, (x_GET_PARAM | x_KVAL_DEC)<<8, 0, 0); + stubManager.Write(response.RecivedData); + stubManager.Write("\n"); + stubManager.Write(DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")); + Thread.Sleep(1000); + + + + + + +} + + + + + + + + + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/temp.cs b/Software/Stubs Collection/stubs/Scripts/temp.cs new file mode 100644 index 000000000..23508b71b --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/temp.cs @@ -0,0 +1,492 @@ +using System; +using System.Text; +using System.IO; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ +string path=""; + Form form1 = new Form(); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + +// Set the caption bar text of the form. + form1.TopMost = true; + form1.Text = "RTFU Test"; + form1.FormBorderStyle = FormBorderStyle.FixedDialog; + form1.MaximizeBox = false; + form1.MinimizeBox = false; + form1.StartPosition = FormStartPosition.CenterScreen; + form1.AutoSize = true; + form1.AutoSizeMode = AutoSizeMode.GrowAndShrink; +// Create buttons to Run. + Button button1 = new Button () + { + Width = 100, + Height = 100, + }; + button1.Text = "Run"; + button1.Location = new Point (40, 100); + form1.Controls.Add(button1); +//-----RTFU Serial Number ----------- + + Label Label1 = new Label () + { + Width = 150, + Height = 20, + Text =" RTFU S/N" + }; + Label1.Location = new Point (30, 10); + form1.Controls.Add(Label1); + TextBox TextBox1 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; + TextBox1.Location = new Point (40, 40); + form1.Controls.Add(TextBox1); + //----------LOCATION---------- + + Label Label3 = new Label () + { + Width = 150, + Height = 20, + Text ="LOCATION" + }; +Label3.Location = new Point (350, 10); + form1.Controls.Add(Label3); + + + +TextBox TextBox3 = new TextBox () + { + Width = 100, + Height = 10, + Text ="" + }; +TextBox3.Location = new Point (360, 40); + form1.Controls.Add(TextBox3); + + + + + Label Label5 = new Label () + { + Width = 120, + Height =100, + Text = "" + }; + Label5.Location = new Point (300, 100); + Label5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + + Label5.Text=""; + Label5.Font = new Font("Arial", 24,FontStyle.Bold); + form1.Controls.Add(Label5); + + + + +//-------------------------------------------------------------------------------- + + stubManager.Write("Counter is 2 \n"); + + button1.Click += (_,__) => + + { + + Label5.Text="Pros"; + + if (!Directory.Exists(path1)) + { + path=path2; + if (!Directory.Exists(path2)) + Directory.CreateDirectory(path2); + } + else + path=path1; + + File_Name1=path + TextBox1.Text +"_RTFU_" + DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss")+".log" ; + + + stubManager.Write(File_Name1 +"\n"); + stubManager.WriteToFile(File_Name1,DateTime.Now +" " ); + stubManager.Write(DateTime.Now +"\n" ); + + stubManager.AppendToFile(File_Name1,"RTFU Test Report" ); + stubManager.Write("RTFU Test Report\n" ); + + stubManager.AppendToFile(File_Name1,"RTFU S/N: \t" + TextBox1.Text ); + stubManager.Write("RTFU S/N:" + TextBox1.Text +"\n" ); + + + stubManager.AppendToFile(File_Name1,"Location:\t" + TextBox3.Text ); + stubManager.Write("Location:" + TextBox3.Text +"\n" ); + + +//------------------------------- start test ----------- + Test_RLOADING_RTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(100); + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x14000000); //set kval ran to 0x14,0.65A + + Test_RDRIVING_RTFU(); + Test_DANCER_RTFU(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + Status=write_to_file(); + stubManager.Write(Status +"\n"); + + Label5.Text=Status; + TextBox1.Text=""; + }; + + form1.ShowDialog(); + + return ; + } + //------------------------------------ +int Test_RLOADING_RTFU() +{ + int temp=1; + int counter; + + Motor_SetParam(F1_MOTO_RLOADING_TX1,F1_MOTO_RLOADING_TX0,0x0a,0x2c000000); //set kval ran to 0x2c- 1.3A + Thread.Sleep(100); + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + Thread.Sleep(3000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + Thread.Sleep(1000); +//------------------------------------------ check F1_LS_RLOADMOTOR_up------------------------------------------------ + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RLOADMOTOR_UP) !=F1_LS_RLOADMOTOR_UP ) //if LS_RLOADMOTOR_UP is up then error + { + DialogResult result = MessageBox.Show("Did RLOADIN MOTOR Move?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.Yes) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + else + { + Units_status[2,1]="Fail"; + stubManager.Write("RLOADMOTOR\tFail\n"); + return 0; + } + } + +//----------------------------------------- mov RLOADING up ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor,false,200); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_UP) != F1_LS_RLOADMOTOR_UP ) + counter=250; + + Thread.Sleep(100); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + if (counter == 150) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP\tFail\n"); + return 0; + } + DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result1 == DialogResult.No) + { + Units_status[0,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_UP Not calibrate\n"); + return 0; + } + Units_status[0,1]="Pass"; + Units_status[2,1]="Pass"; + +//------------------------------------------ check F1_LS_RLOADMOTOR_DN------------------------------------------------ + + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + + if ((response.Value & F1_LS_RLOADMOTOR_DN) !=F1_LS_RLOADMOTOR_DN ) //if LS_RLOADMOTOR_DN is up then error + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } +//------------------------------------------ mov RLOADING dn ------------------------------------------------ + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RLOADMOTOR_DN) != F1_LS_RLOADMOTOR_DN ) + counter=250; + + Thread.Sleep(100); + } + + if (counter == 150) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN\tFail\n"); + return 0; + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.YesNo); + if(result2 == DialogResult.No) + { + Units_status[1,1]="Fail"; + stubManager.Write("LS_RLOADMOTOR_DN Not calibrate\n"); + return 0; + } + Units_status[1,1]="Pass"; + stubManager.Write("RLOADMOTOR\tPass\n"); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RLOADING_Motor, true,200); //move Rloading down + Thread.Sleep(2000); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RLOADING_Motor, 3); //hold Rloading high z + + return 1 ; + +} + +//---------------------------------- + +Int32 ReadEncoder() +{ + Int32 temp; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,F1_RDANCER_ROTENC_DATA_p_TX, 0x0000); //triggers a TX transmission + + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_lsb); + var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_RDANCER_ROTENC_DATA_p_RX_msb); + + temp = Convert.ToInt32 (((((response1.Value <<16) + response.Value)>>10 ) & 0x3fff)); + + + return temp; +} +//-------------------------------------------------------------------------------- +int Test_DANCER_RTFU() +{ + int counter; + Int32 temp; + Int32 temp1; + +//------------------------------------------ check F1_LS_RDANCER_DOWN ------------------------------------------------ + + MessageBox.Show("Make sure RDANCER Doun"); + var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //read LS + if ((response.Value & F1_LS_RDANCER_DOWN) !=F1_LS_RDANCER_DOWN ) //if F1_LS_RDANCER_DOWN is up then error + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } +//----------------------------------------- mov RDANCER_Motor up and check F1_LS_RDANCER_DOWN ------------------------------------------------- + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,true,10); //move Rloading up + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[4,1]="Pass"; + stubManager.Write("LS_RDANCER_DOWN\tPass\n"); + +//----------------------------------------- check F1_LS_RDANCER_UP ------------------------------------------------- + + if ((response.Value & F1_LS_RDANCER_UP) !=F1_LS_RDANCER_UP ) //if F1_LS_RDANCER_UP is up then error + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RDANCER_UP is up then move down + if ((response.Value & F1_LS_RDANCER_UP) != F1_LS_RDANCER_UP ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[5,1]="Fail"; + stubManager.Write("LS_RDANCER_UP\tFail\n"); + return 0; + } + Units_status[5,1]="Pass"; + stubManager.Write("LS_RDANCER_UP\tPass\n"); + +//----------------------------------------- check F1_LS_RLOADRAM_DOWN ------------------------------------------------- + + if ((response.Value & F1_LS_RLOADRAM_DOWN) !=F1_LS_RLOADRAM_DOWN ) //if F1_LS_RLOADRAM_DOWN is up then error + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if F1_LS_RLOADRAM_DOWN is up then move down + if ((response.Value & F1_LS_RLOADRAM_DOWN) != F1_LS_RLOADRAM_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[6,1]="Fail"; + stubManager.Write("LS_RLOADRAM_DOWN\tFail\n"); + return 0; + } + Units_status[6,1]="Pass"; + stubManager.Write("LS_RLOADRAM_DOWN\tPass\n"); + +//----------------------------------------- mov RDANCER_Motor down and check rdancer encoder ------------------------------------------------- + temp= ReadEncoder(); + + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDANCER_Motor,false,10); //move Rloading down + counter =0; + while ( counter < 150) + { + counter = counter + 1; + response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_03_Direct); //if LS_RLOADMOTOR_UP is up then move down + if ((response.Value & F1_LS_RDANCER_DOWN) != F1_LS_RDANCER_DOWN ) + counter=250; + + Thread.Sleep(100); + } + if (counter == 150) + { + Units_status[4,1]="Fail"; + stubManager.Write("LS_RDANCER_DOWN\tFail\n"); + return 0; + } + Units_status[7,1]="Pass"; + stubManager.Write("RDANCER_Motor\tPass\n"); + + temp1= ReadEncoder(); + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z + + stubManager.Write("temp="+temp + "\temp1="+temp1 +"\n"); + + DialogResult result = MessageBox.Show("SSI Dancer led is Green(not blinking)?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + + if (temp>temp1) + temp1=temp1+0x4000; + + temp1=temp1-temp; + if ((temp1> 15000) || (temp1 <1000)) + { + Units_status[8,1]="Fail"; + stubManager.Write("RDANCER_SSI\tFail\n"); + return 0; + } + Units_status[8,1]="Pass"; + stubManager.Write("RDANCER_SSI\tPass\n"); + + return 1; +} + + +//------------------------------------------------------------- +int Test_RDRIVING_RTFU() +{ + stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,RDRIVING_Motor, true,200); //move Rdriving clockwise + stubManager.Write("RDRIVING_Motor Motor rotate \n "); + + DialogResult result = MessageBox.Show("Are RDRIVING Motor rotate?", "Warning",MessageBoxButtons.YesNo); + if(result == DialogResult.No) + { + Units_status[3,1]="Fail"; + stubManager.Write("RDRIVING Motor not rotate\n"); + } + else + { + Units_status[3,1]="Pass"; + stubManager.Write("RDRIVING Motor rotate\n"); + } + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,RDRIVING_Motor,3); //stop motor + + return 0; +} + + + +//-------------------------------------------------------------------------------- +int Motor_SetParam(Int32 HighAdr, Int32 LowAdr, Int32 ParaAddr, uint ParaData1) +{ + + Int32 Temp = 0; + Temp = (ParaAddr << 8 ) + ( (Int32) ParaData1 >> 24); + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,HighAdr, (Temp & 0xffff)); + Temp = ((Int32)ParaData1 >> 8) & 0xffff; + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,LowAdr, (Temp)); + + return 1; +} + //------------------------------------ +string write_to_file() +{ + stubManager.Write("write_to_file\n"); + +string Stemp="Pass"; + for (int i=0;i<UNIT_UNDER_TEST;i++) + { + stubManager.AppendToFile(File_Name1,Units_status[i,0]+"\t" + Units_status[i,1] ); + stubManager.Write(Units_status[i,0]+"\t" + Units_status[i,1]+"\n" ); + + if ((Units_status[i,1]=="Fail")||(Units_status[i,1]=="Not Test")) + Stemp="Fail"; + } + if (Stemp=="Fail") + { + stubManager.AppendToFile(File_Name1,"-------------RTFU Fail ------------ "); + stubManager.Write("-------------RTFU Fail ------------ "); + } + else + { + stubManager.AppendToFile(File_Name1,"-------------RTFU Pass ------------ )"); + stubManager.Write("-------------RTFU Pass ------------ "); + } + + return Stemp; + +} + diff --git a/Software/Stubs Collection/stubs/Scripts/test.cs b/Software/Stubs Collection/stubs/Scripts/test.cs new file mode 100644 index 000000000..a0aebf743 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/test.cs @@ -0,0 +1,76 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +//---------------------- + +//---------------------- +const Int32 I2C_ID = 3; //MCU_I2C2 +const Int32 TCA9548A_address = 0xe2; //or 0xE0 or 0xE4 +const Int32 I2C_Slave_Add = 0xc0; // /MPC9600 address +//const Int32 I2C_Slave_Add = 0x46; //must be 0x40, 0x44 or 0x46 +//---------------------- + + +int disable_all_channel1() + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = 0xe0; + +// UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x10);//enable all 8 i2c channel + + stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + Thread.Sleep(10); + + return 1; + } +int disable_all_channel2() + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = 0xe2; + +// UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//enable all 8 i2c channel + + stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + Thread.Sleep(10); + + return 1; + } + +int disable_all_channel3() + { + StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest(); + stubI2CWriteBytesRequest.I2CId = I2C_ID; + stubI2CWriteBytesRequest.SlaveAddress = 0xe4; + +// UInt32 uInt32 = new UInt32(); + stubI2CWriteBytesRequest.BytesTWrite.Add(0x00);//enable all 8 i2c channel + + stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest); + Thread.Sleep(10); + + return 1; + } + + + +public void OnExecute(StubManager stubManager) +{ + disable_all_channel1(); + disable_all_channel2(); + disable_all_channel3(); + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/wd_enable.cs b/Software/Stubs Collection/stubs/Scripts/wd_enable.cs new file mode 100644 index 000000000..3919b7256 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/wd_enable.cs @@ -0,0 +1,25 @@ +using System; +using System.Text; +using System.Linq; +using System.Drawing; +using System.Diagnostics; +using System.Windows.Forms; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using Tango.PMR.Stubs; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ + for (int i = 0; i < 100; i++) + { + +//var response = stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000160, 0x4001); //wd fpga1 +var response = stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000540, 0x4001); //wd fpga2 +//var response = stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x60000940, 0x4001); //wd fpga3 + Thread.Sleep(100); + + + } +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/read embedded version.cs b/Software/Stubs Collection/stubs/read embedded version.cs index 27424c029..8990fc2cd 100644 --- a/Software/Stubs Collection/stubs/read embedded version.cs +++ b/Software/Stubs Collection/stubs/read embedded version.cs @@ -8,7 +8,7 @@ using System.Threading; using System.Threading.Tasks; using System.Collections.Generic; using Tango.PMR.Stubs; -using Tango.Stubs.UI; +using Tango.Stubs; public void OnExecute(StubManager stubManager) { |
