{
  "productInfo" : {
    "company" : "HighByte",
    "product" : "IntelligenceHub",
    "version" : "4.4.1",
    "build" : "2026.4.14.7",
    "stage" : "Release"
  },
  "project" : {
    "version" : 13,
    "connections" : [ {
      "name" : "ip21",
      "uri" : "ip21://{{System.Variables.host_reference}}:45390",
      "description" : "This is a Connection to Aspen InfoPlus.21 Historian. The purpose of the Connection is to obtain data for starter solution examples and, specifically starter solutions related to IP.21.  HighByte note: this Connection uses a dedicated agent installed on a demo system EC2.",
      "tags" : [ "starter_ip21" ],
      "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" : {
        "connectionString" : "Driver={AspenTech SQLplus};Host=34.215.151.255;Port=10014;READONLY=Yes",
        "connectTimeoutSeconds" : 5,
        "requestTimeoutMS" : 120000,
        "compression" : "GZIP",
        "password" : {
          "type" : "Reference",
          "value" : "ip21_token_reference"
        }
      }
    }, {
      "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"
      }
    } ],
    "inputs" : [ {
      "name" : "ip21_input_last_values",
      "connection" : "ip21",
      "type" : "ip21",
      "qualifier" : {
        "type" : "query",
        "command" : "SELECT NAME, IP_VALUE, IP_VALUE_TIME, IP_VALUE_QUALITY FROM IP_AnalogDef WHERE (NAME = 'PP_InFlow1' OR NAME = 'PP_OutFlow')"
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "ip21_input_metadata_tags",
      "connection" : "ip21",
      "type" : "ip21",
      "qualifier" : {
        "type" : "query",
        "command" : "SELECT NAME, IP_DESCRIPTION, IP_TAG_TYPE, IP_ENG_UNITS, IP_HIGH_HIGH_LIMIT, IP_LOW_LOW_LIMIT FROM IP_AnalogDef WHERE (NAME LIKE 'A1%' OR NAME LIKE 'C1%' OR NAME LIKE 'CA%'  OR NAME LIKE 'FC%' OR NAME LIKE 'FI%' OR NAME LIKE 'HC%' OR NAME LIKE 'II%' OR NAME LIKE 'LC%'  OR NAME LIKE 'PC%' OR NAME LIKE 'PI%' OR NAME LIKE 'TI%')\nORDER BY NAME;"
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "ip21_input_tag_list",
      "connection" : "ip21",
      "type" : "ip21",
      "qualifier" : {
        "type" : "query",
        "command" : "SELECT NAME FROM IP_AnalogDef WHERE (IP_VALUE IS NOT NULL AND IP_VALUE_TIME IS NOT NULL AND NAME LIKE 'PP_%Flow%')"
      },
      "cacheLifetime" : {
        "enabled" : true,
        "interval" : {
          "duration" : 1,
          "units" : "Days"
        }
      },
      "template" : {
        "type" : "Off"
      },
      "parameters" : {
        "type" : "EmptyParameters"
      }
    }, {
      "name" : "ip21_input_values_time_span",
      "connection" : "ip21",
      "type" : "ip21",
      "qualifier" : {
        "type" : "query",
        "command" : "SELECT NAME, VALUE, TS, STATUS FROM HISTORY WHERE NAME LIKE 'TI%' AND TS BETWEEN TIMESTAMP '{{this.startTime}}' AND TIMESTAMP '{{this.endTime}}' ORDER BY TS;"
      },
      "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-06-09 23:13:00.0",
            "internalType" : "String"
          }, {
            "attributeType" : "Internal",
            "name" : "endTime",
            "nullable" : false,
            "required" : false,
            "array" : false,
            "defaultValue" : "2026-06-09 23:13:30.0",
            "internalType" : "String"
          } ]
        }
      }
    } ],
    "outputs" : [ ],
    "modeling" : {
      "models" : [ {
        "name" : "starter_values",
        "description" : "This Model defines a simple narrow schema and supports multiple historian related starter solutions.",
        "groupAs" : "/starter_hist_values",
        "tags" : [ "starter_canary", "starter_ip21", "starter_pi_da" ],
        "attributes" : [ {
          "attributeType" : "Internal",
          "name" : "tagId",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "valueNumeric",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : "Real64"
        }, {
          "attributeType" : "Internal",
          "name" : "valueOther",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "quality",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        }, {
          "attributeType" : "Internal",
          "name" : "time",
          "nullable" : false,
          "required" : true,
          "array" : false,
          "internalType" : "DateTime"
        }, {
          "attributeType" : "Internal",
          "name" : "transactionType",
          "nullable" : true,
          "required" : false,
          "array" : false,
          "internalType" : "String"
        } ]
      } ],
      "instances" : [ ]
    },
    "conditions" : [ ],
    "functions" : [ ],
    "tags" : [ {
      "name" : "starter_ip21"
    } ],
    "pipelines" : [ {
      "name" : "starter_output_ip21_time_span_values_to_mqtt",
      "description" : "This Pipeline obtains value changes for a time span from IP.21 and models the data before publishing the data to the Intelligence Hub MQTT Broker.",
      "groupAs" : "/starter_hist_read_time_span_values",
      "tags" : [ "starter_ip21" ],
      "inputStages" : [ "get_times" ],
      "stages" : [ {
        "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_IP21",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : false,
            "breakupArrays" : false,
            "filterList" : [ "_model", "_name", "_timestamp" ]
          },
          "qualifierExpression" : "",
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "breakup_array",
        "display" : {
          "position" : {
            "x" : 1140,
            "y" : 0
          }
        },
        "description" : "The Stage breakups up the PI Point array.",
        "config" : {
          "type" : ".BreakupConfig",
          "breakupType" : "array",
          "depth" : 1
        },
        "outputs" : [ "apply_model" ]
      }, {
        "name" : "read_values",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "description" : "This Stage reads values for the given time span from IP21.",
        "config" : {
          "type" : ".ReadConfig",
          "failureOutputs" : [ ],
          "reference" : {
            "type" : "Input",
            "name" : "ip21_input_values_time_span",
            "path" : "",
            "params" : {
              "startTime" : "{{event.metadata.startTime}}",
              "endTime" : "{{event.metadata.endTime}}"
            },
            "connectionName" : "ip21"
          }
        },
        "outputs" : [ "breakup_array" ]
      }, {
        "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" : "function convertISOToCustomFormat(isoString) {\r\n    // Create a Date object from the ISO string\r\n    var date = new Date(isoString);\r\n\r\n    // Extract date components\r\n    var year = date.getUTCFullYear();\r\n    var month = String(date.getUTCMonth() + 1).padStart(2, '0'); // Months are zero-based\r\n    var day = String(date.getUTCDate()).padStart(2, '0');\r\n    var hours = String(date.getUTCHours()).padStart(2, '0');\r\n    var minutes = String(date.getUTCMinutes()).padStart(2, '0');\r\n    var seconds = String(date.getUTCSeconds()).padStart(2, '0');\r\n\r\n    // Construct the required format\r\n    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}.0`;\r\n}\r\nvar startTime = state.pipeline.get(\"startTime\",new Date(Date.now() - 30000).toISOString());\r\nvar oneMinuteAgo = new Date(Date.now() - 60000).toISOString();\r\nif (startTime < oneMinuteAgo) {\r\n    startTime = new Date(Date.now() - 30000).toISOString();\r\n}\r\nvar endTime = new Date().toISOString();\r\nstartTime = convertISOToCustomFormat(startTime);\r\nendTime = convertISOToCustomFormat(endTime);\r\nstage.setMetadata(\"startTime\", startTime);\r\nstage.setMetadata(\"endTime\", endTime);\r\n\r\nstate.pipeline.set(\"startTime\", endTime);\r\n\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "read_values" ]
      }, {
        "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_values",
          "objectName" : "",
          "initExpression" : "",
          "attributes" : [ {
            "name" : "tagId",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.NAME"
            }
          }, {
            "name" : "valueNumeric",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "// checks if event.value.value is not not a number (is a number), not null, not blank and is finite number (not +Infinity, or -Infinity).   If true, cast event.value.value to a number.  If false, set to null.\r\nif (!isNaN(event.value.VALUE) && event.value.VALUE !==null && event.value.VALUE !== \"\" && isFinite(event.value.VALUE))\r\n{\r\n\treturn Number(event.value.VALUE);\r\n}\r\nelse\r\n{\r\n\treturn null;\r\n}"
            }
          }, {
            "name" : "valueOther",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "// checks if event.value.value is not not a number (is a number), not null, not blank and is finite number (not +Infinity, or -Infinity).   If true, set to null.  If false, set to event.value.value.\r\nif (!isNaN(event.value.VALUE) && event.value.VALUE !==null && event.value.VALUE !== \"\" && isFinite(event.value.VALUE))\r\n{\r\n\treturn null;\r\n}\r\nelse\r\n{\r\n\treturn (event.value.VALUE);\r\n}"
            }
          }, {
            "name" : "quality",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : "event.value.STATUS"
            }
          }, {
            "name" : "time",
            "expression" : {
              "type" : "JavaScript",
              "expression" : "function convertCustomToISO(dateString) {\r\n    // Define month mapping\r\n    var monthMap = {\r\n        \"JAN\": \"01\", \"FEB\": \"02\", \"MAR\": \"03\", \"APR\": \"04\", \"MAY\": \"05\", \"JUN\": \"06\",\r\n        \"JUL\": \"07\", \"AUG\": \"08\", \"SEP\": \"09\", \"OCT\": \"10\", \"NOV\": \"11\", \"DEC\": \"12\"\r\n    };\r\n    // Extract parts from input\r\n    var parts = dateString.split(\" \");\r\n    var [day, monthAbbr, year] = parts[0].split(\"-\");\r\n    var time = parts[1].split(\".\")[0]; // Remove milliseconds\r\n    // Convert year to full format (assuming 2000+ for two-digit years)\r\n    var fullYear = `20${year}`;\r\n    // Get numeric month\r\n    var month = monthMap[monthAbbr.toUpperCase()];\r\n    // Construct ISO string\r\n    var isoString = `${fullYear}-${month}-${day}T${time}.000Z`;\r\n    return isoString;\r\n}\r\nvar dateStr = event.value.TS;\r\nvar newDate = (convertCustomToISO(dateStr));\r\nreturn newDate;"
            }
          }, {
            "name" : "transactionType",
            "expression" : {
              "type" : "PipelineStageReference",
              "stageReference" : ""
            }
          } ]
        },
        "outputs" : [ "size_buffer" ]
      }, {
        "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" ]
      } ],
      "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" : 30,
            "units" : "Seconds"
          },
          "mode" : "interval"
        }
      } ],
      "errorHandler" : {
        "type" : "default"
      }
    } ],
    "namespace" : [ ]
  },
  "network" : {
    "groups" : [ ],
    "hubs" : [ ]
  }
}