コード例 #1
0
class CenterController:
    def __init__(self):
        self.__center_model = CenterModel()

    """
    *   @brief Call a model method to get the center of the student
    *   @param id_student which is the id of the student of what we want to know his centre
    *   @pre the student has to be registered in the system
    *   @return the id of the center of the student will be given
    """

    def get_center_by_id_student(self, id_student):
        id_center = self.__center_model.get_center_by_id_student(id_student)
        return id_center

    """
    *   @brief Call a model method for the status of the id of the centre we want
    *   @param id_center which is the id of the centre we want to know his status
    *   @pre the center has to be registered in the system
    *   @return the status of the specific center
    """

    def get_center_status(self, id_center):
        status = self.__center_model.get_center_status(id_center)
        return status

    """
    *   @brief Call a model method to change the status of the centre (connected | disconnected)
    *   @param id_center which is the center of we want to change his state
    *   @param state which is the new state of the centre
    *   @pre the center has to been registered
    *   @post the state of the specific center will be changed
    """

    def set_active(self, id_center, state):
        self.__center_model.set_active(id_center, state)

    """
    *   @brief Consult to BD for the centre in which is the admin of the id given
    *   @param id_admin which is the id of the admin of what we want to know his centre
    *   @pre the admin has to be registered in the system
    *   @return the id of the center of the admin will be given
    """

    def get_center_by_id_admin(self, id_admin):
        data = self.__center_model.get_center_by_id_admin(id_admin)
        return data
コード例 #2
0
class AdminController:
    def __init__(self):
        self.__admin_model = AdminModel()
        self.__center_model = CenterModel()

    """
    *   @brief Adds a new admin to the center that we get with the id.
    *   @param id_admin which is the dni of the admin that will be admin
    *   @param name which is the name of the admin
    *   @param surname which is the surname of the admin
    *   @param lastname which is the lastname of the admin
    *   @param password which is the password of the admin
    *   @param active which is the state of the admin (if can log or not)
    *   @pre an admin has logged successfully
    *   @post a new admin will be added
    """

    def add_admin(self, id_admin, id_user, name, surname, lastname, password, active):
        id_center = self.__center_model.get_center_by_id_admin(id_admin)
        self.__admin_model.add_admin(id_center, id_user, name, surname, lastname, password, active)

    """
    *   @brief Get all the admins of a center
    *   @param id_center which is the id of the center we want to know the admins
    *   @pre an admin has been logged successfully
    *   @return an array with all the admins of the center
    """

    def get_all_admins_by_id_center(self, id_center):
        return self.__admin_model.get_users_by_id_center(id_center)

    """
    *   @brief Set to a specific admin the state given
    *   @param id_admin which is the id of the admin we want to change his state
    *   @param state which is the new state of the admin
    *   @pre the admin has to been registered
    *   @post the admin state will be changed
    """

    def set_connected(self, id_admin, state):
        self.__admin_model.set_connected(id_admin, state)

    """
    *   @brief Consult to the bd to know is the name and password given are registered
    *   @param id which is the id given to try to get logged
    *   @param password which is the password given to try to get logged
    *   @pre the socket connection has to been successful
    *   @return returns if the user is correct and exists
    """

    def could_login(self, id, password):
        return self.__admin_model.could_login(id, password)
コード例 #3
0
 def __init__(self):
     self.__center_model = CenterModel()
コード例 #4
0
 def __init__(self):
     self.__admin_model = AdminModel()
     self.__center_model = CenterModel()
コード例 #5
0
 def __init__(self):
     self.__door_model = DeviceModel()
     self.__center_model = CenterModel()
コード例 #6
0
class DeviceController:
    def __init__(self):
        self.__door_model = DeviceModel()
        self.__center_model = CenterModel()

    """
    *   @brief Call a model method to get all the devices of the centre in which the student is registered
    *   @param id_student which is the student of we want to know the center to give him the devices
    *   @pre the user and the center have to been registered in the system
    *   @return returns all the devices that arent in maintenance
    """

    def get_all_devices(self, id_student):
        datos = self.__door_model.get_all_devices(id_student)
        return datos

    """
    *   @brief Call a model method to get all the devices of the centre
    *   @param id_center which is the center of we want to know their devices
    *   @pre the center has to been registered in the system
    *   @return returns all the devices that arent in maintenance of the centre
    """

    def get_all_devices_by_id_center(self, id_center):
        datos = self.__door_model.get_all_devices_by_center_id(id_center)
        return datos

    """
    *   @brief Call a model method to get the status of a specific device
    *   @param id_device which is the id of the device we want to know his status
    *   @pre a center has to been registered and has devices.
    *   @return returns the status of the specific device
    """

    def device_status(self, id_device):
        return self.__door_model.devices_status(id_device)

    """
    *   @brief Call a model method to set the status of a specific device to open
    *   @param id_device which is the id of the device we want to open
    *   @pre the selected device has to be not in maintenance
    *   @post the status of the device will be changed
    """

    def open_device(self, id_device):
        self.__door_model.open_device(id_device)

    """
    *   @brief Call a model method to set the status of a specific device to close
    *   @param id_device which is the id of the device we want to close
    *   @pre the selected device has to be not in maintenance
    *   @post the status of the device will be changed
    """

    def close_device(self, id_device):
        self.__door_model.close_device(id_device)

    """
    *   @brief Get all the info of a device by his id
    *   @param id_device which is the id of the device we want the info
    *   @pre an admin has logged successfully
    *   @return all the info of the selected device
    """

    def get_device_by_id(self, id_device):
        data = self.__door_model.get_device_by_id(id_device)
        return data

    """
    *   @brief Delete a device by his id
    *   @param id_device which is the id of the device we want to delete
    *   @pre an admin has logged successfully
    *   @post the selected device will be deleted 
    """

    def delete_device_by_id(self, id_device):
        self.__door_model.delete_device_by_id(id_device)

    """
    *   @brief Updates a device of a center.
    *   @param id_device which is the id of the device that will be updated
    *   @param name which is the name that will be set to the device
    *   @param state which is the state that will be set to the device
    *   @param maintenance which is the maintenance state that will be set to the device
    *   @param pin_led which is the pin of the led that will be set to the device
    *   @param pin_button which is the pin of the button that will be set to the device
    *   @param pin_servo which is the pin of the servo that will be set to the device
    *   @pre an admin has logged successfully
    *   @post a new device will be updated
    """

    def add_device(self, id_admin, name, state, maintenance, pin_led, pin_button, pin_servo):
        id_center = self.__center_model.get_center_by_id_admin(id_admin)
        self.__door_model.add_device(id_center, name, state, maintenance, pin_led, pin_button, pin_servo)

    """
    *   @brief Adds a new device to the center that we get with the id.
    *   @param id_center is the center in which the device will be added
    *   @param id_device which is the id of the device that will be added
    *   @param name which is the name that will be set to the device
    *   @param state which is the state that will be set to the device
    *   @param maintenance which is the maintenance state that will be set to the device
    *   @param pin_led which is the pin of the led that will be set to the device
    *   @param pin_button which is the pin of the button that will be set to the device
    *   @param pin_servo which is the pin of the servo that will be set to the device
    *   @pre an admin has logged successfully
    *   @post a new device will be added
    """

    def update_device_by_id(self, id_device, name, state, maintenance, pin_led, pin_button, pin_servo):
        self.__door_model.update_device_by_id(id_device, name, state, maintenance, pin_led, pin_button, pin_servo)

    """
    *   @brief Get all the devices to send them to the center
    *   @param id_center which is the id of the center we want the devices.
    *   @pre a center has logged successfully
    *   @return the necessary info for the center 
    """

    def get_devices_for_center(self, id_center):
        return self.__door_model.get_devices_for_center(id_center)

    """
    *   @brief Call a model method to get all the devices of the centre
    *   @param id_center which is the center of we want to know their devices
    *   @pre the center has to been registered in the system
    *   @return returns all the devices that arent in maintenance of the centre
    """

    def get_all_devices_by_id_center_to_web(self, id_center):
        datos = self.__door_model.get_all_doors_by_id_center_for_web(id_center)
        return datos

    def interaction(self, id_student, id_device, fecha, hora):
        print("Yeyo --> ", id_student, id_device, fecha, hora)
コード例 #7
0
class UserController:
    def __init__(self):
        self.__user_model = UserModel()
        self.__center_model = CenterModel()

    """
    *   @brief Call a model method to consult to the bd to know is the name and password given are registered
    *   @param id_student which is the id given to try to get logged
    *   @param password which is the password given to try to get logged
    *   @pre the socket connection has to been successful
    *   @return returns if the user is correct and exists
    """

    def exist_user(self, name, password):
        data = self.__user_model.exist_user(name, password)
        return data

    """
    *   @brief Call a model method to set to a specific student the state given
    *   @param id_student which is the id of the student we want to change his state
    *   @param state which is the new state of the user
    *   @pre the student has to been registered
    *   @post the student state will be changed
    """

    def set_user_state(self, id_student, state):
        self.__user_model.set_user_state(id_student, state)

    """
    *   @brief Call a model method to consult to db for the students in the same center that are connected
    *   @param id_student which is the id of the student we want to know his centre to know the other students
    *   @pre a center and a student of this center have been registed
    *   @return returns all the students in the same centre of the student given
    """

    def get_users_in_same_centre(self, id_student):
        students_in_same_center = self.__user_model.get_users_in_same_center(
            id_student)
        return students_in_same_center

    """
    *   @brief Get all the users of a center
    *   @param id_center which is the id of the center we want to know the students
    *   @pre an admin has been logged successfully
    *   @return an array with all the students of the center
    """

    def get_all_users_by_id_center(self, id_center):
        return self.__user_model.get_users_by_id_center(id_center)

    """
    *   @brief Get all the info of a user by his id
    *   @param id_user which is the id of the user we want the info
    *   @pre an admin has logged successfully
    *   @return all the info of the selected user
    """

    def get_user_by_id(self, id_user):
        return self.__user_model.get_user_by_id(id_user)

    """
    *   @brief Delete a student by his id
    *   @param id_user which is the id of the student we want to delete
    *   @pre an admin has logged successfully
    *   @post the selected user will be deleted 
    """

    def delete_user_by_id(self, id_user):
        self.__user_model.delete_user_by_id(id_user)

    """
    *   @brief Updates a student of a center.
    *   @param id_user which is the dni of the student that will be updated
    *   @param name which is the name that will be set to the student
    *   @param surname which is the surname that will be set to the student
    *   @param lastname which is the lastname that will be set to the student
    *   @param password which is the password that will be set to the student
    *   @param active which is the state that will be set to the student (if can log or not)
    *   @pre an admin has logged successfully
    *   @post a new student will be updated
    """

    def update_user_by_id(self, id_user, name, surname, lastname, password,
                          active):
        self.__user_model.update_user_by_id(id_user, name, surname, lastname,
                                            password, active)

    """
    *   @brief Adds a new user to the center that we get with the id.
    *   @param id_center is the center in which the user will be added
    *   @param id_admin which is the dni of the admin
    *   @param id_user which is the dni of the student that will be added
    *   @param name which is the name of the student
    *   @param surname which is the surname of the student
    *   @param lastname which is the lastname of the student
    *   @param password which is the password of the student
    *   @param active which is the state of the student (if can log or not)
    *   @pre an admin has logged successfully
    *   @post a new student will be added
    """

    def add_user(self, id_admin, id_user, name, surname, lastname, password,
                 active):
        id_center = self.__center_model.get_center_by_id_admin(id_admin)
        self.__user_model.add_user(id_center, id_admin, id_user, name, surname,
                                   lastname, password, active)