{
  "productInfo" : {
    "company" : "HighByte",
    "product" : "IntelligenceHub",
    "version" : "4.1.0",
    "build" : "2025.2.24.371",
    "stage" : "Release"
  },
  "project" : {
    "version" : 10,
    "connections" : [ {
      "name" : "UsingAndSelectingSubPipelines_MQTT",
      "uri" : "mqtt://localhost:1885",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "writes" : {
        "flattenModeledValues" : false
      },
      "subscriptions" : { },
      "storeForward" : {
        "enabled" : false,
        "maxEntries" : 100,
        "waitOnFailureInterval" : {
          "duration" : 1,
          "units" : "Seconds"
        }
      },
      "settings" : {
        "connectionTimeoutSeconds" : 10,
        "keepAliveSeconds" : 60,
        "requestTimeoutMS" : 5000,
        "cleanSession" : true,
        "ssl" : false,
        "redundantBrokers" : [ ],
        "inputDiscovery" : ""
      }
    }, {
      "name" : "UsingAndSelectingSubPipelines_OPC_UA",
      "uri" : "opc.tcp://52.10.6.4:49320",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "writes" : {
        "flattenModeledValues" : false
      },
      "subscriptions" : {
        "subscriptionRate" : {
          "duration" : 1,
          "units" : "Seconds"
        }
      },
      "storeForward" : {
        "enabled" : false,
        "maxEntries" : 100,
        "waitOnFailureInterval" : {
          "duration" : 1,
          "units" : "Seconds"
        }
      },
      "settings" : {
        "security" : "None",
        "authentication" : {
          "type" : "Anonymous"
        },
        "connectTimeoutSeconds" : 5,
        "requestTimeoutMS" : 5000,
        "maxItemsPerRead" : 512,
        "maxItemsPerWrite" : 256,
        "certificateKeyPair" : "app-certificate-private-key",
        "sessionName" : ""
      }
    } ],
    "inputs" : [ {
      "name" : "ProductionLine_PLC_Template_Pressure",
      "connection" : "UsingAndSelectingSubPipelines_OPC_UA",
      "type" : "opc.tcp",
      "qualifier" : {
        "namespaceIndex" : 2,
        "identifierType" : "String",
        "identifier" : "ProductionLine.PLC_{{this.PLCIdx}}.Pressure",
        "type" : "Tag",
        "dataType" : "Real32",
        "samplingInterval" : {
          "units" : "Seconds",
          "duration" : 0
        },
        "isComplex" : true
      },
      "cacheLifetime" : {
        "enabled" : false
      },
      "template" : {
        "name" : "PLCIdx",
        "type" : "Static",
        "params" : [ {
          "name" : "PLCIdx",
          "pattern" : "1-4"
        } ]
      }
    } ],
    "outputs" : [ ],
    "modeling" : {
      "models" : [ ],
      "instances" : [ ]
    },
    "conditions" : [ ],
    "functions" : [ ],
    "tags" : [ {
      "name" : "UsingAndSelectingSubPipelinesForDistributingWorkload"
    } ],
    "pipelines" : [ {
      "name" : "SelectingSubPipelineBasedOnLoad",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "inputStages" : [ "ProductionLine" ],
      "stages" : [ {
        "name" : "SubPileline1",
        "display" : {
          "position" : {
            "x" : 3390,
            "y" : -202
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline1}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "Switch",
        "display" : {
          "position" : {
            "x" : 2940,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".SwitchConfig",
          "switchCases" : [ {
            "expression" : "return Boolean(event.value.Pipeline1.statistics.idle == true)",
            "outputs" : [ "SubPileline1" ],
            "description" : "1"
          }, {
            "expression" : "return Boolean(event.value.Pipeline2.statistics.idle == true)",
            "outputs" : [ "SubPileline2" ],
            "description" : "2"
          }, {
            "expression" : "return Boolean(event.value.Pipeline3.statistics.idle == true)",
            "outputs" : [ "SubPileline3" ],
            "description" : "3"
          }, {
            "expression" : "return Boolean(true)",
            "outputs" : [ "SubPileline4" ],
            "description" : "4"
          } ],
          "evaluationType" : "onFirst"
        },
        "outputs" : [ ]
      }, {
        "name" : "SubPileline2",
        "display" : {
          "position" : {
            "x" : 3390,
            "y" : -67
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline2}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "SubPileline3",
        "display" : {
          "position" : {
            "x" : 3390,
            "y" : 67
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline3}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "SubPileline4",
        "display" : {
          "position" : {
            "x" : 3390,
            "y" : 202
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline4}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "Pipeline1",
        "display" : {
          "position" : {
            "x" : 1590,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".ReadSourcesConfig",
          "failureOutputs" : [ ],
          "keyReferences" : [ {
            "location" : "child",
            "key" : "Pipeline1",
            "reference" : "{{System.Pipelines.SubPipeline1}}"
          } ],
          "inputValueLocation" : "inline",
          "inputValueKey" : "eventIn"
        },
        "outputs" : [ "Pipeline2" ]
      }, {
        "name" : "Pipeline2",
        "display" : {
          "position" : {
            "x" : 2040,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".ReadSourcesConfig",
          "failureOutputs" : [ ],
          "keyReferences" : [ {
            "location" : "child",
            "key" : "Pipeline2",
            "reference" : "{{System.Pipelines.SubPipeline2}}"
          } ],
          "inputValueLocation" : "inline",
          "inputValueKey" : "eventIn"
        },
        "outputs" : [ "Pipeline3" ]
      }, {
        "name" : "Pipeline3",
        "display" : {
          "position" : {
            "x" : 2490,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".ReadSourcesConfig",
          "failureOutputs" : [ ],
          "keyReferences" : [ {
            "location" : "child",
            "key" : "Pipeline3",
            "reference" : "{{System.Pipelines.SubPipeline3}}"
          } ],
          "inputValueLocation" : "inline",
          "inputValueKey" : "eventIn"
        },
        "outputs" : [ "Switch" ]
      }, {
        "name" : "ProductionLine",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".ReadSourcesConfig",
          "failureOutputs" : [ ],
          "keyReferences" : [ {
            "location" : "child",
            "key" : "ProductionLine",
            "reference" : "{{Connection.UsingAndSelectingSubPipelines_OPC_UA.ProductionLine_PLC_Template_Pressure}}"
          } ],
          "inputValueLocation" : "exclude",
          "inputValueKey" : "eventIn"
        },
        "outputs" : [ "ProductionLineToRoot" ]
      }, {
        "name" : "Breakup",
        "display" : {
          "position" : {
            "x" : 1140,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".BreakupConfig",
          "breakupType" : "array"
        },
        "outputs" : [ "Pipeline1" ]
      }, {
        "name" : "ProductionLineToRoot",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TransformConfig",
          "transformExpression" : "stage.setValue(event.value.ProductionLine);"
        },
        "outputs" : [ "Breakup" ]
      } ],
      "trackActivity" : false,
      "triggers" : [ {
        "name" : "PolledTrigger",
        "display" : {
          "position" : {
            "x" : -450,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TriggerPolled",
          "enabled" : false,
          "interval" : {
            "duration" : 1,
            "units" : "Seconds"
          }
        }
      } ],
      "callable" : "external"
    }, {
      "name" : "SelectingSubPipelineBasedOnRoundRobin",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "inputStages" : [ "ProductionLine" ],
      "stages" : [ {
        "name" : "Set_subpipelineIdx",
        "display" : {
          "position" : {
            "x" : 1590,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TransformConfig",
          "transformExpression" : "var subpipelineIdx = state.pipeline.get(\"subpipelineIdx\",0)\r\n\r\nif (subpipelineIdx == 4)\r\n{\r\n  subpipelineIdx = 1\r\n}\r\nelse\r\n{\r\n  subpipelineIdx++\r\n}\r\n\r\nstage.setMetadata(\"subpipelineIdx\", subpipelineIdx)\r\nstate.pipeline.set(\"subpipelineIdx\", subpipelineIdx)\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "Switch" ]
      }, {
        "name" : "SubPileline1",
        "display" : {
          "position" : {
            "x" : 2490,
            "y" : -202
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline1}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "Switch",
        "display" : {
          "position" : {
            "x" : 2040,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".SwitchConfig",
          "switchCases" : [ {
            "expression" : "return Boolean(event.metadata.subpipelineIdx==1)",
            "outputs" : [ "SubPileline1" ],
            "description" : "1"
          }, {
            "expression" : "return Boolean(event.metadata.subpipelineIdx==2)",
            "outputs" : [ "SubPileline2" ],
            "description" : "2"
          }, {
            "expression" : "return Boolean(event.metadata.subpipelineIdx==3)",
            "outputs" : [ "SubPileline3" ],
            "description" : "3"
          }, {
            "expression" : "return Boolean(true)",
            "outputs" : [ "SubPileline4" ],
            "description" : "4"
          } ],
          "evaluationType" : "onFirst"
        },
        "outputs" : [ ]
      }, {
        "name" : "SubPileline2",
        "display" : {
          "position" : {
            "x" : 2490,
            "y" : -67
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline2}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "SubPileline3",
        "display" : {
          "position" : {
            "x" : 2490,
            "y" : 67
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline3}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "SubPileline4",
        "display" : {
          "position" : {
            "x" : 2490,
            "y" : 202
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline4}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "ProductionLine",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".ReadSourcesConfig",
          "failureOutputs" : [ ],
          "keyReferences" : [ {
            "location" : "child",
            "key" : "ProductionLine",
            "reference" : "{{Connection.UsingAndSelectingSubPipelines_OPC_UA.ProductionLine_PLC_Template_Pressure}}"
          } ],
          "inputValueLocation" : "exclude",
          "inputValueKey" : "eventIn"
        },
        "outputs" : [ "ProductionLineToRoot" ]
      }, {
        "name" : "Breakup",
        "display" : {
          "position" : {
            "x" : 1140,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".BreakupConfig",
          "breakupType" : "array"
        },
        "outputs" : [ "Set_subpipelineIdx" ]
      }, {
        "name" : "ProductionLineToRoot",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".ReadSourcesConfig",
          "failureOutputs" : [ ],
          "keyReferences" : [ {
            "location" : "child",
            "key" : "ProductionLine",
            "reference" : "{{Connection.UsingAndSelectingSubPipelines_OPC_UA.ProductionLine_PLC_Template_Pressure}}"
          } ],
          "inputValueLocation" : "exclude",
          "inputValueKey" : "eventIn"
        },
        "outputs" : [ "Breakup" ]
      } ],
      "trackActivity" : false,
      "triggers" : [ {
        "name" : "PolledTrigger",
        "display" : {
          "position" : {
            "x" : -447,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TriggerPolled",
          "enabled" : false,
          "interval" : {
            "duration" : 1,
            "units" : "Seconds"
          }
        }
      } ],
      "callable" : "external"
    }, {
      "name" : "SubPipeline1",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "inputStages" : [ "ExpRandomDelayMeanOneSecond" ],
      "stages" : [ {
        "name" : "ExpRandomDelayMeanOneSecond",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TransformConfig",
          "transformExpression" : "function sleep(milliseconds) {\r\n    if (milliseconds > 9000)\r\n    {\r\n      milliseconds = 9000;\r\n    }\r\n    var now = new Date().getTime();\r\n    while(new Date().getTime() < now + milliseconds){ \r\n        /* Do nothing */ \r\n    }\r\n}\r\n\r\nfunction randomExponential(lambda) {\r\n  return -Math.log(1 - Math.random()) / lambda;\r\n}\r\n\r\nsleep(randomExponential(1) * 1000);\r\n\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "MQTT" ]
      }, {
        "name" : "MQTT",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".DynamicWriteConfig",
          "failureOutputs" : [ ],
          "connectionReference" : "{{Connection.UsingAndSelectingSubPipelines_MQTT}}",
          "qualifier" : {
            "topic" : "UsingAndSelectingSubPipelines/SubPipeline1",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : true,
            "breakupArrays" : false
          },
          "qualifierExpression" : "",
          "writeReturn" : "completion"
        },
        "outputs" : [ ]
      } ],
      "trackActivity" : false,
      "triggers" : [ ],
      "callable" : "external"
    }, {
      "name" : "SubPipeline2",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "inputStages" : [ "ExpRandomDelayMeanOneSecond" ],
      "stages" : [ {
        "name" : "ExpRandomDelayMeanOneSecond",
        "display" : {
          "position" : {
            "x" : 243,
            "y" : -2
          }
        },
        "config" : {
          "type" : ".TransformConfig",
          "transformExpression" : "function sleep(milliseconds) {\r\n    if (milliseconds > 9000)\r\n    {\r\n      milliseconds = 9000;\r\n    }\r\n    var now = new Date().getTime();\r\n    while(new Date().getTime() < now + milliseconds){ \r\n        /* Do nothing */ \r\n    }\r\n}\r\n\r\nfunction randomExponential(lambda) {\r\n  return -Math.log(1 - Math.random()) / lambda;\r\n}\r\n\r\nsleep(randomExponential(1) * 1000);\r\n\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "MQTT" ]
      }, {
        "name" : "MQTT",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".DynamicWriteConfig",
          "failureOutputs" : [ ],
          "connectionReference" : "{{Connection.UsingAndSelectingSubPipelines_MQTT}}",
          "qualifier" : {
            "topic" : "UsingAndSelectingSubPipelines/SubPipeline2",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : true,
            "breakupArrays" : false
          },
          "qualifierExpression" : "",
          "writeReturn" : "completion"
        },
        "outputs" : [ ]
      } ],
      "trackActivity" : false,
      "triggers" : [ ],
      "callable" : "external"
    }, {
      "name" : "SubPipeline3",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "inputStages" : [ "ExpRandomDelayMeanOneSecond" ],
      "stages" : [ {
        "name" : "ExpRandomDelayMeanOneSecond",
        "display" : {
          "position" : {
            "x" : 242,
            "y" : -2
          }
        },
        "config" : {
          "type" : ".TransformConfig",
          "transformExpression" : "function sleep(milliseconds) {\r\n    if (milliseconds > 9000)\r\n    {\r\n      milliseconds = 9000;\r\n    }\r\n    var now = new Date().getTime();\r\n    while(new Date().getTime() < now + milliseconds){ \r\n        /* Do nothing */ \r\n    }\r\n}\r\n\r\nfunction randomExponential(lambda) {\r\n  return -Math.log(1 - Math.random()) / lambda;\r\n}\r\n\r\nsleep(randomExponential(1) * 1000);\r\n\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "MQTT" ]
      }, {
        "name" : "MQTT",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".DynamicWriteConfig",
          "failureOutputs" : [ ],
          "connectionReference" : "{{Connection.UsingAndSelectingSubPipelines_MQTT}}",
          "qualifier" : {
            "topic" : "UsingAndSelectingSubPipelines/SubPipeline3",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : true,
            "breakupArrays" : false
          },
          "qualifierExpression" : "",
          "writeReturn" : "completion"
        },
        "outputs" : [ ]
      } ],
      "trackActivity" : false,
      "triggers" : [ ],
      "callable" : "external"
    }, {
      "name" : "SubPipeline4",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "inputStages" : [ "ExpRandomDelayMean4Seconds" ],
      "stages" : [ {
        "name" : "ExpRandomDelayMean4Seconds",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TransformConfig",
          "transformExpression" : "function sleep(milliseconds) {\r\n    if (milliseconds > 9000)\r\n    {\r\n        milliseconds = 9000;\r\n    }\r\n    var now = new Date().getTime();\r\n    while(new Date().getTime() < now + milliseconds){ \r\n        /* Do nothing */ \r\n    }\r\n}\r\n\r\nfunction randomExponential(lambda) {\r\n  return -Math.log(1 - Math.random()) / lambda;\r\n}\r\n\r\nsleep(randomExponential(1) * 1000);\r\n\r\nstage.setValue(event.value);"
        },
        "outputs" : [ "MQTT" ]
      }, {
        "name" : "MQTT",
        "display" : {
          "position" : {
            "x" : 692,
            "y" : -2
          }
        },
        "config" : {
          "type" : ".DynamicWriteConfig",
          "failureOutputs" : [ ],
          "connectionReference" : "{{Connection.UsingAndSelectingSubPipelines_MQTT}}",
          "qualifier" : {
            "topic" : "UsingAndSelectingSubPipelines/SubPipeline4",
            "qos" : 0,
            "namedRoot" : false,
            "retained" : true,
            "breakupArrays" : false
          },
          "qualifierExpression" : "",
          "writeReturn" : "completion"
        },
        "outputs" : [ ]
      } ],
      "trackActivity" : false,
      "triggers" : [ ],
      "callable" : "external"
    }, {
      "name" : "UsingSubPipelineForDistributingWorkload",
      "tags" : [ "UsingAndSelectingSubPipelinesForDistributingWorkload" ],
      "inputStages" : [ "ProductionLine" ],
      "stages" : [ {
        "name" : "SubPipeline1",
        "display" : {
          "position" : {
            "x" : 1591,
            "y" : -1
          }
        },
        "config" : {
          "type" : ".WriteConfig",
          "failureOutputs" : [ ],
          "references" : [ "{{Pipeline.SubPipeline1}}" ],
          "writeReturn" : "ignore"
        },
        "outputs" : [ ]
      }, {
        "name" : "ProductionLine",
        "display" : {
          "position" : {
            "x" : 240,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".ReadSourcesConfig",
          "failureOutputs" : [ ],
          "keyReferences" : [ {
            "location" : "child",
            "key" : "ProductionLine",
            "reference" : "{{Connection.UsingAndSelectingSubPipelines_OPC_UA.ProductionLine_PLC_Template_Pressure}}"
          } ],
          "inputValueLocation" : "inline",
          "inputValueKey" : "eventIn"
        },
        "outputs" : [ "ProductionLineToRoot" ]
      }, {
        "name" : "ProductionLineToRoot",
        "display" : {
          "position" : {
            "x" : 690,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TransformConfig",
          "transformExpression" : "stage.setValue(event.value.ProductionLine);"
        },
        "outputs" : [ "Breakup" ]
      }, {
        "name" : "Breakup",
        "display" : {
          "position" : {
            "x" : 1140,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".BreakupConfig",
          "breakupType" : "array"
        },
        "outputs" : [ "SubPipeline1" ]
      }, {
        "name" : "Subpipeline",
        "display" : {
          "position" : {
            "x" : 1434,
            "y" : 193
          }
        },
        "config" : {
          "type" : ".SubPipelineConfig",
          "failureOutputs" : [ ],
          "reference" : "{{Pipeline.SubPipeline1}}"
        },
        "outputs" : [ ]
      } ],
      "trackActivity" : false,
      "triggers" : [ {
        "name" : "PolledTrigger",
        "display" : {
          "position" : {
            "x" : -444,
            "y" : 0
          }
        },
        "config" : {
          "type" : ".TriggerPolled",
          "enabled" : false,
          "interval" : {
            "duration" : 1,
            "units" : "Seconds"
          }
        }
      } ],
      "callable" : "external"
    } ],
    "namespace" : [ ]
  },
  "network" : {
    "groups" : [ ],
    "hubs" : [ ]
  }
}