A project by Ken Hanawalt for the Turtle Creek Railroad.
On the Turtle Creek Railroad layout, at the town of Charleroi, there is a small yard for the Ferry Train branch and also a few mainline industries. In the diagram below, the branch tracks and industries are blue, the mainline tracks are red, Tracks shared by the branch and main are violet, and mainline industries are black. Both main and branch are protected by signals where they go into a tunnel on the right. The turnout marked with a circle in the diagram separates the main and branch areas, and is usually set in "reverse" to guide any mainline train onto the front (mainline) track and to restrain the branch train to the back. The Ferry branch is a turn, coming in from the right and returning to the right.
The lock is a small 3D printed object with a hinged lid that fits over the throwbar of a Peco turnout and prevents the turnout from being changed when the lid is shut. Other brands of turnouts would have to be modified or would require a different cutout. The base of the lock (left part of the diagram shown below) contains a cut out for a Hall-Effect transistor, a cutout for the end of the turnout throwbar, and part of the hinge. The top of the lock (middle part below) contains the other part of the hinge, a cutout for a magnet, and a cutout for the throwbar. The cover for the lock (right part) is glued to the top of the lock when assembled and serves as a handle. The cutout in the bottom part prevents the throwbar from moving toward the lock and the cutout in the top part prevents the throwbar from moving away from the lock unless the lid is open. When the lock is assembled, a straight sewing pin is used to hold the hinge parts together and serve as an axle.
The left photo below shows the lock installed over the turnout throwbar with the lid shut so the turnout cannot be changed. The turnout is in "reverse" position, so a train on the inner (shared) mainline will be directed to the outside main and right hand-tunnel entrance. The right photo shows the lock with the lid open (painted red inside as a warning to the operator). With the lid open, the turnout position can be changed and the track signal at the tunnel entrance will be red.