Hi all,
I am new to Ignition Perspective and I am using a 8.1.1 version. I am trying to extract information from a windows file and convert it into the ASCII but when I am running the code I am repeatedly having this error. Please give your inputs for below code:
from ctypes import POINTER, WINFUNCTYPE, c_char_p, c_void_p, c_int, c_ulong, c_char_p
from ctypes.wintypes import BOOL, DWORD, BYTE, INT, LPCWSTR, UINT, LONG, ULONG, LPCSTR, PCHAR, PWCHAR
import ctypes
from ctypes import byref
import sys
import os, glob
tcAccessDll = r"C:\Users\himanshu.choubisa\Desktop\TcAccess.dll"
rstfilename = b"C:\Users\himanshu.choubisa\Desktop\RA03534 AGAS UK 70+4min 130521B.rst"
#check newest results file
#rstfilename = min(glob.iglob(âC:\TCData\Data\*.rstâ), key=os.path.getctime).encode(âasciiâ)
Load DLL into memory.
#hllDll = ctypes.WinDLL (r"c:\PenExe\TcWS\Ver6.3.4\Bin\TcAccess.dll")#
#hllDll = ctypes.cdll.LoadLibrary (r"c:\PenExe\TcWS\Ver6.3.4\Bin\TcAccess.dll")
#hllDll = ctypes.WinDLL (r"c:/PenExe/TcWS/Ver6.3.4/Bin/TcAccess.dll")
#hllDll = ctypes.WinDLL (âTcAccess.dllâ)
def get_winfunc(libname, funcname, restype=None, argtypes=(), _libcache={}):
âââRetrieve a function from a library, and set the data types.â""
from ctypes import windll
if libname not in _libcache:
_libcache[libname] = ctypes.cdll.LoadLibrary(libname)
func = getattr(_libcache[libname], funcname)
func.argtypes = argtypes
func.restype = restype
return func
class TCAccess(object):
Init = get_winfunc(tcAccessDll, âTcAccessInitâ)
LoggedIn = get_winfunc(tcAccessDll,âTcAccessLoggedOnâ, BOOL)
OpenConversation = get_winfunc(tcAccessDll, âTcAccessOpenConversationâ,LONG,[LPCSTR])
CloseConversation = get_winfunc(tcAccessDll, âTcAccessCloseConversationâ, INT, [INT])
Set = get_winfunc(tcAccessDll, âTcAccessSetâ, INT, [INT,LPCSTR,LPCSTR])
Get = get_winfunc(tcAccessDll, âTcAccessGetâ, LPCSTR, [INT, LPCSTR])
print(TCAccess.Init())
print(TCAccess.LoggedIn())
topic = âRSTâ
c=(TCAccess.OpenConversation(b"RST"))
print(c)
print(TCAccess.Set(c,b"RST_FILE_NAME",rstfilename))
peakcount = int((TCAccess.Get(c,b"Rst_Num_Peaks")))
for index in range(peakcount):
(TCAccess.Set(c,b"RST_COMP_INDEX",str(index).encode(âasciiâ)))
CompName=(TCAccess.Get(c,b"CP_COMP_NAME").decode())
(TCAccess.Get(c,b"CP_PEAK_VECTOR"))
(TCAccess.Get(c,b"RST_PEAK_INDEX"))
CompArea=(TCAccess.Get(c,b"PK_AREA_PCT").decode())
CompResult=(TCAccess.Get(c,b"PK_RESULT").decode())
print ("Component " + CompName + " Peak Area %: " + CompArea + " Peak Concentration: " + CompResult)