From b8a61ebfc1e86c5ef86c88cbe7635c288aa0647c Mon Sep 17 00:00:00 2001 From: bettleChen <2207153529@qq.com> Date: Thu, 20 Jul 2023 17:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/NetworkAnalog.iml | 2 +- .idea/misc.xml | 2 +- NetworkAnalog/NetworkAnalog.py | 8 ++++- NetworkAnalog/network.db | Bin 40960 -> 40960 bytes NetworkAnalog/x1/SimObjs.py | 63 +++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 NetworkAnalog/x1/SimObjs.py diff --git a/.idea/NetworkAnalog.iml b/.idea/NetworkAnalog.iml index d0876a7..8fb85ed 100644 --- a/.idea/NetworkAnalog.iml +++ b/.idea/NetworkAnalog.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9b688a8..ebb0faf 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/NetworkAnalog/NetworkAnalog.py b/NetworkAnalog/NetworkAnalog.py index 9391e16..33674dc 100644 --- a/NetworkAnalog/NetworkAnalog.py +++ b/NetworkAnalog/NetworkAnalog.py @@ -12,7 +12,13 @@ from SimObjs import SimPacket, SimHost, AllSimConnect, SimRouter, SimSwitch, Sim from dbUtil import search, execute_sql, delete_obj, truncate_db -def round_rectangle(cv, x1, y1, x2, y2, radius=25, **kwargs): +def round_rectangle(cv, x1, y1, x2, y2, radius=30, **kwargs): + """ + 绘制圆角矩形 + :param cv: canvas对象 + :param radius: 圆角值 + :return: + """ points = [x1 + radius, y1, x1 + radius, y1, x2 - radius, y1, diff --git a/NetworkAnalog/network.db b/NetworkAnalog/network.db index 729a5fee1693b4c6edae462bca5485f2d3abc5c1..e8b53b7f25923766a407e232f8402901b53e1df1 100644 GIT binary patch delta 714 zcma)(&1(}u7{+HN*)K_U6dDC9SYZpTb&{Rk*`3Xyq-#7BQ4<>DMT_p{0LqIjthx0l0&I^pDN8aJwvtPL8XRb}o^uY8lbqFlH|MMViJhKmr>8-@pd` zf{j=`gN0GpLM{~F3-e-dGKFkOd@U>9POcK^;ov=K2 zNZ6na!Wa!hJIFWU9zo$Vv}~(NY#$*(qs3%Whg+hxVf!-N#0vnQ1(t@V1o~r|GNEZA z*fGRhl%l|fBSPMFyn0{i_`3>EhMUN^gDff=i5<5ZhtG6^MR%tr4XuK>I3_NBWEryTL%Bh5lNLF{mcYwZk zt2AFOaS3$Mt%fXXqseoHZcy3P2KW1Q- zjs2WT{M4ZRy|?~X)`TU_i?SgTui1?3*iT&BYk9uiaa7ey299jT&Y;mrwA>Wl^Vbv% zUCn?OG#N@P!*g6?SYxh0&INreTjn}{z%Hb&heCM^iViHQq@{wVTAVop_WQUhg1g~u2ex5E=cx;a+28b+S^J;k#F`dD{>)4sd|S}XSFEbnuTb&m zKG*AKFMnRm>L;7J-wuVLkSDP(cg6i)%kldvbL91G&zBuLa@uWs&}j7=o*O$!+s(e5 GuERe$1bm19 diff --git a/NetworkAnalog/x1/SimObjs.py b/NetworkAnalog/x1/SimObjs.py new file mode 100644 index 0000000..8a5cbc2 --- /dev/null +++ b/NetworkAnalog/x1/SimObjs.py @@ -0,0 +1,63 @@ +class AllSimConnect(): + # todo: 连接类 + def __init__(self, nodex, nodex_ifs, nodey, nodey_ifs, config=None): + """ + 连接对象 + :param nodex: 节点 + :param nodex_ifs: 节点接口 + :param nodey: 节点 + :param nodey_ifs: 节点接口 + """ + self.ConfigCorrect = 0 if config is None else config + self.NobjS = nodex + self.NobjE = nodey + self.IfsS = nodex_ifs + self.IfsE = nodey_ifs + +class SimHost(): + """ + 主机类 + """ + def __init__(self, x=0, y=0, id=None, config=None, label=None): + self.ObjID = id + self.ObjType = 1 + self.ObjLabel = label + self.interface = [] + self.connections = [] + +class SimRouter(): + """ + 路由类 + """ + def __init__(self, x=0, y=0, id=None, config=None, label=None, *args): + self.ObjID = id + self.ObjType = 2 + self.ObjLabel = label + self.router_table = {} + +class SimSwitch(): + """ + 交换机类 + """ + def __init__(self, x=0, y=0, id=None, config=None, label=None, *args): + self.ObjID = id + self.ObjType = 3 + self.ObjLabel = label + self.mac_table = {} + +class SimHub(): + """ + 集线器类 + """ + def __init__(self, x=0, y=0, id=None, config=None, label=None, *args): + self.ObjID = str() if id is None else id + self.ObjType = 4 + self.ObjLabel = label + +if __name__ == '__main__': + AllSimObj = [] + host1 = SimHost() + AllSimObj.append(host1) + router = SimRouter() + AllSimObj.append(router) + connect = AllSimConnect(host1, 1, router, 1)