aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/Scripts/Dispenser_setup.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Stubs Collection/stubs/Scripts/Dispenser_setup.cs')
-rw-r--r--Software/Stubs Collection/stubs/Scripts/Dispenser_setup.cs1415
1 files changed, 1415 insertions, 0 deletions
diff --git a/Software/Stubs Collection/stubs/Scripts/Dispenser_setup.cs b/Software/Stubs Collection/stubs/Scripts/Dispenser_setup.cs
new file mode 100644
index 000000000..703d34ae9
--- /dev/null
+++ b/Software/Stubs Collection/stubs/Scripts/Dispenser_setup.cs
@@ -0,0 +1,1415 @@
+
+//--------------------------------------------------------------------------------
+include "Dispenser_setup_mbar.cs"
+include "Dispenser_Motor_stop.cs"
+include "Dispenser_setup_form_valve close.cs"
+include "Dispenser_setup_form_valve open.cs"
+include "Dispenser_Motor_run.cs"
+include "Dispenser_Motor_Up.cs"
+include "Dispenser_Motor_Down.cs"
+include "EEPROM.cs"
+
+//--------------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.Diagnostics;
+using System.Threading;
+using System.Threading.Tasks;
+using Tango.PMR.Stubs;
+using Tango.Stubs;
+using System.IO;
+
+//--------------------------------------------------------------------------------
+int Characterization;
+UInt32 [] Motor_Dir=new UInt32 [8] {0,0,0,0,0,0,0,0};
+
+string[] Dispenser_Fname= new string[9];
+string [] Dispenser_name= new string[8];
+string [] PCB_SN= new string[8];
+string [] Dispenser_PN= new string[8];
+
+Int32 [,] Dispenser_no = new Int32 [8,2] {{-1,0},{-1,0},{-1,0},{-1,0},{-1,0},{-1,0},{-1,0},{-1,0}};
+
+Int32 [] Dispenser_press= new Int32[8]{0,0,0,0,0,0,0,0};
+Int32 [] max_pressure_level = new Int32 [8] {20000,20000,20000,20000,20000,20000,20000,20000};
+Int32 [] min_pressure_level = new Int32 [8] {-20000,-20000,-20000,-20000,-20000,-20000,-20000,-20000};
+
+Int32 [] A2D_Dispenser= new Int32[8]{0,0,0,0,0,0,0,0};
+Int32 [] Loop_cnt= new Int32[8]{1,1,1,1,1,1,1,1};
+Int32 [] Loop_length= new Int32[8]{1,1,1,1,1,1,1,1};
+
+//byte [] Empty_EEprom=0;
+
+byte [] Empty_EEprom= new byte[8];
+byte [] Dry_Run_EEprom =new byte[8];
+byte [] Flow_EEprom =new byte[8];
+
+
+
+Int32 msec_index=0;
+
+byte [] EEPROM_Data = new byte [128];
+
+const int X_location =500;//260
+const int Y_location =40;
+
+Int32 [] Dispenser_sample_rate= new Int32[8]{1,1,1,1,1,1,1,1};
+//int dispenserNumber=1;
+//int Table=0;
+string shortDateString;
+string ButtonPress;
+string ButtonName;
+UInt32 Type_card;
+
+
+UInt32 RD_LS_01_Direct;
+UInt32 RD_LS_02_Direct;
+UInt32 RD_LS_03_Direct;
+UInt32 RD_LS_04_Direct;
+
+OpenFileDialog _openFiledialog;
+
+CancellationTokenSource _cancellationTokenSource;
+string path ;
+string Tbl_File_Name;
+
+Int32 Press_Sensor_Type ;//0 - 0-10 Bar ; 1- (-1) - 10 Bar ;
+ushort check_sum=0;
+
+//start mat
+//--------------------------------------------------------------------------------
+[STAThread]
+public void OnExecute(StubManager stubManager)
+{
+Dispenser_Fname[0]="";
+Dispenser_Fname[1]="";
+Dispenser_Fname[2]="";
+Dispenser_Fname[3]="";
+Dispenser_Fname[4]="";
+Dispenser_Fname[5]="";
+Dispenser_Fname[6]="";
+Dispenser_Fname[7]="";
+//----------------------------------------------------------------------------------
+stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0X60000522, 0X128);//0X128 EQULE 50 MSEC
+
+//--------------------Create form-------------------------------------------------
+ Form form1 = new Form();
+ _openFiledialog = new OpenFileDialog();
+//--------------------Set the caption bar text of the form------------------------
+ form1.Text = "Dispenser Test V1.9";
+ form1.TopMost = true;
+//------- 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;
+//--------------create ListBox --------------------------------------
+ // Create an instance of the ListBox.
+ ListBox listBox1 = new ListBox();
+ // Set the size and location of the ListBox.
+ listBox1.Size = new System.Drawing.Size(200, 80);
+ listBox1.Location = new System.Drawing.Point(150,400);
+ // Add the ListBox to the form.
+ form1.Controls.Add(listBox1);
+ // Set the ListBox to display items in multiple columns.
+ listBox1.MultiColumn = false;
+ // Set the selection mode to multiple and extended.
+ listBox1.SelectionMode = SelectionMode.MultiExtended;
+
+ // Shutdown the painting of the ListBox as items are added.
+ listBox1.BeginUpdate();
+ listBox1.Items.Add("Press-Sensor 0 to 10 Bar");
+ listBox1.Items.Add("Press-Sensor -1 to 10 Bar");
+ listBox1.Items.Add("Temp");
+ listBox1.Items.Add("Moti");
+ listBox1.EndUpdate();
+
+ // Select one items from the ListBox.
+ string text="0";
+ if (File.Exists("C:\\Dispenser_setup\\setup.txt"))
+ {
+ text = System.IO.File.ReadAllText(@"C:\Dispenser_setup\setup.txt") ;
+ }
+
+ listBox1.SetSelected( Convert.ToInt32(text), true);
+string Text_Blck;
+string Text_Cyn;
+string Text_Mgnt;
+string Text_Ylw;
+string Text_TI;
+
+ if ( (listBox1.SelectedItem)=="Moti")
+ {
+ Text_Blck = "Blck";
+ Text_Cyn = "Cyn";
+ Text_Mgnt = "Mgnt";
+ Text_Ylw = "Ylw";
+ Text_TI = "TI";
+ path = "P:\\TSKF\\BPT\\";
+ }
+ else
+ {
+ Text_Blck = "";
+ Text_Cyn = "";
+ Text_Mgnt = "";
+ Text_Ylw = "";
+ Text_TI = "";
+ path = "C:\\dispenser_setup\\Log\\";
+// path="%userprofile%\\Dropbox\\Dispenser_Tester\\Log\\";
+// path = "C:\\Dispenser_setup\\Log\\";
+ }
+
+ if ( (listBox1.SelectedItem)=="Press-Sensor -1 to 10 Bar")
+ {
+ stubManager.WriteLine("Press_Sensor_Type=1");
+ Press_Sensor_Type=1;
+ }
+ else
+ {
+ stubManager.WriteLine("Press_Sensor_Type=0");
+ Press_Sensor_Type=0;
+ }
+//----------------------------------Dispenser 1 ------------------------------------------
+Label Label100 = new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="1"
+ };
+ Label100.Location = new Point (5, 55);
+ form1.Controls.Add(Label100);
+TextBox TextBox1 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = Text_Blck,
+ };
+TextBox1.Location = new Point (20, 50);
+TextBox1.CharacterCasing = CharacterCasing.Upper;
+ form1.Controls.Add(TextBox1); //dispencer 1
+
+ TextBox Press0 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press0.Location = new Point (135, 50);
+ form1.Controls.Add(Press0); //dispencer 1
+
+ TextBox PartNm0 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm0.Location = new Point (250, 50);
+ form1.Controls.Add(PartNm0); //dispencer 1
+
+ // Create and initialize a CheckBox.
+ CheckBox checkBox0 = new CheckBox();
+ checkBox0.Location = new Point (370, 50);
+ form1.Controls.Add(checkBox0);
+//----------------------------------Dispenser 2 ------------------------------------------
+Label Label102 = new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="2"
+ };
+ Label102.Location = new Point (5, 85);
+ form1.Controls.Add(Label102);
+
+ TextBox TextBox3 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text =Text_Cyn
+ };
+TextBox3.Location = new Point (20, 80);
+TextBox3.CharacterCasing = CharacterCasing.Upper;
+form1.Controls.Add(TextBox3); //dispencer 2
+
+
+ TextBox Press1 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press1.Location = new Point (135, 80);
+ form1.Controls.Add(Press1); //dispencer 2
+
+ TextBox PartNm1 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm1.Location = new Point (250, 80);
+ form1.Controls.Add(PartNm1); //dispencer 2
+ // Create and initialize a CheckBox.
+ CheckBox checkBox1 = new CheckBox();
+ checkBox1.Location = new Point (370, 80);
+ form1.Controls.Add(checkBox1);
+
+//----------------------------------Dispenser 3 ------------------------------------------
+Label Label103 = new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="3"
+ };
+ Label103.Location = new Point (5, 125);
+ form1.Controls.Add(Label103);
+
+ TextBox TextBox4 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text =Text_Mgnt,
+ };
+TextBox4.Location = new Point (20, 120);
+TextBox4.CharacterCasing = CharacterCasing.Upper;
+form1.Controls.Add(TextBox4); //dispencer 3
+
+ TextBox Press2 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press2.Location = new Point (135, 120);
+ form1.Controls.Add(Press2); //dispencer3
+
+ TextBox PartNm2 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm2.Location = new Point (250, 120);
+ form1.Controls.Add(PartNm2); //dispencer 3
+ // Create and initialize a CheckBox.
+ CheckBox checkBox2 = new CheckBox();
+ checkBox2.Location = new Point (370, 120);
+ form1.Controls.Add(checkBox2);
+
+//----------------------------------Dispenser 4 ------------------------------------------
+Label Label104= new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="4"
+ };
+ Label104.Location = new Point (5, 165);
+ form1.Controls.Add(Label104);
+
+TextBox TextBox5 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text =Text_Ylw,
+ };
+TextBox5.Location = new Point (20, 160);
+TextBox5.CharacterCasing = CharacterCasing.Upper;
+ form1.Controls.Add(TextBox5); //dispencer 4
+
+ TextBox Press3 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press3.Location = new Point (135, 160);
+ form1.Controls.Add(Press3); //dispencer4
+
+ TextBox PartNm3 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm3.Location = new Point (250, 160);
+ form1.Controls.Add(PartNm3); //dispencer 4
+ CheckBox checkBox3 = new CheckBox();
+ checkBox3.Location = new Point (370, 160);
+ form1.Controls.Add(checkBox3);
+
+ //----------------------------------Dispenser 5 ------------------------------------------
+Label Label101 = new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="5"
+ };
+ Label101.Location = new Point (5, 205);
+ form1.Controls.Add(Label101);
+
+ TextBox TextBox6 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text =Text_TI
+ };
+TextBox6.Location = new Point (20, 200);
+TextBox6.CharacterCasing = CharacterCasing.Upper;
+ form1.Controls.Add(TextBox6); //dispencer 5
+
+ TextBox Press4 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press4.Location = new Point (135, 200);
+ form1.Controls.Add(Press4); //dispencer5
+
+ TextBox PartNm4 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm4.Location = new Point (250, 200);
+ form1.Controls.Add(PartNm4); //dispencer 5
+ CheckBox checkBox4 = new CheckBox();
+ checkBox4.Location = new Point (370, 200);
+ form1.Controls.Add(checkBox4);
+
+ //----------------------------------Dispenser 6 ------------------------------------------
+Label Label106= new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="6"
+ };
+ Label106.Location = new Point (5, 245);
+ form1.Controls.Add(Label106);
+
+ TextBox TextBox7 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text =""
+ };
+TextBox7.Location = new Point (20, 240);
+TextBox7.CharacterCasing = CharacterCasing.Upper;
+ form1.Controls.Add(TextBox7); //dispencer 6
+
+ TextBox Press5 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press5.Location = new Point (135, 240);
+ form1.Controls.Add(Press5); //dispencer6
+
+ TextBox PartNm5 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm5.Location = new Point (250, 240);
+ form1.Controls.Add(PartNm5); //dispencer 6
+ CheckBox checkBox5 = new CheckBox();
+ checkBox5.Location = new Point (370, 240);
+ form1.Controls.Add(checkBox5);
+
+ //----------------------------------Dispenser 7 ------------------------------------------
+Label Label107= new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="7"
+ };
+ Label107.Location = new Point (5, 285);
+ form1.Controls.Add(Label107);
+
+ TextBox TextBox8 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text =""
+ };
+TextBox8.Location = new Point (20, 280);
+TextBox8.CharacterCasing = CharacterCasing.Upper;
+ form1.Controls.Add(TextBox8); //dispencer 7
+
+ TextBox Press6 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press6.Location = new Point (135, 280);
+ form1.Controls.Add(Press6); //dispencer7
+
+ TextBox PartNm6 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm6.Location = new Point (250, 280);
+ form1.Controls.Add(PartNm6); //dispencer 6
+ CheckBox checkBox6 = new CheckBox();
+ checkBox6.Location = new Point (370, 280);
+ form1.Controls.Add(checkBox6);
+
+//----------------------------------Dispenser 8 ------------------------------------------
+Label Label108= new Label ()
+ {
+ Width = 10,
+ Height = 20,
+ Text ="8"
+ };
+ Label108.Location = new Point (5, 325);
+ form1.Controls.Add(Label108);
+
+ TextBox TextBox9 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text =""
+ };
+TextBox9.Location = new Point (20, 320);
+TextBox9.CharacterCasing = CharacterCasing.Upper;
+ form1.Controls.Add(TextBox9); //dispencer 8
+
+ TextBox Press7 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+Press7.Location = new Point (135, 320);
+ form1.Controls.Add(Press7); //dispencer8
+
+ TextBox PartNm7 = new TextBox ()
+ {
+ Width = 100,
+ Height = 10,
+ Text = ""
+
+ };
+PartNm7.Location = new Point (250, 320);
+ form1.Controls.Add(PartNm7); //dispencer 7
+ CheckBox checkBox7 = new CheckBox();
+ checkBox7.Location = new Point (370, 320);
+ form1.Controls.Add(checkBox7);
+
+ //-----------------------------File name -----------------------------------------
+ TextBox TextBox10 = new TextBox ()
+ {
+ Width = 210,
+ Height = 10,
+ Text =""
+ };
+TextBox10.Location = new Point (270, 10);
+TextBox10.CharacterCasing = CharacterCasing.Upper;
+form1.Controls.Add(TextBox10);
+//-----------------------------Dispenser Serial Number----------------------------------------
+
+Label Label1 = new Label ()
+ {
+ Width = 100,
+ Height = 40,
+ Text =" Dispenser S/N"
+ };
+Label1.Location = new Point (20, 32);
+ form1.Controls.Add(Label1);
+//-----------------------------PCB Serial Number----------------------------------------
+
+Label Label109 = new Label ()
+ {
+ Width = 100,
+ Height = 40,
+ Text =" PCB S/N"
+ };
+Label109.Location = new Point (135, 32);
+ form1.Controls.Add(Label109);
+ //-----------------------------Dispenser Part Number----------------------------------------
+
+Label Labe2109 = new Label ()
+ {
+ Width = 100,
+ Height = 40,
+ Text =" Dispenser P/N"
+ };
+Labe2109.Location = new Point (250, 32);
+ form1.Controls.Add(Labe2109);
+ //-----------------------------Pass----------------------------------------
+
+Label Labe3109 = new Label ()
+ {
+ Width = 100,
+ Height = 40,
+ Text ="Pass"
+ };
+Labe3109.Location = new Point (360, 32);
+ form1.Controls.Add(Labe3109);
+
+
+//---------------------- Seal Test --------------------------------------------
+Button button1 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+
+ button1.Location = new Point (X_location,Y_location);
+ button1.Text = "Seal Test";
+form1.Controls.Add(button1);
+//------------------------------------Priming --------------------------------------------
+Button button2 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button2.Location = new Point (X_location+110,Y_location);
+ button2.Text = "Priming";
+ form1.Controls.Add(button2);
+//------------------------------------Empty Process --------------------------------------------
+Button button3 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button3.Location = new Point (X_location+110,Y_location+220);
+button3.Text = "Empty Process";
+ form1.Controls.Add(button3);
+//----------------------------------------- Load EEprom ---------------------------------------
+Button button4 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button4.Location = new Point (X_location+220,Y_location);
+ button4.Text = "Load EEprom";
+ form1.Controls.Add(button4);
+//---------------------------------------Save EEprom -----------------------------------------
+Button button5 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button5.Location = new Point (X_location+220,Y_location+110);
+ button5.Text = "Save EEprom";
+ form1.Controls.Add(button5);
+//----------------------------------------Motor_Up ----------------------------------------
+Button button6 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button6.Location = new Point (X_location+330,Y_location);
+ button6.Text = "Up";
+ form1.Controls.Add(button6);
+
+//--------------------------------------Motor_Down------------------------------------------
+Button button7 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button7.Location = new Point (X_location+330,Y_location+110);
+ button7.Text = "Down";
+ form1.Controls.Add(button7);
+//-------------------------------------Dynamic sealing positive pressure-------------------------------------------
+Button button8 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button8.Location = new Point (X_location,Y_location+110);
+ button8.Text = "Dynamic sealing positive pressure";
+ form1.Controls.Add(button8);
+//---------------------------------- Dynamic sealing negative pressure ----------------------------------------------
+Button button9 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+
+ button9.Location = new Point (X_location,Y_location+220);
+ button9.Text = "Dynamic sealing negative pressure";
+ form1.Controls.Add(button9);
+//-------------------------------- Flow Test------------------------------------------------
+Button button10 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button10.Location = new Point (X_location+110,Y_location+110);
+ button10.Text = "Flow Test";
+ form1.Controls.Add(button10);
+//---------------------------------------Spare -----------------------------------------
+Button button11 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+button11.Location = new Point (X_location+330,Y_location+220);
+button11.Text = "spare3";
+ form1.Controls.Add(button11);
+//-------------------------------------Valve Open-------------------------------------------
+Button button12 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button12.Location = new Point (X_location+440,Y_location);
+ button12.Text = "Open Valve";
+ form1.Controls.Add(button12);
+//-------------------------------------Valve Close -------------------------------------------
+Button button13 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button13.Location = new Point (X_location+440,Y_location+110);
+ button13.Text = "Close Valve";
+ form1.Controls.Add(button13);
+//-----------------------------------Reliability Test ---------------------------------------------
+Button button14 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button14.Location = new Point (X_location+220,Y_location+220);
+ button14.Text = "Reliability Test";
+ form1.Controls.Add(button14);
+ //-----------------------------------Pressure build up ---------------------------------------------
+Button button15 = new Button ()
+ {
+ Width = 100,
+ Height = 100,
+ };
+ button15.Location = new Point (X_location+440,Y_location+220);
+ button15.Text = "Pressure build up";
+ form1.Controls.Add(button15);
+ //------------------------------- load file.. -------------------------------------------------
+Button button16 = new Button ()
+ {
+ Width = 100,
+ Height = 20,
+ };
+ button16.Location = new Point (160, 10);
+ button16.Text = "Load file";
+ form1.Controls.Add(button16);
+//------------------------------------run file --------------------------------------------
+Button button17 = new Button ()
+ {
+ Width = 100,
+ Height = 20,
+ };
+ button17.Location = new Point (490, 10);
+ button17.BackColor = System.Drawing.Color.Green;
+ button17.Text = "Run";
+ form1.Controls.Add(button17);
+//------------------------------------stop --------------------------------------------
+Button button18 = new Button ()
+ {
+ Width = 100,
+ Height = 20,
+ };
+ button18.Text = "Stop";
+ button18.BackColor = System.Drawing.Color.Red;
+ button18.Location = new System.Drawing.Point(600, 10);
+ button18.Enabled =false;
+
+ form1.Controls.Add(button18);
+//--------------DispPress--------------------------------------------------------------------
+// void DispPress ()
+// {
+// Press0.Text=Dispenser_press[0].ToString();
+// Press1.Text=Dispenser_press[1].ToString();
+// Press2.Text=Dispenser_press[2].ToString();
+// Press3.Text=Dispenser_press[3].ToString();
+// Press4.Text=Dispenser_press[4].ToString();
+// Press5.Text=Dispenser_press[5].ToString();
+// Press6.Text=Dispenser_press[6].ToString();
+// Press7.Text=Dispenser_press[7].ToString();
+// }
+
+
+//---------------------- Seal Test --------------------------------------------
+ button1.Click +=async (_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(SealTest_Table,"SealTest");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+//------------------------------------Priming --------------------------------------------
+ button2.Click += async(_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(Priming_Table,"Priming");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+//------------------------------------Empty Process --------------------------------------------
+
+ button3.Click += async (_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(EmptyProcess_Table,"EmptyProcess");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+
+//----------------------------------------- Load EEprom ---------------------------------------
+ button4.Click += (_,__) =>
+ {
+ disable_test();
+ Load_EEPROM();
+ LoadDispenserName();
+ enable_test();
+ };
+
+//----------------------------------------- save EEprom ---------------------------------------
+
+ button5.Click += (_,__) =>
+ {
+ disable_test();
+ Dispenser_name[0] = (TextBox1.Text);
+ Dispenser_name[1] = (TextBox3.Text);
+ Dispenser_name[2] = (TextBox4.Text);
+ Dispenser_name[3] = (TextBox5.Text);
+ Dispenser_name[4] = (TextBox6.Text);
+ Dispenser_name[5] = (TextBox7.Text);
+ Dispenser_name[6] = (TextBox8.Text);
+ Dispenser_name[7] = (TextBox9.Text);
+
+ PCB_SN[0]=(Press0.Text);
+ PCB_SN[1]=(Press1.Text);
+ PCB_SN[2]=(Press2.Text);
+ PCB_SN[3]=(Press3.Text);
+ PCB_SN[4]=(Press4.Text);
+ PCB_SN[5]=(Press5.Text);
+ PCB_SN[6]=(Press6.Text);
+ PCB_SN[7]=(Press7.Text);
+
+ Dispenser_PN[0]=(PartNm0.Text);
+ Dispenser_PN[1]=(PartNm1.Text);
+ Dispenser_PN[2]=(PartNm2.Text);
+ Dispenser_PN[3]=(PartNm3.Text);
+ Dispenser_PN[4]=(PartNm4.Text);
+ Dispenser_PN[5]=(PartNm5.Text);
+ Dispenser_PN[6]=(PartNm6.Text);
+ Dispenser_PN[7]=(PartNm7.Text);
+
+
+ //-----------------------------------------
+ if (checkBox0.Checked)
+ {
+ Empty_EEprom[0] = 80; //"P"
+ Dry_Run_EEprom[0]= 80; //"P"
+ Flow_EEprom[0]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[0] = 70; //"F"
+ Dry_Run_EEprom[0]= 70; //"F"
+ Flow_EEprom[0]= 70; //"F"
+ }
+//-----------------------------------------
+ if (checkBox1.Checked)
+ {
+ Empty_EEprom[1] = 80; //"P"
+ Dry_Run_EEprom[1]= 80; //"P"
+ Flow_EEprom[1]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[1] = 70; //"F"
+ Dry_Run_EEprom[1]= 70; //"F"
+ Flow_EEprom[1]= 70; //"F"
+ }
+//-----------------------------------------
+ if (checkBox2.Checked)
+ {
+ Empty_EEprom[2] = 80; //"P"
+ Dry_Run_EEprom[2]= 80; //"P"
+ Flow_EEprom[2]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[2] = 70; //"F"
+ Dry_Run_EEprom[2]= 70; //"F"
+ Flow_EEprom[2]= 70; //"F"
+ }
+//-----------------------------------------
+ if (checkBox3.Checked)
+ {
+ Empty_EEprom[3] = 80; //"P"
+ Dry_Run_EEprom[3]= 80; //"P"
+ Flow_EEprom[3]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[3] = 70; //"F"
+ Dry_Run_EEprom[3]= 70; //"F"
+ Flow_EEprom[3]= 70; //"F"
+ }
+//-----------------------------------------
+ if (checkBox4.Checked)
+ {
+ Empty_EEprom[4] = 80; //"P"
+ Dry_Run_EEprom[4]= 80; //"P"
+ Flow_EEprom[4]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[4] = 70; //"F"
+ Dry_Run_EEprom[4]= 70; //"F"
+ Flow_EEprom[4]= 70; //"F"
+ }
+//-----------------------------------------
+ if (checkBox5.Checked)
+ {
+ Empty_EEprom[5] = 80; //"P"
+ Dry_Run_EEprom[5]= 80; //"P"
+ Flow_EEprom[5]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[5] = 70; //"F"
+ Dry_Run_EEprom[5]= 70; //"F"
+ Flow_EEprom[5]= 70; //"F"
+ }
+//-----------------------------------------
+ if (checkBox6.Checked)
+ {
+ Empty_EEprom[6] = 80; //"P"
+ Dry_Run_EEprom[6]= 80; //"P"
+ Flow_EEprom[6]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[6] = 70; //"F"
+ Dry_Run_EEprom[6]= 70; //"F"
+ Flow_EEprom[6]= 70; //"F"
+ }
+//-----------------------------------------
+ if (checkBox7.Checked)
+ {
+ Empty_EEprom[7] = 80; //"P"
+ Dry_Run_EEprom[7]= 80; //"P"
+ Flow_EEprom[7]= 80; //"P"
+ }
+ else
+ {
+ Empty_EEprom[7] = 70; //"F"
+ Dry_Run_EEprom[7]= 70; //"F"
+ Flow_EEprom[7]= 70; //"F"
+ }
+
+ Save_EEPROM();
+ enable_test();
+
+ };
+ //----------------------------------------Motor_Up ----------------------------------------
+ button6.Click +=async(_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(Up_Table,"MotorUp");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+
+ }
+ };
+//--------------------------------------Motor_Down Homing------------------------------------------
+ button7.Click += async(_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(Down_Table,"Homing");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+
+ }
+ };
+//-------------------------------------Dynamic sealing positive pressure-------------------------------------------
+
+ button8.Click += async(_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(DynamicPositive_Table,"Dynamic Positive");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+//---------------------------------- Dynamic sealing negative pressure ----------------------------------------------
+ button9.Click +=async (_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(DynamicNegative_Table,"Dynamic Negative");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+//-------------------------------- Flow Test------------------------------------------------
+ button10.Click += async(_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(Flow_Table,"Flow Test");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+
+//---------------------------------------Homing no need -----------------------------------------
+// button11.Click += (_,__) =>
+// {
+// ButtonName = "Homing";
+// Dispenser_name[0] = (TextBox1.Text);
+// Dispenser_name[1] = (TextBox3.Text);
+// Dispenser_name[2] = (TextBox4.Text);
+// Dispenser_name[3] = (TextBox5.Text);
+// Dispenser_name[4] = (TextBox6.Text);
+// Dispenser_name[5] = (TextBox7.Text);
+// Dispenser_name[6] = (TextBox8.Text);
+// Dispenser_name[7] = (TextBox9.Text);
+// Table=2;
+//
+// DispenserSetup();
+// };
+//-------------------------------------Valve Open-------------------------------------------
+
+ button12.Click += (_,__) =>
+ {
+ ButtonName = "Open Valve";
+ valveopen(stubManager);
+ };
+
+//-------------------------------------Valve Close -------------------------------------------
+ button13.Click += (_,__) =>
+ {
+ ButtonName = "Close Valve";
+ valveclose(stubManager);
+ };
+
+//-----------------------------------Reliability Test ---------------------------------------------
+ button14.Click += async(_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(Reliability_Table,"Reliability Test");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+ //-----------------------------------Pressure build up ---------------------------------------------
+ button15.Click += async(_,__) =>
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ var longRunningTask =await DispenserSetup(BuildUp_Table,"Pressure Build Up");
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ };
+
+//------------------------------- load file.. -------------------------------------------------
+ button16.Click += (_,__) =>
+ {
+ try
+ {
+ Thread t = new Thread(() => {
+ OpenFileDialog dlg = new OpenFileDialog();
+ // The following would not return the dialog if the current
+ // thread is not STA
+ dlg.Filter = "TBL|*.tbl";
+ if(dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ {
+ TextBox10.Text= dlg.SafeFileName;
+ Tbl_File_Name=TextBox10.Text;
+ }
+ });
+ t.SetApartmentState(ApartmentState.STA);
+ t.Start();
+ }
+ catch (Exception ex)
+ {
+ stubManager.WriteLine("exseption");
+ //ex.LogException();
+ }
+ };
+ //------------------------------------run file --------------------------------------------
+ button17.Click += async(_,__) =>
+ {
+ // stubManager.WriteLine(Tbl_File_Name +" -1");
+
+ if ((ConverFileToTBL(Tbl_File_Name)) ==0)
+ {
+ stubManager.WriteLine(Tbl_File_Name +" --ok");
+
+ _cancellationTokenSource = new CancellationTokenSource();
+ try
+ {
+ disable_test();
+ string[] FileName = Tbl_File_Name.Split('.');
+ var longRunningTask =await DispenserSetup(Start_Table,FileName[0]);
+ }
+ catch (OperationCanceledException)
+ {
+ enable_test();
+ // Status="Cancel";
+ stubManager.WriteLine("Task was cancelled");
+ }
+ finally
+ {
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("end Task ");
+ enable_test();
+ }
+ }
+ else
+ {
+ _cancellationTokenSource = new CancellationTokenSource();
+ _cancellationTokenSource.Dispose();
+ stubManager.WriteLine("Error Table ");
+ }
+
+ };
+//------------------------------------stop --------------------------------------------
+ button18.Click += (_, __) =>
+ {
+ _cancellationTokenSource.Cancel();
+ stubManager.WriteLine("stop ");
+
+ // ButtonName = "Stop";
+
+
+ //TextBox1.Text ="";
+ };
+
+ //--------------------load dispenser name ------------------------
+ void LoadDispenserName ()
+ {
+ (TextBox1.Text) = Dispenser_name[0];
+ (TextBox3.Text) = Dispenser_name[1];
+ (TextBox4.Text) = Dispenser_name[2];
+ (TextBox5.Text) = Dispenser_name[3];
+ (TextBox6.Text) = Dispenser_name[4];
+ (TextBox7.Text) = Dispenser_name[5];
+ (TextBox8.Text) = Dispenser_name[6];
+ (TextBox9.Text) = Dispenser_name[7];
+
+
+ (Press0.Text)=PCB_SN[0];
+ (Press1.Text)=PCB_SN[1];
+ (Press2.Text)=PCB_SN[2];
+ (Press3.Text)=PCB_SN[3];
+ (Press4.Text)=PCB_SN[4];
+ (Press5.Text)=PCB_SN[5];
+ (Press6.Text)=PCB_SN[6];
+ (Press7.Text)=PCB_SN[7];
+
+ (PartNm0.Text)=Dispenser_PN[0];
+ (PartNm1.Text)=Dispenser_PN[1];
+ (PartNm2.Text)=Dispenser_PN[2];
+ (PartNm3.Text)=Dispenser_PN[3];
+ (PartNm4.Text)=Dispenser_PN[4];
+ (PartNm5.Text)=Dispenser_PN[5];
+ (PartNm6.Text)=Dispenser_PN[6];
+ (PartNm7.Text)=Dispenser_PN[7];
+
+
+ }
+
+
+//--------------------disabele test ------------------------
+ void disable_test()
+ {
+
+ if ( (listBox1.SelectedItem)=="Press-Sensor -1 to 10 Bar")
+ {
+ stubManager.WriteLine("Press_Sensor_Type=1");
+ Press_Sensor_Type=1;
+ }
+ else
+ {
+ stubManager.WriteLine("Press_Sensor_Type=0");
+ Press_Sensor_Type=0;
+ }
+
+ button1.Enabled =false;
+ button2.Enabled =false;
+ button3.Enabled =false;
+ button4.Enabled =false;
+ button5.Enabled =false;
+ button6.Enabled =false;
+ button7.Enabled =false;
+ button8.Enabled =false;
+ button9.Enabled =false;
+ button10.Enabled =false;
+ button11.Enabled =false;
+ button12.Enabled =false;
+ button13.Enabled =false;
+ button14.Enabled =false;
+ button15.Enabled =false;
+ button16.Enabled =false;
+ button17.Enabled =false;
+ button18.Enabled =true;
+
+
+ Dispenser_name[0] = (TextBox1.Text);
+ Dispenser_name[1] = (TextBox3.Text);
+ Dispenser_name[2] = (TextBox4.Text);
+ Dispenser_name[3] = (TextBox5.Text);
+ Dispenser_name[4] = (TextBox6.Text);
+ Dispenser_name[5] = (TextBox7.Text);
+ Dispenser_name[6] = (TextBox8.Text);
+ Dispenser_name[7] = (TextBox9.Text);
+
+ PCB_SN[0]=(Press0.Text);
+ PCB_SN[1]=(Press1.Text);
+ PCB_SN[2]=(Press2.Text);
+ PCB_SN[3]=(Press3.Text);
+ PCB_SN[4]=(Press4.Text);
+ PCB_SN[5]=(Press5.Text);
+ PCB_SN[6]=(Press6.Text);
+ PCB_SN[7]=(Press7.Text);
+
+
+ Dispenser_PN[0]=(PartNm0.Text);
+ Dispenser_PN[1]=(PartNm1.Text);
+ Dispenser_PN[2]=(PartNm2.Text);
+ Dispenser_PN[3]=(PartNm3.Text);
+ Dispenser_PN[4]=(PartNm4.Text);
+ Dispenser_PN[5]=(PartNm5.Text);
+ Dispenser_PN[6]=(PartNm6.Text);
+ Dispenser_PN[7]=(PartNm7.Text);
+
+
+
+
+
+ }
+//--------------------enable test ------------------------
+
+ void enable_test()
+ {
+ button1.Enabled =true;
+ button2.Enabled =true;
+ button3.Enabled =true;
+ button4.Enabled =true;
+ button5.Enabled =true;
+ button6.Enabled =true;
+ button7.Enabled =true;
+ button8.Enabled =true;
+ button9.Enabled =true;
+ button10.Enabled =true;
+ button11.Enabled =true;
+ button12.Enabled =true;
+ button13.Enabled =true;
+ button14.Enabled =true;
+ button15.Enabled =true;
+ button16.Enabled =true;
+ button17.Enabled =true;
+ button18.Enabled =false;
+
+ for (Int32 i=0;i<8;i++)
+ {
+ MotorStop(i);
+ }
+
+ // stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,WINDER_Motor,3); //stop motor
+ // stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,SCREW,3); //stop motor
+
+ }
+
+
+
+// Display the form as a modal dialog box.
+ form1.ShowDialog();
+
+
+ for (Int32 i=0;i<8;i++)
+ {
+ MotorStop(i);
+ stubManager.Write("Motor Stop Hard Hiz \t");
+
+ System.IO.File.WriteAllText(@"C:\Dispenser_setup\setup.txt", listBox1.SelectedIndex.ToString());
+
+ stubManager.Write(listBox1.SelectedItem);
+ }
+
+ return;
+}
+
+public int delay(Int32 ms_delay)
+ {
+
+ Thread.Sleep(ms_delay);
+ if (_cancellationTokenSource.Token.IsCancellationRequested)
+ {
+ _cancellationTokenSource.Token.ThrowIfCancellationRequested();
+ throw new TaskCanceledException();
+ return 0;
+ }
+ return 0;
+ }