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_Name2; 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) { string u =System.Environment.UserName; 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 (40, 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 Part Number ----------- Label PN_lbl = new Label () { Width = 150, Height = 20, Text =" P/N" }; PN_lbl.Location = new Point (190, 10); form1.Controls.Add(PN_lbl); TextBox PN_TexstBox = new TextBox () { Width = 150, Height = 20, Text ="" }; PN_TexstBox.Location = new Point (190, 40); PN_TexstBox.CharacterCasing = CharacterCasing.Upper; form1.Controls.Add(PN_TexstBox); //----------Create Lable to LOCATION---------- Label Location_lbl = new Label () { Width = 150, Height = 20, Text ="LOCATION" }; Location_lbl.Location = new Point (440, 10); form1.Controls.Add(Location_lbl); TextBox Location_TexstBox = new TextBox () { Width = 150, Height = 20, Text =Location_str }; Location_TexstBox.Location = new Point (440, 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 Open_Log_btm = new Button() { Width = 100, Height = 40, }; Open_Log_btm.Text = "Open Log File"; Open_Log_btm.BackColor = System.Drawing.Color.Red; Open_Log_btm.Location = new System.Drawing.Point(300, 286); Open_Log_btm.Enabled= false; form1.Controls.Add(Open_Log_btm); Open_Log_btm.Click += (_, __) => { System.Diagnostics.Process.Start(File_Name2 ); }; //-------------------------------------------------------------------------------- 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); disable_test(); 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= false; } // 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() { disable_test(); //enable_test(); Timer_dis(); Open_Log_btm.Enabled= true; 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; } } PN_TexstBox.TextChanged += (_,__)=> { string temp; if (SN_TexstBox.Text.Length!=15) { disable_test(); return; } if (PN_TexstBox.Text.Contains("-")) { temp=PN_TexstBox.Text.Substring(0, PN_TexstBox.Text.IndexOf("-")); switch (temp) { case "AM00315": //DyeHead NewDyeHead_btm.Enabled= true; break; case "AM00103": //Winder Winder_btm.Enabled = true; break; case "AM00087": //MidTank MidTank_btm.Enabled = true; break; case "AM00031": //LTFU LTFU_btm.Enabled = true; break; case "AM00007": //Dryer Dryer_btm.Enabled = true; break; case "AM00030": //RTFU RTFU_btm.Enabled = true; break; case "AM00281": //New Mixer NewMixer_btm.Enabled= true; break; // case "AM00281": // Mixer // Mixer_btm.Enabled= true; // break; default: disable_test(); break; } } else disable_test(); }; SN_TexstBox.TextChanged += (_,__)=> { string temp; if (SN_TexstBox.Text.Length!=15) { disable_test(); return; } if (PN_TexstBox.Text.Contains("-")) { temp=PN_TexstBox.Text.Substring(0, PN_TexstBox.Text.IndexOf("-")); switch (temp) { case "AM00315": //DyeHead NewDyeHead_btm.Enabled= true; break; case "AM00103": //Winder Winder_btm.Enabled = true; break; case "AM00087": //MidTank MidTank_btm.Enabled = true; break; case "AM00031": //LTFU LTFU_btm.Enabled = true; break; case "AM00007": //Dryer Dryer_btm.Enabled = true; break; case "AM00030": //RTFU RTFU_btm.Enabled = true; break; case "AM00286": //New Mixer NewMixer_btm.Enabled= true; break; default: disable_test(); break; // case "AM00281": // Mixer // Mixer_btm.Enabled= true; // break; } } else disable_test(); }; //----------------------------------------- Winder_btm.Click += async(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- Winder "); // path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Winder\\" ; path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Winder\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); Winder_btm.Enabled = false; Stop_btm.Enabled= true; var longRunningTask = await Winder_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_test(); Status="Cancel"; stubManager.Run("StubMotorStopRequest" ,WINDER_Motor,3); //stop motor stubManager.Run("StubMotorStopRequest" ,SCREW,3); //stop motor stubManager.WriteLine("Task was cancelled"); } finally { _cancellationTokenSource.Dispose(); } end_test(); }; //----------------------------------------- LTFU_btm.Click += async(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- LTFU "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\LTFU\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); LTFU_btm.Enabled = false; Stop_btm.Enabled= true; var longRunningTask = await LTFU_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_test(); Status="Cancel"; stubManager.Run("StubMotorStopRequest" ,LLOADING_Motor, 3); //hold LRoading high z stubManager.Run("StubMotorStopRequest" ,LDANCER1_Motor, 3); //hold Lloading high z stubManager.Run("StubMotorStopRequest" ,LDANCER2_Motor, 3); //hold Lloading high z stubManager.Run("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(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- Dryer "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Dryer\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); Dryer_btm.Enabled = false; Stop_btm.Enabled= true; var longRunningTask = await Dryer_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_test(); Status="Cancel"; stubManager.Run("StubMotorStopRequest" ,DryerLid_Motor, 2); //Hard stop hiZ motor stubManager.Run("StubMotorStopRequest" ,DryerMain_Motor,3); //stop motor stubManager.Run("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(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- DyeHead "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\DyeHead\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); DyeHead_btm.Enabled= false; Stop_btm.Enabled= true; var longRunningTask = await DyeHead_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_test(); Status="Cancel"; stubManager.Run("StubMotorStopRequest" ,MAGNET_Driver,3); //stop magnet stubManager.Run("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(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- New DyeHead "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\NewDyeHead\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); NewDyeHead_btm.Enabled= false; Stop_btm.Enabled= true; var longRunningTask = await NewDyeHead_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_test(); Status="Cancel"; stubManager.Run("StubMotorStopRequest" ,MAGNET_Driver,3); //stop magnet stubManager.Run("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor for (Int32 i = 0; i < 12; i++) //???MF { stubManager.Run("ProgressRequest" ,0x0EAD,0x40F000 + i*0x100); // turn all heaters OFF Thread.Sleep(10); } stubManager.WriteLine("Task was cancelled"); } finally { _cancellationTokenSource.Dispose(); } end_test(); }; //----------------------------------------- RTFU_btm.Click += async(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- RTFU "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\RTFU\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); RTFU_btm.Enabled= false; Stop_btm.Enabled= true; var longRunningTask = await RTFU_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_test(); Status="Cancel"; stubManager.Run("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("StubMotorStopRequest" ,RDANCER_Motor, 3); //hold Rloading high z stubManager.Run("StubMotorStopRequest" ,RDRIVING_Motor,3); //stop motor stubManager.WriteLine("Task was cancelled"); } finally { _cancellationTokenSource.Dispose(); } end_test(); }; //----------------------------------------- MidTank_btm.Click += async(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- MidTank "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\MidTank\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); MidTank_btm.Enabled= false; Stop_btm.Enabled= true; var longRunningTask = await MidTank_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_test(); Status="Cancel"; stubManager.Run("StubFpgaWriteRegRequest" ,F3_VALVE_OUT, 0); //close all valve stubManager.WriteLine("Task was cancelled"); } finally { _cancellationTokenSource.Dispose(); } end_test(); }; //---------------------------Mixer-------------- Mixer_btm.Click += async(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- Mixer "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Mixer\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); Mixer_btm.Enabled= false; Stop_btm.Enabled= true; var longRunningTask = await Mixer_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_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(_,__) => { Open_Log_btm.Enabled= false; Run_text.Text = "Run"; stubManager.WriteLine("DUT- New Mixer "); path="C:\\Users\\" + u + "\\Dropbox\\"+Location_TexstBox.Text +"_Bench_Tester"+"\\Mixer\\" ; Timer_en(); _cancellationTokenSource = new CancellationTokenSource(); try { // disable_test(); NewMixer_btm.Enabled= false; Stop_btm.Enabled= true; var longRunningTask = await New_Mixer_test(setLabel1TextSafe, _cancellationTokenSource.Token, SN_TexstBox.Text ,Location_TexstBox.Text ); } catch (OperationCanceledException) { disable_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("StubFpgaWriteRegRequest" ,Addr, Data); return 1; } StubFpgaReadRegResponse Fpga_Read_Reg(Int32 Addr) { var response = stubManager.Run("StubFpgaReadRegRequest" ,Addr); response.Value = response.Value & 0xffff; return response; } float Read_pt100(int i) { var response = stubManager.Run("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("StubFpgaWriteRegRequest" ,HighAdr, (Temp & 0xffff)); Temp = ((Int32)ParaData1 >> 8) & 0xffff; stubManager.Run("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(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(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(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; }