Skip to content

Appendix A Design

jgyates edited this page Dec 18, 2020 · 2 revisions

Overview

The general design of genmon.py is fairly simple. The application has a main python class named GeneratorDevice and two sub classes for serial communications, and email functionality. The following is a list of the classes and modules, their functions and threads:

  • GeneratorDevice class - Main Application
    • ProcessThread - Uses for polling the generator controller registers using Modbus over serial communications. A cached set of registers is maintained. The cached registers are checked for generator events and used to to display information via commands and the web interface.
    • MonitorThread - Used to display information to the console if enabled in genmon.conf. Reads from the cached copy of registers.
    • InterfaceServerThread - Supports a TCP socket server interface that allows external applications (ClientInterface.py, web interface, Nagios) to retrieve information and send commands to the generator
    • ComWatchDog - A thread that monitors the serial communications and reports an error if they are not occurring as expected.
    • DebugThread - Not active by default unless enabled in genmon.conf. This thread is used for monitoring unknown registers in the Controller for changes.
    • SerialDevice class - Handles serial communications. Uses external python module pyserial for low level serial communications.
      • Receive Thread - Used for polling serial port and storing received data in a buffer.
    • MyMail class - Handles transmitting and receiving mail (contained in the file mymail.py)
      • Email Command Thread - Used for polling the specified IMAP mail box folder for incoming main with commands in the subject field.
    • MyLog python module - Sets up logging for all other classes (contained in the file mylog.py)
    • MyThread python module - Helper functions for thread handling (contained in mythread.py)
    • crcmod - external python module for calculating the Modbus CRC