{
  "custom": {},
  "params": {
    "configuring": false,
    "equipmentPath": "",
    "title": "Title"
  },
  "propConfig": {
    "params.configuring": {
      "onChange": {
        "enabled": null,
        "script": "\tviewParams\u003dself.params\n\tconfigParams\u003dself.getChild(\"root/configuration\").props.params\n\tif currentValue.value:\n\t\tconfigParams.equipmentPathIn \u003d viewParams.equipmentPath\t\n\t\tconfigParams.titleIn \u003d viewParams.title\n\telif previousValue is not None and previousValue.value:\n\t\tviewParams.equipmentPath \u003d configParams.equipmentPathOut\n\t\tviewParams.title \u003d configParams.titleOut"
      },
      "paramDirection": "input",
      "persistent": true
    },
    "params.equipmentPath": {
      "paramDirection": "inout",
      "persistent": true
    },
    "params.title": {
      "paramDirection": "inout",
      "persistent": true
    }
  },
  "props": {
    "defaultSize": {
      "height": 428,
      "width": 457
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "Widget Title"
        },
        "position": {
          "height": 0.1034,
          "width": 1
        },
        "propConfig": {
          "meta.visible": {
            "binding": {
              "config": {
                "expression": "!{view.params.configuring}"
              },
              "type": "expr"
            }
          },
          "props.params.text": {
            "binding": {
              "config": {
                "path": "view.params.title"
              },
              "type": "property"
            }
          }
        },
        "props": {
          "path": "Page/Embedded/Widget Title"
        },
        "type": "ia.display.view"
      },
      {
        "children": [
          {
            "meta": {
              "name": "Label"
            },
            "position": {
              "height": 0.0714,
              "width": 0.9535,
              "x": 0.0256,
              "y": -0.0057
            },
            "propConfig": {
              "props.style.fontSize": {
                "binding": {
                  "config": {
                    "path": "page.props.dimensions.screen.width"
                  },
                  "transforms": [
                    {
                      "code": "\tif(value \u003e\u003d600 and value\u003c1300):\n\t\treturn 12\n\telif (value \u003e\u003d1300 and value\u003c\u003d1580):\n\t\treturn 14\n\telif(value \u003e 1580):\n\t\treturn 18\n\telse:\n\t\treturn 6",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              },
              "props.text": {
                "binding": {
                  "config": {
                    "path": "view.params.equipmentPath"
                  },
                  "transforms": [
                    {
                      "code": "\tif value \u003d\u003d \"\" or value is None:\n\t\treturn \"\"\n\t\n\treturn value.split(\u0027\\\\\u0027)[3]",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "alignVertical": "bottom",
              "style": {
                "fontFamily": "Roboto",
                "fontWeight": "bold",
                "marginBottom": 5,
                "marginTop": 10,
                "overflow": "auto",
                "overflowX": "auto",
                "overflowY": "auto",
                "textAlign": "center"
              }
            },
            "type": "ia.display.label"
          },
          {
            "meta": {
              "name": "tf_quantity"
            },
            "position": {
              "height": 0.1428,
              "width": 0.9535,
              "x": 0.0238,
              "y": 0.5538
            },
            "propConfig": {
              "props.style.fontSize": {
                "binding": {
                  "config": {
                    "path": "page.props.dimensions.screen.width"
                  },
                  "transforms": [
                    {
                      "code": "\tif(value \u003e\u003d600 and value\u003c1300):\n\t\treturn 10\n\telif (value \u003e\u003d1300 and value\u003c\u003d1580):\n\t\treturn 12\n\telif(value \u003e 1580):\n\t\treturn 15\n\telse:\n\t\treturn 6",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "placeholder": "Enter Quantity",
              "style": {
                "fontFamily": "Roboto",
                "marginBottom": 10,
                "marginTop": 10,
                "paddingBottom": 10,
                "paddingTop": 10,
                "textAlign": "left"
              }
            },
            "type": "ia.input.text-field"
          },
          {
            "events": {
              "component": {
                "onActionPerformed": {
                  "config": {
                    "script": "\tdef fixLots(eqPath):\n\t\tdata \u003d system.mes.trace.getInventory(equipmentPath\u003deqPath)\n\t\tfor lot in data[\u0027lots\u0027]:\n\t\t\tif lot[\u0027NetQuantity\u0027] \u003c 0:\n\t\t\t\tlotObj \u003d system.mes.loadMaterialLot(lot[\u0027LotNumber\u0027], 1, True)\n\t\t\t\tlotstatus \u003d lotObj.lotAvailabilityStatus\n\t\t\t\tusedLotStatus \u003d lotstatus.getTypeFromName(\u0027USED\u0027)\n\t\t\t\tlotObj.setLotAvailabilityStatus(usedLotStatus)\n\t\t\t\tlotObj.save()\n\t\n\teqPath \u003d self.view.params.equipmentPath\n\tq \u003d float(self.getSibling(\"tf_quantity\").props.text)\n\tlotNumber \u003d system.date.toMillis(system.date.now())\n\tmatName \u003d self.getSibling(\"mos_matDef\").props.selectedMESObject.name\n\tlot \u003d system.mes.trace.getInventory(equipmentPath\u003deqPath,materialName\u003dmatName)\n\t\n\t#lot already exists, record adding to inventory\n\tif lot[\u0027lots\u0027]:\n\t\texistingLot \u003d lot[\u0027lots\u0027][0]\n\t\tnewQuantity \u003d existingLot[\u0027NetQuantity\u0027] + q\n\t\toriginalMatIn \u003d system.mes.trace.configureMaterial(lotNo\u003dexistingLot[\u0027LotNumber\u0027], name\u003d\u0027currentLot\u0027, quantity\u003dexistingLot[\u0027NetQuantity\u0027], materialName\u003dmatName, equipmentPath\u003deqPath)\n\t\tnewMatIn      \u003d system.mes.trace.configureMaterial(lotNo\u003dlotNumber,name\u003d\u0027newMaterial\u0027,quantity\u003dq,materialName\u003dmatName,equipmentPath\u003deqPath,autoCreateLot\u003dTrue)\n\t\tmatout \u003d system.mes.trace.configureMaterial(lotNo\u003dexistingLot[\u0027LotNumber\u0027], name\u003d\u0027materialOut\u0027, quantity\u003dnewQuantity, materialName\u003dmatName, equipmentPath\u003deqPath, autoCreateLot\u003dTrue)\n\t\t\n\t\tsystem.mes.trace.recordOperation(equipmentPath\u003deqPath,name\u003d\u0027Receive Inventory\u0027,materialIn\u003d[originalMatIn,newMatIn], materialOut\u003d[matout])\n\telse:\n\t\t#retrieve environmental information from external API\n\t\tchartPath \u003d \u0027Weather/getWeatherByZip\u0027\n\t\tparameterValues \u003d {\n\t\t\u0027zip\u0027 : \u002795762\u0027}\n\t\treturnThese \u003d [\u0027temp\u0027, \u0027humidity\u0027, \u0027pressure\u0027]\n\t\treturnedParams \u003d system.mes.bc.executeChartSynchronous(chartPath, parameterValues, returnThese)\n\t\tcustomProps \u003d [{\u0027Name\u0027:\u0027batchid\u0027,\u0027Value\u0027:str(system.date.toMillis(system.date.now()))},{\u0027Name\u0027:\u0027temp\u0027,\u0027Value\u0027:returnedParams[\u0027temp\u0027]},{\u0027Name\u0027:\u0027humidity\u0027,\u0027Value\u0027:returnedParams[\u0027humidity\u0027]}]\n\t\t\t\n\t\t\n\t\t#No lot exists, create new\n\t\tmatout \u003d system.mes.trace.configureMaterial(lotNo\u003dlotNumber, name\u003d\u0027materialOut\u0027, quantity\u003dq, materialName\u003dmatName, equipmentPath\u003deqPath, autoCreateLot\u003dTrue, lotCustomProps\u003dcustomProps)\n\t\tsystem.mes.trace.recordOperation(equipmentPath\u003deqPath,name\u003d\u0027Receive Inventory\u0027,materialOut\u003d[matout])\n\t\n\t#overcoming issue with input lot creation but not getting marked as used\n\timport time\n\ttime.sleep(1)\n\tfixLots(eqPath)\n\tself.getSibling(\"lbl_message\").props.text \u003d \u0027Success - Lot \u0027 + str(lotNumber) + \u0027 created\u0027\n\tself.getSibling(\"tf_quantity\").props.text \u003d \u0027\u0027\n\t\n\t#update inventory tag\t\n\tshared.mes.inventory.updateCurrentInventory(eqPath, \u0027Raw Materials\u0027)"
                  },
                  "scope": "G",
                  "type": "script"
                }
              },
              "dom": {
                "onBlur": {
                  "config": {
                    "script": "\tself.getSibling(\"lbl_message\").props.text \u003d \u0027\u0027"
                  },
                  "scope": "G",
                  "type": "script"
                }
              }
            },
            "meta": {
              "name": "btn_receive"
            },
            "position": {
              "height": 0.1428,
              "width": 0.9535,
              "x": 0.0238,
              "y": 0.7793
            },
            "propConfig": {
              "props.textStyle.fontSize": {
                "binding": {
                  "config": {
                    "path": "page.props.dimensions.screen.width"
                  },
                  "transforms": [
                    {
                      "code": "\tif(value \u003e\u003d600 and value\u003c1300):\n\t\treturn 14\n\telif (value \u003e\u003d1300 and value\u003c\u003d1580):\n\t\treturn 16\n\telif(value \u003e 1580):\n\t\treturn 18\n\telif(value \u003d\u003d 0):\n\t\treturn 18\n\telse:\n\t\treturn 10",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "style": {
                "classes": "Buttons/Large_Button",
                "height": "64px",
                "width": "100px"
              },
              "text": "Receive Materials"
            },
            "type": "ia.input.button"
          },
          {
            "meta": {
              "name": "lbl_message"
            },
            "position": {
              "height": 0.0659,
              "width": 0.9304,
              "x": 0.0342,
              "y": 0.9259
            },
            "props": {
              "style": {
                "color": "#000000BA",
                "fontFamily": "Roboto",
                "fontSize": 15,
                "fontWeight": "bold",
                "textAlign": "center"
              }
            },
            "type": "ia.display.label"
          },
          {
            "meta": {
              "name": "mos_matClass"
            },
            "position": {
              "height": 0.1428,
              "width": 0.9535,
              "x": 0.0238,
              "y": 0.0919
            },
            "props": {
              "displayText": "Select Material Group",
              "includeMaterialClassObjects": true,
              "primaryClassFilter": "Raw Materials"
            },
            "type": "mes.production.mesObjectSelector"
          },
          {
            "meta": {
              "name": "mos_matDef"
            },
            "position": {
              "height": 0.1428,
              "width": 0.9535,
              "x": 0.0238,
              "y": 0.3228
            },
            "propConfig": {
              "props.parentMESObjectFilter": {
                "binding": {
                  "config": {
                    "path": "../mos_matClass.props.selectedMESObject"
                  },
                  "type": "property"
                }
              }
            },
            "props": {
              "displayText": "Select material",
              "includeMaterialDefObjects": true
            },
            "type": "mes.production.mesObjectSelector"
          }
        ],
        "meta": {
          "name": "runtime"
        },
        "position": {
          "height": 0.8929,
          "width": 0.9938,
          "x": 0.0049,
          "y": 0.1049
        },
        "propConfig": {
          "meta.visible": {
            "binding": {
              "config": {
                "expression": "!{view.params.configuring}"
              },
              "type": "expr"
            }
          }
        },
        "props": {
          "mode": "percent"
        },
        "type": "ia.container.coord"
      },
      {
        "meta": {
          "name": "configuration"
        },
        "position": {
          "height": 1,
          "width": 1
        },
        "propConfig": {
          "meta.visible": {
            "binding": {
              "config": {
                "path": "view.params.configuring"
              },
              "type": "property"
            }
          }
        },
        "props": {
          "params": {
            "equipmentPathIn": "",
            "equipmentPathOut": "",
            "titleIn": "Title",
            "titleOut": "Title"
          },
          "path": "Page/Widgets/Configuration/Equipment Path, Title"
        },
        "type": "ia.display.view"
      }
    ],
    "meta": {
      "name": "root"
    },
    "props": {
      "mode": "percent"
    },
    "type": "ia.container.coord"
  }
}