You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
4.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "tgzWindow.h"
  2. #include "../../source/lib/hardware/soc/modules/pru/pru_ss.h"
  3. tgz1Window::tgz1Window( protocolTGZ *Device ) : WindowCLI( NULL ){
  4. m_pDeviceProtocol = Device;
  5. m_x = 3;
  6. m_y = 3;
  7. m_w = 40;
  8. m_h = 17;
  9. #ifdef NEWT_CLI
  10. m_l1 = newtLabel( 3, 1, "Bytes: 3 2 1 0");
  11. m_l2 = newtLabel( 3, 2, "Data : 00 00 00 00");
  12. m_l3 = newtLabel( 3, 3, " MSB --- LSB");
  13. m_t1 = newtTextbox( 10, 2, 11, 1, 0 );
  14. m_l4 = newtLabel( 3, 4, "PRF: KHz");
  15. m_t2 = newtTextbox( 8, 4, 3, 1, 0 );
  16. m_l5 = newtLabel( 3, 5, "Divider:");
  17. m_t3 = newtTextbox( 12, 5, 2, 1, 0 );
  18. m_l6 = newtLabel( 3, 6, "Ratio:");
  19. m_t4 = newtTextbox( 10, 6, 3, 1, 0 );
  20. m_l7 = newtLabel( 3, 7, "Flags: Start[ ] Reset Error[ ]");
  21. m_t5 = newtTextbox( 16, 7, 1, 1, 0 );
  22. m_t6 = newtTextbox( 31, 7, 1, 1, 0 );
  23. m_oMenu = newtListbox( 3, 9, 7, NEWT_FLAG_RETURNEXIT | NEWT_FLAG_SCROLL );
  24. newtListboxAppendEntry( m_oMenu, "Toggle Start/Stop", (void *) 1 );
  25. newtListboxAppendEntry( m_oMenu, "Toggle Reset-Error", (void *) 2 );
  26. newtListboxAppendEntry( m_oMenu, "Toggle PRF", (void *) 3 );
  27. newtListboxAppendEntry( m_oMenu, "Toggle Divider", (void *) 4 );
  28. newtListboxAppendEntry( m_oMenu, "Toggle Ratio", (void *) 5 );
  29. newtListboxAppendEntry( m_oMenu, "Send CMD to TGZ", (void *) 6 );
  30. newtListboxAppendEntry( m_oMenu, "EXIT", (void *) 255 );
  31. newtFormAddComponents( m_oForm, m_l1, m_l2, m_l3, m_l4, m_l5, m_l6, m_l7, m_t1, m_t2, m_t3, m_t4, m_t5, m_t6, m_oMenu, NULL );
  32. #else
  33. create( 0, 18, 40, 17 );
  34. #endif
  35. };
  36. tgz1Window::~tgz1Window(){
  37. newtPopWindow();
  38. };
  39. int tgz1Window::decodeEvent( newtComponent evt ){
  40. if( evt == m_oMenu ) {
  41. void *selected;
  42. selected = newtListboxGetCurrent( m_oMenu );
  43. return ( int )selected;
  44. };
  45. return 0;
  46. };
  47. void tgz1Window::paint( void ){
  48. #ifdef NEWT_CLI
  49. newtCenteredWindow( m_w, m_h, "TGZ Old Protocol" );
  50. if( m_pDeviceProtocol != NULL ) {
  51. char tBuffer[245];
  52. m_dwMyStatus = m_pDeviceProtocol->getPreparing();
  53. m_dwTGZStatus = m_pDeviceProtocol->getLastReceived();
  54. sprintf( tBuffer, "%02X %02X %02X %02X", ((m_dwMyStatus >> 24 )& 0xFF),((m_dwMyStatus >> 16 )& 0xFF),((m_dwMyStatus >> 8 )& 0xFF),( m_dwMyStatus & 0xFF) );
  55. newtTextboxSetText( m_t1, tBuffer );
  56. sprintf( tBuffer, "%d", m_pDeviceProtocol->getPRF() );
  57. newtTextboxSetText( m_t2, tBuffer );
  58. sprintf( tBuffer, "%d", m_pDeviceProtocol->getDivider() );
  59. newtTextboxSetText( m_t3, tBuffer );
  60. sprintf( tBuffer, "%d", m_pDeviceProtocol->getRatio() );
  61. newtTextboxSetText( m_t4, tBuffer );
  62. sprintf( tBuffer, "%c",(m_pDeviceProtocol->getRunFlag()?'*':' '));
  63. newtTextboxSetText( m_t5, tBuffer );
  64. sprintf( tBuffer, "%c",(m_pDeviceProtocol->getResetFlag()?'*':' '));
  65. newtTextboxSetText( m_t6, tBuffer );
  66. }
  67. newtDrawForm( m_oForm );
  68. #else
  69. createBox( true );
  70. mvwprintw( m_pWND, 2,2, " TGZ Communication " );
  71. if( m_pDeviceProtocol != NULL ) {
  72. m_dwMyStatus = m_pDeviceProtocol->getPreparing();
  73. m_dwTGZStatus = m_pDeviceProtocol->getLastReceived();
  74. mvwprintw( m_pWND, 3,2, " Frame 0x200 output: \t%08X", m_dwMyStatus );
  75. mvwprintw( m_pWND, 4,2, " Control Byte: \t0x%02X [%s%s]", (m_dwMyStatus & 0xFF),((m_dwMyStatus & 0xFF)&2)?"Run":"Stp",((m_dwMyStatus & 0xFF)&1)?",RstErr":"");
  76. mvwprintw( m_pWND, 5,2, " PRF: \t\t%d kHz", ((m_dwMyStatus >> 8) & 0xFF) );
  77. mvwprintw( m_pWND, 6,2, " Block Cycles: \t%d", ((m_dwMyStatus >> 16) & 0xFF) );
  78. mvwprintw( m_pWND, 7,2, " PRF Divider: \t%d", ((m_dwMyStatus >> 24) & 0xFF) );
  79. mvwprintw( m_pWND, 8,2, " Frame 0x201 input: \t%08X", m_dwTGZStatus );
  80. mvwprintw( m_pWND, 9,2, " Status Byte: \t0x%02X [%s%s%s]", (m_dwTGZStatus & 0xFF), ((m_dwTGZStatus & 0xFF)&4)?"Sync":"nSync",((m_dwTGZStatus & 0xFF)&2)?",Run":"",((m_dwTGZStatus & 0xFF)&1)?",Rdy":",Stb" );
  81. mvwprintw( m_pWND, 10,2, " PRF: \t\t%d kHz", ((m_dwTGZStatus >> 8) & 0xFF) );
  82. mvwprintw( m_pWND, 11,2, " Block Cycles: \t%d", ((m_dwTGZStatus >> 16) & 0xFF) );
  83. mvwprintw( m_pWND, 12,2, " PRF Divider: \t%d", ((m_dwTGZStatus >> 24) & 0xFF) );
  84. if( (((m_dwMyStatus & 0xFF)&2)== 0 ) && ((( m_dwTGZStatus & 0xFF)&2)== 0 ) ) {
  85. mvwprintw( m_pWND, 15,2, " [Available to Config]" );
  86. } else {
  87. mvwprintw( m_pWND, 15,2, " [Config is Disabled]" );
  88. }
  89. } else {
  90. mvwprintw( m_pWND, 3,2, " Not Init" );
  91. }
  92. wrefresh( m_pWND );
  93. #endif
  94. };