diff options
author | Ayush Agrawal | 2019-12-24 16:27:14 +0530 |
---|---|---|
committer | Ayush Agrawal | 2019-12-24 16:27:14 +0530 |
commit | 7df9dbb0e57f2eeb03ab7fbf7de0b9f4cd658048 (patch) | |
tree | f1dbf52ae003f6cde245c22249a6bbd54bb50f0b /container.py | |
parent | 9f86138b86efebb816a2289bf84b96d688615f41 (diff) | |
download | Chemical-Simulator-GUI-7df9dbb0e57f2eeb03ab7fbf7de0b9f4cd658048.tar.gz Chemical-Simulator-GUI-7df9dbb0e57f2eeb03ab7fbf7de0b9f4cd658048.tar.bz2 Chemical-Simulator-GUI-7df9dbb0e57f2eeb03ab7fbf7de0b9f4cd658048.zip |
Restructured the API, and the front-end
Diffstat (limited to 'container.py')
-rw-r--r-- | container.py | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/container.py b/container.py index 89fb897..dd3cf89 100644 --- a/container.py +++ b/container.py @@ -5,9 +5,22 @@ from OMChem.Heater import Heater from component_selector import * from collections import defaultdict from PyQt5.QtCore import * +from PyQt5.QtWidgets import * from PyQt5.QtGui import * +from PyQt5.uic import loadUiType +from PyQt5.QtCore import Qt +from PyQt5.QtWidgets import QGraphicsProxyWidget, QGraphicsObject, QGraphicsEllipseItem ,QGraphicsPixmapItem,QApplication, QGraphicsView, QGraphicsScene, QHBoxLayout, QWidget, QLabel +from PyQt5.QtGui import QBrush ,QTransform ,QMouseEvent +import PyQt5.QtCore as QtCore +import PyQt5.QtWidgets as QtWidgets +from dockWidget import dockWidget import datetime import itertools +import json +import pickle +import os +import sys + class Container(): def __init__(self,msgbrowser): self.unitOp = [] @@ -20,35 +33,20 @@ class Container(): self.msg.setText("") self.opl=[] self.result=[] + def currentTime(self): now = datetime.datetime.now() time = str(now.hour) + ":" + str(now.minute) + ":" +str(now.second) return time + + def updateConn(self,key,value): self.conn[key].append(value) self.msg.append("<span style=\"color:blue\">["+str(self.currentTime())+"]<b> "+key.name+" </b> output is connected to input of<b> "+value.name +" </b></span>") - - def addUnitOp(self,obj): - if(obj in self.unitOp): - pass - else: - self.unitOp.append(obj) - self.msg.append("<span style=\"color:blue\">["+str(self.currentTime())+"]<b> "+obj.name+" </b>is instantiated .""</span>") - - def fetchObject(self,name): - for i in self.unitOp: - if(i.name==name): - return i - - def addCompounds(self,comp): - self.compounds = comp - - def add_thermoPackage(self,thermo): - self.thermoPackage = thermo - + def connection(self): try: self.op.clear() @@ -71,6 +69,36 @@ class Container(): except Exception as e: print(e) + + def addUnitOp(self,obj,scene,graphics): + box = None + self.obj = obj + self.scene = scene + self.graphics = graphics + box = self.graphics.createNodeItem(self.obj) + self.scene.addItem(box) + box.setPos(2500-30, 2500-30) + + + if(obj in self.unitOp): + pass + else: + self.unitOp.append(obj) + + self.msg.append("<span style=\"color:blue\">["+str(self.currentTime())+"]<b> "+obj.name+" </b>is instantiated .""</span>") + + def fetchObject(self,name): + for i in self.unitOp: + if(i.name==name): + return i + def addCompounds(self,comp): + self.compounds = comp + + def add_thermoPackage(self,thermo): + self.thermoPackage = thermo + + + def msgBrowser(self,f): std = f.stdout.decode("utf-8") if(std): @@ -85,18 +113,18 @@ class Container(): self.msg.append("<span style=\"color:red\">"+stdout+"</span>") def simulate(self,mode): + print("SIMULATE") print(mode) self.compounds = compound_selected - self.connection() + #self.connection() f = Flowsheet() f.add_comp_list(self.compounds) print("######## connection master#########\n",self.conn) for i in self.unitOp : - if i in self.opl: print("here",i) - f.add_UnitOpn(i,1) - else: - f.add_UnitOpn(i,0) + f.add_UnitOpn(i) + + if mode=='SM': self.msg.append("<span>["+str(self.currentTime())+"] Simulating in <b>Sequential</b> mode ... </span>") f.simulateSM(self.ip,self.op) |