Ejemplo n.º 1
0
        private void checkData()
        {
            tempdir = System.IO.Path.GetDirectoryName(dbFile) + @"\temp\" + Guid.NewGuid().ToString();
            if (!Directory.Exists(tempdir))
            {
                Directory.CreateDirectory(tempdir);
            }
            backgroundWorker.ReportProgress(5);
            PRZWriter w  = new PRZWriter();
            DataTable dt = w.copyStream(przFile, eqName);

            backgroundWorker.ReportProgress(15);
            FlashCompute flashc = new FlashCompute();

            strTray1Pressure = dt.Rows[0]["pressure"].ToString();
            if (strTray1Pressure == "")
            {
                strTray1Pressure = "0";
            }
            strTray1Pressure = UnitConverter.unitConv(strTray1Pressure, "KPA", "MPAG", "{0:0.0000}");
            backgroundWorker.ReportProgress(25);
            string strTray1Temperature = dt.Rows[0]["Temperature"].ToString();

            if (strTray1Temperature == "")
            {
                strTray1Temperature = "0";
            }
            strTray1Temperature = UnitConverter.unitConv(strTray1Temperature, "K", "C", "{0:0.0000}");


            tray1_s = dt.Rows[0]["streamname"].ToString().ToUpper();
            string gd = Guid.NewGuid().ToString();

            vapor  = "S_" + gd.Substring(0, 5).ToUpper();
            liquid = "S_" + gd.Substring(gd.Length - 5, 5).ToUpper();
            backgroundWorker.ReportProgress(30);
            string content = InpReader.getUsableContent(przFile, dt.Rows[0]["streamname"].ToString(), tempdir);

            backgroundWorker.ReportProgress(40);
            tray1_f = flashc.compute(content, 1, Prelief.ToString(), 3, "", dt.Rows[0], vapor, liquid, tempdir);
            backgroundWorker.ReportProgress(60);
            PRZReader reader = new PRZReader(tray1_f);
            DataSet   ds     = reader.getDataFromFile();

            while (ds.Tables[0].Rows[0]["temperature"].ToString() == "")
            {
                ds = reader.getDataFromFile();
            }
            backgroundWorker.ReportProgress(80);
            DBRelief dbreader = new DBRelief();

            feedH           = dbreader.computeH(ds.Tables[0], tray1_s.ToUpper());
            vaporH          = dbreader.computeH(ds.Tables[0], vapor);
            liqidH          = dbreader.computeH(ds.Tables[0], liquid);
            tempTemperature = vaporH[3];

            backgroundWorker.ReportProgress(100);
        }
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            PRZReader przReader = new PRZReader(newPrzFile);
            DataSet   ds        = przReader.getDataFromFile();
            DBRelief  dbreader  = new DBRelief();

            string[] feedH  = dbreader.computeH(ds.Tables[0], txtName.Text.Trim().ToUpper());
            string[] vaporH = dbreader.computeH(ds.Tables[0], v);
            string[] liqidH = dbreader.computeH(ds.Tables[0], l);


            lblFeedH.Content  = "FEED= " + feedH[0] + " KJ/hr";
            lblVaporH.Content = "VAPOR= " + vaporH[0] + " KJ/hr";
            lblLiqidH.Content = "LIQID= " + liqidH[0] + " KJ/hr";
            lblTest.Content   = (double.Parse(vaporH[1]) - double.Parse(liqidH[1])).ToString() + " KJ/Kg";
        }
Ejemplo n.º 3
0
        private void loadData()
        {
            DataSet  ds       = new DataSet();
            DBRelief dbreader = new DBRelief();

            dtfrmcase_feed_single    = dtfrmcase_feed.Clone();
            dtfrmcase_product_single = dtfrmcase_product.Clone();
            foreach (DataRow dr in dtfrmbasecase_feed.Rows)
            {
                DataRow drIn = dtfrmcase_feed_single.NewRow();
                drIn["SpecificEnthalpy"] = dr["SpEnthalpy"];
                drIn["FlowRate"]         = dr["weightflow"];
                drIn["StreamName"]       = dr["StreamName"];
                drIn["visiofile"]        = vsdFile;
                dtfrmcase_feed_single.Rows.Add(drIn);
            }

            int count = dtFlashResult.Rows.Count;

            for (int i = 1; i <= count; i++)
            {
                DataRow dr       = dtFlashResult.Rows[i - 1];
                string  prodtype = dr["prodtype"].ToString();
                string  tray     = dr["tray"].ToString();
                if (dr["przfile"].ToString() != "")
                {
                    PRZReader przReader = new PRZReader(dr["przfile"].ToString());
                    ds = przReader.getDataFromFile();
                    if (ds != null)
                    {
                        DataRow drout = dtfrmcase_product_single.NewRow();
                        while (ds.Tables[0].Rows[0]["temperature"].ToString() == "")
                        {
                            Thread.Sleep(10000);
                            ds = przReader.getDataFromFile();
                        }
                        dbreader = new DBRelief();
                        if (prodtype == "4" || (prodtype == "2" && tray == "1") || prodtype == "3" || prodtype == "6")
                        {
                            string[] liquidH2 = dbreader.computeH(ds.Tables[0], dr["vapor"].ToString().ToUpper());
                            drout["SpecificEnthalpy"] = liquidH2[1];
                        }
                        else
                        {
                            string[] liquidH2 = dbreader.computeH(ds.Tables[0], dr["liquid"].ToString().ToUpper());
                            drout["SpecificEnthalpy"] = liquidH2[1];
                        }


                        drout["StreamName"] = dr["stream"].ToString().ToUpper();
                        drout["FlowRate"]   = 0;
                        foreach (DataRow dro in dtStreamOut.Rows)
                        {
                            if (drout["streamname"].ToString() == dro["streamname"].ToString())
                            {
                                drout["FlowRate"] = dro["weightflow"].ToString();
                                drout["ProdType"] = dro["ProdType"].ToString();
                            }
                        }
                        drout["tray"]      = tray;
                        drout["visiofile"] = vsdFile;
                        dtfrmcase_product_single.Rows.Add(drout);
                        int percents = (i * 100) / count;
                        backgroundWorker.ReportProgress(percents, i);
                    }
                }
            }
        }