Skip to content

Commit

Permalink
simple example of using a CollectingReporter in a script.
Browse files Browse the repository at this point in the history
  • Loading branch information
pabender committed Jun 4, 2019
1 parent ca65391 commit b7d71a2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jython/CollectingReporterExample.py
@@ -0,0 +1,25 @@
# Provides an example of retreiving the collection maintained
# by a jmri.CollectingReporter.
#
# This script simply retreives the contents of the collection
# and prints each entry. Entries may not be strings, so the
# output may require further interpretation, which this script
# does not perform.
#
# Author: Paul Bender, copyright 2019
# Part of the JMRI distribution
#
# The Reporter name is hardcoded in the example.
# Change the value to something that makes sense for your layout

import jmri

# get the reporter manager from the InstanceManager
rm = jmri.InstanceManager.getDefault(jmri.ReporterManager)
# ask for the reporter, and store it in rptr.
rptr = rm.getReporter("ZRD5C3:7")
# ask the reporter for the collection
array = rptr.getCollection().toArray()
# and print each entry
for i in array:
print i

0 comments on commit b7d71a2

Please sign in to comment.