示例#1
0
        public void Log(AlarmObject alarmObj, AlarmLogType logType)
        {
            switch (logType)
            {
                case AlarmLogType.Occur:
                    AlarmLog.Log(alarmObj.Identifier + " " + alarmObj.AlarmCode + " Occurred ");
                    break;

                case AlarmLogType.Release:
                    AlarmLog.Log(alarmObj.Identifier + " " + alarmObj.AlarmCode + " Released by " + alarmObj.ResetResult);
                    break;
            }
        }
        private void LoadIniFile(string iniFilePath)
        {
            IniFile iniFile = new IniFile(iniFilePath);

            for (int i = 0; i < iniFile.GetSectionNames().Length; i++)
            {
                AlarmObject alarmObj = new AlarmObject(iniFile.GetSectionNames()[i]);

                alarmObj.Level = iniFile.GetString(iniFile.GetSectionNames()[i], "Level", "");
                alarmObj.Type = iniFile.GetString(iniFile.GetSectionNames()[i], "Type", "");
                alarmObj.Reset = (iniFile.GetInt32(iniFile.GetSectionNames()[i], "Reset", 0) == 1) ? true : false;
                alarmObj.Retry = (iniFile.GetInt32(iniFile.GetSectionNames()[i], "Retry", 0) == 1) ? true : false;
                alarmObj.Skip = (iniFile.GetInt32(iniFile.GetSectionNames()[i], "Skip", 0) == 1) ? true : false;
                alarmObj.Continue = (iniFile.GetInt32(iniFile.GetSectionNames()[i], "Continue", 0) == 1) ? true : false;
                alarmObj.Message = iniFile.GetString(iniFile.GetSectionNames()[i], "Message", "");
                alarmObj.TroubleShooting = iniFile.GetString(iniFile.GetSectionNames()[i], "Troubleshooting", "");
                alarmObj.ReleaseTime = "";
                alarmObj.ReportTime = "";
                alarmObj.Message = alarmObj.Message.Replace("**********", "\r\n");
                alarmObj.TroubleShooting = alarmObj.TroubleShooting.Replace("**********", "\r\n");

                alarmList.Add(alarmObj);
            }
        }
        private bool GetDataFromUI()
        {
            List<AlarmObject> alarmListTemp = new List<AlarmObject>();
            bool bFault = false;

            for (int i = 0; i < alarmListDataGridView.Rows.Count; i++)
            {
                bool bSkip = false;

                if (alarmListDataGridView.Rows[i].Cells[0].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[0].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[0].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[1].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[1].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[1].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[2].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[2].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[2].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[3].Value == null)
                    alarmListDataGridView.Rows[i].Cells[3].Value = false;
                if (alarmListDataGridView.Rows[i].Cells[4].Value == null)
                    alarmListDataGridView.Rows[i].Cells[4].Value = false;
                if (alarmListDataGridView.Rows[i].Cells[5].Value == null)
                    alarmListDataGridView.Rows[i].Cells[5].Value = false;
                if (alarmListDataGridView.Rows[i].Cells[6].Value == null)
                    alarmListDataGridView.Rows[i].Cells[6].Value = false;
                if (alarmListDataGridView.Rows[i].Cells[7].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[7].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[7].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[8].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[8].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[8].Style.BackColor = Color.Red;
                    bSkip = true;
                }

                if (bSkip == false)
                {
                    AlarmObject alarmObj = new AlarmObject((string)alarmListDataGridView.Rows[i].Cells[0].Value);

                    alarmObj.Level = (string)alarmListDataGridView.Rows[i].Cells[1].Value;
                    alarmObj.Type = (string)alarmListDataGridView.Rows[i].Cells[2].Value;
                    alarmObj.Reset = (bool)alarmListDataGridView.Rows[i].Cells[3].Value;
                    alarmObj.Retry = (bool)alarmListDataGridView.Rows[i].Cells[4].Value;
                    alarmObj.Skip = (bool)alarmListDataGridView.Rows[i].Cells[5].Value;
                    alarmObj.Continue = (bool)alarmListDataGridView.Rows[i].Cells[6].Value;
                    alarmObj.Message = (string)alarmListDataGridView.Rows[i].Cells[7].Value;
                    alarmObj.TroubleShooting = (string)alarmListDataGridView.Rows[i].Cells[8].Value;

                    alarmListTemp.Add(alarmObj);
                }
                else
                    bFault = true;
            }
            if (bFault == false)
            {
                alarmList = alarmListTemp;
                return true;
            }
            else
                return false;
        }
 public bool GetAlarmInfo(ref AlarmObject alarmObject)
 {
     for (int i = 0; i < alarmList.Count; i++)
     {
         if (alarmList[i].AlarmCode.Equals(alarmObject.AlarmCode) == true)
         {
             alarmObject.Message = alarmList[i].Message;
             alarmObject.Level = alarmList[i].Level;
             alarmObject.TroubleShooting = alarmList[i].TroubleShooting;
             alarmObject.Type = alarmList[i].Type;
             alarmObject.Reset = alarmList[i].Reset;
             alarmObject.Retry = alarmList[i].Retry;
             alarmObject.Skip = alarmList[i].Skip;
             alarmObject.Continue = alarmList[i].Continue;
             return true;
         }
     }
     return false;
 }
示例#5
0
        private bool GetDataFromUI()
        {
            List <AlarmObject> alarmListTemp = new List <AlarmObject>();
            bool bFault = false;

            for (int i = 0; i < alarmListDataGridView.Rows.Count; i++)
            {
                bool bSkip = false;

                if (alarmListDataGridView.Rows[i].Cells[0].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[0].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[0].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[1].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[1].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[1].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[2].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[2].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[2].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[3].Value == null)
                {
                    alarmListDataGridView.Rows[i].Cells[3].Value = false;
                }
                if (alarmListDataGridView.Rows[i].Cells[4].Value == null)
                {
                    alarmListDataGridView.Rows[i].Cells[4].Value = false;
                }
                if (alarmListDataGridView.Rows[i].Cells[5].Value == null)
                {
                    alarmListDataGridView.Rows[i].Cells[5].Value = false;
                }
                if (alarmListDataGridView.Rows[i].Cells[6].Value == null)
                {
                    alarmListDataGridView.Rows[i].Cells[6].Value = false;
                }
                if (alarmListDataGridView.Rows[i].Cells[7].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[7].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[7].Style.BackColor = Color.Red;
                    bSkip = true;
                }
                if (alarmListDataGridView.Rows[i].Cells[8].Value == null || ((string)alarmListDataGridView.Rows[i].Cells[8].Value).Length == 0)
                {
                    alarmListDataGridView.Rows[i].Cells[8].Style.BackColor = Color.Red;
                    bSkip = true;
                }

                if (bSkip == false)
                {
                    AlarmObject alarmObj = new AlarmObject((string)alarmListDataGridView.Rows[i].Cells[0].Value);

                    alarmObj.Level           = (string)alarmListDataGridView.Rows[i].Cells[1].Value;
                    alarmObj.Type            = (string)alarmListDataGridView.Rows[i].Cells[2].Value;
                    alarmObj.Reset           = (bool)alarmListDataGridView.Rows[i].Cells[3].Value;
                    alarmObj.Retry           = (bool)alarmListDataGridView.Rows[i].Cells[4].Value;
                    alarmObj.Skip            = (bool)alarmListDataGridView.Rows[i].Cells[5].Value;
                    alarmObj.Continue        = (bool)alarmListDataGridView.Rows[i].Cells[6].Value;
                    alarmObj.Message         = (string)alarmListDataGridView.Rows[i].Cells[7].Value;
                    alarmObj.TroubleShooting = (string)alarmListDataGridView.Rows[i].Cells[8].Value;

                    alarmListTemp.Add(alarmObj);
                }
                else
                {
                    bFault = true;
                }
            }
            if (bFault == false)
            {
                alarmList = alarmListTemp;
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#6
0
        private void InsertAlarmToAlarmReportTable(AlarmObject alarmObject)
        {
            alarmReportDataGridView.Rows.Add(1);

            int iRowIdx = alarmReportDataGridView.Rows.Count - 1;
            alarmReportDataGridView.Rows[iRowIdx].SetValues(iRowIdx + 1,
                                          alarmObject.AlarmCode,
                                          alarmObject.Level,
                                          alarmObject.Type,
                                          alarmObject.Message,
                                          DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss:fff"));
            // 更新Row的高度
            Int32 preferredNormalContentHeight =
                   alarmReportDataGridView.Rows[iRowIdx].GetPreferredHeight(alarmReportDataGridView.Rows[iRowIdx].Index,
                   DataGridViewAutoSizeRowMode.AllCellsExceptHeader, true) -
                   alarmReportDataGridView.Rows[iRowIdx].DefaultCellStyle.Padding.Bottom;

            alarmReportDataGridView.Rows[iRowIdx].Height = preferredNormalContentHeight;
        }
示例#7
0
        private void AlarmLogSpilt(ref List<AlarmObject> AlarmLogList, string szInfo, DateTime startTime, DateTime endTime, string szCode)
        {
            string[] szAllInfo = szInfo.Split(' ');
            bool bCreatNewAlarmObject = true;

            if (startTime.Ticks > 1 && endTime.Ticks > 1)
            {
                DateTime logTime = DateTime.Parse(szAllInfo[0] + " " + szAllInfo[1]);

                if (logTime.Ticks < startTime.Ticks || logTime.Ticks > endTime.Ticks)
                {
                    return;
                }
            }

            if (szCode != "" && szAllInfo[3] != szCode)
            {
                return;
            }

            foreach (AlarmObject tmpAlarm in AlarmLogList)
            {
                if (tmpAlarm.Identifier == long.Parse(szAllInfo[2]) && tmpAlarm.AlarmCode == szAllInfo[3])
                {
                    if (szAllInfo[4] == "Released")
                    {
                        tmpAlarm.ReleaseTime = szAllInfo[0] + " " + szAllInfo[1];
                        tmpAlarm.ResetResult = szAllInfo[6];
                        bCreatNewAlarmObject = false;
                        return;
                    }
                }
            }

            if (bCreatNewAlarmObject)
            {
                AlarmObject tmpAlarm = new AlarmObject(szAllInfo[3]);

                if (AlarmListPanelControl.getSingleton().GetAlarmInfo(ref tmpAlarm) == true)
                {

                }
                else
                {
                    tmpAlarm.Message = "This alarm is not being defined!";
                    tmpAlarm.Reset = true;
                }

                tmpAlarm.Identifier = long.Parse(szAllInfo[2]);
                tmpAlarm.ReportTime = szAllInfo[0] + " " + szAllInfo[1];
                tmpAlarm.ReleaseTime = "";
                AlarmLogList.Add(tmpAlarm);
            }
        }
示例#8
0
        public int ReportAlarm(string alarmCode)
        {
            AlarmObject alarmObject = new AlarmObject(alarmCode);

            if (AlarmListPanelControl.getSingleton().GetAlarmInfo(ref alarmObject) == true)
            {

            }
            else
            {
                alarmObject.Message = "This alarm is not being defined!";
                alarmObject.Reset = true;
            }

            reportAlarmList.Add(alarmObject);

            Log(alarmObject, AlarmLogType.Occur);

            if (alarmReportDataGridView.Rows.Count > 0)
                alarmReportDataGridView.Rows[0].Selected = true;

            InsertAlarmToAlarmReportTable(alarmObject);

            alarmTabControlEX.SelectedTab = currentAlarmTabPageEX;            

            return 0;
        }