Building Your Own Scripts

When writing your own script please take a look at the Beacon Counter script in {PROGRAM_INSTALL}\Scripts\countBeacons.py, and use it as a guide. In order to be able to call your scripts from the PLC Sniffer, your script must accept the log database file name as a command line parameter expecified with “-d” flag:

    myPythonScript –d log_database_name

Inside your script, you can build complex queries or analyze data as needed. Beacon Counter script is very simple and is included as an example for building your own scripts. It can be replaced by a single SQL query:

    SELECT Sid, COUNT(*) FROM Frame where PduType = 2 GROUP BY Sid

Prime and G3 log database models are described in sections Appendix A. PRIME SQLite Log Database and Appendix B. G3-PLC SQLite Log Database respectively. Data fields are encoded as defined in the respective standards.

In order to let the PLC Sniffer tool to launch your own scripts, you must place your script in the {PROGRAM_INSTALL}\Scripts\ folder and update the ScriptsDb.xml file accordingly. Add a new <Script> Section describing your script. Each time the Script Launcher dialog is shown, the ScriptDB.xml file is parsed. All scripts defined in xml file will be available in the dialog for execution.