From 7df9dbb0e57f2eeb03ab7fbf7de0b9f4cd658048 Mon Sep 17 00:00:00 2001 From: Ayush Agrawal Date: Tue, 24 Dec 2019 16:27:14 +0530 Subject: Restructured the API, and the front-end --- container.py | 76 +++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 24 deletions(-) (limited to 'container.py') 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("["+str(self.currentTime())+"] "+key.name+" output is connected to input of "+value.name +" ") - - def addUnitOp(self,obj): - if(obj in self.unitOp): - pass - else: - self.unitOp.append(obj) - self.msg.append("["+str(self.currentTime())+"] "+obj.name+" is instantiated .""") - - 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("["+str(self.currentTime())+"] "+obj.name+" is instantiated .""") + + 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(""+stdout+"") 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("["+str(self.currentTime())+"] Simulating in Sequential mode ... ") f.simulateSM(self.ip,self.op) -- cgit