Esempio n. 1
0
def main():
    '''
    Create our window and comm driver
    '''
    global root
    global comm
    global ProductionCount
    
    # create a comm driver
    comm = PLC()
    comm.IPAddress = ipAddress

    # create a tkinter window
    root = Tk()
    root.config(background='black')
    root.title = 'Production Count'
    root.geometry('800x600')
    
    # bind the "q" key to quit
    root.bind('q', lambda event:root.destroy())
    
    # create a labe to display our variable
    ProductionCount = Label(root, text='n', fg='white', bg='black', font='Helvetica 350 bold')
    ProductionCount.place(anchor=CENTER, relx=0.5, rely=0.5)
    
    # call our updater and show our window
    root.after(1000, UpdateValue)
    root.mainloop()
    comm.Close()
Esempio n. 2
0
import cv2
from darkflow.net.build import TFNet
import numpy as np
import time
import tensorflow as tf
from eip import PLC

#There is no comms error checking in this program
#so if it cant find PLC it will hang up.
#I am pushing data to a PLC running CLX 5000 software
test = PLC()
# Set the I.P to youre CLX 5000 rack
test.IPAddress = "172.16.2.161"

config = tf.ConfigProto(log_device_placement=True)
config.gpu_options.allow_growth = True
with tf.Session(config=config) as sess:
    options = {
        'model': 'cfg/yolov2-tiny-voc.cfg',
        'load': 'bin/yolov2-tiny-voc.weights',
        'threshold': 0.2,
        'gpu': 1.0
    }
    tfnet = TFNet(options)

colors = [tuple(255 * np.random.rand(3)) for _ in range(10)]

capture = cv2.VideoCapture(0)
#capture.set(cv2.CAP_PROP_FRAME_WIDTH,416)
#capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 416)
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)
#================================================================
# Code for an reading an array from PLC and moving it into Excel
#================================================================

from eip import PLC
comm = PLC()
comm.IPAddress = '100.100.100.100'
' xArray is the PLC tag being read and 5 is the number of arrays to read 
array = comm.Read('xArray[0]',5)

print (array)
[1234, 2345, 3456, 4567, 5678]
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
for i, value in enumerate(array):
	ws.cell(column=1,row=i+1,value=value)

<Cell 'Sheet'.A1>
<Cell 'Sheet'.A2>
<Cell 'Sheet'.A3>
<Cell 'Sheet'.A4>
<Cell 'Sheet'.A5>
wb.save('PLC_Read.xlsx')
Esempio n. 5
0
            end = '\n'

            # some tab space formatting
            if len(name) >= 36: tabs = '\t'
            if len(name) < 36 and len(name) >= 32: tabs = '\t' * 2
            if len(name) < 32 and len(name) >= 28: tabs = '\t' * 3
            if len(name) < 28 and len(name) >= 24: tabs = '\t' * 4
            if len(name) < 24 and len(name) >= 20: tabs = '\t' * 5
            if len(name) < 20 and len(name) >= 16: tabs = '\t' * 6
            if len(name) < 16 and len(name) >= 12: tabs = '\t' * 7
            if len(name) < 12: tabs = '\t' * 8

            line = name + tabs + dtype + '\t' + offset + end
            text_file.write(line)


# define our communication
comm = PLC()
comm.IPAddress = '192.168.0.167'
#comm.ProcessorSlot = 2

# uncomment one of the examples.
#ex_read('NewProductID')
#ex_readArray('ObjectValue[0]', 10)
#ex_multiRead()
#ex_write('ThisTag.Thingy', '107')
#ex_getPLCTime()
#ex_setPLCTime()
#ex_discover()
#ex_getTags()
Esempio n. 6
0
      dtype = "Type: " + str(tag.DataType)
      offset= "Offset: " + str(tag.Offset)
      end = '\n'

      # some tab space formatting
      if len(name) >= 36: tabs = '\t'
      if len(name) < 36 and len(name) >= 32: tabs = '\t'*2
      if len(name) < 32 and len(name) >= 28: tabs = '\t'*3
      if len(name) < 28 and len(name) >= 24: tabs = '\t'*4
      if len(name) < 24 and len(name) >= 20: tabs = '\t'*5
      if len(name) < 20 and len(name) >= 16: tabs = '\t'*6
      if len(name) < 16 and len(name) >= 12: tabs = '\t'*7
      if len(name) < 12: tabs = '\t'*8

      line = name + tabs + dtype + '\t' + offset + end
      text_file.write(line)

# define our communication
comm = PLC()
comm.IPAddress = '192.168.250.1'
#comm.ProcessorSlot = 2

# uncomment one of the examples.
#ex_read('NewProductID')
#ex_readArray('ObjectValue[0]', 10)
#ex_multiRead()
#ex_write('ThisTag.Thingy', '107')
#ex_getPLCTime()
ex_discover()
ex_getTags()
Esempio n. 7
0
      dtype = "Type: " + str(tag.DataType)
      offset= "Offset: " + str(tag.Offset)
      end = '\n'
    
      # some tab space formatting
      if len(name) >= 36: tabs = '\t'
      if len(name) < 36 and len(name) >= 32: tabs = '\t'*2
      if len(name) < 32 and len(name) >= 28: tabs = '\t'*3
      if len(name) < 28 and len(name) >= 24: tabs = '\t'*4
      if len(name) < 24 and len(name) >= 20: tabs = '\t'*5
      if len(name) < 20 and len(name) >= 16: tabs = '\t'*6
      if len(name) < 16 and len(name) >= 12: tabs = '\t'*7
      if len(name) < 12: tabs = '\t'*8
    
      line = name + tabs + dtype + '\t' + offset + end
      text_file.write(line)
    
# define our communication
comm = PLC()
comm.IPAddress = '192.168.1.10'
#comm.ProcessorSlot = 2

# uncomment one of the examples.
#ex_read('NewProductID')
#ex_readArray('ObjectValue[0]', 10)
#ex_multiRead()
#ex_write('ThisTag.Thingy', '107')
#ex_getPLCTime()
#ex_discover()
#ex_getTags()