Example #1
0
        /// <summary>
        ///     加载数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Maintenance_Load(object sender, EventArgs e)
        {
            try
            {
                FiveHistoryRecordData = new DataTable();
                FiveHistoryRecordData.Columns.Add("Point");
                FiveHistoryRecordData.Columns.Add("SaveTime");
                FiveHistoryRecordData.Columns.Add("TypeName");
                FiveHistoryRecordData.Columns.Add("StateName");
                FiveHistoryRecordData.Columns.Add("Location");
                FiveHistoryRecordData.Columns.Add("DeviceTypeName");
                FiveHistoryRecordData.Columns.Add("RealData");
                FiveHistoryRecordData.Columns.Add("GradingAlarmLevel");
                FiveHistoryRecordData.Columns.Add("Voltage");
                FiveHistoryRecordData.Columns.Add("FeedBackState");
                FiveHistoryRecordData.Columns.Add("FeedState");
                gridControlFiveHisData.DataSource = FiveHistoryRecordData;

                ControlHistoryRecordData = new DataTable();
                ControlHistoryRecordData.Columns.Add("Point");
                ControlHistoryRecordData.Columns.Add("SaveTime");
                ControlHistoryRecordData.Columns.Add("TypeName");
                ControlHistoryRecordData.Columns.Add("StateName");
                ControlHistoryRecordData.Columns.Add("Location");
                ControlHistoryRecordData.Columns.Add("Value");
                ControlHistoryRecordData.Columns.Add("ControlDeviceConvert");
                gridContrlConHisData.DataSource = ControlHistoryRecordData;


                var allSubstation = ControlInterfaceFuction.GetAllSubstation(); //获取所有分站缓存数据
                RefSubstationFiveHisDataList(allSubstation);
                RefSubstationConHisDataList(allSubstation);
                if (_refThr == null)
                {
                    _ifLoop = true;
                    _refThr = new Thread(RefThrFun)
                    {
                        IsBackground = true
                    };
                    //_refThr = new Thread(RefThrFun);
                    _refThr.Start();
                }

                LoadKhAndDzh();

                StationUpdate su = new StationUpdate();
                su.Dock     = DockStyle.Fill;
                su.TopLevel = false;
                su.TopMost  = true;
                xtraTabPage2.Controls.Add(su);
                su.Show();


                devList = deviceDefineService.GetAllDeviceDefineCache().Data;
            }
            catch (Exception exc)
            {
                XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Example #2
0
        private void Frm_AddressTypeDefine_Load(object sender, EventArgs e)
        {
            deviceDefineService = ServiceFactory.Create <IDeviceDefineService>();

            addressTypeService = ServiceFactory.Create <IKJ_AddresstypeService>();

            addresstyperuleService = ServiceFactory.Create <IKJ_AddresstyperuleService>();

            AddressTypeRuleList = new DataTable();
            AddressTypeRuleList.Columns.Add("ID");
            AddressTypeRuleList.Columns.Add("Addresstypeid");
            AddressTypeRuleList.Columns.Add("Devid");
            AddressTypeRuleList.Columns.Add("Devname");
            AddressTypeRuleList.Columns.Add("UpAlarmValue");
            AddressTypeRuleList.Columns.Add("UpPoweroffValue");
            AddressTypeRuleList.Columns.Add("LowAlarmValue");
            AddressTypeRuleList.Columns.Add("LowPoweroffValue");
            gridControl1.DataSource = AddressTypeRuleList;

            //加载人员报警设置  20171128



            if (type == 1)
            {
                AddressType = GetAddressTypeByAddressTypeID(AddressTypeid);
                if (AddressType != null)
                {
                    txt_AddressTypeName.Text = AddressType.Addresstypename;

                    List <KJ_AddresstyperuleInfo> AddressTypeRuleItems = addresstyperuleService.GetKJ_AddresstyperuleListByAddressTypeId(new Request.KJ_Addresstyperule.KJ_AddresstyperuleGetListRequest()
                    {
                        Id = AddressTypeid
                    }).Data;
                    Jc_DevInfo devInfo;
                    //加载已有规则信息
                    devItems = deviceDefineService.GetAllDeviceDefineCache().Data.OrderBy(a => a.Devid).ToList();
                    foreach (KJ_AddresstyperuleInfo item in AddressTypeRuleItems)
                    {
                        devInfo = devItems.FirstOrDefault(a => a.Devid.ToString() == item.Devid);
                        AddGridData(item.ID, item.Addresstypeid, item.Devid, devInfo == null ? "未知" : devInfo.Name,
                                    Math.Round(item.UpAlarmLowValue, 2) + "~" + Math.Round(item.UpAlarmHighValue, 2),
                                    Math.Round(item.UpPoweroffLowValue, 2) + "~" + Math.Round(item.UpPoweroffHighValue, 2),
                                    Math.Round(item.LowAlarmLowValue, 2) + "~" + Math.Round(item.LowAlarmHighValue, 2),
                                    Math.Round(item.LowPoweroffLowValue, 2) + "~" + Math.Round(item.LowPoweroffHighValue, 2));
                    }
                }
            }
            else
            {
                AddressType = null;
            }


            LoadDev();
        }
Example #3
0
        private void RealRunRecordControl_Load(object sender, EventArgs e)
        {
            inigrid();
            try
            {
                //根据配置,判断并动态加载人员采集信息显示  20180131
                string      displayPersonCollect = "1";
                SettingInfo setting = RealInterfaceFuction.GetConfigFKey("DisplayPersonCollect");
                if (setting != null)
                {
                    displayPersonCollect = setting.StrValue;
                }
                if (displayPersonCollect == "0")
                {
                    gridControl1.Visible = false;
                    mainGrid.Dock        = DockStyle.Fill;
                }
                else
                {
                    gridControl1.Visible = true;
                    mainGrid.Dock        = DockStyle.None;
                }

                devAllList = deviceDefineService.GetAllDeviceDefineCache().Data;

                //获取服务器当前时间
                var nowtime = Model.RealInterfaceFuction.GetServerNowTime();

                LastCounter = nowtime.Ticks;

                getdata();

                refresh(nowtime);
            }
            catch (Exception ex)
            {
                Basic.Framework.Logging.LogHelper.Error(ex);
            }
            //timer1.Enabled = true;
            freshthread = new Thread(new ThreadStart(fthread));
            freshthread.Start();
        }
Example #4
0
        private void LoadDev()
        {
            var result = deviceDefineService.GetAllDeviceDefineCache();

            if (result.Data != null && result.IsSuccess)
            {
                devItems = result.Data.FindAll(a => a.Type == 1 || a.Type == 2);
                devItems = devItems.OrderBy(a => a.Type).ThenBy(a => long.Parse(a.Devid)).ToList();
                for (int i = 0; i < devItems.Count; i++)
                {
                    cmb_dev.Items.Add(devItems[i].Devid + "【" + devItems[i].Name + "】");
                }
            }
        }
        /// <summary>
        /// 查询服务接口端缓存信息,并同步到网关
        /// </summary>
        /// <returns></returns>
        public static QueryCacheDataResponse QueryServiceCacheDataToGateway()
        {
            QueryCacheDataResponse queryCacheDataResponse = new QueryCacheDataResponse();
            //获取定义、设备类型、网络模块、手动/交叉控制缓存信息
            List <Jc_DefInfo>    PointDefineCacheList        = _PointDefineService.GetAllPointDefineCache().Data.FindAll(a => a.Upflag != "1");//修改,不向网关同步由子系统同步的数据  20180131
            List <Jc_DevInfo>    DeviceDefineCacheList       = _DeviceDefineService.GetAllDeviceDefineCache().Data;
            List <Jc_MacInfo>    NetworkModuleCacheList      = _NetworkModuleService.GetAllNetworkModuleCache().Data;
            List <Jc_JcsdkzInfo> ManualCrossControlCacheList = _ManualCrossControlService.GetAllManualCrossControl().Data;
            //数据转换
            List <DeviceInfo>              GatewayPointDefineCacheList        = Basic.Framework.Common.ObjectConverter.CopyList <Jc_DefInfo, DeviceInfo>(PointDefineCacheList).ToList();
            List <DeviceTypeInfo>          GatewayDeviceDefineCacheList       = Basic.Framework.Common.ObjectConverter.CopyList <Jc_DevInfo, DeviceTypeInfo>(DeviceDefineCacheList).ToList();
            List <NetworkDeviceInfo>       GatewayNetworkModuleCacheList      = Basic.Framework.Common.ObjectConverter.CopyList <Jc_MacInfo, NetworkDeviceInfo>(NetworkModuleCacheList).ToList();
            List <DeviceAcrossControlInfo> GatewayManualCrossControlCacheList = Basic.Framework.Common.ObjectConverter.CopyList <Jc_JcsdkzInfo, DeviceAcrossControlInfo>(ManualCrossControlCacheList).ToList();

            //key赋值
            foreach (DeviceInfo PointDefine in GatewayPointDefineCacheList)
            {
                PointDefine.UniqueKey = PointDefine.Point;
            }
            foreach (DeviceTypeInfo DeviceDefine in GatewayDeviceDefineCacheList)
            {
                DeviceDefine.UniqueKey = DeviceDefine.Devid;
            }
            foreach (NetworkDeviceInfo NetworkModule in GatewayNetworkModuleCacheList)
            {
                NetworkModule.UniqueKey = NetworkModule.MAC;
            }
            foreach (DeviceAcrossControlInfo ManualCrossControl in GatewayManualCrossControlCacheList)
            {
                ManualCrossControl.UniqueKey = ManualCrossControl.ID;
            }

            queryCacheDataResponse.DeviceList              = GatewayPointDefineCacheList;
            queryCacheDataResponse.DeviceTypeList          = GatewayDeviceDefineCacheList;
            queryCacheDataResponse.NetworkDeviceList       = GatewayNetworkModuleCacheList;
            queryCacheDataResponse.DeviceAcrossControlList = GatewayManualCrossControlCacheList;

            return(queryCacheDataResponse);
        }
Example #6
0
        /// <summary>
        /// 启动线程
        /// </summary>
        public void Start()
        {
            if (!_isRun)
            {
                _isRun    = true;
                PointSsz  = new List <string>();
                _rwLocker = new ReaderWriterLock();

                //读取所有设备、数据状态枚举类型
                var response = graphicsbaseinfService.GetAllDeviceEnumcode();
                dtStateVal = response.Data;

                DevInfos = devService.GetAllDeviceDefineCache().Data;


                m_PointSszThread = new Thread(setAllPointSszThread);
                //object o = mx;
                m_PointSszThread.Start();

                //注册关闭事件
                RequestUtil.OnMainFormCloseEvent += new RequestUtil.OnMainFormClose(MainFormCloseEvent);
            }
        }
Example #7
0
        private void Frm_AreaDefine_Load(object sender, EventArgs e)
        {
            deviceDefineService = ServiceFactory.Create <IDeviceDefineService>();

            areaService = ServiceFactory.Create <IAreaService>();

            areaRuleList = new DataTable();
            areaRuleList.Columns.Add("id");
            areaRuleList.Columns.Add("devid");
            areaRuleList.Columns.Add("devname");
            areaRuleList.Columns.Add("deviceCount");
            areaRuleList.Columns.Add("maxVal");
            areaRuleList.Columns.Add("minVal");
            gridControl1.DataSource = areaRuleList;

            //加载人员报警设置  20171128

            //加载默认报警时间
            AlarmTime.Text = "08:00";
            //加载默认报警类型
            AlarmType.SelectedIndex = 0;
            //加载默认超员报警人数
            RatedPersonCount.Value = 0;


            if (type == 1)
            {
                area = GetAreaByAreaID(areaid);
                if (area != null)
                {
                    position = area.AreaBound;
                    txt_areaPosition.Text     = position;
                    txt_areaPosition.ReadOnly = true;
                    txt_areaName.Text         = area.Areaname;

                    List <AreaRuleInfo> areaRuleItems = area.AreaRuleInfoList;
                    Jc_DevInfo          devInfo;
                    //加载已有规则信息
                    devItems = deviceDefineService.GetAllDeviceDefineCache().Data.OrderBy(a => a.Devid).ToList();
                    foreach (AreaRuleInfo item in areaRuleItems)
                    {
                        devInfo = devItems.FirstOrDefault(a => a.Devid.ToString() == item.Devid);
                        AddGridData(item.Devid, devInfo == null ? "未知" : devInfo.Name,
                                    item.DeviceCount.ToString(),
                                    item.MaxValue.ToString(),
                                    item.MinValue.ToString());
                    }

                    //加载已有区域人员报警信息  20171128
                    if (area.Bz1 != null)
                    {
                        AlarmTime.Text = area.Bz1.ToString();
                    }
                    if (area.Bz2 != null)
                    {
                        RatedPersonCount.Value = int.Parse(area.Bz2);
                    }
                    if (area.RestrictedpersonInfoList != null)
                    {
                        if (area.RestrictedpersonInfoList.Count > 0)
                        {
                            restrictedpersonInfoList = area.RestrictedpersonInfoList;
                            AlarmType.SelectedIndex  = area.RestrictedpersonInfoList[0].Type;
                        }
                    }
                }
            }
            else
            {
                area = null;
            }


            LoadDev();
        }
Example #8
0
 public BasicResponse <List <Jc_DevInfo> > GetAllDeviceDefineCache()
 {
     return(_DeviceDefineService.GetAllDeviceDefineCache());
 }
Example #9
0
 /// <summary>
 /// 获取所有设备类型
 /// </summary>
 /// <returns></returns>
 public static List <Jc_DevInfo> GetAllDeviceDefine()
 {
     return(deviceDefineService.GetAllDeviceDefineCache().Data);
 }
Example #10
0
        private void GetCalibrationDue()
        {
            try
            {
                List <EnumcodeInfo>            enumcodeInfos = new List <EnumcodeInfo>();
                EnumcodeInfo                   enumcodeInfo;
                EnumcodeGetByEnumTypeIDRequest enumcoderequest = new EnumcodeGetByEnumTypeIDRequest();
                enumcoderequest.EnumTypeId = "3";
                var result = enumcodeService.GetEnumcodeByEnumTypeID(enumcoderequest);
                if (result.IsSuccess & result.Data != null)
                {
                    enumcodeInfos = result.Data;
                }


                //获取设备类型及测点定义基础数据
                if (deviceDefineList.Count == 0 || bIsDevChange())
                {
                    deviceDefineList = deviceDefineService.GetAllDeviceDefineCache().Data;
                    pointDefineList  = pointDefineService.GetAllPointDefineCache().Data;
                }
                GetRealDataRequest request = new GetRealDataRequest();
                realDataList = realMessageService.GetRealData(request).Data;

                //标效及传感器到期提醒

                //查询近90天内的标效记录(统计前一天,及之前90天的记录)
                DateTime  startTime         = DateTime.Parse(DateTime.Now.AddDays(-91).ToShortDateString());
                DateTime  endTime           = DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:59:59");
                DataTable calibrationRecord = ClientAlarmServer.GetCalibrationRecord(startTime, endTime);
                //按设备类型循环获取未标校、到期的传感器数量
                int NoCalibrationCount = 0;
                int DueCount           = 0;
                foreach (Jc_DevInfo dev in deviceDefineList)
                {
                    //2018.5.9 by AI
                    enumcodeInfo = enumcodeInfos.FirstOrDefault(a => a.LngEnumValue == dev.Bz4);
                    if (enumcodeInfo == null)
                    {
                        //LogHelper.Error("【GetCalibrationDue】枚举中未找到设备:" + dev.Bz4);
                        continue;
                    }
                    int tempCalibrationTime = 0;
                    int.TryParse(dev.Pl4.ToString(), out tempCalibrationTime);//标校周期
                    List <Jc_DefInfo> pointList = pointDefineList.FindAll(a => a.Devid == dev.Devid);
                    if (tempCalibrationTime > 0)
                    {
                        #region 标效周期报警
                        //计算当前设备类型下面的传感器是否到标效期
                        foreach (Jc_DefInfo def in pointList)
                        {
                            DataRow[] dr = calibrationRecord.Select("point='" + def.Point + "' and stime<='" + endTime + "'", "stime desc");
                            if (dr.Length > 0)
                            {
                                TimeSpan ts = endTime - DateTime.Parse(dr[0]["stime"].ToString());
                                if ((int)ts.TotalDays >= tempCalibrationTime)//如果上一次标校记录时间超过了设置的标校时间周期,则记入未标校数量
                                {
                                    NoCalibrationCount++;

                                    SensorCalibrationInfo tempSensorCalibrationInfo = new SensorCalibrationInfo();
                                    tempSensorCalibrationInfo.Point               = def.Point;
                                    tempSensorCalibrationInfo.Position            = def.Wz;
                                    tempSensorCalibrationInfo.DevName             = def.DevName;
                                    tempSensorCalibrationInfo.SetCalibrationTime  = tempCalibrationTime.ToString();
                                    tempSensorCalibrationInfo.LastCalibrationTime = dr[0]["stime"].ToString();
                                    tempSensorCalibrationInfo.CalibrationDays     = ((int)(ts.TotalDays)).ToString();
                                    tempSensorCalibrationInfo.id      = dr[0]["id"].ToString();
                                    tempSensorCalibrationInfo.pointid = def.PointID;
                                    if (ClientAlarmServer.sensorCalibrationInfoList.Find(a => a.Point == tempSensorCalibrationInfo.Point) == null)
                                    {
                                        ClientAlarmServer.sensorCalibrationInfoList.Add(tempSensorCalibrationInfo);
                                    }
                                }
                                else
                                {
                                    int index = ClientAlarmServer.sensorCalibrationInfoList.FindIndex(a => a.Point == def.Point);
                                    if (index >= 0)
                                    {
                                        ClientAlarmServer.sensorCalibrationInfoList.RemoveAt(index);
                                    }
                                }
                            }
                            else//未找到标校记录,则直接记入未标校
                            {
                                NoCalibrationCount++;

                                SensorCalibrationInfo tempSensorCalibrationInfo = new SensorCalibrationInfo();
                                tempSensorCalibrationInfo.Point               = def.Point;
                                tempSensorCalibrationInfo.Position            = def.Wz;
                                tempSensorCalibrationInfo.DevName             = def.DevName;
                                tempSensorCalibrationInfo.SetCalibrationTime  = tempCalibrationTime.ToString();
                                tempSensorCalibrationInfo.LastCalibrationTime = "未记录";
                                tempSensorCalibrationInfo.CalibrationDays     = "-";
                                tempSensorCalibrationInfo.pointid             = def.PointID;
                                //tempSensorCalibrationInfo.id = dr[0]["id"].ToString();
                                if (ClientAlarmServer.sensorCalibrationInfoList.Find(a => a.Point == tempSensorCalibrationInfo.Point) == null)
                                {
                                    ClientAlarmServer.sensorCalibrationInfoList.Add(tempSensorCalibrationInfo);
                                }
                            }
                        }
                        #endregion
                    }
                }
                //清除已删除的测点
                foreach (SensorCalibrationInfo tempSensorCalibrationInfo in ClientAlarmServer.sensorCalibrationInfoList)
                {
                    if (pointDefineList.FindAll(a => a.Point == tempSensorCalibrationInfo.Point).Count == 0)//如果测点定义缓存中不存在测点,则清除未标校集合中的记录
                    {
                        ClientAlarmServer.sensorCalibrationInfoList.Remove(tempSensorCalibrationInfo);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }