Schematic Processor v2.0 documentation

Writing Processing Ops

Processing ops are written in Python. If you have ArcGIS installed, you also have Python installed. For your editor, you can use IDLE (which comes with Python), you can download any number of free editors or you can just use Notepad.

The remainder of this document assumes you have a basic understanding of how to create Python files with your editor of choice.

Creating the File

The schematic processor looks for ops in the ops subfolder within the schematic_processor folder. To create your own op, simply create a Python module (e.g., a file named my_nifty_op.py) in the ops folder.

Implementing the process_values Function

Your Python module must contain a function called process_values. This is the function that the schematic processor calls to simulate RECEIVE or PASS behavior. The function has two parameters (row and input_values) and is expected to return a numerical value.

The row parameter is an instance of an arcpy Row class. This object represents the schematic feature (a link or a node). It is supplied in case your function needs direct access to the feature. Otherwise, the values to process are provided in the input_values parameter.

The input_values parameter is a list of ValueTuple objects, where ValueTuple is a class with three attributes:

  • value – numerical value to process
  • source_class – class containing the feature providing the value
  • feature_id – unique identifier of the feature providing the value

Both RECEIVE and PASS behaviors are implemented with this function signature. For RECEIVE behavior, the input values include the incremental value for the given feature as well as all upstream values. There will be one ValueTuple in the input_values list for each value to handle. For PASS behavior, the input values will only include the total value for the current feature.

In simple cases, you will only need ValueTuple.value, but the other information is provided in case you need it. Once you have the input values, do whatever processing you need to and then return the result as a numerical value.

For examples of processing ops, please see the ops included in the ops folder within the schematic_processor folder, the simplest of which is the accumulation op.