How to get rotation of constrained object?
The file you've linked works as it is supposed to work, you've given a Limit Rotation on the X axis of -30° and 30°, as seen below. 0° on the X axis is a flat axis (in Global axis but also in cylinder's Local axis if you ever switch to it).

If you want the gun to follow the angle you're displaying you need to choose Min -60° and Max 0°.

If you want the angle to be relative to the rectangle rotations, don't use a Copy Location for your cylinder, parent it to the rectangle so that it's new Global orientations depends on the rectangle, not on the world. Also don't forget to limit on Z so that it doesn't flip.