Set up piston

Hi
I´m trying to build an excavator but having problem with the piston. What is the best approach to create a piston that can move according to point B in the attached picture?

Constrains? Static meshes that rotates on the influences of the arm positions?

Regards Steel