osis-python 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- osis_python-0.1.0.dist-info/METADATA +64 -0
- osis_python-0.1.0.dist-info/RECORD +55 -0
- osis_python-0.1.0.dist-info/WHEEL +5 -0
- osis_python-0.1.0.dist-info/licenses/LICENSE +21 -0
- osis_python-0.1.0.dist-info/top_level.txt +1 -0
- pyosis/__init__.py +15 -0
- pyosis/ai/__init__.py +6 -0
- pyosis/ai/agents/BaseAgent.py +79 -0
- pyosis/ai/agents/DecisionAgent.py +189 -0
- pyosis/ai/agents/MaterialAgent.py +44 -0
- pyosis/ai/agents/ModelAgent.py +42 -0
- pyosis/ai/agents/QuickBuildingAgent.py +74 -0
- pyosis/ai/agents/SectionAgent.py +40 -0
- pyosis/ai/agents/__init__.py +0 -0
- pyosis/boundary/__init__.py +7 -0
- pyosis/boundary/interface.py +90 -0
- pyosis/control/__init__.py +1 -0
- pyosis/control/interface.py +182 -0
- pyosis/core/PyInterface.pyi +153 -0
- pyosis/core/__init__.py +12 -0
- pyosis/core/command.py +180 -0
- pyosis/core/engine.py +13 -0
- pyosis/element/__init__.py +1 -0
- pyosis/element/interface.py +220 -0
- pyosis/general/__init__.py +1 -0
- pyosis/general/interface.py +31 -0
- pyosis/live/__init__.py +3 -0
- pyosis/live/analysis.py +116 -0
- pyosis/live/grade.py +125 -0
- pyosis/live/lane.py +56 -0
- pyosis/load/__init__.py +3 -0
- pyosis/load/loadcase.py +59 -0
- pyosis/load/static.py +274 -0
- pyosis/load/tendon.py +325 -0
- pyosis/material/__init__.py +1 -0
- pyosis/material/interface.py +207 -0
- pyosis/node/__init__.py +1 -0
- pyosis/node/interface.py +51 -0
- pyosis/post/__init__.py +1 -0
- pyosis/post/interface.py +21 -0
- pyosis/property/__init__.py +0 -0
- pyosis/property/coordinate.py +5 -0
- pyosis/property/creep_shrink.py +53 -0
- pyosis/property/damping.py +37 -0
- pyosis/property/pu_curve.py +59 -0
- pyosis/quick_building/__init__.py +1 -0
- pyosis/quick_building/interface.py +298 -0
- pyosis/section/__init__.py +4 -0
- pyosis/section/common.py +325 -0
- pyosis/section/numeric.py +0 -0
- pyosis/section/param.py +96 -0
- pyosis/section/steel.py +0 -0
- pyosis/stage/__init__.py +3 -0
- pyosis/stage/define.py +123 -0
- pyosis/stage/overall.py +85 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Interfaces of OSIS functions
|
|
3
|
+
|
|
4
|
+
========
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from typing import Literal
|
|
10
|
+
from ..core import REGISTRY
|
|
11
|
+
|
|
12
|
+
# @REGISTRY.register("Boundary")
|
|
13
|
+
# def osis_boundary(nBd: int=1, eBoundaryType: Literal["GENERAL", "MSTSLV", "RELEASE", "ELSTCSPT"]="GENERAL", params: Dict[str, Any]={}):
|
|
14
|
+
# '''
|
|
15
|
+
# 创建边界
|
|
16
|
+
|
|
17
|
+
# Args:
|
|
18
|
+
# nBd (int): 边界编号
|
|
19
|
+
# eBoundaryType (str): 边界类型,不区分大小写。GENERAL = 一般边界,MSTSLV = 主从约束,RELEASE = 释放梁端约束,ELSTCSPT = 节点弹性支承
|
|
20
|
+
# params (Dict[str, Any]): 对应边界类型所需要的参数
|
|
21
|
+
# Returns:
|
|
22
|
+
# tuple (bool, str): 是否成功,失败原因
|
|
23
|
+
# '''
|
|
24
|
+
# pass
|
|
25
|
+
|
|
26
|
+
@REGISTRY.register("Boundary")
|
|
27
|
+
def osis_boundary_general(nBd: int, eBoundaryType: Literal["GENERAL"]="GENERAL", nCoor: int = -1, bX: bool = 1, bY: bool = 1, bZ: bool = 1, bRX: bool = 1, bRY: bool = 1, bRZ: bool = 1, bRW: bool = 1):
|
|
28
|
+
'''
|
|
29
|
+
定义或修改一般边界
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
nBd (int): 编号
|
|
33
|
+
eBoundaryType (str): 固定为 GENERAL
|
|
34
|
+
nCoor (int): 局部坐标系编号,-1代表缺省
|
|
35
|
+
bX (bool): 0 = 释放,1 = 约束
|
|
36
|
+
bY (bool): 0 = 释放,1 = 约束
|
|
37
|
+
bZ (bool): 0 = 释放,1 = 约束
|
|
38
|
+
bRX (bool): 0 = 释放,1 = 约束
|
|
39
|
+
bRY (bool): 0 = 释放,1 = 约束
|
|
40
|
+
bRZ (bool): 0 = 释放,1 = 约束
|
|
41
|
+
bRW (bool): 0 = 释放,1 = 约束
|
|
42
|
+
Returns:
|
|
43
|
+
tuple (bool, str): 是否成功,失败原因
|
|
44
|
+
'''
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@REGISTRY.register("AsgnBd")
|
|
49
|
+
def osis_assign_boundary(nBd: int=1, eOP: Literal["a", "s", "r", "aa", "ra"]="a", param: list=[]):
|
|
50
|
+
'''
|
|
51
|
+
分配边界给节点(一般支撑,节点弹性支撑)
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
nBd (int): 边界编号
|
|
55
|
+
eOP (str): 操作
|
|
56
|
+
* a = 添加
|
|
57
|
+
* s = 替换
|
|
58
|
+
* r = 移除
|
|
59
|
+
* aa = 添加全部
|
|
60
|
+
* ra = 移除全部
|
|
61
|
+
param (list): 待操作的编号,支持的格式:*,*to*,*by*(仅用于替换)。
|
|
62
|
+
例子:[2,3,5,"8to10"] ["2by3","5by6","8by10"] 重合的编号自动忽略
|
|
63
|
+
Returns:
|
|
64
|
+
tuple (bool, str): 是否成功,失败原因
|
|
65
|
+
'''
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
@REGISTRY.register("BdGrp")
|
|
69
|
+
def osis_boundary_group(strName: str, eOP: Literal["c", "a", "s", "r", "aa", "ra", "m", "d"], param: list=[]):
|
|
70
|
+
'''
|
|
71
|
+
添加或移除边界组
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
strName (str): 边界组名
|
|
75
|
+
eOP (str): 操作
|
|
76
|
+
* c = 创建
|
|
77
|
+
* a = 添加
|
|
78
|
+
* s = 替换
|
|
79
|
+
* r = 移除
|
|
80
|
+
* aa = 添加全部
|
|
81
|
+
* ra = 移除全部
|
|
82
|
+
* m = 修改组名
|
|
83
|
+
* d = 删除
|
|
84
|
+
param (list): 待操作的编号,支持的格式:*, *to*; *by*,仅用于替换。
|
|
85
|
+
例子:[2,3,5,"8to10"] ["2by3","5by6","8by10"] 重合的编号自动忽略
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
tuple (bool, str): 是否成功,失败原因
|
|
89
|
+
'''
|
|
90
|
+
pass
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .interface import *
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Interfaces of OSIS functions
|
|
3
|
+
|
|
4
|
+
========
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from ..core import OSISEngine, REGISTRY
|
|
10
|
+
|
|
11
|
+
@REGISTRY.register("Acel")
|
|
12
|
+
def osis_acel(dG: float = 9.8066):
|
|
13
|
+
'''
|
|
14
|
+
定义或修改重力加速度值
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
dG (float): 重力加速度值
|
|
18
|
+
Returns:
|
|
19
|
+
tuple (bool, str): 是否成功,失败原因
|
|
20
|
+
'''
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
@REGISTRY.register("CalcTendon")
|
|
24
|
+
def osis_calc_tendon(bFlag: int=1):
|
|
25
|
+
'''
|
|
26
|
+
是否计算预应力
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
bFlag (bool): 1=开,0=关
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
tuple (bool, str): 是否成功,失败原因
|
|
33
|
+
'''
|
|
34
|
+
pass
|
|
35
|
+
|
|
36
|
+
@REGISTRY.register("CalcConForce")
|
|
37
|
+
def osis_calc_con_force(bFlag: int=1):
|
|
38
|
+
'''
|
|
39
|
+
是否计算并发反力
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
bFlag (bool): 1=开,0=关
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
tuple (bool, str): 是否成功,失败原因
|
|
46
|
+
'''
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
@REGISTRY.register("CalcShrink")
|
|
50
|
+
def osis_calc_shrink(bFlag: int=1):
|
|
51
|
+
'''
|
|
52
|
+
是否计算收缩
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
bFlag (bool): 1=开,0=关
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
tuple (bool, str): 是否成功,失败原因
|
|
59
|
+
'''
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
@REGISTRY.register("CalcCreep")
|
|
63
|
+
def osis_calc_creep(bFlag: int=1):
|
|
64
|
+
'''
|
|
65
|
+
是否计算徐变
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
bFlag (bool): 1=开,0=关
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
tuple (bool, str): 是否成功,失败原因
|
|
72
|
+
'''
|
|
73
|
+
pass
|
|
74
|
+
|
|
75
|
+
@REGISTRY.register("CalcCreep")
|
|
76
|
+
def osis_calc_shear(bFlag: int=1):
|
|
77
|
+
'''
|
|
78
|
+
是否计算剪切
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
bFlag (bool): 1=开,0=关
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
tuple (bool, str): 是否成功,失败原因
|
|
85
|
+
'''
|
|
86
|
+
pass
|
|
87
|
+
|
|
88
|
+
@REGISTRY.register("CalcRlx")
|
|
89
|
+
def osis_calc_rlx(bFlag: int=1):
|
|
90
|
+
'''
|
|
91
|
+
是否计算钢束松弛
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
bFlag (bool): 1=开,0=关
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
tuple (bool, str): 是否成功,失败原因
|
|
98
|
+
'''
|
|
99
|
+
pass
|
|
100
|
+
|
|
101
|
+
@REGISTRY.register("ModLocCoor")
|
|
102
|
+
def osis_mod_loc_coor(bFlag: int=1):
|
|
103
|
+
'''
|
|
104
|
+
是否修改变截面单元局部坐标轴来计算内力/应力
|
|
105
|
+
|
|
106
|
+
Args:
|
|
107
|
+
bFlag (bool): 1=开,0=关
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
tuple (bool, str): 是否成功,失败原因
|
|
111
|
+
'''
|
|
112
|
+
pass
|
|
113
|
+
|
|
114
|
+
@REGISTRY.register("IncTendon")
|
|
115
|
+
def osis_inc_tendon(bFlag: int=1):
|
|
116
|
+
'''
|
|
117
|
+
是否考虑钢束自重及钢束对截面几何特性的影响
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
bFlag (bool): 1=开,0=关
|
|
121
|
+
|
|
122
|
+
Returns:
|
|
123
|
+
tuple (bool, str): 是否成功,失败原因
|
|
124
|
+
'''
|
|
125
|
+
pass
|
|
126
|
+
|
|
127
|
+
@REGISTRY.register("NL")
|
|
128
|
+
def osis_nl(bGeom: int=0, bLink: int=0):
|
|
129
|
+
'''
|
|
130
|
+
非线性控制开关
|
|
131
|
+
|
|
132
|
+
Args:
|
|
133
|
+
bGeom (bool):
|
|
134
|
+
* 0 = 关闭几何非线性开关
|
|
135
|
+
* 1 = 打开几何非线性开关、大位移大转角
|
|
136
|
+
bLink (bool):
|
|
137
|
+
* 0 = 不考虑非线性连接单元
|
|
138
|
+
* 1 = 考虑非线性连接单元
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
tuple (bool, str): 是否成功,失败原因
|
|
142
|
+
'''
|
|
143
|
+
pass
|
|
144
|
+
|
|
145
|
+
@REGISTRY.register("LnSrch")
|
|
146
|
+
def osis_ln_srch(bFlag: int=1):
|
|
147
|
+
'''
|
|
148
|
+
求解设置线性搜索开关
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
bFlag (bool): 1=开,0=关
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
tuple (bool, str): 是否成功,失败原因
|
|
155
|
+
'''
|
|
156
|
+
pass
|
|
157
|
+
|
|
158
|
+
@REGISTRY.register("AutoTs")
|
|
159
|
+
def osis_auto_ts(bFlag: int=1):
|
|
160
|
+
'''
|
|
161
|
+
是否定义自动计算时间荷载步
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
bFlag (bool): 1=开,0=关
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
tuple (bool, str): 是否成功,失败原因
|
|
168
|
+
'''
|
|
169
|
+
pass
|
|
170
|
+
|
|
171
|
+
@REGISTRY.register("ModOpt")
|
|
172
|
+
def osis_mod_opt(nMod: int=1):
|
|
173
|
+
'''
|
|
174
|
+
定义模态分析所需的特征值最大数目
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
nMod (int): 需要计算的特征值最大数目(缺省值:1)
|
|
178
|
+
|
|
179
|
+
Returns:
|
|
180
|
+
tuple (bool, str): 是否成功,失败原因
|
|
181
|
+
'''
|
|
182
|
+
pass
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
'''
|
|
2
|
+
PyInterface 的 高亮提示文件
|
|
3
|
+
'''
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict, Tuple
|
|
6
|
+
|
|
7
|
+
class PyInterface:
|
|
8
|
+
_instance = None
|
|
9
|
+
|
|
10
|
+
@classmethod
|
|
11
|
+
def GetInstance(cls) -> 'PyInterface':
|
|
12
|
+
if cls._instance is None:
|
|
13
|
+
cls._instance = cls()
|
|
14
|
+
return cls._instance
|
|
15
|
+
|
|
16
|
+
# def setProjects(self, project: Any) -> None: ...
|
|
17
|
+
|
|
18
|
+
def OSIS_Run(self, strCmd: str, mode: str) -> Tuple[bool, str]:
|
|
19
|
+
return True, ""
|
|
20
|
+
|
|
21
|
+
# def OSIS_Replot(self) -> Tuple[bool, str]:
|
|
22
|
+
# return True, ""
|
|
23
|
+
|
|
24
|
+
# def OSIS_Clear(self) -> Tuple[bool, str]:
|
|
25
|
+
# return True, ""
|
|
26
|
+
|
|
27
|
+
# def OSIS_Solve(self) -> Tuple[bool, str]:
|
|
28
|
+
# return True, ""
|
|
29
|
+
|
|
30
|
+
# def OSIS_Acel(self, dG: float) -> tuple[bool, str]:
|
|
31
|
+
# return True, ""
|
|
32
|
+
|
|
33
|
+
# def OSIS_CalcTendon(self, bFlag: int) -> tuple[bool, str]:
|
|
34
|
+
# return True, ""
|
|
35
|
+
|
|
36
|
+
# def OSIS_CalcConForce(self, bFlag: int) -> tuple[bool, str]:
|
|
37
|
+
# return True, ""
|
|
38
|
+
|
|
39
|
+
# def OSIS_CalcShrink(self, bFlag: int) -> tuple[bool, str]:
|
|
40
|
+
# return True, ""
|
|
41
|
+
|
|
42
|
+
# def OSIS_CalcCreep(self, bFlag: int) -> tuple[bool, str]:
|
|
43
|
+
# return True, ""
|
|
44
|
+
|
|
45
|
+
# def OSIS_CalcShear(self, bFlag: int) -> tuple[bool, str]:
|
|
46
|
+
# return True, ""
|
|
47
|
+
|
|
48
|
+
# def OSIS_CalcRlx(self, bFlag: int) -> tuple[bool, str]:
|
|
49
|
+
# return True, ""
|
|
50
|
+
|
|
51
|
+
# def OSIS_ModLocCoor(self, bFlag: int) -> tuple[bool, str]:
|
|
52
|
+
# return True, ""
|
|
53
|
+
|
|
54
|
+
# def OSIS_IncTendon(self, bFlag: int) -> tuple[bool, str]:
|
|
55
|
+
# return True, ""
|
|
56
|
+
|
|
57
|
+
# def OSIS_NL(self, bGeom: int, bLink: int) -> tuple[bool, str]:
|
|
58
|
+
# return True, ""
|
|
59
|
+
|
|
60
|
+
# def OSIS_LnSrch(self, bFlag: int) -> tuple[bool, str]:
|
|
61
|
+
# return True, ""
|
|
62
|
+
|
|
63
|
+
# def OSIS_AutoTs(self, bFlag: int) -> tuple[bool, str]:
|
|
64
|
+
# return True, ""
|
|
65
|
+
|
|
66
|
+
# def OSIS_ModOpt(self, nMod: int) -> tuple[bool, str]:
|
|
67
|
+
# return True, ""
|
|
68
|
+
|
|
69
|
+
# def OSIS_CrpShrk(self, nNO: int, strName: str, dAvgHumidity: float, nBirthTime: int, dTypeCoeff: float, nBirthByShrinking: int) -> Tuple[bool, str]:
|
|
70
|
+
# return True, ""
|
|
71
|
+
|
|
72
|
+
# def OSIS_Material(self, nMat: int, strName: str, eMaterialType: str, eCode: str, eGrade: str, nCrepShrk: int, dDmp: float, params: dict={}) -> Tuple[bool, str]: # 需要修改
|
|
73
|
+
# return True, ""
|
|
74
|
+
|
|
75
|
+
# def OSIS_MaterialDel(self, nMat: int) -> Tuple[bool, str]:
|
|
76
|
+
# return True, ""
|
|
77
|
+
|
|
78
|
+
# def OSIS_MaterialMod(self, nOld: int, nNew: int) -> Tuple[bool, str]:
|
|
79
|
+
# return True, ""
|
|
80
|
+
|
|
81
|
+
# def OSIS_Section(self, nSec: int, strName: str, eSectionType: str, params: Dict[str, Any]) -> Tuple[bool, str]:
|
|
82
|
+
# return True, ""
|
|
83
|
+
|
|
84
|
+
# def OSIS_SectionOffset(self, nSec: int, offsetTypeY: str, dOffsetValueY: float, offsetTypeZ: str, dOffsetValueZ: float) -> Tuple[bool, str]:
|
|
85
|
+
# return True, ""
|
|
86
|
+
|
|
87
|
+
# def OSIS_SectionMesh(self, nSec: int, bMeshMethod: int, dMeshSize: float) -> Tuple[bool, str]:
|
|
88
|
+
# return True, ""
|
|
89
|
+
|
|
90
|
+
# def OSIS_SectionDel(self, nSec: int) -> Tuple[bool, str]:
|
|
91
|
+
# return True, ""
|
|
92
|
+
|
|
93
|
+
# def OSIS_SectionMod(self, nOld: int, nNew: int) -> Tuple[bool, str]:
|
|
94
|
+
# return True, ""
|
|
95
|
+
|
|
96
|
+
# def OSIS_Node(self, nNO: int, x: float, y: float, z: float) -> Tuple[bool, str]:
|
|
97
|
+
# return True, ""
|
|
98
|
+
|
|
99
|
+
# def OSIS_NodeDel(self, nNO: int) -> Tuple[bool, str]:
|
|
100
|
+
# return True, ""
|
|
101
|
+
|
|
102
|
+
# def OSIS_NodeMod(self, nOld: int, nNew: int) -> Tuple[bool, str]:
|
|
103
|
+
# return True, ""
|
|
104
|
+
|
|
105
|
+
# def OSIS_Element(self, nEle: int, eElementType: str, params: Dict[str, Any]) -> Tuple[bool, str]:
|
|
106
|
+
# return True, ""
|
|
107
|
+
|
|
108
|
+
# def OSIS_ElementDel(self, nEle: int) -> Tuple[bool, str]:
|
|
109
|
+
# return True, ""
|
|
110
|
+
|
|
111
|
+
# def OSIS_ElementMod(self, nOld: int, nNew: int) -> Tuple[bool, str]:
|
|
112
|
+
# return True, ""
|
|
113
|
+
|
|
114
|
+
# def OSIS_Boundary(self, nBd: int, eBoundaryType: str, params: Dict[str, Any]) -> Tuple[bool, str]:
|
|
115
|
+
# return True, ""
|
|
116
|
+
|
|
117
|
+
# def OSIS_AsgnBd(self, nBd: int, eOP: str, nodeNOs: list) -> Tuple[bool, str]:
|
|
118
|
+
# return True, ""
|
|
119
|
+
|
|
120
|
+
# def OSIS_Load(self, eLoadType: str, strLCName: str, params: Dict[str, Any]) -> Tuple[bool, str]:
|
|
121
|
+
# return True, ""
|
|
122
|
+
|
|
123
|
+
# def OSIS_LoadCase(self, strName: str, eLoadCaseType: str, dScalar: float, strPrompt: str) -> Tuple[bool, str]:
|
|
124
|
+
# return True, ""
|
|
125
|
+
|
|
126
|
+
# def OSIS_LiveGrade(self, strName: str, eCode: str, eLiveLoadType: str, params: Dict[str, Any]) -> Tuple[bool, str]:
|
|
127
|
+
# return True, ""
|
|
128
|
+
|
|
129
|
+
def OSIS_ElemForce(self, strLCName: str, eDataItem: str, eElementType: str) -> Tuple[bool, str, Any]:
|
|
130
|
+
return True, "", None
|
|
131
|
+
|
|
132
|
+
def OSIS_QBOverall(self, eBridgeType: str, spans: list, bIsElasticConnection: bool,
|
|
133
|
+
dKxOfAbutment1: float, dKyOfAbutment1: float, dKzOfAbutment1: float,
|
|
134
|
+
dKxOfAbutment2: float, dKyOfAbutment2: float, dKzOfAbutment2: float, dElasticLength: float) -> Tuple[bool, str]:
|
|
135
|
+
return True, ""
|
|
136
|
+
|
|
137
|
+
def OSIS_QBPortrait(self, eBridgeType: str, dEleLengthMin: float, dEleLengthMax: float, S1: float, L1: float, F1: float, Tb: float, Tw: float, D1: float) -> Tuple[bool, str]:
|
|
138
|
+
return True, ""
|
|
139
|
+
|
|
140
|
+
def OSIS_QBLoad(self, eBridgeType: str,
|
|
141
|
+
bHaveDeadLoad: bool, bHavePavement: bool, bHaveRail: bool, bHaveSidewalk: bool, bHaveSideBeam: bool, bHaveMiddleBeam: bool,
|
|
142
|
+
bHaveMovingLoad: bool, bHaveTemperEff: bool, bHaveTemperGradient: bool, bHaveSupSettle: bool,
|
|
143
|
+
dDeadLoadFactor: float, dPavementIntensity: float, dRailIntensity: float, dSidewalkIntensity: float, dCrowdLoad: float,
|
|
144
|
+
dSideBeamPointLoad: float, dMiddleBeamPointLoad: float,
|
|
145
|
+
dTransVehDistribution: float, bIsSelfDefine: bool, dFundFreq: float, dWarming: float, dCooling: float,
|
|
146
|
+
T1: float, T2: float, dSupSettle: float) -> Tuple[bool, str]:
|
|
147
|
+
return True, ""
|
|
148
|
+
|
|
149
|
+
def OSIS_QBTendon(self, eBridgeType: str, tendonInfo: list) -> Tuple[bool, str]:
|
|
150
|
+
return True, ""
|
|
151
|
+
|
|
152
|
+
def OSIS_QBStage(self, eBridgeType: str, stageInfo: list) -> Tuple[bool, str]:
|
|
153
|
+
return True, ""
|
pyosis/core/__init__.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pyosis.core 的 Docstring
|
|
3
|
+
--------
|
|
4
|
+
|
|
5
|
+
OSISEngine中的函数,将会分发到各个模块,被再次封装,意图为:
|
|
6
|
+
- 避免麻烦的OSISEngine::GetInstance().OSIS_XXX调用方式
|
|
7
|
+
- 将各个模块分类开以实现逻辑清晰
|
|
8
|
+
- 将函数命名格式转换成python的常用格式,便于人与AI的理解
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from .engine import OSISEngine
|
|
12
|
+
from .command import REGISTRY, osis_run, set_run_mode
|
pyosis/core/command.py
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
'''
|
|
2
|
+
pyosis.core.command 的 Docstring
|
|
3
|
+
|
|
4
|
+
===
|
|
5
|
+
# OSIS命令流兼容
|
|
6
|
+
'''
|
|
7
|
+
|
|
8
|
+
import datetime
|
|
9
|
+
import inspect
|
|
10
|
+
import functools
|
|
11
|
+
from typing import Dict, Any, Tuple, Literal
|
|
12
|
+
from .engine import OSISEngine
|
|
13
|
+
|
|
14
|
+
def osis_run(strCmd: str="", mode: Literal["stash", "exec"]="exec") -> Tuple[bool, str, Any]:
|
|
15
|
+
'''
|
|
16
|
+
直接以命令流的形式运行OSIS功能
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
strCmd: 完整的命令流
|
|
20
|
+
mode: 运行模式,此参数为了同时执行多条命令提高效率
|
|
21
|
+
* 使用 stash 仅会将命令流存到OSIS中,不会执行
|
|
22
|
+
* 收到 exec 信号才会执行暂存包括当前的所有命令流。
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
tuple (bool, str, Any): 是否成功,失败原因,其他结果数据
|
|
26
|
+
'''
|
|
27
|
+
e = OSISEngine.GetInstance()
|
|
28
|
+
return e.OSIS_Run(strCmd, mode)
|
|
29
|
+
|
|
30
|
+
def _log(text, filename="pyosis.log"):
|
|
31
|
+
"""简单的日志函数"""
|
|
32
|
+
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
33
|
+
with open(filename, 'a', encoding='utf-8') as f:
|
|
34
|
+
f.write(f"[{timestamp}] {text}\n")
|
|
35
|
+
f.close()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class OSISFunctionRegistry:
|
|
39
|
+
"""
|
|
40
|
+
OSIS函数注册表.通过装饰器注册函数,可指定命令流名称
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
Attributes:
|
|
44
|
+
commands (dict): 存储所有注册的命令,键为命令流名称,值为对应的函数
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
>>> REGISTRY = OSISFunctionRegistry()
|
|
48
|
+
>>>
|
|
49
|
+
>>> @REGISTRY.register("BdGrp")
|
|
50
|
+
... def boundary_group(name, op, params=None): # 函数名写全名便于人和**AI**理解
|
|
51
|
+
... '''边界组操作'''
|
|
52
|
+
... pass
|
|
53
|
+
>>>
|
|
54
|
+
>>> # 调用函数会自动转换为命令字符串
|
|
55
|
+
>>> result = boundary_group(2, "a", [2, 3, 5, "8to10"]) # 会自动组装成 “ BdGrp,2,a,2,3,5,8to10; ” 并发给OSIS执行
|
|
56
|
+
>>> print(result)
|
|
57
|
+
(True, "")
|
|
58
|
+
>>>
|
|
59
|
+
>>> @REGISTRY.register("test")
|
|
60
|
+
... def test_func(a: str, b: bool, c: float, d: int=None):
|
|
61
|
+
... '''示例'''
|
|
62
|
+
... pass
|
|
63
|
+
>>> test_func("name", True, 1.0, None) # 组装成 test,name,1,1.0; # 参数值为None会被忽略
|
|
64
|
+
>>> test_func("name", True, "", 1) # 组装成 test,name,1,,1; # 需要空参数忽略参数类型填一个空字符串: ""
|
|
65
|
+
>>>
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
def __init__(self):
|
|
71
|
+
self.commands = {} # func_name -> info
|
|
72
|
+
self.run_mode = "stash" # 命令处理模式,默认暂存
|
|
73
|
+
|
|
74
|
+
def register(self, cmd_name=None):
|
|
75
|
+
"""
|
|
76
|
+
注册函数装饰器
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
cmd_name: 命令别名,不提供则使用函数名
|
|
80
|
+
"""
|
|
81
|
+
def decorator(func):
|
|
82
|
+
name = cmd_name or func.__name__
|
|
83
|
+
|
|
84
|
+
# 保存函数信息
|
|
85
|
+
self.commands[func.__name__] = {
|
|
86
|
+
'func': func,
|
|
87
|
+
'name': func.__name__,
|
|
88
|
+
'cmd_name': name,
|
|
89
|
+
'doc': func.__doc__ or '',
|
|
90
|
+
'module': func.__module__
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# 创建包装函数
|
|
94
|
+
@functools.wraps(func)
|
|
95
|
+
def wrapper(*args, **kwargs): # 函数执行时,都会走这个路径
|
|
96
|
+
# 包装参数
|
|
97
|
+
cmd = self._process_arguments(func, cmd_name, *args, **kwargs)
|
|
98
|
+
# 发送到软件
|
|
99
|
+
return self._execute_command(cmd)
|
|
100
|
+
|
|
101
|
+
return wrapper
|
|
102
|
+
|
|
103
|
+
return decorator
|
|
104
|
+
|
|
105
|
+
def _process_arguments(self, func, cmd_name, *args, **kwargs):
|
|
106
|
+
"""处理参数并生成命令字符串"""
|
|
107
|
+
|
|
108
|
+
# 获取函数签名
|
|
109
|
+
sig = inspect.signature(func)
|
|
110
|
+
|
|
111
|
+
# 绑定用户参数
|
|
112
|
+
try:
|
|
113
|
+
bound = sig.bind(*args, **kwargs)
|
|
114
|
+
bound.apply_defaults()
|
|
115
|
+
except TypeError as e:
|
|
116
|
+
raise ValueError(f"参数错误: {e}")
|
|
117
|
+
|
|
118
|
+
# 收集参数值
|
|
119
|
+
param_values = []
|
|
120
|
+
|
|
121
|
+
for param_name, param in sig.parameters.items(): # 参数值为空字符串时会加一个空的参数
|
|
122
|
+
value = bound.arguments[param_name]
|
|
123
|
+
|
|
124
|
+
# 自动展开list/tuple
|
|
125
|
+
if isinstance(value, (list, tuple)):
|
|
126
|
+
for item in value:
|
|
127
|
+
param_values.append(str(item))
|
|
128
|
+
# 自动展开dict,只取值
|
|
129
|
+
elif isinstance(value, dict):
|
|
130
|
+
for val in value.values():
|
|
131
|
+
param_values.append(str(val))
|
|
132
|
+
elif isinstance(value, bool):
|
|
133
|
+
param_values.append(str(int(value)))
|
|
134
|
+
elif value is None:
|
|
135
|
+
# 参数值为空字符串时会加一个空的参数
|
|
136
|
+
# 如果希望生成 cmd,a,b,,d;的命令格式,c参数需要忽略参数类型填写空字符串:""
|
|
137
|
+
# param_values.append("") # 加一个空字符串
|
|
138
|
+
continue # 如果为None则跳过解析
|
|
139
|
+
else:
|
|
140
|
+
# 普通值
|
|
141
|
+
param_values.append(str(value))
|
|
142
|
+
|
|
143
|
+
# 生成命令字符
|
|
144
|
+
return f"{cmd_name},{','.join(param_values)};" if len(param_values) != 0 else f"{cmd_name};"
|
|
145
|
+
|
|
146
|
+
def _execute_command(self, cmd) -> Tuple[bool, str, Any]:
|
|
147
|
+
"""执行命令(发送到软件)"""
|
|
148
|
+
_log(cmd)
|
|
149
|
+
return osis_run(cmd, self.run_mode)
|
|
150
|
+
|
|
151
|
+
def list_commands(self):
|
|
152
|
+
"""列出所有命令"""
|
|
153
|
+
for cmd_name, info in self.commands.items():
|
|
154
|
+
print(f"{cmd_name}: {info['doc'].split(chr(10))[0] if info['doc'] else '无描述'}")
|
|
155
|
+
|
|
156
|
+
def get_command(self, cmd_name):
|
|
157
|
+
"""获取函数信息"""
|
|
158
|
+
return self.commands.get(cmd_name)
|
|
159
|
+
|
|
160
|
+
def count_command(self):
|
|
161
|
+
"""计算总共多少个函数"""
|
|
162
|
+
return len(self.commands)
|
|
163
|
+
|
|
164
|
+
def set_run_mode(self, mode: Literal["stash", "exec"]="exec"):
|
|
165
|
+
'''设置命令运行模式,默认是暂存,可以提高性能'''
|
|
166
|
+
self.mode = mode
|
|
167
|
+
|
|
168
|
+
# 全局函数注册表实例
|
|
169
|
+
REGISTRY = OSISFunctionRegistry() # 作用为提供python函数和命令流的映射关系,保证参数个数与顺序正常,python函数一定要注册一下
|
|
170
|
+
|
|
171
|
+
def set_run_mode(mode: Literal["stash", "exec"]="exec"):
|
|
172
|
+
'''
|
|
173
|
+
设置全局命令运行模式,默认是暂存,可以提高性能
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
mode: 运行模式,此参数为了同时执行多条命令提高效率
|
|
177
|
+
* 使用 stash 仅会将命令流存到OSIS中,不会执行
|
|
178
|
+
* 收到 exec 信号才会执行暂存包括当前的所有命令流。
|
|
179
|
+
'''
|
|
180
|
+
REGISTRY.set_run_mode(mode)
|
pyosis/core/engine.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
# 查找dll路径
|
|
5
|
+
current_dir =os.path.dirname(os.path.abspath(__file__))
|
|
6
|
+
# dll_dir= os.path.abspath(os.path.join(current_dir, "../../../../bin64"))
|
|
7
|
+
|
|
8
|
+
if os.path.exists(os.path.join(current_dir, "PyInterface.pyi")):
|
|
9
|
+
from PyInterface import PyInterface as OSISEngine # 如果有pyi,认为pyd已经被找到了,直接导入就行
|
|
10
|
+
else:
|
|
11
|
+
from .PyInterface import PyInterface as OSISEngine # 如果没有pyi,认为只是简单实验下能不能跑,不用打开pyd
|
|
12
|
+
|
|
13
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .interface import *
|