// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: get_discipline_params()
void get_discipline_params()
{
u08 type;
float v1,v2,v3;
float v4,v5,v6,v7;
int osc_ok;

   log_packet_id("Packet 0x8F.A8 (Discipline params)");

   type = tsip_byte();

   if(type == 0) {
      v1 = tsip_single();
      v2 = tsip_single();
      if(STARLOC) ;
      else if(saw_ntpx) {
         v3 = tsip_single();
         v4 = tsip_single();
         v5 = tsip_single();
//sprintf(plot_title, "v: %f %f %f %f %f      ", v1,v2,v3,v4,v5);
      } 
      else if(try_nortel & 0x01) {
         v3 = tsip_single();
         v4 = tsip_single();
         v5 = tsip_single();
         v6 = tsip_single();
         v7 = tsip_single();
      }
      check_tsip_end(1);

      if(tsip_error) {
         try_nortel ^= 0x01;
         request_discipline_params(0x00);
         return;
      }

      time_constant = v1;
      have_tc = 0x01;

      damping_factor = v2;
      have_damp = 1;
      have_osc_params |= (PARAM_TC | PARAM_DAMP);

      if(STARLOC) ;
      else if(saw_ntpx) {
         osc_gain = v3;
         min_volts = v4;
         max_volts = v5;
         have_minv = have_maxv = 1;
         have_osc_params |= (PARAM_GAIN | PARAM_MINV | PARAM_MAXV);
      }
      else if(try_nortel & 0x01) {
         osc_gain = v3;
         min_volts = v4;
         max_volts = v5;
         have_minv = have_maxv = 1;
         have_osc_params |= (PARAM_GAIN | PARAM_MINV | PARAM_MAXV);

         jam_sync = v6;
         have_jam_sync = 1;
         max_freq_offset = v7;
         have_freq_ofs = 1;
         have_osc_params |= (PARAM_JAMSYNC | PARAM_MAXFREQ);

         saw_nortel |= 0x01;
         strcpy(unit_name, "Nortel NTGS/NTBW"); 
         saw_gpsdo = 4;
         if(user_set_temp_filter == 0) undo_fw_temp_filter = 0;
      }
   }
   else if(type == 1) {
      v1 = tsip_single();
      v2 = tsip_single();
      v3 = tsip_single();
      if(STARLOC) ;
      else if(try_nortel & 0x02) {
         v4 = tsip_single();
         v5 = tsip_single();
      }
      check_tsip_end(1);
      if(tsip_error) {
         try_nortel ^= 0x02;
         request_discipline_params(0x01);
         return;
      }
      if(pause_data) return;   // in case reading log file,  we don't want to change the OSC_GAIN
                               // since the user may be calculating osc parameters
      gain_color = WHITE;
      osc_gain = v1;
      have_gain = 1;
      min_volts = v2;
      max_volts = v3;
      have_minv = have_maxv = 1;
      have_osc_params |= (PARAM_GAIN | PARAM_MINV | PARAM_MAXV);

      if(STARLOC);
      else if(try_nortel & 0x02) {
         jam_sync = v4;
         have_jam_sync = 1;
         max_freq_offset = v5;
         have_freq_ofs = 1;
         saw_nortel |= 0x02;
         strcpy(unit_name, "Nortel NTGS/NTBW"); 
         saw_gpsdo = 5;
         have_osc_params |= (PARAM_JAMSYNC | PARAM_MAXFREQ);
         if(user_set_temp_filter == 0) undo_fw_temp_filter = 0;
      }
   }
   else if(saw_ntpx) {  // packets 2,3,4 have no data
      check_tsip_end(1);
      if(tsip_error) return;
   }
   else if(type == 2) {
      v1 = tsip_single();
      v2 = tsip_single();
      check_tsip_end(1);
      if(tsip_error) return;

      jam_sync = v1;
      have_jam_sync = 1;
      max_freq_offset = v2;
      have_freq_ofs = 1;
      have_osc_params |= (PARAM_JAMSYNC | PARAM_MAXFREQ);
   }
   else if(type == 3) {
      v1 = tsip_single();
      check_tsip_end(1);
      if(tsip_error) return;

      initial_voltage = v1;
      have_initv = 1;
      have_osc_params |= (PARAM_INITV);
   }
   else if(type == 4) {     // undocumented - allowable dac range?
      v1 = tsip_single();
      v2 = tsip_single();
      check_tsip_end(1);
      if(tsip_error) return;

      min_dac_v = v1;
      max_dac_v = v2;
      have_dac_range = 1;
      have_osc_params |= (PARAM_MINRANGE | PARAM_MAXRANGE);
   }
   else {
      check_tsip_end(1);
      if(tsip_error) return;
   }

   if((have_osc_params & PARAM_TBOLT) == PARAM_TBOLT) {  // !!!!! 0x0F: we have all osc params available
      osc_ok = 1;
   }
   else if(saw_ntpx && ((have_osc_params & PARAM_NTPX) == PARAM_NTPX)) {
      osc_ok = 1;
   }
   else osc_ok = 0;


   if(1 && user_set_osc_param && osc_ok) {  // set osc params from command line values
      update_osc_params();
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x30, %rsp
leaq 0xac9c5(%rip), %rdi     # 0x1220c6
callq 0x58dc2
callq 0x587be
cmpl $0x100, %eax            # imm = 0x100
jb 0x7571c
leaq 0x1c9857(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
cmpb $0x1, %al
je 0x75765
movzbl %al, %ecx
testl %ecx, %ecx
jne 0x757ec
callq 0x58a30
movss %xmm0, -0x18(%rbp)
callq 0x58a30
movss %xmm0, -0x14(%rbp)
leaq 0x1a318a(%rip), %r14    # 0x2188d0
cmpq $0x1, (%r14)
leaq 0x1a5883(%rip), %rbx    # 0x21afd4
jne 0x75818
cmpl $0x53, (%rbx)
jne 0x75818
jmp 0x75846
callq 0x58a30
movss %xmm0, -0x1c(%rbp)
callq 0x58a30
movss %xmm0, -0x14(%rbp)
callq 0x58a30
movss %xmm0, -0x18(%rbp)
leaq 0x1a3146(%rip), %r14    # 0x2188d0
cmpq $0x1, (%r14)
leaq 0x1a583f(%rip), %rbx    # 0x21afd4
jne 0x7579c
cmpl $0x53, (%rbx)
je 0x757c7
testb $0x2, 0x2f6679(%rip)    # 0x36be1c
je 0x757c7
callq 0x58a30
movss %xmm0, -0x28(%rbp)
callq 0x58a30
cvtss2sd -0x28(%rbp), %xmm1
movsd %xmm1, -0x30(%rbp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorl %edi, %edi
callq 0x58e9b
leaq 0x1c979b(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
je 0x75935
xorb $0x2, 0x2f6637(%rip)    # 0x36be1c
movl $0x1, %edi
jmp 0x75862
leaq 0x1c9749(%rip), %rdx    # 0x23ef3c
cmpb $0x0, (%rdx)
je 0x75a47
xorl %edi, %edi
callq 0x58e9b
leaq 0x1c9766(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75d04
jmp 0x75cc2
leaq 0x1c971d(%rip), %rax    # 0x23ef3c
cmpb $0x0, (%rax)
je 0x75ad9
callq 0x58a30
movss %xmm0, -0x1c(%rbp)
callq 0x58a30
movss %xmm0, -0x28(%rbp)
callq 0x58a30
movss %xmm0, -0x30(%rbp)
xorl %edi, %edi
callq 0x58e9b
leaq 0x1c971c(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
je 0x7586f
xorb $0x1, 0x2f65bc(%rip)    # 0x36be1c
xorl %edi, %edi
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x70871
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x297872(%rip), %rax    # 0x30d0f0
movsd %xmm0, (%rax)
leaq 0x297a67(%rip), %rax    # 0x30d2f0
movl $0x1, %ecx
movl %ecx, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x297861(%rip), %rax    # 0x30d100
movsd %xmm0, (%rax)
leaq 0x297a4a(%rip), %rax    # 0x30d2f4
movl %ecx, (%rax)
leaq 0x298549(%rip), %rax    # 0x30ddfc
movl (%rax), %ecx
movl %ecx, %edx
orl $0x3, %edx
movl %edx, (%rax)
cmpq $0x1, (%r14)
jne 0x758cb
cmpl $0x53, (%rbx)
je 0x75cc2
leaq 0x1c966a(%rip), %rdx    # 0x23ef3c
cmpb $0x0, (%rdx)
je 0x75be9
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x29781e(%rip), %rdx    # 0x30d108
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x28(%rbp), %xmm0
leaq 0x297823(%rip), %rdx    # 0x30d120
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x297818(%rip), %rdx    # 0x30d128
movsd %xmm0, (%rdx)
leaq 0x2979ed(%rip), %rdx    # 0x30d308
movl $0x1, %esi
movl %esi, (%rdx)
leaq 0x2979db(%rip), %rdx    # 0x30d304
movl %esi, (%rdx)
orl $0x37, %ecx
movl %ecx, (%rax)
jmp 0x75cc2
leaq 0x1a58f8(%rip), %rax    # 0x21b234
cmpb $0x0, (%rax)
jne 0x75d04
leaq 0x29781c(%rip), %rax    # 0x30d168
movl $0xf, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x2977a7(%rip), %rax    # 0x30d108
movsd %xmm0, (%rax)
leaq 0x29798c(%rip), %rax    # 0x30d2f8
movl $0x1, %ecx
movl %ecx, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x29779e(%rip), %rax    # 0x30d120
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x297793(%rip), %rax    # 0x30d128
movsd %xmm0, (%rax)
leaq 0x297968(%rip), %rax    # 0x30d308
movl %ecx, (%rax)
leaq 0x29795b(%rip), %rax    # 0x30d304
movl %ecx, (%rax)
leaq 0x29844a(%rip), %rax    # 0x30ddfc
movl (%rax), %ecx
movl %ecx, %edx
orl $0x34, %edx
movl %edx, (%rax)
cmpq $0x1, (%r14)
jne 0x759ca
cmpl $0x53, (%rbx)
je 0x75cc2
testb $0x2, 0x2f644b(%rip)    # 0x36be1c
je 0x75cc2
leaq 0x297762(%rip), %rdx    # 0x30d140
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x297922(%rip), %rdx    # 0x30d310
movl $0x1, %esi
movl %esi, (%rdx)
leaq 0x29774c(%rip), %rdx    # 0x30d148
movsd -0x28(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x1c952e(%rip), %rdx    # 0x23ef3a
orb $0x2, (%rdx)
leaq 0x2978fe(%rip), %rdx    # 0x30d314
movl %esi, (%rdx)
movups 0xb9284(%rip), %xmm0    # 0x12eca3
leaq 0x2c6c1a(%rip), %rdx    # 0x33c640
movaps %xmm0, (%rdx)
movb $0x0, 0x10(%rdx)
leaq 0x1a5604(%rip), %rdx    # 0x21b038
movl $0x5, (%rdx)
orl $0x634, %ecx            # imm = 0x634
movl %ecx, (%rax)
jmp 0x75cac
cmpb $0x4, %al
je 0x75b7b
cmpl $0x3, %ecx
je 0x75b2b
cmpl $0x2, %ecx
jne 0x757fc
callq 0x58a30
movss %xmm0, -0x18(%rbp)
callq 0x58a30
movss %xmm0, -0x14(%rbp)
xorl %edi, %edi
callq 0x58e9b
leaq 0x1c94ed(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75d04
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x2976a5(%rip), %rax    # 0x30d140
movsd %xmm0, (%rax)
leaq 0x29786a(%rip), %rax    # 0x30d310
movl $0x1, %ecx
movl %ecx, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x29768c(%rip), %rax    # 0x30d148
movsd %xmm0, (%rax)
leaq 0x29784d(%rip), %rax    # 0x30d314
movl %ecx, (%rax)
leaq 0x29832c(%rip), %rax    # 0x30ddfc
orb $0x6, 0x1(%rax)
jmp 0x75cc2
testb $0x1, 0x2f633c(%rip)    # 0x36be1c
je 0x75760
callq 0x58a30
movss %xmm0, -0x1c(%rbp)
callq 0x58a30
movss %xmm0, -0x28(%rbp)
callq 0x58a30
movss %xmm0, -0x30(%rbp)
callq 0x58a30
movss %xmm0, -0x38(%rbp)
callq 0x58a30
cvtss2sd -0x38(%rbp), %xmm1
movsd %xmm1, -0x38(%rbp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x75846
callq 0x58a30
movss %xmm0, -0x14(%rbp)
xorl %edi, %edi
callq 0x58e9b
leaq 0x1c942d(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75d04
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x2975f5(%rip), %rax    # 0x30d150
movsd %xmm0, (%rax)
leaq 0x29779a(%rip), %rax    # 0x30d300
movl $0x1, (%rax)
leaq 0x298289(%rip), %rax    # 0x30ddfc
orb $0x8, (%rax)
jmp 0x75cc2
callq 0x58a30
movss %xmm0, -0x14(%rbp)
callq 0x58a30
movss %xmm0, -0x18(%rbp)
xorl %edi, %edi
callq 0x58e9b
leaq 0x1c93d3(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75d04
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x29757b(%rip), %rax    # 0x30d130
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x297570(%rip), %rax    # 0x30d138
movsd %xmm0, (%rax)
leaq 0x297739(%rip), %rax    # 0x30d30c
movl $0x1, (%rax)
leaq 0x29821c(%rip), %rax    # 0x30ddfc
orb $0x18, 0x1(%rax)
jmp 0x75cc2
testb $0x1, 0x2f622c(%rip)    # 0x36be1c
je 0x75cc2
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x297503(%rip), %rdx    # 0x30d108
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x28(%rbp), %xmm0
leaq 0x297508(%rip), %rdx    # 0x30d120
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x2974fd(%rip), %rdx    # 0x30d128
movsd %xmm0, (%rdx)
leaq 0x2976d2(%rip), %rdx    # 0x30d308
movl $0x1, %esi
movl %esi, (%rdx)
leaq 0x2976c0(%rip), %rdx    # 0x30d304
movl %esi, (%rdx)
leaq 0x2974f3(%rip), %rdx    # 0x30d140
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x2976b3(%rip), %rdx    # 0x30d310
movl %esi, (%rdx)
leaq 0x2974e2(%rip), %rdx    # 0x30d148
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x29769e(%rip), %rdx    # 0x30d314
movl %esi, (%rdx)
orl $0x637, %ecx            # imm = 0x637
movl %ecx, (%rax)
leaq 0x1c92b3(%rip), %rax    # 0x23ef3a
orb $0x1, (%rax)
movups 0xb9012(%rip), %xmm0    # 0x12eca3
leaq 0x2c69a8(%rip), %rax    # 0x33c640
movaps %xmm0, (%rax)
movb $0x0, 0x10(%rax)
leaq 0x1a5392(%rip), %rax    # 0x21b038
movl $0x4, (%rax)
leaq 0x1a565a(%rip), %rax    # 0x21b30d
cmpb $0x0, (%rax)
jne 0x75cc2
leaq 0x1a564d(%rip), %rax    # 0x21b30c
movb $0x0, (%rax)
leaq 0x298133(%rip), %rax    # 0x30ddfc
movl (%rax), %eax
notl %eax
movb $0x1, %cl
testb $0x3f, %al
je 0x75ce7
leaq 0x1c9262(%rip), %rcx    # 0x23ef3c
cmpb $0x0, (%rcx)
setne %dl
testb $0x37, %al
sete %cl
andb %dl, %cl
testb %cl, %cl
je 0x75d04
leaq 0x298106(%rip), %rax    # 0x30ddf8
cmpl $0x0, (%rax)
je 0x75d04
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x6edd3
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq