Commit 301578d1 authored by yogesh.m's avatar yogesh.m

update

parent bab15ac6
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
<change beforePath="$PROJECT_DIR$/build/main/main.pkg" beforeDir="false" afterPath="$PROJECT_DIR$/build/main/main.pkg" afterDir="false" /> <change beforePath="$PROJECT_DIR$/build/main/main.pkg" beforeDir="false" afterPath="$PROJECT_DIR$/build/main/main.pkg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/main/warn-main.txt" beforeDir="false" afterPath="$PROJECT_DIR$/build/main/warn-main.txt" afterDir="false" /> <change beforePath="$PROJECT_DIR$/build/main/warn-main.txt" beforeDir="false" afterPath="$PROJECT_DIR$/build/main/warn-main.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/main/xref-main.html" beforeDir="false" afterPath="$PROJECT_DIR$/build/main/xref-main.html" afterDir="false" /> <change beforePath="$PROJECT_DIR$/build/main/xref-main.html" beforeDir="false" afterPath="$PROJECT_DIR$/build/main/xref-main.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dist/klopcua cloner.exe" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/dist/opcua_cloner.exe" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/hash_sender.py" beforeDir="false" afterPath="$PROJECT_DIR$/hash_sender.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.spec" beforeDir="false" afterPath="$PROJECT_DIR$/main.spec" afterDir="false" /> <change beforePath="$PROJECT_DIR$/opcua_transmitter.py" beforeDir="false" afterPath="$PROJECT_DIR$/opcua_transmitter.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<recent name="D:\opcua-cloning" /> <recent name="D:\opcua-cloning" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python.main"> <component name="RunManager" selected="Python.opcua_transmitter">
<configuration name="asyncua_server (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="asyncua_server (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="opcua-cloning" /> <module name="opcua-cloning" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="asyncua_server" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="hash_sender" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="opcua-cloning" /> <module name="opcua-cloning" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="D:\opcua-cloning\asyncua_server.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/hash_sender.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="hash_sender" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="opcua-cloning" /> <module name="opcua-cloning" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/hash_sender.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="main" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true"> <configuration name="opcua-transmitter (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="opcua-cloning" /> <module name="opcua-cloning" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/opcua-transmitter.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="opcua-transmitter (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="opcua_receiver" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="opcua-cloning" /> <module name="opcua-cloning" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/opcua-transmitter.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/opcua_receiver.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
...@@ -168,7 +168,7 @@ ...@@ -168,7 +168,7 @@
<option name="INPUT_FILE" value="" /> <option name="INPUT_FILE" value="" />
<method v="2" /> <method v="2" />
</configuration> </configuration>
<configuration name="opcua_receiver" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="opcua_transmitter" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="opcua-cloning" /> <module name="opcua-cloning" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/opcua_receiver.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/opcua_transmitter.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
...@@ -191,11 +191,11 @@ ...@@ -191,11 +191,11 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.opcua_transmitter" />
<item itemvalue="Python.hash_sender" />
<item itemvalue="Python.opcua-transmitter (1)" /> <item itemvalue="Python.opcua-transmitter (1)" />
<item itemvalue="Python.opcua_receiver" /> <item itemvalue="Python.opcua_receiver" />
<item itemvalue="Python.hash_sender" />
<item itemvalue="Python.asyncua_server (1)" /> <item itemvalue="Python.asyncua_server (1)" />
<item itemvalue="Python.asyncua_server" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
...@@ -220,5 +220,6 @@ ...@@ -220,5 +220,6 @@
</entry> </entry>
</map> </map>
</option> </option>
<option name="oldMeFiltersMigrated" value="true" />
</component> </component>
</project> </project>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
No preview for this file type
No preview for this file type
...@@ -16,11 +16,11 @@ IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for ...@@ -16,11 +16,11 @@ IMPORTANT: Do NOT post this list to the issue-tracker. Use it as a basis for
missing module named pyimod02_importers - imported by C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py (top-level), C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py (top-level) missing module named pyimod02_importers - imported by C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py (top-level), C:\Users\Admin\AppData\Local\Programs\Python\Python39\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py (top-level)
missing module named StringIO - imported by six (conditional), pkg_resources._vendor.six (conditional) missing module named StringIO - imported by six (conditional), pkg_resources._vendor.six (conditional)
missing module named 'org.python' - imported by pickle (optional), xml.sax (delayed, conditional) missing module named org - imported by pickle (optional)
missing module named _posixsubprocess - imported by subprocess (optional), multiprocessing.util (delayed) missing module named _posixsubprocess - imported by subprocess (optional), multiprocessing.util (delayed)
missing module named grp - imported by shutil (optional), tarfile (optional), pathlib (delayed, optional), subprocess (optional) missing module named grp - imported by shutil (optional), tarfile (optional), pathlib (delayed, optional), subprocess (optional)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), pathlib (delayed, conditional, optional), subprocess (optional), netrc (delayed, conditional), getpass (delayed), http.server (delayed, optional), webbrowser (delayed), distutils.util (delayed, conditional, optional) missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), pathlib (delayed, conditional, optional), subprocess (optional), netrc (delayed, conditional), getpass (delayed), http.server (delayed, optional), webbrowser (delayed), distutils.util (delayed, conditional, optional)
missing module named posix - imported by os (conditional, optional), shutil (conditional) missing module named posix - imported by shutil (conditional), os (conditional, optional)
missing module named resource - imported by posix (top-level) missing module named resource - imported by posix (top-level)
missing module named termios - imported by getpass (optional), tty (top-level) missing module named termios - imported by getpass (optional), tty (top-level)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level) missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), zipimport (top-level)
...@@ -29,7 +29,7 @@ missing module named pep517 - imported by importlib.metadata (delayed) ...@@ -29,7 +29,7 @@ missing module named pep517 - imported by importlib.metadata (delayed)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional) missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional)
missing module named __builtin__ - imported by pkg_resources._vendor.pyparsing (conditional) missing module named __builtin__ - imported by pkg_resources._vendor.pyparsing (conditional)
missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional) missing module named ordereddict - imported by pkg_resources._vendor.pyparsing (optional)
missing module named org - imported by copy (optional) missing module named 'org.python' - imported by copy (optional), xml.sax (delayed, conditional)
missing module named _manylinux - imported by pkg_resources._vendor.packaging.tags (delayed, optional) missing module named _manylinux - imported by pkg_resources._vendor.packaging.tags (delayed, optional)
missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.markers (top-level), pkg_resources._vendor.packaging.requirements (top-level) missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.markers (top-level), pkg_resources._vendor.packaging.requirements (top-level)
missing module named 'win32com.shell' - imported by pkg_resources._vendor.appdirs (conditional, optional) missing module named 'win32com.shell' - imported by pkg_resources._vendor.appdirs (conditional, optional)
......
...@@ -323,7 +323,7 @@ imported by: ...@@ -323,7 +323,7 @@ imported by:
<a target="code" href="" type="text/plain"><tt>'org.python'</tt></a> <a target="code" href="" type="text/plain"><tt>'org.python'</tt></a>
<span class="moduletype">MissingModule</span> <div class="import"> <span class="moduletype">MissingModule</span> <div class="import">
imported by: imported by:
<a href="#pickle">pickle</a> <a href="#copy">copy</a>
&#8226; <a href="#xml.sax">xml.sax</a> &#8226; <a href="#xml.sax">xml.sax</a>
</div> </div>
...@@ -4991,8 +4991,8 @@ imported by: ...@@ -4991,8 +4991,8 @@ imported by:
<a target="code" href="///C:/users/admin/appdata/local/programs/python/python39/lib/copy.py" type="text/plain"><tt>copy</tt></a> <a target="code" href="///C:/users/admin/appdata/local/programs/python/python39/lib/copy.py" type="text/plain"><tt>copy</tt></a>
<span class="moduletype">SourceModule</span> <div class="import"> <span class="moduletype">SourceModule</span> <div class="import">
imports: imports:
<a href="#copyreg">copyreg</a> <a href="#'org.python'">'org.python'</a>
&#8226; <a href="#org">org</a> &#8226; <a href="#copyreg">copyreg</a>
&#8226; <a href="#types">types</a> &#8226; <a href="#types">types</a>
&#8226; <a href="#weakref">weakref</a> &#8226; <a href="#weakref">weakref</a>
...@@ -13415,7 +13415,7 @@ imported by: ...@@ -13415,7 +13415,7 @@ imported by:
<a target="code" href="" type="text/plain"><tt>org</tt></a> <a target="code" href="" type="text/plain"><tt>org</tt></a>
<span class="moduletype">MissingModule</span> <div class="import"> <span class="moduletype">MissingModule</span> <div class="import">
imported by: imported by:
<a href="#copy">copy</a> <a href="#pickle">pickle</a>
</div> </div>
...@@ -13651,14 +13651,14 @@ imported by: ...@@ -13651,14 +13651,14 @@ imported by:
<a target="code" href="///C:/users/admin/appdata/local/programs/python/python39/lib/pickle.py" type="text/plain"><tt>pickle</tt></a> <a target="code" href="///C:/users/admin/appdata/local/programs/python/python39/lib/pickle.py" type="text/plain"><tt>pickle</tt></a>
<span class="moduletype">SourceModule</span> <div class="import"> <span class="moduletype">SourceModule</span> <div class="import">
imports: imports:
<a href="#'org.python'">'org.python'</a> <a href="#_compat_pickle">_compat_pickle</a>
&#8226; <a href="#_compat_pickle">_compat_pickle</a>
&#8226; <a href="#_pickle">_pickle</a> &#8226; <a href="#_pickle">_pickle</a>
&#8226; <a href="#codecs">codecs</a> &#8226; <a href="#codecs">codecs</a>
&#8226; <a href="#copyreg">copyreg</a> &#8226; <a href="#copyreg">copyreg</a>
&#8226; <a href="#functools">functools</a> &#8226; <a href="#functools">functools</a>
&#8226; <a href="#io">io</a> &#8226; <a href="#io">io</a>
&#8226; <a href="#itertools">itertools</a> &#8226; <a href="#itertools">itertools</a>
&#8226; <a href="#org">org</a>
&#8226; <a href="#pprint">pprint</a> &#8226; <a href="#pprint">pprint</a>
&#8226; <a href="#re">re</a> &#8226; <a href="#re">re</a>
&#8226; <a href="#struct">struct</a> &#8226; <a href="#struct">struct</a>
......
...@@ -7,7 +7,11 @@ import json ...@@ -7,7 +7,11 @@ import json
nm_no = None nm_no = None
async def create_node_hierarchy(client, node_objects): class Hash_Sender():
def __init__(self):
self.hash = ""
async def create_node_hierarchy(self,client, node_objects):
node_hierarchy={} node_hierarchy={}
for sub_obj in node_objects: for sub_obj in node_objects:
if("ns="+str(nm_no)+";" in str(sub_obj)): if("ns="+str(nm_no)+";" in str(sub_obj)):
...@@ -18,7 +22,7 @@ async def create_node_hierarchy(client, node_objects): ...@@ -18,7 +22,7 @@ async def create_node_hierarchy(client, node_objects):
if (identifier not in str(sub_obj)): if (identifier not in str(sub_obj)):
child_disp_name = await sub_obj.read_display_name() child_disp_name = await sub_obj.read_display_name()
identifier_name = sub_obj.nodeid.Identifier identifier_name = sub_obj.nodeid.Identifier
node_hierarchy[identifier_name] = await create_node_hierarchy(client, children_nodes) node_hierarchy[identifier_name] = await self.create_node_hierarchy(client, children_nodes)
node_hierarchy[identifier_name]["name"] = child_disp_name.Text node_hierarchy[identifier_name]["name"] = child_disp_name.Text
node_hierarchy[identifier_name]["type"] = node_class._value_ node_hierarchy[identifier_name]["type"] = node_class._value_
if (node_class._name_ == "Variable"): if (node_class._name_ == "Variable"):
...@@ -35,7 +39,7 @@ async def create_node_hierarchy(client, node_objects): ...@@ -35,7 +39,7 @@ async def create_node_hierarchy(client, node_objects):
node_hierarchy[identifier_name]["datatype"] = datatype._value_ node_hierarchy[identifier_name]["datatype"] = datatype._value_
return node_hierarchy return node_hierarchy
async def get_send_hash(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port): async def get_send_hash(self,ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port):
global nm_no global nm_no
serverAddressPort = (server_hash_udp_ip, server_hash_udp_port) serverAddressPort = (server_hash_udp_ip, server_hash_udp_port)
UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM) UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
...@@ -46,12 +50,13 @@ async def get_send_hash(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_po ...@@ -46,12 +50,13 @@ async def get_send_hash(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_po
node_objects = root_objects[0] node_objects = root_objects[0]
while True: while True:
node_objects_children = await node_objects.get_children() # replace with your own node id node_objects_children = await node_objects.get_children() # replace with your own node id
node_hierarchy = await create_node_hierarchy(client, node_objects_children) node_hierarchy = await self.create_node_hierarchy(client, node_objects_children)
node_hierarchy["hash"] = hash(str(node_hierarchy)) self.hash = node_hierarchy["hash"] = hash(str(node_hierarchy))
node_hierarchy["namespace_idx"]=nm_no node_hierarchy["namespace_idx"]=nm_no
json_hierarchy = json.dumps(node_hierarchy) json_hierarchy = json.dumps(node_hierarchy)
binary_data = json_hierarchy.encode() binary_data = json_hierarchy.encode()
UDPClientSocket.sendto(binary_data, serverAddressPort) UDPClientSocket.sendto(binary_data, serverAddressPort)
def send_hash(Endpoint,Namespace,server_hash_udp_ip,server_hash_udp_port): def send_hash(self,Endpoint,Namespace,server_hash_udp_ip,server_hash_udp_port):
asyncio.run(get_send_hash(Endpoint,Namespace,server_hash_udp_ip,server_hash_udp_port)) asyncio.run(self.get_send_hash(Endpoint,Namespace,server_hash_udp_ip,server_hash_udp_port))
\ No newline at end of file return self.hash
\ No newline at end of file
import asyncio import asyncio
import socket import socket
import threading import threading
import hash_sender from hash_sender import Hash_Sender
from asyncua import Client, Node from asyncua import Client, Node
from asyncua.common.subscription import DataChangeNotif, SubHandler from asyncua.common.subscription import DataChangeNotif, SubHandler
import yaml import yaml
...@@ -60,23 +60,44 @@ async def get_nodes(client,node_objects): ...@@ -60,23 +60,44 @@ async def get_nodes(client,node_objects):
return variables return variables
async def main() -> None: hash_changed=False
async def subscribe_node():
global nm_no global nm_no
try:
async with Client(url=ENDPOINT) as client: async with Client(url=ENDPOINT) as client:
nm_no = str(await client.get_namespace_index(NAMESPACE)) nm_no = str(await client.get_namespace_index(NAMESPACE))
global hash_changed
object_root_node = client.get_objects_node() object_root_node = client.get_objects_node()
objects = await object_root_node.get_children() objects = await object_root_node.get_children()
node = await get_nodes(client,objects) node = await get_nodes(client, objects)
t1=threading.Thread(target=hash_sender.send_hash,args=(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port,))
t1.start()
handler = MyHandler() handler = MyHandler()
subscription = await client.create_subscription(period=0, handler=handler) subscription = await client.create_subscription(period=0, handler=handler)
await subscription.subscribe_data_change(node) await subscription.subscribe_data_change(node)
while True: while True and not hash_changed:
await handler.process() await handler.process()
await asyncio.sleep(0.01) await asyncio.sleep(0.01)
except: hash_changed=False
def subscribe_to_node():
asyncio.run(subscribe_node())
async def main() -> None:
hs=Hash_Sender()
global hash_changed
prev_hash=""
try:
t1=threading.Thread(target=hs.send_hash,args=(ENDPOINT,NAMESPACE,server_hash_udp_ip,server_hash_udp_port,))
t1.start()
while True:
hash=hs.hash
if(hash!=prev_hash and not hash_changed):
prev_hash=hash
hash_changed = True
while(hash_changed):
hash_changed = False
t2=threading.Thread(target=subscribe_to_node,args=())
t2.start()
except Exception:
print("No connection found for opcua server, check if the server is active") print("No connection found for opcua server, check if the server is active")
def transmitter_main(_server_hash_udp_ip,_server_hash_udp_port,_server_udp_ip,_server_udp_port,_ENDPOINT,_NAMESPACE): def transmitter_main(_server_hash_udp_ip,_server_hash_udp_port,_server_udp_ip,_server_udp_port,_ENDPOINT,_NAMESPACE):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment