remove configApp
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,15 +0,0 @@
|
||||
from kivy.app import App
|
||||
from kivy.uix.widget import Widget
|
||||
|
||||
|
||||
class PongGame(Widget):
|
||||
pass
|
||||
|
||||
|
||||
class PongApp(App):
|
||||
def build(self):
|
||||
return PongGame()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
PongApp().run()
|
||||
Binary file not shown.
@@ -1,65 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
ZetCode PyQt5 tutorial
|
||||
|
||||
This program creates a skeleton of
|
||||
a classic GUI application with a menubar,
|
||||
toolbar, statusbar, and a central widget.
|
||||
|
||||
Author: Jan Bodnar
|
||||
Website: zetcode.com
|
||||
Last edited: August 2017
|
||||
"""
|
||||
|
||||
import sys
|
||||
import time
|
||||
from PyQt5.QtWidgets import QWidget, QTextEdit, QAction, QApplication, QGridLayout, QLabel
|
||||
from PyQt5.QtGui import QIcon
|
||||
from plc import read_tag
|
||||
|
||||
PLC_IP_ADDRESS = '192.168.1.12'
|
||||
PLC_TYPE = 'Micro800'
|
||||
|
||||
class Example(QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
grid = QGridLayout()
|
||||
self.setLayout(grid)
|
||||
|
||||
for i in range(1,11):
|
||||
for j in range(1,5):
|
||||
grid.addWidget(QLabel('Pond {} Height'.format(j), self), *(0, 2 * (j - 1)))
|
||||
grid.addWidget(QLabel('Pond {} Volume'.format(j), self), *(0, 2 * (j - 1) + 1))
|
||||
lbl_height_pos = (i, 2 * (j - 1))
|
||||
lbl_volume_pos = (i, 2 * (j - 1) + 1)
|
||||
print("{}/40".format(j + (i-1) * 4))
|
||||
# grid.addWidget(QLabel("pond{}CalibrationHeight[{}]".format(j, i), self), *lbl_height_pos)
|
||||
# grid.addWidget(QLabel("pond{}CalibrationVolume[{}]".format(j, i), self), *lbl_volume_pos)
|
||||
|
||||
tag_val_height = read_tag(PLC_IP_ADDRESS, "pond{}CalibrationHeight[{}]".format(j, i), plc_type=PLC_TYPE)
|
||||
if tag_val_height:
|
||||
lbl_height = QLabel('{}'.format(tag_val_height[0]), self)
|
||||
grid.addWidget(lbl_height, *lbl_height_pos)
|
||||
time.sleep(2)
|
||||
tag_val_volume = read_tag(PLC_IP_ADDRESS, "pond{}CalibrationVolume[{}]".format(j, i), plc_type=PLC_TYPE)
|
||||
if tag_val_volume:
|
||||
lbl_volume = QLabel('{}'.format(tag_val_volume[0]), self)
|
||||
grid.addWidget(lbl_volume, *lbl_volume_pos)
|
||||
time.sleep(2)
|
||||
|
||||
self.setGeometry(300, 300, 800, 800)
|
||||
self.setWindowTitle('Main window')
|
||||
self.show()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
ex = Example()
|
||||
sys.exit(app.exec_())
|
||||
@@ -1,54 +0,0 @@
|
||||
"""PLC data."""
|
||||
import time
|
||||
from pycomm.ab_comm.clx import Driver as ClxDriver
|
||||
from pycomm.cip.cip_base import CommError, DataError
|
||||
|
||||
TAG_DATAERROR_SLEEPTIME = 5
|
||||
|
||||
def read_tag(addr, tag, plc_type="CLX"):
|
||||
"""Read a tag from the PLC."""
|
||||
direct = plc_type == "Micro800"
|
||||
addr = str(addr)
|
||||
tag = str(tag)
|
||||
c = ClxDriver()
|
||||
try:
|
||||
if c.open(addr, direct_connection=direct):
|
||||
try:
|
||||
v = c.read_tag(tag)
|
||||
return v
|
||||
except DataError as e:
|
||||
c.close()
|
||||
time.sleep(TAG_DATAERROR_SLEEPTIME)
|
||||
print("Data Error during readTag({}, {}, plc_type='{}'): {}".format(addr, tag, plc_type, e))
|
||||
else:
|
||||
raise DataError("no data")
|
||||
|
||||
except CommError:
|
||||
# err = c.get_status()
|
||||
c.close()
|
||||
print("Could not connect during readTag({}, {})".format(addr, tag))
|
||||
# print err
|
||||
except AttributeError as e:
|
||||
c.close()
|
||||
print("AttributeError during readTag({}, {}): \n{}".format(addr, tag, e))
|
||||
c.close()
|
||||
|
||||
def write_tag(addr, tag, val, plc_type="CLX"):
|
||||
"""Write a tag value to the PLC."""
|
||||
direct = plc_type == "Micro800"
|
||||
clx = ClxDriver()
|
||||
if clx.open(addr, direct_connection=direct):
|
||||
try:
|
||||
prevval = clx.read_tag(tag)
|
||||
if direct:
|
||||
time.sleep(1)
|
||||
write_result = clx.write_tag(tag, val, prevval[1])
|
||||
return write_result
|
||||
except Exception:
|
||||
print("Error during writeTag({}, {}, {})".format(addr, tag, val))
|
||||
err = clx.get_status()
|
||||
clx.close()
|
||||
print(err)
|
||||
return False
|
||||
clx.close()
|
||||
return False
|
||||
Reference in New Issue
Block a user