{
  "custom": {},
  "params": {
    "equipmentPath": ""
  },
  "propConfig": {
    "params.equipmentPath": {
      "paramDirection": "input",
      "persistent": true
    },
    "params.timePeriod": {
      "paramDirection": "inout",
      "persistent": false
    },
    "params.title": {
      "paramDirection": "inout",
      "persistent": false
    }
  },
  "props": {},
  "root": {
    "children": [
      {
        "meta": {
          "name": "EmbeddedView"
        },
        "position": {
          "shrink": 0
        },
        "propConfig": {
          "props.params.text": {
            "binding": {
              "config": {
                "path": "view.params.title"
              },
              "enabled": false,
              "type": "property"
            },
            "persistent": true
          }
        },
        "props": {
          "params": {
            "text": "Site Production Goal"
          },
          "path": "Page/Embedded/Widget Title",
          "style": {
            "overflow": "hidden"
          }
        },
        "type": "ia.display.view"
      },
      {
        "meta": {
          "name": "Label"
        },
        "position": {
          "basis": "60px"
        },
        "type": "ia.display.label"
      },
      {
        "meta": {
          "name": "PieChart"
        },
        "position": {
          "grow": 1
        },
        "propConfig": {
          "props.data": {
            "persistent": false
          },
          "props.legendLabelColor": {
            "binding": {
              "config": {
                "path": "session.props.theme"
              },
              "transforms": [
                {
                  "code": "\tif value \u003d\u003d \u0027dark\u0027:\n\t\treturn \u0027#FFFFFF\u0027\n\telse:\n\t\treturn \u0027#000000\u0027",
                  "type": "script"
                }
              ],
              "type": "property"
            }
          }
        },
        "props": {
          "colors": [
            "#4C9C2E",
            "#EC1C24",
            "#A1CB91",
            "#CCC233",
            "#E69300"
          ],
          "cutoutRadius": 60,
          "labels": {
            "color": "#666666",
            "showName": false,
            "showValue": false,
            "wrap": {
              "enabled": true,
              "maxWidth": 115
            }
          },
          "legend": {
            "fontSize": 15,
            "position": "top"
          },
          "valueFormat": {
            "showValueAsPercent": false
          }
        },
        "type": "ia.chart.pie"
      }
    ],
    "meta": {
      "name": "root"
    },
    "propConfig": {
      "custom.live_analysis_time": {
        "binding": {
          "config": {
            "fallbackDelay": 2.5,
            "mode": "indirect",
            "references": {
              "provider": "{session.custom.defaultTagProvider}"
            },
            "tagPath": "{provider}Time Periods/Current Shift/End"
          },
          "type": "tag"
        },
        "onChange": {
          "enabled": null,
          "script": "\tfilter \u003d system.mes.object.filter.createFilter()\n\tfilter.setMESObjectTypeName(\u0027Line\u0027)\n\tfilter.setPrimaryMESObjectPath(self.view.params.equipmentPath)\n\tlines \u003d system.mes.searchMESObjects(filter)\n\t\n\ttotalProduced, totalRejects, totalRemaining, remaining \u003d 0,0,0,0\n\t\n\t\n\t#Iterate through all lines to sum counters\n\tfor mesObjectLink in lines:\n\t\tfault \u003d False\n\t\teqPath \u003d mesObjectLink.getMESObject().getEquipmentPath()\n\t\tparentPath \u003d \u0027[MES]\u0027 + eqPath.replace(\u0027\\\\\u0027,\u0027/\u0027) + \u0027/Live Analysis/Day(production)/\u0027\n\t\tresults \u003d system.tag.readBlocking([parentPath + \u0027OEE Outfeed Count\u0027,parentPath + \u0027OEE Reject Count\u0027,parentPath + \u0027Line Target Count Variance\u0027],1000)\n\t\t\n\t\tfor tag in results:\n\t\t\tif not (tag.getQuality().isGood()):\n\t\t\t\tlogger \u003d system.util.getLogger(\u0027MES Admin\u0027)\n\t\t\t\tlogger.warn(str(parentPath) +\u0027Tag not found for Site Production Goal. Ensure onboarding is complete and check Live Analysis\u0027)\n\t\t\t\tfault \u003d True\n\t\t\t\tbreak\n\t\tif fault:\n\t\t\tlogger.warn(\u0027skipping \u0027 + str(eqPath))\n\t\t\tcontinue\n\t\t\t\n\t\tproduced \u003d int(results[0].value)\n\t\trejects \u003d int(results[1].value)\n\t\tremaining \u003d int(results[2].value)\n\t\t\n\t\tif remaining \u003c 0:\n\t\t\tremaining \u003d abs(remaining)\n\t\telif remaining \u003e 0:\n\t\t\tremaining \u003d 0\n\t\t\n\t\ttotalProduced +\u003d produced\n\t\ttotalRejects +\u003d rejects\n\t\ttotalRemaining +\u003d remaining\n\t\t\n\t\tdata \u003d [{\u0027title\u0027:\u0027Produced\u0027,\u0027count\u0027:totalProduced},{\u0027title\u0027:\u0027Rejects\u0027,\u0027count\u0027:totalRejects},{\u0027title\u0027:\u0027Remaining\u0027,\u0027count\u0027:totalRemaining}]\n\t\tself.getChild(\"PieChart\").props.data \u003d data"
        }
      }
    },
    "props": {
      "direction": "column",
      "style": {
        "overflow": "hidden"
      }
    },
    "type": "ia.container.flex"
  }
}