//has the required delay passed? set_output_state($outputs, $i, substr($os, $i * 2, 2)); //toggle the real output $otimes[$i + 1] = sprintf("%d,%.02f", 1 - $tstate[0], $t); //remember time of the state change $houtputs_changed++; } } } if ($houtputs_changed) { set_outputs($outputs); //set the hardware outputs if ($debug & IO_DEBUG_ID) { logformat("Current Hardware State:\n"); logformat(sprintf("Out States :%s\n", $outputs)); } } } if ($must_exit) { break; } //now sleep until our next POLL period starts while ((microtime(true) - $t) * 1000 < POLLINTERVAL) { usleep(10000); } //10ms sleep } io_write_state_file($state_file, $out_states, $in_states, $in_programs, $in_levels); socket_close($xap_sock_in); shmop_close($shm_id); logformat("hac_io exiting cleanly.\n");
function io_create_state_file($state_file, &$out_states, &$in_states, &$in_programs, &$in_levels) { $out_states = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; $in_states = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; $in_programs = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'; $in_levels = 'A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0A0'; return io_write_state_file($state_file, $out_states, $in_states, $in_programs, $in_levels); }