// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: poll_next_scpi()
void poll_next_scpi()
{
int test;

   // request an item from a SCPI receiver.  Requests are alternated between
   // a time message and some receiver parameter.  The parameter requests are 
   // alternated between one of three important parameters and then the lesser
   // important ones.

   test = 1;
   if(test && (polled_q_in != polled_q_out)) {  // we have a special message request queued
      send_queued_cmd(1);
   }
   else if(polled_msg_id == SCPI_TIME_MSG) { // request next misc message every time
      if((test == 0) && (polled_q_in != polled_q_out)) {  // we have a special message request queued
         send_queued_cmd(2);
      }
      else if(scpi_type == NORTEL_TYPE) {
         if(polled_req < 0) polled_req = 0;

         if((polled_seq % 10) == 0) send_polled_cmd("PTIME:INTERVAL?",       SCPI_TINT_MSG);    
         else if((polled_seq % 10) == 1) send_polled_cmd("ROSC:CONT?",       SCPI_EFC_MSG);
         else {
            if     (polled_req ==  0) send_polled_cmd("PTIME:LEAPSECOND?",           SCPI_LEAPTIME_MSG);
            else if(polled_req ==  1) send_polled_cmd("PTIME:ACC:LEAPSECOND?",       SCPI_UTC_OFS_MSG);
            else if(polled_req ==  2) send_polled_cmd("*IDN?",                       SCPI_ID_MSG);
            else if(polled_req ==  3) send_polled_cmd("GPS:POSITION?",               SCPI_POSN_MSG);
            else if(polled_req ==  4) send_polled_cmd("GPS:REF:ADELAY?",             SCPI_GET_CABLE_MSG);
            else if(polled_req ==  5) send_polled_cmd("GPS:SAT:TRAC:EMANGLE?",       SCPI_ELEV_MSG);
            else if(polled_req ==  6) send_polled_cmd("ANTENNA:CONDITION?",          SCPI_ANTENNA_MSG);
            else if(polled_req ==  7) send_polled_cmd("STATUS:OPERATION:CONDITION?", SCPI_OPERATION_MSG);
            else if(polled_req ==  8) send_polled_cmd("STATUS:HARDWARE:CONDITION?",  SCPI_HARDWARE_MSG);
            else if(polled_req ==  9) send_polled_cmd("GPS:POS:SURVEY:PROGRESS?",    SCPI_PROGRESS_MSG);
            else if(polled_req == 10) send_polled_cmd("GPS:SAT:TRACKING?",           SCPI_TRACK_MSG);
            else if(polled_req == 11) send_polled_cmd("GPS:SAT:VIS:PRED?",           SCPI_VIS_MSG);
            else if(polled_req == 12) send_polled_cmd("ROSC:HOLD:DUR?",              SCPI_HOLDOVER_MSG);
            else if(polled_req == 13) send_polled_cmd("GPS:SAT:TRAC:IGNORE?",        SCPI_IGNORE_MSG);
            else if(polled_req == 14) send_polled_cmd("GPS:SAT:TRAC:INCLUDE?",       SCPI_INCLUDE_MSG);
            else if(polled_req == 15) send_polled_cmd("DIAG:LIFETIME:COUNT?",        SCPI_LIFE_MSG);
            else if(polled_req == 16) send_polled_cmd("SYNC:FFOM?",                  SCPI_FFOM_MSG);

            if(++polled_req > 16) {
               polled_req = 0;
               ++all_polled;
            }
         }
         ++polled_seq;
      }
      else {
//       queue_scpi_cmd(":DIAG:ROSC:EFC?", SCPI_EFC_MSG);     // we want these as often as possible
//       queue_scpi_cmd(":PTIM:TINT?",     SCPI_TINT_MSG);
//       queue_scpi_cmd(":ROSC:HOLD:TUNC:PRED?",    SCPI_TUNC_MSG);

         if(polled_req < 0) polled_req = 0;

         if(     (polled_seq % 10) == 0) send_polled_cmd(":PTIM:TINT?",           SCPI_TINT_MSG);
         else if((polled_seq % 10) == 1) send_polled_cmd(":DIAG:ROSC:EFC?",       SCPI_EFC_MSG);
         else {
            if     (polled_req == 0)  send_polled_cmd(":PTIM:LEAP:ACC?",          SCPI_UTC_OFS_MSG);
            else if(polled_req == 1)  {
               if(scpi_type == HP_TYPE) {
                  send_polled_cmd(":GPS:POS?", SCPI_POSN_MSG);
               }
               else {
                  send_polled_cmd(":GPS:POS:ACT?",            SCPI_POSN_MSG);
               }
            }
            else if(polled_req == 2)  send_polled_cmd("*IDN?",                    SCPI_ID_MSG);
            else if(polled_req == 3)  send_polled_cmd(":PTIM:GPS:SAT:VIS:PRED?",  SCPI_VIS_MSG);
            else if(polled_req == 4)  send_polled_cmd(":PTIM:GPS:SAT:TRAC?",      SCPI_TRACK_MSG);
            else if(polled_req == 5)  send_polled_cmd(":GPS:SAT:TRAC:IGN?"      , SCPI_IGNORE_MSG);
            else if(polled_req == 6)  send_polled_cmd(":STATUS:OPER:HARD:COND?",  SCPI_HARDWARE_MSG);
            else if(polled_req == 7)  send_polled_cmd(":ROSC:HOLD:DUR?",          SCPI_HOLDOVER_MSG);
            else if(polled_req == 8)  send_polled_cmd(":DIAG:GPS:UTC?",           SCPI_UTC_MSG);

            else if(polled_req == 9)  send_polled_cmd(":PTIM:GPS:EMAN?",          SCPI_ELEV_MSG);
            else if(polled_req == 10) send_polled_cmd(":PTIM:GPS:ADEL?",          SCPI_GET_CABLE_MSG);
            else if(polled_req == 11) send_polled_cmd(":PTIM:GPS:POS:SURV:STAT?", SCPI_SURVEY_MSG);
            else if(polled_req == 12) send_polled_cmd(":PTIM:GPS:POS:SURV:PROG?", SCPI_PROGRESS_MSG);
            else if(polled_req == 13) send_polled_cmd(":PTIM:LEAP:GPST?",         SCPI_LEAPTIME_MSG);
            else if(polled_req == 14) send_polled_cmd(":PTIM:LEAP:DATE?",         SCPI_LEAPTIME_MSG);
            else if(polled_req == 15) send_polled_cmd(":PTIM:PPS:EDGE?",          SCPI_EDGE_MSG);
            else if(polled_req == 16) send_polled_cmd(":DIAG:LIF:COUNT?",         SCPI_LIFE_MSG);
            else if(polled_req == 17) send_polled_cmd(":ROSC:HOLD:TUNC:PRED?", SCPI_TUNC_MSG);

            if(++polled_req > 17) {
               polled_req = 0;
               ++all_polled;
            }
         }
         ++polled_seq;
      }
   }
   else {
      send_polled_cmd(":PTIME:TCODE?", SCPI_TIME_MSG);  // request time message
   }
}

// Assembly:
movl 0x300acd(%rip), %eax    # 0x36ffd0
cmpl 0x300acb(%rip), %eax    # 0x36ffd4
jne 0x6f56d
cmpl $0x3e7, 0x2fd6eb(%rip)  # imm = 0x3E7
jne 0x6f577
pushq %rbp
movq %rsp, %rbp
leaq 0x1ababe(%rip), %rax    # 0x21afe0
movl (%rax), %eax
movl 0x300ab2(%rip), %ecx    # 0x36ffdc
cmpl $0x4e, %eax
jne 0x6f588
testl %ecx, %ecx
jns 0x6f53d
movl $0x0, 0x300a9f(%rip)    # 0x36ffdc
movl 0x300a9d(%rip), %eax    # 0x36ffe0
movl $0xcccccccd, %ecx       # imm = 0xCCCCCCCD
imulq %rax, %rcx
shrq $0x23, %rcx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
cmpl $0x1, %eax
je 0x6f5c7
testl %eax, %eax
jne 0x6f5e9
leaq 0xb5caf(%rip), %rdi     # 0x12521a
jmp 0x6f5c0
movl $0x1, %edi
jmp 0x8ab04
leaq 0xb5e67(%rip), %rdi     # 0x1253e5
movl $0x3e7, %esi            # imm = 0x3E7
jmp 0x6e3bc
testl %ecx, %ecx
jns 0x6f596
movl $0x0, 0x300a46(%rip)    # 0x36ffdc
movl 0x300a44(%rip), %ecx    # 0x36ffe0
movl $0xcccccccd, %edx       # imm = 0xCCCCCCCD
imulq %rcx, %rdx
shrq $0x23, %rdx
addl %edx, %edx
leal (%rdx,%rdx,4), %edx
subl %edx, %ecx
cmpl $0x1, %ecx
je 0x6f5d0
testl %ecx, %ecx
jne 0x6f61a
leaq 0xb5d1c(%rip), %rdi     # 0x1252dc
movl $0x10, %esi
jmp 0x6f5dc
leaq 0xb1ca5(%rip), %rdi     # 0x121273
jmp 0x6f5d7
leaq 0xb5d11(%rip), %rdi     # 0x1252e8
movl $0xb, %esi
callq 0x6e3bc
incl 0x3009f9(%rip)          # 0x36ffe0
popq %rbp
retq
movl 0x3009ed(%rip), %eax    # 0x36ffdc
cmpq $0x10, %rax
ja 0x6f740
leaq 0xaf6b0(%rip), %rcx     # 0x11ecb0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xb5c1a(%rip), %rdi     # 0x12522a
movl $0x1b, %esi
jmp 0x6f73b
movl 0x3009bc(%rip), %ecx    # 0x36ffdc
cmpq $0x11, %rcx
ja 0x6f86f
leaq 0xaf637(%rip), %rdx     # 0x11ec68
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0xb5cb7(%rip), %rdi     # 0x1252f8
movl $0xf, %esi
jmp 0x6f86a
leaq 0xb5c7f(%rip), %rdi     # 0x1252d1
movl $0x32, %esi
jmp 0x6f73b
leaq 0xb1617(%rip), %rdi     # 0x120c7a
movl $0x20, %esi
jmp 0x6f73b
leaq 0xb5cb2(%rip), %rdi     # 0x125326
movl $0xc, %esi
jmp 0x6f73b
leaq 0xb1926(%rip), %rdi     # 0x120fab
movl $0xe, %esi
jmp 0x6f73b
leaq 0xb1d78(%rip), %rdi     # 0x12140e
movl $0x16, %esi
jmp 0x6f73b
leaq 0xb221a(%rip), %rdi     # 0x1218c1
movl $0x12, %esi
jmp 0x6f73b
leaq 0xb1f2f(%rip), %rdi     # 0x1215e7
movl $0x1c, %esi
jmp 0x6f73b
leaq 0xb5bf6(%rip), %rdi     # 0x1252bc
movl $0x23, %esi
jmp 0x6f73b
leaq 0xb5b7e(%rip), %rdi     # 0x125252
movl $0x15, %esi
jmp 0x6f73b
leaq 0xb5b91(%rip), %rdi     # 0x125273
movl $0x34, %esi
jmp 0x6f73b
leaq 0xb5b4c(%rip), %rdi     # 0x12523c
movl $0xf, %esi
jmp 0x6f73b
leaq 0xb1712(%rip), %rdi     # 0x120e10
movl $0xa, %esi
jmp 0x6f73b
leaq 0xb1559(%rip), %rdi     # 0x120c65
movl $0x1e, %esi
jmp 0x6f73b
leaq 0xb5b46(%rip), %rdi     # 0x125260
movl $0x33, %esi
jmp 0x6f73b
leaq 0xb5b82(%rip), %rdi     # 0x1252aa
movl $0xd, %esi
jmp 0x6f73b
leaq 0xb5b59(%rip), %rdi     # 0x12528f
movl $0x1a, %esi
callq 0x6e3bc
movl 0x300896(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x30088d(%rip)    # 0x36ffdc
cmpl $0x10, %eax
jl 0x6f5e1
jmp 0x6f887
leaq 0xb5c5a(%rip), %rdi     # 0x1253be
movl $0x23, %esi
jmp 0x6f86a
leaq 0xb5c38(%rip), %rdi     # 0x1253ad
jmp 0x6f82d
leaq 0xb1ebf(%rip), %rdi     # 0x121640
movl $0x13, %esi
jmp 0x6f86a
leaq 0xb5ba6(%rip), %rdi     # 0x125338
movl $0xd, %esi
jmp 0x6f86a
leaq 0xb5be0(%rip), %rdi     # 0x125383
movl $0x12, %esi
jmp 0x6f86a
leaq 0xb1684(%rip), %rdi     # 0x120e38
movl $0xa, %esi
jmp 0x6f86a
leaq 0xb1e22(%rip), %rdi     # 0x1215e7
movl $0x1c, %esi
jmp 0x6f86a
leaq 0xb1820(%rip), %rdi     # 0x120ff6
movl $0x22, %esi
jmp 0x6f86a
leaq 0xb5b39(%rip), %rdi     # 0x125320
movl $0xc, %esi
jmp 0x6f86a
leaq 0xb1c18(%rip), %rdi     # 0x12140d
movl $0x16, %esi
jmp 0x6f86a
cmpl $0x38, %eax
jne 0x6f85e
leaq 0xb5b00(%rip), %rdi     # 0x125308
jmp 0x6f865
leaq 0xb5bbe(%rip), %rdi     # 0x1253cf
movl $0x18, %esi
jmp 0x6f86a
leaq 0xb1382(%rip), %rdi     # 0x120ba1
movl $0x1e, %esi
jmp 0x6f86a
leaq 0xb5b6f(%rip), %rdi     # 0x12539c
movl $0x1b, %esi
jmp 0x6f86a
leaq 0xb5b11(%rip), %rdi     # 0x12534c
movl $0x1a, %esi
jmp 0x6f86a
leaq 0xb5b2a(%rip), %rdi     # 0x125373
movl $0xe, %esi
jmp 0x6f86a
leaq 0xb5b0d(%rip), %rdi     # 0x125364
movl $0x17, %esi
jmp 0x6f86a
leaq 0xb5aad(%rip), %rdi     # 0x125312
movl $0x15, %esi
callq 0x6e3bc
movl 0x300767(%rip), %eax    # 0x36ffdc
leal 0x1(%rax), %ecx
movl %ecx, 0x30075e(%rip)    # 0x36ffdc
cmpl $0x11, %eax
jl 0x6f5e1
movl $0x0, 0x30074b(%rip)    # 0x36ffdc
incl 0x2fc531(%rip)          # 0x36bdc8
jmp 0x6f5e1