} $pc_dn[$i] = 0; } } GPIO_Output(GPIO_PIN_DN, GPIO_LOW); if ($something_changed) { io_write_shared_memory($shm_id, 0, $in_states, $in_programs, $in_levels); } //check the shared memory buffer for changes and send event messages $outputs_changed = 0; $inputs_changed = 0; $os = ''; $is = ''; $ip = ''; $il = ''; io_read_shared_memory($shm_id, $os, $is, $ip, $il); if ($os . $is . $ip . $il != $out_states . $in_states . $in_programs . $in_levels) { //something changed //if($os!=$out_states) set_outputs($os); //set the hardware outputs for ($i = 0; $i < OUT_PINS; $i++) { if (substr($os, $i * 2, 2) != substr($out_states, $i * 2, 2)) { send_io_output_binary_event_message($i, $os); //light $outputs_changed = 1; } } for ($i = 0; $i < IN_PINS; $i++) { if (substr($is, $i * 2, 2) != substr($in_states, $i * 2, 2) or substr($il, $i * 2, 2) != substr($in_levels, $i * 2, 2)) { send_io_input_level_event_message($i, $is, $il); //switch state and level $inputs_changed = 1;
//use this to set up the listener and register with the hub $b = ''; $os = ''; $is = ''; $ip = ''; $il = ''; $di = ''; $do1 = ''; $do2 = ''; while (1) { if ($must_exit) { break; } //send xAP heartbeat periodically $t = xap_check_send_heartbeat(array(XAPUID_IO_IN, XAPUID_IO_OUT, XAPUID_DMX_IN1, XAPUID_DMX_OUT1, XAPUID_DMX_OUT2), array(XAPSRC_IO_IN, XAPSRC_IO_OUT, XAPSRC_DMX_IN1, XAPSRC_DMX_OUT1, XAPSRC_DMX_OUT2)); io_read_shared_memory($io_shm_id, $out_states, $in_states, $in_programs, $in_levels); dmx_read_shared_memory($dmx_shm_id, $dmx_inputs, $dmx_outputs1, $dmx_outputs2); if ($xap = xap_listen($b)) { if ($debug & MSG_DEBUG_ID) { print_r($xap); } $c = process_xap_msgs($xap); } if ($os . $is . $ip . $il != $out_states . $in_states . $in_programs . $in_levels) { if ($debug & IO_DEBUG_ID) { logformat("Current IO State:\n"); logformat(sprintf("Out States :%s\n", $out_states)); logformat(sprintf("In States :%s\n", $in_states)); logformat(sprintf("In Programs:%s\n", $in_programs)); logformat(sprintf("In Levels :%s\n", $in_levels)); }