{
  "productInfo" : {
    "company" : "HighByte",
    "product" : "IntelligenceHub",
    "version" : "4.4.1",
    "build" : "2026.4.14.7",
    "stage" : "Release"
  },
  "project" : {
    "version" : 13,
    "connections" : [ {
      "name" : "pi_da",
      "uri" : "osisoft.afsdk://{{System.Variables.pi_host_central}}: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 Data Archive.",
      "tags" : [ "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" : {
        "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_da_input_current_values",
      "connection" : "pi_da",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "point",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : true,
          "useReference" : false,
          "query" : "",
          "index" : false,
          "indexWindow" : "",
          "calcBasis" : "timeWeighted",
          "points" : [ "{{this.flow}}", "{{this.status}}" ]
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "flow",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "OSIDemo_Line 1.Inlet Pump.Flow Rate.71d17760-99ae-5bcc-3123-3ca8750adb04",
            "internalType" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "status",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "OSIDemo_Line 1.Inlet Pump.Status.794e1058-b3b2-54ff-0364-8e5b16aaee56",
            "internalType" : "String"
          } ]
        }
      }
    }, {
      "name" : "pi_da_input_metadata_points",
      "connection" : "pi_da",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "pointbrowse",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : true,
          "includeChildren" : true,
          "query" : "OSIDemo_Line*p.Flow* OR OSIDemo_Line*p.Status*",
          "index" : false,
          "indexWindow" : "",
          "additionalMetadataProperties" : [ "changedate" ]
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_da_input_point_list",
      "connection" : "pi_da",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "pointbrowse",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : true,
          "query" : "OSIDemo_Line*p.Flow* OR OSIDemo_Line*p.Status*",
          "index" : false,
          "indexWindow" : ""
        }
      },
      "cacheLifetime" : {
        "enabled" : true,
        "interval" : {
          "duration" : 1,
          "units" : "Days"
        }
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_da_input_points_for_current_values",
      "connection" : "pi_da",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "pointbrowse",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : true,
          "query" : "OSIDemo_Line 1*p.Flow* OR OSIDemo_Line 1*p.Status* OR OSIDemo_Line 2*p.Flow* OR OSIDemo_Line 2*p.Status*",
          "index" : false,
          "indexWindow" : "",
          "additionalMetadataProperties" : [ ]
        }
      },
      "cacheLifetime" : {
        "enabled" : true,
        "interval" : {
          "duration" : 1,
          "units" : "Days"
        }
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_da_input_points_for_time_span",
      "connection" : "pi_da",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "pointbrowse",
        "options" : {
          "get" : "currentValue",
          "includeMetaData" : false,
          "includeChildren" : true,
          "query" : "OSIDemo_Line*p.Flow* OR OSIDemo_Line*p.Status*",
          "index" : false,
          "indexWindow" : "",
          "additionalMetadataProperties" : [ ]
        }
      },
      "cacheLifetime" : {
        "enabled" : true,
        "interval" : {
          "duration" : 1,
          "units" : "Days"
        }
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "pi_da_input_values_time_span",
      "connection" : "pi_da",
      "type" : "osisoft.afsdk",
      "qualifier" : {
        "type" : "point",
        "options" : {
          "get" : "rawValues",
          "includeMetaData" : false,
          "includeChildren" : true,
          "useReference" : true,
          "boundaryType" : "inside",
          "startTime" : "{{this.startTime}}",
          "endTime" : "{{this.endTime}}",
          "query" : "",
          "index" : false,
          "indexWindow" : "",
          "calcBasis" : "timeWeighted",
          "points" : [ "{{this.tagList}}]]]" ],
          "reference" : "{{Connection.pi_da.pi_da_input_points_for_time_span}}"
        }
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "inline",
        "model" : {
          "name" : "params",
          "tags" : [ ],
          "attributes" : [ {
            "attributeType" : "Internal",
            "name" : "startTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "internalType" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "endTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "internalType" : "String"
          } ]
        }
      }
    } ],
    "outputs" : [ ],
    "modeling" : {
      "models" : [ {
        "name" : "starter_last_values",
        "description" : "This is an example provided for modeling last values obtained per process variable from a historian.  The process variables pertain to a pump.  The Model is a component of a starter solution.\n",
        "groupAs" : "/start_hist_read_last_values",
        "tags" : [ "starter_canary", "starter_ip21", "starter_pi_af", "starter_pi_da" ],
        "attributes" : [ {
          "attributeType" : "Internal",
          "name" : "assetName",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "assetPath",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "flowRate",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : "Real64"
        }, {
          "attributeType" : "Internal",
          "name" : "flowRateUOM",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "defaultValue" : "gallons per minute",
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "state",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "time",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : "DateTime"
        }, {
          "attributeType" : "Internal",
          "name" : "source",
          "nullable" : false,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        } ]
      } ],
      "instances" : [ ]
    },
    "conditions" : [ ],
    "functions" : [ ],
    "tags" : [ {
      "name" : "starter_pi_da"
    } ],
    "pipelines" : [ {
      "name" : "starter_output_pi_da_current_values_to_mqtt",
      "description" : "This Pipeline obtains current values from AVEVA PI System Data Archive and models the data before publishing the data to the Intelligence Hub MQTT Broker.",
      "groupAs" : "/start_hist_read_last_values",
      "tags" : [ "starter_pi_da" ],
      "inputStages" : [ "read_pi_da_points" ],
      "stages" : [ {
        "name" : "point_array",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "description" : "This JavaScript code combines PI Points for an asset based on the PI Point naming convention.",
        "config" : {
          "type" : ".JavaScriptTransformConfig",
          "transformExpression" : "var tags = event.value\r\n// Helper: get the pump path (everything except the last two dot-segments)\r\nfunction getPumpPath(tag) {\r\n  var parts = tag.split(\".\");\r\n  return parts.slice(0, parts.length - 2).join(\".\");\r\n}\r\n\r\n// Separate into flow and status buckets\r\nvar flows   = tags.filter(t => t.includes(\".Flow Rate.\") || t.includes(\".FlowRate.\"));\r\nvar statuses = tags.filter(t => t.includes(\".Status.\"));\r\n\r\n// Pair them up by matching pump path\r\nvar result = flows.map(flow => {\r\n  var pumpPath = getPumpPath(flow);\r\n  var status = statuses.find(s => getPumpPath(s) === pumpPath);\r\n  return { flow, status: status || null };\r\n});\r\nvar pointArray = result;\r\nstage.setValue(pointArray);"
        },
        "outputs" : [ "breakup_point_array" ]
      }, {
        "name" : "breakup_point_array",
        "display" : {
          "position" : {
            "x" : 1140,
            "y" : 0
          }
        },
        "description" : "This Stage breaks up the PI Point array.",
        "config" : {
          "type" : ".BreakupConfig",
          "breakupType" : "array",
          "depth" : 1
        },
        "outputs" : [ "to_metadata" ]
      }, {
        "name" : "read_pi_da_points",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : 0
          }
        },
        "description" : "This Stage reads a list of PI Points from PI Data Archive.",
        "config" : {
          "type" : ".ReadConfig",
          "failureOutputs" : [ ],
          "reference" : {
            "type" : "Input",
            "name" : "pi_da_input_points_for_current_values",
            "path" : "",
            "params" : { },
            "connectionName" : "pi_da"
          }
        },
        "outputs" : [ "point_array" ]
      }, {
        "name" : "to_mqtt",
        "display" : {
          "position" : {
            "x" : 3390,
            "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" : "Last_Values_PI_DA",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : false,
            "breakupArrays" : false,
            "filterList" : [ "_model", "_name", "_timestamp" ]
          },
          "qualifierExpression" : "",
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "read_pi_da_values",
        "display" : {
          "position" : {
            "x" : 2040,
            "y" : 0
          }
        },
        "description" : "This Stage reads last values from PI Data Archive.",
        "config" : {
          "type" : ".ReadConfig",
          "failureOutputs" : [ ],
          "reference" : {
            "type" : "Input",
            "name" : "pi_da_input_current_values",
            "path" : "",
            "params" : {
              "flow" : "{{event.value.flow}}",
              "status" : "{{event.value.status}}"
            },
            "connectionName" : "pi_da"
          }
        },
        "outputs" : [ "apply_model" ]
      }, {
        "name" : "to_metadata",
        "display" : {
          "position" : {
            "x" : 1590,
            "y" : 0
          }
        },
        "description" : "This Stage uses JavaScript to save the PI Points to metadata.",
        "config" : {
          "type" : ".JavaScriptTransformConfig",
          "transformExpression" : "stage.setMetadata(\"flow\", event.value.flow);\r\nstage.setMetadata(\"status\", event.value.status);\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "read_pi_da_values" ]
      }, {
        "name" : "apply_model",
        "display" : {
          "position" : {
            "x" : 2490,
            "y" : 0
          }
        },
        "description" : "This Stage applies the desired schema for the current values payload.",
        "config" : {
          "type" : ".ModelConfig",
          "model" : "starter_last_values",
          "objectName" : "",
          "initExpression" : "",
          "attributes" : [ {
            "name" : "assetName",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var tag = event.metadata.flow;\r\nvar result = tag.split(\".\").slice(0, 2).join(\".\");\r\nreturn result;"
            }
          }, {
            "name" : "assetPath",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : ""
            }
          }, {
            "name" : "flowRate",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var point = event.metadata.flow;\r\nvar flow = event.value[point].value;\r\nif (flow == null) {\r\n        flow = 0;\r\n}\r\nflow = parseFloat(flow.toFixed(2));\r\nreturn flow;"
            }
          }, {
            "name" : "flowRateUOM",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : ""
            }
          }, {
            "name" : "state",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var point = event.metadata.status;\r\nvar status = event.value[point].value;\r\nvar state = (status === 1) ? \"Running\" : \"Down\";\r\nreturn state;"
            }
          }, {
            "name" : "time",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "var point = event.metadata.flow;\r\nreturn event.value[point].time;"
            }
          }, {
            "name" : "source",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : ""
            },
            "defaultValue" : "AVEVA PISystem Data Archive"
          } ]
        },
        "outputs" : [ "size_buffer" ]
      }, {
        "name" : "size_buffer",
        "display" : {
          "position" : {
            "x" : 2940,
            "y" : 0
          }
        },
        "description" : "A buffer Stage is often used before writing data to a Data Lake or Data Warehouse.\n",
        "config" : {
          "type" : ".SizedBufferConfig",
          "windowExpression" : "stage.setBufferKey(null);",
          "windowSize" : 10,
          "timeout" : {
            "duration" : 0,
            "units" : "Seconds"
          }
        },
        "outputs" : [ "to_mqtt" ]
      } ],
      "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" : 5,
            "units" : "Seconds"
          },
          "mode" : "interval"
        }
      } ],
      "errorHandler" : {
        "type" : "default"
      }
    } ],
    "namespace" : [ ]
  },
  "network" : {
    "groups" : [ ],
    "hubs" : [ ]
  }
}