// File: /workspace/github_cpp_makefile_star2_O2/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 0xa0ab8(%rip), %rdi     # 0x10c00e
callq 0x520bf
callq 0x51c47
cmpb $0x1, %al
je 0x6b5a9
movzbl %al, %ecx
testl %ecx, %ecx
jne 0x6b62e
callq 0x51dc3
movss %xmm0, -0x18(%rbp)
callq 0x51dc3
movss %xmm0, -0x14(%rbp)
leaq 0x197346(%rip), %r14    # 0x2028d0
cmpq $0x1, (%r14)
leaq 0x199a3f(%rip), %rbx    # 0x204fd4
jne 0x6b65a
cmpl $0x53, (%rbx)
jne 0x6b65a
jmp 0x6b688
callq 0x51dc3
movss %xmm0, -0x1c(%rbp)
callq 0x51dc3
movss %xmm0, -0x14(%rbp)
callq 0x51dc3
movss %xmm0, -0x18(%rbp)
leaq 0x197302(%rip), %r14    # 0x2028d0
cmpq $0x1, (%r14)
leaq 0x1999fb(%rip), %rbx    # 0x204fd4
jne 0x6b5e0
cmpl $0x53, (%rbx)
je 0x6b60b
testb $0x2, 0x2ea835(%rip)    # 0x355e1c
je 0x6b60b
callq 0x51dc3
movss %xmm0, -0x28(%rbp)
callq 0x51dc3
cvtss2sd -0x28(%rbp), %xmm1
movsd %xmm1, -0x30(%rbp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorl %edi, %edi
callq 0x52194
leaq 0x1bd957(%rip), %rax    # 0x228f70
cmpl $0x0, (%rax)
je 0x6b761
xorb $0x2, 0x2ea7f3(%rip)    # 0x355e1c
pushq $0x1
popq %rdi
jmp 0x6b6a4
leaq 0x1bd907(%rip), %rdx    # 0x228f3c
cmpb $0x0, (%rdx)
je 0x6b863
xorl %edi, %edi
callq 0x52194
leaq 0x1bd924(%rip), %rax    # 0x228f70
cmpl $0x0, (%rax)
jne 0x6bb01
jmp 0x6babf
leaq 0x1bd8db(%rip), %rax    # 0x228f3c
cmpb $0x0, (%rax)
je 0x6b8ed
callq 0x51dc3
movss %xmm0, -0x1c(%rbp)
callq 0x51dc3
movss %xmm0, -0x28(%rbp)
callq 0x51dc3
movss %xmm0, -0x30(%rbp)
xorl %edi, %edi
callq 0x52194
leaq 0x1bd8da(%rip), %rax    # 0x228f70
cmpl $0x0, (%rax)
je 0x6b6b1
xorb $0x1, 0x2ea77a(%rip)    # 0x355e1c
xorl %edi, %edi
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x670a5
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x28ba33(%rip), %rax    # 0x2f70f0
movsd %xmm0, (%rax)
leaq 0x28bc28(%rip), %rcx    # 0x2f72f0
pushq $0x1
popq %rax
movl %eax, (%rcx)
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x28ba27(%rip), %rcx    # 0x2f7100
movsd %xmm0, (%rcx)
leaq 0x28bc10(%rip), %rcx    # 0x2f72f4
movl %eax, (%rcx)
leaq 0x28c70f(%rip), %rcx    # 0x2f7dfc
movl (%rcx), %edx
movl %edx, %esi
orl $0x3, %esi
movl %esi, (%rcx)
cmpq $0x1, (%r14)
jne 0x6b705
cmpl $0x53, (%rbx)
je 0x6babf
leaq 0x1bd830(%rip), %rsi    # 0x228f3c
cmpb $0x0, (%rsi)
je 0x6b9f4
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x28b9e7(%rip), %rsi    # 0x2f7108
movsd %xmm0, (%rsi)
cvtss2sd -0x28(%rbp), %xmm0
leaq 0x28b9ef(%rip), %rsi    # 0x2f7120
movsd %xmm0, (%rsi)
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x28b9e7(%rip), %rsi    # 0x2f7128
movsd %xmm0, (%rsi)
leaq 0x28bbbc(%rip), %rsi    # 0x2f7308
movl %eax, (%rsi)
leaq 0x28bbaf(%rip), %rsi    # 0x2f7304
movl %eax, (%rsi)
orl $0x37, %edx
movl %edx, (%rcx)
jmp 0x6babf
leaq 0x199acc(%rip), %rax    # 0x205234
cmpb $0x0, (%rax)
jne 0x6bb01
leaq 0x28b9f0(%rip), %rax    # 0x2f7168
movl $0xf, (%rax)
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x28b97e(%rip), %rax    # 0x2f7108
movsd %xmm0, (%rax)
leaq 0x28bb63(%rip), %rcx    # 0x2f72f8
pushq $0x1
popq %rax
movl %eax, (%rcx)
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x28b97a(%rip), %rcx    # 0x2f7120
movsd %xmm0, (%rcx)
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x28b972(%rip), %rcx    # 0x2f7128
movsd %xmm0, (%rcx)
leaq 0x28bb47(%rip), %rcx    # 0x2f7308
movl %eax, (%rcx)
leaq 0x28bb3a(%rip), %rcx    # 0x2f7304
movl %eax, (%rcx)
leaq 0x28c629(%rip), %rcx    # 0x2f7dfc
movl (%rcx), %edx
movl %edx, %esi
orl $0x34, %esi
movl %esi, (%rcx)
cmpq $0x1, (%r14)
jne 0x6b7eb
cmpl $0x53, (%rbx)
je 0x6babf
testb $0x2, 0x2ea62a(%rip)    # 0x355e1c
je 0x6babf
leaq 0x28b941(%rip), %rsi    # 0x2f7140
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rsi)
leaq 0x28bb01(%rip), %rsi    # 0x2f7310
movl %eax, (%rsi)
leaq 0x28b930(%rip), %rsi    # 0x2f7148
movsd -0x28(%rbp), %xmm0
movsd %xmm0, (%rsi)
leaq 0x1bd712(%rip), %rsi    # 0x228f3a
orb $0x2, (%rsi)
leaq 0x28bae2(%rip), %rsi    # 0x2f7314
movl %eax, (%rsi)
movups 0xad388(%rip), %xmm0    # 0x118bc3
leaq 0x2badfe(%rip), %rax    # 0x326640
movaps %xmm0, (%rax)
movb $0x0, 0x10(%rax)
leaq 0x1997e8(%rip), %rax    # 0x205038
movl $0x5, (%rax)
orl $0x634, %edx            # imm = 0x634
movl %edx, (%rcx)
jmp 0x6baa9
cmpb $0x4, %al
je 0x6b98c
cmpl $0x3, %ecx
je 0x6b93f
cmpl $0x2, %ecx
jne 0x6b63e
callq 0x51dc3
movss %xmm0, -0x18(%rbp)
callq 0x51dc3
movss %xmm0, -0x14(%rbp)
xorl %edi, %edi
callq 0x52194
leaq 0x1bd6d1(%rip), %rax    # 0x228f70
cmpl $0x0, (%rax)
jne 0x6bb01
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x28b88c(%rip), %rax    # 0x2f7140
movsd %xmm0, (%rax)
leaq 0x28ba51(%rip), %rax    # 0x2f7310
pushq $0x1
popq %rcx
movl %ecx, (%rax)
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x28b878(%rip), %rax    # 0x2f7148
movsd %xmm0, (%rax)
leaq 0x28ba39(%rip), %rax    # 0x2f7314
movl %ecx, (%rax)
leaq 0x28c518(%rip), %rax    # 0x2f7dfc
orb $0x6, 0x1(%rax)
jmp 0x6babf
testb $0x1, 0x2ea528(%rip)    # 0x355e1c
je 0x6b5a4
callq 0x51dc3
movss %xmm0, -0x1c(%rbp)
callq 0x51dc3
movss %xmm0, -0x28(%rbp)
callq 0x51dc3
movss %xmm0, -0x30(%rbp)
callq 0x51dc3
movss %xmm0, -0x38(%rbp)
callq 0x51dc3
cvtss2sd -0x38(%rbp), %xmm1
movsd %xmm1, -0x38(%rbp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x6b688
callq 0x51dc3
movss %xmm0, -0x14(%rbp)
xorl %edi, %edi
callq 0x52194
leaq 0x1bd619(%rip), %rax    # 0x228f70
cmpl $0x0, (%rax)
jne 0x6bb01
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x28b7e4(%rip), %rax    # 0x2f7150
movsd %xmm0, (%rax)
leaq 0x28b989(%rip), %rax    # 0x2f7300
movl $0x1, (%rax)
leaq 0x28c478(%rip), %rax    # 0x2f7dfc
orb $0x8, (%rax)
jmp 0x6babf
callq 0x51dc3
movss %xmm0, -0x14(%rbp)
callq 0x51dc3
movss %xmm0, -0x18(%rbp)
xorl %edi, %edi
callq 0x52194
leaq 0x1bd5c2(%rip), %rax    # 0x228f70
cmpl $0x0, (%rax)
jne 0x6bb01
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x28b76d(%rip), %rax    # 0x2f7130
movsd %xmm0, (%rax)
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x28b765(%rip), %rax    # 0x2f7138
movsd %xmm0, (%rax)
leaq 0x28b92e(%rip), %rax    # 0x2f730c
movl $0x1, (%rax)
leaq 0x28c411(%rip), %rax    # 0x2f7dfc
orb $0x18, 0x1(%rax)
jmp 0x6babf
testb $0x1, 0x2ea421(%rip)    # 0x355e1c
je 0x6babf
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x28b6fb(%rip), %rsi    # 0x2f7108
movsd %xmm0, (%rsi)
cvtss2sd -0x28(%rbp), %xmm0
leaq 0x28b703(%rip), %rsi    # 0x2f7120
movsd %xmm0, (%rsi)
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x28b6fb(%rip), %rsi    # 0x2f7128
movsd %xmm0, (%rsi)
leaq 0x28b8d0(%rip), %rsi    # 0x2f7308
movl %eax, (%rsi)
leaq 0x28b8c3(%rip), %rsi    # 0x2f7304
movl %eax, (%rsi)
leaq 0x28b6f6(%rip), %rsi    # 0x2f7140
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rsi)
leaq 0x28b8b6(%rip), %rsi    # 0x2f7310
movl %eax, (%rsi)
leaq 0x28b6e5(%rip), %rsi    # 0x2f7148
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rsi)
leaq 0x28b8a1(%rip), %rsi    # 0x2f7314
movl %eax, (%rsi)
orl $0x637, %edx            # imm = 0x637
movl %edx, (%rcx)
leaq 0x1bd4b6(%rip), %rax    # 0x228f3a
orb $0x1, (%rax)
movups 0xad135(%rip), %xmm0    # 0x118bc3
leaq 0x2babab(%rip), %rax    # 0x326640
movaps %xmm0, (%rax)
movb $0x0, 0x10(%rax)
leaq 0x199595(%rip), %rax    # 0x205038
movl $0x4, (%rax)
leaq 0x19985d(%rip), %rax    # 0x20530d
cmpb $0x0, (%rax)
jne 0x6babf
leaq 0x199850(%rip), %rax    # 0x20530c
movb $0x0, (%rax)
leaq 0x28c336(%rip), %rax    # 0x2f7dfc
movl (%rax), %eax
notl %eax
movb $0x1, %cl
testb $0x3f, %al
je 0x6bae4
leaq 0x1bd465(%rip), %rcx    # 0x228f3c
cmpb $0x0, (%rcx)
setne %dl
testb $0x37, %al
sete %cl
andb %dl, %cl
testb %cl, %cl
je 0x6bb01
leaq 0x28c309(%rip), %rax    # 0x2f7df8
cmpl $0x0, (%rax)
je 0x6bb01
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x658c7
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq