" ."Error: invalid analogue cable end specification" ." $cable. Example of a correct spec: 8032C" .""; } else { $ans = array( $regs[1], 11 + ord($regs[2]) - ord(A) ); } } return $ans; } ################################################################ # Returns array with 'error' and 'data' keys. # The 'data' field contains a structure to be passed # to postamp_mainpage() function postamp_query_db($item_id, $item_type, $sernum) { $pa_dat = array( 'error' => '', 'data' => array( 'item_id' => $item_id, 'item_type' => $item_type ) ); ## ================================================================ ## Prepare status info $res = edit_get_status($item_id, $item_type); if($res['error']) { $pa_dat['error'] .= $res['error']; } else { $pa_dat['data']['status'] = $res['status']; $pa_dat['data']['status_date'] = $res['date']; $pa_dat['data']['status_set'] = $res['isset']; $pa_dat['data']['status_options'] = $res['options']; } ## ================================================================ ## Where is the item installed? $res = edit_get_base($sernum); if($res['error']) { $pa_dat['error'] .= $res['error']; } else { $pa_dat['data']['base_sernum'] = $res['base_sernum']; $pa_dat['data']['base_point'] = $res['point']; $pa_dat['data']['base_id'] = $res['base_sernum']? format_default_id( $res['base_sernum']) : ""; $pa_dat['data']['base_description'] = $res['description']; } ## ---------------------------------------------------------------- ## Parameters $res = edit_get_value( $sernum, 'postamp_pars', array('a','b') ); if($res['error']) { $pa_dat['error'] .= $res['error']; } else { $pa_dat['data']['fit_date'] = $res['date']; $pa_dat['data']['a'] = $res['a']; $pa_dat['data']['b'] = $res['b']; } ## ---------------------------------------------------------------- ## Cables $res = edit_get_parts( array($sernum), array(10,20,30) ); if($res['error']) { $pa_dat['error'] .= $res['error']; } else { $pa_dat['data']['cable_date'] = $res['last_date']; $dd = $res['data']; $pa_dat['data']['analogAsernum'] = $dd[$sernum][10]['part']['part_id']; $pa_dat['data']['analogA'] = format_default_id($dd[$sernum][10]['part']['part_id']) . postamp_analogue_letter($dd[$sernum][10]['part']['part_point']) ; $pa_dat['data']['analogBsernum'] = $dd[$sernum][10]['part']['part_id']; $pa_dat['data']['analogB'] = format_default_id($dd[$sernum][20]['part']['part_id']) . postamp_analogue_letter($dd[$sernum][20]['part']['part_point']) ; $pa_dat['data']['ecl'] = $dd[$sernum][30]['part']['part_id']; } ## ---------------------------------------------------------------- $pa_dat['data']['comments'] = get_comments($sernum); return $pa_dat; } #================================================================ # Returns HTML text to be used in between
..
function postamp_mainpage($data) { # ---------------------------------------------------------------- return "
\n" # ---------------------------------------------------------------- ."
\n" ."\n" ."Status:" ."\n" ."\n" . ($data['status_set'] ? "" : "(default) " ) ."\n" ."     " .( $data['status_date'] ? "\n" ."Status change date: $data[status_date]\n" ."\n" : "" ) ."
\n" # ---------------------------------------------------------------- # Cables ."
Connected cables
".href2($data['ecl'],"Output ch 1-16 (ECL)")."
".href2($data[analogBsernum],"Input ch 9-16 (Analog)")."
".href2($data[analogAsernum],"Input ch 1-8 (Analog)")."
" .( $data['cable_date']? "

Date of the last cabling change: $data[cable_date]\n" : "" ) ."

" # ---------------------------------------------------------------- .'
Calibration parameters A, B were derived from
Demand_Voltage = (1 + A)*Measured_Voltage + B,
all in millivolts. Demand voltage amplitude will be set from:
Demand = (1 + A)*Request + B
Here Request is understood as request amplitude (non negative number).
If Demand evaluates to a negative number, Demand = 0 will be used.
' # ---------------------------------------------------------------- # Parameters ."

PostAmp parameters:

A =     B = " .( $data['fit_date'] ? "    Effective date: $data[fit_date] " : "" ) ."
" # ---------------------------------------------------------------- # Comments ."

Comment to add

" # ---------------------------------------------------------------- ."
\n" ; } ################################################################ function postamp_modstr($vars, &$errflag) { $modstr = ''; if($vars['workdate'] == '') { $date_err = "Required date field missing."; } else { $date_err .= edit_std_date(&$vars['workdate']); } $date_str = ( $date_err == '' ? $vars['workdate'] : "$date_err\n" ); #---------------------------------------------------------------- if($vars['status'] != $vars['old_status']) { $modstr .= " Status $vars[old_status] $vars[status] $date_str "; } #---------------------------------------------------------------- if( ($vars['a'] != $vars['old_a']) ||($vars['b'] != $vars['old_b']) ) { $a_str = parcheck("a", $vars['a'], &$errflag); $b_str = parcheck("b", $vars['b'], &$errflag); $from_table = "" ."" ."" ."
A = $vars[old_a]
B = $vars[old_b]
" ; $to_table = "" ."" ."" ."
A = $a_str
B = $b_str
" ; $modstr .= "" ."Postamp pars" ."$from_table" ."$to_table" ."$date_str" ."\n" ; } #---------------- if(($modstr != '') && ($date_err != '')) { $errflag = 1; } return $modstr; } #================================================================ # Vars pa_sernum and old_pa_sernum should be set in the $vars array function postamp_part_ops($vars) { $errmsg = ''; $ans = array( 'error' => '', 'allsteps' => array() ); ##---------------- # constants $vars['tmpAnalogType'] = 8; $vars['old_tmpAnalogType'] = 8; $vars['tmpECLtype'] = 13; $vars['old_tmpECLtype'] = 13; $vars['tmpPostAmpType'] = 14; $vars['old_tmpPostAmpType'] = 14; $vars['cableA_cat'] = 10; $vars['old_cableA_cat'] = 10; $vars['cableB_cat'] = 20; $vars['old_cableB_cat'] = 20; $vars['cableECL_cat'] = 30; $vars['old_cableECL_cat'] = 30; $vars['tmpECLpt'] = 1; $vars['old_tmpECLpt'] = 1; ##---------------------------------------------------------------- list($analogA, $analogApt) = postamp_analogue_decompose($vars['analogA'], &$ans['error']); list($old_analogA, $old_analogApt) = postamp_analogue_decompose($vars['old_analogA'], &$ans['error']); if($ans['error'] != '') { return $ans; } $vars['tmpAnalogA'] = $analogA; $vars['old_tmpAnalogA'] = $old_analogA; $vars['tmpAnalogApt'] = $analogApt; $vars['old_tmpAnalogApt'] = $old_analogApt; # postamp_sernum comes from outside... $res = check_connection_change( 'tmpPostAmpType', 'pa_sernum', 'cableA_cat', 'tmpAnalogType', 'tmpAnalogA', 'workdate', $vars, 'tmpAnalogApt' ); $ans['error'] .= $res['error']; if($ans['error']) { return $ans; } $ans['allsteps'] = array_merge($ans['allsteps'], $res['steps']); ##---------------------------------------------------------------- list($old_analogB, $old_analogBpt) = postamp_analogue_decompose($vars['old_analogB'], &$ans['error']); list($analogB, $analogBpt) = postamp_analogue_decompose($vars['analogB'], &$ans['error']); if($ans['error'] != '') { return $ans; } $vars['tmpAnalogB'] = $analogB; $vars['old_tmpAnalogB'] = $old_analogB; $vars['tmpAnalogBpt'] = $analogBpt; $vars['old_tmpAnalogBpt'] = $old_analogBpt; # postamp_sernum comes from outside... $res = check_connection_change( 'tmpPostAmpType', 'pa_sernum', 'cableB_cat', 'tmpAnalogType', 'tmpAnalogB', 'workdate', $vars, 'tmpAnalogBpt' ); $ans['error'] .= $res['error']; if($ans['error']) { return $ans; } $ans['allsteps'] = array_merge($ans['allsteps'], $res['steps']); ##---------------------------------------------------------------- $res = check_connection_change( 'tmpPostAmpType', 'pa_sernum', 'cableECL_cat', 'tmpECLtype', 'ecl', 'workdate', $vars, 'tmpECLpt' ); $ans['error'] .= $res['error']; if($ans['error']) { return $ans; } $ans['allsteps'] = array_merge($ans['allsteps'], $res['steps']); #---------------------------------------------------------------- return $ans; } #---------------------------------------------------------------- # Vars pa_sernum and old_pa_sernum should be set in the $vars array function postamp_part_str($vars, &$errflag) { $parts_str = ''; $res = postamp_part_ops($vars); if($res['error'] != "") { $errflag = 1; $parts_str .= "" ."$res[error]" .""; } elseif($res['allsteps']) { while(list($i, $step) = each($res['allsteps'])) { $id_str = eregi("Analog.*cabl", $step['part_description']) ? ( $step['part_id'] . postamp_analogue_letter($step['item_point'])) : $step['part_id']; $act_str = ($step[action] == "install")? "Connect" : "Disconnect"; $parts_str .= "" ."$act_str" ."$step[part_description] $id_str" ."" . ($step[action]=="install"? "to":"from") . " $step[base_description] $step[base_id]" ."at $step[point_name]" ."on $step[date]" ."\n"; } } return $parts_str; } #================================================================ function postamp_stage2_vars($vars) { return "\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ."\n" ; } #================================================================ function postamp_write_db($sernum, $vars) { $err = ''; if($vars['status'] != $vars['old_status']) { $err .= edit_set_selected( $sernum, $vars['status'], $vars['workdate'], 'status', 'statuses', 'status'); } ##---------------------------------------------------------------- if( ($vars['a'] != $vars['old_a']) ||($vars['b'] != $vars['old_b']) ) { $err .= edit_set_values( $sernum, 'postamp_pars', $vars['workdate'], array( 'a' => $vars['a'], 'b' => $vars['b'] ) ); } ##---------------------------------------------------------------- $res = postamp_part_ops($vars); $err .= $res['error']; if($err == '') { while(list($i, $step) = each($res['allsteps'])) { $err .= edit_set_connection($step); } } return $err; } ################################################################ ?>