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; /*** LTFU SSI Encoders ***/ const Int32 F1_LDANCER1_ROTENC_MSB = 0x01c2; const Int32 F1_LDANCER1_ROTENC_LSB = 0x01c0; const Int32 F1_LDANCER1_ROTENC_TX = 0x01ce; const Int32 F1_LDANCER2_ROTENC_MSB = 0x01b2; const Int32 F1_LDANCER2_ROTENC_LSB = 0x01b0; const Int32 F1_LDANCER2_ROTENC_TX = 0x01be; const Int32 F1_LSPARE_ROTENC_MSB = 0x0192; const Int32 F1_LSPARE_ROTENC_LSB = 0x0190; const Int32 F1_LSPARE_ROTENC_TX = 0x019e; /*** RTFU SSI Encoders ***/ const Int32 F1_RDANCER_ROTENC_MSB = 0x01a2; const Int32 F1_RDANCER_ROTENC_LSB = 0x01a0; const Int32 F1_RDANCER_ROTENC_TX = 0x01ae; const Int32 F1_RSPARE_ROTENC_MSB = 0x0182; const Int32 F1_RSPARE_ROTENC_LSB = 0x0180; const Int32 F1_RSPARE_ROTENC_TX = 0x018e; /*** RTFU, LTFU and DISPENSER SSI Prescalers ***/ const Int32 F1_Prescaler1_reg1 = 0x03e0; const Int32 F1_Prescaler1_reg2 = 0x03e2; const Int32 F1_SPI_Busy1_Direct = 0x0090; const Int32 F2_Prescaler1_reg1 = 0x03e0; const Int32 F2_Prescaler1_reg2 = 0x03e2; const Int32 F3_Prescaler1_reg1 = 0x03e0; const Int32 F3_Prescaler1_reg2 = 0x03e2; /*** DISPENSER SSI Encoders ***/ const Int32 F2_DISPENSER_ROTENC_1_MSB = 0x0182; const Int32 F2_DISPENSER_ROTENC_1_LSB = 0x0180; const Int32 F2_DISPENSER_ROTENC_1_TX = 0x018e; const Int32 F2_DISPENSER_ROTENC_2_MSB = 0x0192; const Int32 F2_DISPENSER_ROTENC_2_LSB = 0x0190; const Int32 F2_DISPENSER_ROTENC_2_TX = 0x019e; const Int32 F2_DISPENSER_ROTENC_3_MSB = 0x01a2; const Int32 F2_DISPENSER_ROTENC_3_LSB = 0x01a0; const Int32 F2_DISPENSER_ROTENC_3_TX = 0x01ae; const Int32 F2_DISPENSER_ROTENC_4_MSB = 0x01b2; const Int32 F2_DISPENSER_ROTENC_4_LSB = 0x01b0; const Int32 F2_DISPENSER_ROTENC_4_TX = 0x01be; const Int32 F2_DISPENSER_ROTENC_5_MSB = 0x01c2; const Int32 F2_DISPENSER_ROTENC_5_LSB = 0x01c0; const Int32 F2_DISPENSER_ROTENC_5_TX = 0x01ce; const Int32 F2_DISPENSER_ROTENC_6_MSB = 0x01d2; const Int32 F2_DISPENSER_ROTENC_6_LSB = 0x01d0; const Int32 F2_DISPENSER_ROTENC_6_TX = 0x01de; const Int32 F2_DISPENSER_ROTENC_7_MSB = 0x01e2; const Int32 F2_DISPENSER_ROTENC_7_LSB = 0x01e0; const Int32 F2_DISPENSER_ROTENC_7_TX = 0x01ee; const Int32 F2_DISPENSER_ROTENC_8_MSB = 0x01f2; const Int32 F2_DISPENSER_ROTENC_8_LSB = 0x01f0; const Int32 F2_DISPENSER_ROTENC_8_TX = 0x01fe; const Int32 F3_SPARE1_ROTENC_MSB = 0x02c0; const Int32 F3_SPARE1_ROTENC_LSB = 0x02c2; const Int32 F3_SPARE1_ROTENC_TX = 0x02ce; const Int32 F3_SPARE2_ROTENC_MSB = 0x02d0; const Int32 F3_SPARE2_ROTENC_LSB = 0x02d2; const Int32 F3_SPARE2_ROTENC_TX = 0x02de; int ssi_loop(Int32 Addr) { var RetValue = Fpga_Read_Reg(FPGA1, F1_SPI_Busy1_Direct,10); if ( (RetValue.Value&0x1f) == 0) { //stubManager.Write("\nWriting to F1 DANCER TX"); //Trigger SSI Tx Fpga_Write_Reg(FPGA1, Addr, 0xffff, 0); //Wait for SSI sequence to finish Thread.Sleep(800); } RetValue.Value = 1; return 1; } int SSI_Read_Write(Int32 Fpga, Int32 HighAdr, Int32 LowAdr, Int32 TxAdr) { var rv1 = Fpga_Read_Reg(Fpga, HighAdr, 0); var rv2 = Fpga_Read_Reg(Fpga, LowAdr, 0); stubManager.Write(" Adr = "); stubManager.WriteHex(TxAdr,4); stubManager.Write(" ("); stubManager.WriteHex(rv1.Value,4); stubManager.Write(", "); stubManager.WriteHex(rv2.Value,4); stubManager.Write(")"); //if ( (rv2.Value&0x200) == 0x200) stubManager.Write(" Error"); Fpga_Write_Reg(Fpga, TxAdr, 0xffff, 0); Thread.Sleep(100); return 1; }