{
  "productInfo" : {
    "company" : "HighByte",
    "product" : "IntelligenceHub",
    "version" : "4.4.1",
    "build" : "2026.4.14.7",
    "stage" : "Release"
  },
  "project" : {
    "version" : 13,
    "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"
      }
    }, {
      "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"
      },
      "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"
      },
      "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" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "endTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-05-26T22:00:16.875Z",
            "internalType" : "String"
          } ]
        }
      }
    }, {
      "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"
      },
      "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"
      },
      "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" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "start",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-05-03T04:00:00.0000000Z",
            "internalType" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "end",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-05-03T08:00:00.0000000Z",
            "internalType" : "String"
          } ]
        }
      }
    }, {
      "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"
      },
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "pageIndex",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "internalType" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "pageSize",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "internalType" : "String"
          } ]
        }
      }
    }, {
      "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"
      },
      "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"
      },
      "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"
      },
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "pageIndex",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : 0,
            "internalType" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "pageSize",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : 100,
            "internalType" : "String"
          } ]
        }
      }
    }, {
      "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"
      },
      "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"
      },
      "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" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "endTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2025-07-09T00:01:00.0000000Z",
            "internalType" : "String"
          } ]
        }
      }
    } ],
    "outputs" : [ ],
    "modeling" : {
      "models" : [ {
        "name" : "starter_time_span_values_pumps",
        "groupAs" : "/starter_hist_read_time_span_values",
        "tags" : [ "starter_pi_af" ],
        "attributes" : [ {
          "attributeType" : "Internal",
          "name" : "assetName",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "assetPath",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "flow",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : "Real64"
        }, {
          "attributeType" : "Internal",
          "name" : "status",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "time",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : "DateTime"
        } ]
      } ],
      "instances" : [ ]
    },
    "conditions" : [ ],
    "functions" : [ ],
    "tags" : [ {
      "name" : "starter_pi_af"
    } ],
    "pipelines" : [ {
      "name" : "starter_output_pi_af_time_span_values_to_mqtt",
      "description" : "This Pipeline obtains value changes for a time span from AVEVA PI System and models the data with asset context before publishing the data to the Intelligence Hub MQTT Broker.",
      "groupAs" : "/starter_hist_read_time_span_values",
      "tags" : [ "starter_pi_af" ],
      "inputStages" : [ "get_times" ],
      "stages" : [ {
        "name" : "read_pi_values",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "description" : "This Stage reads values for the given time span from PI System.",
        "config" : {
          "type" : ".ReadConfig",
          "failureOutputs" : [ ],
          "reference" : {
            "type" : "Input",
            "name" : "pi_af_input_values_time_span",
            "path" : "",
            "params" : {
              "startTime" : "{{event.metadata.startTime}}",
              "endTime" : "{{event.metadata.endTime}}"
            },
            "connectionName" : "pi_af"
          }
        },
        "outputs" : [ "breakup_array" ]
      }, {
        "name" : "to_mqtt",
        "display" : {
          "position" : {
            "x" : 2490,
            "y" : 0
          }
        },
        "description" : "This Stage publishes the payload to the Intelligence Hub MQTT broker which is being used to view the output.",
        "config" : {
          "type" : ".DynamicWriteConfig",
          "failureOutputs" : [ ],
          "connectionReference" : "{{Connection.mqtt}}",
          "qualifier" : {
            "topic" : "Time_Span_Values_PI_AF",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : false,
            "breakupArrays" : false,
            "filterList" : [ "_model", "_name", "_timestamp" ]
          },
          "qualifierExpression" : "",
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "size_buffer",
        "display" : {
          "position" : {
            "x" : 2040,
            "y" : 0
          }
        },
        "description" : "A buffer Stage is often used before writing data to a Data Lake or Data Warehouse.",
        "config" : {
          "type" : ".SizedBufferConfig",
          "windowExpression" : "stage.setBufferKey(null);",
          "windowSize" : 100,
          "timeout" : {
            "duration" : 0,
            "units" : "Seconds"
          }
        },
        "outputs" : [ "to_mqtt" ]
      }, {
        "name" : "breakup_array",
        "display" : {
          "position" : {
            "x" : 1140,
            "y" : 0
          }
        },
        "description" : "The Stage breakups up the values array.",
        "config" : {
          "type" : ".BreakupConfig",
          "breakupType" : "array",
          "depth" : 1
        },
        "outputs" : [ "apply_model" ]
      }, {
        "name" : "apply_model",
        "display" : {
          "position" : {
            "x" : 1590,
            "y" : 0
          }
        },
        "description" : "This Stage applies the desired schema for the values payload.",
        "config" : {
          "type" : ".ModelConfig",
          "model" : "starter_time_span_values_pumps",
          "objectName" : "",
          "initExpression" : "",
          "attributes" : [ {
            "name" : "assetName",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value._name"
            }
          }, {
            "name" : "assetPath",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var path = event.value._path;\r\nvar convertedPath = path.replace(/\\\\/g, \"/\");\r\nreturn convertedPath;"
            }
          }, {
            "name" : "flow",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.FlowRate"
            }
          }, {
            "name" : "status",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var int = event.value.Status;\r\nvar status = (int === 1) ? \"Running\" : \"Down\";\r\nreturn status;"
            }
          }, {
            "name" : "time",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var extendedDateStr = event.value._timestamp;\r\n// Truncate to 3 digits of milliseconds to make it a standard ISO string\r\nvar trimmedDateStr = extendedDateStr.replace(/(\\.\\d{3})\\d*Z$/, '$1Z');\r\n// Convert to Date object\r\nvar date = new Date(trimmedDateStr);\r\n// Convert back to standard ISO string (e.g., \"2025-07-09T21:21:35.000Z\")\r\nvar standardISOString = date.toISOString();\r\nreturn standardISOString;"
            }
          } ]
        },
        "outputs" : [ "size_buffer" ]
      }, {
        "name" : "get_times",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : 0
          }
        },
        "description" : "This JavaScript Stage is used to set the interval and calculate the time span for the current execution of the Pipeline.",
        "config" : {
          "type" : ".JavaScriptTransformConfig",
          "transformExpression" : "// intervalSeconds\r\nlet intervalSeconds = 15;\r\n\r\n// intervalMilliseconds\r\nlet intervalMilliseconds = intervalSeconds * 1000;\r\n\r\n// set initial for start time\r\nlet initialStartTime = new Date();\r\ninitialStartTime.setTime(initialStartTime.getTime() - intervalMilliseconds);\r\n\r\n// read NextStartTime as the state value if it exists or initialStartTime if it does not exist.\r\nlet nextStartTime = new Date(state.pipeline.get(\"NextStartTime\", initialStartTime));\r\n\r\n// set startTime\r\nlet startTime = new Date(nextStartTime);\r\n\r\n// avoid flood of date if pipeline has not been run for a long period of time\r\nlet diffTime = initialStartTime - startTime;\r\nif (diffTime > intervalMilliseconds) {\r\n    startTime = initialStartTime;\r\n}\r\n\r\n// set endTime\r\nlet endTime = new Date();\r\nendTime.setTime(endTime.getTime());\r\n\r\n// set startTime and endTime as metadata\r\nstage.setMetadata(\"startTime\", startTime.toISOString());\r\nstage.setMetadata(\"endTime\", endTime.toISOString());\r\n\r\nstate.pipeline.set(\"NextStartTime\", endTime.toISOString());\r\n\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "read_pi_values" ]
      } ],
      "trackActivity" : false,
      "triggers" : [ {
        "name" : "polled_trigger",
        "display" : {
          "position" : {
            "x" : -450,
            "y" : 0
          }
        },
        "description" : "The trigger Stage initiates the Pipeline.",
        "config" : {
          "type" : ".TriggerPolled",
          "enabled" : false,
          "interval" : {
            "duration" : 15,
            "units" : "Seconds"
          },
          "mode" : "interval"
        }
      } ],
      "errorHandler" : {
        "type" : "default"
      }
    } ],
    "namespace" : [ ]
  },
  "network" : {
    "groups" : [ ],
    "hubs" : [ ]
  }
}