Example #1
0
    def run(self):
        print("Main Loop Started")
        while True:
            startTime = time.time()

            MainLoop.tickCounter +=1
            print(MainLoop.tickCounter)

            for x in devices:
                if devices[x].requestedStatus != 0 :
                    if devices[x].requestedStatus==2 :
                        devices[x].status=2
                        devices[x].run()
                    if devices[x].requestedStatus==3 :
                        if devices[x].status==2:
                            devices[x].status=3
                            devices[x].stop()
                        if devices[x].status==4:
                            devices[x].status=3
                            devices[x].carryOnTime=0
                    if devices[x].requestedStatus==4 :
                        devices[x].status=4
                        devices[x].carryOn()
                    devices[x].requestedStatus = 0

            for x in recipes:
                recipes[x].run()

            # Start Compute Time
            endTime = time.time()
            remainingTime = endTime - startTime
            if Singleton.getInstance().SysTick - remainingTime >0 :
                time.sleep(Singleton.getInstance().SysTick - remainingTime)
Example #2
0
def main():
    print('Start.')
    obj1 = Singleton()
    obj2 = Singleton()

    if (obj1 == obj2):
        print('obj1 and obj2 are the same instance')

    else:
        print('obj1 and obj2 are not the same instance')

    print('End.')
Example #3
0
 def __init__(self, srvName, srvDesc, defCfgFilePath):
     Singleton.__init__(self)
     self.workDir = None
     self.cfgFilePath = None
     # used by relativePath
     self.workDir = self.workDir or os.getcwd()
     self.appDir = os.path.dirname(sys.argv[0])
     self.action = self._parseArgs()  # what to do
     pidFilePath = '%s.pid' % self.relativePath(self.workDir, srvName)
     Daemon.__init__(self, pidFilePath, srvDesc)
     self.cfgFilePath = self.cfgFilePath or self.relativePath(
         self.appDir, defCfgFilePath)
     self.daemonMode = False
     self.signalMutex = threading.Lock()  # signal processing flag
Example #4
0
    def demo(self):
        print("Checking singleton class...")
        s1 = Singleton.getInstance()
        s2 = Singleton.getInstance()
        if (s1 == s2):
            print("same ")
        else:
            print("not same")

        print("Checking SingletonThreadSafe...")
        s3 = SingletonThreadSafe.getInstance()
        s4 = SingletonThreadSafe.getInstance()
        if (s3 == s4):
            print("same ")
        else:
            print("not same")
class RunCode(object):

    _attribute_sample = "attibute sample"

    def __init__(self):
        self._singleton_one = Singleton()
        self._singleton_two = Singleton()
        self.__compare()

    def __compare(self):
        print "same id" if id(self._singleton_one) == id(self._singleton_two) else "different ids"
        self.__setSingletonAttribute()

    def __setSingletonAttribute(self):
        self._singleton_one.setAttribute(self._attribute_sample)
        print "self._singleton_one._some_attribute: %s" % self._singleton_one._some_attribute
        print "self._singleton_two._some_attribute: %s" % self._singleton_two._some_attribute
    def sort_column_checkbox_table_widget_stock_screener(column):
        """
        Sorted column with checkbox, ascending = Unchecked to Checked ; descending = Checked to Unchecked
        :param column: column of header cell clicked
        :type column: int
        :return: None
        """
        table_widget = ui.tableWidget_stockScreener

        # When a click is made on a column's name, a sorting is done. We are changing the indicator in MainWindow
        # accordingly. The ValueTableItems that we are using use that indicator to adjust their comparison's algorithms.
        if table_widget.horizontalHeader().sortIndicatorOrder() == 0:
            Singleton.set_order(Singleton(), True)
        else:
            Singleton.set_order(Singleton(), False)

        if column == table_widget.columnCount() - 1:
            HelperFunctionQt.sorted_column_checkbox_table_widget(table_widget)
Example #7
0
from Singleton import Singleton
from PricingRule import PricingRule
from Checkout import Checkout

if __name__ == '__main__':
    singleton = Singleton.get_instance()
    co = Checkout(PricingRule())
    co.scan(singleton.productManager.get_product('mbp'))
    co.scan(singleton.productManager.get_product('vga'))
    co.scan(singleton.productManager.get_product('vga'))
    print(co.total())
Example #8
0
os.chdir(os.path.dirname(os.path.abspath(__file__)))

from constants import *

try:
    PYPROPS_CORELIBPATH
    sys.path.append(PYPROPS_CORELIBPATH)
except NameError:
    pass

from PiRelayApp import PiRelayApp
from Singleton import Singleton, SingletonException

me = None
try:
    me = Singleton()
except SingletonException:
    sys.exit(-1)
except BaseException as e:
    print(e)

if USE_GPIO and os.path.isfile('/opt/vc/include/bcm_host.h'):
    import RPi.GPIO as GPIO
    GPIO.setmode(GPIO.BCM)
    if GPIO_CLEANUP:
        # GPIO.cleanup() sets any GPIO you have used within RPi.GPIO to INPUT mode.
        # If that behaviour is desirable call the method before exiting your script.
        GPIO.cleanup()
    else:
        GPIO.setwarnings(False)
Example #9
0
 def __init__(self):
     Singleton.__init__(self)
     self.__options = {}
 def __init__(self):
     Singleton.__init__(self)
     self.Settings = ConfigParser()
     self.Settings.optionxform = str
Example #11
0
from Singleton import Singleton

Class1 = Singleton('Hello Hady')
Class2 = Singleton('Hello Hady 2')

print(Class1 is Class2)
Example #12
0
__author__ = 'yokoi-h'

from Singleton import Singleton
from Singleton2 import INSTANCE

if __name__ == "__main__":
    ins1 = Singleton.getInstance()
    ins2 = Singleton.getInstance()
    print ins1.name
    print ins2.name
    if ins1 is ins2:
        print "same"
    else:
        print "different"

    ins3 = Singleton("hoge")
    if ins1 is ins3:
        print "same"
    else:
        print "different"

    ins4 = INSTANCE
    ins5 = INSTANCE
    print ins4.name
    print ins5.name
    if ins4 is ins5:
        print "same"
    else:
        print "different"
Example #13
0
 def __init__(self):
     Singleton.__init__(self)
     self.__options = {}
Example #14
0
def main():
    a = Singleton()
    b = Singleton()

    if (a == b):
        print("같다")
Example #15
0
from Singleton import Singleton


first_singleton = Singleton()
first_singleton.talk()
first_singleton.name()

second_singleton = Singleton()
second_singleton.talk()
second_singleton.name()
Example #16
0
 def __init__(self):
     Singleton.__init__(self)
Example #17
0
from Singleton import Singleton

if __name__ == "__main__":
    
    singleton = Singleton()
    singletonTwo = Singleton()

    singleton.setNumber(5)

    print("Singleton:")
    print("Number: ", singleton.getNumber())


    print("Singleton Two:")
    print("Number: ", singletonTwo.getNumber())

    singleton.setNumber(99)

    print("Singleton:")
    print("Number: ", singleton.getNumber())


    print("Singleton Two:")
    print("Number: ", singletonTwo.getNumber())

    print("Singleton:")
    print(singleton)

    print("Singleton Two:")
    print(singletonTwo)
Example #18
0
 def __init__(self):
     Singleton.__init__(self)
 def __init__(self):
     self._singleton_one = Singleton()
     self._singleton_two = Singleton()
     self.__compare()
Example #20
0
if __name__ == "__main__":
    from Singleton import Singleton
else:
    from .Singleton import Singleton


class ConcreteClass(Singleton):
    pass


#print(Singleton())
#print(ConcreteClass())

print(ConcreteClass())
print(Singleton())