dmx_write_shared_memory($shm_id, $di, 0, 0); //send xap event(s) for ($i = 0; $i < 128; $i++) { if (substr($di, $i * 2, 2) != substr($dmx_inputs, $i * 2, 2)) { send_dmx_input_level_event_message($i, $di); } } $dmx_inputs = $di; } } } else { $outs1_changed = 0; $outs2_changed = 0; $do1 = ''; $do2 = ''; dmx_read_shared_memory($shm_id, $di, $do1, $do2); if ($do1 . $do2 != $dmx_outputs1 . $dmx_outputs2) { //something changed in shm for ($i = 0; $i < 128; $i++) { if (substr($do1, $i * 2, 2) != substr($dmx_outputs1, $i * 2, 2)) { //send xap dmx level change message for universe 1 send_dmx_output_level_event_message($i, XAPSRC_DMX_OUT1, XAPUID_DMX_OUT1, $do1, $donames1); $outs1_changed = 1; } if (substr($do2, $i * 2, 2) != substr($dmx_outputs2, $i * 2, 2)) { //send xap dmx level change message for universe 2 send_dmx_output_level_event_message($i, XAPSRC_DMX_OUT2, XAPUID_DMX_OUT2, $do2, $donames2); $outs2_changed = 1; } } }
$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)); } $os = $out_states;