cloudpss 4.1.1b8__py3-none-any.whl → 4.5.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.
- cloudpss/__init__.py +2 -3
- cloudpss/asyncio/__init__.py +8 -0
- cloudpss/asyncio/job/__init__.py +5 -0
- cloudpss/asyncio/job/job.py +116 -0
- cloudpss/asyncio/job/messageStreamReceiver.py +121 -0
- cloudpss/asyncio/job/messageStreamSender.py +45 -0
- cloudpss/asyncio/model/__init__.py +5 -0
- cloudpss/asyncio/model/model.py +257 -0
- cloudpss/asyncio/model/revision.py +41 -0
- cloudpss/asyncio/model/topology.py +34 -0
- cloudpss/asyncio/utils/__init__.py +6 -0
- cloudpss/{utils → asyncio/utils}/httpAsyncRequest.py +2 -2
- cloudpss/function/functionExecution.py +36 -3
- cloudpss/ieslab/DataManageModel.py +131 -9
- cloudpss/ieslab/EvaluationModel.py +80 -9
- cloudpss/ieslab/IESLabOpt.py +235 -0
- cloudpss/ieslab/IESLabPlan.py +82 -4
- cloudpss/ieslab/IESLabSimulation.py +59 -32
- cloudpss/ieslab/PlanModel.py +276 -33
- cloudpss/ieslab/__init__.py +2 -1
- cloudpss/job/job.py +136 -141
- cloudpss/job/jobReceiver.py +8 -2
- cloudpss/job/messageStreamReceiver.py +42 -99
- cloudpss/job/messageStreamSender.py +5 -42
- cloudpss/job/{view/EMTView.py → result/EMTResult.py} +11 -13
- cloudpss/job/result/IESLabSimulationResult.py +5 -0
- cloudpss/job/result/IESLabTypicalDayResult.py +136 -0
- cloudpss/job/{view/IESView.py → result/IESResult.py} +2 -2
- cloudpss/job/{view/PowerFlowView.py → result/PowerFlowResult.py} +2 -2
- cloudpss/job/result/__init__.py +39 -0
- cloudpss/job/{view/view.py → result/result.py} +37 -8
- cloudpss/model/implements/diagram.py +113 -0
- cloudpss/model/jobDefinitions.py +6 -6
- cloudpss/model/model.py +232 -209
- cloudpss/model/revision.py +30 -35
- cloudpss/model/topology.py +13 -15
- cloudpss/runner/IESLabEvaluationResult.py +14 -6
- cloudpss/runner/IESLabPlanResult.py +91 -35
- cloudpss/runner/IESLabTypicalDayResult.py +62 -50
- cloudpss/runner/MessageStreamReceiver.py +5 -100
- cloudpss/runner/result.py +6 -1
- cloudpss/runner/runner.py +77 -48
- cloudpss/utils/IO.py +1 -1
- cloudpss/utils/graphqlUtil.py +3 -2
- cloudpss/utils/httprequests.py +16 -8
- cloudpss/version.py +1 -1
- {cloudpss-4.1.1b8.dist-info → cloudpss-4.5.0.dist-info}/METADATA +2 -2
- cloudpss-4.5.0.dist-info/RECORD +70 -0
- cloudpss/dslab/__init__.py +0 -2
- cloudpss/dslab/dataManageModel.py +0 -275
- cloudpss/dslab/dslab.py +0 -210
- cloudpss/dslab/files/__init__.py +0 -2
- cloudpss/dslab/files/curveData.py +0 -140229
- cloudpss/dslab/files/files.py +0 -27
- cloudpss/dslab/financialAnalysisModel.py +0 -137
- cloudpss/job/jobMachine.py +0 -11
- cloudpss/job/jobPolicy.py +0 -129
- cloudpss/job/jobQueue.py +0 -14
- cloudpss/job/jobTres.py +0 -6
- cloudpss/job/view/IESLabSimulationView.py +0 -5
- cloudpss/job/view/IESLabTypicalDayView.py +0 -27
- cloudpss/job/view/__init__.py +0 -42
- cloudpss/runner/DSLabResult.py +0 -92
- cloudpss-4.1.1b8.dist-info/RECORD +0 -71
- /cloudpss/{utils → asyncio/utils}/AsyncIterable.py +0 -0
- {cloudpss-4.1.1b8.dist-info → cloudpss-4.5.0.dist-info}/WHEEL +0 -0
- {cloudpss-4.1.1b8.dist-info → cloudpss-4.5.0.dist-info}/top_level.txt +0 -0
| @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            import copy
         | 
| 2 2 | 
             
            import uuid
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            from . | 
| 5 | 
            -
            class  | 
| 3 | 
            +
            from deprecated import deprecated
         | 
| 4 | 
            +
            from .result import Result
         | 
| 5 | 
            +
            class EMTResult(Result):
         | 
| 6 6 | 
             
                """
         | 
| 7 7 | 
             
                    电磁暂态结果视图, 
         | 
| 8 8 |  | 
| @@ -36,7 +36,7 @@ class EMTView(View): | |
| 36 36 |  | 
| 37 37 | 
             
                def getPlot(self, index: int):
         | 
| 38 38 | 
             
                    '''
         | 
| 39 | 
            -
                         | 
| 39 | 
            +
                        获取指定序号的曲线分组
         | 
| 40 40 |  | 
| 41 41 | 
             
                        :params: index 图表位置
         | 
| 42 42 |  | 
| @@ -100,12 +100,13 @@ class EMTView(View): | |
| 100 100 | 
             
                    else:
         | 
| 101 101 | 
             
                        raise Exception('sender is None')
         | 
| 102 102 |  | 
| 103 | 
            +
                
         | 
| 103 104 | 
             
                def writeShm(self,path,buffer,offset):
         | 
| 104 105 | 
             
                    """
         | 
| 105 | 
            -
                        写内存接口
         | 
| 106 | 
            +
                        写内存接口 (未最终确定,后续版本进行修改,使用时注意版本)
         | 
| 106 107 | 
             
                    """
         | 
| 107 108 | 
             
                    if self._sender is not None:
         | 
| 108 | 
            -
                        self._sender.write({'type': 'memory', 'path': path,' | 
| 109 | 
            +
                        self._sender.write({'type': 'memory', 'path': path,'buffer':buffer,'offset':offset})
         | 
| 109 110 | 
             
                    else:
         | 
| 110 111 | 
             
                        raise Exception('transmitter is None')
         | 
| 111 112 |  | 
| @@ -136,7 +137,6 @@ class EMTView(View): | |
| 136 137 |  | 
| 137 138 | 
             
                    self._writeEvent('time','-1','1',{'SimuCtrl': eventData})
         | 
| 138 139 |  | 
| 139 | 
            -
                    
         | 
| 140 140 | 
             
                def _snapshotControl(self,ctrlType,snapshotNumber,log):
         | 
| 141 141 | 
             
                    """
         | 
| 142 142 | 
             
                        断面控制
         | 
| @@ -151,8 +151,7 @@ class EMTView(View): | |
| 151 151 | 
             
                    }
         | 
| 152 152 | 
             
                    eventData = {}
         | 
| 153 153 | 
             
                    eventData = {'SnapshotCtrl': param}
         | 
| 154 | 
            -
                    self._writeEvent('time','-1','1',{'SnapshotCtrl': eventData})
         | 
| 155 | 
            -
                    
         | 
| 154 | 
            +
                    self._writeEvent('time','-1','1',{'SnapshotCtrl': eventData})  
         | 
| 156 155 | 
             
                def saveSnapshot(self,snapshotNumber,log='保存断面成功'):
         | 
| 157 156 | 
             
                    """
         | 
| 158 157 | 
             
                        通过事件链保存断面
         | 
| @@ -164,7 +163,6 @@ class EMTView(View): | |
| 164 163 | 
             
                    """
         | 
| 165 164 | 
             
                    self._snapshotControl('1',snapshotNumber,log)
         | 
| 166 165 |  | 
| 167 | 
            -
             | 
| 168 166 | 
             
                def control(self,controlParam,eventTime='-1',eventTimeType='1'):
         | 
| 169 167 | 
             
                    """
         | 
| 170 168 | 
             
                        控制仿真
         | 
| @@ -190,10 +188,10 @@ class EMTView(View): | |
| 190 188 |  | 
| 191 189 | 
             
                def monitor(self,monitorParam,eventTime='-1',eventTimeType='1'):
         | 
| 192 190 |  | 
| 193 | 
            -
                    if type( | 
| 194 | 
            -
                         | 
| 191 | 
            +
                    if type(monitorParam) is not list:
         | 
| 192 | 
            +
                        monitorParam=[monitorParam]
         | 
| 195 193 | 
             
                    para={}
         | 
| 196 | 
            -
                    for param in  | 
| 194 | 
            +
                    for param in monitorParam:
         | 
| 197 195 | 
             
                        para[param['key']]={
         | 
| 198 196 | 
             
                            'a': {
         | 
| 199 197 | 
             
                                'uuid':param['uuid'] if param.get('uuid',None) is not None else str(uuid.uuid1()),
         | 
| @@ -0,0 +1,136 @@ | |
| 1 | 
            +
            from .IESResult import IESResult
         | 
| 2 | 
            +
            import re
         | 
| 3 | 
            +
            import copy
         | 
| 4 | 
            +
            class IESLabTypicalDayResult(IESResult):
         | 
| 5 | 
            +
                
         | 
| 6 | 
            +
                def __init__(self, *args, **kwargs):
         | 
| 7 | 
            +
                    """
         | 
| 8 | 
            +
                        初始化
         | 
| 9 | 
            +
                    """
         | 
| 10 | 
            +
                    IESResult.__init__(self, *args, **kwargs)
         | 
| 11 | 
            +
                    self.__plotIndex = 0
         | 
| 12 | 
            +
                    self.__typicalIndex = 0
         | 
| 13 | 
            +
                    self.__type_list =['电负荷', '热负荷','冷负荷','总辐射','散射辐射', '直射辐射',  '天顶角', '环境温度', '土壤温度', '10m风速', '50m风速', '建筑物高度风速', '风机高度风速']
         | 
| 14 | 
            +
                    self.result = {'TypicalMonth': [],'TypicalDay': []}
         | 
| 15 | 
            +
                    for i in range(12):
         | 
| 16 | 
            +
                        self.result['TypicalMonth'].append({'月份': int, '持续天数': [],'电负荷': [], '热负荷': [],'冷负荷':[],'总辐射': [],'直射辐射': [],'散射辐射': [],'天顶角': [],
         | 
| 17 | 
            +
                                                            '环境温度': [], '土壤温度': [], '建筑物高度风速': [], '风机高度风速': [],'10m风速': [], '50m风速': [] })
         | 
| 18 | 
            +
                def __readPlotResult(self):
         | 
| 19 | 
            +
                    length = self.getMessageLength()
         | 
| 20 | 
            +
                    if (length > self.__plotIndex):
         | 
| 21 | 
            +
                        for num in range(self.__plotIndex, length):# update TypicalMonth
         | 
| 22 | 
            +
                            val = self.getMessage(num)
         | 
| 23 | 
            +
                            if val['type'] == 'plot':
         | 
| 24 | 
            +
                                key_list = re.split('-month',val['key'])#分别为类型和月份
         | 
| 25 | 
            +
                                # print(key_list)
         | 
| 26 | 
            +
                                self.result['TypicalMonth'][int(key_list[1])-1]['月份'] = int(key_list[1])
         | 
| 27 | 
            +
                                if key_list[0] in ['总辐射','散射辐射']:#从第一类数据中分析每个月各个典型日的天数
         | 
| 28 | 
            +
                                    typicalNum = len(val['data']['traces'])
         | 
| 29 | 
            +
                                    for i in range(typicalNum):
         | 
| 30 | 
            +
                                        self.result['TypicalMonth'][int(key_list[1])-1]['持续天数'].append(int(re.findall('\d+',val['data']['traces'][i]['name'])[1]))
         | 
| 31 | 
            +
                                # 每个月各类型数据的各个典型日的数据,由于部分月份可能没有电冷热负荷,某月的某个典型日可能缺少冷热负荷
         | 
| 32 | 
            +
                                for i in range(typicalNum):
         | 
| 33 | 
            +
                                    self.result['TypicalMonth'][int(key_list[1])-1][key_list[0]].append([])
         | 
| 34 | 
            +
                                for i in range(len(val['data']['traces'])):
         | 
| 35 | 
            +
                                    self.result['TypicalMonth'][int(key_list[1])-1][key_list[0]][int(re.findall('\d+',val['data']['traces'][i]['name'])[0])-1] = copy.deepcopy(val['data']['traces'][i]['y'])
         | 
| 36 | 
            +
                        self.__plotIndex = length
         | 
| 37 | 
            +
                        # update TypicalDay based on TypicalMonth
         | 
| 38 | 
            +
                        for m in range(12):
         | 
| 39 | 
            +
                            for i in range(len(self.result['TypicalMonth'][m]['持续天数'])):
         | 
| 40 | 
            +
                                self.result['TypicalDay'].append({'info':{'typicalDayID': int, 'name': str, 'duration': int, 'maxElectricalLoad': 0.0, 'maxHeatLoad': 0.0, 'maxCoolLoad': 0.0}, 
         | 
| 41 | 
            +
                                                                  'data': {'电负荷': [], '热负荷': [],'冷负荷':[],'总辐射': [],'直射辐射': [],'散射辐射': [],'天顶角': [],
         | 
| 42 | 
            +
                                                                           '环境温度': [], '土壤温度': [], '建筑物高度风速': [], '风机高度风速': [],'10m风速': [], '50m风速': []}})
         | 
| 43 | 
            +
                                self.result['TypicalDay'][-1]['info']['typicalDayID'] = self.__typicalIndex
         | 
| 44 | 
            +
                                self.result['TypicalDay'][-1]['info']['name'] = str(m+1) + '月典型日' + str(i+1)
         | 
| 45 | 
            +
                                self.result['TypicalDay'][-1]['info']['duration'] = self.result['TypicalMonth'][m]['持续天数'][i]
         | 
| 46 | 
            +
                                if self.result['TypicalMonth'][m]['电负荷']:
         | 
| 47 | 
            +
                                    if self.result['TypicalMonth'][m]['电负荷'][i]:
         | 
| 48 | 
            +
                                        self.result['TypicalDay'][-1]['info']['maxElectricalLoad'] = max(self.result['TypicalMonth'][m]['电负荷'][i])
         | 
| 49 | 
            +
                                if self.result['TypicalMonth'][m]['热负荷']:
         | 
| 50 | 
            +
                                    if self.result['TypicalMonth'][m]['热负荷'][i]:
         | 
| 51 | 
            +
                                        self.result['TypicalDay'][-1]['info']['maxHeatLoad'] = max(self.result['TypicalMonth'][m]['热负荷'][i])
         | 
| 52 | 
            +
                                if self.result['TypicalMonth'][m]['冷负荷']:
         | 
| 53 | 
            +
                                    if self.result['TypicalMonth'][m]['冷负荷'][i]:
         | 
| 54 | 
            +
                                        self.result['TypicalDay'][-1]['info']['maxCoolLoad'] = max(self.result['TypicalMonth'][m]['冷负荷'][i])
         | 
| 55 | 
            +
                                for type_i in self.__type_list:
         | 
| 56 | 
            +
                                    if self.result['TypicalMonth'][m][type_i]:
         | 
| 57 | 
            +
                                        self.result['TypicalDay'][-1]['data'][type_i] = self.result['TypicalMonth'][m][type_i][i]
         | 
| 58 | 
            +
                                self.__typicalIndex += 1
         | 
| 59 | 
            +
                def GetTypical(self):
         | 
| 60 | 
            +
                    '''
         | 
| 61 | 
            +
                        获取所有的 GetTypical 典型日数据
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                        >>> result.GetTypical()
         | 
| 64 | 
            +
                        {...}
         | 
| 65 | 
            +
                    '''
         | 
| 66 | 
            +
                    self.__readPlotResult()
         | 
| 67 | 
            +
                    return self.result['TypicalDay']
         | 
| 68 | 
            +
                def GetTypicalDayNum(self):
         | 
| 69 | 
            +
                    '''
         | 
| 70 | 
            +
                        获取当前result的典型日数量
         | 
| 71 | 
            +
                        
         | 
| 72 | 
            +
                        :return: int类型,代表典型日数量
         | 
| 73 | 
            +
                    '''
         | 
| 74 | 
            +
                    
         | 
| 75 | 
            +
                    self.__readPlotResult()
         | 
| 76 | 
            +
                    return self.__typicalIndex
         | 
| 77 | 
            +
                def GetTypicalDayInfo(self,dayID):
         | 
| 78 | 
            +
                    '''
         | 
| 79 | 
            +
                        获取dayID对应典型日的基础信息
         | 
| 80 | 
            +
                        
         | 
| 81 | 
            +
                        :params: dayID int类型,表示典型日的ID,数值位于 0~典型日数量 之间
         | 
| 82 | 
            +
                        
         | 
| 83 | 
            +
                        :return: dict类型,代表典型日的基础信息,包括典型日所代表的日期范围、典型日的名称等
         | 
| 84 | 
            +
                    '''
         | 
| 85 | 
            +
                    self.__readPlotResult()
         | 
| 86 | 
            +
                    return self.result['TypicalDay'][dayID].get('info','没有该数据')
         | 
| 87 | 
            +
                    
         | 
| 88 | 
            +
                def GetTypicalDayCurve(self,dayID, dataType):
         | 
| 89 | 
            +
                    '''
         | 
| 90 | 
            +
                        获取dayID对应典型日下dataType参数的时序曲线
         | 
| 91 | 
            +
                        
         | 
| 92 | 
            +
                        :params: dayID int类型,表示典型日的ID,数值位于 0~典型日数量 之间
         | 
| 93 | 
            +
                        :params: dataType enum类型,标识辐照强度、环境温度、土壤温度、建筑物高度风速、风机高度风速、电负荷、热负荷、冷负荷的参数类型
         | 
| 94 | 
            +
                        
         | 
| 95 | 
            +
                        :return: list<float>类型,代表以1h为时间间隔的该参数的日内时序曲线
         | 
| 96 | 
            +
                    '''
         | 
| 97 | 
            +
                    self.__readPlotResult()
         | 
| 98 | 
            +
                    return self.result['TypicalDay'][dayID]['data'].get(dataType,'没有该类型数据')
         | 
| 99 | 
            +
                
         | 
| 100 | 
            +
                def GetTypicalMonth(self):
         | 
| 101 | 
            +
                    '''
         | 
| 102 | 
            +
                        获取所有的 GetTypicalMonth 数据
         | 
| 103 | 
            +
                        
         | 
| 104 | 
            +
                        >>> result.GetTypicalMonth()
         | 
| 105 | 
            +
                        
         | 
| 106 | 
            +
                        :return: list<dict>类型,代表各月各类型的典型日数据
         | 
| 107 | 
            +
                    '''
         | 
| 108 | 
            +
                    self.__readPlotResult()
         | 
| 109 | 
            +
                    return self.result['TypicalMonth']
         | 
| 110 | 
            +
                
         | 
| 111 | 
            +
                def GetTypicalMonthNum(self,monthID):
         | 
| 112 | 
            +
                    '''
         | 
| 113 | 
            +
                        获取第monthID月各类型的典型日数据
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                        >>> result.GetTypicalMonthNum()
         | 
| 116 | 
            +
                        
         | 
| 117 | 
            +
                        :params: monthID int类型,表示典型月的ID,数值位于 1-12 之间
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                        :return: dict类型,代表第monthID月各类型的典型日数据
         | 
| 120 | 
            +
                        {...}
         | 
| 121 | 
            +
                    '''
         | 
| 122 | 
            +
                    self.__readPlotResult()
         | 
| 123 | 
            +
                    return self.result['TypicalMonth'][monthID-1]
         | 
| 124 | 
            +
                    
         | 
| 125 | 
            +
                
         | 
| 126 | 
            +
                def GetTypicalMonthCurve(self,monthID, dataType):
         | 
| 127 | 
            +
                    '''
         | 
| 128 | 
            +
                        获取dayID对应典型日下dataType参数的时序曲线
         | 
| 129 | 
            +
                        
         | 
| 130 | 
            +
                        :params: monthID int类型,表示典型月的ID,数值位于 1-12 之间
         | 
| 131 | 
            +
                        :params: dataType enum类型,标识总辐射、环境温度、土壤温度、建筑物高度风速、风机高度风速、电负荷、热负荷、冷负荷的参数类型
         | 
| 132 | 
            +
                        
         | 
| 133 | 
            +
                        :return: list<list>类型,代表以1h为时间间隔的该参数的典型日内时序曲线
         | 
| 134 | 
            +
                    '''
         | 
| 135 | 
            +
                    self.__readPlotResult()
         | 
| 136 | 
            +
                    return self.result['TypicalMonth'][monthID-1].get(dataType,'没有该类型数据')
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            from .IESResult import IESResult
         | 
| 2 | 
            +
            from .result import Result
         | 
| 3 | 
            +
            from .EMTResult import EMTResult
         | 
| 4 | 
            +
            from .PowerFlowResult import PowerFlowResult
         | 
| 5 | 
            +
            from .IESLabSimulationResult import IESLabSimulationResult
         | 
| 6 | 
            +
            from .IESLabTypicalDayResult import IESLabTypicalDayResult
         | 
| 7 | 
            +
            from ..messageStreamReceiver import MessageStreamReceiver
         | 
| 8 | 
            +
            from ..messageStreamSender import MessageStreamSender
         | 
| 9 | 
            +
            __all__ = [
         | 
| 10 | 
            +
                'Result','EMTResult','PowerFlowResult','IESLabSimulationResult','IESResult','IESLabTypicalDayResult','MessageStreamReceiver','MessageStreamSender'
         | 
| 11 | 
            +
            ]
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            RESULT = {
         | 
| 14 | 
            +
                'function/CloudPSS/emtp': EMTResult,
         | 
| 15 | 
            +
                'function/CloudPSS/emtps': EMTResult,
         | 
| 16 | 
            +
                'function/CloudPSS/sfemt': EMTResult,
         | 
| 17 | 
            +
                'function/CloudPSS/power-flow': PowerFlowResult,
         | 
| 18 | 
            +
                'function/CloudPSS/ies-simulation': IESResult,
         | 
| 19 | 
            +
                'function/CloudPSS/ies-optimization': IESResult,
         | 
| 20 | 
            +
                'function/ies/ies-optimization': IESResult,
         | 
| 21 | 
            +
                'function/CloudPSS/three-phase-powerFlow': PowerFlowResult,
         | 
| 22 | 
            +
                'function/ies/ies-simulation': IESLabSimulationResult,
         | 
| 23 | 
            +
                'function/ies/ies-gmm':IESLabTypicalDayResult,
         | 
| 24 | 
            +
                'function/CloudPSS/ieslab-simulation': IESLabSimulationResult,
         | 
| 25 | 
            +
                'function/CloudPSS/ieslab-gmm':IESLabTypicalDayResult,
         | 
| 26 | 
            +
                'function/CloudPSS/ieslab-optimization': IESResult,
         | 
| 27 | 
            +
            }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
             | 
| 30 | 
            +
            def getResultClass(rid: str) -> Result:
         | 
| 31 | 
            +
                """
         | 
| 32 | 
            +
                获取仿真结果视图
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                :param rid: 仿真任务的 rid
         | 
| 35 | 
            +
                :param db: 仿真任务的数据库
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                :return: 仿真结果视图
         | 
| 38 | 
            +
                """
         | 
| 39 | 
            +
                return RESULT.get(rid, Result)
         | 
| @@ -1,10 +1,11 @@ | |
| 1 1 |  | 
| 2 2 |  | 
| 3 | 
            +
            import sys
         | 
| 4 | 
            +
            from deprecated import deprecated
         | 
| 3 5 | 
             
            from ..messageStreamSender import MessageStreamSender
         | 
| 4 6 | 
             
            from ..messageStreamReceiver import MessageStreamReceiver
         | 
| 5 7 |  | 
| 6 | 
            -
             | 
| 7 | 
            -
            class View(object):
         | 
| 8 | 
            +
            class Result(object):
         | 
| 8 9 | 
             
                """
         | 
| 9 10 | 
             
                    结果视图基类,提供基础的结果获取接口
         | 
| 10 11 | 
             
                """
         | 
| @@ -18,7 +19,7 @@ class View(object): | |
| 18 19 | 
             
                    self.__logsIndex = 0
         | 
| 19 20 |  | 
| 20 21 | 
             
                async def receive(self):
         | 
| 21 | 
            -
                    async for msg in self._receiver | 
| 22 | 
            +
                    async for msg in self._receiver:
         | 
| 22 23 | 
             
                        yield msg
         | 
| 23 24 |  | 
| 24 25 | 
             
                def __len__(self):
         | 
| @@ -33,7 +34,10 @@ class View(object): | |
| 33 34 |  | 
| 34 35 | 
             
                    for key, val in dict1.items():
         | 
| 35 36 | 
             
                        if type(val) is dict:
         | 
| 36 | 
            -
                             | 
| 37 | 
            +
                            if type(dict2) is dict and dict2.get(key, None) is None:
         | 
| 38 | 
            +
                                dict2[key] = val
         | 
| 39 | 
            +
                            else:
         | 
| 40 | 
            +
                                self.__deepModify(val, dict2[key])
         | 
| 37 41 | 
             
                        else:
         | 
| 38 42 | 
             
                            dict2[key] = val
         | 
| 39 43 |  | 
| @@ -123,12 +127,37 @@ class View(object): | |
| 123 127 | 
             
                        self.__logsIndex = length
         | 
| 124 128 | 
             
                    return result
         | 
| 125 129 |  | 
| 130 | 
            +
                def getMessageLength(self):
         | 
| 131 | 
            +
                    """
         | 
| 132 | 
            +
                        获取消息数据的长度
         | 
| 133 | 
            +
             | 
| 134 | 
            +
                        :returns: 消息数据的长度
         | 
| 135 | 
            +
                    """
         | 
| 136 | 
            +
                    return len(self._receiver.messages)
         | 
| 137 | 
            +
                    
         | 
| 138 | 
            +
                
         | 
| 139 | 
            +
                def waitFor(self,timeOut=sys.maxsize):
         | 
| 140 | 
            +
                    """
         | 
| 141 | 
            +
                        阻塞方法,直到任务完成
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                        :params timeOut: 超时时间
         | 
| 144 | 
            +
                    """
         | 
| 145 | 
            +
                    return self._receiver.waitFor(timeOut)
         | 
| 126 146 |  | 
| 127 147 | 
             
                @property
         | 
| 128 | 
            -
                 | 
| 148 | 
            +
                @deprecated(version='3.0', reason="该方法将在 5.0 版本移除")
         | 
| 149 | 
            +
                def db(self):
         | 
| 129 150 | 
             
                    """
         | 
| 130 | 
            -
                         | 
| 151 | 
            +
                        获取数据库对象
         | 
| 131 152 |  | 
| 132 | 
            -
                        :returns:  | 
| 153 | 
            +
                        :returns: 数据库对象
         | 
| 154 | 
            +
                    """
         | 
| 155 | 
            +
                    return self._receiver
         | 
| 156 | 
            +
                
         | 
| 157 | 
            +
                def pop(self,index=-1):
         | 
| 158 | 
            +
                    """
         | 
| 159 | 
            +
                        pop 出缓存中的消息
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                        :returns: 消息数据
         | 
| 133 162 | 
             
                    """
         | 
| 134 | 
            -
                    return self._receiver. | 
| 163 | 
            +
                    return self._receiver.messages.pop(index)
         | 
| @@ -1,4 +1,6 @@ | |
| 1 1 | 
             
            from .component import Component
         | 
| 2 | 
            +
            from typing import Optional
         | 
| 3 | 
            +
            import uuid
         | 
| 2 4 |  | 
| 3 5 |  | 
| 4 6 | 
             
            class DiagramImplement(object):
         | 
| @@ -44,3 +46,114 @@ class DiagramImplement(object): | |
| 44 46 | 
             
                    """
         | 
| 45 47 |  | 
| 46 48 | 
             
                    return self.cells
         | 
| 49 | 
            +
                
         | 
| 50 | 
            +
                def addComponent(
         | 
| 51 | 
            +
                    self,
         | 
| 52 | 
            +
                    definition: str,
         | 
| 53 | 
            +
                    label: str,
         | 
| 54 | 
            +
                    args: dict = {},
         | 
| 55 | 
            +
                    pins: dict = {},
         | 
| 56 | 
            +
                    canvas: Optional[str] = None,
         | 
| 57 | 
            +
                    position: Optional[dict] = None,
         | 
| 58 | 
            +
                    size: Optional[dict] = None,
         | 
| 59 | 
            +
                ) -> Component:
         | 
| 60 | 
            +
                    """
         | 
| 61 | 
            +
                    添加元件
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                    :param definition 元件定义, 连接线没有definition
         | 
| 64 | 
            +
                    :param label 元件标签
         | 
| 65 | 
            +
                    :param args 元件参数数据,连接线没有参数数据
         | 
| 66 | 
            +
                    :param pins 元件引脚数据,连接线没有引脚数据
         | 
| 67 | 
            +
                    :param canvas 元件所在图纸数据
         | 
| 68 | 
            +
                    :param position 元件位置数据, 连接线没有位置数据
         | 
| 69 | 
            +
                    :param size 元件大小数据,连接线没有大小数据
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                    :return: Component
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                    >>>> diagram.addComponent(args)
         | 
| 74 | 
            +
                    """
         | 
| 75 | 
            +
                    id = "comp_" + str(uuid.uuid4())
         | 
| 76 | 
            +
                    shape = "diagram-component"
         | 
| 77 | 
            +
                    definition = definition
         | 
| 78 | 
            +
                    label = label or definition
         | 
| 79 | 
            +
                    args = args.copy()
         | 
| 80 | 
            +
                    pins = pins.copy()
         | 
| 81 | 
            +
                    props = {"enabled": True}
         | 
| 82 | 
            +
                    context = {}
         | 
| 83 | 
            +
                    canvas or self.canvas[0].get("key", "canvas_0")
         | 
| 84 | 
            +
                    position = position.copy() if position else {"x": 0, "y": 0}
         | 
| 85 | 
            +
                    size = size.copy() if size else None
         | 
| 86 | 
            +
                    zIndex = 0
         | 
| 87 | 
            +
                    style = {
         | 
| 88 | 
            +
                        "--fill": "var(--spectrum-global-color-gray-100)",
         | 
| 89 | 
            +
                        "--fill-opacity": 1,
         | 
| 90 | 
            +
                        "--font-family": "var(--spectrum-global-font-family-base, Arial, Helvetica, sans-serif)",
         | 
| 91 | 
            +
                        "--stroke": "var(--spectrum-global-color-gray-900)",
         | 
| 92 | 
            +
                        "--stroke-opacity": 1,
         | 
| 93 | 
            +
                        "--stroke-width": 2,
         | 
| 94 | 
            +
                        "--text": "var(--spectrum-global-color-gray-900)",
         | 
| 95 | 
            +
                        "--text-opacity": 1,
         | 
| 96 | 
            +
                    }
         | 
| 97 | 
            +
                    diagram = {
         | 
| 98 | 
            +
                        "id": id,
         | 
| 99 | 
            +
                        "shape": shape,
         | 
| 100 | 
            +
                        "definition": definition,
         | 
| 101 | 
            +
                        "label": label,
         | 
| 102 | 
            +
                        "args": args,
         | 
| 103 | 
            +
                        "pins": pins,
         | 
| 104 | 
            +
                        "props": props,
         | 
| 105 | 
            +
                        "context": context,
         | 
| 106 | 
            +
                        "canvas": canvas,
         | 
| 107 | 
            +
                        "position": position,
         | 
| 108 | 
            +
                        "size": size,
         | 
| 109 | 
            +
                        "zIndex": zIndex,
         | 
| 110 | 
            +
                        "style": style,
         | 
| 111 | 
            +
                    }
         | 
| 112 | 
            +
                    component = Component(diagram)
         | 
| 113 | 
            +
                    self.cells[id] = component
         | 
| 114 | 
            +
                    return component
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                def removeComponent(self, key: str) -> bool:
         | 
| 117 | 
            +
                    """
         | 
| 118 | 
            +
                    删除元件
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                    :param key: str
         | 
| 121 | 
            +
                    :return: bool
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                    >>>> diagram.removeComponent(key)
         | 
| 124 | 
            +
                    """
         | 
| 125 | 
            +
                    component = self.cells.get(key)
         | 
| 126 | 
            +
                    if not component:
         | 
| 127 | 
            +
                        return False
         | 
| 128 | 
            +
                    position = component.position.copy()
         | 
| 129 | 
            +
                    del self.cells[key]
         | 
| 130 | 
            +
                    for edge in self.cells.values():
         | 
| 131 | 
            +
                        if edge.shape == "diagram-edge":
         | 
| 132 | 
            +
                            if edge.source.get("cell") == key:
         | 
| 133 | 
            +
                                edge.source = position.copy()
         | 
| 134 | 
            +
                                position["x"] += 5
         | 
| 135 | 
            +
                                position["y"] += 5
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                            if edge.target.get("cell") == key:
         | 
| 138 | 
            +
                                edge.target = position.copy()
         | 
| 139 | 
            +
                                position["x"] += 5
         | 
| 140 | 
            +
                                position["y"] += 5
         | 
| 141 | 
            +
                    return True
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                def updateComponent(self, key: str, args: dict) -> bool:
         | 
| 144 | 
            +
                    """
         | 
| 145 | 
            +
                    更新元件
         | 
| 146 | 
            +
             | 
| 147 | 
            +
                    :param key: str
         | 
| 148 | 
            +
                    :param args: dict
         | 
| 149 | 
            +
                    :return: bool
         | 
| 150 | 
            +
             | 
| 151 | 
            +
                    >>>> diagram.updateComponent(key)
         | 
| 152 | 
            +
                    """
         | 
| 153 | 
            +
                    component = self.cells.get(key)
         | 
| 154 | 
            +
                    if not component:
         | 
| 155 | 
            +
                        return False
         | 
| 156 | 
            +
                    for k, v in self.cells.items():
         | 
| 157 | 
            +
                        if k == key:
         | 
| 158 | 
            +
                            v.__dict__.update(args)
         | 
| 159 | 
            +
                            return True
         | 
    
        cloudpss/model/jobDefinitions.py
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            JOB_DEFINITIONS = {
         | 
| 2 2 | 
             
                "emtp": {
         | 
| 3 | 
            -
                    "rid": " | 
| 3 | 
            +
                    "rid": "function/CloudPSS/emtp",
         | 
| 4 4 | 
             
                    "args": {
         | 
| 5 5 | 
             
                        "debug":
         | 
| 6 6 | 
             
                        "0",
         | 
| @@ -48,7 +48,7 @@ JOB_DEFINITIONS = { | |
| 48 48 | 
             
                },
         | 
| 49 49 | 
             
                'sfemt': {
         | 
| 50 50 | 
             
                    "name": "移频电磁暂态仿真方案 1",
         | 
| 51 | 
            -
                    "rid": " | 
| 51 | 
            +
                    "rid": "function/CloudPSS/sfemt",
         | 
| 52 52 | 
             
                    "args": {
         | 
| 53 53 | 
             
                        "begin_time":
         | 
| 54 54 | 
             
                        "0",
         | 
| @@ -103,7 +103,7 @@ JOB_DEFINITIONS = { | |
| 103 103 | 
             
                },
         | 
| 104 104 | 
             
                "powerFlow": {
         | 
| 105 105 | 
             
                    "name": "潮流计算方案 1",
         | 
| 106 | 
            -
                    "rid": " | 
| 106 | 
            +
                    "rid": "function/CloudPSS/power-flow",
         | 
| 107 107 | 
             
                    "args": {
         | 
| 108 108 | 
             
                        "UseBusVoltageAsInit": "1",
         | 
| 109 109 | 
             
                        "UseBusAngleAsInit": "1",
         | 
| @@ -115,7 +115,7 @@ JOB_DEFINITIONS = { | |
| 115 115 | 
             
                },
         | 
| 116 116 | 
             
                "iesLoadPrediction": {
         | 
| 117 117 | 
             
                    "name": "负荷预测方案 1",
         | 
| 118 | 
            -
                    "rid": " | 
| 118 | 
            +
                    "rid": "function/CloudPSS/ies-load-prediction",
         | 
| 119 119 | 
             
                    "arcs": {
         | 
| 120 120 | 
             
                        "startTime": "2022 -01-01 00:00:00",
         | 
| 121 121 | 
             
                        "endTime": "2022 -12-31 23:00:00",
         | 
| @@ -128,7 +128,7 @@ JOB_DEFINITIONS = { | |
| 128 128 | 
             
                },
         | 
| 129 129 | 
             
                "iesPowerFlow": {
         | 
| 130 130 | 
             
                    "name": "时序潮流方案 1",
         | 
| 131 | 
            -
                    "rid": " | 
| 131 | 
            +
                    "rid": "function/CloudPSS/ies-power-flow",
         | 
| 132 132 | 
             
                    "arcs": {
         | 
| 133 133 | 
             
                        "startTime": "2022 -01-01 00:00:00",
         | 
| 134 134 | 
             
                        "endTime": "2022 -12-31 23:00:00",
         | 
| @@ -138,7 +138,7 @@ JOB_DEFINITIONS = { | |
| 138 138 | 
             
                },
         | 
| 139 139 | 
             
                "iesEnergyStoragePlan": {
         | 
| 140 140 | 
             
                    "name": "储能规划方案 1",
         | 
| 141 | 
            -
                    "rid": " | 
| 141 | 
            +
                    "rid": "function/CloudPSS/ies-energy-storage-plan",
         | 
| 142 142 | 
             
                    "arcs": {
         | 
| 143 143 | 
             
                        "Planyear": "15",
         | 
| 144 144 | 
             
                        "NetConfig": [],
         |