Oxygen Systems

To equip an aircraft with a crew oxygen system, go to the second equipment tab of Plane Maker, and enter the crew oxygen bottle capacity in liter. Note that this refers to the volume of compressed oxygen in a typical 1800psi bottle. For reference, a popular Mountain High Oxygen system in a Cirrus SR22 has a capacity of 415 liter, and that will supply three people for about one hour and ten minutes at 18.000 feet. To use the oxygen system in your panel or plugin, you can then use the following datarefs:

sim/cockpit2/oxygen/actuators/o2_valve_on - this turns on the valve that allows oxygen to flow from the bottle through the pressure reducer to the ports.
sim/cockpit2/oxygen/actuators/num_plugged_in_o2 - this is how many people have masks plugged into those ports and are using them
sim/cockpit2/oxygen/actuators/demand_flow_setting - this is how the oxygen flow to the masks is regulated.
0: Off - no flow
1: Unregulated - the masks are plugged in directly, there is no pulse demand regulator
2: N - the pulse demand regulator is in N mode
3: D5 - the pulse demand regulator is in D5 mode
4: D10 - the pulse demand regulator is in D10 mode
5: F1 - the pulse demand regulator is in F1 mode
6: F2 - the pulse demand regulator is in F2 mode
7: F3 - the pulse demand regulator is in F3 mode
8: F4 - the pulse demand regulator is in F4 mode

These settings will have great influence on how fast you are going to deplete your oxygen reserve. For example, unregulated mode will blast you with oxygen regardless of your pressure altitude, whereas a demand regulator will give you less oxygen at lower pressure altitudes. For more information on the simulated pulse demand regulator, see the documentation of the real O2D2-G2 from Mountain High Oxygen:

http://www.mhoxygen.com/index.php/downloadsmanuals

To see the result of your oxygen consumption, you can use the following datarefs:

sim/cockpit2/oxygen/indicators/o2_bottle_pressure_psi - the pressure of the bottle, which is an indirect indication of how much is left in there (note that it's not completely linear with the remaining volume).
sim/cockpit2/oxygen/indicators/o2_bottle_rem_liter - this is cheating, and telling you the actual volume. Note that not all of that is useable, since the flow rate will drop when the pressure gets too low. For reference, a 415 liter system should be considered to have about 370 useable liter before you see a decrease in flow rate.
sim/cockpit2/oxygen/indicators/pilot_felt_altitude_ft - This is how good your mask user feels. The lower the altitude, the better. Hypoxia symptoms (X-Plane blackout) will begin at 12.500ft and be obvious at 15.000ft. 

Finally, if you want complete control over oxygen and pilot health, you can set the override

sim/operation/override/override_oxygen_system

which will allow you to set all these datarefs from your plugin and thus also completely control the blackout.

Passenger Oxygen

The passenger oxygen has been implemented since X-Plane 9.30 as a failure and annunciator dataref, exposed in the simulator as the “Passenger O2 on” failure. X-Plane 11.30 adds the following functionality: When your aircraft type is airliner, your aircraft does have a pressurized cabin (max differential pressure is greater than 0) and the cabin altitude climbs above 13,000ft, the masks are auto-deployed. Aircraft designers can check the

sim/operation/failures/rel_pass_o2_on

dataref for modelling dropped masks. If you model this in 3d, avoid using

sim/cockpit2/annunciators/passenger_oxy_on

for that purpose, otherwise you will show dropped masks when a light test is in progress!

X-Plane 11.30 adds these two new datarefs

sim/cockpit2/oxygen/indicators/pass_oxygenator_working - tells you whether the chemical oxygenator is actually still supplying oxygen
sim/cockpit2/oxygen/indicators/pass_oxygenator_min_rem - tells you how many minutes are left until they stop working

X-Plane 11.30 does not actually use these datarefs for anything yet, as it does not award points or a score. Plugin authors however can take advantage of these in combination with the cabin altitude dataref, to score passenger health for virtual airline or career system plugins.