public void calWeight(double netweight) { if (netweight == 0) { return; } if (netweight == preweight) { return; } else { preweight = netweight; //暂停2秒钟 //Thread.Sleep(2000); #region 查询电耗数据,查询当前精炼炉炉号,将电量保存到数据库 //double netweight =Math.Round( getValue(val_netweight),2); double tareweight = Math.Round(getValue(val_tareweight), 2); try { oraDbHelp service = new oraDbHelp(); string exeSql = " insert into ts_fg_weight(fgid,netweight,tareweight) values('" + fgid + "'," + netweight + "," + tareweight + ") "; service.Update(exeSql); } catch { } } #endregion }
/// <summary> /// 获取各流速度和跟踪值(每1s接受一个数据) /// </summary> public void getSpeedAndTrack() { try { double L1S = ccmCutStrand_1.getSpeed(); double L2S = ccmCutStrand_2.getSpeed(); double L3S = ccmCutStrand_3.getSpeed(); double L4S = ccmCutStrand_4.getSpeed(); if (L1S > 0 || L2S > 0 || L3S > 0 || L4S > 0) { double L1T = ccmCutStrand_1.getTrack(); double L2T = ccmCutStrand_2.getTrack(); double L3T = ccmCutStrand_3.getTrack(); double L4T = ccmCutStrand_4.getTrack(); ccmCutStrand_1.speed = L1S; ccmCutStrand_1.track = L1T; ccmCutStrand_2.speed = L2S; ccmCutStrand_2.track = L2T; ccmCutStrand_3.speed = L3S; ccmCutStrand_3.track = L3T; ccmCutStrand_4.speed = L4S; ccmCutStrand_4.track = L4T; #region 根据跟踪值,计算钢坯位置 calZhuPiWeizhi(ccmCutStrand_1); calZhuPiWeizhi(ccmCutStrand_2); calZhuPiWeizhi(ccmCutStrand_3); calZhuPiWeizhi(ccmCutStrand_4); #endregion oraDbHelp service = new oraDbHelp(); service.connectionString = "Data Source = 192.168.48.117/XGMES; User Id = XGMES; Password =XGMES;"; string exeSql = " insert into CUT_Speed_DATA(CCMID,SPEED_1ST,TRACK_1ST,SPEED_2ST,TRACK_2ST,SPEED_3ST,TRACK_3ST,SPEED_4ST,TRACK_4ST) "; exeSql += " values('" + CCMID + "', " + L1S + ", " + L1T + ", " + L2S + ", " + L2T + ", " + L3S + ", " + L3T + ", " + L4S + ", " + L4T + ") "; service.Update(exeSql); #region 向数据库保存铸坯跟踪数据 string sqlstr = " insert into cut_strand_info_his (ccmid,strandid,heatid,starttrack,endtrack,zhupiStart,zhupiEnd,speed) "; sqlstr += " values('" + CCMID + "', 1, '" + ccmCutStrand_1.heatid + "', " + ccmCutStrand_1.pitouTrack + "," + ccmCutStrand_1.track + ", " + ccmCutStrand_1.zhupiStart + ", " + ccmCutStrand_1.zhupiEnd + ", " + ccmCutStrand_1.speed + ") "; sqlstr += " ,('" + CCMID + "', 2, '" + ccmCutStrand_2.heatid + "', " + ccmCutStrand_2.pitouTrack + "," + ccmCutStrand_2.track + ", " + ccmCutStrand_2.zhupiStart + ", " + ccmCutStrand_2.zhupiEnd + ", " + ccmCutStrand_2.speed + ") "; sqlstr += " ,('" + CCMID + "', 3, '" + ccmCutStrand_3.heatid + "', " + ccmCutStrand_3.pitouTrack + "," + ccmCutStrand_3.track + ", " + ccmCutStrand_3.zhupiStart + ", " + ccmCutStrand_3.zhupiEnd + ", " + ccmCutStrand_3.speed + ") "; sqlstr += " ,('" + CCMID + "', 4, '" + ccmCutStrand_4.heatid + "', " + ccmCutStrand_4.pitouTrack + "," + ccmCutStrand_4.track + ", " + ccmCutStrand_4.zhupiStart + ", " + ccmCutStrand_4.zhupiEnd + ", " + ccmCutStrand_4.speed + ") "; try { var db = new sqlDbHelp(); db.ExeSql(sqlstr); } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";insert into cut_strand_info_his方法出错" + ex.ToString() + sqlstr); } #endregion } } catch { } }
public void calDianhao(Int32 shijian) { if (shijian == 0) { return; } if (shijian == caijishijian) { return; } else { caijishijian = shijian; #region 查询电耗数据,查询当前精炼炉炉号,将电量保存到数据库 double dianhao = getValue(val_dianhao); try { string sql = " select treatno from ( select treatno from clf_process_data "; sql += " where treatno like '" + lfid + "%' and dt < sysdate - 2/1440 order by dt desc ) where rownum = 1"; oraDbHelp service = new oraDbHelp(); DataSet ds = service.Query(sql); string heatid = ""; if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { heatid = item["treatno"].ToString(); } } string exeSql = " insert into ts_lf_dianliang(lfid,treatno,dh) values('" + lfid + "','" + heatid + "'," + dianhao + ") "; service.Update(exeSql); } catch { } } #endregion }
/// <summary> /// 各流是否开浇的状态 /// </summary> /// <param name="strandStatus"></param> public void acceptStrandStatus(int strand_Status) { //将流号,状态保存到数据库 oraDbHelp service = new oraDbHelp(); service.connectionString = "Data Source = 192.168.48.117/XGMES; User Id = XGMES; Password =XGMES;"; //insert into CUT_STRANDSTATUS_DATA(CCMID,STRANDID,STRANDSTATUS) strandstatus = strand_Status; //流开浇时,将铸坯的坯头和坯尾位置置为0 if (strand_Status == 1) { zhupiStart = 0; zhupiEnd = 0; pitouTrack = 0; } string exeSql = " insert into CUT_STRANDSTATUS_DATA(CCMID,STRANDID,STRANDSTATUS) "; exeSql += " values('" + CCMID + "', " + strandid + ", " + strand_Status + ") "; service.Update(exeSql); }
public void calData(int castingstatus) { #region 大包开浇时,记录各个值 if (castingstatus == 1) { tundishweight = getValue(valid_tundishweight); var A_weight = getValue(valid_A_weight); var B_weight = getValue(valid_B_weight); if (A_weight > B_weight) { dabaobi = "A"; grossweight = A_weight; } else { dabaobi = "B"; grossweight = B_weight; } genzongzhi1 = getValue(valid_genzongzhi1); genzongzhi2 = getValue(valid_genzongzhi2); genzongzhi3 = getValue(valid_genzongzhi3); genzongzhi4 = getValue(valid_genzongzhi4); casting_begin = DateTime.Now; status = "浇注中"; } #endregion #region 大包停浇时,计算各个值,并保存到数据库 if (castingstatus == 0) { //中包浇注重量 var tundishweight_end = getValue(valid_tundishweight); var tundishweight_add = tundishweight_end - tundishweight; //大包壁称量重量 var tare_weight = 0.0; if (dabaobi == "A") { tare_weight = getValue(valid_A_weight); } else { tare_weight = getValue(valid_B_weight); } var remainweight = getValue(valid_ladelweight); //大包浇注时长 var casting_end = DateTime.Now; var castingtime = Math.Round((casting_end - casting_begin).TotalMinutes, 1); //大包铸坯长度等 var genzongzhi1_end = getValue(valid_genzongzhi1); var genzongzhi2_end = getValue(valid_genzongzhi2); var genzongzhi3_end = getValue(valid_genzongzhi3); var genzongzhi4_end = getValue(valid_genzongzhi4); var zhupi_length = Math.Round(genzongzhi1_end - genzongzhi1 + genzongzhi2_end - genzongzhi2 + genzongzhi3_end - genzongzhi3 + genzongzhi4_end - genzongzhi4, 2); if (zhupi_length < 20) { return; } string heatid = ""; double danzhong = 0; string sql = " select heatid,(select round(weight * 1000 / length, 3) from CQA_CAL_WEIGHT_STD where spec = '280*325' and steelgrade = cccm_base_data.steelgrade and length = cccm_base_data.length and rownum = 1) as danzhong "; sql += " from cccm_base_data where treatno = (select max(treatno) from cccm_base_data where ccmid = 'S65') "; oraDbHelp service = new oraDbHelp(); DataSet ds = service.Query(sql); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { heatid = item["heatid"].ToString(); try { danzhong = Convert.ToDouble(item["danzhong"]); } catch { danzhong = 0.72; } } } var zhupi_weight = zhupi_length * danzhong; string exeSql = " insert into cccm_ladle_weight(heatid, casting_weight, tundish_weight, zhupi_weight, zhupi_length, zhupi_danzhong, dabaobi, grossweight, tareweight, "; exeSql += " castingtime, casting_begin, casting_end, tundish_begin, tundish_end, zhupi1_begin, zhupi1_end, zhupi2_begin, zhupi2_end, "; exeSql += " zhupi3_begin, zhupi3_end, zhupi4_begin, zhupi4_end,remainweight) "; exeSql += " values('" + heatid + "', " + (tundishweight_add + zhupi_weight) + ", " + tundishweight_add + ", " + zhupi_weight + ", " + zhupi_length + ", " + danzhong + ", '" + dabaobi; exeSql += "'," + grossweight + ", " + tare_weight + "," + castingtime + ", '" + casting_begin.ToString("HH:mm:ss") + "', '" + casting_end.ToString("HH:mm:ss"); exeSql += "'," + tundishweight + ", " + tundishweight_end + ", " + genzongzhi1 + ", " + genzongzhi1_end + ", " + genzongzhi2 + ", " + genzongzhi2_end + ", " + genzongzhi3 + "," + genzongzhi3_end + ", " + genzongzhi4 + ", " + genzongzhi4_end + ", " + remainweight + ") "; service.Update(exeSql); status = "已停浇"; } #endregion }
/// <summary> /// 大包缝,可以理解为各流开浇时刻,将流的下一炉号赋给当前炉号 /// </summary> /// <param name="status"></param> public void acceptLadlefeng(int status) { //保存到数据库 double L1T = ccmCutStrand_1.getTrack(); double L2T = ccmCutStrand_2.getTrack(); double L3T = ccmCutStrand_3.getTrack(); double L4T = ccmCutStrand_4.getTrack(); oraDbHelp service = new oraDbHelp(); service.connectionString = "Data Source = 192.168.48.117/XGMES; User Id = XGMES; Password =XGMES;"; string exeSql = " insert into CUT_LADLEFENG_DATA(CCMID,LADLEFENG,TRACK_1ST,TRACK_2ST,TRACK_3ST,TRACK_4ST) "; exeSql += " values('" + CCMID + "'," + status + "," + L1T + "," + L2T + "," + L3T + "," + L4T + ") "; service.Update(exeSql); #region 流炉号变更 if (ccmCutStrand_1.heatid == "" || ccmCutStrand_1.heatid == null) { oraDbHelp service1 = new oraDbHelp(); string selectSql = " select heatid from(select heatid, PRODUCTIONDATE from cccm_base_data where ccmid = '" + CCMID + "' order by PRODUCTIONDATE desc) where rownum <= 2"; var steelGradeInfo = service1.Query(selectSql); if (steelGradeInfo != null && steelGradeInfo.Tables.Count > 0 && steelGradeInfo.Tables[0].Rows.Count > 0) { ccmCutStrand_1.heatid = steelGradeInfo.Tables[0].Rows[1]["heatid"].ToString(); ccmCutStrand_2.heatid = steelGradeInfo.Tables[0].Rows[1]["heatid"].ToString(); ccmCutStrand_3.heatid = steelGradeInfo.Tables[0].Rows[1]["heatid"].ToString(); ccmCutStrand_4.heatid = steelGradeInfo.Tables[0].Rows[1]["heatid"].ToString(); } } #region 记录大包缝数据 // insert into cut_ladlefenginfo(ccmid,strandid,heatid,endtrack) //values('S63', 1, '99', 33.3) try { var db = new sqlDbHelp(); string sql = ""; if (ccmCutStrand_1.strandstatus == 1) { ladleFeng s1ladlefeng = new ladleFeng(); s1ladlefeng.heatid = ccmCutStrand_1.heatid; s1ladlefeng.startTrack = L1T; ccmCutStrand_1.listLadleFeng.Add(s1ladlefeng); try { sql = " insert into cut_ladlefenginfo(ccmid,strandid,heatid,endtrack) "; sql += " values('" + CCMID + "', 1, '" + s1ladlefeng.heatid + "', " + s1ladlefeng.startTrack + ") "; db.ExeSql(sql); } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";insert into cut_ladlefenginfo方法出错1" + ex.ToString()); } } if (ccmCutStrand_2.strandstatus == 1) { ladleFeng s2ladlefeng = new ladleFeng(); s2ladlefeng.heatid = ccmCutStrand_2.heatid; s2ladlefeng.startTrack = L2T; ccmCutStrand_2.listLadleFeng.Add(s2ladlefeng); try { sql = " insert into cut_ladlefenginfo(ccmid,strandid,heatid,endtrack) "; sql += " values('" + CCMID + "', 2, '" + s2ladlefeng.heatid + "', " + s2ladlefeng.startTrack + ") "; db.ExeSql(sql); } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";insert into cut_ladlefenginfo方法出错2" + ex.ToString()); } } if (ccmCutStrand_3.strandstatus == 1) { ladleFeng s3ladlefeng = new ladleFeng(); s3ladlefeng.heatid = ccmCutStrand_3.heatid; s3ladlefeng.startTrack = L3T; ccmCutStrand_3.listLadleFeng.Add(s3ladlefeng); try { sql = " insert into cut_ladlefenginfo(ccmid,strandid,heatid,endtrack) "; sql += " values('" + CCMID + "', 3, '" + s3ladlefeng.heatid + "', " + s3ladlefeng.startTrack + ") "; db.ExeSql(sql); } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";insert into cut_ladlefenginfo方法出错3" + ex.ToString()); } } if (ccmCutStrand_4.strandstatus == 1) { ladleFeng s4ladlefeng = new ladleFeng(); s4ladlefeng.heatid = ccmCutStrand_4.heatid; s4ladlefeng.startTrack = L4T; ccmCutStrand_4.listLadleFeng.Add(s4ladlefeng); try { sql = " insert into cut_ladlefenginfo(ccmid,strandid,heatid,endtrack) "; sql += " values('" + CCMID + "', 4, '" + s4ladlefeng.heatid + "', " + s4ladlefeng.startTrack + ") "; db.ExeSql(sql); } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";insert into cut_ladlefenginfo方法出错4" + ex.ToString()); } } } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";insert into cut_ladlefenginfo方法出错5" + ex.ToString()); } #endregion if (heatid == "" || heatid == null) { oraDbHelp service1 = new oraDbHelp(); string selectSql = " select heatid from(select heatid, PRODUCTIONDATE from cccm_base_data where ccmid = '" + CCMID + "' order by PRODUCTIONDATE desc) where rownum = 1"; var steelGradeInfo = service1.Query(selectSql); if (steelGradeInfo != null && steelGradeInfo.Tables.Count > 0 && steelGradeInfo.Tables[0].Rows.Count > 0) { heatid = steelGradeInfo.Tables[0].Rows[0]["heatid"].ToString(); } } ccmCutStrand_1.heatid = heatid; ccmCutStrand_2.heatid = heatid; ccmCutStrand_3.heatid = heatid; ccmCutStrand_4.heatid = heatid; #endregion }
/// <summary> /// 连铸机到达开浇停浇状态 /// </summary> /// <param name="status"></param> public void acceptCasterStatus(int status) { if (status == 2) { ////暂停5秒后 //Thread.Sleep(5000); //保存到数据库 //炉号先变更 heatid = ""; oraDbHelp service = new oraDbHelp(); #region 1、读取生产计划 2、传输给切割 3、删除 try { string selectSql = " select a.guid,a.ccmid,a.heatid,b.steelgrade,b.length,c.weight,d.tundish_heatnum from cccm_download_heatid a ,cplan_tapping b , "; selectSql += " csteel_data c, cccm_process_data d where a.heatid = b.heatid and a.heatid = c.heatid and a.heatid = d.heatid(+) "; selectSql += " and a.ccmid = '" + CCMID + "' order by a.c_ts desc"; var steelGradeInfo = service.Query(selectSql); if (steelGradeInfo != null && steelGradeInfo.Tables.Count > 0 && steelGradeInfo.Tables[0].Rows.Count > 0) { int length = 0; try { length = Convert.ToInt32(steelGradeInfo.Tables[0].Rows[0]["length"]); } catch { } double weight = 0; try { weight = Convert.ToDouble(steelGradeInfo.Tables[0].Rows[0]["weight"]); } catch { } int heatnum = 0; try { heatnum = Convert.ToInt32(steelGradeInfo.Tables[0].Rows[0]["tundish_heatnum"]); } catch { } string insertSql = "insert into CUT_PRODUCTPLAN(heatid, ccmid, length, steelgrade, netweight, tundish_heatnum) values"; insertSql += "('" + steelGradeInfo.Tables[0].Rows[0]["heatid"].ToString() + "', '" + steelGradeInfo.Tables[0].Rows[0]["ccmid"].ToString() + "', " + length + ", '" + steelGradeInfo.Tables[0].Rows[0]["steelgrade"].ToString() + "', " + weight + ", " + heatnum + ")"; service.connectionString = "Data Source = 192.168.48.117/XGMES; User Id = XGMES; Password =XGMES;"; service.Update(insertSql); foreach (DataRow item in steelGradeInfo.Tables[0].Rows) { service.connectionString = "Data Source = 192.168.36.153/XGMES; User Id = XGMES; Password =XGMES;"; string deleteSql = "delete from cccm_download_heatid where guid='" + item["guid"].ToString() + "'"; service.Update(deleteSql); } #region 将炉号赋给大包的heatid,同时赋给各个流的下一个炉号 heatid = steelGradeInfo.Tables[0].Rows[0]["heatid"].ToString(); //if(ccmCutStrand_1.heatid=="") //ccmCutStrand_1.nextheatid = heatid; //ccmCutStrand_2.nextheatid = heatid; //ccmCutStrand_3.nextheatid = heatid; //ccmCutStrand_4.nextheatid = heatid; #endregion } } catch { } #endregion #region 输开浇信号 #endregion service.connectionString = "Data Source = 192.168.48.117/XGMES; User Id = XGMES; Password =XGMES;"; string exeSql = " insert into CUT_CCMSTATUS_DATA(CCMID,CCMSTATUS) values('" + CCMID + "', " + status + ") "; service.Update(exeSql); } else { //保存到数据库 oraDbHelp service = new oraDbHelp(); service.connectionString = "Data Source = 192.168.48.117/XGMES; User Id = XGMES; Password =XGMES;"; string exeSql = " insert into CUT_CCMSTATUS_DATA(CCMID,CCMSTATUS) values('" + CCMID + "', " + status + ") "; service.Update(exeSql); } }
/// <summary> /// 各流切割状态的变化 /// </summary> /// <param name="cutStatus"></param> public void acceptCutStatus(int cutStatus) { //将流号,切割状态、跟踪值保存到数据库 double billet_length = getValue(valid_billetLength); double track_value = getValue(valid_trackvalue); double track = getValue(valid_track); string curheatid = heatid; double yuanPiTouTrack = pitouTrack; double yuanPiWeiTrack = 0; double dabaofeng = 0; try { oraDbHelp service = new oraDbHelp(); service.connectionString = "Data Source = 192.168.48.117/XGMES; User Id = XGMES; Password =XGMES;"; string exeSql = " insert into CUT_STRAND_DATA(CCMID, STRANDID, STATUS, BILLETLENGTH, TRACKVALUE) "; exeSql += " values('" + CCMID + "', " + strandid + ", " + cutStatus + ", " + billet_length + ", " + track_value + ") "; service.Update(exeSql); if (cutStatus == 3) { #region 切割时,铸坯位置的跟踪计算 if (strandstatus == 1) { //正常浇注模式,坯头跟踪值,为跟踪值-固定值 pitouTrack = track - zhupichangdu; zhupiStart = zhupichangdu; } else { //拉尾坯时,坯头跟踪值,原坯头跟踪值+定尺 pitouTrack = pitouTrack + billet_length; zhupiStart = zhupichangdu; //坯尾的位置:固定长度--(实际红坯的长度) zhupiEnd = zhupichangdu - (track - pitouTrack); } #endregion yuanPiWeiTrack = pitouTrack; #region 切割时,对大包缝的判断 #endregion if (listLadleFeng.Count > 0) { dabaofeng = listLadleFeng[0].startTrack; //如果小于大包缝的跟踪,则使用大包缝的炉号 if (yuanPiWeiTrack < listLadleFeng[0].startTrack) { curheatid = listLadleFeng[0].heatid; } //大包缝在中间时 else if (yuanPiWeiTrack >= listLadleFeng[0].startTrack && yuanPiTouTrack < listLadleFeng[0].startTrack) { double zhongdian = (yuanPiWeiTrack - yuanPiTouTrack) / 2 + yuanPiTouTrack; if (zhongdian < listLadleFeng[0].startTrack) { curheatid = listLadleFeng[0].heatid; } else { //如果存在两个大包缝,则用第二个 if (listLadleFeng.Count > 1) { curheatid = listLadleFeng[1].heatid; } } #region 在数据库中将此状态置为1 //update cut_ladlefenginfo set status=1,u_ts='1' where heatid='' and strandid=1 try { var db = new sqlDbHelp(); string sql = "update cut_ladlefenginfo set status=1,u_ts='" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' where heatid='" + listLadleFeng[0].heatid + "' and strandid=" + strandid + ""; db.ExeSql(sql); } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";流号:" + strandid + ";acceptCutStatus-update cut_ladlefenginfo方法出错" + ex.ToString()); } #endregion //移除第一个大包缝 listLadleFeng.RemoveAt(0); //如果有第二个大包缝,则继续移除 if (listLadleFeng.Count > 0) { if (yuanPiWeiTrack >= listLadleFeng[0].startTrack) { listLadleFeng.RemoveAt(0); } } } } try { var dbhelp = new sqlDbHelp(); string inSql = "insert into cut_info(ccmid,strandid,heatid,toutrack,weitrack,fengtrack) "; inSql += "values('" + CCMID + "', " + strandid + ", '" + curheatid + "', " + yuanPiTouTrack + "," + yuanPiWeiTrack + ", " + dabaofeng + ")"; dbhelp.ExeSql(inSql); } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";流号:" + strandid + ";acceptCutStatus-insert into cut_info方法出错" + ex.ToString()); } } } catch (Exception ex) { SysLog.Log(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "-- 铸机:" + CCMID + ";流号:" + strandid + ";acceptCutStatus方法出错" + ex.ToString()); } }