Advertisement
Guest User

Untitled

a guest
Nov 7th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.79 KB | None | 0 0
  1. import sys
  2. import os
  3. import threading
  4. import time
  5. import OpenOPC
  6.  
  7.  
  8.  
  9. #import for library
  10. from lackey import *
  11. from Tkinter import *
  12.  
  13.  
  14.  
  15. #Variable
  16.  
  17. firstBarcode = "112345678"
  18. secondcode = "12345678"
  19. #
  20. #OPC Control
  21. #
  22. opc = OpenOPC.client()
  23. #check all avalible OPC server
  24. opcservers= opc.servers()
  25. print opcservers
  26. #check all avalible tag for Kepware OPC server
  27. opc.list()
  28. # open connection to Server
  29. opc.connect('Kepware.KEPServerEX.V6')
  30. #read value from server
  31. print opc['Simulation Examples.Test.RR01']
  32. opc.close()
  33.  
  34. #
  35. # Watch Dog
  36. class WatchDog(object):
  37.     """ Watch dog example class
  38.    The run() method will be started and it will run in the background
  39.    until the application exits.
  40.    """
  41.  
  42.     def __init__(self, interval=1):
  43.         """ Constructor
  44.        :type interval: int
  45.        :param interval: Check interval, in seconds
  46.        :   time.sleep(self.interval)
  47.        """
  48.         self.interval = interval
  49.  
  50.         thread = threading.Thread(target=self.run, args=())
  51.         thread.daemon = True                            # Daemonize thread
  52.         thread.start()                                  # Start the execution
  53.  
  54.     def run(self):
  55.         #  Method that runs forever
  56.         while True:
  57.              if exists(Pattern("images/logo.png").similar(0.65)):
  58.               print ("Logo is oK")
  59.               opc.connect('Kepware.KEPServerEX.V6')
  60.               print opc['Simulation Examples.Test.RR01']
  61.               opc.close()
  62.               wait (2)
  63.              else:
  64.               print ("EP is Offline")
  65.               wait(3)
  66.              
  67.            
  68. # Functions
  69. #
  70. # Main rutine
  71. def main_loop():
  72.  while exists("images/logo.png", 10):
  73.    watch_dog = 0
  74.    click(Pattern("images/product.png").similar(0.95))
  75.    click(Pattern("images/Vrijgeven.png").similar(0.95))
  76.    watch_dog = watch_dog + 1
  77.    print watch_dog
  78.    click("images/Print.png")
  79.    click(Pattern("images/yellow_input.png").exact())
  80.    type(firstBarcode)
  81.    ask_loop()
  82. # end main rutine
  83. # Exit rutine
  84.  
  85. def exit_program():
  86.  exitmsges = ("Ariana","Thank you for use.")
  87.  print exitmsges
  88.  wait(3)
  89.  exit
  90. #end  Exit rutine
  91. # start window rutine
  92. def ask_loop():
  93.   startmsges = tkMessageBox.askyesno("Ariana","Do you want to start?")
  94.   print startmsges
  95.   answer = startmsges
  96.   return answer
  97. #end start windows rutine
  98. # OPC server status check
  99. def opc_status():
  100.     print opc.list()
  101.     print opc.info()
  102.  
  103. #
  104. #Program start
  105. # Run Watch Dog and OPC communication on Background
  106. CheckLogo = WatchDog()
  107.  
  108.  
  109. # HERE START
  110.  
  111. startmsges = ask_loop()
  112.  
  113.  
  114. #Main Loop
  115. #Start Message
  116.  
  117. # If you want start or continue then ...
  118. if startmsges == True:
  119.  
  120.  print "Start"  
  121.  main_loop()
  122.  
  123. # If you want finish  
  124. if startmsges == False:
  125.  exit_program()
  126.        
  127. #GUI Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement