Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- import threading
- import time
- import OpenOPC
- #import for library
- from lackey import *
- from Tkinter import *
- #Variable
- firstBarcode = "112345678"
- secondcode = "12345678"
- #
- #OPC Control
- #
- opc = OpenOPC.client()
- #check all avalible OPC server
- opcservers= opc.servers()
- print opcservers
- #check all avalible tag for Kepware OPC server
- opc.list()
- # open connection to Server
- opc.connect('Kepware.KEPServerEX.V6')
- #read value from server
- print opc['Simulation Examples.Test.RR01']
- opc.close()
- #
- # Watch Dog
- class WatchDog(object):
- """ Watch dog example class
- The run() method will be started and it will run in the background
- until the application exits.
- """
- def __init__(self, interval=1):
- """ Constructor
- :type interval: int
- :param interval: Check interval, in seconds
- : time.sleep(self.interval)
- """
- self.interval = interval
- thread = threading.Thread(target=self.run, args=())
- thread.daemon = True # Daemonize thread
- thread.start() # Start the execution
- def run(self):
- # Method that runs forever
- while True:
- if exists(Pattern("images/logo.png").similar(0.65)):
- print ("Logo is oK")
- opc.connect('Kepware.KEPServerEX.V6')
- print opc['Simulation Examples.Test.RR01']
- opc.close()
- wait (2)
- else:
- print ("EP is Offline")
- wait(3)
- # Functions
- #
- # Main rutine
- def main_loop():
- while exists("images/logo.png", 10):
- watch_dog = 0
- click(Pattern("images/product.png").similar(0.95))
- click(Pattern("images/Vrijgeven.png").similar(0.95))
- watch_dog = watch_dog + 1
- print watch_dog
- click("images/Print.png")
- click(Pattern("images/yellow_input.png").exact())
- type(firstBarcode)
- ask_loop()
- # end main rutine
- # Exit rutine
- def exit_program():
- exitmsges = ("Ariana","Thank you for use.")
- print exitmsges
- wait(3)
- exit
- #end Exit rutine
- # start window rutine
- def ask_loop():
- startmsges = tkMessageBox.askyesno("Ariana","Do you want to start?")
- print startmsges
- answer = startmsges
- return answer
- #end start windows rutine
- # OPC server status check
- def opc_status():
- print opc.list()
- print opc.info()
- #
- #Program start
- # Run Watch Dog and OPC communication on Background
- CheckLogo = WatchDog()
- # HERE START
- startmsges = ask_loop()
- #Main Loop
- #Start Message
- # If you want start or continue then ...
- if startmsges == True:
- print "Start"
- main_loop()
- # If you want finish
- if startmsges == False:
- exit_program()
- #GUI Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement