From 335fc32732b225cac10583ee5455ad06b44c3586 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Sun, 18 Apr 2021 13:53:07 +0800 Subject: [PATCH] Initial Commit. --- .idea/.gitignore | 8 ++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/misc.xml | 7 ++ .idea/modules.xml | 8 ++ .idea/scheduling.iml | 10 ++ .idea/vcs.xml | 6 ++ model.py | 95 +++++++++++++++++++ runtime.py | 33 +++++++ scheduling.py | 14 +++ 9 files changed, 187 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/scheduling.iml create mode 100644 .idea/vcs.xml create mode 100644 model.py create mode 100644 runtime.py create mode 100644 scheduling.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..30078b5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..57e3b20 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/scheduling.iml b/.idea/scheduling.iml new file mode 100644 index 0000000..e1774a4 --- /dev/null +++ b/.idea/scheduling.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/model.py b/model.py new file mode 100644 index 0000000..1a5311a --- /dev/null +++ b/model.py @@ -0,0 +1,95 @@ +from __future__ import annotations +from datetime import datetime +from typing import List, Dict, Set + + +class Order: + + def __init__(self, order_id: str, description: str): + self.order_id: str = order_id + self.description: str = description + self.earliest_start_time: datetime = datetime.today() + self.latest_end_time: datetime = datetime.today() + self.products: List[Dict[str, any]] = [] + + def set_time(self, earliest_start_time: datetime, latest_end_time: datetime): + self.earliest_start_time = earliest_start_time + self.latest_end_time = latest_end_time + + def add_product(self, product, amount): + self.products.append({ + "product": product, + "amount": amount + }) + + +class Product: + + def __init__(self, product_id: str, product_name: str): + self.product_id: str = product_id + self.product_name: str = product_name + + +class Workspace: + + def __init__(self, name: str): + self.name: str = name + + +class Process: + + def __init__(self, + pcs_id: str, + pcs_name: str, + product: Product, + prev_pcs: Process, + last_pcs: Process, + workspace: Workspace): + + self.pcs_id: str = pcs_id + self.pcs_name: str = pcs_name + self.product: Product = product + + self.production_mode: int = 0 + self.min_quantity: int = 0 + self.max_quantity: int = 0 + + self.pdt_time: int = 0 + + self.prev_pcs: Process = prev_pcs + self.last_pcs: Process = last_pcs + self.res_needs: List[Dict[str, any]] = [] + self.workspace: Workspace = workspace + + def set_mode_quantity(self, production_mode: int, min_quantity: int, max_quantity: int): + self.production_mode: int = production_mode + self.min_quantity: int = max_quantity + self.max_quantity: int = min_quantity + + def set_product_time(self, pdt_time: int): + self.pdt_time: int = pdt_time + + def add_res_need(self, rcs_attrs, amount): + self.res_needs.append({ + "rcs_attrs": rcs_attrs, + "amount": amount + }) + + +class Resource: + + def __init__(self, rsc_id: str, rsc_name: str, rsc_type: str, workspace: Workspace): + self.rsc_id: str = rsc_id + self.rsc_name: str = rsc_name + self.rsc_type: str = rsc_type + + self.attr: str = "" + self.basic_attrs: Set = set() + self.workspace: Workspace = workspace + + def set_attr(self, attr: str, basic_attrs: List[str]): + if attr not in basic_attrs: + raise Exception("Attr NOT IN Basic_Attrs") + + self.attr: str = attr + self.basic_attrs: List[str] = basic_attrs diff --git a/runtime.py b/runtime.py new file mode 100644 index 0000000..214729b --- /dev/null +++ b/runtime.py @@ -0,0 +1,33 @@ +import model +from datetime import datetime, timedelta +from typing import List + + +class RuntimeProduct: + + def __init__(self, product, amount): + self.ddl: datetime = datetime.today() + self.product: model.Product = product + self.amount: int = amount + + def set_ddl(self, ddl: datetime): + self.ddl = ddl + pass + + +class ProductLine: + + def __init__(self, product: model.Product): + self.product: product = product + self.runtime_products: List[RuntimeProduct] = [] + + def add_runtime_product(self, runtime_product: RuntimeProduct): + self.runtime_products.append(runtime_product) + + +class RuntimeProcess: + + def __init__(self, runtime_product: RuntimeProduct, process: model.Process): + self.runtime_product = runtime_product + self.process = process + self.start_ddl = self.runtime_product.ddl - timedelta(minutes=process.pdt_time) diff --git a/scheduling.py b/scheduling.py new file mode 100644 index 0000000..53ddade --- /dev/null +++ b/scheduling.py @@ -0,0 +1,14 @@ +import runtime +import model +import csv +from typing import List +from datetime import datetime +import time + + +def read_dataset(): + order_list: List[model.Order] = [] + + +if __name__ == "__main__": + read_dataset() \ No newline at end of file