{
  "custom": {},
  "params": {
    "configuring": false,
    "equipmentPath": "",
    "timePeriod": "",
    "title": "Current Schedule Variance"
  },
  "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.timePeriod": {
      "paramDirection": "inout",
      "persistent": true
    },
    "params.title": {
      "paramDirection": "inout",
      "persistent": true
    }
  },
  "props": {
    "defaultSize": {
      "height": 396,
      "width": 431
    }
  },
  "root": {
    "children": [
      {
        "meta": {
          "name": "configuration"
        },
        "position": {
          "basis": "320px",
          "grow": 1
        },
        "propConfig": {
          "position.display": {
            "binding": {
              "config": {
                "path": "view.params.configuring"
              },
              "type": "property"
            }
          }
        },
        "props": {
          "params": {
            "equipmentPathIn": "",
            "equipmentPathOut": "",
            "timePeriodIn": "",
            "timePeriodOut": "",
            "titleIn": "Current Schedule Variance",
            "titleOut": "Current Schedule Variance"
          },
          "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"
          },
          {
            "meta": {
              "name": "mesWorkOrderTable"
            },
            "position": {
              "basis": "500px",
              "display": false
            },
            "type": "mes.production.mesWorkOrderTable"
          },
          {
            "children": [
              {
                "meta": {
                  "name": "leftSpacing"
                },
                "propConfig": {
                  "position.grow": {
                    "binding": {
                      "config": {
                        "path": ".../VarianceContainer.custom.VariancePos"
                      },
                      "type": "property"
                    }
                  }
                },
                "props": {
                  "style": {
                    "marginLeft": "35px"
                  }
                },
                "type": "ia.container.coord"
              },
              {
                "children": [
                  {
                    "meta": {
                      "name": "Units"
                    },
                    "position": {
                      "basis": "32px",
                      "shrink": 0
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../runtime.custom.VarianceUnits"
                          },
                          "transforms": [
                            {
                              "code": "\tif value is None:\n\t\treturn \"\"\n\telif value \u003d\u003d 0:\n\t\treturn \"Zero Units\"\n\treturn \"{:,}\".format(int(value)) + \" Units\"",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "props": {
                      "textStyle": {
                        "textAlign": "center"
                      }
                    },
                    "type": "ia.display.label"
                  },
                  {
                    "meta": {
                      "name": "Minutes"
                    },
                    "position": {
                      "basis": "32px",
                      "shrink": 0
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../runtime.custom.VarianceMinutes"
                          },
                          "transforms": [
                            {
                              "code": "\tif value is None:\n\t\treturn \"\"\n\telif value \u003d\u003d 0:\n\t\treturn \"Zero Minutes\"\n\treturn \"{:,}\".format(int(value)) + \" Minutes\"",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "props": {
                      "textStyle": {
                        "textAlign": "center"
                      }
                    },
                    "type": "ia.display.label"
                  },
                  {
                    "meta": {
                      "name": "Status"
                    },
                    "position": {
                      "basis": "32px",
                      "shrink": 0
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../runtime.custom.Remaining"
                          },
                          "transforms": [
                            {
                              "code": "\tdef calcPos(NegPos):\n\t\tif NegPos \u003d\u003d 0:\n\t\t\tself.parent.parent.parent.getChild(\"VarianceContainer\").custom.ScheduledPos \u003d 0.5\n\t\t\tself.parent.parent.parent.getChild(\"VarianceContainer\").custom.VariancePos \u003d 0.5\n\t\t\treturn\n\t\tstartToNowMinutes \u003d self.parent.parent.parent.parent.getChild(\"runtime\").custom.startToNowMinutes\n\t\tVarianceMinutes \u003d self.parent.parent.parent.parent.getChild(\"runtime\").custom.VarianceMinutes\n\t\t\n\t\tmaxMinutesSize \u003d 2 * startToNowMinutes\n\t\t\n\t\tif VarianceMinutes \u003e startToNowMinutes:\n\t\t\tmaxMinutesSize \u003d 2 * VarianceMinutes\n\t\t\t\n\t\tVariancePos \u003d float(startToNowMinutes + VarianceMinutes * NegPos) / maxMinutesSize\n\t\tScheduledPos \u003d  float(startToNowMinutes) / maxMinutesSize\n\t\t\n\t\tif ScheduledPos \u003c 0:\n\t\t\tScheduledPos \u003d 0\n\t\telif ScheduledPos \u003e 1:\n\t\t\tScheduledPos \u003d 1\n\t\t\n\t\tif VariancePos \u003c 0:\n\t\t\tVariancePos \u003d 0\n\t\telif VariancePos \u003e 1:\n\t\t\tVariancePos \u003d 1\n\t\t\n\t\tself.parent.parent.parent.getChild(\"VarianceContainer\").custom.ScheduledPos \u003d ScheduledPos\n\t\tself.parent.parent.parent.getChild(\"VarianceContainer\").custom.VariancePos \u003d VariancePos\n\t\t\n\tif value is None or value \u003d\u003d 0:\n\t\tcalcPos(0)\n\t\treturn  \"Zero Remaining\"\n\tif value \u003e 0:\n\t\tcalcPos(-1)\n\t\treturn \"Remaining\"\n\telse:\n\t\tcalcPos(1)\n\t\treturn \"Overrun\"",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "props": {
                      "textStyle": {
                        "textAlign": "center"
                      }
                    },
                    "type": "ia.display.label"
                  }
                ],
                "meta": {
                  "name": "FlexContainer"
                },
                "position": {
                  "shrink": 0
                },
                "props": {
                  "direction": "column",
                  "justify": "flex-end"
                },
                "type": "ia.container.flex"
              },
              {
                "meta": {
                  "name": "rightSpacing"
                },
                "position": {
                  "basis": "35px",
                  "shrink": 0
                },
                "type": "ia.container.coord"
              }
            ],
            "meta": {
              "name": "VarianceFlex"
            },
            "position": {
              "basis": "90px",
              "shrink": 0
            },
            "props": {
              "style": {
                "marginBottom": "2%",
                "marginTop": "2%"
              }
            },
            "type": "ia.container.flex"
          },
          {
            "children": [
              {
                "meta": {
                  "name": "madeBox"
                },
                "position": {
                  "height": "20%",
                  "width": "90%",
                  "x": "5%",
                  "y": "40%"
                },
                "props": {
                  "style": {
                    "borderStyle": "none",
                    "classes": "SepasoftColors/Background/SecondaryColor_C8C7C6"
                  }
                },
                "type": "ia.container.coord"
              },
              {
                "meta": {
                  "name": "remainingBox"
                },
                "position": {
                  "height": "20%",
                  "width": "0.0%",
                  "y": "40%"
                },
                "propConfig": {
                  "position.x": {
                    "binding": {
                      "config": {
                        "expression": "{parent.custom.ScheduledPos} + \",\" + {parent.custom.VariancePos}"
                      },
                      "transforms": [
                        {
                          "code": "\tarray \u003d value.split(\",\")\n\tScheduledPos \u003d float(array[0])\n\tVariancePos \u003d float(array[1])\n\t\n\tif ScheduledPos \u003e VariancePos:\n\t\tpos \u003d str(5 + VariancePos * 90) + \"%\"\n\t\twidth \u003d str( 1+ (ScheduledPos - VariancePos) * 90) + \"%\"\n\t\tself.position.width \u003d width\n\t\treturn pos\n\telse:\n\t\tpos \u003d str(5 + ScheduledPos * 90) + \"%\"\n\t\twidth \u003d str( (VariancePos - ScheduledPos) * 90 ) + \"%\"\n\t\tself.position.width \u003d width\n\t\t\n\t\treturn pos\n\treturn value",
                          "type": "script"
                        }
                      ],
                      "type": "expr"
                    }
                  },
                  "props.style.classes": {
                    "binding": {
                      "config": {
                        "expression": "{parent.custom.ScheduledPos} +\",\"+ {parent.custom.VariancePos}"
                      },
                      "transforms": [
                        {
                          "code": "\tarray \u003d value.split(\",\")\n\tScheduledPos \u003d float(array[0])\n\tVariancePos  \u003d float(array[1])\n\tif ScheduledPos - VariancePos  \u003c 0:\n\t\treturn \"SepasoftColors/Background/PrimaryColor_4C9C2E\"\n\telse:\n\t\treturn \"SepasoftColors/Background/SecondaryColor_EC1C24\"",
                          "type": "script"
                        }
                      ],
                      "type": "expr"
                    }
                  }
                },
                "props": {
                  "style": {
                    "borderStyle": "none"
                  }
                },
                "type": "ia.container.coord"
              },
              {
                "meta": {
                  "name": "ScheduledStick"
                },
                "position": {
                  "height": "60%",
                  "width": "1%"
                },
                "propConfig": {
                  "position.x": {
                    "binding": {
                      "config": {
                        "path": "parent.custom.VariancePos"
                      },
                      "transforms": [
                        {
                          "code": "\tpos \u003d str(int(5 + value * 90)) + \"%\"\n\t\n\treturn pos",
                          "type": "script"
                        }
                      ],
                      "type": "property"
                    }
                  }
                },
                "props": {
                  "style": {
                    "classes": "SepasoftColors/Background/SecondaryColor_2D2A26"
                  }
                },
                "type": "ia.container.coord"
              },
              {
                "meta": {
                  "name": "MadeStick"
                },
                "position": {
                  "height": "60%",
                  "width": "1%",
                  "y": "40%"
                },
                "propConfig": {
                  "position.x": {
                    "binding": {
                      "config": {
                        "path": "parent.custom.ScheduledPos"
                      },
                      "transforms": [
                        {
                          "code": "\tpos \u003d str(int(5 + value * 90)) + \"%\"\n\t\n\treturn pos",
                          "type": "script"
                        }
                      ],
                      "type": "property"
                    }
                  }
                },
                "props": {
                  "style": {
                    "classes": "SepasoftColors/Background/SecondaryColor_2D2A26"
                  }
                },
                "type": "ia.container.coord"
              }
            ],
            "custom": {
              "ScheduledPos": 0.5,
              "VariancePos": 0.5
            },
            "meta": {
              "name": "VarianceContainer"
            },
            "position": {
              "basis": "200px",
              "grow": 1
            },
            "type": "ia.container.coord"
          },
          {
            "children": [
              {
                "meta": {
                  "name": "leftSpacing"
                },
                "propConfig": {
                  "position.grow": {
                    "binding": {
                      "config": {
                        "path": ".../VarianceContainer.custom.ScheduledPos"
                      },
                      "type": "property"
                    }
                  }
                },
                "props": {
                  "style": {
                    "marginLeft": "35px"
                  }
                },
                "type": "ia.container.coord"
              },
              {
                "children": [
                  {
                    "meta": {
                      "name": "Units"
                    },
                    "position": {
                      "basis": "32px",
                      "shrink": 0
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../runtime.custom.Scheduled"
                          },
                          "transforms": [
                            {
                              "code": "\tif value is None:\n\t\treturn \"\"\n\telif value \u003d\u003d 0:\n\t\treturn \"Zero Units Scheduled\"\n\treturn \"{:,}\".format(int(value)) + \" Units Scheduled\"",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "props": {
                      "textStyle": {
                        "textAlign": "center"
                      }
                    },
                    "type": "ia.display.label"
                  },
                  {
                    "meta": {
                      "name": "Minutes"
                    },
                    "position": {
                      "basis": "32px",
                      "shrink": 0
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../runtime.custom.ScheduledTime"
                          },
                          "transforms": [
                            {
                              "code": "\ttry:\n\t\treturn system.date.format(value, \"yyyy-MM-dd\")\n\texcept:\n\t\treturn \"\"\n",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "props": {
                      "textStyle": {
                        "textAlign": "center"
                      }
                    },
                    "type": "ia.display.label"
                  },
                  {
                    "meta": {
                      "name": "Status"
                    },
                    "position": {
                      "basis": "32px",
                      "shrink": 0
                    },
                    "propConfig": {
                      "props.text": {
                        "binding": {
                          "config": {
                            "path": "...../runtime.custom.ScheduledTime"
                          },
                          "transforms": [
                            {
                              "code": "\ttry:\n\t\treturn system.date.format(value, \"hh:mm:ss\")\n\texcept:\n\t\treturn \"\"",
                              "type": "script"
                            }
                          ],
                          "type": "property"
                        }
                      }
                    },
                    "props": {
                      "textStyle": {
                        "textAlign": "center"
                      }
                    },
                    "type": "ia.display.label"
                  }
                ],
                "meta": {
                  "name": "FlexContainer"
                },
                "position": {
                  "shrink": 0
                },
                "props": {
                  "direction": "column",
                  "justify": "flex-end"
                },
                "type": "ia.container.flex"
              },
              {
                "meta": {
                  "name": "rightSpacing"
                },
                "position": {
                  "basis": "35px",
                  "shrink": 0
                },
                "type": "ia.container.coord"
              }
            ],
            "meta": {
              "name": "ScheduledFlex"
            },
            "position": {
              "basis": "90px",
              "shrink": 0
            },
            "props": {
              "style": {
                "marginBottom": "2%",
                "marginTop": "2%"
              }
            },
            "type": "ia.container.flex"
          }
        ],
        "custom": {
          "Remaining": 0,
          "Scheduled": 0,
          "ScheduledTime": null,
          "VarianceUnits": 0,
          "startToNowMinutes": 0
        },
        "meta": {
          "name": "runtime"
        },
        "position": {
          "basis": "200px",
          "grow": 1
        },
        "propConfig": {
          "custom.VarianceMinutes": {
            "binding": {
              "config": {
                "expression": "toStr({./mesWorkOrderTable.props.data}) + \"~\" + toStr({view.params.equipmentPath})"
              },
              "transforms": [
                {
                  "code": "\t#https://help.sepasoft.com/docs/display/SEPA/system.mes.getEquipmentScheduleEntries\n\teqPath \u003d str(value).split(\"~\")[1]\n\t\n\tdef clearValues():\n\t\tself.custom.VarianceUnits \u003d 0\n\t\tself.custom.VarianceMinutes \u003d 0\n\t\tself.custom.ScheduledTime \u003d None\n\t\tself.custom.Scheduled \u003d 0\n\t\tself.custom.startToNowMinutes \u003d 0\n\t\tself.custom.Remaining \u003d 0\n\t\treturn 0\t\n\t\t\n\tif eqPath \u003d\u003d \"\":\n\t\treturn clearValues()\n\t\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\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\tfor Schedule in list:\n\t\tStartDate \u003d Schedule.getOriginalStartDate()\n\t\tEndDate \u003d Schedule.getScheduledEndDate()\n\t\tif (system.date.secondsBetween(now, StartDate) \u003c 0 and system.date.secondsBetween(now, EndDate) \u003e 0):\n\t\t\tcurrentSchedule \u003d Schedule\t\n\t\t\tbreak\t\n\t\t\n\tif (currentSchedule is None):\n\t\treturn clearValues()\n\n\t#https://help.sepasoft.com/docs/display/SEPA/MES+Work+Order\n\tWorkOrderLink \u003d currentSchedule.getWorkOrderLink()\n\n\tScheduled \u003d float(WorkOrderLink.getMESObject().getWorkOrderQuantity())#getScheduledQuantity())\n\tEndTime \u003d currentSchedule.getScheduledEndDate()\n\tRemaining \u003d float(WorkOrderLink.getMESObject().getRemainingQuantity())\n\tMade \u003d Scheduled - Remaining\n\t\n\t#caculate variance\n\tstartToNowMinutes \u003d system.date.minutesBetween(currentSchedule.getOriginalStartDate(),system.date.now())\n\tRemainingMinutes \u003d system.date.minutesBetween(system.date.now(),currentSchedule.getScheduledEndDate())\n\t\n\tUnitsPerMinutes \u003d 0\n\t\n\tif Made!\u003d0 and startToNowMinutes !\u003d 0:\n\t\tUnitsPerMinutes \u003d Made / startToNowMinutes\n\t\n\t\testimatedFutureUnitsToBeMade \u003d UnitsPerMinutes * RemainingMinutes\n\t\tunitDif \u003d estimatedFutureUnitsToBeMade - Remaining\n\t\ttimeDif \u003d int(unitDif / UnitsPerMinutes)\n\t\t\n\t\tself.custom.VarianceUnits \u003d int(unitDif)\n\t\tself.custom.VarianceMinutes \u003d timeDif\n\t\tself.custom.ScheduledTime \u003d EndTime\n\t\tself.custom.Scheduled \u003d Scheduled\n\t\tself.custom.startToNowMinutes \u003d startToNowMinutes\n\t\tself.custom.Remaining \u003d Remaining\n\t\treturn timeDif\n\t\t \n\telif Made\u003d\u003d0 and startToNowMinutes !\u003d 0:\n\n\t\tself.custom.VarianceUnits \u003d 0\n\t\tself.custom.VarianceMinutes \u003d None\n\t\tself.custom.ScheduledTime \u003d EndTime\n\t\tself.custom.Scheduled \u003d Scheduled\n\t\tself.custom.startToNowMinutes \u003d startToNowMinutes\n\t\tself.custom.Remaining \u003d Remaining\n\t\treturn startToNowMinutes\n\t\t \n\treturn clearValues()",
                  "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"
    },
    "type": "ia.container.flex"
  }
}