diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-12-01 18:28:41 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-12-01 18:28:41 +0200 |
| commit | beec9e4961b89d0146ca6cf8d4c42b5b7a94fed0 (patch) | |
| tree | 7c2ce66244fc50604331fa40ca33ae420764b033 /Software/Stubs Collection/stubs/Scripts | |
| parent | e1ee0eafc192d6df9fa41a2749d016473d7563f4 (diff) | |
| download | Tango-beec9e4961b89d0146ca6cf8d4c42b5b7a94fed0.tar.gz Tango-beec9e4961b89d0146ca6cf8d4c42b5b7a94fed0.zip | |
several changes in stubs, some fixes, stub for WHS v0 read
Diffstat (limited to 'Software/Stubs Collection/stubs/Scripts')
10 files changed, 403 insertions, 5 deletions
diff --git a/Software/Stubs Collection/stubs/Scripts/CalculateContinuous.cs b/Software/Stubs Collection/stubs/Scripts/CalculateContinuous.cs new file mode 100644 index 000000000..443df9008 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/CalculateContinuous.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; + +public void OnExecute(StubManager stubManager) +{ + int i = 0; + //for (int i = 0; i < 10; i++) + { + // Request ---- + // Double : A + // Double : B + + // Response ---- + // Double : Sum + CalculateRequest calculateRequest = new CalculateRequest(); + calculateRequest.A = 1; + calculateRequest.B = 1; + + //var response = stubManager.RunContinuous<CalculateResponse>("CalculateRequest",0,2,Write); + stubManager.RunContinuous<CalculateResponse>(calculateRequest,(response1) => + { + stubManager.WriteLine (String.Format("Data, {0} {1}",++i,response1.Sum)); + }); + + /*if (response.Sum == 15) + { + stubManager.Write(i); + stubManager.WriteLine(" OK!"); + } + Thread.Sleep(10);*/ + } +} + diff --git a/Software/Stubs Collection/stubs/Scripts/ChangePidDuringRun.cs b/Software/Stubs Collection/stubs/Scripts/ChangePidDuringRun.cs new file mode 100644 index 000000000..9422e2cdc --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/ChangePidDuringRun.cs @@ -0,0 +1,52 @@ +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.Hardware; +using Tango.Stubs; + +public void OnExecute(StubManager stubManager) +{ +StubHeatingTestRequest stubHeatingTestRequest = new StubHeatingTestRequest(); + +stubHeatingTestRequest.DryerZone1Temp = 0; +stubHeatingTestRequest.DryerZone2Temp = 0; + +HardwarePidControl hardwarePidControl = new HardwarePidControl(); +hardwarePidControl.OutputProportionalPowerLimit = 0.5; //Maximal additional power +hardwarePidControl.OutputProportionalBand = 5; +hardwarePidControl.DerivativeTime = 0; //Kd +hardwarePidControl.SensorCorrectionAdjustment = 0; +hardwarePidControl.SensorMinValue = 0; +hardwarePidControl.SensorMaxValue = 0; +hardwarePidControl.SetPointRampRateorSoftStartRamp = 100; //Ki divider +hardwarePidControl.SetPointControlOutputRate = 0; +hardwarePidControl.ControlOutputType = 0.001; ////Dt +hardwarePidControl.SsrControlOutputType = 0; +hardwarePidControl.OutputOnOffHysteresisValue = 100; //Kp divider +hardwarePidControl.ProcessVariableSamplingRate = 10; +hardwarePidControl.PvInputFilterFactorMode = 4; //averaging the readouts / number of samples +hardwarePidControl.OutputProportionalCycleTime = 0; +hardwarePidControl.AcHeatersHalfCycleTime = 0; +hardwarePidControl.PidActive = false; +hardwarePidControl.Epsilon = 0; +hardwarePidControl.OutputOnOffHysteresisValue = 100; + +hardwarePidControl.HardwarePidControlType = Tango.PMR.Hardware.HardwarePidControlType.MotorWinder; +hardwarePidControl.IntegralTime = 8000; //Ki +hardwarePidControl.ProportionalGain = 7000; //Kp + +stubHeatingTestRequest.HardwarePidControl1 = hardwarePidControl; + +StubHeatingTestPollRequest stubHeatingTestPollRequest = new StubHeatingTestPollRequest(); + +var response = stubManager.Run<StubHeatingTestResponse>(stubHeatingTestRequest); + + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Priming1.pproj b/Software/Stubs Collection/stubs/Scripts/Priming1.pproj new file mode 100644 index 000000000..4a7f5fcc3 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Priming1.pproj @@ -0,0 +1 @@ +{"$id":"1","Visibility":"Public","Inputs":{"$id":"2","$values":[]},"Variables":{"$id":"3","$values":[]},"Resources":{"$id":"4","$values":[]},"Dialogs":{"$id":"5","$values":[]},"ID":"eb73dbd4-1e1e-4f5d-adc8-5f159edab802","Name":"Priming1","Description":"Used for a dispenser priming","ApartmentState":"STA","ReferenceAssemblies":{"$id":"6","$values":[{"$id":"7","File":"C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll","HintType":"System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"8","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Core\\v4.0_4.0.0.0__b77a5c561934e089\\System.Core.dll","HintType":"System.Linq.Enumerable, System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"9","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Windows.Forms\\v4.0_4.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll","HintType":"System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"},{"$id":"10","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.FSE.Procedures.dll","HintType":"Tango.FSE.Procedures.ProcedureProject, Tango.FSE.Procedures, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"11","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.FSE.Common.dll","HintType":"Tango.FSE.Common.Diagnostics.IDiagnosticsProvider, Tango.FSE.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"12","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.BL.dll","HintType":"Tango.BL.Enumerations.TechMonitors, Tango.BL, Version=2.0.36.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"13","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.PMR.dll","HintType":"Tango.PMR.Common.MessageType, Tango.PMR, Version=2.0.40.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"14","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.Transport.dll","HintType":"Tango.Transport.ITransporter, Tango.Transport, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"},{"$id":"15","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Tango.Integration.dll","HintType":"Tango.Integration.Operation.IMachineOperator, Tango.Integration, Version=2.0.31.1608, Culture=neutral, PublicKeyToken=null"},{"$id":"16","File":"C:\\Program Files (x86)\\Twine Solutions LTD\\Tango FSE\\Google.Protobuf.dll","HintType":"Google.Protobuf.IMessage, Google.Protobuf, Version=3.4.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604"},{"$id":"17","File":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Drawing\\v4.0_4.0.0.0__b03f5f7f11d50a3a\\System.Drawing.dll","HintType":"System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"}]},"Scripts":{"$id":"18","$values":[{"$id":"19","Name":"Program.csx","IsEntryPoint":true,"Code":"using System;\r\nusing System.Collections.Generic;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing System.Drawing;\r\nusing Google.Protobuf;\r\nusing Tango.BL.Entities;\r\nusing Tango.BL.Enumerations;\r\nusing Tango.PMR.Stubs;\r\nusing Tango.PMR.Diagnostics;\r\nusing Tango.FSE.Common.Connection;\r\nusing Tango.FSE.Common.Diagnostics;\r\nusing Tango.FSE.Procedures;\r\nusing System.IO;\r\nusing System.Diagnostics;\r\nusing System.Windows.Forms;\r\n\r\n\r\npublic class Program\r\n{\r\n\r\n\r\nprivate IProcedureContext context;\r\n\r\n//---------------------Start Command ----------------\r\nconst Int32\tCMD_RUN\t=\t0;\t\t//Run on Pulse Per Secound .positive run Up and negative run Down b\r\nconst Int32\tCMD_STOP=\t1;\t\t//0;Hard stop(Defualt);1-Soft stop;2-Hard Hiz;3-Soft Hiz\r\nconst Int32\tCMD_VALVE=\t2;\t\t//0-to Midtank ,1-to head \r\nconst Int32\tCMD_DLY\t=\t3;\t\t//delay in Seconds .\r\nconst Int32\tCMD_TIME=\t4;\t\t//Print Time .\r\nconst Int32\tCMD_PRESS=\t5;\t\t//return from Delay loop when pressure is high (on mBAR) .\r\nconst Int32 CMD_LOOP_NM=6;\t\t//NUMBER OF counter\r\nconst Int32 CMD_LOOP=\t7;\t\t//jump up(+) or down(-) command u\r\nconst Int32 CMD_MTV_OPEN =\t8;\t\t//0 Air ; 1 Ink\r\nconst Int32 CMD_MTV_CLOSE=\t9;\t\t//0 Air ; 1 Ink\r\nconst Int32 CMD_LBL=\t10;\t//label for user \r\nconst Int32 CMD_SMP=\t11; //sample rate ,defualt 100msec (1); for 1 second is 10.\r\nconst Int32 CMD_PRESL=\t12; //return from Delay loop when pressure is low (on mBAR) .\r\n\r\nconst Int32\tCMD_END\t=\t13;\t//end loop .\r\n \r\n\r\nInt32[] BuildUp_Table = new int []\r\n{\r\n\tCMD_LOOP_NM,3,\r\n\r\n\tCMD_VALVE,0,\r\n\tCMD_DLY,1, \r\n\tCMD_VALVE,1,\r\n\tCMD_DLY,1, \r\n\tCMD_LOOP,-4,\r\n\r\n\r\n\tCMD_VALVE,1,\r\n\tCMD_PRESL,800,\r\n\tCMD_DLY,60, \r\n\r\n\r\n\tCMD_VALVE,0,\r\n\tCMD_PRESS,1000,\t//mbar --> 1000 = 100% work, 4000 = 200% work, 350 = 20% work\r\n\tCMD_RUN,1068,\r\n\tCMD_DLY,150, \t\t\r\n\tCMD_LBL,1,\r\n\tCMD_PRESS,2000,\t//mbar --> 2000 = 100% work, 4000 = 200% work, 350 = 20% work\r\n\tCMD_DLY,60, \t\t\r\n\tCMD_LBL,2,\r\n\tCMD_PRESS,3000,\r\n\tCMD_DLY,60, // to limit\r\n\tCMD_STOP,0,\r\n\tCMD_VALVE,1,\r\n\tCMD_DLY,1, \r\n\r\n\t\r\n\tCMD_END,3,\r\n};\r\n\t\r\n\r\nInt32[] Up_Table = new int []\r\n{\r\n\tCMD_VALVE,0,\r\n\tCMD_DLY,1, \r\n\tCMD_VALVE,1,\r\n\tCMD_DLY,1, \r\n\tCMD_LOOP,-4,\r\n\r\n\tCMD_VALVE,1,\r\n\tCMD_PRESL,800,\r\n\tCMD_DLY,60, \r\n\t\r\n\tCMD_PRESS,3000,\t//mbar --> 1000 = 100% work, 4000 = 200% work, 350 = 20% work\r\n\tCMD_RUN,534, // 100%\r\n\tCMD_DLY,120,\r\n\tCMD_STOP,0,\r\n\tCMD_END,3,\r\n};\r\nInt32 Dispenser_sample_rate= 1; \r\n\r\n\tstring path = @\"C:\\Dispenser_setup\\Log\\\"; \t\r\n//----------------------\r\nconst UInt32 I2C_ID \t\t\t= \t4;\t\t\t\t\t//MCU_I2C4 \r\nconst UInt32 TCA9548A_address \t=\t0xE2;\t \t\r\nconst UInt32 I2C_Slave_Low_Add \t= \t0xA0;\t\t\t\t//eeprom address - 64k low \r\nconst UInt32 I2C_Slave_High_Add = \t0xA2;\t\t\t\t//eeprom address - 64k High\r\n//----------------------\r\nbyte [] EEPROM_Data = new byte [128];\r\n\r\n\r\n//---------------------End Command ----------------\r\n\r\nconst Int32\tDispenser_Motor1\t=\t6;\t\t \r\nconst Int32\tDispenser_Motor2\t=\t7;\t\t \r\nconst Int32\tDispenser_Motor3\t=\t8;\t\t \r\nconst Int32\tDispenser_Motor4\t=\t9;\t\t \r\nconst Int32\tDispenser_Motor5\t=\t10;\t\t \r\nconst Int32\tDispenser_Motor6\t=\t11;\t\t \r\nconst Int32\tDispenser_Motor7\t=\t12;\t\t \r\nconst Int32\tDispenser_Motor8\t=\t13;\t\t \r\n\r\nconst Int32 AN_IDS_PRESSENS_1\t=\t2;\r\nconst Int32 AN_IDS_PRESSENS_2\t=\t3;\r\nconst Int32 AN_IDS_PRESSENS_3\t=\t4;\r\nconst Int32 AN_IDS_PRESSENS_4\t=\t5;\r\nconst Int32 AN_IDS_PRESSENS_5\t=\t6;\r\nconst Int32 AN_IDS_PRESSENS_6\t=\t7;\r\nconst Int32 AN_IDS_PRESSENS_7\t=\t8;\r\nconst Int32 AN_IDS_PRESSENS_8\t=\t9;\r\n\r\nconst Int32\tF2_LS_01_Direct\t=\t0x60000420\t;\t//\tReads the direct values that are currently being sent to the fpga.\trsv\t\trsv\t\trsv\t\t\t\t\t\trsv\t\t\t\t\t\tF2_LS_DISPENSER_UP_2\tF2_LS_DISPENSER_25_2\tF2_LS_DISPENSER_75_2\tF2_LS_DISPENSER_DOWN_2 \tF2_LS_DISPENSER_50_2\tF2_LS_DISPENSER_SPARE_2\tF2_LS_DISPENSER_UP_1\tF2_LS_DISPENSER_25_1 \tF2_LS_DISPENSER_75_1\tF2_LS_DISPENSER_DOWN_1\tF2_LS_DISPENSER_50_1\tF2_LS_DISPENSER_SPARE_1\t\t\t\r\nconst Int32\tF2_LS_02_Direct\t=\t0x60000430\t;\t//\tReads the direct values that are currently being sent to the fpga.\trsv\t\trsv\t\trsv\t\t\t\t\t\trsv\t\t\t\t\t\tF2_LS_DISPENSER_UP_4\tF2_LS_DISPENSER_25_4\tF2_LS_DISPENSER_75_4\tF2_LS_DISPENSER_DOWN_4\tF2_LS_DISPENSER_50_4\tF2_LS_DISPENSER_SPARE_4\tF2_LS_DISPENSER_UP_3\tF2_LS_DISPENSER_25_3 \tF2_LS_DISPENSER_75_3\tF2_LS_DISPENSER_DOWN_3\tF2_LS_DISPENSER_50_3\tF2_LS_DISPENSER_SPARE_3\t\t\t\r\nconst Int32\tF2_LS_03_Direct\t=\t0x60000440\t;\t//\tReads the direct values that are currently being sent to the fpga.\trsv\t\trsv\t\trsv\t\t\t\t\t\trsv\t\t\t\t\t\tF2_LS_DISPENSER_UP_6 \tF2_LS_DISPENSER_25_6 \tF2_LS_DISPENSER_75_6 \tF2_LS_DISPENSER_DOWN_6\tF2_LS_DISPENSER_50_6\tF2_LS_DISPENSER_SPARE_6\tF2_LS_DISPENSER_UP_5\tF2_LS_DISPENSER_25_5 \tF2_LS_DISPENSER_75_5\tF2_LS_DISPENSER_DOWN_5\tF2_LS_DISPENSER_50_5\tF2_LS_DISPENSER_SPARE_5\t\t\t\r\nconst Int32\tF2_LS_04_Direct =\t0x60000480\t;\t//\tReads the direct values that are currently being sent to the fpga.\trsv\t\trsv\t\trsv\t\t\t\t\t\trsv\t\t\t\t\t\tF2_LS_DISPENSER_UP_8\tF2_LS_DISPENSER_25_8\tF2_LS_DISPENSER_75_8\tF2_LS_DISPENSER_DOWN_8\tF2_LS_DISPENSER_50_8\tF2_LS_DISPENSER_SPARE_8\tF2_LS_DISPENSER_UP_7\tF2_LS_DISPENSER_25_7 \tF2_LS_DISPENSER_75_7\tF2_LS_DISPENSER_DOWN_7\tF2_LS_DISPENSER_50_7\tF2_LS_DISPENSER_SPARE_7\t\t\t\r\n\r\nconst Int32 Dispenser_Valve1\t=\t0;\r\nconst Int32 Dispenser_Valve2\t=\t1;\r\nconst Int32 Dispenser_Valve3\t=\t2;\r\nconst Int32 Dispenser_Valve4\t=\t3;\r\nconst Int32 Dispenser_Valve5\t=\t4;\r\nconst Int32 Dispenser_Valve6\t=\t5;\r\nconst Int32 Dispenser_Valve7\t=\t6;\r\nconst Int32 Dispenser_Valve8\t=\t7;\r\n\r\nconst ushort MinPress_Mbar_Add =0x5c ;\r\nconst ushort MaxPress_Mbar_Add =0x60 ;\r\n\r\nconst Int32 F3_VALVE_OUT\t= 0x600000e2;\t\t\r\n\r\n//string path = \"C:\\\\Dispenser_setup\\\\Log\\\\\"; \r\n\r\n\r\n//Int32[] Start_Table;\r\n\r\nInt32[] Start_Table = new Int32 [10000];\r\n\r\nUInt32 [] Motor_Dir=new UInt32 [8] {0,0,0,0,0,0,0,0};\r\n\r\nstring Dispenser_Fname ;\r\n\r\nInt32 Dispenser_ptr =-1;\r\n\r\nInt32 [] Dispenser_press= new Int32[8]{0,0,0,0,0,0,0,0};\r\nInt32 max_pressure_level = 20000;\r\nInt32 min_pressure_level = -20000;\r\n\t\r\nInt32 [] A2D_Dispenser= new Int32[8]{0,0,0,0,0,0,0,0};\r\nInt32 Loop_cnt= 1;\r\nInt32 Loop_length=1;\r\n\r\nInt32 PressureSensorType= 1;\t\t//1- new -1up +10 . 0-old 0 to +10\r\nInt32\tTemp_Delay=0;\r\n\r\nInt32\tFirst_Delay=0;\r\n\r\n\r\nUInt32 RD_LS_01_Direct;\r\nUInt32 RD_LS_02_Direct;\r\nUInt32 RD_LS_03_Direct;\r\nUInt32 RD_LS_04_Direct;\r\n\r\nlong Lebel1_time;\r\nlong Lebel2_time;\r\nlong End_Time=0;\r\n\r\nlong elapsed_time =0;\r\n\r\nlong time_Table;\r\n\r\nInt32 msec_index=0;\r\n\r\nInt32 MaxPress_Mbar;\r\nInt32 MinPress_Mbar;\r\nstring state;\r\n\r\n\tpublic Int32 OnExecute(IProcedureContext context)\r\n {\r\n\t\tlong Max_PBU;\r\n\t\tInt32 Index=0;\r\n\t\tInt32 speed=0;\r\n\t\tInt32 Dispenser_Nm;\r\n\t\tthis.context = context;\r\n\t\tint Test_Index=0;\r\n \t\t\r\n \r\n\r\n\t\t\r\n\t\tstring box_msg = \"Make sure Mixer Hot \";\r\n\t\tMessageBox.Show(box_msg);\r\n\t\t\r\n\t\tvar response1 = context.RequestUserInputFor<String>(\"Dispenser Number\", \"Enter Dispenser number to make priming (1-8):\");\r\n\t\tcontext.WriteLine(response1);\r\n\t\tDispenser_Nm = Int32.Parse(response1);\r\n\t\t\r\n\t\tcheck_Min_Max_Mbar(Dispenser_Nm);\r\n\t\r\n\t\tif (Dispenser_Nm==8)\r\n\t\t\tMax_PBU=8000;\r\n\t\telse\r\n\t\t\tMax_PBU=6000;\r\n\t\t\t\r\n\t\r\n\tif (!Directory.Exists(path))\r\n\t\t{\r\n\t\t\tDirectory.CreateDirectory(path);\r\n\t\t}\t\r\n\t\t\tcontext.WriteLine(path);\r\n\t\t\t\r\n\tcontext.Send<ProgressResponse>(\"ProgressRequest\" ,0xe0, 1);\r\n\r\n\tDispenser_Fname=path + \"Dispenser_Nm_\" + Dispenser_Nm+\"_\" + DateTime.Now.ToString(\"MM-dd-yy hh-mm\")+ \".csv\" ;\r\n\r\n\tcontext.WriteLine(Dispenser_Fname);\r\n\r\n\tcontext.WriteToFile(Dispenser_Fname,\"Dispenser Nm,\" + Dispenser_Nm + \"\\n\" );\r\n\tcontext.AppendToFile(Dispenser_Fname,\"Pressure,Command,Value,DateTime,Remark\\n\" ); \r\n\t\r\n\tcontext.UpdateProgress(\"Priming\",false,Test_Index,10);\r\n\r\n\tfor(int j=0; j<2;j++)\r\n\t\t{\r\n\t\t\tfor(int i=0; i<4;i++)\r\n\t\t\t{\r\n\t\t\t\tstate=\"PBU No. \"+ (4*j+i+1 );\r\n\t\t\t\tStart_Table=BuildUp_Table;\r\n\t\t\t\tTable_Run(Dispenser_Nm );\r\n\t\t\t\tif (time_Table>300000)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontext.AddResult(ResultType.Failed,\"PBU\", \"PBU No.\"+ (4*j+i+1 ) + \" Fail\");\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\t\t\t\t context.AddResult(ResultType.Passed,\"PBU\",\"PBU No.\"+ (4*j+i+1 ) + \" Pass\");\r\n \r\n\t\t\tTest_Index++;\r\n \t\t\tcontext.UpdateProgress(\"Priming\",false,Test_Index,10);\r\n\t\t\t\t\t\r\n\t\t\t}\r\n\t\t\tstate=\"Flow No.\"+ (j+1 ) ;\r\n\t\t\tStart_Table=Up_Table;\r\n\t\t\tTable_Run(Dispenser_Nm );\r\n\t\t\tif (time_Table<115000)\r\n\t\t\t\t{\r\n\t\t\t\t\tcontext.WriteLine(\"time_Table= \" +time_Table);\r\n\t\t\t\t\tcontext.AddResult(ResultType.Failed,\"Flow\", \"Flow No.\"+ (j+1) + \" Fail\");\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\t\t\t\t context.AddResult(ResultType.Passed,\"Flow\",\"Flow No.\"+ (j+1 ) + \" Pass\");\r\n\t\t\t\t \tTest_Index++;\r\n \t\t\t\t\tcontext.UpdateProgress(\"Priming\",false,Test_Index,10);\r\n\t\t\r\n\t\t}\r\n\t\t\t\t state=\"Last PBU \" ;\r\n\t\t\t\t Start_Table=BuildUp_Table;\r\n\t\t\t\tTable_Run(Dispenser_Nm );\r\n\t\t\t\t\tTest_Index++;\r\n \t\t\t\t\tcontext.UpdateProgress(\"Priming\",false,Test_Index,10);\r\n\r\n\t\t\t\tlong Time=Lebel2_time-Lebel1_time;\r\n\t\t\t\tif (Time>Max_PBU)\r\n\t\t\t\t { \r\n\t\t\t\t context.AddResult(ResultType.Failed,\"PBU\", \"PBU = \" +Time + \"msec \");\r\n\t\t\t\t state=\"PBU = \" +Time + \"msec \\tFail\";\r\n\t\t\t\t }\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t context.AddResult(ResultType.Passed,\"PBU\", \"PBU = \" +Time + \"msec \");\r\n\t\t\t\t state=\"PBU = \" +Time + \"msec \\tPass\";\r\n\t\t\t\t}\t\r\n\t\treturn 0;\r\n\t\t\r\n }\r\n\r\n/////////////////////////////////////////////\r\nvoid \t\tcheck_Min_Max_Mbar(Int32 i )\r\n{\r\n\tint k;\r\n\tstring s ;\r\n\ti--;\r\n\r\n\t\t\t\t\tcontext.WriteLine(\"-------------- write Enable Channel ------------\");\t//debug\r\n\t\tenable_channel(i); // Chanel 0-7 => Disp0enser 0-7 \r\n\t\t\t\t\tcontext.WriteLine(\"-------------- Read_header ------------\");\t//debug\r\n\r\n\t\t\t\t\tcontext.WriteLine(\"-------------- write_address_eeprom ------------\");\t//debug\r\n\t\twrite_address_eeprom (I2C_Slave_Low_Add,MinPress_Mbar_Add);\r\n\t\t\t\t\tcontext.WriteLine(\"-------------- read_data_from_eeprom ------------\");\t//debug\r\n\t\tread_data_from_eeprom (I2C_Slave_Low_Add,1);\r\n\t\tif \t(EEPROM_Data[0]==0\t)\r\n\t\t{\tPressureSensorType=0;\r\n\t\t\tcontext.WriteLine(\"PressureSensorType=0\" );\t//debug\r\n\t\t}\r\n\t\telse\t\r\n\t\t{\t\r\n\t\t\tPressureSensorType=1;\t\t\t\t\t\r\n\t\t\tcontext.WriteLine(\"PressureSensorType=1\" );\t//debug\r\n\t\t}\r\n\t\r\n}\t\r\n//----------------write address eeprom -------------------------\r\npublic void write_address_eeprom (UInt32 I2C_Add, UInt32 Eeprom_Add)\r\n{\t\r\n\tStubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest();\r\n\tstubI2CWriteBytesRequest.I2CId = I2C_ID;\r\n\tstubI2CWriteBytesRequest.SlaveAddress = I2C_Add;\r\n\t\r\n\tUInt32 uInt32 = new UInt32();\r\n\tstubI2CWriteBytesRequest.BytesTWrite.Add(Convert.ToByte( (Eeprom_Add & 0xff00) >>8));\t//Byte High add to write\r\n\tstubI2CWriteBytesRequest.BytesTWrite.Add(Convert.ToByte(Eeprom_Add & 0xff));\t\t\t//Byte Low add to write\r\n\t\t\t\t\tcontext.WriteLine( (Eeprom_Add & 0xff00) >>8) ;\t//debug\r\n\t\t\t\t\tcontext.WriteLine( Eeprom_Add & 0xff);\t//debug\r\n\r\n\tcontext.Send<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);\t\r\n}\r\n//------------------- read Data from EEprom--------------------------\r\n\r\npublic void read_data_from_eeprom ( UInt32 I2C_Add, UInt32 cnt )\r\n{\r\n\tStubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest();\r\n\tstubI2CReadBytesRequest.I2CId = I2C_ID;\r\n\tstubI2CReadBytesRequest.SlaveAddress = (I2C_Add + 1);\r\n\tstubI2CReadBytesRequest.NumberOfBytesToRead = cnt; // Number of bytes to read\r\n\r\n\tvar response1 = context.Send<StubI2CReadBytesResponse>(stubI2CReadBytesRequest);\r\n\r\n\tfor(int i=0; i<cnt;i++)\r\n\t\t{\r\n\t\t\tEEPROM_Data[i]=Convert.ToByte(response1.ReadBytes[i]);\r\n\t\t\tcontext.WriteLine(EEPROM_Data[i] );\t//debug\r\n\r\n\t\t}\t\t\r\n}\t\r\n\r\n\r\n///////////////////////////////////////////////\r\n//----------- enable I2c channel --------------\r\npublic int enable_channel(Int32 Channel_ID) \r\n{\r\n\tuint Const_temp = 0x01;\t\r\n\t\r\n\tStubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest();\r\n\tstubI2CWriteBytesRequest.I2CId = I2C_ID;\r\n\tstubI2CWriteBytesRequest.SlaveAddress = TCA9548A_address;\r\n\t\r\n\tConst_temp = Const_temp << Channel_ID;\r\n\tstubI2CWriteBytesRequest.BytesTWrite.Add(Const_temp);//enable i2c channel 0 Dispenser 1\r\n\r\n\tvar response = context.Send<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);\r\n\t\r\n\treturn 1;\r\n}\r\n\r\n\r\n////////////////////////////////////////////////////////////// \r\nInt32 Table_Run(Int32 Dispenser )\r\n\r\n{\r\n\tInt32 COMMAND=0;\r\n\tInt32 Data=0;\r\n\tInt32 count=0;\r\n\t\r\n\tDispenser--;\t\t//check from 0-7\r\n\t\r\n\tint j=0;\r\n\t\tvar stopwatch = new Stopwatch();\r\n\r\n\t\tstopwatch.Start();\r\n\t\r\n\t\t elapsed_time = stopwatch.ElapsedMilliseconds;\r\n\t\tcontext.WriteLine(elapsed_time);\r\n\t\t\r\n\twhile (count!=-1) \r\n\t{\r\n\tmsec_index=msec_index+1;\r\n\t\t\r\n\t\tif (Dispenser<2) \r\n\t\t\t{\r\n\t\t\t\tvar response1 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_01_Direct);\r\n\t\t\t\tRD_LS_01_Direct=response1.Value\t ;\r\n\t\t\t}\r\n\t\telse if ( (Dispenser<4) )\r\n\t\t\t{\r\n\t\t\t\tvar response1 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_02_Direct);\r\n\t\t\t\tRD_LS_02_Direct=response1.Value\t ;\r\n\t\t\t}\r\n\t\telse if ( (Dispenser<6) )\r\n\t\t\t{\r\n\t\t\t\tvar response1 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_03_Direct);\r\n\t\t\t\tRD_LS_03_Direct=response1.Value\t ;\r\n\t\t\t}\r\n\t\telse\r\n\t\t\t{\r\n\t\t\t\tvar response1 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_04_Direct);\r\n\t\t\t\tRD_LS_04_Direct=response1.Value\t ;\r\n\t\t\t}\r\n\t\tif (Dispenser<4) \r\n\t\t\t{\r\n\t\t\tvar response2 = context.Send<StubIntADCReadResponse>(\"StubIntADCReadRequest\" ,0x8000 + AN_IDS_PRESSENS_1);\r\n\t\t\t\tA2D_Dispenser[0]=(response2.SamplingInBits)>>16;\r\n\t\t\t\tA2D_Dispenser[1] =(response2.SamplingInBits) & 0x0000ffff;\r\n\t\t\t\tA2D_Dispenser[2] =(response2.VoltageSamplingMv)>>16;\r\n\t\t\t\tA2D_Dispenser[3] =(response2.VoltageSamplingMv) & 0x0000ffff;\r\n\t\t\t}\r\n\t\telse\r\n\t\t\t{\r\n\t\t\tvar\tresponse3 = context.Send<StubIntADCReadResponse>(\"StubIntADCReadRequest\" ,0x8000 + AN_IDS_PRESSENS_5);\r\n\t\t\t\tA2D_Dispenser[4] =(response3.SamplingInBits)>>16;\r\n\t\t\t\tA2D_Dispenser[5] =(response3.SamplingInBits)& 0x0000ffff;\r\n\t\t\t\tA2D_Dispenser[6] =(response3.VoltageSamplingMv)>>16;\r\n\t\t\t\tA2D_Dispenser[7] =(response3.VoltageSamplingMv)& 0x0000ffff;\r\n\t\t\t}\r\n\t\t\t\t\r\n\t\t\tCOMMAND=Start_Table[count];\r\n\t\t\tData=Start_Table[(count+1)];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//Index=Index+2;\r\n\t\t\tswitch (COMMAND)\r\n\t\t\t\t{\r\n\t\t\t\tcase CMD_RUN:\r\n\t\t\t\t\tMotor_Run(Data,Dispenser);\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_VALVE:\r\n\t\t\t\t\tValve_3W(Data,Dispenser);\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_STOP:\r\n\t\t\t\t\tMotor_Stop(Data,Dispenser);\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_DLY:\r\n\t\t\t\t\tDelay_on_second(Data,Dispenser,elapsed_time);\r\n\t\t\t\t\tif (Temp_Delay <1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tmax_pressure_level=20000;\t\r\n\t\t\t\t\t\tmin_pressure_level=-20000;\t\r\n\t\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_TIME:\r\n\t\t\t\t\tPrint_Time();\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_PRESS:\r\n\t\t\t\t\tmax_pressure_level=Data;\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",Max_pressure_level is, \" + Data +\",\"+DateTime.Now+\"\\n\");\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_PRESL:\r\n\t\t\t\t\tmin_pressure_level=Data;\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",Min_pressure_level is, \" + Data +\",\"+DateTime.Now+\"\\n\");\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_LBL:\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",Label,\" + Data+\",\"+DateTime.Now+\"\\n\");\r\n\t\t\t\t\tif(Data==1)\r\n\t\t\t\t\t\tLebel1_time=stopwatch.ElapsedMilliseconds;\r\n\t\t\t\t\tif(Data==2)\r\n\t\t\t\t\t\tLebel2_time=stopwatch.ElapsedMilliseconds;\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_SMP:\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",SampleRate,\" + Data+\",\"+DateTime.Now+\"\\n\");\r\n\t\t\t\t\tDispenser_sample_rate =Data;\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\t\r\n\t\t\t\tcase CMD_END:\r\n\t\t\t\t\tcount=-1;\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",End testing,,\"+DateTime.Now+\"\\n\");\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\t\tcase CMD_MTV_OPEN:\r\n\t\t\t\t\topen_midtank_valve(Data,Dispenser);\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",OPEN MIDTANK, \" + Dispenser+\",\"+DateTime.Now+\"\\n\");\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase CMD_MTV_CLOSE:\r\n\t\t\t\t\tclose_midtank_valve(Data,Dispenser);\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",CLOSE MIDTANK, \" + Dispenser+\",\"+DateTime.Now+\"\\n\");\r\n\t\t\t\t\tcount = count+2;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\t\tcase CMD_LOOP_NM:\r\n\t\t\t\t\r\n\t\t\t\t\tLoop_cnt=Data-1;\r\n\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",Counter Loop,\"+ Data+\",\"+DateTime.Now +\"\\n\");\r\n\t\t\t\t\tcount = count+2;\t\t\t\t\t\t\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase CMD_LOOP:\r\n\t\t\t\t\r\n\t\t\t\t\tif (Loop_cnt!=0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\"Counter Loop,\"+ Loop_cnt+\",\"+DateTime.Now+\"\\n\" );\r\n\t\t\t\t\t\tcount = count+2*Data;\r\n\t\t\t\t\t\tLoop_cnt--;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",End loop,,\"+DateTime.Now +\"\\n\");\r\n\t\t\t\t\t\tcount = count+2;\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t}\t\r\n\t\t\t\r\n\t\t\tlong elapsed_time1 = stopwatch.ElapsedMilliseconds;\r\n\t\t\tlong elapsed_time2= elapsed_time1-elapsed_time;\r\n\t\t\tif (elapsed_time2>95)\r\n\t\t\telapsed_time2=95;\t\t//minimum time\r\n\t\t\t\tThread.Sleep(100-(int )(elapsed_time2));\r\n\r\n\t\t\telapsed_time = stopwatch.ElapsedMilliseconds;\t\t\r\n\r\n\r\n\t\t\tj++;\r\n\t\t\t\tif (j==10)\r\n\t\t\t\t{\r\n\t\t\t\t\tj=0;\r\n\t\t\t\t\tcontext.WriteLine(Dispenser_press[Dispenser]+ \" mBar\\t\"+state + \"\\tTime-\" + (elapsed_time/1000));\r\n\t\t\t\t}\r\n\t}\r\n\ttime_Table=elapsed_time;\r\n\treturn 0;\r\n}\r\n\r\n///////////////////////////////////////////////////////////////////\t\r\nInt32 Motor_Run(Int32 speed,Int32 Dispenser)\r\n\r\n{\r\n\r\n\tswitch (Dispenser)\r\n\t\t{\r\n\t\tcase 0:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[0]=2;\r\n\t\t\t\t\tif ((RD_LS_01_Direct & 0x04)!=0x04)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor1, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[0]=1;\r\n\t\t\t\t\tif ((RD_LS_01_Direct & 0x20)!=0x20)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor1, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase 1:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[1]=2;\r\n\t\t\t\t\tif ((RD_LS_01_Direct & 0x100)!=0x100)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor2, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[1]=1;\r\n\t\t\t\t\tif ((RD_LS_01_Direct & 0x800)!=0x800)\r\n\t\t\t\t\t{\t\t\t\t\t\t\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor2, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase 2:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[2]=2;\r\n\t\t\t\t\tif ((RD_LS_02_Direct & 0x04)!=0x04)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor3, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[2]=1;\r\n\t\t\t\t\tif ((RD_LS_02_Direct & 0x20)!=0x20)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now+ \",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor3, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase 3:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[3]=2;\r\n\r\n\t\t\t\t\tif ((RD_LS_02_Direct & 0x100)!=0x100)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now+ \",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor4, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[3]=1;\r\n\r\n\t\t\t\t\tif ((RD_LS_02_Direct & 0x800)!=0x800)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor4, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\r\n\t\tcase 4:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[4]=2;\r\n\t\t\t\t\tif ((RD_LS_03_Direct & 0x04)!=0x04)\r\n\t\t\t\t\t{ \r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now+ \",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor5, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[4]=1;\r\n\t\t\t\t\tif ((RD_LS_03_Direct & 0x20)!=0x20)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now+ \",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor5, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase 5:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[5]=2;\r\n\t\t\t\t\tif ((RD_LS_03_Direct & 0x100)!=0x100)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor6, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[5]=1;\r\n\t\t\t\t\tif ((RD_LS_03_Direct & 0x800)!=0x800)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now+ \",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor6, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase 6:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[6]=2;\r\n\t\t\t\t\tif ((RD_LS_04_Direct & 0x04)!=0x04)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor7, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[6]=1;\r\n\t\t\t\t\tif ((RD_LS_04_Direct & 0x20)!=0x20)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor7, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\tcase 7:\r\n\t\t\t\tif ( speed<0)\r\n\t\t\t\t{\r\n\t\t\t\t\tMotor_Dir[7]=2;\r\n\r\n\t\t\t\t\tif ((RD_LS_04_Direct & 0x100)!=0x100)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor8, false, (-speed));\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\t\r\n\t\t\t\t\tMotor_Dir[7]=1;\r\n\r\n\t\t\t\t\tif ((RD_LS_04_Direct & 0x800)!=0x800)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Motor on Limit\\n\");\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcontext.Send<StubMotorRunResponse>(\"StubMotorRunRequest\" ,Dispenser_Motor8, true, (speed));\r\n\t\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\t\r\n\t\tdefault:\r\n\t\t\tbreak;\r\n\r\n\t\t}\r\n \tcontext.AppendToFile(Dispenser_Fname,\",Run,\" +speed+\",\"+DateTime.Now +\"\\n\" ); \r\n\r\n\treturn 1;\r\n} \r\n \r\n \t\r\n Int32 Valve_3W(Int32 Valve_Value,Int32 Dispenser)\r\n{\r\n\tif ( Valve_Value==1)\r\n\t\tcontext.Send<StubValveResponse>(\"StubValveRequest\" ,Dispenser_Valve1+Dispenser, 3, true);\t//3 3Way\r\n\telse\t\r\n\t\tcontext.Send<StubValveResponse>(\"StubValveRequest\" ,Dispenser_Valve1+Dispenser, 3, false); //3 3Way\r\n \r\n\tcontext.AppendToFile(Dispenser_Fname,\",Dispenser Valve position is, \" + Valve_Value+\",\"+DateTime.Now +\"\\n\" );\r\n\r\n\treturn 1;\t\r\n}\t\r\n//--------------------------------------- \r\n\r\n Int32 Motor_Stop(Int32 Stop_Value,Int32 Dispenser )\r\n{\r\n\tcontext.Send<StubMotorStopResponse>(\"StubMotorStopRequest\" ,Dispenser_Motor1+Dispenser, Stop_Value);\r\n\t\r\n\tcontext.AppendToFile(Dispenser_Fname,\",Motor Stop,\" + Stop_Value+\",\"+DateTime.Now +\"\\n\");\r\n\tMotor_Dir[Dispenser]=0;\r\n\treturn 1;\t\r\n}\r\n\r\n//--------------------------------------- \r\n\r\n Int32 Delay_on_second(Int32 Delay,Int32 Dispenser ,long time)\r\n{\r\n//Int32 temp1;\r\nInt32 pressure_om_mBAR=0;\r\n\tif \t(Temp_Delay ==0)\r\n\t{\r\n\t\tcontext.AppendToFile(Dispenser_Fname,\",DLY, \" + Delay +\",\"+DateTime.Now+\"\\n\");\r\n\t\tEnd_Time=time+Delay*1000-1;\r\n\r\n\t\tTemp_Delay = 1;\r\n//\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.Write(\"A\");\t\t//debug\r\n\t}\r\n\telse\t\r\nif (time>End_Time)\t\r\n\t\t{\t\t\t\t\r\n\t\tTemp_Delay=0;\r\n\t\t}\r\n\t\t\t\r\n\tif ( LimitSW_Dispenser(Dispenser)==0)\r\n \t {\t\r\n \t \tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now+\",Warning Motor on Limit\\n\");\r\n\t\t\tMotorStop(Dispenser);\r\n\t\t\tTemp_Delay =0;\t//end delay\r\n//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.Write(\"C\");\t\t//debug\r\n\r\n\t\t\treturn 0 ;\r\n \t }\r\n\t\t\t\t\t\r\n\tpressure_om_mBAR=Calc_mBAR(Dispenser,true);\r\n \tif (pressure_om_mBAR > max_pressure_level)\r\n \t \t{\r\n\t\t//\tMotorStop(Dispenser);\r\n\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Pressure too high\\n\");\r\n\t\t\tTemp_Delay =0;\t//end delay\r\n//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.Write(\"D\");\t\t//debug\r\n\t\t\t\r\n\t\t\treturn 0;\r\n\t\t}\r\n \tif (pressure_om_mBAR < min_pressure_level)\r\n \t \t{\r\n\t\t//\tMotorStop(Dispenser);\r\n\t\t\tcontext.AppendToFile(Dispenser_Fname,\",,,\"+DateTime.Now +\",Warning Pressure too low\\n\");\r\n\t\t\tTemp_Delay =0;\t//end delay\r\n//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcontext.Write(\"D\");\t\t//debug\r\n\t\t\t\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n \treturn 1;\r\n}\t\r\n \t \t\r\nInt32 LimitSW_Dispenser(Int32 Dispenser) \r\n{\r\n\r\n\tif (Dispenser==0)\r\n\t\t\r\n\t\t{\r\n\t\t\t\r\n//\t\tvar response1 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_01_Direct);\r\n\r\n\t\t\t\tif (((RD_LS_01_Direct & 0x04)!=0x04) && (Motor_Dir[0]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_01_Direct & 0x20)!=0x20) && (Motor_Dir[0]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t}\r\n\t\t\r\n\tif (Dispenser==1)\r\n\t\t\r\n\t\t{\r\n//\t\tvar response2 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_01_Direct);\r\n\t\t\t\tif (((RD_LS_01_Direct & 0x100)!=0x100) && (Motor_Dir[1]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_01_Direct & 0x800)!=0x800) && (Motor_Dir[1]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t}\r\n\t\t\r\n\r\n\tif (Dispenser==2)\r\n\t\t\r\n\t\t{\r\n\t\t\t\t\r\n\t\t//var response3 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_02_Direct);\r\n\t\t\t\tif (((RD_LS_02_Direct & 0x04)!=0x04) && (Motor_Dir[2]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_02_Direct & 0x20)!=0x20) && (Motor_Dir[2]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\tif (Dispenser==3)\r\n\t\t\r\n\t\t{\r\n\t\t\t\tvar response4 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_02_Direct);\r\n\t\t\t\tif (((RD_LS_02_Direct & 0x100)!=0x100) && (Motor_Dir[3]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_02_Direct & 0x800)!=0x800) && (Motor_Dir[3]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\t\r\n\r\n\tif (Dispenser==4)\r\n\t\t\r\n\t\t{\r\n\t\t\t\r\n//\t\tvar response1 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_01_Direct);\r\n\t\t\t\tif (((RD_LS_03_Direct & 0x04)!=0x04) && (Motor_Dir[4]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_03_Direct & 0x20)!=0x20) && (Motor_Dir[4]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t}\r\n\t\t\r\n\tif (Dispenser==5)\r\n\t\t\r\n\t\t{\r\n//\t\tvar response2 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_01_Direct);\r\n\t\t\t\tif (((RD_LS_03_Direct & 0x100)!=0x100) && (Motor_Dir[5]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_03_Direct & 0x800)!=0x800) && (Motor_Dir[5]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t}\r\n\t\t\r\n\r\n\tif (Dispenser==6)\r\n\t\t\r\n\t\t{\r\n\t\t\t\t\r\n\t\t//var response3 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_02_Direct);\r\n\t\t\t\tif (((RD_LS_04_Direct & 0x04)!=0x04) && (Motor_Dir[6]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_04_Direct & 0x20)!=0x20) && (Motor_Dir[6]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t\t\r\n\t\t}\r\n\t\t\r\n\tif (Dispenser==7)\r\n\t\t\r\n\t\t{\r\n//\t\tvar response4 = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" ,F2_LS_02_Direct);\r\n\t\t\t\tif (((RD_LS_04_Direct & 0x100)!=0x100) && (Motor_Dir[7]==2))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\tif (((RD_LS_04_Direct & 0x800)!=0x800) && (Motor_Dir[7]==1))\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\telse\r\n\t\t\t\treturn 1;\t\t\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\treturn 0;\r\n}\t\t\r\n\t\t\r\n\t \t\r\nInt32 Print_Time() \r\n{\t\r\n\t\tcontext.AppendToFile(Dispenser_Fname,\",Time is\\t,,\"+ DateTime.Now +\"\\n\" ); \r\n\r\n\t\treturn 1;\r\n}\t\r\n\r\n\r\n\r\nInt32 Calc_mBAR(Int32 Dispenser, bool save_press)\r\n{\t\t\r\nInt32 Data;\r\nInt32 Sense1;\r\nInt32 temp=0;\r\n\r\n\t\tData =A2D_Dispenser[Dispenser];\r\n\t\tif (Data<100)\r\n\t\t\ttemp=-1;\r\n\t\tData=Data-710;\r\n\t\tif (Data<0)\r\n\t\tData=0;\r\n\r\n\t\tData=Data*(10000+PressureSensorType*1000)/2840;\t//\tfor -1 to 10 bar Press_Sensor_Type=1 else 0\r\n\t\tData=Data-1000*PressureSensorType; \t\t\t// for -1 to 10 bar\r\n\r\n\t\tif (temp==-1)\t\t\t\t\t\t//if SamplingInBits <100 then No pressure sensor exist\r\n\t\tSense1=-9999\t;\r\n\t\telse\t\r\n\t\tSense1=Data\t;\r\n\t\tif (\t((msec_index) % (Dispenser_sample_rate)) == 0)\r\n\t\t{\r\n\t\t\tcontext.AppendToFile(Dispenser_Fname,\"\" + Sense1+\",,,\"+ DateTime.Now+\"\\n\");\r\n\t\t}\r\n\t\tDispenser_press[Dispenser]=Sense1;\r\n\treturn Sense1;\r\n\t\t\t\r\n } \t\r\n\r\n \r\n//--------------------------------\r\nint open_midtank_valve (Int32 valve_type,Int32 valve_nm)\t\t//valve_type=0 is Air ,1 is Ink ; valve_nm 0-7\r\n{\r\n\tSetBit (F3_VALVE_OUT,((valve_type+1)*8)- valve_nm-1, 1);\r\n\treturn 1;\r\n\r\n}\r\n//--------------------------------\t\r\nint close_midtank_valve (Int32 valve_type,Int32 valve_nm)\t\t//valve_type=0 is Air ,1 is Ink ; valve_nm 0-7\r\n{\r\n\tSetBit (F3_VALVE_OUT,((valve_type+1)*8)- valve_nm-1, 0);\r\n\treturn 1;\r\n}\r\n//--------------------------------\r\nInt32 SetBit(Int32 Adr, Int32 BitNo, Int32 Bit)\r\n{\r\n\tInt32 BitMask;\r\n\r\n var response = context.Send<StubFpgaReadRegResponse>(\"StubFpgaReadRegRequest\" , F3_VALVE_OUT);\r\n\tInt32 RV = (Int32) response.Value & 0xffff;\r\n\t\r\n\t\r\n\tif (Bit == 0x1) \r\n\t{\r\n\t\tBitMask = 0x1 << BitNo;\r\n\t\tRV = RV | BitMask;\r\n\t\tcontext.Send<StubFpgaWriteRegResponse>(\"StubFpgaWriteRegRequest\" ,F3_VALVE_OUT , RV);\r\n\t}\r\n\telse if (Bit == 0x0)\r\n\t{\r\n\t\tBitMask = ~(0x1 << BitNo);\r\n\t\tRV = RV & BitMask;\r\n\t\tcontext.Send<StubFpgaWriteRegResponse>(\"StubFpgaWriteRegRequest\" ,F3_VALVE_OUT , RV);\r\n\t}\r\n\treturn 1;\r\n}\r\n//---------------------------------- \r\n void MotorStop(Int32 i)\r\n{\r\n \r\ncontext.Send<StubMotorStopResponse>(\"StubMotorStopRequest\" ,Dispenser_Motor1+i, 2);\r\nMotor_Dir[i]=0;\t//0 stop 1- up 2-dn\r\n\r\n}\r\n \r\n}"},{"$id":"20","Name":"Service.csx","IsEntryPoint":false,"Code":"using System;\r\nusing System.Collections.Generic;\r\nusing System.Collections.ObjectModel;\r\nusing System.ComponentModel;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\nusing System.Drawing;\r\nusing Google.Protobuf;\r\nusing Tango.BL.Entities;\r\nusing Tango.BL.Enumerations;\r\nusing Tango.PMR.Stubs;\r\nusing Tango.PMR.Diagnostics;\r\nusing Tango.FSE.Common.Connection;\r\nusing Tango.FSE.Common.Diagnostics;\r\nusing Tango.FSE.Procedures;\r\n\r\npublic class Service\r\n{\r\n public double Calc(double a, double b)\r\n {\r\n return a + b;\r\n }\r\n}"}]}}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/Read Dancer new.cs b/Software/Stubs Collection/stubs/Scripts/Read Dancer new.cs new file mode 100644 index 000000000..9d1572291 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/Read Dancer new.cs @@ -0,0 +1,138 @@ +//------------------------------------------- +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) +{ + + +//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, + }; + Button button3 = new Button () + { + Width = 100, + Height = 100, + }; +//-------------------------------------------------------------------------------- +// Set the text of button + + button1.Text = "Left Dancer"; + button2.Text = "Center Dancer"; + button3.Text = "Right Dancer"; + +//-------------------------------------------------------------------------------- +// Set the position of the button on the form. + + button1.Location = new Point (40, 40); + + button2.Location + = new Point (button1.Left + button1.Width + 10, 40); + + button3.Location + = new Point (button2.Left + button2.Width + 10, 40); + +//-------------------------------------------------------------------------------- + // Add button to the form. + + form1.Controls.Add(button1); + + form1.Controls.Add(button2); + + form1.Controls.Add(button3); + +//-------------------------------------------------------------------------------- + +// Set the caption bar text of the form. + + form1.Text = "Read Dancer"; + +//-------------------------------------------------------------------------------- + + // 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; +//----------------------------------------- + button1.Click += (_,__) => + { + stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,0); + Thread.Sleep(1000); + }; +//----------------------------------------- + button2.Click += (_,__) => + + { + stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,1); + Thread.Sleep(1000); + + }; +//----------------------------------------- + + button3.Click += (_,__) => + { + stubManager.Run<StubDancerPositionResponse>("StubDancerPositionRequest" ,2); + Thread.Sleep(1000); + }; + +//-------------------------------------------------------------------------------- + +// Display the form as a modal dialog box. + form1.ShowDialog(); + + stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,5, 3); + + + return; +} + + + diff --git a/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs b/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs index 5c3708af7..88de4de01 100644 --- a/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs +++ b/Software/Stubs Collection/stubs/Scripts/WHS_Test_EEPROM.cs @@ -12,9 +12,9 @@ using Tango.Stubs; //---------------------- const Int32 I2C_ID = 3; //MCU_I2C3 -const Int32 TCA9548A_address = 0xE0; +const Int32 TCA9548A_address = 0xE2; const Int32 I2C_Slave_Add = 0xA0; // //eeprom address - 32kByte -int Head_Mux_Channel_ID = 1; //WHS MUX channel +int Head_Mux_Channel_ID = 0; //WHS MUX channel //---------------------- diff --git a/Software/Stubs Collection/stubs/Scripts/auto shutt off.cs b/Software/Stubs Collection/stubs/Scripts/auto shutt off.cs new file mode 100644 index 000000000..8fd9963c2 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/auto shutt off.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) +{ + + while (true) + + { + + + stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x600004e2, 0x800); + Thread.Sleep(50); + + + + } + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/change sublimation time.cs b/Software/Stubs Collection/stubs/Scripts/change sublimation time.cs new file mode 100644 index 000000000..3292a3b7e --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/change sublimation time.cs @@ -0,0 +1,23 @@ +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 SublimationDuration = 30; +ProgressRequest progressRequest = new ProgressRequest(); +progressRequest.Amount = 0xB26; +progressRequest.Delay = SublimationDuration; + + var response = stubManager.Run<ProgressResponse>(progressRequest); + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/embeddedparametersbuild_w_cleaning.cs b/Software/Stubs Collection/stubs/Scripts/embeddedparametersbuild_w_cleaning.cs index 5aaa33a56..16a8324ba 100644 --- a/Software/Stubs Collection/stubs/Scripts/embeddedparametersbuild_w_cleaning.cs +++ b/Software/Stubs Collection/stubs/Scripts/embeddedparametersbuild_w_cleaning.cs @@ -137,11 +137,11 @@ SetAutoFill = 3.0; configurationParameters.GeneralParameters.Add(SetAutoFill); double PowerOffDisableCleaning = new Double(); -PowerOffDisableCleaning = 0.0 +PowerOffDisableCleaning = 0.0; configurationParameters.GeneralParameters.Add(PowerOffDisableCleaning); double SublimationBlowTime = new Double(); -SublimationBlowTime = 30.0 +SublimationBlowTime = 30.0; configurationParameters.GeneralParameters.Add(SublimationBlowTime); double AllowedRangeForHeadBlowerDeviation = new Double(); @@ -152,7 +152,9 @@ double AllowedRangeForWasteBlowerDeviation = new Double(); AllowedRangeForWasteBlowerDeviation = 20; configurationParameters.GeneralParameters.Add(AllowedRangeForWasteBlowerDeviation); - +double Voltage_Hysteresis = new Double(); +Voltage_Hysteresis = 4; +configurationParameters.GeneralParameters.Add(Voltage_Hysteresis); File.WriteAllBytes("C:/temp/EmbParam.cfg",configurationParameters.ToBytes()); diff --git a/Software/Stubs Collection/stubs/Scripts/read and store main card data.cs b/Software/Stubs Collection/stubs/Scripts/read and store main card data.cs new file mode 100644 index 000000000..aec6bef3d --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/read and store main card data.cs @@ -0,0 +1,83 @@ +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; +using System.IO; +using Tango.PMR.IO; +using Google.Protobuf; + +string[] Main_Card_EEpromAddress = { +"DATA_SIZE", +"DANCER_0", +"DANCER_1", +"DANCER_2", +"DRYER_CENTER", +"DRYER_CYCLES", +"MIDTANK_1_A", +"MIDTANK_1_B", +"MIDTANK_2_A", +"MIDTANK_2_B", +"MIDTANK_3_A", +"MIDTANK_3_B", +"MIDTANK_4_A", +"MIDTANK_4_B", +"MIDTANK_5_A", +"MIDTANK_5_B", +"MIDTANK_6_A", +"MIDTANK_6_B", +"MIDTANK_7_A", +"MIDTANK_7_B", +"MIDTANK_8_A", +"MIDTANK_8_B", +"WINDER_CALIBRATION", +"EMBEDDED_VERSION", +"EEPROM_ALARM_SUPPORT", +"EEPROM_ORIFICE1_ZERO_VALUE", +"EEPROM_ORIFICE3_ZERO_VALUE", +"EEPROM_WASTE_TANK_ZERO_VALUE", +"EEPROM_PULLER_TENSION_POSITION", +"EEPROM_WINDER_TENSION_POSITION", +"EEPROM_INIT_FAILURE_COUNTER", +"DANCER_3", +"DANCER_4", +"EEPROM_PRESSURE_SENSOR_V0_0", +"EEPROM_PRESSURE_SENSOR_V0_1", +"EEPROM_DRIER_LOADING_ARM_ANGLE"}; + + +private const string JSON_FILE_PATH = "C:/temp/maineeprom.json"; +private const string CSV_FILE_PATH = "C:/temp/maineeprom.csv"; +public void OnExecute(StubManager stubManager) +{ + StubReadEmbeddedVersionRequest stubReadEmbeddedVersionRequest = new StubReadEmbeddedVersionRequest(); + var response2 = stubManager.Run<StubReadEmbeddedVersionResponse>(stubReadEmbeddedVersionRequest); + + if ((response2.VerMajor>=1)&&(response2.VerMinor>=5)&&(response2.VerPatch>=5)&&(response2.VerBuild>=2)) + { + MainCardStoredDataRequest mainCardStoredDataRequest = new MainCardStoredDataRequest(); + var response3 = stubManager.Run<MainCardStoredDataResponse>(mainCardStoredDataRequest); + stubManager.AppendToFile(JSON_FILE_PATH, "MainCardStoredData: "+ response3); + } + else + { + stubManager.AppendToFile(CSV_FILE_PATH, "Address,Name,Data"); + for (int i = 1; i < 36; i++) + { + StubMainCardEEpromReadRequest stubMainCardEEpromReadRequest = new StubMainCardEEpromReadRequest(); + stubMainCardEEpromReadRequest.Address = i; + stubMainCardEEpromReadRequest.Data = 0; + + var response = stubManager.Run<StubMainCardEEpromReadResponse>(stubMainCardEEpromReadRequest); + stubManager.AppendToFile(CSV_FILE_PATH, response.Address + "," + Main_Card_EEpromAddress[i] +"," + response.Data); + } + } + +}
\ No newline at end of file diff --git a/Software/Stubs Collection/stubs/Scripts/read_cpu_eeprom.cs b/Software/Stubs Collection/stubs/Scripts/read_cpu_eeprom.cs new file mode 100644 index 000000000..e5960c3f3 --- /dev/null +++ b/Software/Stubs Collection/stubs/Scripts/read_cpu_eeprom.cs @@ -0,0 +1,29 @@ +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 response = stubManager.Run<StubMainCardEEpromReadResponse>("StubMainCardEEpromReadRequest" ,30, 0); + stubManager.Write("\ninit counter: \t"+ response.Data ); + response = stubManager.Run<StubMainCardEEpromReadResponse>("StubMainCardEEpromReadRequest" ,40, 0); + stubManager.Write("\nnumber of resets: \t"+ response.Data ); + int j = response.Data; + + for (Int32 i=0;i<j;i++) + { + response = stubManager.Run<StubMainCardEEpromReadResponse>("StubMainCardEEpromReadRequest" ,41+i, 3); + + stubManager.Write("\nAddress \t"+ i + "\tdata = " ); + stubManager.WriteHex(response.Data,4); + + } +}
\ No newline at end of file |
