{
  "custom": {},
  "params": {
    "configuring": false,
    "equipmentPath": "",
    "title": "Current 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": 321,
      "width": 459
    }
  },
  "root": {
    "children": [
      {
        "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.label"
                      },
                      "type": "property"
                    }
                  }
                },
                "props": {
                  "textStyle": {
                    "fontFamily": "Roboto",
                    "fontSize": "18px"
                  }
                },
                "type": "ia.display.label"
              }
            ],
            "meta": {
              "name": "CurrentScheduleFlexContainer"
            },
            "position": {
              "shrink": 0
            },
            "props": {
              "justify": "center",
              "style": {
                "marginTop": "10px"
              }
            },
            "type": "ia.container.flex"
          },
          {
            "children": [
              {
                "meta": {
                  "name": "CountLabel"
                },
                "position": {
                  "shrink": 0
                },
                "propConfig": {
                  "props.text": {
                    "binding": {
                      "config": {
                        "path": "..../runtime.custom.scheduleCount"
                      },
                      "transforms": [
                        {
                          "code": "\ttry:\n\t\treturn \"{:,}\".format( int(value)) + \" Units Scheduled\"\n\texcept:\n\t\treturn \"\"",
                          "type": "script"
                        }
                      ],
                      "type": "property"
                    }
                  }
                },
                "props": {
                  "textStyle": {
                    "fontSize": 16
                  }
                },
                "type": "ia.display.label"
              }
            ],
            "meta": {
              "name": "UnitsScheduledFlexContainer"
            },
            "position": {
              "shrink": 0
            },
            "propConfig": {
              "meta.visible": {
                "binding": {
                  "config": {
                    "path": "parent.custom.timeLinetype"
                  },
                  "transforms": [
                    {
                      "code": "\tif value \u003d\u003d \"production\":\n\t\treturn True\n\treturn False",
                      "type": "script"
                    }
                  ],
                  "type": "property"
                }
              }
            },
            "props": {
              "justify": "center"
            },
            "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": {
                "binding": {
                  "config": {
                    "path": "parent.custom.idealCount"
                  },
                  "type": "property"
                }
              },
              "props.params.timeLinetype": {
                "binding": {
                  "config": {
                    "path": "parent.custom.timeLinetype"
                  },
                  "type": "property"
                }
              },
              "props.params.varianceCount": {
                "binding": {
                  "config": {
                    "path": "parent.custom.varianceCount"
                  },
                  "type": "property"
                }
              },
              "props.params.variancePercentage": {
                "binding": {
                  "config": {
                    "path": "parent.custom.variancePercentage"
                  },
                  "type": "property"
                }
              }
            },
            "props": {
              "params": {
                "showVariance": true
              },
              "path": "Page/Widgets/Custom/VarianceTimeline",
              "style": {
                "marginBottom": 10,
                "marginLeft": 10,
                "marginRight": 10,
                "marginTop": 10
              }
            },
            "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": {
                "textAlign": "center"
              },
              "text": "None"
            },
            "type": "ia.display.label"
          }
        ],
        "custom": {
          "BeginTime": null,
          "EndTime": null,
          "idealCount": 0,
          "scheduleCount": 0,
          "timeLinetype": "",
          "varianceCount": 0,
          "variancePercentage": 0,
          "varianceTime": 0
        },
        "meta": {
          "name": "runtime"
        },
        "position": {
          "basis": "200px",
          "grow": 1
        },
        "propConfig": {
          "custom.label": {
            "binding": {
              "config": {
                "expression": "toStr(now(1000)) + \u0027~\u0027 + toStr({view.params.equipmentPath})"
              },
              "overlayOptOut": true,
              "transforms": [
                {
                  "code": "\teqPath \u003d value.split(\u0027~\u0027)[1]\n\t\n\ttimeLinetype \u003d \"production\"\n\t\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.varianceCount \u003d 0\n\t\tself.custom.variancePercentage \u003d 0\t\n\t\tself.custom.idealCount \u003d 0\n\t\tself.custom.scheduleCount \u003d 0\n\t\tself.custom.timeLinetype \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.addDays(system.date.now(), -100)\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\t\n\tlist \u003d system.mes.getEquipmentScheduleEntries(eqPath, begin, end, category, False)\n\t\n\tcurrentSchedule \u003d None\n\t\n\tnow \u003d system.date.now()\n\t\t\n\tStartDate \u003d 0\n\tEndDate \u003d 0\n\t\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\n\t\tif ( state \u003d\u003d 2 or state \u003d\u003d 5):\n\t\t\tcurrentSchedule \u003d Schedule\t\n\t\t\tbreak\t\n\t\t\n\tif (currentSchedule is None):\n\t\treturn clearData()\n\t\n\tself.getChild(\"EmbeddedViewTimeLine\").position.display \u003d True\n\n\t#get count\n\t#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\topSchedule \u003d currentSchedule.getMESOperationsScheduleLink().getMESObject()\n\t\n\tscheduleCount \u003d opSchedule.getScheduleProductionCount()\n\tif scheduleCount is None:\n\t\tsystem.perspective.print(\"schedule\")\n\t\ttimeLinetype \u003d \"schedule\"\n\t\tscheduleCount \u003d 0\n\t\n\tcurrentCount \u003d 0\n\t\n\tresponseLink \u003d currentSchedule.getMESOperationsResponseLink()\n\tif responseLink:\n\t\topResponse \u003d responseLink.getMESObject()\n\t\tcurrentCount \u003d opResponse.getProductionCount()\n\n\t#caculate variance\n\t#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\t\n\tscheduleStartEndtimDif \u003d system.date.minutesBetween(StartDate,EndDate)\n\tscheduleStartNowtimDif \u003d system.date.minutesBetween(StartDate, system.date.now())\n\n\tidealRate \u003d scheduleCount/scheduleStartEndtimDif\n\t\n\tidealCount \u003d idealRate * scheduleStartNowtimDif\n\t\n\tvarianceCount \u003d currentCount - idealCount \n\tvarianceTime \u003d 0\n\tvariancePercentage \u003d 0\n\t\n\tif scheduleStartNowtimDif !\u003d 0 and scheduleCount !\u003d 0:\n\t\tvariancePercentage \u003d currentCount / scheduleCount\n\t\t\n\t\tactualRate \u003d float(currentCount) / scheduleStartNowtimDif\n\t\t\n\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 currentSchedule.getMESOperationsRequestLink().getName().split(\u0027-\u0027)[0]\n\tlabel \u003d materialName\n\t\t\n\t#set everything\t\n\t#\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\n\n\tself.custom.BeginTime \u003d StartDate\n\tself.custom.EndTime \u003d EndDate\n\tself.custom.varianceCount \u003d varianceCount\n\tself.custom.variancePercentage \u003d variancePercentage\t\n\tself.custom.idealCount \u003d idealCount\n\tself.custom.scheduleCount \u003d scheduleCount\n\tself.custom.timeLinetype \u003d timeLinetype\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": "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 2",
            "equipmentPathOut": "",
            "titleIn": "Current Schedule",
            "titleOut": "Current Schedule"
          },
          "path": "Page/Widgets/Configuration/Equipment Path, Title"
        },
        "type": "ia.display.view"
      }
    ],
    "meta": {
      "name": "root"
    },
    "props": {
      "direction": "column",
      "style": {
        "fontFamily": "Roboto",
        "fontSize": "12px"
      }
    },
    "type": "ia.container.flex"
  }
}