{
  "custom": {},
  "params": {
    "equipmentPath": "New Enterprise\\Site 1\\Simulation Area\\Simulation Line",
    "manualMode": false
  },
  "propConfig": {
    "params.equipmentPath": {
      "paramDirection": "input",
      "persistent": true
    },
    "params.manualMode": {
      "paramDirection": "inout",
      "persistent": true
    }
  },
  "props": {
    "defaultSize": {
      "height": 305,
      "width": 373
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "Title"
        },
        "position": {
          "shrink": 0
        },
        "propConfig": {
          "props.text": {
            "binding": {
              "config": {
                "path": "view.params.equipmentPath"
              },
              "transforms": [
                {
                  "code": "\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"
      },
      {
        "meta": {
          "name": "ModeLabel"
        },
        "position": {
          "basis": "25px",
          "grow": 1
        },
        "propConfig": {
          "props.text": {
            "binding": {
              "config": {
                "fallbackDelay": 2.5,
                "mode": "indirect",
                "references": {
                  "equipmentPath": "{view.params.equipmentPath}"
                },
                "tagPath": "[MES]{equipmentPath}\\Live Analysis\\Current Shift\\Equipment Mode Type"
              },
              "overlayOptOut": true,
              "transforms": [
                {
                  "code": "\tif value:\n\t\treturn value\n\telse:\n\t\treturn \u0027\u0027",
                  "type": "script"
                }
              ],
              "type": "tag"
            }
          }
        },
        "props": {
          "style": {
            "fontFamily": "Roboto",
            "fontSize": 20,
            "fontWeight": "500",
            "textAlign": "center"
          }
        },
        "type": "ia.display.label"
      },
      {
        "meta": {
          "name": "Var"
        },
        "position": {
          "display": false
        },
        "propConfig": {
          "props.text": {
            "binding": {
              "config": {
                "fallbackDelay": 2.5,
                "mode": "indirect",
                "references": {
                  "equipmentPath": "{view.params.equipmentPath}"
                },
                "tagPath": "[MES]{equipmentPath}\\Live Analysis\\Current Shift\\OEE Outfeed Count"
              },
              "overlayOptOut": true,
              "transforms": [
                {
                  "expression": "toInt(abs({value}- tag(\"[MES]\" + {view.params.equipmentPath} + \"\\\\Live Analysis\\\\Current Shift\\\\Outfeed Standard Count\")))",
                  "type": "expression"
                },
                {
                  "code": "\tif value:\n\t\treturn \u0027Var: \u0027 + str(value)\n\telse:\n\t\treturn \u0027Var:\u0027",
                  "type": "script"
                }
              ],
              "type": "tag"
            }
          }
        },
        "props": {
          "style": {
            "fontFamily": "Roboto",
            "marginLeft": 11,
            "paddingBottom": 11,
            "paddingTop": 11
          }
        },
        "type": "ia.display.label"
      },
      {
        "children": [
          {
            "meta": {
              "name": "StateIcon"
            },
            "position": {
              "basis": "40px"
            },
            "propConfig": {
              "props.path": {
                "binding": {
                  "config": {
                    "expression": "if( isGood(tag(concat(\u0027[MES]\u0027,replace({view.params.equipmentPath},\u0027\\\\\u0027,\u0027/\u0027),\u0027/Live Analysis/Current Shift/Line State Type\u0027))),\r\ntag(concat(\u0027[MES]\u0027,replace({view.params.equipmentPath},\u0027\\\\\u0027,\u0027/\u0027),\u0027/Live Analysis/Current Shift/Line State Type\u0027)),\r\n\"\")"
                  },
                  "transforms": [
                    {
                      "code": "\tdef createIcon(state):\n\t\t\ticon \u003d \"\"\n\t\t\tif state \u003d\u003d \"Idle\":\n\t\t\t\ticon \u003d \"EquipmentStateTypes/Idle\"\t\n\t\t\telif state \u003d\u003d \"Starved\":\n\t\t\t\ticon \u003d \"EquipmentStateTypes/Blocked\"\t\n\t\t\telif state \u003d\u003d \"Running\":\n\t\t\t\ticon \u003d \"EquipmentStateTypes/Running\"\n\t\t\telif state \u003d\u003d \"Disabled\":\n\t\t\t\ticon \u003d \"EquipmentStateTypes/Blocked\"\t\n\t\t\telif state \u003d\u003d \"Blocked\":\n\t\t\t\ticon \u003d \"EquipmentStateTypes/Blocked\"\t\n\t\t\telif state \u003d\u003d \"Planned Downtime\":\n\t\t\t\ticon \u003d \"EquipmentStateTypes/PlannedDowntime\"\n\t\t\telif state \u003d\u003d \"Unplanned Downtime\":\n\t\t\t\ticon \u003d \"EquipmentStateTypes/UnplannedDowntime\"\n\t\t\t\t\n\t\t\treturn icon\n\t\t\n\treturn createIcon(value)",
                      "type": "script"
                    }
                  ],
                  "type": "expr"
                }
              }
            },
            "props": {
              "style": {
                "marginLeft": "5%"
              }
            },
            "type": "ia.display.icon"
          },
          {
            "meta": {
              "name": "ProductName"
            },
            "propConfig": {
              "props.text": {
                "binding": {
                  "config": {
                    "fallbackDelay": 2.5,
                    "mode": "indirect",
                    "references": {
                      "equipmentPath": "{view.params.equipmentPath}"
                    },
                    "tagPath": "[MES]{equipmentPath}\\Live Analysis\\Current Shift\\Product Code"
                  },
                  "overlayOptOut": true,
                  "transforms": [
                    {
                      "code": "\tif value:\n\t\treturn \"Material: \" + value\n\telse:\n\t\treturn \u0027\u0027",
                      "type": "script"
                    }
                  ],
                  "type": "tag"
                }
              }
            },
            "props": {
              "style": {
                "fontFamily": "Roboto",
                "marginLeft": 11,
                "paddingBottom": 11,
                "paddingTop": 11
              }
            },
            "type": "ia.display.label"
          }
        ],
        "meta": {
          "name": "StateProductLabel"
        },
        "position": {
          "basis": "45px",
          "grow": 1,
          "shrink": 0
        },
        "props": {
          "alignItems": "center"
        },
        "type": "ia.container.flex"
      },
      {
        "children": [
          {
            "meta": {
              "name": "BarContainer_one"
            },
            "position": {
              "height": 30,
              "x": "5%",
              "y": 60
            },
            "propConfig": {
              "position.width": {
                "binding": {
                  "config": {
                    "expression": "{parent.custom.Rejected} + \",\" +\r\n{parent.custom.Out} + \",\" +\r\n{parent.custom.Goal} + \",\" +\r\n{../CheckboxFlexContainer/OutFlexContainer/OutCheckbox.props.selected} + \",\" +\r\n{../CheckboxFlexContainer/GoalFlexContainer/GoalCheckbox.props.selected}  + \",\" +\r\n{../CheckboxFlexContainer/RejectedFlexContainer/RejectedCheckbox.props.selected}"
                  },
                  "transforms": [
                    {
                      "code": "\t\n\n\tarrayValues \u003d value.split(\",\")\n\tif (not arrayValues[0].isdigit()) or (not arrayValues[1].isdigit() )or (not arrayValues[2].isdigit()) :\n\t\t\n\t\t#bar 1\n\t\tself.props.style.backgroundColor \u003d \"black\"\n\t\t\n\t\t#bar 2\n\t\tself.getSibling(\"BarContainer_two\").position.width \u003d \"0%\"\n\t\t\n\t\t#bar 3\n\t\tself.getSibling(\"BarContainer_three\").position.width \u003d \"0%\"\n\n\t\treturn \"90%\"\n\t\n\trejectedCount \u003d int(arrayValues[0])\n\toutCount \u003d int(arrayValues[1])\n\tgoalCount \u003d int(arrayValues[2])\n\t\n\tCountArray \u003d []\n\t\n\tif arrayValues[3] \u003d\u003d \"true\":\n\t\tCountArray.append({\"type\": \"out\", \"count\" : outCount})\n\t\n\tif arrayValues[4] \u003d\u003d \"true\":\n\t\tCountArray.append({\"type\": \"goal\", \"count\" : goalCount})\n\t\n\tdef CountColor(countName):\n\t\tif countName \u003d\u003d \"rejected\":\n\t\t\treturn \"red\"\n\t\telif countName \u003d\u003d \"out\":\n\t\t\treturn \"#85CF7A\"\n\t\telif countName \u003d\u003d \"goal\":\n\t\t\treturn \"green\"\n\t\telse: \n\t\t\treturn \"black\"\n\t\n\t\n\t#https://www.geeksforgeeks.org/python-program-for-recursive-insertion-sort/\n\t# Recursive function to sort an array using insertion sort\n\tdef insertionSortRecursive(arr, n):\n\t    # base case\n\t    if n \u003c\u003d 1:\n\t        return\n\t \n\t    # Sort first n-1 elements\n\t    insertionSortRecursive(arr, n - 1)\n\t \n\t    # Insert last element at its correct position in sorted array.\n\t    last \u003d arr[n - 1]\n\t    j \u003d n - 2\n\t \n\t    # Move elements of arr[0..i-1], that are\n\t    # greater than key, to one position ahead\n\t    # of their current position\n\t    while (j \u003e\u003d 0 and arr[j][\"count\"] \u003e last[\"count\"]):\n\t        arr[j + 1] \u003d arr[j]\n\t        j \u003d j - 1\n\t    arr[j + 1] \u003d last\n\t \n\tn \u003d len(CountArray)\n\tLargestSize \u003d rejectedCount\n\t\n\tselfWidth \u003d \"90%\"\n\t\n\tif (n \u003d\u003d 0):\n\t\n\t\tself.meta.visible \u003d False\n\t\tself.getSibling(\"BarContainer_two\").meta.visible \u003d False\n\n\telif (n \u003d\u003d 1):\n\t\tself.meta.visible \u003d True\n\t\tself.getSibling(\"BarContainer_two\").meta.visible \u003d False\n\t\tself.props.style.backgroundColor \u003d CountColor(CountArray[0][\"type\"])\n\t\tLargestSize \u003d CountArray[0][\"count\"] \n\t\tif LargestSize \u003d\u003d 0:\n\t\t\tselfWidth \u003d \"0%\"\n\t\t\n\telse:\n\t\tself.meta.visible \u003d True\n\t\tself.getSibling(\"BarContainer_two\").meta.visible \u003d True\n\t\tsorted \u003d insertionSortRecursive(CountArray, n)\n\t\t\n\t\tLargestSize \u003d CountArray[-1][\"count\"] \n\t\t#bar 1\n\t\tself.props.style.backgroundColor \u003d CountColor(CountArray[1][\"type\"])\n\t\tif LargestSize \u003d\u003d 0:\n\t\t\tselfWidth \u003d \"0%\"\n\t\t#bar 2\n\t\tself.getSibling(\"BarContainer_two\").props.style.backgroundColor  \u003d CountColor(CountArray[0][\"type\"])\n\t\tif CountArray[0][\"count\"] !\u003d 0:\n\t\t\tself.getSibling(\"BarContainer_two\").position.width \u003d str(int( CountArray[0][\"count\"] / float(LargestSize) * 90 ) ) + \"%\" \n\t\telse:\n\t\t\tself.getSibling(\"BarContainer_two\").position.width \u003d \"0%\" \n\n\n\t#bar 3\n\tif rejectedCount !\u003d 0 and arrayValues[5] \u003d\u003d \"true\":\n\t\t\n\t\tself.getSibling(\"BarContainer_three\").props.style.backgroundColor \u003d CountColor(\"rejected\")\n\t\t#90 instead of 100, becouse only using 90% \n\t\tnewWidth \u003d int( rejectedCount / float(LargestSize) * 90 )\n\t\tif newWidth \u003e 100:\n\t\t\tself.getSibling(\"BarContainer_three\").position.width \u003d \"90%\" #90% is max width\n\t\t\tselfWidth \u003d str(int( LargestSize / float(rejectedCount) * 90 ) ) + \"%\" \n\t\t\tBarContainer_two_width \u003d self.getSibling(\"BarContainer_two\").position.width\n\t\t\tBarContainer_two_width \u003d float(BarContainer_two_width[:-1])\n\t\t\tif (BarContainer_two_width !\u003d 0):\n\t\t\t\tBarContainer_two_width *\u003d LargestSize  / float(rejectedCount) \n\t\t\t\tself.getSibling(\"BarContainer_two\").position.width \u003d str(BarContainer_two_width ) + \"%\"\n\t\telse:\n\t\t\tself.getSibling(\"BarContainer_three\").position.width \u003d str(newWidth ) + \"%\" \n\telse:\n\t\tself.getSibling(\"BarContainer_three\").position.width \u003d \"0%\" \n\n\t#debug\n\t#system.perspective.print(\"\")\n\t#system.perspective.print(selfWidth)\n\t#system.perspective.print(self.getSibling(\"BarContainer_two\").position.width)\n\t#system.perspective.print(self.getSibling(\"BarContainer_three\").position.width)\n\t\n\n\treturn selfWidth",
                      "type": "script"
                    }
                  ],
                  "type": "expr"
                }
              }
            },
            "props": {
              "style": {
                "backgroundColor": "green"
              }
            },
            "type": "ia.container.coord"
          },
          {
            "meta": {
              "name": "BarContainer_two"
            },
            "position": {
              "height": 30,
              "width": "40%",
              "x": "5%",
              "y": 60
            },
            "props": {
              "style": {
                "backgroundColor": "#85CF7A"
              }
            },
            "type": "ia.container.coord"
          },
          {
            "meta": {
              "name": "BarContainer_three"
            },
            "position": {
              "height": 15,
              "width": "8%",
              "x": "5%",
              "y": 75
            },
            "propConfig": {
              "meta.visible": {
                "binding": {
                  "config": {
                    "path": "../CheckboxFlexContainer/RejectedFlexContainer/RejectedCheckbox.props.selected"
                  },
                  "type": "property"
                }
              }
            },
            "props": {
              "style": {
                "backgroundColor": "red"
              }
            },
            "type": "ia.container.coord"
          },
          {
            "children": [
              {
                "children": [
                  {
                    "meta": {
                      "name": "RejectedCheckbox"
                    },
                    "props": {
                      "checkedIcon": {
                        "color": {
                          "disabled": "red",
                          "enabled": "red"
                        }
                      },
                      "indeterminateIcon": {
                        "color": {
                          "disabled": "red",
                          "enabled": "red"
                        }
                      },
                      "selected": true,
                      "text": "Rejected",
                      "uncheckedIcon": {
                        "color": {
                          "disabled": "red",
                          "enabled": "red"
                        }
                      }
                    },
                    "type": "ia.input.checkbox"
                  },
                  {
                    "meta": {
                      "name": "RejectedCountLabel"
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../CountCoordinateContainer.custom.Rejected"
                          },
                          "transforms": [
                            {
                              "code": "\tif value \u003d\u003d 0:\n\t\treturn \"Zero\"\n\t\n\treturn value",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "type": "ia.display.label"
                  }
                ],
                "meta": {
                  "name": "RejectedFlexContainer"
                },
                "position": {
                  "grow": 1,
                  "shrink": 0
                },
                "props": {
                  "direction": "column",
                  "style": {
                    "overflow": "hidden"
                  }
                },
                "type": "ia.container.flex"
              },
              {
                "children": [
                  {
                    "meta": {
                      "name": "OutCheckbox"
                    },
                    "props": {
                      "checkedIcon": {
                        "color": {
                          "disabled": "#85CF7A",
                          "enabled": "#85CF7A"
                        }
                      },
                      "indeterminateIcon": {
                        "color": {
                          "disabled": "#85CF7A",
                          "enabled": "#85CF7A"
                        }
                      },
                      "selected": true,
                      "text": "Out",
                      "uncheckedIcon": {
                        "color": {
                          "disabled": "#85CF7A",
                          "enabled": "#85CF7A"
                        }
                      }
                    },
                    "type": "ia.input.checkbox"
                  },
                  {
                    "meta": {
                      "name": "OutCountLabel"
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../CountCoordinateContainer.custom.Out"
                          },
                          "transforms": [
                            {
                              "code": "\tif value \u003d\u003d 0:\n\t\treturn \"Zero\"\n\treturn value",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "type": "ia.display.label"
                  }
                ],
                "meta": {
                  "name": "OutFlexContainer"
                },
                "position": {
                  "grow": 1,
                  "shrink": 0
                },
                "props": {
                  "direction": "column",
                  "style": {
                    "overflow": "hidden"
                  }
                },
                "type": "ia.container.flex"
              },
              {
                "children": [
                  {
                    "meta": {
                      "name": "GoalCheckbox"
                    },
                    "props": {
                      "checkedIcon": {
                        "color": {
                          "disabled": "green",
                          "enabled": "green"
                        }
                      },
                      "indeterminateIcon": {
                        "color": {
                          "disabled": "green",
                          "enabled": "green"
                        }
                      },
                      "selected": true,
                      "text": "Target",
                      "uncheckedIcon": {
                        "color": {
                          "disabled": "green",
                          "enabled": "green"
                        }
                      }
                    },
                    "type": "ia.input.checkbox"
                  },
                  {
                    "meta": {
                      "name": "GoalCountLabel"
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../CountCoordinateContainer.custom.Goal"
                          },
                          "transforms": [
                            {
                              "code": "\tif value \u003d\u003d 0:\n\t\treturn \"Zero\"\n\treturn value",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "type": "ia.display.label"
                  }
                ],
                "meta": {
                  "name": "GoalFlexContainer"
                },
                "position": {
                  "grow": 1,
                  "shrink": 0
                },
                "props": {
                  "direction": "column",
                  "style": {
                    "overflow": "hidden"
                  }
                },
                "type": "ia.container.flex"
              }
            ],
            "meta": {
              "name": "CheckboxFlexContainer"
            },
            "position": {
              "height": 57,
              "width": "90%",
              "x": "5%"
            },
            "type": "ia.container.flex"
          }
        ],
        "meta": {
          "name": "CountCoordinateContainer"
        },
        "position": {
          "basis": "100px",
          "grow": 1
        },
        "propConfig": {
          "custom.Goal": {
            "binding": {
              "config": {
                "fallbackDelay": 2.5,
                "mode": "indirect",
                "references": {
                  "equipmentPath": "{view.params.equipmentPath}"
                },
                "tagPath": "[MES]{equipmentPath}\\Live Analysis\\Day(production)\\Outfeed Standard Count"
              },
              "transforms": [
                {
                  "code": "\tif value is None:\n\t\treturn \"None\"\n\telse:\n\t\treturn abs( int(value))",
                  "type": "script"
                }
              ],
              "type": "tag"
            }
          },
          "custom.Out": {
            "binding": {
              "config": {
                "fallbackDelay": 2.5,
                "mode": "indirect",
                "references": {
                  "equipmentPath": "{view.params.equipmentPath}"
                },
                "tagPath": "[MES]{equipmentPath}\\Live Analysis\\Production Run\\OEE Outfeed Count"
              },
              "transforms": [
                {
                  "code": "\tif value is None:\n\t\treturn \"None\"\n\telse:\n\t\treturn value",
                  "type": "script"
                }
              ],
              "type": "tag"
            }
          },
          "custom.Rejected": {
            "binding": {
              "config": {
                "fallbackDelay": 2.5,
                "mode": "indirect",
                "references": {
                  "equipmentPath": "{view.params.equipmentPath}"
                },
                "tagPath": "[MES]{equipmentPath}\\Live Analysis\\Production Run\\OEE Reject Count"
              },
              "transforms": [
                {
                  "code": "\tif value is None:\n\t\treturn \"None\"\n\telse:\n\t\treturn value",
                  "type": "script"
                }
              ],
              "type": "tag"
            }
          }
        },
        "type": "ia.container.coord"
      },
      {
        "children": [
          {
            "events": {
              "component": {
                "onActionPerformed": {
                  "config": {
                    "script": "\teqPath \u003d self.view.params.equipmentPath\n\tlineObj \u003d system.mes.loadMESObjectByEquipmentPath(eqPath)\n\tcounters \u003d lineObj.getCounters()\n\tcurrOp \u003d system.mes.getCurrentOperation(eqPath)\n\tif(len(counters) \u003d\u003d 0):\n\t\tsystem.perspective.openPopup(\"123\",\"Popup/Error\", params \u003d {\"message\": \"No configurable counters\"})\n\telif(currOp \u003d\u003d None):\n\t\tsystem.perspective.openPopup(\"123\",\"Popup/Error\", params \u003d {\"message\": \"Production Line is not running\"})\n\telse:\n\t\tsystem.perspective.openPopup(\"123\",\"Popup/Add Counts\", params \u003d {\"equipmentPath\": eqPath}, title \u003d \"Add \u0026 Adjust Counts\")"
                  },
                  "scope": "G",
                  "type": "script"
                }
              }
            },
            "meta": {
              "name": "CountButton"
            },
            "props": {
              "style": {
                "classes": "Buttons/Small_Button",
                "fontSize": 18,
                "fontWeight": "bold",
                "height": "70%",
                "marginRight": 22,
                "width": "125px"
              },
              "text": "Edit Counts"
            },
            "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\tif manualMode:\n\t\tsystem.perspective.openPopup(\"123\",\"Popup/DT Reason Popup\",params \u003d {\"cellPath\":self.view.params.equipmentPath,\"equipmentPath\":  self.view.params.equipmentPath}, title \u003d \"Add Downtime Reason \" +  self.parent.parent.getChild(\"Title\").props.text , resizable \u003d True,modal \u003d True )"
                  },
                  "scope": "G",
                  "type": "script"
                }
              }
            },
            "meta": {
              "name": "DowntimeButton"
            },
            "props": {
              "style": {
                "classes": "Buttons/Small_Button",
                "fontSize": 18,
                "fontWeight": "bold",
                "height": "70%",
                "width": "125px"
              },
              "text": "+ DT Reason"
            },
            "type": "ia.input.button"
          }
        ],
        "meta": {
          "name": "ButtonFlexContainer"
        },
        "position": {
          "basis": "70px",
          "shrink": 0.5
        },
        "propConfig": {
          "position.display": {
            "binding": {
              "config": {
                "path": "view.params.manualMode"
              },
              "type": "property"
            }
          }
        },
        "props": {
          "alignItems": "center",
          "justify": "center",
          "style": {
            "marginBottom": 11,
            "marginTop": 11,
            "overflow": "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"
  }
}