{
  "custom": {},
  "params": {
    "configuring": false,
    "equipmentPath": "",
    "title": "Next Schedule"
  },
  "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": 313,
      "width": 492
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "configuration"
        },
        "position": {
          "basis": "320px",
          "grow": 1
        },
        "propConfig": {
          "position.display": {
            "binding": {
              "config": {
                "path": "view.params.configuring"
              },
              "type": "property"
            }
          }
        },
        "props": {
          "params": {
            "equipmentPathIn": "New Enterprise\\Site 1\\Area 1\\Packaging Line 1",
            "equipmentPathOut": "",
            "timePeriodIn": "",
            "timePeriodOut": "",
            "titleIn": "Next Schedule",
            "titleOut": "Next Schedule"
          },
          "path": "Page/Widgets/Configuration/Equipment Path, Title"
        },
        "type": "ia.display.view"
      },
      {
        "children": [
          {
            "meta": {
              "name": "title"
            },
            "position": {
              "shrink": 0
            },
            "propConfig": {
              "position.display": {
                "binding": {
                  "config": {
                    "expression": "coalesce({view.params.title},\u0027\u0027)!\u003d\u0027\u0027"
                  },
                  "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": "ProductLabel"
                },
                "position": {
                  "shrink": 0
                },
                "propConfig": {
                  "props.text": {
                    "binding": {
                      "config": {
                        "path": "..../runtime.custom.product"
                      },
                      "transforms": [
                        {
                          "code": "\tif value is None:\n\t\treturn \"\"\n\treturn value",
                          "type": "script"
                        }
                      ],
                      "type": "property"
                    }
                  }
                },
                "type": "ia.display.label"
              },
              {
                "meta": {
                  "name": "workOrderLabel"
                },
                "position": {
                  "shrink": 0
                },
                "propConfig": {
                  "props.text": {
                    "binding": {
                      "config": {
                        "path": "..../runtime.custom.workOrder"
                      },
                      "transforms": [
                        {
                          "code": "\tif value \u003d\u003d \"\" or \"None\":\n\t\treturn \"\"\n\tif self.getSibling(\"ProductLabel\").props.text \u003d\u003d \"\":\n\t\t\treturn str(value)\n\t\t\n\treturn \"/\" + str(value)",
                          "type": "script"
                        }
                      ],
                      "type": "property"
                    }
                  }
                },
                "type": "ia.display.label"
              }
            ],
            "meta": {
              "name": "NextScheduledFlexContainer"
            },
            "position": {
              "shrink": 0
            },
            "props": {
              "justify": "center",
              "style": {
                "marginTop": "20px"
              }
            },
            "type": "ia.container.flex"
          },
          {
            "children": [
              {
                "meta": {
                  "name": "CountLabel"
                },
                "position": {
                  "shrink": 0
                },
                "propConfig": {
                  "props.text": {
                    "binding": {
                      "config": {
                        "path": "..../runtime.custom.Scheduled"
                      },
                      "transforms": [
                        {
                          "code": "\ttry:\n\t\treturn \"{:,}\".format( int(value)) + \" Units Scheduled\"\n\texcept:\n\t\treturn \"\"",
                          "type": "script"
                        }
                      ],
                      "type": "property"
                    }
                  }
                },
                "type": "ia.display.label"
              }
            ],
            "meta": {
              "name": "UnitsScheduledFlexContainer"
            },
            "position": {
              "shrink": 0
            },
            "props": {
              "justify": "center",
              "style": {
                "marginTop": "0px"
              }
            },
            "type": "ia.container.flex"
          },
          {
            "meta": {
              "name": "EmbeddedViewTimeLine"
            },
            "position": {
              "basis": "320px",
              "display": false
            },
            "propConfig": {
              "props.params.Begin": {
                "binding": {
                  "config": {
                    "path": "parent.custom.BeginTime"
                  },
                  "transforms": [
                    {
                      "formatType": "datetime",
                      "formatValue": {
                        "date": "short",
                        "time": "medium"
                      },
                      "type": "format"
                    },
                    {
                      "code": "\tdate \u003d system.date.parse(str(value), \u0027MM/dd/yy, hh:mm:ss a\u0027)\n\treturn date",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              },
              "props.params.End": {
                "binding": {
                  "config": {
                    "path": "parent.custom.EndTime"
                  },
                  "transforms": [
                    {
                      "formatType": "datetime",
                      "formatValue": {
                        "date": "short",
                        "time": "medium"
                      },
                      "type": "format"
                    },
                    {
                      "code": "\tdate \u003d system.date.parse(str(value), \u0027MM/dd/yy, hh:mm:ss a\u0027)\n\treturn date",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "params": {
                "idealCount": 2,
                "timeLinetype": "next",
                "varianceCount": -1,
                "variancePercentage": 0
              },
              "path": "Page/Widgets/Custom/VarianceTimeline"
            },
            "type": "ia.display.view"
          },
          {
            "meta": {
              "name": "NoneLabel"
            },
            "position": {
              "basis": "32px",
              "grow": 1
            },
            "propConfig": {
              "position.display": {
                "binding": {
                  "config": {
                    "expression": "!{../EmbeddedViewTimeLine.position.display}"
                  },
                  "type": "expr"
                }
              }
            },
            "props": {
              "style": {
                "fontFamily": "Roboto",
                "textAlign": "center"
              },
              "text": "None"
            },
            "type": "ia.display.label"
          }
        ],
        "custom": {
          "BeginTime": null,
          "EndTime": null,
          "Scheduled": "",
          "workOrder": ""
        },
        "meta": {
          "name": "runtime"
        },
        "position": {
          "basis": "200px",
          "grow": 1
        },
        "propConfig": {
          "custom.product": {
            "binding": {
              "config": {
                "expression": "toStr(tag(\u0027[MES]\u0027+ {view.params.equipmentPath} + \u0027/Live Analysis/Current Shift/Product Code\u0027)) + \"~\" + toStr({view.params.equipmentPath})"
              },
              "transforms": [
                {
                  "code": "\teqPath \u003d str(value).split(\"~\")[1]\n\tcurrentProductCode \u003d str(value).split(\"~\")[0]\n\tdef clearData():\n\t\tself.getChild(\"EmbeddedViewTimeLine\").position.display \u003d False\n\t\tself.custom.BeginTime \u003d None\n\t\tself.custom.EndTime \u003d None\n\t\tself.custom.workOrder \u003d \"\"\n\t\tself.custom.Scheduled \u003d \"\"\n\t\treturn \"\"\n\t\n\tif eqPath \u003d\u003d \"\":\n\t\treturn clearData()\n\t\n\t#define the start and end dates\n\tbegin \u003d system.date.now()\n\tend \u003d system.date.addDays(system.date.now(), 100)\n\t  \n\t#let category be \u0027Active\u0027\n\tcategory \u003d \u0027Active\u0027\n\t  \n\t#Gets the equipment schedule entries\n\t#https://help.sepasoft.com/docs/display/SEPA/system.mes.getEquipmentScheduleEntries\n\tlist \u003d system.mes.getEquipmentScheduleEntries(eqPath, begin, end, category, False)\n\t\n\tnextSchedule \u003d None\n\t\n\tnow \u003d system.date.now()\n\t\n\tStartDate \u003d 0\n\tEndDate \u003d 0\n\t\n\tfor Schedule in list:\n\t\tStartDate \u003d Schedule.getScheduledStartDate()\n\t\tEndDate \u003d Schedule.getScheduledEndDate()\n\t\tstate \u003d Schedule.getState()\n\t\tif ( state \u003d\u003d 2 or state \u003d\u003d 5):\n\t\t\tcontinue\n\t\t\n\t\tif (system.date.secondsBetween(now, StartDate) \u003e 0 and system.date.secondsBetween(now, EndDate) \u003e 0):\n\t\t\tnextSchedule \u003d Schedule\t\t\n\t\t\tbreak\n\t\t\t\n\t\n\tif (nextSchedule is None):\n\t\treturn clearData()\n\t\t\n\t\n\n\tself.custom.BeginTime \u003d StartDate\n\tself.custom.EndTime \u003d EndDate\n\tself.getChild(\"EmbeddedViewTimeLine\").position.display \u003d True\n\n\tWorkOrderLink \u003d nextSchedule.getWorkOrderLink()\n\t#find label, material/work order\n\t#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\tmaterialName \u003d nextSchedule.getMESOperationsRequestLink().getName().split(\u0027-\u0027)[0]\n\tlabel \u003d materialName\n\tif label \u003d\u003d currentProductCode:\n\t\treturn clearData()\n\t\n\t#get count\n\topSchedule \u003d nextSchedule.getMESOperationsScheduleLink().getMESObject()\n\tscheduleCount \u003d opSchedule.getScheduleProductionCount()\n\t\n\tself.custom.Scheduled \u003d scheduleCount\n\n\treturn label",
                  "type": "script"
                }
              ],
              "type": "expr"
            }
          },
          "position.display": {
            "binding": {
              "config": {
                "expression": "!{view.params.configuring}"
              },
              "type": "expr"
            }
          }
        },
        "props": {
          "direction": "column"
        },
        "type": "ia.container.flex"
      }
    ],
    "meta": {
      "name": "root"
    },
    "props": {
      "direction": "column",
      "style": {
        "fontFamily": "Roboto",
        "fontSize": "12px"
      }
    },
    "type": "ia.container.flex"
  }
}