Use Node Constraints and gimricks. Also use an Sphere (general shape)
Piston Gimrick parent, sphere item as child object. This in folders structure
Sphere object as Parent, Female hand node as child in Node constraits
Sphere object as parent, Dick node as child in Node constarits.
That way you can control stroke and speed standalone, also can adjust position moving piston freely.
This is only one method, there are other, for example, Clip cpntroller.
I usually at home on weekends, for now I am away my potato machine, but if ya had the patient, I will make a short tutorial for you.