diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2020-08-30 08:48:14 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2020-08-30 08:48:14 +0300 |
| commit | ac6d62249d43b4e6a3c227af7b8281b9e3ce2635 (patch) | |
| tree | b1f251d6290261222c70f09b8147dd3cada7978f /Software/Stubs Collection/Procedures/Priming.pproj | |
| parent | 0c038093d83f8e266f09f489cd93dda3dbc6ab3f (diff) | |
| parent | daaeac95e6b16bbb390da940b32bae88688e55dc (diff) | |
| download | Tango-ac6d62249d43b4e6a3c227af7b8281b9e3ce2635.tar.gz Tango-ac6d62249d43b4e6a3c227af7b8281b9e3ce2635.zip | |
merge
Diffstat (limited to 'Software/Stubs Collection/Procedures/Priming.pproj')
| -rw-r--r-- | Software/Stubs Collection/Procedures/Priming.pproj | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Software/Stubs Collection/Procedures/Priming.pproj b/Software/Stubs Collection/Procedures/Priming.pproj new file mode 100644 index 000000000..9139b1597 --- /dev/null +++ b/Software/Stubs Collection/Procedures/Priming.pproj @@ -0,0 +1 @@ +{"$id":"1","Name":"Priming","Description":"Used for a dispenser priming","Scripts":{"$id":"2","$values":[{"$id":"3","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_VALVE,1,\r\n\tCMD_PRESL,200,\r\n\tCMD_DLY,200, \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\tCMD_VALVE,0,\r\n\tCMD_RUN,1068,\r\n\tCMD_PRESS,1000,\t//mbar --> 1000 = 100% work, 4000 = 200% work, 350 = 20% work\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_END,3,\r\n};\r\n\t\r\n\r\nInt32[] Up_Table = new int []\r\n{\r\n\tCMD_VALVE,1,\r\n\tCMD_PRESL,200,\r\n\tCMD_DLY,200, \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\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\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\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=6000;\r\n\t\telse\r\n\t\t\tMax_PBU=4000;\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\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\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\t\t\r\n\t\t}\r\n\t\t\t\t state=\"Last PBU \" ;\r\n\t\t\t\tStart_Table=BuildUp_Table; \r\n\t\t\t\tTable_Run(Dispenser_Nm );\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\tvar stopwatch = new Stopwatch();\r\n\t\tstopwatch.Start();\r\n\t\r\n\t\tlong 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);\r\n\t\t\t\t\tif (Temp_Delay ==0)\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 )\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\tTemp_Delay = Delay *10 -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\n\t\t\tTemp_Delay--;\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+\"\\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}","Name":"Program.csx","IsEntryPoint":true},{"$id":"4","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}","Name":"Service.csx","IsEntryPoint":false}]},"Inputs":{"$id":"5","$values":[]},"Variables":{"$id":"6","$values":[]},"ReferenceAssemblies":{"$id":"7","$values":[{"$id":"8","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":"9","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":"10","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":"11","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":"12","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":"13","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":"14","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":"15","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":"16","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":"17","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":"18","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"}]},"Resources":{"$id":"19","$values":[]},"Dialogs":{"$id":"20","$values":[]},"ID":"eb73dbd4-1e1e-4f5d-adc8-5f159edab802","ApartmentState":"STA"}
\ No newline at end of file |
