Ejemplo n.º 1
0
        /// <summary>
        /// 生成工位点
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="stationNo"></param>
        /// <param name="resourceId"></param>
        /// <param name="deviceId"></param>
        private void generateStationInfoData(string stationName, int stationNo, string resourceId, string deviceId)
        {
            InterfaceFactory.getInstance(this.mainFormOperation, interfaceType).checkStationInfo(stationName, stationNo, resourceId, deviceId);

            for (int i = 0; i < this.pointNames.Count; i++)
            {
                Dictionary <string, PointAttr> dictionary = this.csvRowAttrs[i];
                List <PointAttr> csvRowAttrList           = dictionary.Values.ToList();
                PointAttr        csvRowAttr = csvRowAttrList[0];

                List <CSVCell> rows = new List <CSVCell>();

                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Pt_id, csvRowAttr.Pt_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Access, csvRowAttr.Access));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Access_filter, csvRowAttr.Access_filter));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Ack_timeout_hi, csvRowAttr.Ack_timeout_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Ack_timeout_hihi, csvRowAttr.Ack_timeout_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Ack_timeout_lo, csvRowAttr.Ack_timeout_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Ack_timeout_lolo, csvRowAttr.Ack_timeout_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Addr, csvRowAttr.Addr));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Addr_offset, csvRowAttr.Addr_offset));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Addr_type, csvRowAttr.Addr_type));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_changeapproval, csvRowAttr.Alarm_changeapproval));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_hi, csvRowAttr.Alarm_delay_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_hihi, csvRowAttr.Alarm_delay_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_lo, csvRowAttr.Alarm_delay_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_lolo, csvRowAttr.Alarm_delay_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_unit_hi, csvRowAttr.Alarm_delay_unit_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_unit_hihi, csvRowAttr.Alarm_delay_unit_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_unit_lo, csvRowAttr.Alarm_delay_unit_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_delay_unit_lolo, csvRowAttr.Alarm_delay_unit_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alarm_publish, csvRowAttr.Alarm_publish));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_class, csvRowAttr.Alm_class));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_criteria, csvRowAttr.Alm_criteria));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_deadband, csvRowAttr.Alm_deadband));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_delay, csvRowAttr.Alm_delay));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_enable, csvRowAttr.Alm_enable));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_high_1, csvRowAttr.Alm_high_1));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_high_2, csvRowAttr.Alm_high_2));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_hlp_file, csvRowAttr.Alm_hlp_file));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_low_1, csvRowAttr.Alm_low_1));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_low_2, csvRowAttr.Alm_low_2));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_msg, csvRowAttr.Alm_msg));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_route_oper, csvRowAttr.Alm_route_oper));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_route_sysmgr, csvRowAttr.Alm_route_sysmgr));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_route_user, csvRowAttr.Alm_route_user));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_severity, csvRowAttr.Alm_severity));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_str, csvRowAttr.Alm_str));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_type, csvRowAttr.Alm_type));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Alm_update_value, csvRowAttr.Alm_update_value));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Analog_deadband, csvRowAttr.Analog_deadband));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_count, csvRowAttr.Bfr_count));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_dur, csvRowAttr.Bfr_dur));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_event_period, csvRowAttr.Bfr_event_period));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_event_pt_id, csvRowAttr.Bfr_event_pt_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_event_type, csvRowAttr.Bfr_event_type));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_event_units, csvRowAttr.Bfr_event_units));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_gate_cond, csvRowAttr.Bfr_gate_cond));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Bfr_sync_time, csvRowAttr.Bfr_sync_time));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Calc_type, csvRowAttr.Calc_type));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Changeapproval, csvRowAttr.Changeapproval));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Conv_lim_high, csvRowAttr.Conv_lim_high));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Conv_lim_low, csvRowAttr.Conv_lim_low));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Conv_type, csvRowAttr.Conv_type));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Delay_load, csvRowAttr.Delay_load));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Delete_req_hi, csvRowAttr.Delete_req_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Delete_req_hihi, csvRowAttr.Delete_req_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Delete_req_lo, csvRowAttr.Delete_req_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Delete_req_lolo, csvRowAttr.Delete_req_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Desc, csvRowAttr.Desc));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Deviation_pt, csvRowAttr.Deviation_pt));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Device_id, csvRowAttr.Device_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Disp_lim_high, csvRowAttr.Disp_lim_high));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Disp_lim_low, csvRowAttr.Disp_lim_low));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Disp_type, csvRowAttr.Disp_type));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Disp_width, csvRowAttr.Disp_width));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Elements, csvRowAttr.Elements));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Eng_units, csvRowAttr.Eng_units));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Enum_id, csvRowAttr.Enum_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Equation, csvRowAttr.Equation));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Extra, csvRowAttr.Extra));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Fw_conv_eq, csvRowAttr.Fw_conv_eq));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Gr_screen, csvRowAttr.Gr_screen));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Init_val, csvRowAttr.Init_val));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Justification, csvRowAttr.Justification));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Level, csvRowAttr.Level));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Local, csvRowAttr.Local));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_ack_hi, csvRowAttr.Log_ack_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_ack_hihi, csvRowAttr.Log_ack_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_ack_lo, csvRowAttr.Log_ack_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_ack_lolo, csvRowAttr.Log_ack_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_data, csvRowAttr.Log_data));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_del_hi, csvRowAttr.Log_del_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_del_hihi, csvRowAttr.Log_del_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_del_lo, csvRowAttr.Log_del_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_del_lolo, csvRowAttr.Log_del_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_gen_hi, csvRowAttr.Log_gen_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_gen_hihi, csvRowAttr.Log_gen_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_gen_lo, csvRowAttr.Log_gen_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_gen_lolo, csvRowAttr.Log_gen_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_reset_hi, csvRowAttr.Log_reset_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_reset_hihi, csvRowAttr.Log_reset_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_reset_lo, csvRowAttr.Log_reset_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Log_reset_lolo, csvRowAttr.Log_reset_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Max_stacked, csvRowAttr.Max_stacked));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Measurement_unit_id, csvRowAttr.Measurement_unit_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Misc_flags, csvRowAttr.Misc_flags));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Poll_after_set, csvRowAttr.Poll_after_set));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Precision, csvRowAttr.Precision));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Proc_id, csvRowAttr.Proc_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Ptmgmt_proc_id, csvRowAttr.Ptmgmt_proc_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Pt_enabled, csvRowAttr.Pt_enabled));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Pt_origin, csvRowAttr.Pt_origin));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Pt_set_interval, csvRowAttr.Pt_set_interval));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Pt_set_time, csvRowAttr.Pt_set_time));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Pt_type, csvRowAttr.Pt_type));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Range_high, csvRowAttr.Range_high));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Range_low, csvRowAttr.Range_low));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Raw_lim_high, csvRowAttr.Raw_lim_high));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Raw_lim_low, csvRowAttr.Raw_lim_low));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Rep_timeout_hi, csvRowAttr.Rep_timeout_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Rep_timeout_hihi, csvRowAttr.Rep_timeout_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Rep_timeout_lo, csvRowAttr.Rep_timeout_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Rep_timeout_lolo, csvRowAttr.Rep_timeout_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_allowed_hi, csvRowAttr.Reset_allowed_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_allowed_hihi, csvRowAttr.Reset_allowed_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_allowed_lo, csvRowAttr.Reset_allowed_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_allowed_lolo, csvRowAttr.Reset_allowed_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_cond, csvRowAttr.Reset_cond));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_pt, csvRowAttr.Reset_pt));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_timeout_hi, csvRowAttr.Reset_timeout_hi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_timeout_hihi, csvRowAttr.Reset_timeout_hihi));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_timeout_lo, csvRowAttr.Reset_timeout_lo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Reset_timeout_lolo, csvRowAttr.Reset_timeout_lolo));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Resource_id, csvRowAttr.Resource_id));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Rev_conv_eq, csvRowAttr.Rev_conv_eq));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Rollover_val, csvRowAttr.Rollover_val));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Safety_pt, csvRowAttr.Safety_pt));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Sample_intv, csvRowAttr.Sample_intv));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Sample_intv_unit, csvRowAttr.Sample_intv_unit));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Scan_rate, csvRowAttr.Scan_rate));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Setpoint_high, csvRowAttr.Setpoint_high));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Setpoint_low, csvRowAttr.Setpoint_low));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Time_of_day, csvRowAttr.Time_of_day));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Trig_ck_pt, csvRowAttr.Trig_ck_pt));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Trig_pt, csvRowAttr.Trig_pt));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Trig_rel, csvRowAttr.Trig_rel));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Trig_val, csvRowAttr.Trig_val));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Uafset, csvRowAttr.Uafset));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Update_criteria, csvRowAttr.Update_criteria));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Variance_val, csvRowAttr.Variance_val));
                rows.Add(generateCSVCell(mCSV.PointAttrFiled.Vars, csvRowAttr.Vars));

                this.mCSV.createRow(rows);
            }

            csvRowAttrs.Clear();
        }
Ejemplo n.º 2
0
        private void loadStationAlarm(List <Area> areas, DataTable dtStationAlarm, int dtStationInfoRows, int progressMaxValue)
        {
            List <PLC>         plcs         = null;
            List <Station>     stations     = new List <Station>();
            List <AlarmDetail> alarmDetails = null;
            int rowNumberThisPlc            = 1; //当前plc报警详细数量行,初始带标题+1
            int rowNumbersAllPlc            = 0; //所有plc报警详细数量行累加之和,带标题

            Area        area    = null;
            PLC         plc     = null;
            Station     station = null;
            AlarmDetail ad      = null;

            bool readMultiPlcConfig = Global.isReadMultiAlarmConfig;
            int  excelNumber        = 0;


            if (null == dtStationAlarm || dtStationAlarm.Rows.Count == 0)
            {
                return;
            }

            string plcNamePrev   = null;
            int    stationNoPrev = -1;

            string[] fileds = new string[] { "PLC", "IP", "StationNo", "StationName", "AlarmId", "Description" };
            if (!checkTitle(dtStationAlarm, fileds, 6))
            {
                throw new MyException(Constant.CONFIG_STATION_ALARM + "标题不符合要求!");
            }

            //2017/9/30
            if (dtStationAlarm.Rows.Count == 0)
            {
                throw new MyException(Constant.CONFIG_STATION_ALARM + "读取数据为空,请检查Sheet名是否为" + Constant.SHEET_NAME);
            }

            //dtStationAlarm.Rows.Count 总数量不带标题
            for (int m = 0; m < dtStationAlarm.Rows.Count; m++)
            {
                string plcName         = dtStationAlarm.Rows[m]["PLC"].ToString().Trim();
                string sStationNo      = dtStationAlarm.Rows[m]["StationNo"].ToString().Trim();
                string sAlarmIdConfig1 = dtStationAlarm.Rows[m]["AlarmId"].ToString().Trim();
                string alarmDetail     = dtStationAlarm.Rows[m]["Description"].ToString().Trim();
                int    stationNo       = -1;
                int    result          = -1;
                bool   flag;

                //获取plcName,不切换plc时
                if (string.IsNullOrEmpty(plcName))   //支持多PLC在一个配置文件中 2017/9/21
                {
                    if (!string.IsNullOrEmpty(plcNamePrev))
                    {
                        plcName = plcNamePrev;
                    }
                    rowNumberThisPlc++;
                }
                else
                {
                    rowNumberThisPlc = (readMultiPlcConfig == true ? 2 : 1);
                }

                //设置Excel号
                rowNumbersAllPlc = m + 1 + 1;    //序号+1,标题+1
                excelNumber      = (readMultiPlcConfig == true ? rowNumberThisPlc : rowNumbersAllPlc);

                //获取stationNo
                if (!string.IsNullOrEmpty(sStationNo))
                {
                    result = -1;
                    flag   = int.TryParse(sStationNo, out result);
                    if (!flag)
                    {
                        throw new MyException(Constant.CONFIG_STATION_ALARM + "文件中配置了错误的StationNo。Excel行号=" + excelNumber + ",plcName=" + plcName);
                    }

                    stationNo = result;
                }
                else
                {
                    if (stationNoPrev > 0)
                    {
                        stationNo = stationNoPrev;
                    }
                }

                //获取alarmId
                if (!sAlarmIdConfig1.ToUpper().Contains("ALARM"))
                {
                    throw new MyException(Constant.CONFIG_STATION_ALARM + "文件中配置了错误的AlarmId。Excel行号=" + excelNumber + ",AlarmId=" + sAlarmIdConfig1 + ",plcName=" + plcName);
                }

                sAlarmIdConfig1 = sAlarmIdConfig1.Replace("ALARM", "");
                string sAlarmIdConfig2 = OtherUtils.getStringBetweenBracket(sAlarmIdConfig1);

                flag = int.TryParse(sAlarmIdConfig2, out result);

                if (!flag || result < Constant.ALARM_NUMBER_COUNT_MIN || result > Constant.ALARM_NUMBER_COUNT_MAX)
                {
                    throw new MyException(Constant.CONFIG_STATION_ALARM + "文件中配置了错误的AlarmId。Excel行号=" + excelNumber + ",AlarmId=" + result + ",plcName=" + plcName);
                }
                int alarmId = result;

                //对报警描述处理
                //仅支持80个字符。
                if (alarmDetail.Length > 80)
                {
                    alarmDetail = alarmDetail.Substring(0, 79);
                }

                //处理特殊字符
                List <string> specialChars = InterfaceFactory.getInstance(this.mainFormOperation, this.interfaceType).SpecialChar.specialChars;
                for (int i = 0; i < specialChars.Count; i++)
                {
                    if (alarmDetail.Contains(specialChars[i]))
                    {
                        alarmDetail = alarmDetail.Replace(specialChars[i], "");
                        OtherUtils.writeMsgByByte(Constant.LOG_PATH, "检测到报警描述中含有特殊字符=" + specialChars[i] + ",已经删除。Excel行号=" + excelNumber + ",AlarmId=" + alarmId + ",plcName=" + plcName);
                    }
                }

                bool noPlcExist = true;

                if (!string.IsNullOrEmpty(sStationNo))
                {
                    for (int n = 0; n < areas.Count; n++)
                    {
                        area = areas[n];
                        plcs = areas[n].Plcs;
                        for (int o = 0; o < plcs.Count; o++)
                        {
                            if (plcName == plcs[o].Name)
                            {
                                noPlcExist = false;

                                plc      = plcs[o];
                                stations = plc.Stations;
                                for (int p = 0; p < stations.Count; p++)
                                {
                                    if (stations[p].Number == stationNo)         //两个配置文件中的工位号必须保持一致
                                    {
                                        station      = stations[p];
                                        alarmDetails = station.AlarmDetails;     //直接操作了areas里的AlarmDetails
                                        ad           = getAlarmDetail(alarmId, alarmDetail);
                                        alarmDetails.Add(ad);
                                        break;
                                    }
                                }
                                break;
                            }
                        }
                    }

                    if (noPlcExist)
                    {
                        throw new MyException(Constant.CONFIG_STATION_ALARM + "文件中无匹配的PLC存在。Excel行号=" + excelNumber + ",plcName=" + plcName);
                    }

                    plcNamePrev   = plcName;
                    stationNoPrev = stationNo;
                }
                else
                {
                    //配置文件中的报警号=当前工位号,否则不加入
                    if (stationNo == station.Number)
                    {
                        ad = getAlarmDetail(alarmId, alarmDetail);
                        alarmDetails.Add(ad);
                    }
                }

                //判断退出之前更新进度条
                int progressVlaue = dtStationInfoRows + m + 1;
                reportProcess(progressVlaue, "读取station alarm中... area=" + area.Name + ",plcName=" + plc.Name + ",station=" + station.Name + "alarmId=" + alarmId + ",alarm=" + alarmDetail + ",Excel行号=" + excelNumber);

                //最后一行退出
                if (m == dtStationAlarm.Rows.Count - 1)
                {
                    if (this.main.getProgressBar().Value < progressMaxValue)
                    {
                        this.main.stopProgressBar();
                    }
                    return;
                }

                //判断空行
                string plcNameNext     = dtStationAlarm.Rows[m + 1]["PLC"].ToString().Trim();
                string sStationNoNext  = dtStationAlarm.Rows[m + 1]["StationNo"].ToString().Trim();
                string sAlarmIdNext    = dtStationAlarm.Rows[m + 1]["AlarmId"].ToString().Trim();
                string alarmDetailNext = dtStationAlarm.Rows[m + 1]["Description"].ToString().Trim();

                if (string.IsNullOrEmpty(sAlarmIdNext) && string.IsNullOrEmpty(alarmDetailNext))
                {
                    throw new MyException(Constant.CONFIG_STATION_ALARM + "文件中包含空行。Excel行号=" + (rowNumberThisPlc + 1) + ",plcName=" + plcName);
                }
            }
        }
Ejemplo n.º 3
0
 public AlarmPoint(MainController _mainController, MainFormOperation _mainFormOperation, InterfaceEnum _interface)
     : base(_mainController, _mainFormOperation)
 {
     pmcInterface = InterfaceFactory.getInstance(_mainFormOperation, this.interfaceType);
 }