POST
|
Hey thanks for the help. Somehow I manage to solve my problem and my data can be read into MatrikonOPC Explorer. Do you know like what I need to include in order for python to auto update value in MatrikonOPC?
... View more
12-18-2013
04:43 AM
|
0
|
0
|
356
|
POST
|
Cause this code was given to me by my professor in school. Was able to execute previously by him. So I have to make amendment to it according to my excel spread sheet. But after making some amendment I'm not sure why the Query_value1 was not define when I did not change anything there. So I'm quite stuck at this stage
... View more
12-17-2013
10:45 PM
|
0
|
0
|
356
|
POST
|
erm.. you mean insert in code block here? I've attach my code here too
... View more
12-17-2013
08:54 PM
|
0
|
0
|
356
|
POST
|
Currently I'm trying to send real-time data from excel spreadsheet to MatrikonOPC. I'm testing out with random data in excel sheet with my value 1 in the column B of the spreadsheet. Below are my code: import OpenOPCEdited import pyodbc import time opc = OpenOPCEdited.client() opc.connect('Matrikon.OPC.Simulation.1') cnxn = pyodbc.connect('DSN=Excel Files;Dbq=C:\Users\Administrator\Desktop\Minghui\Testing.xlsm', autocommit=True) fetcher = cnxn.cursor() Query_tag = fetcher.execute("select tag from [Sheet2$]").fetchall() Query_value1 = fetcher.execute("select value1 from [Sheet2$]").fetchall() tagname = [] #Tag name list with Bucket Brigade. prefix for tags in Query_tag: raw = tags[-1] compulsory = 'Bucket Brigade.' raw_new = compulsory + str(raw) tagname.append(raw_new) value1 = [] #1st column of data for tags in Query_value1: raw = tags[-1] value1.append(raw) interval = 60 # update interval in seconds #Writing data to OPC for iteration in range(2): n = 0 m = n + 1 for every in tagname: find_cb = every.find('CB') if find_cb == -1: opc[every] = value1 if find_cb != -1: opc[every] = str(value1 ) n += 1 time.sleep(interval) #wait (X) seconds Sorry for the trouble as I'm really a newbie in this stuff. Greatly appreciated. Regards, Minghui
... View more
12-17-2013
08:30 PM
|
0
|
0
|
356
|
POST
|
Thanks for the help. But I got another error asking me to define my Query_value1 when I've already define it. Below are the error message and part of my code. Error message: File "C:\Python27\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript exec codeObject in __main__.__dict__ File "C:\Users\Administrator\Desktop\Minghui\Phyton\Testing.py", line 25, in <module> for tags in Query_value1: NameError: name 'Query_value1' is not defined My code are below: Query_value1 = fetcher.execute("select value1 from [Sheet2$]").fetchall() tagname = [] #Tag name list with Bucket Brigade. prefix for tags in Query_tag: raw = tags[-1] compulsory = 'Bucket Brigade.' raw_new = compulsory + str(raw) tagname.append(raw_new) value1 = [] #1st column of data for tags in Query_value1: raw = tags[-1] value1.append(raw) Regards, Minghui
... View more
12-17-2013
08:17 PM
|
0
|
0
|
356
|
POST
|
Hi, Anyone here can help me solve this error that I encounter during my execution? File "C:\Python27\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript exec codeObject in __main__.__dict__ File "C:\Users\Administrator\Desktop\Minghui\Phyton\Testing.py", line 20, in <module> raw_new = compulsory + raw TypeError: cannot concatenate 'str' and 'float' objects Greatly appreciated. Regards, Minghui
... View more
12-17-2013
07:03 PM
|
0
|
9
|
564
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|