def __init__(self, car_num, db_path):
        print("Car 객체가 생성되었습니다.")
        self.__car_num = car_num
        print("Car number = " + self.__car_num)

        # SQLite DB 연결
        self.mypmsdb = DBinit(db_path)

        self.__location = ''  # 'B1-A1'
        self.__in_time = ''  # format = yyyy-mm-dd
        self.__out_time = ''  # format = yyyy-mm-dd
        self.__free_hour = 0
        self.__pay_amount = 0
        self.__is_paid = 0
    def __init__(self, db_path):
        print("BlockBarIn 객체가 생성되었습니다.")

        # SQLite DB 연결
        self.mypmsdb = DBinit(db_path)
        self.open = False  #초기 상태 = 차단바 closed
        self.is_rgstrd = False  #초기 상태 = 회원이 아님
        self.is_pssd = False  #초기 상태 = 차량이 아직 안 지나감
        self.paid = False  #초기 상태 = 두번째 방문 차량에 해당됨
    def __init__(self, car_num, db_path):
        print("Car 객체가 생성되었습니다.")
        self.__car_num = car_num
        print("Car number = " + self.__car_num)

        # SQLite DB 연결
        # filename db가 있으면 연결, 없으면 새로 생성
        self.conn = sqlite3.connect(db_path,
                                    detect_types=sqlite3.PARSE_DECLTYPES)
        # Connection 으로부터 Cursor 생성
        self.cur = self.conn.cursor()
        self.mypmsdb = DBinit(db_path)

        self.__location = ''  # 'B1-A1'
        self.__in_time = ''  # format = yyyy-mm-dd
        self.__out_time = ''  # format = yyyy-mm-dd
        self.__free_hour = 0
        self.__pay_amount = 0
        self.__is_paid = 0
    def __init__(self, db_path):
        print("BlockBar 객체가 생성되었습니다.")

        # SQLite DB 연결
        self.mypmsdb = DBinit(db_path)
        self.__open = False  #초기 상태 = 차단바 closed
        self.__is_rgstrd = False  #초기 상태 = 회원이 아님
        self.__is_pssd = False  #초기 상태 = 차량이 아직 안 지나감
        self.__paid = False
        self.__WIDTH = 200  # 입구의 너비. 입구에 차량이 없을 때 200cm
        self.__dist = self.__WIDTH  # 물체와 초음파 센서 사이의 거리
Exemple #5
0
    def __init__(self, spot, db_path):
        print("ParkingSpot 객체가 생성되었습니다.")
        self.__spot = spot  # 'B1-A1'
        print("Parking Spot = " + self.__spot)

        # SQLite DB 연결
        self.mypmsdb = DBinit(db_path)

        self.__car_num = ''  # 'B1-A1'
        self.__status = 0  # Parking_status : 0 == vacant ; 1 == occupied ; 2 == moving_out
        self.__dist = 300  # 천장부터 바닥까지 거리 : 300 cm
        self.__led = 'GREEN'
Exemple #6
0
    def __init__(self, db_path):
        print("ParkingLot 객체가 생성되었습니다.")

        # SQLite DB 연결
        self.mypmsdb = DBinit(db_path)

        #### Parking_spot ####
        # Get Parking_spot list fom PARKINGLOT_LIST
        self.mypmsdb.cur.execute('SELECT Parking_spot FROM PARKINGLOT_LIST')
        pksp_list = []
        for row in self.mypmsdb.cur:
            pksp_list.append(row[0])
            print(row[0])

        self.__pksp_list = [[[
            ParkingSpot(pksp_list[l * 100 + j * 10 + i], db_path)
            for i in range(10)
        ] for j in range(10)] for l in range(3)]
Exemple #7
0
    def __init__(self, spot, db_path):
        #print("ParkingSpot 객체가 생성되었습니다.")
        self.__spot = spot # 'B1-A1'
        print("Parking Spot 객체 생성 : " + self.__spot)
        self.cam = Camera(db_path, self.__spot)

        # SQLite DB 연결
        self.mypmsdb = DBinit(db_path)
        self.mypmsdb.cur.execute("SELECT * FROM PARKINGLOT_LIST WHERE Parking_spot = ?", (self.__spot,))


        # row = ['B1-A1', 1, '12가1234']
        row = list(self.mypmsdb.cur.fetchone())
        print(row)

        self.__car_num = row[2]
        self.__status = row[1] # Parking_status : 0 == vacant ; 1 == occupied ; 2 == moving_out
        self.__HEIGHT = 300 # 천장부터 바닥까지 거리 : 300 cm
        self.__dist = self.__HEIGHT # 천장부터 물체까지의 거리
        self.__led = ''
        self.set_led()
        print(self.__spot, self.__car_num, self.__status, self.__led)
Exemple #8
0
    def __init__(self, db_path):
        # db_path에 대하여 SQLite DB 연결
        self.mypmsdb = DBinit(db_path)
        # 월 0 요일 1 시간 2
        self._criteria = 0
        self._sdate = datetime.datetime.now().strftime("%Y-%m-%d")
        self._edate = datetime.datetime.now().strftime("%Y-%m-%d")
        self._admin_id = 'hufs14'
        self._admin_pw = 'onframe341'

        print('ID 를 입력하세요.')
        my_id = input()
        if(my_id != self._admin_id):
            print('존재하지 않는 ID입니다.')
            return
        else:
            print('비밀번호를 입력하세요.')
            my_pw = input()
            if(my_pw != self._admin_pw):
                print('비밀번호가 틀렸습니다.')
                return


        print("통계 기준을 선택하세요.")
        print("0 : 월별     1 : 요일별     2 : 시간대별")
        criteria = input()
        self.criteria = int(criteria)

        print('통계 시작날짜를 입력하세요. yyyy-mm-dd')
        s_date = input()
        self.sdate = s_date
        print('통계 종료날짜를 입력하세요. yyyy-mm-dd')
        e_date = input()
        self.edate = e_date

        # 통계 그래프 보여주기
        self.get_stats(int(criteria))
from Camera import Camera
from Pms_db import DBinit
from Stats import Stats
from Car import Car
import time
import random
from datetime import datetime

if __name__ == '__main__':
    random.seed(datetime.now())
    db_path = 'pms_db_fin_2.sqlite'
    in_cam = Camera(db_path, 'entrance')
    out_cam = Camera(db_path, 'exit')
    bar_in = BlockBar(db_path)
    bar_out = BlockBar(db_path)
    mypmsdb = DBinit(db_path)

    #mypmsdb.cur.execute("UPDATE PARKINGLOT_LIST SET Parking_status = 0, Customer_car_num = ''")
    #mypmsdb.conn.commit()
    #mypmsdb.print_table('PARKINGLOT_LIST')

    print("실행할 프로세스를 선택하세요.")
    print("1. 입차   2. 주차   3. 출차   4. 키오스크   5. [관리자]통계")
    a = input()
    print(a," 번을 선택하셨습니다.")


    # 입차
    if(a == '1'):
        # for test : 등록되지 않은 회원
        car_num = in_cam.recog_carnum(0,0)
class Car:
    '''
    car_num : str
    location : str
    in_time : str
    out_time : int
    free_hour : integer
    pay_amount : integer
    is_paid : integer
    mypmsdb = DBinit() instance

    ----------------------
    get+위 모든 data fields
    set+위 모든 data fields
    park()
    move()
    set_pay_amount(self) # 무료 주차 시간, 주차요금 구해 저장하기
    park_pay (self) # 주차요금 결제
    park_pay_fail(self) # test 를 위한 함수 : 한도초과일 경우
    insert_ppay(self) # db의 park_pay 테이블에 삽입
    '''
    def __init__(self, car_num, db_path):
        print("Car 객체가 생성되었습니다.")
        self.__car_num = car_num
        print("Car number = " + self.__car_num)

        # SQLite DB 연결
        # filename db가 있으면 연결, 없으면 새로 생성
        self.conn = sqlite3.connect(db_path,
                                    detect_types=sqlite3.PARSE_DECLTYPES)
        # Connection 으로부터 Cursor 생성
        self.cur = self.conn.cursor()
        self.mypmsdb = DBinit(db_path)

        self.__location = ''  # 'B1-A1'
        self.__in_time = ''  # format = yyyy-mm-dd
        self.__out_time = ''  # format = yyyy-mm-dd
        self.__free_hour = 0
        self.__pay_amount = 0
        self.__is_paid = 0

    @property
    def car_num(self):
        return self.__car_num

    @property
    def location(self):
        return self.__location

    @property
    def in_time(self):
        return self.__in_time

    @property
    def out_time(self):
        return self.__out_time

    @property
    def free_hour(self):
        return self.__free_hour

    @property
    def pay_amount(self):
        return self.__pay_amount

    @property
    def is_paid(self):
        return self.__is_paid

    # park()   칸에 주차하기
    def park(self, parking_lot):
        now = time.localtime()
        self.__in_time = "%04d-%02d-%02d %02d:%02d:%02d" % (
            now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour - 2, now.tm_min,
            now.tm_sec)
        self.__location = parking_lot

        print("주차 시작시각 : " + self.__in_time)
        print("주차 칸 : " + self.__location)

    # move()   칸에서 차 빼기
    def move(self):
        now = time.localtime()
        self.__out_time = "%04d-%02d-%02d %02d:%02d:%02d" % (
            now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min,
            now.tm_sec)

        print("주차 종료시각 : " + self.__out_time)
        print("주차 칸 : " + self.__location)

    # set_pay_amount()   무료 주차 시간, 주차요금 구해 저장하기
    def set_pay_amount(self):
        # Get parking minutes between park_in and park_out.
        # That is, "how long had this car parked?"
        pmin = self.mypmsdb.diff_min(self.__in_time, self.__out_time,
                                     '%Y-%m-%d %H:%M:%S')
        print('pmin', pmin)
        #### Park_free_hour ####
        # Get Shopping_pay_amount from SHOPPING_PAY
        # 오늘 입차한 손님의 쇼핑 구매 금액 찾기
        self.mypmsdb.cur.execute(
            "SELECT Shopping_pay_amount FROM SHOPPING_PAY WHERE Customer_car_num = ? AND Shopping_pay_time = ?",
            (
                self.car_num,
                self.__in_time.split(' ')[0],
            ))
        row = self.mypmsdb.cur.fetchone()
        if (row is not None):
            spay = row[0]
        else:
            spay = 0
        print(spay)

        # Get DISCOUNT table
        self.mypmsdb.cur.execute('SELECT * FROM DISCOUNT')
        discount_list = []
        for row in self.mypmsdb.cur:
            discount_list.append(list(row))
        print(discount_list)

        # Calculate Park_free_hour
        self.__free_hour = self.mypmsdb.cal_freeh(spay, discount_list)
        print('park free hour')
        print(self.__free_hour)

        #### Park_pay_amount ####
        # Get PRICE table
        self.mypmsdb.cur.execute('SELECT * FROM PRICE')
        for row in self.mypmsdb.cur:
            price_list = list(row)

        # Calculate Park_pay_amount
        self.__pay_amount = self.mypmsdb.cal_price(pmin, price_list,
                                                   self.__free_hour)
        print('park pay amount')
        print(self.__pay_amount)

    # 주차요금 결제
    def park_pay(self):
        # 결제 모듈이 들어가야 함.
        # 결제 시스템과의 통합 필요.
        # 고객의 카드 정보 제공하면, 한도초과가 아니면 결제 정상적으로 완료하고, 한도초과이면 결제 실패
        self.__is_paid = 1  # true
        print('결제가 완료되었습니다.')

    # test 를 위한 함수 : 한도초과일 경우
    def park_pay_fail(self):
        # 결제 모듈이 들어가야 함.
        self.__is_paid = 0  # false
        print('결제에 실패하였습니다. 미납요금은 추후 요청됩니다.')

    # db의 park_pay 테이블에 삽입
    def insert_ppay(self):
        self.mypmsdb.cur.execute(
            """INSERT INTO PARK_PAY(Customer_car_num, Parking_spot, Park_in, Park_out,
                         Park_free_hour, Park_pay_amount, Park_is_paid) VALUES('"""
            + self.car_num + "', '" + self.location + "', '" + self.in_time +
            "', '" + self.out_time + "', " + str(self.free_hour) + ", " +
            str(self.pay_amount) + ", " + str(self.is_paid) + ")")

        # commit 을 해줘야 sqlite 에 반영이 됨
        self.mypmsdb.conn.commit()

        print(self.__in_time.split(' ')[0])
        self.mypmsdb.cur.execute(
            "SELECT * FROM PARK_PAY WHERE Customer_car_num = ? AND Park_in = ?",
            (
                self.car_num,
                self.in_time,
            ))
        print('아래 튜플이 PARK_PAY 테이블에 INSERT 되었습니다.')
        print(self.mypmsdb.cur.fetchone())
class Car:
    '''
    car_num : str
    location : str
    in_time : str
    out_time : int
    free_hour : integer
    pay_amount : integer
    is_paid : integer
    ----------------------
    park(self, parking_lot) # 칸에 주차하기
    move(self) # 칸에서 차 빼기
    set_pay_amount(self) # 무료 주차 시간, 주차요금 구해 저장하기
    park_pay (self, car_num, successed) # 주차요금 결제
    insert_ppay(self) # db의 park_pay 테이블에 삽입
    '''
    def __init__(self, car_num, db_path):
        print("Car 객체가 생성되었습니다.")
        self.__car_num = car_num
        print("Car number = " + self.__car_num)

        # SQLite DB 연결
        self.mypmsdb = DBinit(db_path)

        self.__location = ''  # 'B1-A1'
        self.__in_time = ''  # format = yyyy-mm-dd
        self.__out_time = ''  # format = yyyy-mm-dd
        self.__free_hour = 0
        self.__pay_amount = 0
        self.__is_paid = 0

    @property
    def car_num(self):
        return self.__car_num

    @property
    def location(self):
        return self.__location

    @property
    def in_time(self):
        return self.__in_time

    @property
    def out_time(self):
        return self.__out_time

    @property
    def free_hour(self):
        return self.__free_hour

    @property
    def pay_amount(self):
        return self.__pay_amount

    @property
    def is_paid(self):
        return self.__is_paid

    # park()   칸에 주차하기
    def park(self, parking_lot):
        now = time.localtime()
        self.__in_time = "%04d-%02d-%02d %02d:%02d:%02d" % (
            now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min,
            now.tm_sec)
        self.__location = parking_lot

        print("주차 시작시각 : " + self.__in_time)
        print("주차 칸 : " + self.__location)

        self.mypmsdb.cur.execute(
            """INSERT INTO PARK_PAY(Customer_car_num, Parking_spot, Park_in) VALUES('"""
            + self.car_num + "', '" + self.location + "', '" + self.in_time +
            "')")

        # commit 을 해줘야 sqlite 에 반영이 됨
        self.mypmsdb.conn.commit()

        self.mypmsdb.cur.execute(
            "SELECT * FROM PARK_PAY WHERE Customer_car_num = ? AND Park_in = ?",
            (
                self.car_num,
                self.in_time,
            ))
        print('아래 튜플이 PARK_PAY 테이블에 INSERT 되었습니다.')
        print(self.mypmsdb.cur.fetchone())

    # move()   칸에서 차 빼기
    def move(self):
        self.set_spay(67500)  # 67500원 결제

        now = time.localtime()
        self.__out_time = "%04d-%02d-%02d %02d:%02d:%02d" % (
            now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour + 2, now.tm_min,
            now.tm_sec)

        self.mypmsdb.cur.execute(
            "SELECT * FROM PARK_PAY WHERE Customer_car_num = ? AND Park_in like ?",
            (
                self.car_num,
                self.__out_time[:10] + '%',
            ))
        row = self.mypmsdb.cur.fetchone()
        if (row is not None):
            row = list(row)
        print(row)
        self.__location = row[2]
        self.__in_time = row[3]

        print("주차 종료시각 : " + self.__out_time)
        print("주차 칸 : " + self.__location)

        self.mypmsdb.cur.execute(
            """UPDATE PARK_PAY SET Park_out = ?
                WHERE Customer_car_num = ? AND Park_in like ?""", (
                self.__out_time,
                self.__car_num,
                self.__out_time[:10] + '%',
            ))
        # commit 을 해줘야 sqlite 에 반영이 됨
        self.mypmsdb.conn.commit()

        # 주차요금 UPDATE
        self.set_pay_amount()

        # 확인
        self.mypmsdb.cur.execute(
            "SELECT * FROM PARK_PAY WHERE Customer_car_num = ? AND Park_out = ?",
            (
                self.car_num,
                self.__out_time,
            ))
        print('아래 튜플이 PARK_PAY 테이블에 UPDATE 되었습니다.')
        print(self.mypmsdb.cur.fetchone())

    def set_spay(self, spay_amount):
        now = time.localtime()
        spay_time = "%04d-%02d-%02d %02d:%02d:%02d" % (
            now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour + 2,
            now.tm_min - 15, now.tm_sec)

        self.mypmsdb.cur.execute("""INSERT INTO
        SHOPPING_PAY(Customer_car_num, Shopping_pay_amount, Shopping_pay_time)
        VALUES('""" + self.car_num + "'," + str(spay_amount) + ", '" +
                                 spay_time + "')")
        self.mypmsdb.conn.commit()

        # 확인
        self.mypmsdb.cur.execute(
            "SELECT * FROM SHOPPING_PAY WHERE Customer_car_num = ? AND Shopping_pay_time = ?",
            (
                self.car_num,
                spay_time,
            ))
        print('아래 튜플이 SHOPPING_PAY 테이블에 INSERT 되었습니다.')
        print(self.mypmsdb.cur.fetchone())

    # set_pay_amount()   무료 주차 시간, 주차요금 구해 저장하기
    def set_pay_amount(self):
        # Get parking minutes between park_in and park_out.
        # That is, "how long had this car parked?"
        pmin = self.mypmsdb.diff_min(self.__in_time, self.__out_time,
                                     '%Y-%m-%d %H:%M:%S')
        print('parked minutes : ', pmin)
        #### Park_free_hour ####
        # Get Shopping_pay_amount from SHOPPING_PAY
        # 오늘 입차한 손님의 쇼핑 구매 금액 찾기
        self.mypmsdb.cur.execute(
            "SELECT Shopping_pay_amount FROM SHOPPING_PAY WHERE Customer_car_num = ? AND Shopping_pay_time like ?",
            (
                self.__car_num,
                self.__out_time[:10] + "%",
            ))
        row = self.mypmsdb.cur.fetchone()
        if (row is not None):
            spay = row[0]
        else:
            spay = 0
        print("Shopping pay amount : ", spay)

        # Get DISCOUNT table
        self.mypmsdb.cur.execute('SELECT * FROM DISCOUNT')
        discount_list = []
        for row in self.mypmsdb.cur:
            discount_list.append(list(row))
        print("DISCOUNT Table\n", discount_list)

        # Calculate Park_free_hour
        self.__free_hour = self.mypmsdb.cal_freeh(spay, discount_list)
        print('park free hour : ', self.__free_hour)

        #### Park_pay_amount ####
        # Get PRICE table
        self.mypmsdb.cur.execute('SELECT * FROM PRICE')
        for row in self.mypmsdb.cur:
            price_list = list(row)

        # Calculate Park_pay_amount
        self.__pay_amount = self.mypmsdb.cal_price(pmin, price_list,
                                                   self.__free_hour)
        print('park pay amount : ', self.__pay_amount)

        # UPDATE Table
        self.mypmsdb.cur.execute(
            """UPDATE PARK_PAY SET Park_pay_amount = ?, Park_free_hour = ?
                WHERE Customer_car_num = ? AND Park_in like ?""", (
                self.__pay_amount,
                self.__free_hour,
                self.__car_num,
                self.__out_time[:10] + '%',
            ))
        # commit 을 해줘야 sqlite 에 반영이 됨
        self.mypmsdb.conn.commit()

    # 주차요금 결제
    def park_pay(self, car_num, successed):
        # 결제 모듈이 들어가야 함.
        # 결제 시스템과의 통합 필요.
        # 고객의 카드 정보 제공하면, 한도초과가 아니면 결제 정상적으로 완료하고, 한도초과이면 결제 실패
        now = time.localtime()
        now_time = "%04d-%02d-%02d %02d:%02d:%02d" % (now.tm_year, now.tm_mon,
                                                      now.tm_mday, now.tm_hour,
                                                      now.tm_min, now.tm_sec)

        if (successed == True):
            self.__is_paid = 1  # True

        # for test : 한도초과일 경우
        elif (successed == False):
            self.__is_paid = 0  # False

        # UPDATE Table
        self.mypmsdb.cur.execute(
            """UPDATE PARK_PAY SET Park_is_paid = ?
                WHERE Customer_car_num = ? AND Park_out like ?""", (
                self.__is_paid,
                self.__car_num,
                now_time[:10] + '%',
            ))
        # commit 을 해줘야 sqlite 에 반영이 됨
        self.mypmsdb.conn.commit()
        if (successed == True):
            print('결제가 완료되었습니다.')
        elif (successed == False):
            print('결제에 실패하였습니다. 미납요금은 추후 청구됩니다.')

        # 확인
        self.mypmsdb.cur.execute(
            "SELECT * FROM PARK_PAY WHERE Customer_car_num = ? AND Park_out like ?",
            (
                self.car_num,
                now_time[:10] + '%',
            ))
        print('아래 튜플이 PARK_PAY 테이블에 UPDATE 되었습니다.')
        print(self.mypmsdb.cur.fetchone())

    # db의 park_pay 테이블에 삽입
    def insert_ppay(self):
        self.mypmsdb.cur.execute(
            """INSERT INTO PARK_PAY(Customer_car_num, Parking_spot, Park_in, Park_out,
                         Park_free_hour, Park_pay_amount, Park_is_paid) VALUES('"""
            + self.car_num + "', '" + self.location + "', '" + self.in_time +
            "', '" + self.out_time + "', " + str(self.free_hour) + ", " +
            str(self.pay_amount) + ", " + str(self.is_paid) + ")")

        # commit 을 해줘야 sqlite 에 반영이 됨
        self.mypmsdb.conn.commit()

        print(self.__in_time.split(' ')[0])
        self.mypmsdb.cur.execute(
            "SELECT * FROM PARK_PAY WHERE Customer_car_num = ? AND Park_in = ?",
            (
                self.car_num,
                self.in_time,
            ))
        print('아래 튜플이 PARK_PAY 테이블에 INSERT 되었습니다.')
        print(self.mypmsdb.cur.fetchone())
Exemple #12
0
 def __init__(self, db_path):
     self._staff_tel = '010-1234-2173'
     # SQLite DB 연결
     self.mypmsdb = DBinit(db_path)
Exemple #13
0
 def __init__(self, db_path):
     print("Camera 객체가 생성되었습니다.")
     # SQLite DB 연결
     self.mypmsdb = DBinit(db_path)
 def __init__(self, db_path, cam_id):
     #print(cam_id, " : Camera 객체가 생성되었습니다.")
     # Camera ID 설정
     self.__cam_id = cam_id
     # SQLite DB 연결
     self.mypmsdb = DBinit(db_path)