Building the Own Scripts
When writing the own script, 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 the scripts from the PLC Sniffer, the script must accept the log database file name as a command line parameter expecified with “-d” flag:
myPythonScript –d log_database_name
Inside the script, the user can build complex queries or analyze data as needed. Beacon Counter script is very simple and is included as an example for building the own scripts. It can be replaced by a single SQL query:
SELECT Sid, COUNT(*) FROM Frame where PduType = 2 GROUP BY Sid
PRIME database model is described in section Appendix A. PRIME SQLite Log Database. Data fields are encoded as defined in the respective standards.
In order to let the PLC Sniffer tool to launch the own scripts, the user must place the script in the {PROGRAM_INSTALL}\Scripts\ folder and update the ScriptsDb.xml file accordingly. Add a new <Script> Section describing the 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.
