It's an Enigma. In particular, it's a naval Enigma. Excellent article at
Wikipedia Enigma article.
Only the naval Enigma had four rotors; other Enigmas had [almost always] three. It's both electrical and mechanical. The upper "keyboard" is not a keyboard but a set of lamps. When encrypting, the operator pressed a key to enter a plaintext character, and a lamp illuminated corresponding to the cyphertext character. The operator pressed a key, looked at the lamp, and wrote the cyphertext on a piece of paper for the radioman to send. In decrypting a received message, it worked exactly the same. Spare bulbs are stored in the row at the upper edge of the lid; there are several of them up there, on the left.