Thanks for your inquiry.
You may use two 3-axis accelerometers to tell the angle between two enclosures. One is installed on the stationary enclosure and the other installed on the moving enclosure. Every time when powered on the two enclosures should not be placed vertically which means that the moving enclosure should not move left and right with respect to the stationary enclosure. Instead, the moving enclosure should move up and down with respect to the stationary enclosure when they are powered on.