{
  "custom": {},
  "params": {
    "equipmentCount": 5,
    "equipmentPath": "Enterprise\\El Dorado Hills\\Packaging Area\\Packaging Line 1",
    "isMultiOperationCapable": true,
    "manualMode": false
  },
  "propConfig": {
    "params.equipmentCount": {
      "paramDirection": "output",
      "persistent": true
    },
    "params.equipmentPath": {
      "onChange": {
        "enabled": null,
        "script": "\tself.getChild(\"root\").getChild(\"ViewCanvasTree\").custom.index \u003d 0\n\tself.getChild(\"root\").getChild(\"ViewCanvasTree\").custom.path \u003d \"\"\n\tself.getChild(\"root\").getChild(\"ViewCanvasTree\").refreshBinding(\"custom.interactable\")\n\t\t\n"
      },
      "paramDirection": "input",
      "persistent": true
    },
    "params.isMultiOperationCapable": {
      "paramDirection": "inout",
      "persistent": true
    },
    "params.manualMode": {
      "paramDirection": "inout",
      "persistent": true
    }
  },
  "props": {
    "defaultSize": {
      "height": 212,
      "width": 600
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "Title"
        },
        "propConfig": {
          "props.text": {
            "binding": {
              "config": {
                "path": "view.params.equipmentPath"
              },
              "transforms": [
                {
                  "code": "\treturn \"Equipment\"\n\treturn value.split(\u0027\\\\\u0027)[3] if value else \u0027\u0027\n",
                  "type": "script"
                }
              ],
              "type": "property"
            }
          }
        },
        "props": {
          "alignVertical": "bottom",
          "style": {
            "backgroundColor": "#8B8B8B",
            "fontFamily": "Roboto",
            "fontSize": 18,
            "fontWeight": "bold",
            "paddingBottom": 11,
            "paddingTop": 11,
            "textAlign": "center"
          }
        },
        "type": "ia.display.label"
      },
      {
        "custom": {
          "index": 1,
          "path": "Enterprise\\El Dorado Hills\\Packaging Area\\Packaging Line 1\\Filler"
        },
        "events": {
          "component": {
            "onInstanceClicked": {
              "config": {
                "script": "\tif self.custom.interactable:\n\t\tself.custom.index \u003d self.props.instances[event.index][\u0027viewParams\u0027][\u0027index\u0027]\n\t\tself.custom.path \u003d self.props.instances[event.index][\u0027viewParams\u0027][\u0027eqPath\u0027]\n\t\tunselected \u003d \"#FFFFFF00\"\n\t\tfor index in range(len(self.props.instances)):\n\t\t\tself.props.instances[index].style.backgroundColor \u003d unselected\n\t\t\n\t\tif self.session.props.theme \u003d\u003d \u0027light\u0027:\n\t\t\tselected \u003d \"#DAEAFF\"\n\t\telse:\n\t\t\tselected \u003d \u0027#004A98\u0027\n\t\tself.props.instances[event.index].style.backgroundColor \u003d selected\n\t\t"
              },
              "scope": "G",
              "type": "script"
            }
          }
        },
        "meta": {
          "name": "ViewCanvasTree"
        },
        "position": {
          "basis": "100%",
          "grow": 1
        },
        "propConfig": {
          "custom.interactable": {
            "binding": {
              "config": {
                "path": "view.params.manualMode"
              },
              "transforms": [
                {
                  "code": "\treturn self.view.params.isMultiOperationCapable or value",
                  "type": "script"
                }
              ],
              "type": "property"
            }
          },
          "props.instances": {
            "binding": {
              "config": {
                "path": "view.params.equipmentPath"
              },
              "transforms": [
                {
                  "code": "\tMESLineCell \u003d \"MESLineCell\"\n\tMESLineCellGroup \u003d \"MESLineCellGroup\"\n\tMESLocation \u003d \"MESLocation\"\n\tlinePath \u003d self.view.params.equipmentPath\n\t\n\tif not linePath:\n\t\treturn []\n\n\tisFirst \u003d True\n\tinstances \u003d []\n\tline \u003d system.mes.loadMESObjectByEquipmentPath(linePath)\n\t\n\tcellList \u003d []\n\t\n\t#https://help.sepasoft.com/docs/display/SEPA/MES+Equipment+State\n\tdef createIcon(state):\n\t\ticon \u003d \"\"\n\t\tif state \u003d\u003d \"Idle\":\n\t\t\ticon \u003d \"EquipmentStateTypes/Idle\"\t\n\t\telif state \u003d\u003d \"Starved\":\n\t\t\ticon \u003d \"EquipmentStateTypes/Blocked\"\t\n\t\telif state \u003d\u003d \"Running\":\n\t\t\ticon \u003d \"EquipmentStateTypes/Running\"\n\t\telif state \u003d\u003d \"Disabled\":\n\t\t\ticon \u003d \"EquipmentStateTypes/Blocked\"\t\n\t\telif state \u003d\u003d \"Planned Downtime\":\n\t\t\ticon \u003d \"EquipmentStateTypes/PlannedDowntime\"\n\t\telif state \u003d\u003d \"Unplanned Downtime\":\n\t\t\ticon \u003d \"EquipmentStateTypes/UnplannedDowntime\"\n\t\t\t\n\t\treturn icon\n\t\t\n\tdef createCell(cellPath, index, left):\t\t\n\t\treturn \\\n\t\t\t{\n\t\t  \"position\": \"absolute\",\n\t\t  \"top\": str(index * 35) +\"px\",\n\t\t  \"left\": str(left * 35) +\"px\",\n\t\t  \"bottom\": \"auto\",\n\t\t  \"right\": \"auto\",\n\t\t  \"zIndex\": \"auto\",\n\t\t  \"width\": \"100%\",\n\t\t  \"height\": \"auto\",\n\t\t  \"viewPath\": \"Page/Embedded/IndexingTreeNode\",\n\t\t  \"viewParams\": {\n\t\t    \"eqPath\": cellPath,\n\t\t    \"index\" : index\n\t\t  },\n\t\t  \"style\": {\n\t\t    \"borderTopLeftRadius\": 50,\n\t\t    \"borderTopRightRadius\": 50,\n\t\t    \"borderBottomLeftRadius\": 50,\n\t\t    \"borderBottomRightRadius\": 50\n\t\t  }\n\t\t}\n\tindent \u003d 0\n\t\n\tdef findCells(nestedList, cellList, path, indent):\t\t\t\n\t\t\t# check if list is empty\n\t\t\tif (nestedList \u003d\u003d []):\n\t\t\t\treturn nestedList\n\t\t\t\n\t\t\t#create cell path\t\n\t\t\tcellPath \u003d path\n\t\t\t\n\t\t\t#if path not empty, then it is a nested folder\n\t\t\t#add a / to the folder path\n\t\t\tif (cellPath !\u003d \"\"):\n\t\t\t\tcellPath +\u003d \"\\\\\"\n\t\t\t\t\n\t\t\t#add name of folder to folder path\n\t\t\tcellPath +\u003d nestedList[0].getName()\n\t\t\t\t\n\t\t\t# to check if item is a cellGroup\n\t\t\tif nestedList[0].__class__.__name__ \u003d\u003d MESLineCellGroup:\t\t\t\t\t \t\t\n\t\t\t\tcellList.append( createCell(cellPath, len(cellList), indent))\n\t\t\t\t\n\t\t\t\tnewNestedList \u003d system.mes.loadMESObjectByEquipmentPath(cellPath)\n\t\t\t\t\n\t\t\t\t# first: recursion inside folder contents\n\t\t\t\t# secound: recursion on rest of the list, nested\t\n\t\t\t\treturn findCells(newNestedList.getChildEquipment(), cellList, cellPath, indent + 1) \\\n\t\t\t\t\t+ findCells(nestedList[1:], cellList, cellPath, indent)\n\t\t \n\t\t\t#else, if cell\n\t\t\telif nestedList[0].__class__.__name__ !\u003d MESLocation:\n\t\t\t\tcellList.append( createCell(cellPath, len(cellList),indent) )\t\t\t\n\t\t\t# recursion for rest of the list, the screens\n\t\t\treturn nestedList[1:] + findCells(nestedList[1:], cellList, path, indent)\t\t\n\t\t\n\tcellList \u003d []\n\tfindCells(line.getChildEquipment(), cellList, linePath, 0)\n\t\n\tself.view.params.equipmentCount \u003d len(cellList)\n\t\n\treturn cellList\n\t\t",
                  "type": "script"
                }
              ],
              "type": "property"
            }
          }
        },
        "props": {
          "style": {
            "borderStyle": "none",
            "fontFamily": "Roboto"
          },
          "transitionSettings": {
            "duration": "1s",
            "timingFunction": "linear"
          }
        },
        "type": "ia.display.viewcanvas"
      },
      {
        "children": [
          {
            "events": {
              "component": {
                "onActionPerformed": {
                  "config": {
                    "script": "\tcellPath \u003d self.parent.parent.getChild(\"ViewCanvasTree\").custom.path\n\tsystem.mes.oee.indexCellProduct(cellPath,True)\n"
                  },
                  "scope": "G",
                  "type": "script"
                }
              }
            },
            "meta": {
              "name": "IndexButton"
            },
            "propConfig": {
              "meta.visible": {
                "binding": {
                  "config": {
                    "path": ".../ViewCanvasTree.custom.index"
                  },
                  "transforms": [
                    {
                      "code": "\tisMultiOperationCapable \u003d self.view.params.isMultiOperationCapable\n\t\t\n\tif (value and value !\u003d 0) and isMultiOperationCapable:\n\t\treturn True\n\telse:\n\t\treturn False",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "style": {
                "classes": "Buttons/Small_Button",
                "fontSize": 18,
                "fontWeight": "bold",
                "height": "48px",
                "marginRight": 22,
                "width": "125px"
              },
              "text": "Index"
            },
            "type": "ia.input.button"
          },
          {
            "events": {
              "component": {
                "onActionPerformed": {
                  "config": {
                    "script": "\tlineObj \u003d system.mes.loadMESObjectByEquipmentPath(self.view.params.equipmentPath)\n\tmanualMode \u003d lineObj.getPropertyValue(\u0027isManual\u0027)\n\t\n\tcellPath \u003d self.parent.parent.getChild(\"ViewCanvasTree\").custom.path\n\t\n\tcellName \u003d cellPath.split(\u0027\\\\\u0027)[-1]\n\t\n\tif manualMode:\n\t\tsystem.perspective.openPopup(\"123\",\"Popup/DT Reason Popup\",params \u003d {\"cellPath\":cellPath,\"equipmentPath\": self.view.params.equipmentPath}, title \u003d \"Add Downtime Reason \" +  cellName , resizable \u003d True,modal \u003d True )"
                  },
                  "scope": "G",
                  "type": "script"
                }
              }
            },
            "meta": {
              "name": "Downtime Button"
            },
            "propConfig": {
              "meta.visible": {
                "binding": {
                  "config": {
                    "path": ".../ViewCanvasTree.custom.path"
                  },
                  "transforms": [
                    {
                      "code": "\tmanualMode \u003d self.view.params.manualMode\n\tif (value and value !\u003d \"\") and manualMode:\n\t\treturn True\n\telse:\n\t\treturn False",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "style": {
                "classes": "Buttons/Small_Button",
                "fontSize": 18,
                "fontWeight": "bold",
                "height": "48px",
                "width": "125px"
              },
              "text": "+ DT Reason"
            },
            "type": "ia.input.button"
          }
        ],
        "meta": {
          "name": "ButtonFlexContainer"
        },
        "position": {
          "basis": "70px",
          "grow": 1
        },
        "propConfig": {
          "position.display": {
            "binding": {
              "config": {
                "expression": "( ({view.params.isMultiOperationCapable} \u0026\u0026 {../ViewCanvasTree.custom.index} !\u003d 0 )|| {view.params.manualMode} )  \u0026\u0026 ( {../ViewCanvasTree.custom.path} !\u003d \"\" )"
              },
              "type": "expr"
            }
          }
        },
        "props": {
          "alignItems": "center",
          "justify": "center",
          "style": {
            "marginBottom": 10,
            "marginTop": 10,
            "overflowY": "hidden"
          }
        },
        "type": "ia.container.flex"
      }
    ],
    "meta": {
      "name": "root"
    },
    "props": {
      "alignContent": "space-around",
      "direction": "column",
      "justify": "space-between",
      "style": {
        "borderColor": "#A7A5A4",
        "borderStyle": "solid",
        "borderWidth": 1,
        "overflow": "visible"
      }
    },
    "type": "ia.container.flex"
  }
}