{
  "productInfo" : {
    "company" : "HighByte",
    "product" : "IntelligenceHub",
    "version" : "4.5.0",
    "build" : "2026.8.7.376",
    "stage" : "Alpha"
  },
  "project" : {
    "version" : 14,
    "connections" : [ {
      "name" : "mqtt",
      "uri" : "mqtt://localhost:1889",
      "description" : "This is a Connection to the Intelligence Hub MQTT broker created for the purpose of viewing Pipeline outputs.",
      "tags" : [ "starter_canary", "starter_ip21", "starter_pi_af", "starter_pi_da" ],
      "writes" : {
        "flattenModeledValues" : false
      },
      "writeThrottle" : {
        "enabled" : false,
        "maxBatchSizePerTarget" : 1000,
        "batchDelay" : {
          "duration" : 20,
          "units" : "Milliseconds"
        }
      },
      "subscriptions" : { },
      "storeForward" : {
        "enabled" : false,
        "maxEntries" : 100,
        "waitOnFailureInterval" : {
          "duration" : 1,
          "units" : "Seconds"
        }
      },
      "settings" : {
        "connectionTimeoutSeconds" : 10,
        "keepAliveSeconds" : 60,
        "requestTimeoutMS" : 5000,
        "maxInflight" : 1000,
        "cleanSession" : true,
        "mcpEnabled" : "disabled",
        "ssl" : false,
        "redundantBrokers" : [ ],
        "inputDiscovery" : "",
        "clientId" : "Intelligence_Hub_Reference",
        "maxMessagesReceived" : 0
      }
    }, {
      "name" : "pi_af",
      "uri" : "osisoft.afsdk://{{System.Variables.host_reference}}:45299",
      "description" : "This is a Connection to AVEVA PI System.  The purpose of the Connection is to obtain data for starter solution examples and, specifically starter solutions related to PI Asset Framework.  HighByte note: this Connection uses a dedicated agent installed on a demo system EC2.",
      "tags" : [ "starter_pi_af" ],
      "writes" : {
        "flattenModeledValues" : false
      },
      "writeThrottle" : {
        "enabled" : false,
        "maxBatchSizePerTarget" : 1000,
        "batchDelay" : {
          "duration" : 20,
          "units" : "Milliseconds"
        }
      },
      "subscriptions" : { },
      "storeForward" : {
        "enabled" : false,
        "maxEntries" : 100,
        "waitOnFailureInterval" : {
          "duration" : 1,
          "units" : "Seconds"
        }
      },
      "settings" : {
        "connectTimeoutSeconds" : 5,
        "requestTimeoutMS" : 120000,
        "compression" : "GZIP",
        "auth" : {
          "type" : "credentials",
          "username" : "osisoft",
          "password" : {
            "type" : "Reference",
            "value" : "pi_password"
          }
        },
        "password" : {
          "type" : "Reference",
          "value" : "pi_token_reference"
        }
      }
    } ],
    "inputs" : [ {
      "name" : "pi_af_input_current_values",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "asset",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : true,
          "includeChildren" : false,
          "database" : "ReactorsDemo",
          "query" : "Template: 'Pump'",
          "attributes" : [ "FlowRate", "Status" ],
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_af_input_event_frame",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "eventframe",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : false,
          "database" : "ReactorsDemo",
          "query" : "Template: \"Downtime\" AND End:>\"{{this.startTime}}\" AND End:<\"{{this.endTime}}\"",
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "startTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-05-26T21:59:16.875Z",
            "internalType" : {
              "variant" : "String"
            }
          }, {
            "attributeType" : "Internal",
            "name" : "endTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-05-26T22:00:16.875Z",
            "internalType" : {
              "variant" : "String"
            }
          } ],
          "modelVersion" : ""
        }
      }
    }, {
      "name" : "pi_af_input_event_frame_test",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "eventframe",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : false,
          "database" : "ReactorsDemo",
          "query" : "Name: \"OSIDemo_Line 2_Inlet Pump_Downtime_2026-05-26 21:00:00.000\"",
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_af_input_event_frame_values",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "asset",
        "options" : {
          "get" : "rawValues",
          "includeMetaData" : true,
          "includeChildren" : false,
          "database" : "ReactorsDemo",
          "query" : "ID: {{this.elementID}}",
          "index" : false,
          "indexWindow" : "",
          "startTime" : "{{this.start}}",
          "endTime" : "{{this.end}}",
          "interval" : "1m",
          "attributes" : [ "SuctionPressure", "Status", "SerialNumber", "ReasonCode", "OnOff", "Manufacturer", "FlowRate", "BearingTemperature" ]
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "elementID",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "43607d6c-7a21-11ec-832d-0a7a14cb841b",
            "internalType" : {
              "variant" : "String"
            }
          }, {
            "attributeType" : "Internal",
            "name" : "start",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-05-03T04:00:00.0000000Z",
            "internalType" : {
              "variant" : "String"
            }
          }, {
            "attributeType" : "Internal",
            "name" : "end",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-05-03T08:00:00.0000000Z",
            "internalType" : {
              "variant" : "String"
            }
          } ],
          "modelVersion" : ""
        }
      }
    }, {
      "name" : "pi_af_input_metadata_asset_attributes_page",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "assetmetadata",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : false,
          "includeAttributes" : true,
          "database" : "Grains",
          "query" : "Template: 'Equipment Tag'",
          "index" : false,
          "indexWindow" : "",
          "paging" : true,
          "startIndex" : "{{this.pageIndex}}",
          "pageSize" : "{{this.pageSize}}"
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "pageIndex",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "internalType" : {
              "variant" : "String"
            }
          }, {
            "attributeType" : "Internal",
            "name" : "pageSize",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "internalType" : {
              "variant" : "String"
            }
          } ],
          "modelVersion" : ""
        }
      }
    }, {
      "name" : "pi_af_input_metadata_assets",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "assetmetadata",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : false,
          "includeAttributes" : true,
          "database" : "ReactorsDemo",
          "query" : "Name: 'Inlet Pump' OR Name: 'Outlet Pump'",
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_af_input_metadata_assets_for_tag_list",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "assetmetadata",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : false,
          "includeAttributes" : true,
          "database" : "ReactorsDemo",
          "query" : "Name: 'Inlet Pump' OR Name: 'Outlet Pump'",
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : true,
        "interval" : {
          "duration" : 1,
          "units" : "Days"
        }
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_af_input_metadata_assets_page",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "assetmetadata",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : false,
          "includeAttributes" : false,
          "database" : "Grains",
          "query" : "Template: 'Base'",
          "index" : false,
          "indexWindow" : "",
          "paging" : true,
          "startIndex" : "{{this.pageIndex}}",
          "pageSize" : "{{this.pageSize}}"
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "pageIndex",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : 0,
            "internalType" : {
              "variant" : "String"
            }
          }, {
            "attributeType" : "Internal",
            "name" : "pageSize",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : 100,
            "internalType" : {
              "variant" : "String"
            }
          } ],
          "modelVersion" : ""
        }
      }
    }, {
      "name" : "pi_af_input_value_changes",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "assetdatapipe",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : true,
          "database" : "ReactorsDemo",
          "query" : "Template: 'Pump'",
          "subscriptionId" : "pi_af_input_value_changes_5_26",
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_af_input_values_time_span",
      "connection" : "pi_af",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "asset",
        "options" : {
          "get" : "rawValues",
          "includeMetaData" : true,
          "includeChildren" : false,
          "database" : "ReactorsDemo",
          "query" : "Template: 'Pump'",
          "attributes" : [ "FlowRate", "Status" ],
          "startTime" : "{{this.startTime}}",
          "endTime" : "{{this.endTime}}",
          "interval" : "1s",
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "referenceMap" : [ ],
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "startTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2025-07-09T00:00:00.0000000Z",
            "internalType" : {
              "variant" : "String"
            }
          }, {
            "attributeType" : "Internal",
            "name" : "endTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2025-07-09T00:01:00.0000000Z",
            "internalType" : {
              "variant" : "String"
            }
          } ],
          "modelVersion" : ""
        }
      }
    } ],
    "outputs" : [ ],
    "modeling" : {
      "models" : [ {
        "name" : "starter_metadata_asset_attributes",
        "description" : "This is an example provided for modeling asset attribute metadata.  It is a component of a starter solution.",
        "groupAs" : "/starter_hist_read_metadata_assets",
        "tags" : [ "starter_pi_af" ],
        "attributes" : [ {
          "attributeType" : "Internal",
          "name" : "assetId",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "assetPath",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "attributeId",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "attributeName",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "attributeDescription",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "attributeDataType",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "attributeUnits",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "pointID",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "source",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "time",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "DateTime"
          }
        } ],
        "modelVersion" : ""
      }, {
        "name" : "starter_metadata_assets",
        "description" : "This is an example provided for modeling asset metadata.  It is a component of a starter solution.",
        "groupAs" : "/starter_hist_read_metadata_assets",
        "tags" : [ "starter_pi_af" ],
        "attributes" : [ {
          "attributeType" : "Internal",
          "name" : "assetId",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "assetName",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "assetTemplateId",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "assetPath",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "assetVersion",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "source",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "String"
          }
        }, {
          "attributeType" : "Internal",
          "name" : "time",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : {
            "variant" : "DateTime"
          }
        } ],
        "modelVersion" : ""
      } ],
      "instances" : [ ]
    },
    "conditions" : [ ],
    "functions" : [ ],
    "tags" : [ {
      "name" : "starter_pi_af"
    } ],
    "pipelines" : [ {
      "name" : "starter_output_pi_af_metadata_asset_attributes_page_to_mqtt",
      "description" : "This Pipeline obtains asset attribute metadata from AVEVA PI System Asset Framework and models the data before publishing the data to the Intelligence Hub MQTT Broker.  This Pipeline leverages the Connection Input's paging capability to process asset attribute metadata for a large number of assets.",
      "groupAs" : "/starter_hist_read_metadata_assets",
      "tags" : [ "starter_pi_af" ],
      "inputStages" : [ "while_data" ],
      "stages" : [ {
        "name" : "while_data",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : -205
          },
          "size" : {
            "width" : 4200,
            "height" : 500
          },
          "metadata" : { }
        },
        "description" : "Loop while there is data to process.",
        "config" : {
          "type" : ".WhileLoopConfig",
          "failureOutputs" : [ ],
          "loopOutputs" : [ "pageIndex_pageSize" ],
          "stageTimeout" : {
            "duration" : 90,
            "units" : "Minutes"
          },
          "expression" : "return loop.value.length >  loop.metadata.pageSize * (loop.runCount - 1);",
          "loopValue" : "ACCUMULATED"
        },
        "outputs" : [ ]
      }, {
        "name" : "return_while",
        "display" : {
          "position" : {
            "x" : 3850,
            "y" : 205
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "",
        "config" : {
          "type" : ".ReturnConfig"
        },
        "outputs" : [ ]
      }, {
        "name" : "read_pi_data",
        "display" : {
          "position" : {
            "x" : 500,
            "y" : 205
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "Read data from PI passing page index and page size parameters.",
        "config" : {
          "type" : ".ReadConfig",
          "failureOutputs" : [ ],
          "reference" : {
            "type" : "Input",
            "name" : "pi_af_input_metadata_asset_attributes_page",
            "path" : "",
            "params" : {
              "pageIndex" : "{{event.metadata.pageIndex}} ",
              "pageSize" : "{{event.metadata.pageSize}} "
            },
            "connectionName" : "pi_af"
          },
          "handleGoodNoData" : false,
          "goodNoDataOutputs" : [ ]
        },
        "outputs" : [ "for_assets" ]
      }, {
        "name" : "for_assets",
        "display" : {
          "position" : {
            "x" : 950,
            "y" : 50
          },
          "size" : {
            "width" : 2750,
            "height" : 400
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "This loop processes each asset.",
        "config" : {
          "type" : ".ForEachLoopConfig",
          "failureOutputs" : [ ],
          "loopOutputs" : [ "asset_to_metadata" ],
          "stageTimeout" : {
            "duration" : 5,
            "units" : "Minutes"
          }
        },
        "outputs" : [ "return_while" ]
      }, {
        "name" : "pageIndex_pageSize",
        "display" : {
          "position" : {
            "x" : 50,
            "y" : 205
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "This Stage uses JavaScript to set the page size and page index parameters that will be passed to the Connection Input.",
        "config" : {
          "type" : ".JavaScriptTransformConfig",
          "transformExpression" : "const pageSize = 10;\r\nconst pageIndex = event.metadata.loopIndex * pageSize;\r\nstage.setMetadata(\"pageIndex\", pageIndex); \r\nstage.setMetadata(\"pageSize\", pageSize);\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "read_pi_data" ]
      }, {
        "name" : "each_attribute",
        "display" : {
          "position" : {
            "x" : 500,
            "y" : 50
          },
          "size" : {
            "width" : 850,
            "height" : 300
          },
          "metadata" : {
            "parent" : "for_assets"
          }
        },
        "description" : "This loop processes each attribute.",
        "config" : {
          "type" : ".ForEachLoopConfig",
          "failureOutputs" : [ ],
          "loopOutputs" : [ "apply_model" ],
          "stageTimeout" : {
            "duration" : 5,
            "units" : "Minutes"
          }
        },
        "outputs" : [ "to_mqtt" ]
      }, {
        "name" : "return_single_object",
        "display" : {
          "position" : {
            "x" : 1950,
            "y" : 155
          },
          "metadata" : {
            "parent" : "for_assets"
          }
        },
        "description" : "This stage is used to just return a single object by just returning the parent of event.value. When using for each loops, it is best to return the same size object that was entered into the for each loop.",
        "config" : {
          "type" : ".JSONataTransformConfig",
          "transformExpression" : "event.id"
        },
        "outputs" : [ "return_asset" ]
      }, {
        "name" : "return_asset",
        "display" : {
          "position" : {
            "x" : 2400,
            "y" : 155
          },
          "metadata" : {
            "parent" : "for_assets"
          }
        },
        "description" : "",
        "config" : {
          "type" : ".ReturnConfig"
        },
        "outputs" : [ ]
      }, {
        "name" : "asset_to_metadata",
        "display" : {
          "position" : {
            "x" : 50,
            "y" : 155
          },
          "metadata" : {
            "parent" : "for_assets"
          }
        },
        "description" : "This Stage moves the asset information to metadata.",
        "config" : {
          "type" : ".JavaScriptTransformConfig",
          "transformExpression" : "var _path = event.value._path;\r\nvar convertedPath = \"PI_AF/\" + _path.replace(/\\\\/g, \"/\");\r\nstage.setMetadata(\"assetPath\", convertedPath);\r\nstage.setMetadata(\"elementID\", event.value.elementID);\r\nstage.setValue(event.value.attributes);"
        },
        "outputs" : [ "each_attribute" ]
      }, {
        "name" : "to_mqtt",
        "display" : {
          "position" : {
            "x" : 1500,
            "y" : 155
          },
          "metadata" : {
            "parent" : "for_assets"
          }
        },
        "description" : "This Stage publishes the payload to the Intelligence Hub MQTT broker which is being used in this case to allow easy visualization of the output.  An array is typically used to write data to a Data Lake or Data Warehouse.",
        "config" : {
          "type" : ".DynamicWriteConfig",
          "failureOutputs" : [ ],
          "connectionReference" : "{{Connection.mqtt}}",
          "eventPath" : "",
          "connectionType" : "mqtt",
          "qualifier" : {
            "topic" : "Metadata_Asset_Attribute_PI_AF",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : false,
            "breakupArrays" : false,
            "filterList" : [ "_name", "_model", "_timestamp" ],
            "type" : "Tag"
          },
          "qualifierExpression" : "",
          "writeReturn" : "ignore"
        },
        "outputs" : [ "return_single_object" ]
      }, {
        "name" : "return_attribute",
        "display" : {
          "position" : {
            "x" : 500,
            "y" : 105
          },
          "metadata" : {
            "parent" : "each_attribute"
          }
        },
        "description" : "",
        "config" : {
          "type" : ".ReturnConfig"
        },
        "outputs" : [ ]
      }, {
        "name" : "apply_model",
        "display" : {
          "position" : {
            "x" : 50,
            "y" : 105
          },
          "metadata" : {
            "parent" : "each_attribute"
          }
        },
        "description" : "This Stage applies the desired schema for the attribute payload.\n",
        "config" : {
          "type" : ".ModelConfig",
          "model" : "starter_metadata_asset_attributes",
          "objectName" : "",
          "initExpression" : "",
          "attributes" : [ {
            "name" : "assetId",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.metadata.elementID"
            }
          }, {
            "name" : "assetPath",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.metadata.assetPath"
            }
          }, {
            "name" : "attributeId",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.ID"
            }
          }, {
            "name" : "attributeName",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "return event.value.name;"
            }
          }, {
            "name" : "attributeDescription",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "return event.value.description;"
            }
          }, {
            "name" : "attributeDataType",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.dataType"
            }
          }, {
            "name" : "attributeUnits",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "return event.value.uom;"
            }
          }, {
            "name" : "pointID",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "if (event.value.hasOwnProperty('point')) return event.value.point.ID;\r\nelse return '';\r\n"
            }
          }, {
            "name" : "source",
            "expression" : {
              "type" : "JavaScript",
              "expression" : ""
            },
            "defaultValue" : "AVEVA PI System Asset Framework"
          }, {
            "name" : "time",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "return new Date().toISOString();"
            }
          } ],
          "expandArray" : false
        },
        "outputs" : [ "return_attribute" ]
      } ],
      "trackActivity" : false,
      "queueSize" : 10000,
      "triggers" : [ {
        "name" : "polled_trigger",
        "display" : {
          "position" : {
            "x" : -450,
            "y" : 0
          }
        },
        "description" : "An asset metadata Pipeline typically runs infrequently.   Perhaps every few hours or fractions of a day.",
        "config" : {
          "type" : ".TriggerPolled",
          "enabled" : false,
          "interval" : {
            "duration" : 8,
            "units" : "Hours"
          },
          "mode" : "interval"
        }
      } ],
      "errorHandler" : {
        "type" : "default"
      }
    }, {
      "name" : "starter_output_pi_af_metadata_assets_page_to_mqtt",
      "description" : "This Pipeline obtains asset metadata from AVEVA PI System Asset Framework and models the data before publishing the data to the Intelligence Hub MQTT Broker.  This Pipeline leverages the Connection Input's paging capability to process metadata for a large number of assets.",
      "groupAs" : "/starter_hist_read_metadata_assets",
      "tags" : [ "starter_pi_af" ],
      "inputStages" : [ "while_data" ],
      "stages" : [ {
        "name" : "while_data",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : -155
          },
          "size" : {
            "width" : 3050,
            "height" : 400
          },
          "metadata" : { }
        },
        "description" : "Loop while there is data to process.",
        "config" : {
          "type" : ".WhileLoopConfig",
          "failureOutputs" : [ ],
          "loopOutputs" : [ "pageIndex_pageSize" ],
          "stageTimeout" : {
            "duration" : 30,
            "units" : "Minutes"
          },
          "expression" : "return loop.value.length >  loop.metadata.pageSize * (loop.runCount - 1);",
          "loopValue" : "ACCUMULATED"
        },
        "outputs" : [ ]
      }, {
        "name" : "pageIndex_pageSize",
        "display" : {
          "position" : {
            "x" : 200,
            "y" : 155
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "This Stage uses JavaScript to set the page size and page index parameters that will be passed to the Connection Input.",
        "config" : {
          "type" : ".JavaScriptTransformConfig",
          "transformExpression" : "const pageSize = 100;\r\nconst pageIndex = event.metadata.loopIndex * pageSize;\r\nstage.setMetadata(\"pageIndex\", pageIndex); \r\nstage.setMetadata(\"pageSize\", pageSize);\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "read_pi_data" ]
      }, {
        "name" : "return_while",
        "display" : {
          "position" : {
            "x" : 2700,
            "y" : 155
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "",
        "config" : {
          "type" : ".ReturnConfig"
        },
        "outputs" : [ ]
      }, {
        "name" : "read_pi_data",
        "display" : {
          "position" : {
            "x" : 650,
            "y" : 155
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "This Stage reads data from PI passing the page index and page size parameters.",
        "config" : {
          "type" : ".ReadConfig",
          "failureOutputs" : [ ],
          "reference" : {
            "type" : "Input",
            "name" : "pi_af_input_metadata_assets_page",
            "path" : "",
            "params" : {
              "pageIndex" : "{{event.metadata.pageIndex}} ",
              "pageSize" : "{{event.metadata.pageSize}} "
            },
            "connectionName" : "pi_af"
          },
          "handleGoodNoData" : false,
          "goodNoDataOutputs" : [ ]
        },
        "outputs" : [ "each_asset" ]
      }, {
        "name" : "each_asset",
        "display" : {
          "position" : {
            "x" : 1100,
            "y" : 50
          },
          "size" : {
            "width" : 1000,
            "height" : 300
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "This for loop process each asset.",
        "config" : {
          "type" : ".ForEachLoopConfig",
          "failureOutputs" : [ ],
          "loopOutputs" : [ "apply_model" ],
          "stageTimeout" : {
            "duration" : 1,
            "units" : "Minutes"
          }
        },
        "outputs" : [ "to_mqtt" ]
      }, {
        "name" : "to_mqtt",
        "display" : {
          "position" : {
            "x" : 2250,
            "y" : 155
          },
          "metadata" : {
            "parent" : "while_data"
          }
        },
        "description" : "This Stage publishes the payload to the Intelligence Hub MQTT broker which is being used in this case to allow easy visualization of the output.",
        "config" : {
          "type" : ".DynamicWriteConfig",
          "failureOutputs" : [ ],
          "connectionReference" : "{{Connection.mqtt}}",
          "eventPath" : "",
          "connectionType" : "mqtt",
          "qualifier" : {
            "topic" : "Metadata_Asset_PI_AF",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : false,
            "breakupArrays" : false,
            "filterList" : [ "_name", "_model", "_timestamp" ],
            "type" : "Tag"
          },
          "qualifierExpression" : "",
          "writeReturn" : "ignore"
        },
        "outputs" : [ "return_while" ]
      }, {
        "name" : "apply_model",
        "display" : {
          "position" : {
            "x" : 200,
            "y" : 105
          },
          "metadata" : {
            "parent" : "each_asset"
          }
        },
        "description" : "This Stage applies the desired schema.",
        "config" : {
          "type" : ".ModelConfig",
          "model" : "starter_metadata_assets",
          "objectName" : "",
          "initExpression" : "",
          "attributes" : [ {
            "name" : "assetId",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.elementID"
            }
          }, {
            "name" : "assetName",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value._name"
            }
          }, {
            "name" : "assetTemplateId",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.template.ID"
            }
          }, {
            "name" : "assetPath",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var _path = event.value._path;\r\nvar newPath = _path.replace(/\\//g, '|');\r\nvar convertedPath = \"Asset_PI_AF/\" + newPath.replace(/\\\\/g, \"/\");\r\nreturn convertedPath;"
            }
          }, {
            "name" : "assetVersion",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.version"
            }
          }, {
            "name" : "source",
            "expression" : {
              "type" : "JavaScript",
              "expression" : ""
            },
            "defaultValue" : "AVEVA PI System Asset Framework"
          }, {
            "name" : "time",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.,etadata.timestamp"
            }
          } ],
          "expandArray" : false
        },
        "outputs" : [ "return_for" ]
      }, {
        "name" : "return_for",
        "display" : {
          "position" : {
            "x" : 650,
            "y" : 105
          },
          "metadata" : {
            "parent" : "each_asset"
          }
        },
        "description" : "",
        "config" : {
          "type" : ".ReturnConfig"
        },
        "outputs" : [ ]
      } ],
      "trackActivity" : false,
      "queueSize" : 10000,
      "triggers" : [ {
        "name" : "polled_trigger",
        "display" : {
          "position" : {
            "x" : -450,
            "y" : 0
          }
        },
        "description" : "An asset metadata Pipeline typically runs infrequently.   Perhaps every few hours or fractions of a day.",
        "config" : {
          "type" : ".TriggerPolled",
          "enabled" : false,
          "interval" : {
            "duration" : 8,
            "units" : "Hours"
          },
          "mode" : "interval"
        }
      } ],
      "errorHandler" : {
        "type" : "default"
      }
    } ],
    "namespace" : [ ],
    "lookupMap" : [ ],
    "servers" : {
      "i3x" : {
        "historyReadPipeline" : {
          "type" : "Empty"
        },
        "writePipeline" : {
          "type" : "Empty"
        }
      }
    }
  },
  "network" : {
    "groups" : [ ],
    "hubs" : [ ]
  }
}