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; Int32 temp; Int32 counter = 0; UInt32 Direction = 0; Int32 Prev_counter = 0; public void OnExecute(StubManager stubManager) { while (true) { // Request ---- // UInt32 : Address // Response ---- // UInt32 : Address // UInt32 : Value // String : Status // UInt32 : StatusWord var response = stubManager.Run("StubFpgaReadRegRequest" ,0x60000100); //LSB //stubManager.WriteLine(response.Value); var response1 = stubManager.Run("StubFpgaReadRegRequest" ,0x60000102); //MSB //stubManager.WriteLine(response1.Value & 0x3FF ); Direction = (response1.Value) & 0400; temp = ((Int32)(response1.Value) & 0x3FF); temp = temp << 16; temp = temp + (Int32)(response.Value); if((Prev_counter - temp > 10) || (temp - Prev_counter > 10)) { if(Direction != 0) counter = counter - temp; else counter = counter + temp; } stubManager.WriteLine(temp); Prev_counter = temp; //counter = counter + temp; //stubManager.WriteLine(counter); //stubManager.WriteLine(temp); stubManager.Write("\n"); Thread.Sleep(1000); } }