56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
# uncompyle6 version 3.9.2
|
|
# Python bytecode version base 3.7.0 (3394)
|
|
# Decompiled from: Python 3.8.19 (default, Mar 20 2024, 15:27:52)
|
|
# [Clang 14.0.6 ]
|
|
# Embedded file name: /var/user/app/device_supervisorbak/device_supervisor/lib/pycomm3/com_server.py
|
|
# Compiled at: 2024-04-18 03:12:57
|
|
# Size of source mod 2**32: 2908 bytes
|
|
raise NotImplementedError("COMServer implementation is incomplete")
|
|
import pythoncom
|
|
from pycomm3 import LogixDriver, Tag
|
|
CLSID = "{7038d3a1-1ac4-4522-97d5-4c5a08a29906}"
|
|
|
|
class COMTag(Tag):
|
|
_public_attrs_ = [
|
|
"name", "value", "type", "error"]
|
|
_readonly_attrs_ = _public_attrs_
|
|
|
|
|
|
class LogixDriverCOMServer:
|
|
_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER
|
|
_public_methods_ = ["open", "close", "read_tag", "write"]
|
|
_readonlu_attrs_ = []
|
|
_public_attrs_ = []
|
|
_reg_clsid_ = CLSID
|
|
_reg_desc_ = "Pycomm3 - Python Ethernet/IP ControlLogix Library COM Server"
|
|
_reg_progid_ = "Pycomm3.COMServer"
|
|
|
|
def __init__(self):
|
|
self.plc = None
|
|
|
|
def open(self, path, init_tags=True, init_program_tags=False, init_info=True):
|
|
self.plc = LogixDriver(path, init_tags=init_tags, init_program_tags=init_program_tags, init_info=init_info)
|
|
self.plc.open()
|
|
|
|
def close(self):
|
|
self.plc.close()
|
|
|
|
def read(self, tag):
|
|
result = self.plc.read(tag)
|
|
if result:
|
|
return result.value
|
|
|
|
def write(self, *tag_values):
|
|
return (self.plc.write)(*tag_values)
|
|
|
|
|
|
def register_COM_server():
|
|
import sys
|
|
if "--register" in sys.argv or "--unregister" in sys.argv:
|
|
import win32com.server.register
|
|
win32com.server.register.UseCommandLine(LogixDriverCOMServer)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
register_COM_server()
|