private void Write() { string text = txtLogContent.Text; if (String.IsNullOrWhiteSpace(text)) { MessageBox.Show("日志内容不能为空!"); return; } try { HslMessageDegree degree = HslMessageDegree.INFO; //HslMessageDegree degree = (HslMessageDegree)cmbLogLv.SelectedItem; WriteLog(degree, txtLogKey.Text /*cmbLogKey.Text*/, text); Thread.Sleep(50); LoadLog(); m_formMain.AddTips("写入成功!", false); } catch (Exception ex) { m_formMain.AddTips("写入失败", true); m_formMain.LogNetProgramer.WriteError("写入日志异常---->", ex.Message); } }
private void AlarmMonitor() { while (b_isWindowShow) { try { if (m_opcUaClient != null && m_opcUaClient.Connected) { AlarmNo = m_opcUaClient.ReadNode <int>("ns=3;s=\"WeldPara\".\"Alarmlog\""); if (AlarmNo != 0) { if (AlarmNo != AlarmNoLast) { if (m_main.IsStation_S) { AlarmContent = Alarm.SortAlarmS(AlarmNo); } else { AlarmContent = Alarm.SortAlarmL(AlarmNo); } AlarmNoLast = AlarmNo; b_saveAlarmLog = true; } } } } catch (Exception ex) { m_main.AddTips(ResourceCulture.GetValue("PLCConnectException"), true); m_main.LogNetProgramer.WriteError("异常", "读取报警内容异常--->" + ex.Message); } Thread.Sleep(3000); } }
/// <summary> /// 保存焊接参数并显示数据 /// </summary> /// <param name="power">焊接功率</param> /// <param name="speed">焊接转速</param> /// <param name="pos">XYZR坐标</param> /// <param name="time">焊接时间</param> /// <param name="pressure">保护气体压力值</param> /// <param name="flow">保护气体流量值</param> /// <param name="pno">设备编号</param> private bool SaveWeldParam(double power, int speed, double xpos, double ypos, double zpos, double rpos, int time, double pressure, double flow, string pno) { string sql = "UPDATE Product SET XPos=@xpos,YPos=@ypos,ZPos=@zpos,RPos=@rpos WHERE PNo=@pno"; SqlParameter[] sqlParameters = { new SqlParameter { ParameterName = "@xpos", SqlDbType = SqlDbType.Decimal, SqlValue = xpos }, new SqlParameter { ParameterName = "@ypos", SqlDbType = SqlDbType.Decimal, SqlValue = ypos }, new SqlParameter { ParameterName = "@zpos", SqlDbType = SqlDbType.Decimal, SqlValue = zpos }, new SqlParameter { ParameterName = "@rpos", SqlDbType = SqlDbType.Decimal, SqlValue = rpos }, new SqlParameter { ParameterName = "@pno", SqlDbType = SqlDbType.NVarChar, SqlValue = pno } }; int c = m_tool.ModifyTable(sql, sqlParameters); if (c > 0) { //Debug.WriteLine("焊接参数保存成功!"); return(true); } else { m_main.AddTips("焊接参数保存失败 !", true); return(false); } }
private void btnSelectByTerm_Click(object sender, EventArgs e) { if (!SQLServerDAL.SqlHelper.IsConnection(SQLServerDAL.SqlHelper.SQLServerConnectionString)) { return; } DateTime starTime = timeCheckStart.Value; DateTime endTime = timeCheckEnd.Value; if (starTime > endTime) { MessageBox.Show("起始时间不能大于终止时间!"); return; } bool productChecked = chkProductState.Checked; bool coaxStateChecked = chkCoaxState.Checked; bool coaxRangeChecked = chkCoaxRange.Checked; bool weldChecked = chkWeldState.Checked; bool weldDepthChecked = chkWeldDepth.Checked; bool lwmStateChecked = chkLwmState.Checked; string strSQL = string.Empty; SqlWhere = new StringBuilder(" 1=1 "); strSQL = "SELECT " + m_dbColunmsNames + "FROM Product WHERE "; if (!string.IsNullOrEmpty(txtBarCode.Text.Trim())) { SqlWhere.Append(" AND PNo='" + txtBarCode.Text.Trim() + "'"); m_conditionExtra = "PNo = '" + txtBarCode.Text.Trim() + "'"; } if (productChecked)//产品状态 { SqlWhere.Append(" AND QCResult='" + cmbProductState.SelectedItem.ToString() + "'"); m_conditionExtra = "QCResult='" + cmbProductState.SelectedItem.ToString() + "'"; } if (coaxStateChecked)//同心度状态 { if (cmbCoaxState.SelectedItem.ToString() == "OK") { SqlWhere.Append(" AND Surface='OK'"); m_conditionExtra = "Surface='OK'"; } else if (cmbCoaxState.SelectedItem.ToString() == "NG") { SqlWhere.Append(" AND Surface='同心度NG'"); m_conditionExtra = " Surface='同心度NG'"; } } if (coaxRangeChecked)//同心度范围 { string coaxDown = numCoaxRangeDowm.Value.ToString(); string coaxUp = numCoaxRangeUp.Value.ToString(); SqlWhere.Append(" AND Coaxiality BETWEEN " + coaxDown + " AND " + coaxUp); m_conditionExtra = " Coaxiality BETWEEN " + coaxDown + " AND " + coaxUp; } if (weldChecked)//表面质量 { if (cmbWeldState.SelectedItem.ToString() == "OK") { SqlWhere.Append(" AND Surface='OK'"); m_conditionExtra = " Surface='OK'"; } else if (cmbWeldState.SelectedItem.ToString() == "焊缝NG") { SqlWhere.Append(" AND Surface='焊缝NG'"); m_conditionExtra = " Surface='焊缝NG'"; } else if (cmbWeldState.SelectedItem.ToString() == "瑕疵NG") { SqlWhere.Append(" AND Surface='瑕疵NG'"); m_conditionExtra = " Surface='瑕疵NG'"; } } if (weldDepthChecked)//焊缝高度差 { string depthDown = numWeldDepthDown.Value.ToString(); string depthUp = numWeldDepthUp.Value.ToString(); SqlWhere.Append(" AND WeldDepth BETWEEN " + depthDown + " AND " + depthUp); m_conditionExtra = " WeldDepth BETWEEN " + depthDown + " AND " + depthUp; } if (lwmStateChecked) { SqlWhere.Append("AND LwmCheck='" + cmbLwmState.SelectedItem.ToString() + "'"); m_conditionExtra = " LwmCheck='" + cmbLwmState.SelectedItem.ToString() + "'"; } SqlWhere.Append(" AND StorageTime BETWEEN '" + timeCheckStart.Value + "' AND '" + timeCheckEnd.Value.AddDays(1) + "' "); SqlWhere.Append("ORDER BY StorageTime DESC"); SQLFinalSelect = strSQL + SqlWhere.ToString(); stopwatch.Restart(); m_main.AddTips("正在查询数据,请稍等...", false); //更新总条数 AllCount = m_main.DbTool.GetTableCount(string.Format("SELECT COUNT(1) FROM ({0}) T", SQLFinalSelect.Replace("ORDER BY StorageTime DESC", ""))); txtAllCount.Text = AllCount.ToString(); Remain = AllCount % PageSize; UpdatePageCount(); ShowPage(Inum, PageSize); UpdateProduction(); stopwatch.Stop(); LogHelper.WriteLog("查询数据", "耗时 - " + Math.Round(stopwatch.Elapsed.TotalSeconds, 2) + " s"); m_main.AddTips("查询成功!", false); //Query(); }