1080 lines
47 KiB
C#
1080 lines
47 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
using CRVM.Utility;
|
|||
|
|
using System.Xml;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Data;
|
|||
|
|
using CRVM.Entity;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace CRVM.SIDExcuter
|
|||
|
|
{
|
|||
|
|
public class DbHelper
|
|||
|
|
{
|
|||
|
|
private string _path;
|
|||
|
|
private LogicConnect DBlogicConn;
|
|||
|
|
private LogicConnect l2Connect;
|
|||
|
|
private LogicConnect localConnect;
|
|||
|
|
private EDBItem soudb;
|
|||
|
|
private EDBItem desdb;
|
|||
|
|
private int freq = 5;//频率(秒)
|
|||
|
|
private static DbHelper _instance = null;
|
|||
|
|
|
|||
|
|
private string coldid_before = "";
|
|||
|
|
|
|||
|
|
public EDBItem SouDB
|
|||
|
|
{
|
|||
|
|
get { return soudb; }
|
|||
|
|
set { soudb = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public EDBItem DesDB
|
|||
|
|
{
|
|||
|
|
get { return desdb; }
|
|||
|
|
set { desdb = value; }
|
|||
|
|
}
|
|||
|
|
public int Freq
|
|||
|
|
{
|
|||
|
|
get { return freq; }
|
|||
|
|
set { freq = value; }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DbHelper(string path)
|
|||
|
|
{
|
|||
|
|
_path = path;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static DbHelper GetInstance(string path)
|
|||
|
|
{
|
|||
|
|
if (_instance == null)
|
|||
|
|
{
|
|||
|
|
_instance = new DbHelper(path);
|
|||
|
|
_instance.DesDB = new EDBItem();
|
|||
|
|
_instance.SouDB = new EDBItem();
|
|||
|
|
}
|
|||
|
|
return _instance;
|
|||
|
|
}
|
|||
|
|
public bool isStart { get; set; }
|
|||
|
|
|
|||
|
|
public bool LoadConfigData(DbHelper dbhelper)
|
|||
|
|
{
|
|||
|
|
XmlDocument xmldoc = new XmlDocument();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string ipath = _path + "\\dbaccess.conf";
|
|||
|
|
if (File.Exists(ipath))
|
|||
|
|
{
|
|||
|
|
xmldoc.Load(ipath);
|
|||
|
|
string systemName = "";
|
|||
|
|
if (xmldoc.DocumentElement.Attributes.Count > 0)
|
|||
|
|
systemName = xmldoc.DocumentElement.Attributes[0].InnerText;
|
|||
|
|
XmlNodeList nodes = xmldoc.SelectNodes("Schm/DB");
|
|||
|
|
int count = nodes.Count;
|
|||
|
|
string DbName = nodes[0].Attributes[0].InnerText;
|
|||
|
|
soudb.DataType = nodes[0].ChildNodes[0].Attributes[0].InnerText;
|
|||
|
|
soudb.Database = nodes[0].ChildNodes[0].Attributes[1].InnerText;
|
|||
|
|
soudb.Userid = nodes[0].ChildNodes[0].Attributes[2].InnerText;
|
|||
|
|
soudb.Password = nodes[0].ChildNodes[0].Attributes[3].InnerText;
|
|||
|
|
soudb.Ipaddress = nodes[0].ChildNodes[0].Attributes[4].InnerText;
|
|||
|
|
string DestDbName = nodes[1].Attributes[0].InnerText;
|
|||
|
|
desdb.DataType = nodes[1].ChildNodes[0].Attributes[0].InnerText;
|
|||
|
|
desdb.Database = nodes[1].ChildNodes[0].Attributes[1].InnerText;
|
|||
|
|
desdb.Userid = nodes[1].ChildNodes[0].Attributes[2].InnerText;
|
|||
|
|
desdb.Password = nodes[1].ChildNodes[0].Attributes[3].InnerText;
|
|||
|
|
desdb.Ipaddress = nodes[1].ChildNodes[0].Attributes[4].InnerText;
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (XmlException)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 重设L2数据库操作对象
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SetL2Connect()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
l2Connect = new LogicConnect(soudb, soudb.Userid);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 重设本地数据库操作对象
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SetLocalConnect()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
localConnect = new LogicConnect(desdb, desdb.Userid);
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 剪切时向t_coil_info_server表中插入一条新纪录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="alarmFlag"></param>
|
|||
|
|
/// <param name="endFlag"></param>
|
|||
|
|
/// <param name="OrigPath"></param>
|
|||
|
|
/// <param name="EnergyPath"></param>
|
|||
|
|
/// <param name="disLength"></param>
|
|||
|
|
public void AddNewCoilInfo(int alarmFlag, int endFlag, string OrigPath, string EnergyPath, string disLength)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//将本次记录之前的当前卷标记全部置为0,保证当前卷标记唯一性
|
|||
|
|
string update_sql = "update t_coil_info_server set nowflag = 0 where nowflag = 1";
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
|
|||
|
|
//插入新纪录,并将当前卷标记置为1
|
|||
|
|
string insert_sql = string.Format("insert into t_coil_info_server (createdate,endflag,origPath,energyPath,alarmflag,nowflag,disLength) values('{0}',{1},'{2}','{3}',{4},1,{5})",
|
|||
|
|
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), endFlag, OrigPath, EnergyPath, alarmFlag, disLength);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("AddNewCoilInfo", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 从L2数据库获取钢卷信息,补充到本地t_coil_info_server表,并将冷卷号更新到t_alarm_info_server表中
|
|||
|
|
/// 梅钢酸轧项目不使用
|
|||
|
|
/// </summary>
|
|||
|
|
public void UpdateLocalCoilInfo()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//获取L2钢卷信息表中最新的一条记录
|
|||
|
|
string sql_l2 = "select coldcoilid,hotcoilid,extlength,steelgrade,alloycode,extthick,extwidth,entthick from fv_pro_data";
|
|||
|
|
//string sql_l2 = "select coldcoilid,encoilid,coillengthx,coilinnerdiam,coiloutdiax,alloycode,thick_ave,width,coil_ind0,ent_gauge_ind0 from app.fv_vibration_proddata where rownum = 1";
|
|||
|
|
|
|||
|
|
DataTable l2data = l2Connect.DataBase(sql_l2);
|
|||
|
|
|
|||
|
|
if (l2data != null)
|
|||
|
|
{
|
|||
|
|
if (l2data.Rows.Count != 0)
|
|||
|
|
{
|
|||
|
|
//若本次从L2获取的最新第一条记录的卷号与上次记录的卷号一致,则表示L2新卷号还没有生成
|
|||
|
|
if (l2data.Rows[0]["coldcoilid"].ToString().Trim() == coldid_before)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//根据L2信息更新本地t_coil_info_server表中热卷号、冷卷号、钢种牌号、宽度、入口厚度、出口厚度、钢种等级信息
|
|||
|
|
string coilinfo_update_sql = string.Format("update t_coil_info_server set coldcoilno_hotcoild='{0}',coldcoilno='{1}',coldcoil_alloycode='{2}',coldcoil_extwidth={3},coldcoil_entthick={4},coldcoil_extthick={5} where nowflag = 1 and endflag = 1",
|
|||
|
|
l2data.Rows[0]["hotcoilid"], l2data.Rows[0]["coldcoilid"], l2data.Rows[0]["alloycode"], Convert.ToDouble(l2data.Rows[0]["extwidth"]), Convert.ToDouble(l2data.Rows[0]["entthick"]), Convert.ToDouble(l2data.Rows[0]["extthick"]));
|
|||
|
|
localConnect.DataBase(coilinfo_update_sql);
|
|||
|
|
|
|||
|
|
//更新t_alarm_info_server中的冷卷号信息
|
|||
|
|
string alarm_update_sql = string.Format("update t_alarm_info_server set coldcoilid= '{0}' where nowflag= 1", l2data.Rows[0]["coldcoilid"]);
|
|||
|
|
localConnect.DataBase(alarm_update_sql);
|
|||
|
|
coldid_before = l2data.Rows[0]["coldcoilid"].ToString().Trim();//记录上一卷的冷卷号
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateLocalCoilInfo", ex.ToString());
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存数据库配置
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SaveConfigData()
|
|||
|
|
{
|
|||
|
|
StreamWriter write = new StreamWriter(_path + "\\dbaccess.conf", false, Encoding.GetEncoding("gb2312"));
|
|||
|
|
StringBuilder str = new StringBuilder();
|
|||
|
|
str = str.AppendLine("<?xml version=\"1.0\" encoding=\"GB2312\" ?> ");
|
|||
|
|
str = str.AppendLine("<Schm BPLATURE=\"BPCSYSTEM\">");
|
|||
|
|
str = str.AppendLine(" <DB name=\"sourcedb\">");
|
|||
|
|
if (soudb != null)
|
|||
|
|
{
|
|||
|
|
str = str.AppendLine(" <item dbtype=\"" + soudb.DataType + "\" dbname=\"" + soudb.Database + "\" dbuser=\"" + soudb.Userid + "\" dbpwd=\"" + soudb.Password + "\" dbip=\"" + soudb.Ipaddress + "\" />");
|
|||
|
|
}
|
|||
|
|
str = str.AppendLine(" </DB>");
|
|||
|
|
str = str.AppendLine(" <DB name=\"destdb\">");
|
|||
|
|
if (desdb != null)
|
|||
|
|
{
|
|||
|
|
str = str.AppendLine(" <item dbtype=\"" + desdb.DataType + "\" dbname=\"" + desdb.Database + "\" dbuser=\"" + desdb.Userid + "\" dbpwd=\"" + desdb.Password + "\" dbip=\"" + desdb.Ipaddress + "\" />");
|
|||
|
|
}
|
|||
|
|
str = str.AppendLine(" </DB>");
|
|||
|
|
str = str.AppendLine("</Schm>");
|
|||
|
|
write.WriteLine(str.ToString());
|
|||
|
|
write.Close();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 测试数据库是否连接成功
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="item"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool IsConnected(EDBItem item)
|
|||
|
|
{
|
|||
|
|
DBlogicConn = new LogicConnect(item, item.Userid);
|
|||
|
|
DataTable dt = new DataTable();
|
|||
|
|
if (item.DataType == "oracle")
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
dt = DBlogicConn.DataBase("select * from FV_ROLL_DATA");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (item.DataType == "postgres")
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
dt = DBlogicConn.DataBase("select * from pg_am");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (item.DataType == "db2")
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
dt = DBlogicConn.DataBase("select excoilid,entcoilid,length,innerdiam,outdiam,alloycode,extthick,extwidth,hentry from app.fv_vibration_proddata where rownum = 1");
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 当前文件结束后在t_alarm_info_server表中插入本文件对应的报警信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="start"></param>
|
|||
|
|
/// <param name="end"></param>
|
|||
|
|
/// <param name="coilNo"></param>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
/// <param name="alarmType"></param>
|
|||
|
|
/// <param name="energy"></param>
|
|||
|
|
public void InsertAlarmInfo(int[] start, int[] end, int[] standNo, int[] alarmType, double[] energy)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//将t_alarm_info_server表中当前卷标志全部置为0
|
|||
|
|
string update_sql = "update t_alarm_info_server set nowflag = 0 where nowflag = 1";
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
|
|||
|
|
//插入新纪录,并将新纪录的当前卷标志置为1
|
|||
|
|
DateTime nowtime = DateTime.Now;
|
|||
|
|
for (int i = 0; i < start.Length; i++)
|
|||
|
|
{
|
|||
|
|
string time = nowtime.AddMilliseconds(-i).ToString("yyyy-MM-dd HH:mm:ss.fff");
|
|||
|
|
string insert_sql = string.Format("insert into t_alarm_info_server (createdate,startpos,endpos,standno,alarmtype,energy,nowflag) values('{0}',{1},{2},{3},{4},{5},1)",
|
|||
|
|
time, start[i], end[i], standNo[i] + 1, alarmType[i], energy[i]);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("InsertAlarmInfo", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
///
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="mac"></param>
|
|||
|
|
/// <param name="rolldata"></param>
|
|||
|
|
public void RollDataInfo(Machine mac, DataTable rolldata)
|
|||
|
|
{
|
|||
|
|
if (mac == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
mac.Stand[i].rollDiameterBL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterBU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterML = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterMU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWU = 10000.0;
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (rolldata != null)
|
|||
|
|
{
|
|||
|
|
Console.WriteLine("RollDataInfo--------Yes!");
|
|||
|
|
if (rolldata.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
mac.Stand[i].rollDiameterWU = Convert.ToDouble(rolldata.Rows[0][i * 6 + 0]);
|
|||
|
|
mac.Stand[i].rollDiameterWL = Convert.ToDouble(rolldata.Rows[0][i * 6 + 1]);
|
|||
|
|
//中间辊 c102机组轧机无中间辊
|
|||
|
|
mac.Stand[i].rollDiameterMU = Convert.ToDouble(rolldata.Rows[0][i * 6 + 2]);
|
|||
|
|
mac.Stand[i].rollDiameterML = Convert.ToDouble(rolldata.Rows[0][i * 6 + 3]);
|
|||
|
|
mac.Stand[i].rollDiameterBU = Convert.ToDouble(rolldata.Rows[0][i * 6 + 4]);
|
|||
|
|
mac.Stand[i].rollDiameterBL = Convert.ToDouble(rolldata.Rows[0][i * 6 + 5]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
mac.Stand[i].rollDiameterBL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterBU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterML = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterMU = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWL = 10000.0;
|
|||
|
|
mac.Stand[i].rollDiameterWU = 10000.0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
finally
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 根据L2轧辊信息更新本地轧辊表
|
|||
|
|
/// 梅钢酸轧项目不使用
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="data"></param>
|
|||
|
|
|
|||
|
|
public void UpdateLocalRollData(DataTable data)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string nowtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|||
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
string update_sql = string.Format("insert into T_ROLL_DATA (createdate,rollno,standno,rolltype,rollposition,DiameterMiddle) values('{0}','{1}',{2},'{3}','{4}',{5})", nowtime,
|
|||
|
|
data.Rows[i]["rollno"], data.Rows[i]["standno"], data.Rows[i]["rolltype"].ToString(), data.Rows[i]["rollposition"], data.Rows[i]["diametermiddle"]);
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateLocalRollData", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取t_roll_data表中所有的时刻点
|
|||
|
|
/// 梅钢酸轧项目不使用
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable SelCreateTimeRolData()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = "select distinct createdate from t_roll_data";
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取t_roll_data表中某个时刻点的轧辊数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="createdate"></param>
|
|||
|
|
/// 梅钢酸轧项目不使用
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable SelRollDataByCreateDate(string createdate)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select rollno,diametermiddle,standno,rollposition,rolltype from t_roll_data where createdate='{0}'", createdate);
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取L2在线轧辊信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetL2OnlineRollInfo()
|
|||
|
|
{
|
|||
|
|
string std_sql = "select ";
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount - 1; i++)
|
|||
|
|
{
|
|||
|
|
std_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", (i + 1).ToString());
|
|||
|
|
}
|
|||
|
|
std_sql += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", (SysParam.Instance.SpeedChannelCount).ToString());
|
|||
|
|
std_sql += " from t_roll_online where seqno=1";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//string select_sql = "select standno,rollposition,to_char(diametermiddle/1000,'9999.99') as diametermiddle,rolltype,rollno from app.fv_vibration_rolldata where rollstatus='I'";
|
|||
|
|
//string stand1_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "1");
|
|||
|
|
//string stand2_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "2");
|
|||
|
|
//string stand3_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "3");
|
|||
|
|
//string stand4_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "4");
|
|||
|
|
//string stand5_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "5");
|
|||
|
|
//string stand6_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", "6");
|
|||
|
|
//string select_sql = "select " + stand1_sql + stand2_sql + stand3_sql + stand4_sql + stand5_sql + stand6_sql + " from t_roll_online where seqno=1";
|
|||
|
|
//Console.WriteLine(select_sql);
|
|||
|
|
//return localConnect.DataBase(select_sql);
|
|||
|
|
return localConnect.DataBase(std_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DataTable error = new DataTable();
|
|||
|
|
//throw ex;
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetL2OnlineRollInfo", ex.ToString());
|
|||
|
|
return error;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 验证用户输入的密码是否正确
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="password"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool IsUser(string password)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select * from t_users where pswd='{0}' and name = 'tcm'", password);
|
|||
|
|
DataTable dt = localConnect.DataBase(select_sql);
|
|||
|
|
|
|||
|
|
if (dt.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取t_coil_info_server表中所有的冷卷号
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public List<string> SelAllCoilIDs()
|
|||
|
|
{
|
|||
|
|
List<string> coillist = new List<string>();
|
|||
|
|
string select_sql = "select coldcoilno from t_coil_info_server";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable data = localConnect.DataBase(select_sql);
|
|||
|
|
if (data != null)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
coillist.Add(data.Rows[i]["coldcoilno"].ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return coillist;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改用户密码
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="newpswd"></param>
|
|||
|
|
public void ChangePassWord(string newpswd)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string update_sql = string.Format("update t_users set pswd='{0}' where name='tcm'", newpswd);
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_alarm_info_server表中根据冷卷号搜索钢卷报警信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="coldcoilid"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable SelAlarmInfoByColdId(string coldcoilid)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string select_sql = string.Format("select startpos,endpos,standno,alarmtype,energy from t_alarm_info_server where coldcoilid='{0}'", coldcoilid);
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_server表中搜索时间范围内的钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="isAlarm"></param>
|
|||
|
|
/// <param name="startTime"></param>
|
|||
|
|
/// <param name="endTime"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByDate(bool isAlarm, DateTime startTime, DateTime endTime)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//string select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,coldcoil_len,endflag,origpath,energypath from t_coil_info_server where createdate<='{0}'and createdate>='{1}'", endTime, startTime);
|
|||
|
|
string select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,dislength,coldcoil_len,endflag,origpath,energypath from t_coil_info_server where createdate<='{0}'and createdate>='{1}'", endTime, startTime);
|
|||
|
|
if (isAlarm)
|
|||
|
|
{
|
|||
|
|
select_sql += " and alarmflag = 1";
|
|||
|
|
}
|
|||
|
|
select_sql += " order by createdate desc";
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_server表中根据冷卷号搜索钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="coldcoilno"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByColdId(string coldcoilno)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//string select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,coldcoil_len,endflag,origpath,energypath from t_coil_info_server where coldcoilno='{0}'", coldcoilno);
|
|||
|
|
//return localConnect.DataBase(select_sql);
|
|||
|
|
string select_sql = "";
|
|||
|
|
if (coldcoilno.Trim() == "")
|
|||
|
|
{
|
|||
|
|
select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,dislength,coldcoil_len,endflag,origpath,energypath from t_coil_info_server where coldcoilno = 'xxxxxxxxxx'", coldcoilno);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
select_sql = string.Format("select to_char(createdate,'YYYY-MM-DD HH24:MI:SS'),alarmflag,coldcoilno_hotcoild,coldcoilno,coldcoil_steegrade,coldcoil_alloycode, coldcoil_extwidth,coldcoil_entthick,coldcoil_extthick,dislength,coldcoil_len,endflag,origpath,energypath from t_coil_info_server where coldcoilno like '%{0}%'", coldcoilno);
|
|||
|
|
}
|
|||
|
|
return localConnect.DataBase(select_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
throw ex;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_server表中根据原始数据路径搜索钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="originPath"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByOriginPath(string originPath, Machine macReview)
|
|||
|
|
{
|
|||
|
|
string sql_str = "select coldcoilno,coldcoil_steegrade,coldcoil_extwidth,coldcoil_extthick,coldcoil_alloycode,";
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount - 1; i++)
|
|||
|
|
{
|
|||
|
|
sql_str += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", (i + 1).ToString());
|
|||
|
|
}
|
|||
|
|
sql_str += string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", SysParam.Instance.SpeedChannelCount.ToString());
|
|||
|
|
sql_str += string.Format(" from t_coil_info_server where origpath='{0}'", originPath);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//string coil_sql = "select coldcoilno,coldcoil_steegrade,coldcoil_extwidth,coldcoil_extthick,coldcoil_alloycode,";
|
|||
|
|
|
|||
|
|
//string stand1_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "1");
|
|||
|
|
//string stand2_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "2");
|
|||
|
|
//string stand3_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "3");
|
|||
|
|
//string stand4_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "4");
|
|||
|
|
//string stand5_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", "5");
|
|||
|
|
|
|||
|
|
//string where_sql = string.Format(" from t_coil_info_server where origpath='{0}'", originPath);
|
|||
|
|
//string sql = coil_sql + stand1_sql + stand2_sql + stand3_sql + stand4_sql + stand5_sql + where_sql;
|
|||
|
|
DataTable dt = localConnect.DataBase(sql_str);
|
|||
|
|
|
|||
|
|
if (dt.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
macReview.review_coldcoilno = dt.Rows[0]["coldcoilno"].ToString();
|
|||
|
|
macReview.review_extThick = dt.Rows[0]["coldcoil_extthick"].ToString();
|
|||
|
|
macReview.review_alloyCode = dt.Rows[0]["coldcoil_alloycode"].ToString();
|
|||
|
|
macReview.review_steelGrade = dt.Rows[0]["coldcoil_steegrade"].ToString();
|
|||
|
|
macReview.review_width = dt.Rows[0]["coldcoil_extwidth"].ToString();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < 5; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = Convert.ToDouble(dt.Rows[0]["wrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterWL = Convert.ToDouble(dt.Rows[0]["wrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterMU = Convert.ToDouble(dt.Rows[0]["imrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterML = Convert.ToDouble(dt.Rows[0]["imrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBU = Convert.ToDouble(dt.Rows[0]["burdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBL = Convert.ToDouble(dt.Rows[0]["burdialow" + (i + 1).ToString()]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterWL = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterMU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterML = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBL = 0;
|
|||
|
|
}
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetCoilInfoByOriginPath", ex.ToString());
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 在t_coil_info_server表中根据能量数据路径搜索钢卷信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="energyPath"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetCoilInfoByEnergyPath(string energyPath, Machine macReview)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string coil_sql = "select coldcoilno,coldcoil_steegrade,coldcoil_extwidth,coldcoil_extthick,coldcoil_alloycode,";
|
|||
|
|
|
|||
|
|
string stand1_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "1");
|
|||
|
|
string stand2_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "2");
|
|||
|
|
string stand3_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "3");
|
|||
|
|
string stand4_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0},", "4");
|
|||
|
|
string stand5_sql = string.Format("wrdiaup{0},wrdialow{0},imrdiaup{0},imrdialow{0},burdiaup{0},burdialow{0}", "5");
|
|||
|
|
|
|||
|
|
string where_sql = string.Format(" from t_coil_info_server where energypath='{0}'", energyPath);
|
|||
|
|
string sql = coil_sql + stand1_sql + stand2_sql + stand3_sql + stand4_sql + stand5_sql + where_sql;
|
|||
|
|
DataTable dt = localConnect.DataBase(sql);
|
|||
|
|
|
|||
|
|
if (dt.Rows.Count == 1)
|
|||
|
|
{
|
|||
|
|
macReview.review_coldcoilno = dt.Rows[0]["coldcoilno"].ToString();
|
|||
|
|
macReview.review_extThick = dt.Rows[0]["coldcoil_extthick"].ToString();
|
|||
|
|
macReview.review_alloyCode = dt.Rows[0]["coldcoil_alloycode"].ToString();
|
|||
|
|
macReview.review_steelGrade = dt.Rows[0]["coldcoil_steegrade"].ToString();
|
|||
|
|
macReview.review_width = dt.Rows[0]["coldcoil_extwidth"].ToString();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = Convert.ToDouble(dt.Rows[0]["wrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterWL = Convert.ToDouble(dt.Rows[0]["wrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterMU = Convert.ToDouble(dt.Rows[0]["imrdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterML = Convert.ToDouble(dt.Rows[0]["imrdialow" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBU = Convert.ToDouble(dt.Rows[0]["burdiaup" + (i + 1).ToString()]);
|
|||
|
|
macReview.Stand[i].rollDiameterBL = Convert.ToDouble(dt.Rows[0]["burdialow" + (i + 1).ToString()]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
macReview.Stand[i].rollDiameterWU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterWL = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterMU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterML = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBU = 0;
|
|||
|
|
macReview.Stand[i].rollDiameterBL = 0;
|
|||
|
|
}
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetCoilInfoByEnergyPath", ex.ToString());
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void recordLogInfo(string userName, string logInfo)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string insert_sql = string.Format("insert into t_log_info (seqno,username,loginfo) values((select max(seqno) + 1 from t_log_info),'{0}','{1}')",
|
|||
|
|
userName, logInfo);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("recordLogInfo", ex.ToString());
|
|||
|
|
recordLogInfoFirst(userName, logInfo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
public void recordLogInfoFirst(string userName, string logInfo)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string insert_sql = string.Format("insert into t_log_info (seqno,username,loginfo) values(1,'{0}','{1}')",
|
|||
|
|
userName, logInfo);
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("recordLogInfoFirst", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取基本配置参数,包括报警次数,采样点数等
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetBaseConfig()
|
|||
|
|
{
|
|||
|
|
string sql_str = "select key,value from t_dict_data;";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable dt = localConnect.DataBase(sql_str);
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetAlarmParam()
|
|||
|
|
{
|
|||
|
|
string sql_str = "select standno,alarmspeed,lowpassl,lowpassu,lowalarmvalue,lowdefectvalue,midpassl," +
|
|||
|
|
"midpassu,midalarmvalue,middefectvalue,highpassl,highpassu,highalarmvalue,highdefectvalue," +
|
|||
|
|
"alarmtimes_l,alarmtimes_m,alarmtimes_h from t_alarm_param order by standno ,alarmspeed ;";
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable dt = localConnect.DataBase(sql_str);
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获取指定机架的报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public DataTable GetAlarmParamByStanNo(int standNo)
|
|||
|
|
{
|
|||
|
|
string sql_str = "select alarmspeed,lowpassl,lowpassu,lowalarmvalue,lowdefectvalue,midpassl," +
|
|||
|
|
"midpassu,midalarmvalue,middefectvalue,highpassl,highpassu,highalarmvalue,higdefectvalue from t_alarm_param" +
|
|||
|
|
String.Format(" where standno={};", standNo);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
DataTable dt = localConnect.DataBase(sql_str);
|
|||
|
|
return dt;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
DataTable errdt = new DataTable();
|
|||
|
|
return errdt;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增报警参数记录
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="data"></param>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
public void AddAlarmParamByStandNo(EntityAlarmSpeed data, int standNo)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string insert_sql = "insert into t_alarm_param (standno,alarmspeed,lowpassl," +
|
|||
|
|
"lowpassu,lowalarmvalue,lowdefectvalue,midpassl,midpassu,midalarmvalue,middefectvalue,highpassl," + String.Format("highpassu,highalarmvalue,highdefectvalue) values({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13})", standNo,
|
|||
|
|
data.alarmSpeed, data.lowPassL, data.lowPassU, data.lowAlarmValue, data.lowDefectValue, data.midPassL, data.midPassU,
|
|||
|
|
data.midAlarmValue, data.midDefectValue, data.highPassL, data.highPassU, data.highAlarmValue, data.highDefectValue);
|
|||
|
|
;
|
|||
|
|
localConnect.DataBase(insert_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("AddAlarmParamByStandNo", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 单个机架报警参数更新
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="data"></param>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
public void UpdateAlarmParamByStandNo(IList<EntityAlarmSpeed> data, int standNo)
|
|||
|
|
{
|
|||
|
|
if (data == null || data.Count == 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (standNo > 0 && standNo < SysParam.Instance.SpeedChannelCount + 1)
|
|||
|
|
{
|
|||
|
|
//报警参数
|
|||
|
|
DeleteAlarmParamByStandNo(standNo);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
foreach (EntityAlarmSpeed item in data)
|
|||
|
|
{
|
|||
|
|
AddAlarmParamByStandNo(item, standNo);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("SaveAlarmParam", String.Format("standno:{0},Error:", standNo) + ex.ToString());
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
//报警次数
|
|||
|
|
UpdateAlarmTimes(standNo, SysParam.Instance.channel[standNo - 1].alarmTimes_l,
|
|||
|
|
SysParam.Instance.channel[standNo - 1].alarmTimes_m,
|
|||
|
|
SysParam.Instance.channel[standNo - 1].alarmTimes_h);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除指定机架的报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="standNo"></param>
|
|||
|
|
public void DeleteAlarmParamByStandNo(int standNo)
|
|||
|
|
{
|
|||
|
|
string delete_sql = String.Format("delete from t_alarm_param where standno = {0};", standNo);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
localConnect.DataBase(delete_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("GetBaseConfig()", ex.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存有速度机架的整个报警参数
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="datas"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public bool SaveAlarmParam(Dictionary<int, IList<EntityAlarmSpeed>> datas)
|
|||
|
|
{
|
|||
|
|
//报警参数
|
|||
|
|
foreach (KeyValuePair<int, IList<EntityAlarmSpeed>> items in datas)
|
|||
|
|
{
|
|||
|
|
if (items.Value != null && items.Value.Count > 0)
|
|||
|
|
{
|
|||
|
|
int standNoi = items.Key + 1;
|
|||
|
|
if (standNoi > 0 && standNoi < SysParam.Instance.SpeedChannelCount + 1)
|
|||
|
|
{
|
|||
|
|
DeleteAlarmParamByStandNo(standNoi);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
foreach (EntityAlarmSpeed item in items.Value)
|
|||
|
|
{
|
|||
|
|
AddAlarmParamByStandNo(item, standNoi);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("SaveAlarmParam", String.Format("standno:{0},Error:", standNoi) + ex.ToString());
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//报警次数
|
|||
|
|
for (int i = 0; i < SysParam.Instance.SpeedChannelCount; i++)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
UpdateAlarmTimes(i + 1, SysParam.Instance.channel[i].alarmTimes_l,
|
|||
|
|
SysParam.Instance.channel[i].alarmTimes_m,
|
|||
|
|
SysParam.Instance.channel[i].alarmTimes_h);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 将数据库报警参数更新到系统
|
|||
|
|
/// </summary>
|
|||
|
|
public void autoUpdateAlarmParam()
|
|||
|
|
{
|
|||
|
|
//报警参数
|
|||
|
|
DataTable eas = GetAlarmParam();
|
|||
|
|
if (eas == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Dictionary<int, IList<EntityAlarmSpeed>> config_base = new Dictionary<int, IList<EntityAlarmSpeed>>();
|
|||
|
|
|
|||
|
|
for (int i = 0; i < eas.Rows.Count; i++)
|
|||
|
|
{
|
|||
|
|
DataRow row = eas.Rows[i];
|
|||
|
|
EntityAlarmSpeed itemdata = new EntityAlarmSpeed();
|
|||
|
|
int standNo = Convert.ToInt32(row["standno"]);
|
|||
|
|
itemdata.alarmSpeed = Convert.ToInt32(row["alarmspeed"]);
|
|||
|
|
itemdata.lowPassL = Convert.ToInt32(row["lowpassl"]);
|
|||
|
|
itemdata.lowPassU = Convert.ToInt32(row["lowpassu"]);
|
|||
|
|
itemdata.lowAlarmValue = Convert.ToSingle(row["lowalarmvalue"]);
|
|||
|
|
itemdata.lowDefectValue = Convert.ToSingle(row["lowdefectvalue"]);
|
|||
|
|
itemdata.midPassL = Convert.ToInt32(row["midpassl"]);
|
|||
|
|
itemdata.midPassU = Convert.ToInt32(row["midpassu"]);
|
|||
|
|
itemdata.midAlarmValue = Convert.ToSingle(row["midalarmvalue"]);
|
|||
|
|
itemdata.midDefectValue = Convert.ToSingle(row["middefectvalue"]);
|
|||
|
|
itemdata.highPassL = Convert.ToInt32(row["highpassl"]);
|
|||
|
|
itemdata.highPassU = Convert.ToInt32(row["highpassu"]);
|
|||
|
|
itemdata.highAlarmValue = Convert.ToSingle(row["highalarmvalue"]);
|
|||
|
|
itemdata.highDefectValue = Convert.ToSingle(row["highdefectvalue"]);
|
|||
|
|
|
|||
|
|
if (!config_base.ContainsKey(standNo - 1))
|
|||
|
|
{
|
|||
|
|
IList<EntityAlarmSpeed> itemlist = new List<EntityAlarmSpeed>();
|
|||
|
|
config_base.Add(standNo - 1, itemlist);
|
|||
|
|
}
|
|||
|
|
config_base[standNo - 1].Add(itemdata);
|
|||
|
|
}
|
|||
|
|
for (int j = 0; j < config_base.Keys.Count; j++)
|
|||
|
|
{
|
|||
|
|
SysParam.Instance.channel[j].alarmConfig = config_base[j].ToArray();//报警参数
|
|||
|
|
DataRow dr = eas.Select(String.Format("standno={0}", j + 1))[0];
|
|||
|
|
SysParam.Instance.channel[j].alarmTimes_l = Convert.ToInt32(dr["alarmtimes_l"]);//报警次数
|
|||
|
|
SysParam.Instance.channel[j].alarmTimes_m = Convert.ToInt32(dr["alarmtimes_m"]);//报警次数
|
|||
|
|
SysParam.Instance.channel[j].alarmTimes_h = Convert.ToInt32(dr["alarmtimes_h"]);//报警次数
|
|||
|
|
}
|
|||
|
|
Console.WriteLine("test");
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("autoUpdateAlarmParam", ex.Message);
|
|||
|
|
}
|
|||
|
|
//报警次数
|
|||
|
|
|
|||
|
|
//DataTable kv = GetBaseConfig();
|
|||
|
|
//if (kv == null)
|
|||
|
|
//{
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// try
|
|||
|
|
// {
|
|||
|
|
// for (int i = 0; i < kv.Rows.Count; i++)
|
|||
|
|
// {
|
|||
|
|
// string keyi = Convert.ToString(kv.Rows[i]["key"]);
|
|||
|
|
// if (keyi == "alarmTimes_l" || keyi == "alarmTimes_m" || keyi == "alarmTimes_h")
|
|||
|
|
// {
|
|||
|
|
// for (int j = 0; j < SysParam.Instance.SpeedChannelCount; j++)
|
|||
|
|
// {
|
|||
|
|
// if (keyi == "alarmTimes_l")
|
|||
|
|
// {
|
|||
|
|
// SysParam.Instance.channel[j].alarmTimes_l = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// }
|
|||
|
|
// else if (keyi == "alarmTimes_m")
|
|||
|
|
// {
|
|||
|
|
// SysParam.Instance.channel[j].alarmTimes_m = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// SysParam.Instance.channel[j].alarmTimes_h = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// }
|
|||
|
|
// //else if(keyi == "vibSens")
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.channel[j].vibSens = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
// //else
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.channel[j].speedSens = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
// //else
|
|||
|
|
// //{
|
|||
|
|
// // DevelopLog.DeBug.WriteLogFile("autoUpdateAlarmParam-BaseConfig", "Error:参数异常,key="+keyi);
|
|||
|
|
// //}
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// //else if (keyi == "samplePoint")
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.samplePoint = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
// //else if (keyi == "sampleFre")
|
|||
|
|
// //{
|
|||
|
|
// // SysParam.Instance.sampleFre = Convert.ToInt32(kv.Rows[i]["value"]);
|
|||
|
|
// //}
|
|||
|
|
|
|||
|
|
|
|||
|
|
// }
|
|||
|
|
// }
|
|||
|
|
// catch (Exception ex)
|
|||
|
|
// {
|
|||
|
|
// DevelopLog.DeBug.WriteLogFile("autoUpdateAlarmParam-BaseConfig", ex.Message);
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
public void UpdateAlarmTimes(int standNo, int l, int m, int h)
|
|||
|
|
{
|
|||
|
|
if (l < 0 || m < 0 || h < 0 || standNo < 0 || standNo > SysParam.Instance.SpeedChannelCount)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateAlarmTimes",
|
|||
|
|
String.Format("参数异常:standNo={0},l={1},m={2},h={3}", standNo, l, m, h));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string update_sql = String.Format("update t_alarm_param set alarmtimes_l={0},alarmtimes_m={1},alarmtimes_h={2} where standno={3};", l, m, h, standNo);
|
|||
|
|
localConnect.DataBase(update_sql);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
DevelopLog.DeBug.WriteLogFile("UpdateAlarmTimes", ex.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|