# Path: src/bin/tools.py
# def RunThread(func, args=(), daemon=True, lock=None, wait_lock=False, wait_timeout=0.5):
# 	'''
# 	 @brief Run function in separate thread.
# 
# 	 @param func Function to run.
# 	 @param args Input arguments (single argument: (arg1,) - or multiple: (arg1, arg2))
# 	 @param daemon (True/false) - run as daemon or not.
# 	 @param lock Mutex lock - wait for it to be available before starting thread.
# 	 @param wait_lock - Wait for mutex to be available, or raise exception immideately.
# 	 @param wait_timeout - Time to wait in seconds (if wait_lock==True)
# 
# 	 return t Threading object
# 	'''
# 	t = threading.Thread(target=func, args=args)
# 	t.daemon = daemon
# 	if lock == None:
# 		t.start()
# 	else:
# 		if wait_lock:
# 			timeout = timeit.default_timer()
# 			while True:
# 				if not(lock.locked()):
# 					t.start()
# 					break
# 				elif (timeit.default_timer() - timeout) > wait_timeout:
# 					raise Exception('Runtime error - lock not availble')
# 		else:
# 			if not(lock.locked()):
# 				t.start()
# 			else:
# 				raise Exception('Runtime error - lock not availble')
# 	return t


import threading
from src.bin.tools import RunThread
from Getch import Getch
from getpass import getpass

    def ForceTermination(self):
        '''
         @brief Force termination
        '''
        self.__terminate = True

    def ResetTermination(self):
        '''
         @brief Reset the force termination key
        '''
        self.__terminate = False

    def CheckTerminated(self):
        '''
         @brief Check if user input is terminated

         @return True/False
        '''
        if self.__manual_user_input:
            self.ManualHandleUserInput()
        return self.__terminate

    def StartAutoHandleUserInput(self):
        '''
         @brief Handle auto user input in thread
        '''
        if self.__auto:
            self.__manual_user_input = False
            if not(self.__no_termination):

# Path: src/bin/tools.py
# def RunThread(func, args=(), daemon=True, lock=None, wait_lock=False, wait_timeout=0.5):
# 	'''
# 	 @brief Run function in separate thread.
# 
# 	 @param func Function to run.
# 	 @param args Input arguments (single argument: (arg1,) - or multiple: (arg1, arg2))
# 	 @param daemon (True/false) - run as daemon or not.
# 	 @param lock Mutex lock - wait for it to be available before starting thread.
# 	 @param wait_lock - Wait for mutex to be available, or raise exception immideately.
# 	 @param wait_timeout - Time to wait in seconds (if wait_lock==True)
# 
# 	 return t Threading object
# 	'''
# 	t = threading.Thread(target=func, args=args)
# 	t.daemon = daemon
# 	if lock == None:
# 		t.start()
# 	else:
# 		if wait_lock:
# 			timeout = timeit.default_timer()
# 			while True:
# 				if not(lock.locked()):
# 					t.start()
# 					break
# 				elif (timeit.default_timer() - timeout) > wait_timeout:
# 					raise Exception('Runtime error - lock not availble')
# 		else:
# 			if not(lock.locked()):
# 				t.start()
# 			else:
# 				raise Exception('Runtime error - lock not availble')
# 	return t


# Path: src/bin/UserInput/UserInput.py
import threading
from src.bin.tools import RunThread
from Getch import Getch
from getpass import getpass


    def ForceTermination(self):
        '''
         @brief Force termination
        '''
        self.__terminate = True

    def ResetTermination(self):
        '''
         @brief Reset the force termination key
        '''
        self.__terminate = False

    def CheckTerminated(self):
        '''
         @brief Check if user input is terminated

         @return True/False
        '''
        if self.__manual_user_input:
            self.ManualHandleUserInput()
        return self.__terminate

    def StartAutoHandleUserInput(self):
        '''
         @brief Handle auto user input in thread
        '''
        if self.__auto:
            self.__manual_user_input = False
            if not(self.__no_termination):

                RunThread(self.AutoHandleUserInput)