Skip to content

Instantly share code, notes, and snippets.

@SpyDude
Created November 12, 2011 14:19
Show Gist options
  • Save SpyDude/1360567 to your computer and use it in GitHub Desktop.
Save SpyDude/1360567 to your computer and use it in GitHub Desktop.
next gen
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#written by Yuriy Karpilov <[email protected]>
try:
import sys, pygtk
pygtk.require('2.0')
except:
print 'Не удалось импортировать модуль PyGTK'
sys.exit(1)
import gtk
import math
class Solver(object):
@staticmethod
def calctw1(tsw, condfactor):
tw1 = (tsw + condfactor)
return (tsw + condfactor)
@staticmethod
def calctw2(tw1, condfactor1):
tw2 = (tw1 + condfactor1)
return (tw1 + condfactor1)
@staticmethod
def calctk(tw1, tcondfactor):
tk = (tw1 + tcondfactor)
return (tw1 + tcondfactor)
@staticmethod
def calctlr(tk, tlroutcond):
tlr = (tk - tlroutcond)
return (tk - tlroutcond)
@staticmethod
def calctbrina(taincr, tbrinac):
tbrina = (taincr - tbrinac)
return (taincr - tbrinac)
@staticmethod
def calctrentrycompr(tbrina, trentrycomprc):
trentrycompr = (tbrina + trentrycomprc)
return (tbrina + trentrycomprc)
@staticmethod
def calcp1t(trentrycompr):
p1t = (trentrycompr)
return (trentrycompr)
@staticmethod
def calcp3t(tk):
p3t = (tk)
return (tk)
@staticmethod
def calcp4t(tlr):
p4t = (tlr)
return (tlr)
@staticmethod
def calcp5t(tbrina):
p5t = (tbrina)
return (tbrina)
@staticmethod
def calcq0(p1h, p5h):
q0 = (p1h - p5h)
return (p1h - p5h)
@staticmethod
def calcqv(q0, p1v):
qv = (q0 / p1v)
return (q0 / p1v)
@staticmethod
def calcl0(p1h, p2h):
l0 = (p2h - p1h)
return (p2h - p1h)
@staticmethod
def calcga(q0pc, q0):
ga = (3600 * q0pc / q0)
return (3600 * q0pc / q0)
@staticmethod
def calcvh(ga, p1v):
vh = (ga * p1v)
return (ga * p1v)
@staticmethod
def calcna(ga, l0):
na = (ga * l0 / 3600)
return (ga * l0 / 3600)
@staticmethod
def calcne(ga, l0):
ne = (ga * l0 / (3600*0.65))
return (ga * l0 / (3600*0.65))
@staticmethod
def calcni(ne, nifactor):
ni = (ne * nifactor)
return (ne * nifactor)
@staticmethod
def calcem(q0, l0):
em = (q0 / l0)
return (q0 / l0)
@staticmethod
def calced(q0pc, ne):
ed = (q0pc / ne)
return (q0pc / ne)
@staticmethod
def calcqk(q0pc, ni):
qk = (q0pc + 1000 * ni)
return (q0pc + 1000 * ni)
@staticmethod
def calcvcwf(qk, tw1, tw2):
vcwf = (qk / (4.187 * 1025 * (tw2 - tw1)))
return (qk / (4.187 * 1025 * (tw2 - tw1)))
@staticmethod
def calcn1(vcwf):
n1 = (4 * vcwf / (pi * (0.002 ** 2) * 1.2))
return (4 * vcwf / (pi * (0.002 ** 2) * 1.2))
@staticmethod
def calctw(tw1, tw2):
tw = (0.5 * (tw1 + tw2))
return (0.5 * (tw1 + tw2))
@staticmethod
def calctst(tw, tk):
tst = (0.5 * (tw + tk))
return (0.5 * (tw + tk))
@staticmethod
def calcb(tk):
b = (377 - (1.45 * tk))
return (377 - (1.45 * tk))
@staticmethod
def calcb(tk):
b = (377 - (1.45 * tk))
return (377 - (1.45 * tk))
class InitialData(object):
def on_window_destroy(self, widget, data=None):
gtk.main_quit()
def on_button1_clicked(self, widget, data=None):
tsw = float(self.entry_tsw.get_text())
taincr = float(self.entry_taincr.get_text())
tbrinac = self.entry_tbrinac.get_value()
condfactor = self.entry_condfactor.get_value()
condfactor1 = self.entry_condfactor1.get_value()
tcondfactor = self.entry_tcondfactor.get_value()
tlroutcond = self.entry_tlroutcond.get_value()
trentrycomprc = self.entry_trentrycompr.get_value()
tw1 = Solver.calctw1(tsw, condfactor)
text = "{0:g}".format(tw1)
self.rtcwec.set_markup(text)
tw2 = Solver.calctw2(tw1, condfactor1)
text = "{0:g}".format(tw2)
self.rtcwoc.set_markup(text)
tk = Solver.calctk(tw1, tcondfactor)
text = "{0:g}".format(tk)
self.rtcond.set_markup(text)
tlr = Solver.calctlr(tk, tlroutcond)
text="{0:g}".format(tlr)
self.rtlroutcond.set_markup(text)
tbrina = Solver.calctbrina(taincr, tbrinac)
text="{0:g}".format(tbrina)
self.rtbrina.set_markup(text)
trentrycompr = Solver.calctrentrycompr(tbrina, trentrycomprc)
text="{0:g}".format(trentrycompr)
self.rtrentrycompr.set_markup(text)
p1t = Solver.calcp1t(trentrycompr)
text="{0:g}".format(p1t)
self.rp1t.set_markup(text)
p3t = Solver.calcp3t(tk)
text="{0:g}".format(p3t)
self.rp3t.set_markup(text)
p4t = Solver.calcp4t(tlr)
text="{0:g}".format(p4t)
self.rp4t.set_markup(text)
p5t = Solver.calcp5t(tbrina)
text="{0:g}".format(p5t)
self.rp5t.set_markup(text)
def on_button2_clicked(self, widget, data=None):
p2t = float(self.entry_p2t.get_text())
p1v = float(self.entry_p1v.get_text())
p1p = float(self.entry_p1p.get_text())
p2p = float(self.entry_p2p.get_text())
p3p = float(self.entry_p3p.get_text())
p4p = float(self.entry_p4p.get_text())
p5p = float(self.entry_p5p.get_text())
p1h = float(self.entry_p1h.get_text())
p2h = float(self.entry_p2h.get_text())
p3h = float(self.entry_p3h.get_text())
p4h = float(self.entry_p4h.get_text())
p5h = float(self.entry_p5h.get_text())
q0pc = float(self.entry_q0pc.get_text()) # Cooling capacity of one compressor
q0pac = float(self.entry_q0pac.get_text()) # Cooling capacity of all compressor
lyamda = float(self.entry_lyamda.get_text())
nifactor = self.entry_nifactor.get_value()
q0 = Solver.calcq0(p1h, p5h)
text="{0:g}".format(q0)
self.rq0.set_markup(text)
qv = Solver.calcqv(q0, p1v)
text="{0:.0f}".format(qv)
self.rqv.set_markup(text)
l0 = Solver.calcl0(p1h, p2h)
text="{0:g}".format(l0)
self.rl0.set_markup(text)
ga = Solver.calcga(q0pc, q0)
text="{0:.0f}".format(ga)
self.rga.set_markup(text)
vh = Solver.calcvh(ga, p1v)
text="{0:.1f}".format(vh)
self.rvh.set_markup(text)
na = Solver.calcna(ga, l0)
text="{0:.1f}".format(na)
self.rna.set_markup(text)
ne = Solver.calcne(ga, l0)
text="{0:.1f}".format(ne)
self.rne.set_markup(text)
ni = Solver.calcni(ne, nifactor)
text="{0:.1f}".format(ni)
self.rni.set_markup(text)
em = Solver.calcem(q0, l0)
text="{0:.1f}".format(em)
self.rem.set_markup(text)
ed = Solver.calced(q0pc, ne)
text="{0:.2f}".format(ed)
self.red.set_markup(text)
def on_button3_clicked(self, widget, data=None):
q0pc = float(self.entry_q0pc.get_text())
vi = self.spin_vi.get_value()
dr = float(self.entry_dr.get_text())
rld = float(self.entry_rld.get_text())
dpmax = float(self.entry_dpmax.get_text())
rln1 = float(self.entry_rln1.get_text())
vh101 = float(self.entry_vh101.get_text())
rln2 = float(self.entry_rln2.get_text())
vh102 = float(self.entry_vh102.get_text())
r = float(self.entry_r.get_text())
qk = Solver.calcqk(q0pc, ni)
text="{0:.0f}".format(qk)
self.rqk.set_markup(text)
vcwf = Solver.calcvcwf(qk, tw1, tw2)
text="{0:.0f}".format(vcwf)
self.rvcwf.set_markup(text)
n1 = Solver.calcn1(vcwf)
text="{0:.0f}".format(n1)
self.rn1.set_markup(text)
tw = Solver.calctw(tw1, tw2)
text="{0:.1f}".format(tw)
self.rtw.set_markup(text)
tst = Solver.calctst(tw, tk)
text="{0:.1f}".format(tst)
self.rtst.set_markup(text)
b = Solver.calcb(tk)
text="{0:.1f}".format(b)
self.rb.set_markup(text)
def on_about_clicked(self, widget):
about = gtk.AboutDialog()
about.set_program_name("СХМ")
about.set_version("0.1")
about.set_copyright("(c) Karpilov Yuriy")
about.set_comments("СХМ — простой инструмент для расчета холодильной машины")
about.set_website("http://SeaMan.Net.UA")
about.set_logo(gtk.gdk.pixbuf_new_from_file("snowflakeicon.svg"))
about.run()
about.destroy()
def delete_event(self, widget, event, data=None):
print "Closing window"
return False
def destroy(self, widget, data=None):
print "Window was closed"
gtk.main_quit()
def __init__(self, parent=None):
builder = gtk.Builder()
builder.add_from_file("diplomnew.glade")
self.window = builder.get_object("window")
self.window.set_icon_from_file("iconsnowflake.png")
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.button1 = builder.get_object("button1")
self.button2 = builder.get_object("button2")
self.button3 = builder.get_object("button3")
self.entry_tsw = builder.get_object("entry_tsw")
self.entry_taincr = builder.get_object("entry_taincr")
self.entry_tlroutcond = builder.get_object("entry_tlroutcond")
self.entry_condfactor = builder.get_object("entry_condfactor")
self.entry_condfactor1 = builder.get_object("entry_condfactor1")
self.entry_tcondfactor = builder.get_object("entry_tcondfactor")
self.entry_trentrycompr = builder.get_object("entry_trentrycompr")
self.entry_tbrinac = builder.get_object("entry_tbrinac")
self.rtbrina = builder.get_object("rtbrina")
self.rtrentrycompr = builder.get_object("rtrentrycompr")
self.rtcwec = builder.get_object("rtcwec")
self.rtcwoc = builder.get_object("rtcwoc")
# On_button2_clicked
self.entry_q0pc = builder.get_object("entry_q0pc")
self.entry_q0pac = builder.get_object("entry_q0pac")
self.entry_p2t = builder.get_object("entry_p2t")
self.entry_p1v = builder.get_object("entry_p1v")
self.entry_p1p = builder.get_object("entry_p1p")
self.entry_p2p = builder.get_object("entry_p2p")
self.entry_p3p = builder.get_object("entry_p3p")
self.entry_p4p = builder.get_object("entry_p4p")
self.entry_p5p = builder.get_object("entry_p5p")
self.entry_p1h = builder.get_object("entry_p1h")
self.entry_p2h = builder.get_object("entry_p2h")
self.entry_p3h = builder.get_object("entry_p3h")
self.entry_p4h = builder.get_object("entry_p4h")
self.entry_p5h = builder.get_object("entry_p5h")
self.entry_lyamda = builder.get_object("entry_lyamda")
self.rtlroutcond = builder.get_object("rtlroutcond")
self.rtcond = builder.get_object("rtcond")
self.rp1t = builder.get_object("rp1t")
self.rp3t = builder.get_object("rp3t")
self.rp4t = builder.get_object("rp4t")
self.rp5t = builder.get_object("rp5t")
self.rq0 = builder.get_object("rq0")
self.rqv = builder.get_object("rqv")
self.rl0 = builder.get_object("rl0")
self.rga = builder.get_object("rga")
self.rvh = builder.get_object("rvh")
self.rna = builder.get_object("rna")
self.rne = builder.get_object("rne")
self.rni = builder.get_object("rni")
self.rem = builder.get_object("rem")
self.red = builder.get_object("red")
self.entry_nifactor = builder.get_object("entry_nifactor")
# On_button3_clicked
self.spin_vi = builder.get_object("spin_vi")
self.entry_dr = builder.get_object("entry_dr")
self.entry_rld = builder.get_object("entry_rld")
self.entry_dpmax = builder.get_object("entry_dpmax")
self.entry_rln1 = builder.get_object("entry_rln1")
self.entry_rln2 = builder.get_object("entry_rln2")
self.entry_vh101 = builder.get_object("entry_vh101")
self.entry_vh102 = builder.get_object("entry_vh102")
self.entry_r = builder.get_object("entry_r")
self.rqk = builder.get_object("rqk")
self.rvcwf = builder.get_object("rvcwf")
self.rn1 = builder.get_object("rn1")
self.rtw = builder.get_object("rtw")
self.rtst = builder.get_object("rtst")
self.rb = builder.get_object("rb")
builder.connect_signals(self)
if __name__ == "__main__":
calc = InitialData()
calc.window.show()
gtk.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment