Esempio n. 1
0
from eip import PLC

test = PLC()
test.IPAddress = "172.16.2.161"
value = test.Read("Timer.ACC")
print(value)
#Write a value: test.Write("tagname", value)
ex: test.Write("python_Real", 2.0)
test.Close()
Esempio n. 2
0
capture = cv2.VideoCapture(0)
#capture.set(cv2.CAP_PROP_FRAME_WIDTH,416)
#capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 416)

while True:
    stime = time.time()
    ret, frame = capture.read()
    if ret:  #quit()
        results = tfnet.return_predict(frame)
        for color, result in zip(colors, results):
            tl = (result['topleft']['x'], result['topleft']['y'])
            br = (result['bottomright']['x'], result['bottomright']['y'])
            label = result['label']
            confidence = result['confidence']
            text = '{}: {:.0f}%'.format(label, confidence * 100)
            textCon = '{:.0f}'.format(confidence * 100)
            frame = cv2.rectangle(frame, tl, br, color, 5)
            frame = cv2.putText(frame, text, tl, cv2.FONT_HERSHEY_COMPLEX, 1,
                                (0, 0, 0), 2)
        cv2.imshow('frame', frame)
        # Make a String tag(Nano_YOLO_label) and a String tag(Nano_YOLO_confidence) in your CLX 5000 processor
        ex: test.Write("Nano_YOLO_label", label)
        ex: test.Write("Nano_YOLO_confidence", textCon)
        print('FPS {:.1f}'.format(1 / (time.time() - stime)))
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
    #Un coment line below for PLC support
test.Close()
capture.release()
cv2.destroyAllWindows()
Esempio n. 3
0
'''
the following import is only necessary because eip.py is not in this directory
'''
import sys

sys.path.append('..')
'''
Write to a custom size string

WHen you create a custom size string, it is essentially
a UDT.  We cannot write to them in the same way that we
can write to a standard size string.

In this case, we're going to write some text to the tag
String20, which is a custom string STRING20.  We not only
have to write the data, we have to also write the length.
'''
from eip import PLC

with PLC() as comm:
    comm = PLC()
    comm.IPAddress = '192.168.1.9'
    string_size = 20
    text = 'This is some text'
    values = [ord(c) for c in text] + [0] * (string_size - len(text))
    comm.Write('String20.LEN', len(text))
    comm.Write('String20.DATA[0]', values)
Esempio n. 4
0
'''
the following import is only necessary because eip.py is not in this directory
'''
import sys
sys.path.append('..')
'''
A simple single write using a with statement.

One advantage of using a with statement is that
you don't have to call .Close() when you are done,
this is handled automatically.
'''
from eip import PLC

with PLC() as comm:
    comm = PLC()
    comm.IPAddress = '192.168.1.9'
    comm.Write('CurrentScreen', 10)
'''
the following import is only necessary because eip.py is not in this directory
'''
import sys
sys.path.append('..')


'''
Write a program scoped tag

I have a program named "MiscHMI" in my main task.
In MiscHMI, the tag I'm reading will be TimeArray[0]
You have to specify that the tag will be program scoped
by appending the tag name with "Program" and the beginning,
then add the program name, finally the tag name.  So our
example will look like this:

Program:MiscHMI.TimeArray[0]
'''
from eip import PLC

with PLC() as comm:
    comm = PLC()
    comm.IPAddress = '192.168.1.9'
    comm.Write('Program:MiscHMI.TimeArray[0]', 2019)
Esempio n. 6
0
'''
the following import is only necessary because eip.py is not in this directory
'''
import sys
sys.path.append('..')
'''
Write a little faster by providing the data type
up front

This only really makes sense to do if you have to
write a lot of unique tags. Typically, when you write a
tag, it has to fetch the data type first.  This only
happens the first time you read/write a uniuqe tag name.

If you have, for example, 1000 tags to write and they are
all unique, you would have have to fetch the data type,
then write the value, which is extra overhead.

If you pass the data type up front, it will skip that
initial read...
'''
from eip import PLC

with PLC() as comm:
    comm = PLC()
    comm.IPAddress = '192.168.1.9'
    comm.Write('Zone1Case', 10, datatype=196)
'''
the following import is only necessary because eip.py is not in this directory
'''
import sys
sys.path.append('..')
'''
Write an array of values

I have a tag called "LargeArray", which is DINT[10000]
We can write a list of values all at once to be more efficient.
You should be careful not to exceed the ~500 byte limit of
the packet.  You can pack quite a few values into 500 bytes.
'''
from eip import PLC

values = [8, 6, 7, 5, 3, 0, 9]

with PLC() as comm:
    comm = PLC()
    comm.IPAddress = '192.168.1.9'
    comm.Write('LargeArray[10]', values)