// File: /workspace/github_cpp_makefile_star2_O1/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 0xac747(%rip), %rdi     # 0x121fe6
callq 0x58e77
callq 0x587d1
cmpl $0x100, %eax            # imm = 0x100
jb 0x758ba
leaq 0x1c96b9(%rip), %rcx    # 0x23ef70
orb $0x8, (%rcx)
cmpb $0x1, %al
je 0x75903
movzbl %al, %ecx
testl %ecx, %ecx
jne 0x7598a
callq 0x58aae
movss %xmm0, -0x18(%rbp)
callq 0x58aae
movss %xmm0, -0x14(%rbp)
leaq 0x1a2fec(%rip), %r14    # 0x2188d0
cmpq $0x1, (%r14)
leaq 0x1a56e5(%rip), %rbx    # 0x21afd4
jne 0x759b6
cmpl $0x53, (%rbx)
jne 0x759b6
jmp 0x759e4
callq 0x58aae
movss %xmm0, -0x1c(%rbp)
callq 0x58aae
movss %xmm0, -0x14(%rbp)
callq 0x58aae
movss %xmm0, -0x18(%rbp)
leaq 0x1a2fa8(%rip), %r14    # 0x2188d0
cmpq $0x1, (%r14)
leaq 0x1a56a1(%rip), %rbx    # 0x21afd4
jne 0x7593a
cmpl $0x53, (%rbx)
je 0x75965
testb $0x2, 0x2f64db(%rip)    # 0x36be1c
je 0x75965
callq 0x58aae
movss %xmm0, -0x28(%rbp)
callq 0x58aae
cvtss2sd -0x28(%rbp), %xmm1
movsd %xmm1, -0x30(%rbp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorl %edi, %edi
callq 0x58f50
leaq 0x1c95fd(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
je 0x75ad3
xorb $0x2, 0x2f6499(%rip)    # 0x36be1c
movl $0x1, %edi
jmp 0x75a00
leaq 0x1c95ab(%rip), %rdx    # 0x23ef3c
cmpb $0x0, (%rdx)
je 0x75be5
xorl %edi, %edi
callq 0x58f50
leaq 0x1c95c8(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75ea2
jmp 0x75e60
leaq 0x1c957f(%rip), %rax    # 0x23ef3c
cmpb $0x0, (%rax)
je 0x75c77
callq 0x58aae
movss %xmm0, -0x1c(%rbp)
callq 0x58aae
movss %xmm0, -0x28(%rbp)
callq 0x58aae
movss %xmm0, -0x30(%rbp)
xorl %edi, %edi
callq 0x58f50
leaq 0x1c957e(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
je 0x75a0d
xorb $0x1, 0x2f641e(%rip)    # 0x36be1c
xorl %edi, %edi
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x70756
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x2976d4(%rip), %rax    # 0x30d0f0
movsd %xmm0, (%rax)
leaq 0x2978c9(%rip), %rax    # 0x30d2f0
movl $0x1, %ecx
movl %ecx, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x2976c3(%rip), %rax    # 0x30d100
movsd %xmm0, (%rax)
leaq 0x2978ac(%rip), %rax    # 0x30d2f4
movl %ecx, (%rax)
leaq 0x2983ab(%rip), %rax    # 0x30ddfc
movl (%rax), %ecx
movl %ecx, %edx
orl $0x3, %edx
movl %edx, (%rax)
cmpq $0x1, (%r14)
jne 0x75a69
cmpl $0x53, (%rbx)
je 0x75e60
leaq 0x1c94cc(%rip), %rdx    # 0x23ef3c
cmpb $0x0, (%rdx)
je 0x75d87
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x297680(%rip), %rdx    # 0x30d108
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x28(%rbp), %xmm0
leaq 0x297685(%rip), %rdx    # 0x30d120
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x29767a(%rip), %rdx    # 0x30d128
movsd %xmm0, (%rdx)
leaq 0x29784f(%rip), %rdx    # 0x30d308
movl $0x1, %esi
movl %esi, (%rdx)
leaq 0x29783d(%rip), %rdx    # 0x30d304
movl %esi, (%rdx)
orl $0x37, %ecx
movl %ecx, (%rax)
jmp 0x75e60
leaq 0x1a575a(%rip), %rax    # 0x21b234
cmpb $0x0, (%rax)
jne 0x75ea2
leaq 0x29767e(%rip), %rax    # 0x30d168
movl $0xf, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x297609(%rip), %rax    # 0x30d108
movsd %xmm0, (%rax)
leaq 0x2977ee(%rip), %rax    # 0x30d2f8
movl $0x1, %ecx
movl %ecx, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x297600(%rip), %rax    # 0x30d120
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x2975f5(%rip), %rax    # 0x30d128
movsd %xmm0, (%rax)
leaq 0x2977ca(%rip), %rax    # 0x30d308
movl %ecx, (%rax)
leaq 0x2977bd(%rip), %rax    # 0x30d304
movl %ecx, (%rax)
leaq 0x2982ac(%rip), %rax    # 0x30ddfc
movl (%rax), %ecx
movl %ecx, %edx
orl $0x34, %edx
movl %edx, (%rax)
cmpq $0x1, (%r14)
jne 0x75b68
cmpl $0x53, (%rbx)
je 0x75e60
testb $0x2, 0x2f62ad(%rip)    # 0x36be1c
je 0x75e60
leaq 0x2975c4(%rip), %rdx    # 0x30d140
movsd -0x30(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x297784(%rip), %rdx    # 0x30d310
movl $0x1, %esi
movl %esi, (%rdx)
leaq 0x2975ae(%rip), %rdx    # 0x30d148
movsd -0x28(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x1c9390(%rip), %rdx    # 0x23ef3a
orb $0x2, (%rdx)
leaq 0x297760(%rip), %rdx    # 0x30d314
movl %esi, (%rdx)
movups 0xb8ff6(%rip), %xmm0    # 0x12ebb3
leaq 0x2c6a7c(%rip), %rdx    # 0x33c640
movaps %xmm0, (%rdx)
movb $0x0, 0x10(%rdx)
leaq 0x1a5466(%rip), %rdx    # 0x21b038
movl $0x5, (%rdx)
orl $0x634, %ecx            # imm = 0x634
movl %ecx, (%rax)
jmp 0x75e4a
cmpb $0x4, %al
je 0x75d19
cmpl $0x3, %ecx
je 0x75cc9
cmpl $0x2, %ecx
jne 0x7599a
callq 0x58aae
movss %xmm0, -0x18(%rbp)
callq 0x58aae
movss %xmm0, -0x14(%rbp)
xorl %edi, %edi
callq 0x58f50
leaq 0x1c934f(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75ea2
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x297507(%rip), %rax    # 0x30d140
movsd %xmm0, (%rax)
leaq 0x2976cc(%rip), %rax    # 0x30d310
movl $0x1, %ecx
movl %ecx, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x2974ee(%rip), %rax    # 0x30d148
movsd %xmm0, (%rax)
leaq 0x2976af(%rip), %rax    # 0x30d314
movl %ecx, (%rax)
leaq 0x29818e(%rip), %rax    # 0x30ddfc
orb $0x6, 0x1(%rax)
jmp 0x75e60
testb $0x1, 0x2f619e(%rip)    # 0x36be1c
je 0x758fe
callq 0x58aae
movss %xmm0, -0x1c(%rbp)
callq 0x58aae
movss %xmm0, -0x28(%rbp)
callq 0x58aae
movss %xmm0, -0x30(%rbp)
callq 0x58aae
movss %xmm0, -0x38(%rbp)
callq 0x58aae
cvtss2sd -0x38(%rbp), %xmm1
movsd %xmm1, -0x38(%rbp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
jmp 0x759e4
callq 0x58aae
movss %xmm0, -0x14(%rbp)
xorl %edi, %edi
callq 0x58f50
leaq 0x1c928f(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75ea2
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x297457(%rip), %rax    # 0x30d150
movsd %xmm0, (%rax)
leaq 0x2975fc(%rip), %rax    # 0x30d300
movl $0x1, (%rax)
leaq 0x2980eb(%rip), %rax    # 0x30ddfc
orb $0x8, (%rax)
jmp 0x75e60
callq 0x58aae
movss %xmm0, -0x14(%rbp)
callq 0x58aae
movss %xmm0, -0x18(%rbp)
xorl %edi, %edi
callq 0x58f50
leaq 0x1c9235(%rip), %rax    # 0x23ef70
cmpl $0x0, (%rax)
jne 0x75ea2
xorps %xmm0, %xmm0
cvtss2sd -0x14(%rbp), %xmm0
leaq 0x2973dd(%rip), %rax    # 0x30d130
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
cvtss2sd -0x18(%rbp), %xmm0
leaq 0x2973d2(%rip), %rax    # 0x30d138
movsd %xmm0, (%rax)
leaq 0x29759b(%rip), %rax    # 0x30d30c
movl $0x1, (%rax)
leaq 0x29807e(%rip), %rax    # 0x30ddfc
orb $0x18, 0x1(%rax)
jmp 0x75e60
testb $0x1, 0x2f608e(%rip)    # 0x36be1c
je 0x75e60
xorps %xmm0, %xmm0
cvtss2sd -0x1c(%rbp), %xmm0
leaq 0x297365(%rip), %rdx    # 0x30d108
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x28(%rbp), %xmm0
leaq 0x29736a(%rip), %rdx    # 0x30d120
movsd %xmm0, (%rdx)
xorps %xmm0, %xmm0
cvtss2sd -0x30(%rbp), %xmm0
leaq 0x29735f(%rip), %rdx    # 0x30d128
movsd %xmm0, (%rdx)
leaq 0x297534(%rip), %rdx    # 0x30d308
movl $0x1, %esi
movl %esi, (%rdx)
leaq 0x297522(%rip), %rdx    # 0x30d304
movl %esi, (%rdx)
leaq 0x297355(%rip), %rdx    # 0x30d140
movsd -0x38(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x297515(%rip), %rdx    # 0x30d310
movl %esi, (%rdx)
leaq 0x297344(%rip), %rdx    # 0x30d148
movsd -0x40(%rbp), %xmm0
movsd %xmm0, (%rdx)
leaq 0x297500(%rip), %rdx    # 0x30d314
movl %esi, (%rdx)
orl $0x637, %ecx            # imm = 0x637
movl %ecx, (%rax)
leaq 0x1c9115(%rip), %rax    # 0x23ef3a
orb $0x1, (%rax)
movups 0xb8d84(%rip), %xmm0    # 0x12ebb3
leaq 0x2c680a(%rip), %rax    # 0x33c640
movaps %xmm0, (%rax)
movb $0x0, 0x10(%rax)
leaq 0x1a51f4(%rip), %rax    # 0x21b038
movl $0x4, (%rax)
leaq 0x1a54bc(%rip), %rax    # 0x21b30d
cmpb $0x0, (%rax)
jne 0x75e60
leaq 0x1a54af(%rip), %rax    # 0x21b30c
movb $0x0, (%rax)
leaq 0x297f95(%rip), %rax    # 0x30ddfc
movl (%rax), %eax
notl %eax
movb $0x1, %cl
testb $0x3f, %al
je 0x75e85
leaq 0x1c90c4(%rip), %rcx    # 0x23ef3c
cmpb $0x0, (%rcx)
setne %dl
testb $0x37, %al
sete %cl
andb %dl, %cl
testb %cl, %cl
je 0x75ea2
leaq 0x297f68(%rip), %rax    # 0x30ddf8
cmpl $0x0, (%rax)
je 0x75ea2
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x6ee58
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq